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 +4 -4
- data/app/controllers/concerns/records_controller_behavior.rb +14 -8
- data/app/helpers/concerns/records_helper_behavior.rb +1 -1
- data/app/views/records/_edit_field.html.erb +5 -6
- data/app/views/records/_form.html.erb +2 -2
- data/app/views/records/choose_type.html.erb +4 -5
- data/app/views/records/edit.html.erb +1 -1
- data/app/views/records/edit_fields/_default.html.erb +2 -2
- data/app/views/records/new.html.erb +1 -1
- data/config/locales/hydra_editor.yml +2 -1
- data/config/routes.rb +1 -1
- data/lib/hydra_editor/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d6f571a59f4be4e97f971fd5e70f0158e9e161b
|
4
|
+
data.tar.gz: 5872ae91386407fa5957baaa560852d89ab5f11e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 {
|
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 {
|
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,15 +1,14 @@
|
|
1
1
|
<% render_req ||= true # render_req is true for single file edit, false for batch edit%>
|
2
|
-
|
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, :
|
6
|
+
<%= f.label key, tmp.html_safe, class: "control-label" %>
|
7
7
|
<% else %>
|
8
|
-
<%= f.label key, field_label(key), :
|
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
|
-
|
15
|
-
|
14
|
+
<% end %>
|
@@ -1,9 +1,9 @@
|
|
1
|
-
<%= bootstrap_form_for resource, url: record_form_action_url(resource), html: {:
|
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 :
|
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, :
|
3
|
-
|
4
|
-
<%=
|
5
|
-
|
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,7 +1,7 @@
|
|
1
|
-
|
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
|
-
<%
|
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 :
|
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'
|
data/config/routes.rb
CHANGED
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: 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-
|
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.
|
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
|