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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 491f3e3075c83954b5e49caeb8b091d1aba68ddf0135fe82ddbaf6aeb4b244e9
4
- data.tar.gz: ae5dc4a93ecb31559feff1060f8fb449aa3e618f86890ea25324410226f4d166
3
+ metadata.gz: 407197c03e88402882b081d31dc92999629ec43c25b8c056c6f6ba3ca40135fc
4
+ data.tar.gz: d331368ce985ae7ff32a98f0747e9b06233eb5ac3b9b1a0c17e76a3ecbeeab7a
5
5
  SHA512:
6
- metadata.gz: ce1f326748ee1ae7c9a71f97f43b2eef7d3273c28c9d7d7d3e87516cfcef58002927563dedbaad66ca87f6c396fd462cab6f827eb95d052cdf4f2703bfe8e307
7
- data.tar.gz: 958083e170c64e0c378b38ecf9996343a88dfa6756617d0a7d6d9e548d3dbefc3b53c00eda2ec8412fd6da59ca3b959b7d0fa20f67e32a559fa74da9d01e695b
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&.properties_release&.dig(Labimotion::Prop::LAYERS, layer, Labimotion::Prop::FIELDS)&.pluck('field') || []
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
- scope = Labimotion::Element.none
251
-
250
+ collection_id =
252
251
  if params[:collection_id]
253
- begin
254
- collection = Collection.accessible_for(current_user).find(params[:collection_id])
255
- scope = collection.elements
256
- .joins(:element_klass)
257
- .where(element_klasses: { name: params[:el_type] })
258
- .includes(:tag)
259
- rescue ActiveRecord::RecordNotFound
260
- Labimotion::Element.none
261
- end
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
- # All collection of current_user
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&.properties_release&.dig(Labimotion::Prop::LAYERS, layer, Labimotion::Prop::FIELDS)&.pluck('field') || []
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
- left_joins(:collection_shares).where(collection_shares: { shared_with_id: user_id })
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
- left_joins(:collection_shares).where(collection_shares: { shared_with_id: user_id })
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.accessible_for(current_user).find(c_id)
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.accessible_for(current_user).find(c_id)
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
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  ## Labimotion Version
4
4
  module Labimotion
5
- VERSION = '2.2.0.rc11'
5
+ VERSION = '2.2.0.rc12'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: labimotion
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0.rc11
4
+ version: 2.2.0.rc12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chia-Lin Lin