hydra-editor 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +51 -0
- data/Rakefile +57 -0
- data/app/assets/javascripts/hydra-editor/editMetadata.js +4 -0
- data/app/assets/javascripts/hydra-editor/hydra-editor.js +2 -0
- data/app/assets/javascripts/hydra-editor/multiForm.js +58 -0
- data/app/assets/stylesheets/hydra-editor/application.css +13 -0
- data/app/assets/stylesheets/hydra-editor/hydra-editor.css +6 -0
- data/app/controllers/concerns/records_controller_behavior.rb +75 -0
- data/app/controllers/records_controller.rb +3 -0
- data/app/helpers/concerns/records_helper_behavior.rb +59 -0
- data/app/helpers/records_helper.rb +3 -0
- data/app/views/records/_edit_field.html.erb +15 -0
- data/app/views/records/_form.html.erb +16 -0
- data/app/views/records/choose_type.html.erb +8 -0
- data/app/views/records/edit.html.erb +3 -0
- data/app/views/records/edit_fields/_default.html.erb +10 -0
- data/app/views/records/edit_fields/_suffix.html.erb +6 -0
- data/app/views/records/new.html.erb +2 -0
- data/config/routes.rb +4 -0
- data/lib/hydra-editor.rb +12 -0
- data/lib/hydra_editor/engine.rb +8 -0
- data/lib/hydra_editor/version.rb +3 -0
- data/lib/tasks/hydra-editor_tasks.rake +4 -0
- data/spec/controllers/records_controller_spec.rb +101 -0
- data/spec/dummy/Gemfile +16 -0
- data/spec/dummy/Gemfile.lock +246 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/images/blacklight/bg.png +0 -0
- data/spec/dummy/app/assets/images/blacklight/border.png +0 -0
- data/spec/dummy/app/assets/images/blacklight/bul_sq_gry.gif +0 -0
- data/spec/dummy/app/assets/images/blacklight/checkmark.gif +0 -0
- data/spec/dummy/app/assets/images/blacklight/logo.png +0 -0
- data/spec/dummy/app/assets/images/blacklight/magnifying_glass.gif +0 -0
- data/spec/dummy/app/assets/images/blacklight/remove.gif +0 -0
- data/spec/dummy/app/assets/images/blacklight/separator.gif +0 -0
- data/spec/dummy/app/assets/images/blacklight/start_over.gif +0 -0
- data/spec/dummy/app/assets/images/rails.png +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +18 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/assets/stylesheets/blacklight.css.scss +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +10 -0
- data/spec/dummy/app/controllers/catalog_controller.rb +170 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/solr_document.rb +33 -0
- data/spec/dummy/app/models/user.rb +22 -0
- data/spec/dummy/app/views/devise/confirmations/new.html.erb +12 -0
- data/spec/dummy/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/spec/dummy/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/spec/dummy/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/spec/dummy/app/views/devise/passwords/edit.html.erb +16 -0
- data/spec/dummy/app/views/devise/passwords/new.html.erb +12 -0
- data/spec/dummy/app/views/devise/registrations/edit.html.erb +29 -0
- data/spec/dummy/app/views/devise/registrations/new.html.erb +18 -0
- data/spec/dummy/app/views/devise/sessions/new.html.erb +17 -0
- data/spec/dummy/app/views/devise/shared/_links.erb +25 -0
- data/spec/dummy/app/views/devise/unlocks/new.html.erb +12 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/SolrMarc/config-test.properties +37 -0
- data/spec/dummy/config/SolrMarc/config.properties +37 -0
- data/spec/dummy/config/SolrMarc/index.properties +97 -0
- data/spec/dummy/config/SolrMarc/index_scripts/dewey.bsh +47 -0
- data/spec/dummy/config/SolrMarc/index_scripts/format.bsh +126 -0
- data/spec/dummy/config/SolrMarc/translation_maps/README_MAPS +1 -0
- data/spec/dummy/config/SolrMarc/translation_maps/callnumber_map.properties +407 -0
- data/spec/dummy/config/SolrMarc/translation_maps/composition_era_map.properties +56 -0
- data/spec/dummy/config/SolrMarc/translation_maps/country_map.properties +379 -0
- data/spec/dummy/config/SolrMarc/translation_maps/format_map.properties +50 -0
- data/spec/dummy/config/SolrMarc/translation_maps/instrument_map.properties +101 -0
- data/spec/dummy/config/SolrMarc/translation_maps/language_map.properties +490 -0
- data/spec/dummy/config/application.rb +66 -0
- data/spec/dummy/config/boot.rb +6 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/fedora.yml +14 -0
- data/spec/dummy/config/initializers/action_dispatch_http_upload_monkey_patch.rb +12 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/devise.rb +240 -0
- data/spec/dummy/config/initializers/hydra_config.rb +28 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +12 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/jetty.yml +5 -0
- data/spec/dummy/config/locales/devise.en.yml +59 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/role_map_cucumber.yml +10 -0
- data/spec/dummy/config/role_map_development.yml +12 -0
- data/spec/dummy/config/role_map_production.yml +2 -0
- data/spec/dummy/config/role_map_test.yml +15 -0
- data/spec/dummy/config/routes.rb +66 -0
- data/spec/dummy/config/solr.yml +10 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20130415215624_devise_create_users.rb +46 -0
- data/spec/dummy/db/migrate/20130415215633_create_searches.rb +16 -0
- data/spec/dummy/db/migrate/20130415215634_create_bookmarks.rb +18 -0
- data/spec/dummy/db/migrate/20130415215635_remove_editable_fields_from_bookmarks.rb +12 -0
- data/spec/dummy/db/migrate/20130415215636_add_user_types_to_bookmarks_searches.rb +16 -0
- data/spec/dummy/db/schema.rb +53 -0
- data/spec/dummy/db/seeds.rb +7 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/doc/README_FOR_APP +2 -0
- data/spec/dummy/fedora_conf/conf/development/fedora.fcfg +953 -0
- data/spec/dummy/fedora_conf/conf/test/fedora.fcfg +953 -0
- data/spec/dummy/lib/generators/test_app_generator.rb +26 -0
- data/spec/dummy/log/development.log +78 -0
- data/spec/dummy/log/test.log +2372 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/index.html +241 -0
- data/spec/dummy/public/robots.txt +5 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/solr_conf/conf/schema.xml +433 -0
- data/spec/dummy/solr_conf/conf/solrconfig.xml +158 -0
- data/spec/dummy/solr_conf/solr.xml +35 -0
- data/spec/dummy/test/performance/browsing_test.rb +12 -0
- data/spec/dummy/test/test_helper.rb +13 -0
- data/spec/factories/users.rb +13 -0
- data/spec/helpers/records_helper_spec.rb +20 -0
- data/spec/models/bookmark_spec.rb +7 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/support/Gemfile +12 -0
- data/spec/support/audio.rb +18 -0
- data/spec/support/dummy_generator.rb +26 -0
- data/spec/support/lib/generators/test_app_generator.rb +26 -0
- 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,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,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,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,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,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
|
+
|
data/config/routes.rb
ADDED