hydra-editor 0.2.1 → 0.2.2

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: 2b812815848fd931a305e6daaeba0d4bd37a2e3b
4
- data.tar.gz: e76c5b91ae1e127edede454955484f66946470f5
3
+ metadata.gz: ef71ded0d1bc1ff49e2532decb6d4c9c5154151f
4
+ data.tar.gz: b3ec457db08eefcf939a2887514922727693fe80
5
5
  SHA512:
6
- metadata.gz: fe045f0271232ab10b264b43372283e0da24cf81c3b00de27e8d335556e843523dbcf3190f7946c287a71efce8b9c0e3906bfcda3cb9699376a2719473230e36
7
- data.tar.gz: 83ad623003fd061b2fdbc17fd4cd9a59b7880b57907e4e4bdc4207866b51fe638bfc9fba330d49dadac3cc27dacfdff0b7ea721e45cd3260b7cc840d4f2c791b
6
+ metadata.gz: 32d9db8b9c5f6f4d956e42455cffc1064e3b92bc4dadf37d4c8be01454be03dc95b389eaf80f5cd7735eccab1dfcadfeab67a2bcfe4f244ec01899e6c2297220
7
+ data.tar.gz: 5a25a6e826b9e3fbaa2992bf9af345218a78b21e6b8557fc1083b863bf629edc0fbf9e22b6836aeb410734b2933d550a83003f2eee39a08db626b4c870673906
@@ -37,7 +37,7 @@ module RecordsControllerBehavior
37
37
  format.html { redirect_to redirect_after_create, notice: 'Object was successfully created.' }
38
38
  format.json { render json: object_as_json, status: :created, location: redirect_after_create }
39
39
  else
40
- format.html { render action: "new" }
40
+ format.html { render 'records/new' }
41
41
  format.json { render json: resource.errors, status: :unprocessable_entity }
42
42
  end
43
43
  end
@@ -51,7 +51,7 @@ module RecordsControllerBehavior
51
51
  format.html { redirect_to redirect_after_update, notice: 'Object was successfully updated.' }
52
52
  format.json { head :no_content }
53
53
  else
54
- format.html { render action: "edit" }
54
+ format.html { render 'records/edit' }
55
55
  format.json { render json: resource.errors, status: :unprocessable_entity }
56
56
  end
57
57
  end
@@ -1,4 +1,6 @@
1
+ require 'deprecation'
1
2
  module RecordsHelperBehavior
3
+ extend Deprecation
2
4
 
3
5
  def metadata_help(key)
4
6
  I18n.t("hydra_editor.form.metadata_help.#{key}", default: key.to_s.humanize)
@@ -21,7 +23,8 @@ module RecordsHelperBehavior
21
23
  end
22
24
 
23
25
  def render_edit_field_partial(key, locals)
24
- render_edit_field_partial_with_action('records', key, locals)
26
+ collection = ActiveSupport::Inflector.tableize(locals[:f].object.class)
27
+ render_edit_field_partial_with_action(collection, key, locals)
25
28
  end
26
29
 
27
30
  def add_field (key)
@@ -49,14 +52,24 @@ module RecordsHelperBehavior
49
52
  Array(resource.title).first
50
53
  end
51
54
 
52
- private
55
+ protected
53
56
 
54
- def render_edit_field_partial_with_action(action, key, locals)
55
- if lookup_context.find_all("#{action}/edit_fields/_#{key}").any?
56
- render :partial => "#{action}/edit_fields/#{key}", :locals=>locals.merge({key: key})
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"
57
65
  else
58
- render :partial => "#{action}/edit_fields/default", :locals=>locals.merge({key: key})
66
+ "records/edit_fields/default"
59
67
  end
68
+ render partial: path, locals: locals.merge({key: key})
69
+ end
70
+
71
+ def partial_exists?(path, file)
72
+ lookup_context.find_all("#{path}/_#{file}").any?
60
73
  end
61
74
 
62
75
  def more_or_less_button(key, html_class, symbol)
@@ -1,3 +1,3 @@
1
1
  module HydraEditor
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
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.2.1
4
+ version: 0.2.2
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-01-03 00:00:00.000000000 Z
12
+ date: 2014-01-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -59,6 +59,20 @@ 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'
62
76
  - !ruby/object:Gem::Dependency
63
77
  name: sqlite3
64
78
  requirement: !ruby/object:Gem::Requirement