hydra-editor 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +15 -0
- data/app/assets/javascripts/hydra-editor/hydra-editor.js +0 -1
- data/app/assets/javascripts/hydra-editor/manage_repeating_fields.js +2 -2
- data/app/assets/stylesheets/hydra-editor/multi_value_fields.scss +4 -0
- data/app/forms/hydra_editor/form.rb +5 -1
- data/app/inputs/multi_value_input.rb +7 -1
- data/app/presenters/hydra/presenter.rb +15 -5
- data/app/services/hydra_editor/field_metadata_service.rb +16 -0
- data/app/views/records/_form_header.html.erb +5 -4
- data/app/views/records/edit_fields/_default.html.erb +1 -1
- data/config/jetty.yml +1 -1
- data/config/locales/hydra_editor.yml +3 -0
- data/lib/hydra_editor/version.rb +1 -1
- metadata +4 -4
- data/app/assets/javascripts/hydra-editor/keyboard_support.js +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd1419f83e2d52941a3816a3087a012fd80bc98f
|
4
|
+
data.tar.gz: a0ca374521dd0fb94acdb553cd5fb9cd74666558
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ad0aad1cd3fdcf694bcf318f076107ef8c6b4bc108cd51e6e6fef4d8663b53504e25fce8010f0344692d0a1e51fb39654d50ee84036632155bb57b0aafe8b6e
|
7
|
+
data.tar.gz: d11f4e9817c7daa1aac868cb32890776ba364cb2f9855ded3c119da725334a241ac5a1d3820b6b202311c0537d73f24f5520f0045a27fb30c79877bf9e1490ed
|
data/History.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
# History of hydra-editor releases
|
2
2
|
|
3
|
+
## 1.1.0
|
4
|
+
* 2015-10-09: multiple? shouldn't raise errors when confronted with non-properties [Justin Coyne]
|
5
|
+
* 2015-09-17: Add an instance method version of multiple? [Justin Coyne]
|
6
|
+
* 2015-09-17: Update build matrix [Justin Coyne]
|
7
|
+
* 2015-09-17: Make add and remove button the same size [Justin Coyne]
|
8
|
+
* 2015-09-17: Use property instead of deprecated has_attributes [Justin Coyne]
|
9
|
+
* 2015-09-17: Pin bootstrap-sass to 3.3.4.1 for rails 4.1 build [Justin Coyne]
|
10
|
+
* 2015-06-10: Use html-safe translation to avoid raw() call [Jeremy Echols]
|
11
|
+
* 2015-04-23: Add <kbd> tags for more semantic form instructions [Jeremy Echols]
|
12
|
+
* 2015-04-21: Allow overriding jetty port [Jeremy Echols]
|
13
|
+
* 2015-04-21: Add form instructions for screen readers [Jeremy Echols]
|
14
|
+
* 2015-04-17: Don't hardcode a version of hydra-head in the test app [Justin Coyne]
|
15
|
+
* 2015-04-16: Split option-building from field-building [Jeremy Echols]
|
16
|
+
* 2015-04-14: Make [ENTER] default to submit the form [Jeremy Echols]
|
17
|
+
|
3
18
|
## 1.0.3
|
4
19
|
* 2015-04-02: Updated README with info on how to set form labels [val99erie]
|
5
20
|
* 2015-03-30: Add documentation to Form#model_attributes. (ci skip) [Justin Coyne]
|
@@ -8,8 +8,8 @@ var HydraEditor = (function($) {
|
|
8
8
|
this.options = options;
|
9
9
|
|
10
10
|
this.controls = $("<span class=\"input-group-btn field-controls\">");
|
11
|
-
this.remover = $("<button class=\"btn btn-danger remove\"><i class=\"icon-white glyphicon-minus\"></i><span>Remove</span></button>");
|
12
|
-
this.adder = $("<button class=\"btn btn-success add\"><i class=\"icon-white glyphicon-plus\"></i><span>Add</span></button>");
|
11
|
+
this.remover = $("<button type=\"button\" class=\"btn btn-danger remove\"><i class=\"icon-white glyphicon-minus\"></i><span>Remove</span></button>");
|
12
|
+
this.adder = $("<button type=\"button\" class=\"btn btn-success add\"><i class=\"icon-white glyphicon-plus\"></i><span>Add</span></button>");
|
13
13
|
|
14
14
|
this.fieldWrapperClass = '.field-wrapper';
|
15
15
|
this.warningClass = '.has-warning';
|
@@ -45,6 +45,10 @@ module HydraEditor
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
def multiple?(field)
|
49
|
+
HydraEditor::FieldMetadataService.multiple?(model_class, field)
|
50
|
+
end
|
51
|
+
|
48
52
|
# Return a hash of all the parameters from the form as a hash.
|
49
53
|
# This is typically used by the controller as the main read interface to the form.
|
50
54
|
# This hash can then be used to create or update an object in the data store.
|
@@ -90,7 +94,7 @@ module HydraEditor
|
|
90
94
|
# override this method if you need to initialize more complex RDF assertions (b-nodes)
|
91
95
|
def initialize_field(key)
|
92
96
|
# if value is empty, we create an one element array to loop over for output
|
93
|
-
if
|
97
|
+
if multiple?(key)
|
94
98
|
self[key] = ['']
|
95
99
|
else
|
96
100
|
self[key] = ''
|
@@ -39,7 +39,7 @@ class MultiValueInput < SimpleForm::Inputs::CollectionInput
|
|
39
39
|
# Although the 'index' parameter is not used in this implementation it is useful in an
|
40
40
|
# an overridden version of this method, especially when the field is a complex object and
|
41
41
|
# the override defines nested fields.
|
42
|
-
def
|
42
|
+
def build_field_options(value, index)
|
43
43
|
options = input_html_options.dup
|
44
44
|
|
45
45
|
options[:value] = value
|
@@ -53,6 +53,12 @@ class MultiValueInput < SimpleForm::Inputs::CollectionInput
|
|
53
53
|
options[:class] += ["#{input_dom_id} form-control multi-text-field"]
|
54
54
|
options[:'aria-labelledby'] = label_id
|
55
55
|
@rendered_first_element = true
|
56
|
+
|
57
|
+
options
|
58
|
+
end
|
59
|
+
|
60
|
+
def build_field(value, index)
|
61
|
+
options = build_field_options(value, index)
|
56
62
|
if options.delete(:type) == 'textarea'.freeze
|
57
63
|
@builder.text_area(attribute_name, options)
|
58
64
|
else
|
@@ -3,6 +3,10 @@ module Hydra
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
included do
|
5
5
|
attr_reader :model
|
6
|
+
|
7
|
+
# model_class only needs to be set if you are using the
|
8
|
+
# deprecated class methods multiple? or unique? or if you
|
9
|
+
# need to use +model_name+ method or if this class includes Hydra::Editor::Form.
|
6
10
|
class_attribute :model_class
|
7
11
|
end
|
8
12
|
|
@@ -51,16 +55,22 @@ module Hydra
|
|
51
55
|
self.class._terms
|
52
56
|
end
|
53
57
|
|
58
|
+
# If the field is a reflection, delegate to the reflection.
|
59
|
+
# If the field is a property, delegate to the property.
|
60
|
+
# Otherwise return false
|
61
|
+
def multiple?(field)
|
62
|
+
HydraEditor::FieldMetadataService.multiple?(model.class, field)
|
63
|
+
end
|
64
|
+
|
54
65
|
module ClassMethods
|
66
|
+
# @deprecated Because if we use an instance method, there will be no need to set self.model_class in most instances. Note, there is a class method multiple? on the form.
|
55
67
|
def multiple?(field)
|
56
|
-
|
57
|
-
|
58
|
-
else
|
59
|
-
model_class.multiple?(field)
|
60
|
-
end
|
68
|
+
Deprecation.warn(ClassMethods, "The class method multiple? has been deprecated. Use the instance method instead. This will be removed in version 2.0")
|
69
|
+
HydraEditor::FieldMetadataService.multiple?(model_class, field)
|
61
70
|
end
|
62
71
|
|
63
72
|
def unique?(field)
|
73
|
+
Deprecation.warn(ClassMethods, "The class method unique? has been deprecated. Use the instance method 'multiple?' instead. This will be removed in version 2.0")
|
64
74
|
if reflection = model_class.reflect_on_association(field)
|
65
75
|
!reflection.collection?
|
66
76
|
else
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module HydraEditor
|
2
|
+
class FieldMetadataService
|
3
|
+
# If the field is a reflection, delegate to the reflection.
|
4
|
+
# If the field is a property, delegate to the property.
|
5
|
+
# Otherwise return false
|
6
|
+
def self.multiple?(model_class, field)
|
7
|
+
if reflection = model_class.reflect_on_association(field)
|
8
|
+
reflection.collection?
|
9
|
+
elsif model_class.attribute_names.include?(field.to_s)
|
10
|
+
model_class.multiple?(field)
|
11
|
+
else
|
12
|
+
false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
<p class="instructions"><%= t('hydra_editor.form.instructions_html') %></p>
|
2
|
+
<h2 class="non lower">
|
3
|
+
<%= t('hydra_editor.form.title') %>
|
4
|
+
<small class="pull-right"><span class="error">*</span> <%= t('hydra_editor.form.required_fields') %></small>
|
5
|
+
</h2>
|
data/config/jetty.yml
CHANGED
@@ -8,5 +8,8 @@ en:
|
|
8
8
|
form:
|
9
9
|
title: 'Descriptions'
|
10
10
|
required_fields: 'indicates required fields'
|
11
|
+
instructions_html: 'Use the <kbd>Tab</kbd> key to navigate the form, press
|
12
|
+
<kbd>Space</kbd> to activate a button, and press
|
13
|
+
<kbd>Enter</kbd> to submit the whole form.'
|
11
14
|
new:
|
12
15
|
title: 'Create a New %s Record'
|
data/lib/hydra_editor/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-editor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-10-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -191,7 +191,6 @@ files:
|
|
191
191
|
- Rakefile
|
192
192
|
- app/assets/javascripts/hydra-editor/editMetadata.js
|
193
193
|
- app/assets/javascripts/hydra-editor/hydra-editor.js
|
194
|
-
- app/assets/javascripts/hydra-editor/keyboard_support.js
|
195
194
|
- app/assets/javascripts/hydra-editor/manage_repeating_fields.js
|
196
195
|
- app/assets/stylesheets/hydra-editor/hydra-editor.scss
|
197
196
|
- app/assets/stylesheets/hydra-editor/multi_value_fields.scss
|
@@ -203,6 +202,7 @@ files:
|
|
203
202
|
- app/helpers/records_helper.rb
|
204
203
|
- app/inputs/multi_value_input.rb
|
205
204
|
- app/presenters/hydra/presenter.rb
|
205
|
+
- app/services/hydra_editor/field_metadata_service.rb
|
206
206
|
- app/views/records/_form.html.erb
|
207
207
|
- app/views/records/_form_header.html.erb
|
208
208
|
- app/views/records/choose_type.html.erb
|
@@ -237,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
237
|
version: '0'
|
238
238
|
requirements: []
|
239
239
|
rubyforge_project:
|
240
|
-
rubygems_version: 2.4.5
|
240
|
+
rubygems_version: 2.4.5.1
|
241
241
|
signing_key:
|
242
242
|
specification_version: 4
|
243
243
|
summary: A basic metadata editor for hydra-head
|
@@ -1,14 +0,0 @@
|
|
1
|
-
Blacklight.onLoad(function() {
|
2
|
-
$('body').on('keypress', '.multi-text-field', function(event) {
|
3
|
-
var $activeField = $(event.target).parents('.field-wrapper'),
|
4
|
-
$activeFieldControls = $activeField.children('.field-controls'),
|
5
|
-
$addControl = $activeFieldControls.children('.add'),
|
6
|
-
$removeControl = $activeFieldControls.children('.remove');
|
7
|
-
if (event.keyCode == 13) {
|
8
|
-
event.preventDefault();
|
9
|
-
$addControl.click()
|
10
|
-
$removeControl.click()
|
11
|
-
}
|
12
|
-
});
|
13
|
-
});
|
14
|
-
|