hydra-editor 3.4.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.md +8 -1
- data/README.md +42 -6
- data/app/forms/hydra_editor/form.rb +10 -4
- data/app/presenters/hydra/presenter.rb +9 -4
- data/lib/hydra_editor/version.rb +1 -1
- metadata +4 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29586ab094387a98528c46f14838b7eee43af9e4
|
4
|
+
data.tar.gz: 420f5db0c3ab51aa9ad3929c3aa097da5fc2bbdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2308e0d0260e14de104d680011af09cf0bd0cdc0ba39e42098d30b4d20091d2dae2e725ef80464f9f07a6deb24348c05562d2ec977f6dc12732e16a8ae196473
|
7
|
+
data.tar.gz: 5ae0ac966fdbf43318fe7625188bce2244a27feec248b77efd981af204bfaf2e98bb3dcf247ca652a8fa8e152d7f65075b91e50f29d8d408b75f32e615277e2b
|
data/History.md
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
# History of hydra-editor releases
|
2
2
|
|
3
|
-
##
|
3
|
+
## 4.0.1
|
4
|
+
* 2018-04-25: Updated the gemspec for authors, email, and homepage
|
5
|
+
|
6
|
+
## 4.0.0
|
4
7
|
* 2018-04-25: Released after testing
|
5
8
|
|
9
|
+
## 4.0.0.rc1
|
10
|
+
* 2018-03-21: Updates HydraEditor::Form.model_attributes. [dchandekstark]
|
11
|
+
* 2018-03-21: Replace `Hydra::Presenter#to_model` delegation with `self` [no-reply]
|
12
|
+
|
6
13
|
## 3.4.0.beta
|
7
14
|
* 2018-03-05: Change FactoryGirl dependency to FactoryBot [no-reply]
|
8
15
|
* 2018-03-05: Restrict `simple_form` to `<= 3.5.0` [no-reply]
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# HydraEditor [](http://badge.fury.io/rb/hydra-editor) [](http://badge.fury.io/rb/hydra-editor) [](https://travis-ci.org/samvera/hydra-editor)
|
2
2
|
|
3
3
|
To use add to your gemfile:
|
4
4
|
|
@@ -75,9 +75,45 @@ Add the stylesheets by adding this line to your app/assets/stylesheets/applicati
|
|
75
75
|
|
76
76
|
(Note: The Javascript includes require Blacklight and must be put after that.)
|
77
77
|
|
78
|
+
## Updating to 4.0.0
|
79
|
+
|
80
|
+
* [SimpleForm](https://github.com/plataformatec/simple_form) is supported from release 3.2.0 onwards
|
81
|
+
* `#to_model` now returns `self` (previously it was the value of `@model`):
|
82
|
+
```ruby
|
83
|
+
class MyForm
|
84
|
+
include HydraEditor::Form
|
85
|
+
self.model_class = MyModel
|
86
|
+
self.terms = [:title, :creator]
|
87
|
+
# [...]
|
88
|
+
end
|
89
|
+
# [...]
|
90
|
+
some_work = MyModel.new(title: ['Black holes: The Reith Lectures.'], creator: 'S.W. Hawking')
|
91
|
+
some_form = MyForm.new(some_work)
|
92
|
+
# [...]
|
93
|
+
some_form.to_model
|
94
|
+
# => #<MyForm:0x00007fd5b2fd1468 @attributes={"id"=>nil, "title"=>["Black holes: The Reith Lectures."], "creator"=>"S.W. Hawking"}, @model=#<MyModel id: nil, title: ["Black holes: The Reith Lectures."], creator: "S.W. Hawking">>
|
95
|
+
```
|
96
|
+
* When a form field for a single value is empty, it now returns a `nil` value (as opposed to an empty `String`):
|
97
|
+
```ruby
|
98
|
+
class MyForm
|
99
|
+
include HydraEditor::Form
|
100
|
+
self.model_class = MyModel
|
101
|
+
self.terms = [:title, :creator]
|
102
|
+
# [...]
|
103
|
+
end
|
104
|
+
|
105
|
+
# [...]
|
106
|
+
values = MyForm.model_attributes(
|
107
|
+
title: ['On the distribution of values of angles determined by coplanar points.'],
|
108
|
+
creator: ''
|
109
|
+
)
|
110
|
+
values['creator']
|
111
|
+
# => nil
|
112
|
+
```
|
113
|
+
|
78
114
|
## Other customizations
|
79
115
|
|
80
|
-
By default hydra-editor provides a RecordsController with :new, :create, :edit, and :update actions implemented in the included RecordsControllerBehavior module, and a RecordsHelper module with methods implemented in RecordsHelperBehavior. If you are mounting the engine and using its routes, you can override the controller behaviors by creating your own RecordsController:
|
116
|
+
By default `hydra-editor` provides a RecordsController with :new, :create, :edit, and :update actions implemented in the included RecordsControllerBehavior module, and a RecordsHelper module with methods implemented in RecordsHelperBehavior. If you are mounting the engine and using its routes, you can override the controller behaviors by creating your own RecordsController:
|
81
117
|
|
82
118
|
```ruby
|
83
119
|
class RecordsController < ApplicationController
|
@@ -89,8 +125,8 @@ end
|
|
89
125
|
|
90
126
|
If you are not mounting the engine or using its default routes, you can include RecordsControllerBehavior in your own controller and add the appropriate routes to your app's config/routes.rb.
|
91
127
|
|
92
|
-
#
|
93
|
-
This software has been developed by and is brought to you by the
|
94
|
-
[
|
128
|
+
# Samvera
|
129
|
+
This software has been developed by and is brought to you by the Samvera community. Learn more at the
|
130
|
+
[Samvera website](https://samvera.org/)
|
95
131
|
|
96
|
-

|
@@ -56,11 +56,17 @@ module HydraEditor
|
|
56
56
|
# ImageForm.model_attributes(params[:image])
|
57
57
|
# # => { title: 'My new image' }
|
58
58
|
def model_attributes(form_params)
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
sanitize_params(form_params).tap do |clean_params|
|
60
|
+
terms.each do |key|
|
61
|
+
if clean_params[key]
|
62
|
+
if multiple?(key)
|
63
|
+
clean_params[key].delete('')
|
64
|
+
elsif clean_params[key] == ''
|
65
|
+
clean_params[key] = nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
62
69
|
end
|
63
|
-
clean_params
|
64
70
|
end
|
65
71
|
|
66
72
|
def sanitize_params(form_params)
|
@@ -14,8 +14,13 @@ module Hydra
|
|
14
14
|
@model = object
|
15
15
|
end
|
16
16
|
|
17
|
-
delegate :to_key, :to_param, :
|
18
|
-
|
17
|
+
delegate :to_key, :to_param, :persisted?, :new_record?, :[], :model_name, to: :model
|
18
|
+
|
19
|
+
##
|
20
|
+
# @return [#to_model] self
|
21
|
+
def to_model
|
22
|
+
self
|
23
|
+
end
|
19
24
|
|
20
25
|
module ClassMethods
|
21
26
|
def model_name
|
@@ -33,8 +38,8 @@ module Hydra
|
|
33
38
|
included do
|
34
39
|
class_attribute :_terms, instance_accessor: false
|
35
40
|
|
36
|
-
# You may want to set your own field_metadata_service that can
|
37
|
-
# answer the questions about a fields cardinality regardless of the
|
41
|
+
# You may want to set your own field_metadata_service that can
|
42
|
+
# answer the questions about a fields cardinality regardless of the
|
38
43
|
# cardinality of the model
|
39
44
|
class_attribute :field_metadata_service
|
40
45
|
# This default service just give us the cardiality defined in the model.
|
data/lib/hydra_editor/version.rb
CHANGED
metadata
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-editor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
- David Chandek-Stark
|
9
|
+
- Thomas Johnson
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
@@ -66,9 +67,6 @@ dependencies:
|
|
66
67
|
- - "~>"
|
67
68
|
- !ruby/object:Gem::Version
|
68
69
|
version: '3.2'
|
69
|
-
- - "<="
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
version: 3.5.0
|
72
70
|
type: :runtime
|
73
71
|
prerelease: false
|
74
72
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -76,9 +74,6 @@ dependencies:
|
|
76
74
|
- - "~>"
|
77
75
|
- !ruby/object:Gem::Version
|
78
76
|
version: '3.2'
|
79
|
-
- - "<="
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: 3.5.0
|
82
77
|
- !ruby/object:Gem::Dependency
|
83
78
|
name: sprockets-es6
|
84
79
|
requirement: !ruby/object:Gem::Requirement
|
@@ -263,7 +258,7 @@ dependencies:
|
|
263
258
|
version: '2.3'
|
264
259
|
description: A basic metadata editor for hydra-head
|
265
260
|
email:
|
266
|
-
-
|
261
|
+
- samvera-tech@googlegroups.com
|
267
262
|
executables: []
|
268
263
|
extensions: []
|
269
264
|
extra_rdoc_files: []
|
@@ -300,7 +295,7 @@ files:
|
|
300
295
|
- lib/hydra_editor/engine.rb
|
301
296
|
- lib/hydra_editor/version.rb
|
302
297
|
- lib/tasks/hydra-editor_tasks.rake
|
303
|
-
homepage: http://github.com/
|
298
|
+
homepage: http://github.com/samvera/hydra-editor
|
304
299
|
licenses: []
|
305
300
|
metadata: {}
|
306
301
|
post_install_message:
|