@@ -25,7 +25,7 @@ def dt_aggregated(study, assay = nil)
25
25
end
26
26
columns = dt_cumulative_cols ( sample_types )
27
27
rows = dt_cumulative_rows ( sample_types , columns . length )
28
- { columns :, rows :, sample_types : sample_types . map { |s | { title : s . title , id : s . id } } }
28
+ { columns :, rows :, sample_types : sample_types . map { |s | { title : s . title , id : s . id , assay_title : s . assays . first &. title } } }
29
29
end
30
30
31
31
private
@@ -99,15 +99,19 @@ def transform_registered_sample_single(json_metadata, input_key)
99
99
def dt_cols ( sample_type )
100
100
attribs = sample_type . sample_attributes . map do |a |
101
101
attribute = { title : a . title , name : sample_type . id . to_s , required : a . required , description : a . description ,
102
- is_title : a . is_title , attribute_type : a . sample_attribute_type }
102
+ is_title : a . is_title , attribute_type : a . sample_attribute_type &. base_type }
103
103
104
104
if a . sample_attribute_type &.controlled_vocab?
105
105
cv_allows_free_text = a . allow_cv_free_text
106
106
attribute . merge! ( { cv_allows_free_text : cv_allows_free_text , cv_id : a . sample_controlled_vocab_id } )
107
107
end
108
108
109
109
if a . sample_attribute_type &.seek_sample_multi? || a . sample_attribute_type &.seek_sample?
110
- attribute . merge! ( { multi_link : a . sample_attribute_type &.seek_sample_multi? , linked_sample_type : a . linked_sample_type_id } )
110
+ attribute . merge! ( linked_sample_type : a . linked_sample_type_id )
111
+ end
112
+
113
+ if a . input_attribute?
114
+ attribute . merge! ( is_input : true )
111
115
end
112
116
113
117
attribute
@@ -156,18 +160,21 @@ def get_full_rows(x, depth, row = [], i = 0, rows = [])
156
160
end
157
161
158
162
def dt_cumulative_cols ( sample_types )
159
- sample_types . flat_map do |s |
163
+ sample_types . flat_map . with_index do |s , i |
160
164
s . sample_attributes . map do |a |
161
165
attribute = { title : a . title , name : s . id . to_s , required : a . required , description : a . description ,
162
- is_title : a . is_title , attribute_type : a . sample_attribute_type }
166
+ is_title : a . is_title , attribute_type : a . sample_attribute_type &. base_type }
163
167
is_seek_sample_multi = a . sample_attribute_type . seek_sample_multi?
164
168
is_seek_sample = a . sample_attribute_type . seek_sample?
165
169
is_cv_list = a . sample_attribute_type . seek_cv_list?
166
- attribute . merge! ( { multi_link : true , linked_sample_type : a . linked_sample_type . id } ) if is_seek_sample_multi
167
- attribute . merge! ( { multi_link : false , linked_sample_type : a . linked_sample_type . id } ) if is_seek_sample
168
- attribute . merge! ( { is_cv_list : true } ) if is_cv_list
170
+ is_input = a . input_attribute?
171
+ attribute . merge! ( linked_sample_type : a . linked_sample_type . id ) if is_seek_sample_multi || is_seek_sample
172
+ # The first input has to show up in the experiment view,
173
+ # that's why when i=0, the `is_first_input` flag is set to true.
174
+ attribute . merge! ( { is_input : true , is_first_input : i == 0 } ) if is_input
175
+ attribute . merge! ( is_cv_list : true ) if is_cv_list
169
176
attribute
170
- end . unshift ( { title : 'id' } , { title : 'uuid' } )
177
+ end . unshift ( { title : 'id' , is_id_field : true } , { title : 'uuid' , is_id_field : true } )
171
178
end
172
179
end
173
180
end
0 commit comments