hydra-editor 0.4.0 → 0.5.0

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: c5937ac78d43f5fd201c63ef427ea0d6ea92a5dd
4
- data.tar.gz: 3d49662b8bee6eec6e6b9a432dc4049dc8584832
3
+ metadata.gz: 2d6f571a59f4be4e97f971fd5e70f0158e9e161b
4
+ data.tar.gz: 5872ae91386407fa5957baaa560852d89ab5f11e
5
5
  SHA512:
6
- metadata.gz: a0f9dbe37836743e76b213ecba5f70c7fa6802767ca9f904553c303fd2a359074ea1cd1f4800483b620f19ca47bceeb0dd965eeb6f7679fee974540a578ab5b5
7
- data.tar.gz: b2bb49f551f84ce0967bc757efcbdf2eabc60610310a25f2d5263fb5f589ec369ff7923ce74f47bfa8dc4beba98a9b8b423dd66cf3c4927fdd635ce7fecdb5c3
6
+ metadata.gz: be508501a5b4143ba7eb878a327ab6a2e1f6e1e6057a76b119c179cc396d16cace842e81dabb3bf6ab64fb280b5873e4371b27d8eb32df8f4f3d1b6d20a2b961
7
+ data.tar.gz: c2c01e541df6ac515fb19bbc6d6ea1c96db479396470de5e62dffb77e4697dae8847c3798f3f3034d832f9d38b0f64a528d1bbefb726c5323b24af1fda0953c9
@@ -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 'records/new' }
40
+ format.html { 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 'records/edit' }
54
+ format.html { edit }
55
55
  format.json { render json: resource.errors, status: :unprocessable_entity }
56
56
  end
57
57
  end
@@ -59,9 +59,9 @@ module RecordsControllerBehavior
59
59
 
60
60
  protected
61
61
 
62
- def object_as_json
62
+ def object_as_json
63
63
  # ActiveFedora::Base#to_json causes a circular reference (before 7.0). Do something easy
64
- resource.terms_for_editing.each_with_object({}) { |term, h| h[term] = resource[term] }
64
+ resource.terms_for_editing.each_with_object({}) { |term, h| h[term] = resource[term] }
65
65
  end
66
66
 
67
67
  # Override this method if you want to set different metadata on the object
@@ -70,13 +70,19 @@ module RecordsControllerBehavior
70
70
  end
71
71
 
72
72
  def collect_form_attributes
73
- raw_attributes = params[ActiveModel::Naming.singular(resource)]
74
- # we could probably do this with strong parameters if the gemspec depends on Rails 4+
75
- permitted_attributes = resource.terms_for_editing.each_with_object({}) { |key, attrs| attrs[key] = raw_attributes[key] if raw_attributes[key] }
76
73
  # removes attributes that were only changed by initialize_fields
77
74
  permitted_attributes.reject { |key, value| resource[key].empty? and value == [""] }
78
75
  end
79
76
 
77
+ # we could probably do this with strong parameters if the gemspec depends on Rails 4+
78
+ def permitted_attributes
79
+ resource.terms_for_editing.each_with_object({}) { |key, attrs| attrs[key] = raw_attributes[key] if raw_attributes[key] }
80
+ end
81
+
82
+ def raw_attributes
83
+ params[ActiveModel::Naming.singular(resource)]
84
+ end
85
+
80
86
  # Override to redirect to an alternate location after create
81
87
  def redirect_after_create
82
88
  main_app.catalog_path resource
@@ -93,7 +99,7 @@ module RecordsControllerBehavior
93
99
 
94
100
  def initialize_fields
95
101
  resource.terms_for_editing.each do |key|
96
- # if value is empty, we create an one element array to loop over for output
102
+ # if value is empty, we create an one element array to loop over for output
97
103
  resource[key] = [''] if resource[key].empty?
98
104
  end
99
105
  end
@@ -1,7 +1,7 @@
1
1
  require 'deprecation'
2
2
  module RecordsHelperBehavior
3
3
  extend Deprecation
4
-
4
+
5
5
  def metadata_help(key)
6
6
  I18n.t("hydra_editor.form.metadata_help.#{key}", default: key.to_s.humanize)
7
7
  end
@@ -1,15 +1,14 @@
1
1
  <% render_req ||= true # render_req is true for single file edit, false for batch edit%>
2
- <div class="form-group">
2
+ <%= f.form_group key do %>
3
3
  <% vals = f.object[key] %>
4
4
  <% if render_req && f.object.required?(key) %>
5
5
  <% tmp = '<span class="error">*</span>' + field_label(key) %>
6
- <%= f.label key, tmp.html_safe, :class=>"control-label" %>
6
+ <%= f.label key, tmp.html_safe, class: "control-label" %>
7
7
  <% else %>
8
- <%= f.label key, field_label(key), :class=>"control-label"%>
8
+ <%= f.label key, field_label(key), class: "control-label"%>
9
9
  <% end %>
10
10
 
11
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) %>
12
+ <%= render_edit_field_partial(key, f: f, v: v, index: index, render_req: render_req) %>
13
13
  <% end %>
14
- </div><!-- /control-group -->
15
-
14
+ <% end %>
@@ -1,9 +1,9 @@
1
- <%= bootstrap_form_for resource, url: record_form_action_url(resource), html: {:class => 'form-inline editor'} do |f| %>
1
+ <%= bootstrap_form_for resource, url: record_form_action_url(resource), html: {class: 'form-inline editor'} do |f| %>
2
2
  <div id="descriptions_display">
3
3
  <%= render 'records/form_header' %>
4
4
  <div class="well">
5
5
  <% f.object.terms_for_editing.each do |term| %>
6
- <%= render :partial => "records/edit_field", :locals => {:f => f, :render_req => true, :key => term } %>
6
+ <%= render partial: "records/edit_field", locals: {f: f, render_req: true, key: term } %>
7
7
  <% end %>
8
8
  </div> <!-- /well -->
9
9
  </div>
@@ -1,7 +1,6 @@
1
1
  <h1><%= t('hydra_editor.choose_type.title') %></h1>
2
- <%= bootstrap_form_tag hydra_editor.new_record_path, :method => :get do |f| %>
3
- <%= bootstrap_select_tag :type, options_for_select(object_type_options) %>
4
- <%= bootstrap_actions do %>
5
- <%= bootstrap_submit_tag 'Next' %>
6
- <% end %>
2
+ <%= bootstrap_form_tag url: hydra_editor.new_record_path, method: :get do |f| %>
3
+ <label class="control-label" for="type">Select an object type</label>
4
+ <%= select_tag :type, options_for_select(object_type_options) %>
5
+ <%= f.primary t('hydra_editor.choose_type.next') %>
7
6
  <% end %>
@@ -1,3 +1,3 @@
1
1
  <h1><%= edit_record_title %></h1>
2
- <%= render :partial=>'records/form' %>
2
+ <%= render partial: 'records/form' %>
3
3
 
@@ -1,7 +1,7 @@
1
- <div class="input-group" <% if index == 0 %> id="additional_<%= key.to_s %>_clone" <% end %>>
1
+ <div class="<%= 'input-group' if f.object.class.multiple?(key) %>" <% if index == 0 %> id="additional_<%= key.to_s %>_clone" <% end %>>
2
2
  <% required = render_req && index == 0 && f.object.required?(key) %>
3
3
  <%= text_field_tag "#{ActiveModel::Naming.singular(f.object)}[#{key.to_s}][]", v, id: "#{ActiveModel::Naming.singular(f.object)}_#{key.to_s}", class: "form-control", required: required %>
4
- <% unless f.object.class.unique?(key) %>
4
+ <% if f.object.class.multiple?(key) %>
5
5
  <%= render "records/edit_fields/suffix", {key: key, index: index} %>
6
6
  <% end %>
7
7
  </div>
@@ -1,2 +1,2 @@
1
1
  <h1><%= new_record_title %></h1>
2
- <%= render :partial=>'records/form' %>
2
+ <%= render partial: 'records/form' %>
@@ -2,10 +2,11 @@ en:
2
2
  hydra_editor:
3
3
  choose_type:
4
4
  title: 'Create a New Record'
5
+ next: 'Next'
5
6
  edit:
6
7
  title: 'Edit %s'
7
8
  form:
8
9
  title: 'Descriptions'
9
10
  required_fields: 'indicates required fields'
10
11
  new:
11
- title: 'Create a New %s Record'
12
+ title: 'Create a New %s Record'
@@ -1,3 +1,3 @@
1
1
  HydraEditor::Engine.routes.draw do
2
- resources :records, only: [:new, :edit, :create, :update], :constraints => { :id => /[a-zA-Z0-9_.:\-]+/ }
2
+ resources :records, only: [:new, :edit, :create, :update], constraints: { id: /[a-zA-Z0-9_.:\-]+/ }
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module HydraEditor
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
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.4.0
4
+ version: 0.5.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: 2014-07-03 00:00:00.000000000 Z
12
+ date: 2014-08-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -238,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
238
  version: '0'
239
239
  requirements: []
240
240
  rubyforge_project:
241
- rubygems_version: 2.2.2
241
+ rubygems_version: 2.4.1
242
242
  signing_key:
243
243
  specification_version: 4
244
244
  summary: A basic metadata editor for hydra-head