hydra-editor 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d6f571a59f4be4e97f971fd5e70f0158e9e161b
4
- data.tar.gz: 5872ae91386407fa5957baaa560852d89ab5f11e
3
+ metadata.gz: d5887fe8d0012e6771f7692ab1283824295e18dc
4
+ data.tar.gz: 0979ec4106adb726337eeb071a818c434b05cb09
5
5
  SHA512:
6
- metadata.gz: be508501a5b4143ba7eb878a327ab6a2e1f6e1e6057a76b119c179cc396d16cace842e81dabb3bf6ab64fb280b5873e4371b27d8eb32df8f4f3d1b6d20a2b961
7
- data.tar.gz: c2c01e541df6ac515fb19bbc6d6ea1c96db479396470de5e62dffb77e4697dae8847c3798f3f3034d832f9d38b0f64a528d1bbefb726c5323b24af1fda0953c9
6
+ metadata.gz: 945c22ff3dccfbe2b50c3fdd5a190e31f5cce9175b3c8856f09c091aa1eaedaaeda8695c5fe12ecddabac744e8fc27770f7c5536d0185fe4c05293aba9539f83
7
+ data.tar.gz: 2462a7e7d9e270a5d396e6069ffce9649ecf9a2be11a1449f77b875f54c9f18c849b4cf684700164166e6a4a13331d93698de96480de061d1adc7359bdb8e891
@@ -1,6 +1,4 @@
1
- require 'deprecation'
2
1
  module RecordsHelperBehavior
3
- extend Deprecation
4
2
 
5
3
  def metadata_help(key)
6
4
  I18n.t("hydra_editor.form.metadata_help.#{key}", default: key.to_s.humanize)
@@ -22,9 +20,9 @@ module RecordsHelperBehavior
22
20
  end
23
21
  end
24
22
 
25
- def render_edit_field_partial(key, locals)
23
+ def render_edit_field_partial(field_name, locals)
26
24
  collection = ActiveSupport::Inflector.tableize(locals[:f].object.class)
27
- render_edit_field_partial_with_action(collection, key, locals)
25
+ render_edit_field_partial_with_action(collection, field_name, locals)
28
26
  end
29
27
 
30
28
  def add_field (key)
@@ -52,34 +50,34 @@ module RecordsHelperBehavior
52
50
  Array(resource.title).first
53
51
  end
54
52
 
55
- protected
56
-
57
- def render_edit_field_partial_with_action(requested_path, key, locals)
58
- path = if partial_exists?("#{requested_path}/edit_fields", key)
59
- "#{requested_path}/edit_fields/#{key}"
60
- elsif partial_exists?("records/edit_fields", key) # for backwards compatibility
61
- Deprecation.warn RecordsHelperBehavior, "Rendering view from `records/edit_fields/#{key}`. Move to #{requested_path}/edit_fields/#{key}. This will be removed in 1.0.0"
62
- "records/edit_fields/#{key}"
63
- elsif partial_exists?("#{requested_path}/edit_fields", 'default')
64
- "#{requested_path}/edit_fields/default"
65
- else
66
- "records/edit_fields/default"
53
+ protected
54
+
55
+ # This finds a partial based on the record_type and field_name
56
+ # if no partial exists for the record_type it tries using "records" as a default
57
+ def render_edit_field_partial_with_action(record_type, field_name, locals)
58
+ partial = find_edit_field_partial(record_type, field_name)
59
+ render partial: partial, locals: locals.merge({key: field_name})
60
+ end
61
+
62
+ def find_edit_field_partial(record_type, field_name)
63
+ ["#{record_type}/edit_fields/_#{field_name}", "records/edit_fields/_#{field_name}",
64
+ "#{record_type}/edit_fields/_default", "records/edit_fields/_default"].find do |partial|
65
+ logger.debug "Looking for edit field partial #{partial}"
66
+ return partial.sub(/\/_/, '/') if partial_exists?(partial)
67
67
  end
68
- render partial: path, locals: locals.merge({key: key})
69
68
  end
70
69
 
71
- def partial_exists?(path, file)
72
- lookup_context.find_all("#{path}/_#{file}").any?
70
+ def partial_exists?(partial)
71
+ lookup_context.find_all(partial).any?
73
72
  end
74
-
73
+
75
74
  def more_or_less_button(key, html_class, symbol)
76
75
  # TODO, there could be more than one element with this id on the page, but the fuctionality doesn't work without it.
77
76
  content_tag('button', class: "#{html_class} btn btn-default", id: "additional_#{key}_submit", name: "additional_#{key}") do
78
- (symbol +
77
+ (symbol +
79
78
  content_tag('span', class: 'sr-only') do
80
79
  "add another #{key.to_s}"
81
80
  end).html_safe
82
81
  end
83
82
  end
84
-
85
83
  end
@@ -1,3 +1,3 @@
1
1
  module HydraEditor
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
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: 0.5.0
4
+ version: 0.5.1
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: 2014-08-27 00:00:00.000000000 Z
12
+ date: 2014-11-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -59,20 +59,6 @@ dependencies:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: 6.3.0
62
- - !ruby/object:Gem::Dependency
63
- name: deprecation
64
- requirement: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- type: :runtime
70
- prerelease: false
71
- version_requirements: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
62
  - !ruby/object:Gem::Dependency
77
63
  name: cancancan
78
64
  requirement: !ruby/object:Gem::Requirement
@@ -238,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
224
  version: '0'
239
225
  requirements: []
240
226
  rubyforge_project:
241
- rubygems_version: 2.4.1
227
+ rubygems_version: 2.2.2
242
228
  signing_key:
243
229
  specification_version: 4
244
230
  summary: A basic metadata editor for hydra-head