labimotion 1.2.0.0 → 1.2.0.1

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: 7724683d3271fa68ecdf774518cc4d10a4d51ee1431c957e0538c5a00e4f689d
4
- data.tar.gz: b9cc8b469761e732707c0b272c2e814a8215c3c22a7d7ca077d7f5ddca9ed877
3
+ metadata.gz: 85459b416735dd8702c2764bd1ff996855ddfaf37c8b037737c7cf5dbb9403a4
4
+ data.tar.gz: 8e659ab1b570a0d91dfd0e047720ddde4872eb8a3320c65500bd6b00e8be6e9f
5
5
  SHA512:
6
- metadata.gz: dd7aaa2347333c05e09eb5e9d0628a8079e2fd4819e46b37e7a45fc40577fae12d2f731a5f1eddd601065c35aa333f312f724bd46b59d93f35f3639f8e34d53b
7
- data.tar.gz: f222c51a55a96c1d87c1d79a1fb965b8fb6315a2b182a6767b01222eeae665de248f7bdfdc6ca3789e1f2623faf7a1b69b03bcbc1527f51f6b9c03ba99183d56
6
+ metadata.gz: de6f3f92718a41d4d2a7bb4b7b3547c5a4996ea2e008beb3936e36d5606cabc5d1f6e73bf8525c9f0d306ff9af92d59eb08fce8d9e1fd6f0efcdd233f2bced33
7
+ data.tar.gz: bad917552004d85e0ad14091f32f599b7edda626561b099917a65c5bf2b2e6a7b2611e37782127a1b5a81bf1ed463435d3d4f1d4782d694dc4b19f2ee5e2ba0a
@@ -36,7 +36,7 @@ module Labimotion
36
36
  value
37
37
  end
38
38
 
39
- def proc_assign_sample(value, sample)
39
+ def proc_assign_sample(value, sample, element)
40
40
  return {} if sample.nil?
41
41
 
42
42
  value = {} if value.nil? || value.is_a?(String)
@@ -45,13 +45,16 @@ module Labimotion
45
45
  value['el_tip'] = sample.short_label
46
46
  value['el_label'] = sample.short_label
47
47
  value['el_svg'] = sample.get_svg_path
48
+ if element&.class&.name == Labimotion::Prop::L_ELEMENT && sample&.class&.name == Labimotion::Prop::SAMPLE
49
+ Labimotion::ElementsSample.find_or_create_by(element_id: element.id, sample_id: sample.id)
50
+ end
48
51
  value
49
52
  rescue StandardError => e
50
53
  Labimotion.log_exception(e)
51
54
  value
52
55
  end
53
56
 
54
- def proc_assign_element(value, element)
57
+ def proc_assign_element(value, element, _parent = nil)
55
58
  return {} if element.nil?
56
59
 
57
60
  value = {} if value.nil? || value.is_a?(String)
@@ -59,6 +62,9 @@ module Labimotion
59
62
  value['el_type'] = 'element' if value['el_type'].nil?
60
63
  value['el_tip'] = element.short_label
61
64
  value['el_label'] = element.short_label
65
+ if _parent&.class&.name == Labimotion::Prop::L_ELEMENT && element&.class&.name == Labimotion::Prop::L_ELEMENT
66
+ Labimotion::ElementsElement.find_or_create_by(parent_id: _parent.id, element_id: element.id)
67
+ end
62
68
  value
63
69
  rescue StandardError => e
64
70
  Labimotion.log_exception(e)
@@ -92,20 +98,20 @@ module Labimotion
92
98
  properties
93
99
  end
94
100
 
95
- def proc_table_sample(properties, data, instances, svalue, key, tidx, vdx, col_id)
101
+ def proc_table_sample(properties, data, instances, svalue, key, tidx, vdx, col_id, element)
96
102
  return properties unless id = svalue.fetch('el_id', nil)
97
103
 
98
104
  # orig_s = data.fetch(Labimotion::Prop::SAMPLE, nil)&.fetch(svalue['el_id'], nil)
99
105
  sample = instances.fetch(Labimotion::Prop::SAMPLE, nil)&.fetch(id, nil)
100
106
  val = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][tidx]['sub_values'][vdx][col_id]['value']
101
- properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][tidx]['sub_values'][vdx][col_id]['value'] = proc_assign_sample(val, sample)
107
+ properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][tidx]['sub_values'][vdx][col_id]['value'] = proc_assign_sample(val, sample, element)
102
108
  properties
103
109
  rescue StandardError => e
104
110
  Labimotion.log_exception(e)
105
111
  properties
106
112
  end
107
113
 
108
- def proc_table_prop(layer, key, data, instance, properties, field, tidx, type)
114
+ def proc_table_prop(layer, key, data, instance, properties, field, tidx, type, element)
109
115
  fields = field[Labimotion::Prop::SUBFIELDS].select { |ss| ss['type'] == type }
110
116
  return properties if fields.nil?
111
117
 
@@ -125,7 +131,7 @@ module Labimotion
125
131
  when Labimotion::FieldType::DRAG_MOLECULE
126
132
  properties = proc_table_molecule(properties, data, svalue, key, tidx, vdx, col_id)
127
133
  when Labimotion::FieldType::DRAG_SAMPLE
128
- properties = proc_table_sample(properties, data, instance, svalue, key, tidx, vdx, col_id)
134
+ properties = proc_table_sample(properties, data, instance, svalue, key, tidx, vdx, col_id, element)
129
135
  end
130
136
  end
131
137
  end
@@ -136,14 +142,14 @@ module Labimotion
136
142
  end
137
143
  end
138
144
 
139
- def self.proc_sample(layer, key, data, instances, properties)
145
+ def self.proc_sample(layer, key, data, instances, properties, element)
140
146
  fields = layer[Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::DRAG_SAMPLE }
141
147
  fields.each do |field|
142
148
  idx = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
143
149
  id = field["value"] && field["value"]["el_id"] unless idx.nil?
144
150
  sample = instances.fetch(Labimotion::Prop::SAMPLE, nil)&.fetch(id, nil)
145
151
  val = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']
146
- val = proc_assign_sample(val, sample)
152
+ val = proc_assign_sample(val, sample, element)
147
153
  properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = val
148
154
  end
149
155
  properties
@@ -152,7 +158,7 @@ module Labimotion
152
158
  raise
153
159
  end
154
160
 
155
- def self.proc_element(layer, key, data, instances, properties, elements)
161
+ def self.proc_element(layer, key, data, instances, properties, elements, element)
156
162
  fields = layer[Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::DRAG_ELEMENT }
157
163
  fields.each do |field|
158
164
  idx = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
@@ -162,7 +168,7 @@ module Labimotion
162
168
  properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = {}
163
169
  else
164
170
  val = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']
165
- val = proc_assign_element(val, att_el)
171
+ val = proc_assign_element(val, att_el, element)
166
172
  properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = val
167
173
  end
168
174
  end
@@ -225,14 +231,14 @@ module Labimotion
225
231
  end
226
232
 
227
233
 
228
- def self.proc_table(layer, key, data, instance, properties)
234
+ def self.proc_table(layer, key, data, instance, properties, element)
229
235
  fields = layer[Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::TABLE }
230
236
  fields&.each do |field|
231
237
  tidx = layer[Labimotion::Prop::FIELDS].index(field)
232
238
  next unless field['sub_values'].present? && field[Labimotion::Prop::SUBFIELDS].present?
233
239
 
234
- proc_table_prop(layer, key, data, instance, properties, field, tidx, Labimotion::FieldType::DRAG_MOLECULE)
235
- proc_table_prop(layer, key, data, instance, properties, field, tidx, Labimotion::FieldType::DRAG_SAMPLE)
240
+ proc_table_prop(layer, key, data, instance, properties, field, tidx, Labimotion::FieldType::DRAG_MOLECULE, element)
241
+ proc_table_prop(layer, key, data, instance, properties, field, tidx, Labimotion::FieldType::DRAG_SAMPLE, element)
236
242
  end
237
243
  properties
238
244
  rescue StandardError => e
@@ -246,9 +252,9 @@ module Labimotion
246
252
  layer = properties[Labimotion::Prop::LAYERS][key]
247
253
  properties = proc_molecule(layer, key, data, properties)
248
254
  properties = proc_upload(layer, key, data, instances, attachments, elmenet)
249
- properties = proc_sample(layer, key, data, instances, properties)
250
- properties = proc_element(layer, key, data, instances, properties, elements) # unless elements.nil?
251
- properties = proc_table(layer, key, data, instances, properties)
255
+ properties = proc_sample(layer, key, data, instances, properties, elmenet)
256
+ properties = proc_element(layer, key, data, instances, properties, elements, elmenet) # unless elements.nil?
257
+ properties = proc_table(layer, key, data, instances, properties, elmenet)
252
258
  end
253
259
  properties
254
260
  rescue StandardError => e
@@ -3,5 +3,5 @@
3
3
  ## Labimotion Version
4
4
  module Labimotion
5
5
  IS_RAILS5 = false
6
- VERSION = '1.2.0.0'
6
+ VERSION = '1.2.0.1'
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.2.0.0
4
+ version: 1.2.0.1
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: 2024-03-15 00:00:00.000000000 Z
12
+ date: 2024-03-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails