labimotion 1.0.3 → 1.0.6

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: 85b16e5e5f7016923f9bd794dd16b295e481ba19dd7b5ee7966197709d2ee021
4
- data.tar.gz: 934764fb714324941eb21090bbaeb0a634397ae639b7fd7af2ce855e5d59ab48
3
+ metadata.gz: 4cb214fd84c4c884358893ea3a5c7af5504bf3c9d366747d95c4c86aa6f2c42e
4
+ data.tar.gz: 5ec0a7b4e10b6174ba9802648c9f9f15e85c03b491035d375b06ee85e25ce15e
5
5
  SHA512:
6
- metadata.gz: c485ee1953b3672a3b9a60fc2add5b0000d7af23fc2cc67d995de097600ccbf6a598a4bbb91c3d0adc063e7c6e77404ccf03f2b64d82ea9df50d638482d05195
7
- data.tar.gz: c8a40e8f6bdd3b6521bd1aef4ddf2e153c60aa5d32f7a256f053a83d9c281626979b36fe4d95040332000cc1b76101d119e10b05a6d2f128da5bc86be28f11f2
6
+ metadata.gz: 6c2c0a26c8c8ce05d44f976d1146464f72c1dd173529cff04fa9918863c8f074f69299d90d2d9fefafcd5628a5dd28d29ade1b5b9029b4aac88602f05d64db90
7
+ data.tar.gz: 67bfe5f4e12b5b8412a95fd4124818dfb4da775baa2558e4934c4b8b86d79c43c0c65f51070e4893ef3cf857bfae2e3efd6061bbbd1b5b5759917bfed936568d
@@ -318,7 +318,7 @@ module Labimotion
318
318
  if Labimotion::IS_RAILS5 == true
319
319
  {
320
320
  element: ElementPermissionProxy.new(current_user, element, user_ids).serialized,
321
- attachments: Entities::AttachmentEntity.represent(element.attachments)
321
+ attachments: attach_thumbnail(element&.attachments)
322
322
  }
323
323
  else
324
324
  {
@@ -326,7 +326,7 @@ module Labimotion
326
326
  element,
327
327
  detail_levels: ElementDetailLevelCalculator.new(user: current_user, element: element).detail_levels,
328
328
  ),
329
- attachments: Entities::AttachmentEntity.represent(element.attachments),
329
+ attachments: attach_thumbnail(element&.attachments)
330
330
  }
331
331
  end
332
332
  rescue StandardError => e
@@ -350,7 +350,7 @@ module Labimotion
350
350
  if Labimotion::IS_RAILS5 == true
351
351
  {
352
352
  element: ElementPermissionProxy.new(current_user, element, user_ids).serialized,
353
- attachments: Entities::AttachmentEntity.represent(element.attachments)
353
+ attachments: attach_thumbnail(element&.attachments)
354
354
  }
355
355
  else
356
356
  present(
@@ -386,7 +386,7 @@ module Labimotion
386
386
  if Labimotion::IS_RAILS5 == true
387
387
  {
388
388
  element: ElementPermissionProxy.new(current_user, element, user_ids).serialized,
389
- attachments: Entities::AttachmentEntity.represent(element.attachments)
389
+ attachments: attach_thumbnail(element&.attachments)
390
390
  }
391
391
  else
392
392
  {
@@ -394,7 +394,7 @@ module Labimotion
394
394
  element,
395
395
  detail_levels: ElementDetailLevelCalculator.new(user: current_user, element: element).detail_levels,
396
396
  ),
397
- attachments: Entities::AttachmentEntity.represent(element.attachments),
397
+ attachments: attach_thumbnail(element&.attachments),
398
398
  }
399
399
  end
400
400
  rescue StandardError => e
@@ -159,7 +159,7 @@ module Labimotion
159
159
  att_ary = create_attachments(
160
160
  params[:attfiles],
161
161
  params[:delfiles],
162
- params[:att_type],
162
+ "Labimotion::#{params[:att_type]}",
163
163
  params[:att_id],
164
164
  params[:attfilesIdentifier],
165
165
  current_user.id
@@ -326,5 +326,14 @@ module Labimotion
326
326
  raise e
327
327
  end
328
328
 
329
+ def attach_thumbnail(_attachments)
330
+ attachments = _attachments&.map do |attachment|
331
+ _att = Entities::AttachmentEntity.represent(attachment, serializable: true)
332
+ _att[:thumbnail] = attachment.thumb ? Base64.encode64(attachment.read_thumbnail) : nil
333
+ _att
334
+ end
335
+ attachments
336
+ end
337
+
329
338
  end
330
339
  end
@@ -101,7 +101,7 @@ module Labimotion
101
101
  cds = Container.find(id)
102
102
  cds.attachments.where(aasm_state: 'csv').each do |att|
103
103
  name = File.basename(att.filename, '.csv')
104
- sheet = @xfile.workbook.add_worksheet(name: name)
104
+ sheet = @xfile.workbook.add_worksheet(name: name.slice(0, 25))
105
105
 
106
106
  if Labimotion::IS_RAILS5 == true
107
107
  File.open(att.store.path) do |fi|
@@ -41,9 +41,8 @@ module Labimotion
41
41
 
42
42
  def save_segments(**args) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
43
43
  return if args[:segments].nil?
44
-
45
44
  segments = []
46
- args[:segments].each do |seg|
45
+ args[:segments]&.each do |seg|
47
46
  klass = Labimotion::SegmentKlass.find_by(id: seg['segment_klass_id'])
48
47
  uuid = SecureRandom.uuid
49
48
  props = seg['properties']
@@ -59,7 +58,7 @@ module Labimotion
59
58
  next if segment.present?
60
59
 
61
60
  props['klass_uuid'] = klass.uuid
62
- segment = Labimotion::Segment.create!(properties_release: klass.properties_release, segment_klass_id: seg['segment_klass_id'], element_type: Labimotion::Utils.element_name(self.class.name), element_id: self.id, properties: props, created_by: args[:current_user_id], uuid: uuid, klass_uuid: klass.uuid)
61
+ segment = Labimotion::Segment.create!(properties_release: klass.properties_release, segment_klass_id: seg['segment_klass_id'], element_type: self.class.name, element_id: self.id, properties: props, created_by: args[:current_user_id], uuid: uuid, klass_uuid: klass.uuid)
63
62
  segments.push(segment)
64
63
  end
65
64
  segments
@@ -23,5 +23,14 @@ module Labimotion
23
23
  end
24
24
  properties
25
25
  end
26
+
27
+ def migrate_workflow
28
+ return if properties_template.nil? || properties_release.nil?
29
+
30
+ return if properties_template['flow'].nil? && properties_release['flow'].nil?
31
+
32
+ update_column(:properties_template, split_workflow(properties_template)) if properties_template['flow']
33
+ update_column(:properties_release, split_workflow(properties_release)) if properties_release['flow']
34
+ end
26
35
  end
27
36
  end
@@ -12,6 +12,7 @@ module Labimotion
12
12
  include ElementUIStateScopes
13
13
  include Collectable
14
14
  ## include AnalysisCodes
15
+ include ElementCodes
15
16
  include Taggable
16
17
  include Workflow
17
18
  include Segmentable
@@ -58,7 +59,7 @@ module Labimotion
58
59
 
59
60
 
60
61
  def attachments
61
- Attachment.where(attachable_id: self.id, attachable_type: 'Element')
62
+ Attachment.where(attachable_id: self.id, attachable_type: self.class.name)
62
63
  end
63
64
 
64
65
  def self.get_associated_samples(element_ids)
@@ -23,13 +23,5 @@ module Labimotion
23
23
  )
24
24
  end
25
25
 
26
- def migrate_workflow
27
- return if properties_template.nil? || properties_release.nil?
28
-
29
- return if properties_template['flow'].nil? && properties_release['flow'].nil?
30
-
31
- update_column(:properties_template, split_workflow(properties_template)) if properties_template['flow']
32
- update_column(:properties_release, split_workflow(properties_release)) if properties_release['flow']
33
- end
34
26
  end
35
27
  end
@@ -6,6 +6,7 @@ module Labimotion
6
6
  self.table_name = :segment_klasses
7
7
  acts_as_paranoid
8
8
  include GenericKlassRevisions
9
+ include Workflow
9
10
  belongs_to :element_klass, class_name: 'Labimotion::ElementKlass'
10
11
  has_many :segments, dependent: :destroy, class_name: 'Labimotion::Segment'
11
12
  has_many :segment_klasses_revisions, dependent: :destroy, class_name: 'Labimotion::SegmentKlassesRevision'
@@ -22,6 +22,26 @@ module Labimotion
22
22
  fetch_many.call(klasses, {'created_by' => 'User'})
23
23
  end
24
24
 
25
+ def self.fetch_elements(collection, segments, attachments, fetch_many, fetch_one, fetch_containers)
26
+ fetch_many.call(collection.elements, {
27
+ 'element_klass_id' => 'Labimotion::ElementKlass',
28
+ 'created_by' => 'User',
29
+ })
30
+ fetch_many.call(collection.collections_elements, {
31
+ 'collection_id' => 'Collection',
32
+ 'element_id' => 'Labimotion::Element',
33
+ })
34
+ collection.elements.each do |element|
35
+
36
+ element, attachments = Labimotion::Export.fetch_properties(element, attachments, &fetch_one)
37
+ fetch_containers.call(element)
38
+ segment, @attachments = Labimotion::Export.fetch_segments(element, attachments, &fetch_one)
39
+ segments += segment if segment.present?
40
+ end
41
+
42
+ [segments, attachments]
43
+
44
+ end
25
45
 
26
46
  def self.fetch_segments(element, attachments, &fetch_one)
27
47
  element_type = element.class.name
@@ -3,5 +3,5 @@
3
3
  module Labimotion
4
4
  IS_RAILS5 = false
5
5
  VERSION = '0.1.14' if Labimotion::IS_RAILS5 == true
6
- VERSION = '1.0.3' if Labimotion::IS_RAILS5 == false
6
+ VERSION = '1.0.6' if Labimotion::IS_RAILS5 == false
7
7
  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: 1.0.3
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chia-Lin Lin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-08-31 00:00:00.000000000 Z
12
+ date: 2023-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails