hydra-editor 1.2.0 → 2.0.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: a3c7bcefdae8a2a708950ca465f1a8fd1681c0ed
4
- data.tar.gz: 30897bee5326cf52c481968e43a303b1639f8816
3
+ metadata.gz: a4b9156e8136c594af4e76af76ea7fe527a1b972
4
+ data.tar.gz: 0d9d6a7c2c63353b27c5a059531c1ed37dd2b2c7
5
5
  SHA512:
6
- metadata.gz: 423d8220008a8c5cdab2da1097d6873da0e1f6ffd7a3c997e01004ae8adef4f4742c8a1089d0d43db4a62d4e806a55b5d24d1273fe1fedc7336a663f6eafb29d
7
- data.tar.gz: 5449e1cd9d8bda697ab1d727c978742c530d717d76754cac82bf6893a42779a5adc00ac2b0f498f4f9965110752e3346d85a15678607092779b91fbabbe05389
6
+ metadata.gz: 341432004b0c7624c3f60bae5830511f54372af022e79642482fbc618fc2bc59cd4536c101402dadbf91ef8e22eb10c0c0090a4e5adbe35679aae881cc391465
7
+ data.tar.gz: c9bfeba5d7ff247557fee88700fb38a7f9b10df123eb065711abef9d0a80f9dbe53fe9a8d7baba7eec34d6cae01a37910926b4396d8e14dca9b400f4fc54bf97
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- # HydraEditor [![Gem Version](https://badge.fury.io/rb/hydra-editor.png)](http://badge.fury.io/rb/hydra-editor) [![Build Status](https://travis-ci.org/projecthydra-labs/hydra-editor.png)](https://travis-ci.org/projecthydra-labs/hydra-editor)
2
-
1
+ # HydraEditor [![Gem Version](https://badge.fury.io/rb/hydra-editor.png)](http://badge.fury.io/rb/hydra-editor) [![Build Status](https://travis-ci.org/projecthydra/hydra-editor.png)](https://travis-ci.org/projecthydra/hydra-editor)
3
2
 
4
3
  To use add to your gemfile:
5
4
 
@@ -7,6 +6,16 @@ To use add to your gemfile:
7
6
  gem 'hydra-editor'
8
7
  ```
9
8
 
9
+ Then run:
10
+ ```
11
+ bundle install
12
+ ```
13
+
14
+ Next generate the bootstrap form layouts:
15
+ ```
16
+ rails generate simple_form:install --bootstrap
17
+ ```
18
+
10
19
  And to config/routes.rb add:
11
20
 
12
21
  ```ruby
@@ -79,3 +88,9 @@ end
79
88
  ```
80
89
 
81
90
  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
+
92
+ # Project Hydra
93
+ This software has been developed by and is brought to you by the Hydra community. Learn more at the
94
+ [Project Hydra website](http://projecthydra.org)
95
+
96
+ ![Project Hydra Logo](https://github.com/uvalib/libra-oa/blob/a6564a9e5c13b7873dc883367f5e307bf715d6cf/public/images/powered_by_hydra.png?raw=true)
data/Rakefile CHANGED
@@ -25,15 +25,25 @@ Bundler::GemHelper.install_tasks
25
25
  require 'rspec/core/rake_task'
26
26
  RSpec::Core::RakeTask.new(:spec)
27
27
 
28
- require 'jettywrapper'
29
- Jettywrapper.hydra_jetty_version = "v8.1.1"
30
-
28
+ require 'solr_wrapper/rake_task'
29
+ require 'fcrepo_wrapper'
30
+ require 'active_fedora/rake_support'
31
31
  require 'engine_cart/rake_task'
32
32
 
33
- task ci: ['engine_cart:generate', 'jetty:clean'] do
33
+ require 'jasmine'
34
+ load 'jasmine/tasks/jasmine.rake'
35
+
36
+ # Set up the test application prior to running jasmine tasks.
37
+ task 'jasmine:require' => :setup_test_server
38
+ task :setup_test_server do
39
+ require 'engine_cart'
40
+ EngineCart.load_application!
41
+ end
42
+
43
+ desc 'Continuous Integration'
44
+ task ci: ['engine_cart:generate'] do
34
45
  ENV['environment'] = "test"
35
- jetty_params = Jettywrapper.load_config
36
- error = Jettywrapper.wrap(jetty_params) do
46
+ with_test_server do
37
47
  Rake::Task['spec'].invoke
38
48
  end
39
49
  end
@@ -7,13 +7,13 @@ var HydraEditor = (function($) {
7
7
  this.element = $(element);
8
8
  this.options = options;
9
9
 
10
- this.controls = $("<span class=\"input-group-btn field-controls\">");
11
- this.remover = $("<button type=\"button\" class=\"btn btn-danger remove\"><i class=\"icon-white glyphicon-minus\"></i><span>Remove</span></button>");
12
- this.adder = $("<button type=\"button\" class=\"btn btn-success add\"><i class=\"icon-white glyphicon-plus\"></i><span>Add</span></button>");
10
+ this.controls = $(options.controlsHtml);
11
+ this.remover = $(options.removeButtonHtml);
12
+ this.adder = $(options.addButtonHtml);
13
13
 
14
- this.fieldWrapperClass = '.field-wrapper';
15
- this.warningClass = '.has-warning';
16
- this.listClass = '.listing';
14
+ this.fieldWrapperClass = options.fieldWrapperClass;
15
+ this.warningClass = options.warningClass;
16
+ this.listClass = options.listClass;
17
17
 
18
18
  this.init();
19
19
  }
@@ -121,8 +121,18 @@ var HydraEditor = (function($) {
121
121
  }
122
122
 
123
123
  FieldManager.DEFAULTS = {
124
- add: null,
125
- remove: null
124
+ /* callback to run after add is called */
125
+ add: null,
126
+ /* callback to run after remove is called */
127
+ remove: null,
128
+
129
+
130
+ controlsHtml: "<span class=\"input-group-btn field-controls\">",
131
+ addButtonHtml: "<button type=\"button\" class=\"btn btn-success add\"><i class=\"icon-white glyphicon-plus\"></i><span>More</span></button>",
132
+ removeButtonHtml: "<button type=\"button\" class=\"btn btn-danger remove\"><i class=\"icon-white glyphicon-minus\"></i><span>Remove</span></button>",
133
+ warningClass: '.has-warning',
134
+ listClass: '.listing',
135
+ fieldWrapperClass: '.field-wrapper'
126
136
  }
127
137
 
128
138
  return { FieldManager: FieldManager };
@@ -16,7 +16,7 @@ module RecordsControllerBehavior
16
16
  HydraEditor::ControllerResource
17
17
  end
18
18
  def resource_instance_name
19
- name.sub("Controller", "").underscore.split('/').last.singularize
19
+ name.sub('Controller', '').underscore.split('/').last.singularize
20
20
  end
21
21
  end
22
22
 
@@ -32,7 +32,6 @@ module RecordsControllerBehavior
32
32
 
33
33
  def create
34
34
  set_attributes
35
-
36
35
  respond_to do |format|
37
36
  if resource.save
38
37
  format.html { redirect_to redirect_after_create, notice: 'Object was successfully created.' }
@@ -42,7 +41,6 @@ module RecordsControllerBehavior
42
41
  format.json { render json: resource.errors, status: :unprocessable_entity }
43
42
  end
44
43
  end
45
-
46
44
  end
47
45
 
48
46
  def update
@@ -58,7 +56,7 @@ module RecordsControllerBehavior
58
56
  end
59
57
  end
60
58
 
61
- protected
59
+ protected
62
60
 
63
61
  def object_as_json
64
62
  resource.to_json
@@ -102,7 +100,7 @@ module RecordsControllerBehavior
102
100
  end
103
101
 
104
102
  def form_name
105
- if resource_instance_name == 'record'.freeze
103
+ if resource_instance_name == 'record'
106
104
  if params[:id]
107
105
  "#{resource.class.name}Form"
108
106
  elsif has_valid_type?
@@ -132,5 +130,4 @@ module RecordsControllerBehavior
132
130
  def resource_instance_name
133
131
  self.class.resource_instance_name
134
132
  end
135
-
136
133
  end
@@ -85,6 +85,7 @@ module HydraEditor
85
85
  end
86
86
 
87
87
  protected
88
+
88
89
  def initialize_fields
89
90
  # we're making a local copy of the attributes that we can modify.
90
91
  @attributes = model.attributes
@@ -4,7 +4,6 @@ module HydraEditor
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  module ClassMethods
7
-
8
7
  def build_permitted_params
9
8
  permitted = super
10
9
  permitted << { permissions_attributes: [:type, :name, :access, :id, :_destroy] }
@@ -15,9 +14,7 @@ module HydraEditor
15
14
  # This is required so that fields_for will draw a nested form.
16
15
  # See ActionView::Helpers#nested_attributes_association?
17
16
  # https://github.com/rails/rails/blob/a04c0619617118433db6e01b67d5d082eaaa0189/actionview/lib/action_view/helpers/form_helper.rb#L1890
18
- def permissions_attributes= attributes
19
- model.permissions_attributes= attributes
20
- end
17
+ delegate :permissions_attributes=, to: :model
21
18
  end
22
19
  end
23
20
  end
@@ -5,9 +5,9 @@ module RecordsHelperBehavior
5
5
 
6
6
  def object_type_options
7
7
  @object_type_options ||= HydraEditor.models.inject({}) do |h, model|
8
- label = model_label(model)
9
- h["#{label[0].upcase}#{label[1..-1]}"] = model
10
- h
8
+ label = model_label(model)
9
+ h["#{label[0].upcase}#{label[1..-1]}"] = model
10
+ h
11
11
  end
12
12
  end
13
13
 
@@ -33,7 +33,7 @@ module RecordsHelperBehavior
33
33
  Array(form.title).first
34
34
  end
35
35
 
36
- protected
36
+ protected
37
37
 
38
38
  # This finds a partial based on the record_type and field_name
39
39
  # if no partial exists for the record_type it tries using "records" as a default
@@ -44,7 +44,7 @@ module RecordsHelperBehavior
44
44
 
45
45
  def find_edit_field_partial(record_type, field_name)
46
46
  ["#{record_type}/edit_fields/_#{field_name}", "records/edit_fields/_#{field_name}",
47
- "#{record_type}/edit_fields/_default", "records/edit_fields/_default"].find do |partial|
47
+ "#{record_type}/edit_fields/_default", 'records/edit_fields/_default'].find do |partial|
48
48
  logger.debug "Looking for edit field partial #{partial}"
49
49
  return partial.sub(/\/_/, '/') if partial_exists?(partial)
50
50
  end
@@ -1,7 +1,7 @@
1
1
  class MultiValueInput < SimpleForm::Inputs::CollectionInput
2
2
  def input(wrapper_options)
3
3
  @rendered_first_element = false
4
- input_html_classes.unshift("string")
4
+ input_html_classes.unshift('string')
5
5
  input_html_options[:name] ||= "#{object_name}[#{attribute_name}][]"
6
6
 
7
7
  outer_wrapper do
@@ -25,9 +25,8 @@ class MultiValueInput < SimpleForm::Inputs::CollectionInput
25
25
  " <ul class=\"listing\">\n #{yield}\n </ul>\n"
26
26
  end
27
27
 
28
-
29
28
  def inner_wrapper
30
- <<-HTML
29
+ <<-HTML
31
30
  <li class="field-wrapper">
32
31
  #{yield}
33
32
  </li>
@@ -14,25 +14,8 @@ module Hydra
14
14
  @model = object
15
15
  end
16
16
 
17
- def to_key
18
- model.to_key
19
- end
20
-
21
- def to_param
22
- model.to_param
23
- end
24
-
25
- def to_model
26
- model.to_model
27
- end
28
-
29
- def persisted?
30
- model.persisted?
31
- end
32
-
33
- def [](key)
34
- model[key]
35
- end
17
+ delegate :to_key, :to_param, :to_model, :persisted?, :new_record?,
18
+ :[], to: :model
36
19
 
37
20
  module ClassMethods
38
21
  def model_name
@@ -65,7 +48,7 @@ module Hydra
65
48
  module ClassMethods
66
49
  # @deprecated Because if we use an instance method, there will be no need to set self.model_class in most instances. Note, there is a class method multiple? on the form.
67
50
  def multiple?(field)
68
- Deprecation.warn(ClassMethods, "The class method multiple? has been deprecated. Use the instance method instead. This will be removed in version 2.0")
51
+ Deprecation.warn(ClassMethods, 'The class method multiple? has been deprecated. Use the instance method instead. This will be removed in version 2.0')
69
52
  HydraEditor::FieldMetadataService.multiple?(model_class, field)
70
53
  end
71
54
 
@@ -84,7 +67,7 @@ module Hydra
84
67
  end
85
68
 
86
69
  def terms
87
- self._terms
70
+ _terms
88
71
  end
89
72
 
90
73
  private
@@ -1,14 +1,13 @@
1
- require "hydra_editor/engine"
1
+ require 'hydra_editor/engine'
2
2
 
3
3
  module HydraEditor
4
-
5
4
  class InvalidType < RuntimeError; end
6
5
 
7
6
  extend ActiveSupport::Autoload
8
7
 
9
8
  autoload :ControllerResource
10
9
 
11
- def self.models= val
10
+ def self.models=(val)
12
11
  @models = val
13
12
  end
14
13
 
@@ -4,7 +4,7 @@ class HydraEditor::ControllerResource < CanCan::ControllerResource
4
4
  end
5
5
 
6
6
  def resource_class
7
- raise HydraEditor::InvalidType, "Lost the type" unless has_valid_type?
7
+ raise HydraEditor::InvalidType, 'Lost the type' unless has_valid_type?
8
8
  type_param.constantize
9
9
  end
10
10
 
@@ -1,12 +1,13 @@
1
1
  module HydraEditor
2
2
  class Engine < ::Rails::Engine
3
+ require 'simple_form'
3
4
  engine_name 'hydra_editor'
4
5
  config.eager_load_paths += %W(
5
6
  #{config.root}/app/helpers/concerns
6
7
  #{config.root}/app/presenters
7
8
  )
8
- initializer "hydra-editor.initialize" do
9
- require "cancan"
9
+ initializer 'hydra-editor.initialize' do
10
+ require 'cancan'
10
11
  end
11
12
  end
12
13
  end
@@ -1,3 +1,3 @@
1
1
  module HydraEditor
2
- VERSION = "1.2.0"
2
+ VERSION = '2.0.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: 1.2.0
4
+ version: 2.0.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: 2016-01-21 00:00:00.000000000 Z
12
+ date: 2016-04-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -129,14 +129,14 @@ dependencies:
129
129
  requirements:
130
130
  - - "~>"
131
131
  - !ruby/object:Gem::Version
132
- version: '3.4'
132
+ version: '4.0'
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - "~>"
138
138
  - !ruby/object:Gem::Version
139
- version: '3.4'
139
+ version: '4.0'
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: hydra-head
142
142
  requirement: !ruby/object:Gem::Requirement
@@ -155,30 +155,58 @@ dependencies:
155
155
  name: engine_cart
156
156
  requirement: !ruby/object:Gem::Requirement
157
157
  requirements:
158
- - - '='
158
+ - - "~>"
159
+ - !ruby/object:Gem::Version
160
+ version: '0.8'
161
+ type: :development
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - "~>"
166
+ - !ruby/object:Gem::Version
167
+ version: '0.8'
168
+ - !ruby/object:Gem::Dependency
169
+ name: solr_wrapper
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - "~>"
159
173
  - !ruby/object:Gem::Version
160
- version: 0.8.0
174
+ version: '0.4'
161
175
  type: :development
162
176
  prerelease: false
163
177
  version_requirements: !ruby/object:Gem::Requirement
164
178
  requirements:
165
- - - '='
179
+ - - "~>"
180
+ - !ruby/object:Gem::Version
181
+ version: '0.4'
182
+ - !ruby/object:Gem::Dependency
183
+ name: fcrepo_wrapper
184
+ requirement: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - "~>"
187
+ - !ruby/object:Gem::Version
188
+ version: '0.2'
189
+ type: :development
190
+ prerelease: false
191
+ version_requirements: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - "~>"
166
194
  - !ruby/object:Gem::Version
167
- version: 0.8.0
195
+ version: '0.2'
168
196
  - !ruby/object:Gem::Dependency
169
- name: jettywrapper
197
+ name: jasmine
170
198
  requirement: !ruby/object:Gem::Requirement
171
199
  requirements:
172
200
  - - "~>"
173
201
  - !ruby/object:Gem::Version
174
- version: '2.0'
202
+ version: '2.3'
175
203
  type: :development
176
204
  prerelease: false
177
205
  version_requirements: !ruby/object:Gem::Requirement
178
206
  requirements:
179
207
  - - "~>"
180
208
  - !ruby/object:Gem::Version
181
- version: '2.0'
209
+ version: '2.3'
182
210
  description: A basic metadata editor for hydra-head
183
211
  email:
184
212
  - hydra-tech@googlegroups.com
@@ -209,7 +237,6 @@ files:
209
237
  - app/views/records/edit.html.erb
210
238
  - app/views/records/edit_fields/_default.html.erb
211
239
  - app/views/records/new.html.erb
212
- - config/initializers/simple_form.rb
213
240
  - config/jetty.yml
214
241
  - config/locales/hydra_editor.yml
215
242
  - config/routes.rb
@@ -237,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
264
  version: '0'
238
265
  requirements: []
239
266
  rubyforge_project:
240
- rubygems_version: 2.4.5.1
267
+ rubygems_version: 2.5.1
241
268
  signing_key:
242
269
  specification_version: 4
243
270
  summary: A basic metadata editor for hydra-head
@@ -1,31 +0,0 @@
1
- require 'simple_form'
2
- # Use this setup block to configure all options available in SimpleForm.
3
- SimpleForm.setup do |config|
4
- config.wrappers :inline, tag: 'span', class: 'form-group inline', error_class: 'has-error' do |b|
5
- b.use :html5
6
- b.use :placeholder
7
- b.use :label, class: 'control-label'
8
- b.use :input, class: 'form-control'
9
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
10
- end
11
-
12
- config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
13
- b.use :html5
14
- b.use :placeholder
15
- b.use :label, class: 'control-label'
16
- b.wrapper tag: 'div' do |ba|
17
- ba.use :input, class: 'form-control'
18
- ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
19
- ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
20
- end
21
- end
22
-
23
- # Wrappers for forms and inputs using the Twitter Bootstrap toolkit.
24
- # Check the Bootstrap docs (http://getbootstrap.com/css/)
25
- # to learn about the different styles for forms and inputs,
26
- # buttons and other elements.
27
- config.default_wrapper = :vertical_form
28
-
29
- config.error_notification_class = 'alert alert-danger'
30
- config.button_class = 'btn btn-default'
31
- end