hydra-editor 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +51 -0
  3. data/Rakefile +57 -0
  4. data/app/assets/javascripts/hydra-editor/editMetadata.js +4 -0
  5. data/app/assets/javascripts/hydra-editor/hydra-editor.js +2 -0
  6. data/app/assets/javascripts/hydra-editor/multiForm.js +58 -0
  7. data/app/assets/stylesheets/hydra-editor/application.css +13 -0
  8. data/app/assets/stylesheets/hydra-editor/hydra-editor.css +6 -0
  9. data/app/controllers/concerns/records_controller_behavior.rb +75 -0
  10. data/app/controllers/records_controller.rb +3 -0
  11. data/app/helpers/concerns/records_helper_behavior.rb +59 -0
  12. data/app/helpers/records_helper.rb +3 -0
  13. data/app/views/records/_edit_field.html.erb +15 -0
  14. data/app/views/records/_form.html.erb +16 -0
  15. data/app/views/records/choose_type.html.erb +8 -0
  16. data/app/views/records/edit.html.erb +3 -0
  17. data/app/views/records/edit_fields/_default.html.erb +10 -0
  18. data/app/views/records/edit_fields/_suffix.html.erb +6 -0
  19. data/app/views/records/new.html.erb +2 -0
  20. data/config/routes.rb +4 -0
  21. data/lib/hydra-editor.rb +12 -0
  22. data/lib/hydra_editor/engine.rb +8 -0
  23. data/lib/hydra_editor/version.rb +3 -0
  24. data/lib/tasks/hydra-editor_tasks.rake +4 -0
  25. data/spec/controllers/records_controller_spec.rb +101 -0
  26. data/spec/dummy/Gemfile +16 -0
  27. data/spec/dummy/Gemfile.lock +246 -0
  28. data/spec/dummy/README.rdoc +261 -0
  29. data/spec/dummy/Rakefile +7 -0
  30. data/spec/dummy/app/assets/images/blacklight/bg.png +0 -0
  31. data/spec/dummy/app/assets/images/blacklight/border.png +0 -0
  32. data/spec/dummy/app/assets/images/blacklight/bul_sq_gry.gif +0 -0
  33. data/spec/dummy/app/assets/images/blacklight/checkmark.gif +0 -0
  34. data/spec/dummy/app/assets/images/blacklight/logo.png +0 -0
  35. data/spec/dummy/app/assets/images/blacklight/magnifying_glass.gif +0 -0
  36. data/spec/dummy/app/assets/images/blacklight/remove.gif +0 -0
  37. data/spec/dummy/app/assets/images/blacklight/separator.gif +0 -0
  38. data/spec/dummy/app/assets/images/blacklight/start_over.gif +0 -0
  39. data/spec/dummy/app/assets/images/rails.png +0 -0
  40. data/spec/dummy/app/assets/javascripts/application.js +18 -0
  41. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  42. data/spec/dummy/app/assets/stylesheets/blacklight.css.scss +4 -0
  43. data/spec/dummy/app/controllers/application_controller.rb +10 -0
  44. data/spec/dummy/app/controllers/catalog_controller.rb +170 -0
  45. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  46. data/spec/dummy/app/models/solr_document.rb +33 -0
  47. data/spec/dummy/app/models/user.rb +22 -0
  48. data/spec/dummy/app/views/devise/confirmations/new.html.erb +12 -0
  49. data/spec/dummy/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  50. data/spec/dummy/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  51. data/spec/dummy/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  52. data/spec/dummy/app/views/devise/passwords/edit.html.erb +16 -0
  53. data/spec/dummy/app/views/devise/passwords/new.html.erb +12 -0
  54. data/spec/dummy/app/views/devise/registrations/edit.html.erb +29 -0
  55. data/spec/dummy/app/views/devise/registrations/new.html.erb +18 -0
  56. data/spec/dummy/app/views/devise/sessions/new.html.erb +17 -0
  57. data/spec/dummy/app/views/devise/shared/_links.erb +25 -0
  58. data/spec/dummy/app/views/devise/unlocks/new.html.erb +12 -0
  59. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  60. data/spec/dummy/config.ru +4 -0
  61. data/spec/dummy/config/SolrMarc/config-test.properties +37 -0
  62. data/spec/dummy/config/SolrMarc/config.properties +37 -0
  63. data/spec/dummy/config/SolrMarc/index.properties +97 -0
  64. data/spec/dummy/config/SolrMarc/index_scripts/dewey.bsh +47 -0
  65. data/spec/dummy/config/SolrMarc/index_scripts/format.bsh +126 -0
  66. data/spec/dummy/config/SolrMarc/translation_maps/README_MAPS +1 -0
  67. data/spec/dummy/config/SolrMarc/translation_maps/callnumber_map.properties +407 -0
  68. data/spec/dummy/config/SolrMarc/translation_maps/composition_era_map.properties +56 -0
  69. data/spec/dummy/config/SolrMarc/translation_maps/country_map.properties +379 -0
  70. data/spec/dummy/config/SolrMarc/translation_maps/format_map.properties +50 -0
  71. data/spec/dummy/config/SolrMarc/translation_maps/instrument_map.properties +101 -0
  72. data/spec/dummy/config/SolrMarc/translation_maps/language_map.properties +490 -0
  73. data/spec/dummy/config/application.rb +66 -0
  74. data/spec/dummy/config/boot.rb +6 -0
  75. data/spec/dummy/config/database.yml +25 -0
  76. data/spec/dummy/config/environment.rb +5 -0
  77. data/spec/dummy/config/environments/development.rb +37 -0
  78. data/spec/dummy/config/environments/production.rb +67 -0
  79. data/spec/dummy/config/environments/test.rb +37 -0
  80. data/spec/dummy/config/fedora.yml +14 -0
  81. data/spec/dummy/config/initializers/action_dispatch_http_upload_monkey_patch.rb +12 -0
  82. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  83. data/spec/dummy/config/initializers/devise.rb +240 -0
  84. data/spec/dummy/config/initializers/hydra_config.rb +28 -0
  85. data/spec/dummy/config/initializers/inflections.rb +15 -0
  86. data/spec/dummy/config/initializers/mime_types.rb +12 -0
  87. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  88. data/spec/dummy/config/initializers/session_store.rb +8 -0
  89. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  90. data/spec/dummy/config/jetty.yml +5 -0
  91. data/spec/dummy/config/locales/devise.en.yml +59 -0
  92. data/spec/dummy/config/locales/en.yml +5 -0
  93. data/spec/dummy/config/role_map_cucumber.yml +10 -0
  94. data/spec/dummy/config/role_map_development.yml +12 -0
  95. data/spec/dummy/config/role_map_production.yml +2 -0
  96. data/spec/dummy/config/role_map_test.yml +15 -0
  97. data/spec/dummy/config/routes.rb +66 -0
  98. data/spec/dummy/config/solr.yml +10 -0
  99. data/spec/dummy/db/development.sqlite3 +0 -0
  100. data/spec/dummy/db/migrate/20130415215624_devise_create_users.rb +46 -0
  101. data/spec/dummy/db/migrate/20130415215633_create_searches.rb +16 -0
  102. data/spec/dummy/db/migrate/20130415215634_create_bookmarks.rb +18 -0
  103. data/spec/dummy/db/migrate/20130415215635_remove_editable_fields_from_bookmarks.rb +12 -0
  104. data/spec/dummy/db/migrate/20130415215636_add_user_types_to_bookmarks_searches.rb +16 -0
  105. data/spec/dummy/db/schema.rb +53 -0
  106. data/spec/dummy/db/seeds.rb +7 -0
  107. data/spec/dummy/db/test.sqlite3 +0 -0
  108. data/spec/dummy/doc/README_FOR_APP +2 -0
  109. data/spec/dummy/fedora_conf/conf/development/fedora.fcfg +953 -0
  110. data/spec/dummy/fedora_conf/conf/test/fedora.fcfg +953 -0
  111. data/spec/dummy/lib/generators/test_app_generator.rb +26 -0
  112. data/spec/dummy/log/development.log +78 -0
  113. data/spec/dummy/log/test.log +2372 -0
  114. data/spec/dummy/public/404.html +26 -0
  115. data/spec/dummy/public/422.html +26 -0
  116. data/spec/dummy/public/500.html +25 -0
  117. data/spec/dummy/public/favicon.ico +0 -0
  118. data/spec/dummy/public/index.html +241 -0
  119. data/spec/dummy/public/robots.txt +5 -0
  120. data/spec/dummy/script/rails +6 -0
  121. data/spec/dummy/solr_conf/conf/schema.xml +433 -0
  122. data/spec/dummy/solr_conf/conf/solrconfig.xml +158 -0
  123. data/spec/dummy/solr_conf/solr.xml +35 -0
  124. data/spec/dummy/test/performance/browsing_test.rb +12 -0
  125. data/spec/dummy/test/test_helper.rb +13 -0
  126. data/spec/factories/users.rb +13 -0
  127. data/spec/helpers/records_helper_spec.rb +20 -0
  128. data/spec/models/bookmark_spec.rb +7 -0
  129. data/spec/spec_helper.rb +23 -0
  130. data/spec/support/Gemfile +12 -0
  131. data/spec/support/audio.rb +18 -0
  132. data/spec/support/dummy_generator.rb +26 -0
  133. data/spec/support/lib/generators/test_app_generator.rb +26 -0
  134. metadata +410 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 571d39b6d853b20a3baf98bc1d1caf420023706c
4
+ data.tar.gz: 6ac9a10325b875a13436ed242ec16be90af61437
5
+ SHA512:
6
+ metadata.gz: aa37e1d8040349218d33d67d62e33f43f495dabdc0a61caf2800e990e8347e8854aa6d8e3566ff419bdaf9a4a3f1781d4f0ad9557cd3768c474e27f61329be61
7
+ data.tar.gz: d5f804f41cb7b3d8fc043e54f1977b51110666e37ea3fced3acaed258b1d86d3e42a4e5c0cbadf5f0f504df3c87068307dd7e2fdb03010bb122b2a7fa029d1bd
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # HydraEditor
2
+
3
+ To use add to your gemfile:
4
+
5
+ ```ruby
6
+ gem 'hydra-editor'
7
+ ```
8
+
9
+ And to config/routes.rb add:
10
+
11
+ ```ruby
12
+ mount HydraEditor::Engine => '/'
13
+ ```
14
+
15
+ In your initialization set ```HydraEditor.models```
16
+
17
+ ```ruby
18
+ # config/initializers/hydra_editor.rb
19
+ HydraEditor.models = ["RecordedAudio", "PdfModel"]
20
+ ```
21
+
22
+ You can customize the names of your fields/models by adding to your translation file:
23
+
24
+ ```yaml
25
+ # config/locales/en.yml
26
+ en:
27
+ hydra:
28
+ field_label:
29
+ source2: "Alternate Source"
30
+ dateCreated: "Date Created"
31
+ dateAvailable: "Date Available"
32
+ model_label:
33
+ PdfModel: "PDF"
34
+ RecordedAudio: "audio"
35
+
36
+ ```
37
+
38
+ Expects the following interface on your hydra models:
39
+
40
+ ```terms_for_editing``` returns an array of model attributes to edit
41
+
42
+ Add the javascript by adding this line to your app/assets/javascript/application.js:
43
+
44
+ ```javascript
45
+ //= require hydra-editor/hydra-editor
46
+ ```
47
+
48
+ Add the stylesheets by adding this line to your app/assets/stylesheets/application.css:
49
+ ```css
50
+ *= require hydra-editor/hydra-editor
51
+ ```
data/Rakefile ADDED
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'HydraEditor'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+ Bundler::GemHelper.install_tasks
25
+
26
+ dummy = File.expand_path('../spec/dummy', __FILE__)
27
+ rakefile = File.join(dummy, 'Rakefile')
28
+
29
+ task :clean do
30
+ sh "rm -rf #{dummy}"
31
+ end
32
+
33
+ task :setup do
34
+ unless File.exists?("#{dummy}/Rakefile")
35
+ `rails new #{dummy}`
36
+ `cp -r spec/support/Gemfile #{dummy}/`
37
+ `cp -r spec/support/lib/generators #{dummy}/lib`
38
+ Dir.chdir(dummy) do
39
+ sh "rails g blacklight --devise"
40
+ sh "rails g hydra:head -f"
41
+ sh "rm spec/models/user_spec.rb" # generated by devise
42
+ puts "Generating test app"
43
+ sh "rails generate test_app"
44
+ puts "running migrations"
45
+ sh 'rake db:migrate db:test:prepare'
46
+ end
47
+ end
48
+ end
49
+
50
+ task :spec => :setup do
51
+ here = File.expand_path("../", __FILE__)
52
+ Dir.chdir(dummy) do
53
+ Bundler.with_clean_env do
54
+ sh "bundle exec rspec --color -I#{here}/spec #{here}/spec"
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,4 @@
1
+ $(function() {
2
+ $('form.editor').multiForm();
3
+ });
4
+
@@ -0,0 +1,2 @@
1
+ //= require hydra-editor/multiForm
2
+ //= require hydra-editor/editMetadata
@@ -0,0 +1,58 @@
1
+ (function( $ ){
2
+
3
+ $.fn.multiForm = function( options ) {
4
+
5
+ // Create some defaults, extending them with any options that were provided
6
+ var settings = $.extend( { }, options);
7
+
8
+ function addField() {
9
+ var cloneId = this.id.replace("submit", "clone");
10
+ var newId = this.id.replace("submit", "elements");
11
+ var cloneElem = $('#'+cloneId).clone();
12
+ // change the add button to a remove button
13
+ var plusbttn = cloneElem.find('#'+this.id);
14
+ plusbttn.html('-<span class="accessible-hidden">remove this '+ this.name.replace("_", " ") +'</span>');
15
+ plusbttn.on('click',removeField);
16
+
17
+ // remove the help tag on subsequent added fields
18
+ cloneElem.find('.formHelp').remove();
19
+ cloneElem.find('i').remove();
20
+ cloneElem.find('.modal-div').remove();
21
+
22
+ //clear out the value for the element being appended
23
+ //so the new element has a blank value
24
+ cloneElem.find('input[type=text]').attr("value", "");
25
+ cloneElem.find('input[type=text]').attr("required", false);
26
+
27
+ if (settings.afterAdd) {
28
+ settings.afterAdd(this, cloneElem);
29
+ }
30
+
31
+
32
+ $('#'+newId).append(cloneElem);
33
+ cloneElem.find('input[type=text]').focus();
34
+ return false;
35
+ }
36
+
37
+ function removeField () {
38
+ // get parent and remove it
39
+ $(this).parent().remove();
40
+ return false;
41
+ }
42
+
43
+ return this.each(function() {
44
+
45
+ // Tooltip plugin code here
46
+ /*
47
+ * adds additional metadata elements
48
+ */
49
+ $('.adder', this).click(addField);
50
+
51
+ $('.remover', this).click(removeField);
52
+
53
+
54
+ });
55
+
56
+ };
57
+ })( jQuery );
58
+
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,6 @@
1
+ /* use if a label should be hidden from view but available to screen readers */
2
+ .accessible-hidden {
3
+ position: absolute !important;
4
+ clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
5
+ clip: rect(1px, 1px, 1px, 1px);
6
+ }
@@ -0,0 +1,75 @@
1
+ module RecordsControllerBehavior
2
+ def new
3
+ authorize! :create, ActiveFedora::Base
4
+ unless has_valid_type?
5
+ render 'choose_type'
6
+ return
7
+ end
8
+
9
+ @record = params[:type].constantize.new
10
+ initialize_fields
11
+ end
12
+
13
+ def edit
14
+ @record = ActiveFedora::Base.find(params[:id], cast: true)
15
+ authorize! :edit, @record
16
+ initialize_fields
17
+ end
18
+
19
+ def create
20
+ authorize! :create, ActiveFedora::Base
21
+ unless has_valid_type?
22
+ redirect_to hydra_editor.new_record_path, :flash=> {error: "Lost the type"}
23
+ return
24
+ end
25
+ @record = params[:type].constantize.new
26
+ set_attributes
27
+
28
+ respond_to do |format|
29
+ if @record.save
30
+ format.html { redirect_to main_app.catalog_path(@record), notice: 'Object was successfully created.' }
31
+ # ActiveFedora::Base#to_json causes a circular reference. Do somethign easy
32
+ data = @record.terms_for_editing.inject({}) { |h,term| h[term] = @record[term]; h }
33
+ format.json { render json: data, status: :created, location: hydra_editor.record_path(@record) }
34
+ else
35
+ format.html { render action: "new" }
36
+ format.json { render json: @record.errors, status: :unprocessable_entity }
37
+ end
38
+ end
39
+
40
+ end
41
+
42
+ def update
43
+ @record = ActiveFedora::Base.find(params[:id], cast: true)
44
+ authorize! :update, @record
45
+ set_attributes
46
+ respond_to do |format|
47
+ if @record.save
48
+ format.html { redirect_to main_app.catalog_path(@record), notice: 'Object was successfully updated.' }
49
+ format.json { head :no_content }
50
+ else
51
+ format.html { render action: "edit" }
52
+ format.json { render json: @record.errors, status: :unprocessable_entity }
53
+ end
54
+ end
55
+ end
56
+
57
+ protected
58
+
59
+ # Override this method if you want to set different metadata on the object
60
+ def set_attributes
61
+ @record.attributes = params[@record.class.model_name.underscore]
62
+ end
63
+
64
+
65
+ def has_valid_type?
66
+ HydraEditor.models.include? params[:type]
67
+ end
68
+
69
+ def initialize_fields
70
+ @record.terms_for_editing.each do |key|
71
+ # if value is empty, we create an one element array to loop over for output
72
+ @record[key] = [''] if @record[key].empty?
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,3 @@
1
+ class RecordsController < ApplicationController
2
+ include RecordsControllerBehavior
3
+ end
@@ -0,0 +1,59 @@
1
+ module RecordsHelperBehavior
2
+
3
+ def metadata_help(key)
4
+ I18n.t("hydra.metadata_help.#{key}", default: key.to_s.humanize)
5
+ end
6
+
7
+ def field_label(key)
8
+ I18n.t("hydra.field_label.#{key}", default: key.to_s.humanize)
9
+ end
10
+
11
+ def model_label(key)
12
+ I18n.t("hydra.model_label.#{key}", default: key.to_s.humanize)
13
+ end
14
+
15
+ def object_type_options
16
+ @object_type_options ||= HydraEditor.models.inject({}) do |h, model|
17
+ label = model_label(model)
18
+ h["#{label[0].upcase}#{label[1..-1]}"] = model
19
+ h
20
+ end
21
+ end
22
+
23
+ def render_edit_field_partial(key, locals)
24
+ render_edit_field_partial_with_action('records', key, locals)
25
+ end
26
+
27
+ def render_batch_edit_field_partial(key, locals)
28
+ render_edit_field_partial_with_action('batch_edit', key, locals)
29
+ end
30
+
31
+ def add_field (key)
32
+ more_or_less_button(key, 'adder', '+')
33
+ end
34
+
35
+ def subtract_field (key)
36
+ more_or_less_button(key, 'remover', '-')
37
+ end
38
+
39
+ private
40
+
41
+ def render_edit_field_partial_with_action(action, key, locals)
42
+ if lookup_context.find_all("#{action}/edit_fields/_#{key}").any?
43
+ render :partial => "#{action}/edit_fields/#{key}", :locals=>locals.merge({key: key})
44
+ else
45
+ render :partial => "#{action}/edit_fields/default", :locals=>locals.merge({key: key})
46
+ end
47
+ end
48
+
49
+ def more_or_less_button(key, html_class, symbol)
50
+ # TODO, there could be more than one element with this id on the page, but the fuctionality doesn't work without it.
51
+ content_tag('button', class: "#{html_class} btn", id: "additional_#{key}_submit", name: "additional_#{key}") do
52
+ (symbol +
53
+ content_tag('span', class: 'accessible-hidden') do
54
+ "add another #{key.to_s}"
55
+ end).html_safe
56
+ end
57
+ end
58
+
59
+ end
@@ -0,0 +1,3 @@
1
+ module RecordsHelper
2
+ include RecordsHelperBehavior
3
+ end
@@ -0,0 +1,15 @@
1
+ <% render_req ||= true # render_req is true for single file edit, false for batch edit%>
2
+ <div class="control-group">
3
+ <% vals = @record[key] %>
4
+ <% if render_req && @record.required?(key) %>
5
+ <% tmp = '<span class="error">*</span>' + field_label(key) %>
6
+ <%= f.label key, tmp.html_safe, :class=>"control-label" %>
7
+ <% else %>
8
+ <%= f.label key, field_label(key), :class=>"control-label"%>
9
+ <% end %>
10
+
11
+ <% vals.to_ary.each_with_index do |v, index| %>
12
+ <%= render_edit_field_partial(key, f:f, v: v, index: index, render_req: render_req) %>
13
+ <% end %>
14
+ </div><!-- /control-group -->
15
+
@@ -0,0 +1,16 @@
1
+ <%= bootstrap_form_for @record, :url=>@record.new_record? ? hydra_editor.records_path : hydra_editor.record_path(@record), html: {:class => 'form-inline editor'} do |f| %>
2
+ <div id="descriptions_display">
3
+ <h2 class="non lower">Descriptions <small class="pull-right"><span class="error">*</span> indicates required fields</small> </h2>
4
+ <div class="well">
5
+ <% @record.terms_for_editing.each do |term| %>
6
+ <%= render :partial => "edit_field", :locals => {:f =>f, :render_req => true, :key => term } %>
7
+ <% end %>
8
+ </div><!-- /well -->
9
+ </div>
10
+ <%= hidden_field_tag :type, params[:type] %>
11
+ <%= f.actions do %>
12
+ <%= f.submit 'Save' %>
13
+ <%= f.cancel %>
14
+ <% end %>
15
+ <% end %>
16
+
@@ -0,0 +1,8 @@
1
+ <h1>Create a new record</h1>
2
+
3
+ <%= bootstrap_form_tag hydra_editor.new_record_path, :method=>:get do |f| %>
4
+ <%= bootstrap_select_tag :type, options_for_select(object_type_options) %>
5
+ <%= bootstrap_actions do %>
6
+ <%= bootstrap_submit_tag 'Next'%>
7
+ <% end %>
8
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <h1>Edit <%= Array(@record.title).first %></h1>
2
+ <%= render :partial=>'form' %>
3
+
@@ -0,0 +1,10 @@
1
+ <div class="controls" <% if index == 0 %> id="additional_<%= key.to_s %>_clone" <% end %>>
2
+ <% required = render_req && (index == 0) && @record.required?(key) %>
3
+ <%= text_field_tag "#{@record.class.model_name.underscore}[#{key.to_s}][]", v, :id => "#{@record.class.model_name.underscore}_#{key.to_s}", :class => "input-large", :required => required %>
4
+ <% unless @record.class.unique?(key) %>
5
+ <%= render :partial=>"records/edit_fields/suffix", :locals=>{key: key, index: index} %>
6
+ <% end %>
7
+ </div>
8
+ <div id="additional_<%= key %>_elements"></div>
9
+
10
+
@@ -0,0 +1,6 @@
1
+ <% if index == 0 %>
2
+ <%= add_field(key) %>
3
+ <% else %>
4
+ <%= subtract_field(key) %>
5
+ <% end %>
6
+
@@ -0,0 +1,2 @@
1
+ <h1>Create a new <%= model_label(params[:type]) %> record</h1>
2
+ <%= render :partial=>'form' %>
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ HydraEditor::Engine.routes.draw do
2
+ resources :records, only: [:new, :edit, :create, :update], :constraints => { :id => /[a-zA-Z0-9_.:]+/ }
3
+
4
+ end
@@ -0,0 +1,12 @@
1
+ require "hydra_editor/engine"
2
+ require "bootstrap_forms"
3
+
4
+ module HydraEditor
5
+ def self.models= val
6
+ @models = val
7
+ end
8
+
9
+ def self.models
10
+ @models ||= []
11
+ end
12
+ end