labimotion 1.0.5 → 1.0.7

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: 6043cc7059f5394e70f75b1a06415fff819c17c210450ec0f335d896166709db
4
- data.tar.gz: a20e04caa39ff947b878533a8d13f4019f5722d3a1a309d0066f776b648d3514
3
+ metadata.gz: 905de9f283f00c1f3e7976bd55c0888a826d70ab81dfd3e194479e78e5f94844
4
+ data.tar.gz: b513e705204af46949c78b2510ade676319c6bc71fc315474e28440381d7d629
5
5
  SHA512:
6
- metadata.gz: 28b2d0ee49532e30873049b382275384bae81c8db730397727cadbad8c663b2e03fdd7b50f6c805ca09c99a3dffe1eef1d66378ca5802645ba324046f0cf07e9
7
- data.tar.gz: b2130bd66485442b4944c73f2bb61755e6511d33ab6dd27895eab14df06417b6bb1d8feaa7945b77146b3ea2bc51a15748177cf416602750940312cdb9ec5173
6
+ metadata.gz: 56d99bf9f393d27a60ee1c6513f71df26822b3514daa9d7cc27a5b2a507227f26b06b5eb38f4d7531f35e453d153bf3527d60a60b8485357df6565a0149c000d
7
+ data.tar.gz: dd132a8553f99e35f72bdcc37fcdba945858ec4ebd6f4c167906b8909135f6750ba0e49d83fd7af7419e7afb4f0d5421ae59d154db231e8b425e77a1c9f0d1eb
@@ -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|
@@ -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
@@ -1,11 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
  require 'labimotion/models/concerns/generic_klass_revisions'
3
+ require 'labimotion/models/concerns/workflow'
3
4
 
4
5
  module Labimotion
5
6
  class SegmentKlass < ApplicationRecord
6
7
  self.table_name = :segment_klasses
7
8
  acts_as_paranoid
8
9
  include GenericKlassRevisions
10
+ include Workflow
9
11
  belongs_to :element_klass, class_name: 'Labimotion::ElementKlass'
10
12
  has_many :segments, dependent: :destroy, class_name: 'Labimotion::Segment'
11
13
  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.5' if Labimotion::IS_RAILS5 == false
6
+ VERSION = '1.0.7' 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.5
4
+ version: 1.0.7
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