labimotion 2.2.0.rc11 → 2.2.0.rc12
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/lib/labimotion/apis/generic_element_api.rb +1 -0
- data/lib/labimotion/helpers/element_helpers.rb +21 -15
- data/lib/labimotion/models/concerns/element_fetchable.rb +2 -2
- data/lib/labimotion/models/element.rb +2 -2
- data/lib/labimotion/utils/search.rb +2 -2
- data/lib/labimotion/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 407197c03e88402882b081d31dc92999629ec43c25b8c056c6f6ba3ca40135fc
|
|
4
|
+
data.tar.gz: d331368ce985ae7ff32a98f0747e9b06233eb5ac3b9b1a0c17e76a3ecbeeab7a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 275089d4170573e9961387dfe2274e9c5c8d1f9ccfe02b854aec3b1a5bfb237f5535915fd73205fc1efa564102ef33605a4f5de148fec8244b76ee2ca9fa5b48
|
|
7
|
+
data.tar.gz: 75b3433050aab3b9a76c9442643b0c5dcb87b508672d4b3b1c57b8ca52bbb75e1045cf429c25c4cfa64616df2482baa15062ccc45f515173012f31ca6cbcacef
|
|
@@ -432,6 +432,7 @@ module Labimotion
|
|
|
432
432
|
desc 'Return serialized elements of current user'
|
|
433
433
|
params do
|
|
434
434
|
optional :collection_id, type: Integer, desc: 'Collection id'
|
|
435
|
+
optional :sync_collection_id, type: Integer, desc: 'SyncCollectionsUser id'
|
|
435
436
|
optional :el_type, type: String, desc: 'element klass name'
|
|
436
437
|
optional :from_date, type: Integer, desc: 'created_date from in ms'
|
|
437
438
|
optional :to_date, type: Integer, desc: 'created_date to in ms'
|
|
@@ -215,7 +215,7 @@ module Labimotion
|
|
|
215
215
|
layer, field = params[:sort_column].split('.')
|
|
216
216
|
|
|
217
217
|
element_klass = Labimotion::ElementKlass.find_by(name: params[:el_type])
|
|
218
|
-
allowed_fields = element_klass
|
|
218
|
+
allowed_fields = element_klass.properties_release.dig(Labimotion::Prop::LAYERS, layer, Labimotion::Prop::FIELDS)&.pluck('field') || []
|
|
219
219
|
|
|
220
220
|
if field.in?(allowed_fields)
|
|
221
221
|
query = ActiveRecord::Base.sanitize_sql(
|
|
@@ -247,21 +247,27 @@ module Labimotion
|
|
|
247
247
|
end
|
|
248
248
|
|
|
249
249
|
def list_serialized_elements(params, current_user)
|
|
250
|
-
|
|
251
|
-
|
|
250
|
+
collection_id =
|
|
252
251
|
if params[:collection_id]
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
252
|
+
Collection
|
|
253
|
+
.belongs_to_or_shared_by(current_user.id, current_user.group_ids)
|
|
254
|
+
.find_by(id: params[:collection_id])&.id
|
|
255
|
+
elsif params[:sync_collection_id]
|
|
256
|
+
current_user
|
|
257
|
+
.all_sync_in_collections_users
|
|
258
|
+
.find_by(id: params[:sync_collection_id])&.collection&.id
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
scope =
|
|
262
|
+
if collection_id
|
|
263
|
+
Labimotion::Element
|
|
264
|
+
.joins(:element_klass, :collections_elements)
|
|
265
|
+
.where(
|
|
266
|
+
element_klasses: { name: params[:el_type] },
|
|
267
|
+
collections_elements: { collection_id: collection_id },
|
|
268
|
+
).includes(:tag, collections: :sync_collections_users)
|
|
262
269
|
else
|
|
263
|
-
|
|
264
|
-
scope = Labimotion::Element.for_user(current_user.id)
|
|
270
|
+
Labimotion::Element.none
|
|
265
271
|
end
|
|
266
272
|
|
|
267
273
|
## TO DO: refactor labimotion
|
|
@@ -272,7 +278,7 @@ module Labimotion
|
|
|
272
278
|
layer, field = params[:sort_column].split('.')
|
|
273
279
|
|
|
274
280
|
element_klass = Labimotion::ElementKlass.find_by(name: params[:el_type])
|
|
275
|
-
allowed_fields = element_klass
|
|
281
|
+
allowed_fields = element_klass.properties_release.dig(Labimotion::Prop::LAYERS, layer, Labimotion::Prop::FIELDS)&.pluck('field') || []
|
|
276
282
|
|
|
277
283
|
if field.in?(allowed_fields)
|
|
278
284
|
query = ActiveRecord::Base.sanitize_sql(
|
|
@@ -26,9 +26,9 @@ module Labimotion
|
|
|
26
26
|
joins(collections: :user).where(collections: { user_id: user_id })
|
|
27
27
|
)
|
|
28
28
|
|
|
29
|
-
# Shared records
|
|
29
|
+
# Shared (synced) records
|
|
30
30
|
shared = apply_filters.call(
|
|
31
|
-
|
|
31
|
+
joins(collections: :sync_collections_users).where(sync_collections_users: { user_id: user_id })
|
|
32
32
|
)
|
|
33
33
|
|
|
34
34
|
# Combine (remove duplicates), order, and limit
|
|
@@ -141,9 +141,9 @@ module Labimotion
|
|
|
141
141
|
joins(collections: :user).where(collections: { user_id: user_id })
|
|
142
142
|
)
|
|
143
143
|
|
|
144
|
-
# Shared elements
|
|
144
|
+
# Shared (synced) elements
|
|
145
145
|
shared = apply_filters.call(
|
|
146
|
-
|
|
146
|
+
joins(collections: :sync_collections_users).where(sync_collections_users: { user_id: user_id })
|
|
147
147
|
)
|
|
148
148
|
|
|
149
149
|
# Combine (remove duplicates), order, and limit
|
|
@@ -12,7 +12,7 @@ module Labimotion
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def self.elements_search(params, current_user, c_id, dl)
|
|
15
|
-
collection = Collection.
|
|
15
|
+
collection = Collection.belongs_to_or_shared_by(current_user.id, current_user.group_ids).find(c_id)
|
|
16
16
|
element_scope = Labimotion::Element.joins(:collections_elements).where('collections_elements.collection_id = ?', collection.id).joins(:element_klass).where('element_klasses.id = elements.element_klass_id AND element_klasses.name = ?', params[:selection][:genericElName])
|
|
17
17
|
element_scope = element_scope.where('elements.name like (?)', "%#{params[:selection][:searchName]}%") if params[:selection][:searchName].present?
|
|
18
18
|
element_scope = element_scope.where('elements.short_label like (?)', "%#{params[:selection][:searchShowLabel]}%") if params[:selection][:searchShowLabel].present?
|
|
@@ -97,7 +97,7 @@ module Labimotion
|
|
|
97
97
|
def self.samples_search(c_id = @c_id)
|
|
98
98
|
sqls = []
|
|
99
99
|
sps = params[:selection][:searchProperties]
|
|
100
|
-
collection = Collection.
|
|
100
|
+
collection = Collection.belongs_to_or_shared_by(current_user.id, current_user.group_ids).find(c_id)
|
|
101
101
|
element_scope = Sample.joins(:collections_samples).where('collections_samples.collection_id = ?', collection.id)
|
|
102
102
|
return element_scope if sps.empty?
|
|
103
103
|
|
data/lib/labimotion/version.rb
CHANGED