create_custom_attributes 0.6.2 → 0.6.3
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfc0f2cee77429347fd5b147254475dde430f436d0bddcd34cdf79ac57a137b8
|
4
|
+
data.tar.gz: f0d2d676dec9c047efaa99bb3ff17a31718f7c64dc41f1bef24e447c89536290
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44b5c345a4f4ad50784696fb892b67f62524ce97b0741ee8b0e1afdf9396172aee09769f39d3f447baafbfcbbf3f88f1b98020bdd748bcbd21a46fd54b06ab27
|
7
|
+
data.tar.gz: a3335e2608599d3e276118d873b539d6305ef5b80a514d628811219e7acb940def2a665595b09d18cd14a12cbffdf503b20bdf8679b9125562536184dc8138ec
|
@@ -88,7 +88,7 @@ module CustomAttributes
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
if position.present? && self.class.where(position: position, model_type: model_type).where.not(id: id).count > 0
|
91
|
+
if position.present? && self.class.where(position: position, model_type: model_type).where.not(id: id).where(custom_scope).count > 0
|
92
92
|
errors.add :position, ::I18n.t('activerecord.errors.messages.invalid_position')
|
93
93
|
end
|
94
94
|
end
|
@@ -180,7 +180,7 @@ module CustomAttributes
|
|
180
180
|
def set_position
|
181
181
|
return unless position.nil?
|
182
182
|
|
183
|
-
last_position = self.class.where(model_type: model_type).order(position: :desc).first.try(:position)
|
183
|
+
last_position = self.class.where(model_type: model_type).where(custom_scope).order(position: :desc).first.try(:position)
|
184
184
|
self.position = 1
|
185
185
|
self.position = last_position + 1 unless last_position.nil?
|
186
186
|
end
|
@@ -188,7 +188,7 @@ module CustomAttributes
|
|
188
188
|
def change_position_by(diff)
|
189
189
|
new_pos = position + diff unless position.nil?
|
190
190
|
|
191
|
-
swap_field = self.class.find_by(model_type: model_type, position: new_pos)
|
191
|
+
swap_field = self.class.find_by(model_type: model_type, position: new_pos).where(custom_scope)
|
192
192
|
|
193
193
|
if swap_field.present?
|
194
194
|
swap_field.position = position
|
@@ -213,7 +213,7 @@ module CustomAttributes
|
|
213
213
|
|
214
214
|
def ensure_position_integrity
|
215
215
|
expected_position = 1
|
216
|
-
self.class.where(model_type: model_type).order(position: :asc).each do |field|
|
216
|
+
self.class.where(model_type: model_type).order(position: :asc).where(custom_scope).each do |field|
|
217
217
|
if expected_position != field.position
|
218
218
|
field.position = expected_position
|
219
219
|
field.save
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: create_custom_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Grützmacher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|