hydra-editor 3.3.1 → 3.3.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: 483516ed526d6a67b385e0e68bdcc09d67654943
4
- data.tar.gz: c54e1eb9a3c3ab157e03bced6e0a19bddcb8d463
3
+ metadata.gz: bf1742bb171c18f225eafe23a40a84f28ce88588
4
+ data.tar.gz: f7eba9637334928973ea1a2c9615e9e51dbfe697
5
5
  SHA512:
6
- metadata.gz: b69df85c3c3f58083db84b61e606fdbea630ba91c8febe8f8408eee7129732074923036c9041570084917543e8b8fd303d0dc54308cb3ffbf231145e34b40fbd
7
- data.tar.gz: bb2a3636961a894beb9ce36d47fd36461264ce042a3bb02a7450ed144e44df14b1b0d73c13e12f3cfaccf4e205e4820055350c34a5732f3e9785974539abe5cf
6
+ metadata.gz: e3f11286ab8251e7ac992ec0eb97c6a2d5ee9c0b60dda759f1aae9059400e16cc581bcdffecc6170d2eacd4bec2fd3224508d60551d2c5b58ce43e93a4f99c2f
7
+ data.tar.gz: 47695067e2ced57b919bfe9e889bd92f4fa2caecc6626b863b337b46a6ecec931403b0411922a6af218e2ca113b64dfd6e5a08288198bf4a220c0f6d0b7752e8
@@ -1,12 +1,16 @@
1
1
  export class FieldManager {
2
2
  constructor(element, options) {
3
3
  this.element = $(element);
4
+
4
5
  this.options = options;
5
6
 
6
7
  this.options.label = this.getFieldLabel(this.element, options)
7
8
 
8
- this.adder = this.createAddHtml(this.options);
9
- this.remover = this.createRemoveHtml(this.options);
9
+ this.addSelector = '.add'
10
+ this.removeSelector = '.remove'
11
+
12
+ this.adder = this.createAddHtml(this.options)
13
+ this.remover = this.createRemoveHtml(this.options)
10
14
 
11
15
  this.controls = $(options.controlsHtml);
12
16
 
@@ -35,18 +39,43 @@ export class FieldManager {
35
39
  $(this.element).find('.listing').attr('aria-live', 'polite')
36
40
  }
37
41
 
42
+ // Add the "Add another" and "Remove" controls to the DOM
38
43
  _appendControls() {
39
- $(this.fieldWrapperClass, this.element).append(this.controls);
40
- $(this.fieldWrapperClass + ' .field-controls', this.element).append(this.remover);
44
+ // We want to make these DOM additions idempotently, so exit if it's
45
+ // already set up.
46
+ if (!this._hasRemoveControl()) {
47
+ this._createRemoveWrapper()
48
+ this._createRemoveControl()
49
+ }
41
50
 
42
- if ($(this.element).find('.add').length == 0) {
43
- $(this.element).find(this.listClass).after(this.adder);
51
+ if (!this._hasAddControl()) {
52
+ this._createAddControl()
44
53
  }
45
54
  }
46
55
 
56
+ _createRemoveWrapper() {
57
+ $(this.fieldWrapperClass, this.element).append(this.controls);
58
+ }
59
+
60
+ _createRemoveControl() {
61
+ $(this.fieldWrapperClass + ' .field-controls', this.element).append(this.remover)
62
+ }
63
+
64
+ _createAddControl() {
65
+ this.element.find(this.listClass).after(this.adder)
66
+ }
67
+
68
+ _hasRemoveControl() {
69
+ return this.element.find(this.removeSelector).length > 0
70
+ }
71
+
72
+ _hasAddControl() {
73
+ return this.element.find(this.addSelector).length > 0
74
+ }
75
+
47
76
  _attachEvents() {
48
- this.element.on('click', '.remove', (e) => this.removeFromList(e));
49
- this.element.on('click', '.add', (e) =>this.addToList(e));
77
+ this.element.on('click', this.removeSelector, (e) => this.removeFromList(e))
78
+ this.element.on('click', this.addSelector, (e) => this.addToList(e))
50
79
  }
51
80
 
52
81
  _addCallbacks() {
@@ -1,3 +1,3 @@
1
1
  module HydraEditor
2
- VERSION = '3.3.1'.freeze
2
+ VERSION = '3.3.2'.freeze
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: 3.3.1
4
+ version: 3.3.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: 2017-05-04 00:00:00.000000000 Z
12
+ date: 2017-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -129,6 +129,20 @@ dependencies:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: '3.1'
132
+ - !ruby/object:Gem::Dependency
133
+ name: rails-controller-testing
134
+ requirement: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ type: :development
140
+ prerelease: false
141
+ version_requirements: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
132
146
  - !ruby/object:Gem::Dependency
133
147
  name: factory_girl_rails
134
148
  requirement: !ruby/object:Gem::Requirement