plate-map 2.0.6 → 3.0.0
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.
- package/CHANGELOG.md +84 -0
- package/README.md +49 -37
- package/dist/css/plate-map.css +0 -6
- package/dist/css/plate-map.min.css +1 -2
- package/dist/css/plate-map.min.css.map +1 -1
- package/dist/js/plate-map.js +866 -1512
- package/dist/js/plate-map.min.js +1 -2
- package/dist/js/plate-map.min.js.map +1 -1
- package/package.json +20 -15
- package/example/example.js +0 -216
- package/example/index.html +0 -26
- package/gulpfile.js +0 -190
- package/src/css/plate-layout.css +0 -592
- package/src/js/add-data-on-change.js +0 -178
- package/src/js/add-data-to-tabs.js +0 -19
- package/src/js/add-tab-data.js +0 -236
- package/src/js/add-warning-msg.js +0 -104
- package/src/js/bottom-table.js +0 -271
- package/src/js/check-box.js +0 -159
- package/src/js/color-manager.js +0 -59
- package/src/js/create-field.js +0 -1360
- package/src/js/engine.js +0 -185
- package/src/js/image_assets.js +0 -11
- package/src/js/interface.js +0 -100
- package/src/js/load-plate.js +0 -69
- package/src/js/overlay.js +0 -110
- package/src/js/plate-map.js +0 -409
- package/src/js/preset.js +0 -56
- package/src/js/svg-create.js +0 -126
- package/src/js/svg-events.js +0 -354
- package/src/js/tabs.js +0 -82
- package/src/js/undo-redo-manager.js +0 -76
package/dist/js/plate-map.js
CHANGED
|
@@ -1,29 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
-
|
|
5
1
|
var plateMapWidget = plateMapWidget || {};
|
|
6
|
-
|
|
7
2
|
(function ($) {
|
|
8
3
|
plateMapWidget.addDataOnChange = function () {
|
|
9
4
|
// This object is invoked when something in the tab fields change
|
|
10
5
|
return {
|
|
11
|
-
_addAllData: function
|
|
6
|
+
_addAllData: function (data) {
|
|
12
7
|
if (this.selectedIndices) {
|
|
13
|
-
|
|
8
|
+
let noOfSelectedObjects = this.selectedIndices.length;
|
|
14
9
|
this.selectedIndices.forEach(function (index) {
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
let well;
|
|
17
11
|
if (index in this.engine.derivative) {
|
|
18
12
|
well = this.engine.derivative[index];
|
|
19
13
|
} else {
|
|
20
14
|
well = $.extend(true, {}, this.defaultWell);
|
|
21
15
|
this.engine.derivative[index] = well;
|
|
22
16
|
}
|
|
23
|
-
|
|
24
17
|
well = this.processWellData(data, well, noOfSelectedObjects);
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
let empty = this.engine.wellEmpty(well);
|
|
27
19
|
if (empty) {
|
|
28
20
|
if (this.disableAddDeleteWell) {
|
|
29
21
|
if (this.engine.derivative.hasOwnProperty(index)) {
|
|
@@ -35,66 +27,54 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
35
27
|
}
|
|
36
28
|
}
|
|
37
29
|
}, this);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
}
|
|
31
|
+
// update multiplex
|
|
32
|
+
this.decideSelectedFields();
|
|
33
|
+
// create well when default field is sent for the cases when user delete all fields during disabledNewDeleteWell mode
|
|
43
34
|
this._colorMixer();
|
|
44
|
-
|
|
45
35
|
this.derivativeChange();
|
|
46
36
|
this.addToUndoRedo();
|
|
47
37
|
},
|
|
48
|
-
processWellData: function
|
|
49
|
-
for (
|
|
38
|
+
processWellData: function (newData, curWell, noOfSelectedObjects) {
|
|
39
|
+
for (let id in newData) {
|
|
50
40
|
if (!newData.hasOwnProperty(id)) {
|
|
51
41
|
continue;
|
|
52
42
|
}
|
|
53
|
-
|
|
54
|
-
var newVal = newData[id];
|
|
55
|
-
|
|
43
|
+
let newVal = newData[id];
|
|
56
44
|
if (newVal !== undefined && newVal !== null) {
|
|
57
45
|
if (newVal.multi) {
|
|
58
|
-
|
|
46
|
+
let preData = curWell[id];
|
|
59
47
|
newVal = this._getMultiData(preData, newVal, id, noOfSelectedObjects);
|
|
60
48
|
}
|
|
61
|
-
|
|
62
49
|
newVal = JSON.parse(JSON.stringify(newVal));
|
|
63
50
|
} else {
|
|
64
51
|
newVal = null;
|
|
65
52
|
}
|
|
66
|
-
|
|
67
53
|
curWell[id] = newVal;
|
|
68
54
|
}
|
|
69
|
-
|
|
70
55
|
return curWell;
|
|
71
56
|
},
|
|
72
|
-
_getMultiData: function
|
|
73
|
-
|
|
74
|
-
|
|
57
|
+
_getMultiData: function (preData, curData, fieldId, noOfSelectedObjects) {
|
|
58
|
+
let addNew = curData.added;
|
|
59
|
+
let removed = curData.removed;
|
|
75
60
|
preData = preData || [];
|
|
76
|
-
|
|
77
61
|
if (addNew) {
|
|
78
62
|
if (addNew.value) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
63
|
+
const multiplexId = addNew.id.toString();
|
|
64
|
+
const doAll = multiplexId === '[ALL]';
|
|
65
|
+
let add = !doAll;
|
|
82
66
|
preData = preData.map(function (val) {
|
|
83
67
|
if (doAll || val[fieldId].toString() === multiplexId) {
|
|
84
68
|
add = false;
|
|
85
|
-
|
|
86
|
-
for (var subFieldId in addNew.value) {
|
|
69
|
+
for (let subFieldId in addNew.value) {
|
|
87
70
|
if (subFieldId !== fieldId) {
|
|
88
71
|
val[subFieldId] = addNew.value[subFieldId];
|
|
89
72
|
}
|
|
90
73
|
}
|
|
91
|
-
|
|
92
74
|
return val;
|
|
93
75
|
}
|
|
94
|
-
|
|
95
76
|
return val;
|
|
96
77
|
});
|
|
97
|
-
|
|
98
78
|
if (add) {
|
|
99
79
|
preData.push(addNew.value);
|
|
100
80
|
}
|
|
@@ -102,65 +82,55 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
102
82
|
preData.push(addNew);
|
|
103
83
|
}
|
|
104
84
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
for (var idx in preData) {
|
|
85
|
+
let removeListIndex = function (preData, removeIndex) {
|
|
86
|
+
let newPreData = [];
|
|
87
|
+
for (let idx in preData) {
|
|
110
88
|
if (!preData.hasOwnProperty(idx)) {
|
|
111
89
|
continue;
|
|
112
90
|
}
|
|
113
|
-
|
|
114
91
|
if (parseInt(idx) !== parseInt(removeIndex)) {
|
|
115
92
|
newPreData.push(preData[idx]);
|
|
116
93
|
}
|
|
117
94
|
}
|
|
118
|
-
|
|
119
95
|
return newPreData;
|
|
120
96
|
};
|
|
121
|
-
|
|
122
97
|
if (removed) {
|
|
123
|
-
|
|
124
|
-
|
|
98
|
+
let removeIndex;
|
|
99
|
+
// for multiplex field
|
|
125
100
|
if (removed.value) {
|
|
126
|
-
for (
|
|
127
|
-
|
|
128
|
-
|
|
101
|
+
for (let listIdx in preData) {
|
|
102
|
+
let multiplexData = preData[listIdx];
|
|
129
103
|
if (multiplexData[fieldId].toString() === removed.id.toString()) {
|
|
130
104
|
removeIndex = listIdx;
|
|
131
105
|
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
106
|
+
}
|
|
107
|
+
// remove nested element
|
|
135
108
|
preData = removeListIndex(preData, removeIndex);
|
|
136
109
|
} else {
|
|
137
110
|
if (preData) {
|
|
138
111
|
removeIndex = preData.indexOf(removed);
|
|
139
|
-
|
|
140
112
|
if (removeIndex >= 0) {
|
|
141
113
|
preData = removeListIndex(preData, removeIndex);
|
|
142
114
|
}
|
|
143
115
|
}
|
|
144
116
|
}
|
|
145
117
|
}
|
|
146
|
-
|
|
147
118
|
if (preData && preData.length === 0) {
|
|
148
119
|
preData = null;
|
|
149
120
|
}
|
|
150
|
-
|
|
151
121
|
return preData;
|
|
152
122
|
},
|
|
153
|
-
_colorMixer: function
|
|
123
|
+
_colorMixer: function () {
|
|
154
124
|
this.engine.searchAndStack();
|
|
155
125
|
this.engine.applyColors();
|
|
156
126
|
},
|
|
157
|
-
derivativeChange: function
|
|
127
|
+
derivativeChange: function () {
|
|
158
128
|
this._trigger("updateWells", null, this);
|
|
159
129
|
},
|
|
160
|
-
createState: function
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
130
|
+
createState: function () {
|
|
131
|
+
let derivative = $.extend(true, {}, this.engine.derivative);
|
|
132
|
+
let checkboxes = this.getCheckboxes();
|
|
133
|
+
let selectedIndices = this.selectedIndices.slice();
|
|
164
134
|
return {
|
|
165
135
|
"derivative": derivative,
|
|
166
136
|
"checkboxes": checkboxes,
|
|
@@ -168,22 +138,19 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
168
138
|
"requiredField": this.requiredField
|
|
169
139
|
};
|
|
170
140
|
},
|
|
171
|
-
getPlate: function
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
for (var index in derivative) {
|
|
141
|
+
getPlate: function () {
|
|
142
|
+
let wells = {};
|
|
143
|
+
let derivative = this.engine.derivative;
|
|
144
|
+
for (let index in derivative) {
|
|
176
145
|
if (!derivative.hasOwnProperty(index)) {
|
|
177
146
|
continue;
|
|
178
147
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
var well = derivative[index];
|
|
148
|
+
let address = this.indexToAddress(index);
|
|
149
|
+
let well = derivative[index];
|
|
182
150
|
wells[address] = $.extend(true, {}, well);
|
|
183
151
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
var selectedAddresses = this.getSelectedAddresses();
|
|
152
|
+
let checkboxes = this.getCheckboxes();
|
|
153
|
+
let selectedAddresses = this.getSelectedAddresses();
|
|
187
154
|
return {
|
|
188
155
|
"wells": wells,
|
|
189
156
|
"checkboxes": checkboxes,
|
|
@@ -194,68 +161,57 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
194
161
|
};
|
|
195
162
|
};
|
|
196
163
|
})(jQuery);
|
|
197
|
-
|
|
198
164
|
var plateMapWidget = plateMapWidget || {};
|
|
199
|
-
|
|
200
165
|
plateMapWidget.addDataToFields = function () {
|
|
201
166
|
return {
|
|
202
|
-
_addDataToTabFields: function
|
|
167
|
+
_addDataToTabFields: function (well) {
|
|
203
168
|
// Configure how data is added to tab fields
|
|
204
|
-
for (
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
169
|
+
for (let i = 0; i < this.fieldList.length; i++) {
|
|
170
|
+
let field = this.fieldList[i];
|
|
171
|
+
let v = well[field.id];
|
|
208
172
|
if (v === undefined) {
|
|
209
173
|
v = null;
|
|
210
174
|
}
|
|
211
|
-
|
|
212
175
|
field.setValue(v);
|
|
213
176
|
}
|
|
214
177
|
}
|
|
215
178
|
};
|
|
216
179
|
};
|
|
217
|
-
|
|
218
180
|
var plateMapWidget = plateMapWidget || {};
|
|
219
|
-
|
|
220
181
|
(function ($) {
|
|
221
182
|
plateMapWidget.addTabData = function () {
|
|
222
183
|
return {
|
|
223
184
|
fieldList: [],
|
|
224
185
|
fieldMap: {},
|
|
225
186
|
autoId: 1,
|
|
226
|
-
_addTabData: function
|
|
187
|
+
_addTabData: function () {
|
|
227
188
|
// Here we may need more changes because attributes format likely to change
|
|
228
|
-
|
|
229
|
-
|
|
189
|
+
let tabData = this.options.attributes.tabs;
|
|
190
|
+
let that = this;
|
|
230
191
|
this.requiredField = [];
|
|
231
|
-
|
|
192
|
+
let multiplexFieldArray = [];
|
|
232
193
|
tabData.forEach(function (tab, tabPointer) {
|
|
233
194
|
if (tab["fields"]) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
195
|
+
let tabFields = tab["fields"];
|
|
196
|
+
let fieldArray = [];
|
|
197
|
+
// Now we look for fields in the json
|
|
237
198
|
for (var i = 0; i < tabFields.length; i++) {
|
|
238
|
-
|
|
239
|
-
|
|
199
|
+
let data = tabFields[i];
|
|
240
200
|
if (!data.id) {
|
|
241
201
|
data.id = "Auto" + that.autoId++;
|
|
242
202
|
console.log("Field autoassigned id " + data.id);
|
|
243
203
|
}
|
|
244
|
-
|
|
245
204
|
if (!data.type) {
|
|
246
205
|
data.type = "text";
|
|
247
206
|
console.log("Field " + data.id + " autoassigned type " + data.type);
|
|
248
207
|
}
|
|
249
|
-
|
|
250
|
-
var field = void 0;
|
|
251
|
-
|
|
208
|
+
let field;
|
|
252
209
|
if (data.type === "multiplex") {
|
|
253
210
|
field = that._makeMultiplexField(data, tabPointer, fieldArray);
|
|
254
211
|
that.defaultWell[field.id] = [];
|
|
255
212
|
multiplexFieldArray.push(field);
|
|
256
213
|
} else {
|
|
257
214
|
field = that._makeRegularField(data, tabPointer, fieldArray, true);
|
|
258
|
-
|
|
259
215
|
if (data.type === "multiselect") {
|
|
260
216
|
that.defaultWell[field.id] = [];
|
|
261
217
|
multiplexFieldArray.push(field);
|
|
@@ -264,7 +220,6 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
264
220
|
}
|
|
265
221
|
}
|
|
266
222
|
}
|
|
267
|
-
|
|
268
223
|
that.allDataTabs[tabPointer]["fields"] = fieldArray;
|
|
269
224
|
} else {
|
|
270
225
|
console.log("unknown format in field initialization");
|
|
@@ -272,35 +227,27 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
272
227
|
});
|
|
273
228
|
that.multipleFieldList = multiplexFieldArray;
|
|
274
229
|
},
|
|
275
|
-
_makeSubField: function
|
|
276
|
-
|
|
277
|
-
|
|
230
|
+
_makeSubField: function (mainField, data, tabPointer, fieldArray) {
|
|
231
|
+
let that = this;
|
|
278
232
|
if (!data.id) {
|
|
279
233
|
data.id = "Auto" + that.autoId++;
|
|
280
234
|
console.log("Field autoassigned id " + data.id);
|
|
281
235
|
}
|
|
282
|
-
|
|
283
236
|
if (!data.type) {
|
|
284
237
|
data.type = "text";
|
|
285
238
|
console.log("Field " + data.id + " autoassigned type " + data.type);
|
|
286
239
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
var wrapperDivRightSide = that._createElement("<div></div>").addClass("plate-setup-tab-field-right-side");
|
|
293
|
-
|
|
294
|
-
var nameContainer = that._createElement("<div></div>").addClass("plate-setup-tab-name").text(data.name);
|
|
295
|
-
|
|
296
|
-
var fieldContainer = that._createElement("<div></div>").addClass("plate-setup-tab-field-container");
|
|
297
|
-
|
|
240
|
+
let wrapperDiv = that._createElement("<div></div>").addClass("plate-setup-tab-default-field");
|
|
241
|
+
let wrapperDivLeftSide = that._createElement("<div></div>").addClass("plate-setup-tab-field-left-side");
|
|
242
|
+
let wrapperDivRightSide = that._createElement("<div></div>").addClass("plate-setup-tab-field-right-side");
|
|
243
|
+
let nameContainer = that._createElement("<div></div>").addClass("plate-setup-tab-name").text(data.name);
|
|
244
|
+
let fieldContainer = that._createElement("<div></div>").addClass("plate-setup-tab-field-container");
|
|
298
245
|
$(wrapperDivRightSide).append(nameContainer);
|
|
299
246
|
$(wrapperDivRightSide).append(fieldContainer);
|
|
300
247
|
$(wrapperDiv).append(wrapperDivLeftSide);
|
|
301
248
|
$(wrapperDiv).append(wrapperDivRightSide);
|
|
302
249
|
$(that.allDataTabs[tabPointer]).append(wrapperDiv);
|
|
303
|
-
|
|
250
|
+
let field = {
|
|
304
251
|
id: data.id,
|
|
305
252
|
full_id: mainField.id + "_" + data.id,
|
|
306
253
|
name: data.name,
|
|
@@ -312,25 +259,19 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
312
259
|
that.fieldMap[field.full_id] = field;
|
|
313
260
|
return field;
|
|
314
261
|
},
|
|
315
|
-
_makeRegularField: function
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
var wrapperDivRightSide = that._createElement("<div></div>").addClass("plate-setup-tab-field-right-side ");
|
|
323
|
-
|
|
324
|
-
var nameContainer = that._createElement("<div></div>").addClass("plate-setup-tab-name").text(data.name);
|
|
325
|
-
|
|
326
|
-
var fieldContainer = that._createElement("<div></div>").addClass("plate-setup-tab-field-container");
|
|
327
|
-
|
|
262
|
+
_makeRegularField: function (data, tabPointer, fieldArray, checkbox) {
|
|
263
|
+
let that = this;
|
|
264
|
+
let wrapperDiv = that._createElement("<div></div>").addClass("plate-setup-tab-default-field");
|
|
265
|
+
let wrapperDivLeftSide = that._createElement("<div></div>").addClass("plate-setup-tab-field-left-side");
|
|
266
|
+
let wrapperDivRightSide = that._createElement("<div></div>").addClass("plate-setup-tab-field-right-side ");
|
|
267
|
+
let nameContainer = that._createElement("<div></div>").addClass("plate-setup-tab-name").text(data.name);
|
|
268
|
+
let fieldContainer = that._createElement("<div></div>").addClass("plate-setup-tab-field-container");
|
|
328
269
|
wrapperDivRightSide.append(nameContainer);
|
|
329
270
|
wrapperDivRightSide.append(fieldContainer);
|
|
330
271
|
wrapperDiv.append(wrapperDivLeftSide);
|
|
331
272
|
wrapperDiv.append(wrapperDivRightSide);
|
|
332
273
|
that.allDataTabs[tabPointer].append(wrapperDiv);
|
|
333
|
-
|
|
274
|
+
let field = {
|
|
334
275
|
id: data.id,
|
|
335
276
|
full_id: data.id,
|
|
336
277
|
name: data.name,
|
|
@@ -338,50 +279,39 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
338
279
|
data: data,
|
|
339
280
|
required: data.required
|
|
340
281
|
};
|
|
341
|
-
|
|
342
282
|
if (field.required) {
|
|
343
283
|
that.requiredField.push(field.id);
|
|
344
284
|
}
|
|
345
|
-
|
|
346
285
|
fieldArray.push(field);
|
|
347
286
|
that.fieldList.push(field);
|
|
348
|
-
that.fieldMap[field.full_id] = field;
|
|
287
|
+
that.fieldMap[field.full_id] = field;
|
|
349
288
|
|
|
289
|
+
// Adding checkbox
|
|
350
290
|
if (checkbox) {
|
|
351
291
|
that._addCheckBox(field);
|
|
352
292
|
}
|
|
353
|
-
|
|
354
293
|
that._createField(field);
|
|
355
|
-
|
|
356
294
|
field.onChange = function () {
|
|
357
|
-
|
|
358
|
-
|
|
295
|
+
let v = field.getValue();
|
|
296
|
+
let data = {};
|
|
359
297
|
data[field.id] = v;
|
|
360
|
-
|
|
361
298
|
that._addAllData(data);
|
|
362
299
|
};
|
|
363
|
-
|
|
364
300
|
return field;
|
|
365
301
|
},
|
|
366
|
-
_makeMultiplexField: function
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
var wrapperDivRightSide = that._createElement("<div></div>").addClass("plate-setup-tab-field-right-side ");
|
|
374
|
-
|
|
375
|
-
var nameContainer = that._createElement("<div></div>").addClass("plate-setup-tab-name").text(data.name);
|
|
376
|
-
|
|
377
|
-
var fieldContainer = that._createElement("<div></div>").addClass("plate-setup-tab-field-container");
|
|
378
|
-
|
|
302
|
+
_makeMultiplexField: function (data, tabPointer, fieldArray) {
|
|
303
|
+
let that = this;
|
|
304
|
+
let wrapperDiv = that._createElement("<div></div>").addClass("plate-setup-tab-default-field");
|
|
305
|
+
let wrapperDivLeftSide = that._createElement("<div></div>").addClass("plate-setup-tab-field-left-side");
|
|
306
|
+
let wrapperDivRightSide = that._createElement("<div></div>").addClass("plate-setup-tab-field-right-side ");
|
|
307
|
+
let nameContainer = that._createElement("<div></div>").addClass("plate-setup-tab-name").text(data.name);
|
|
308
|
+
let fieldContainer = that._createElement("<div></div>").addClass("plate-setup-tab-field-container");
|
|
379
309
|
wrapperDivRightSide.append(nameContainer);
|
|
380
310
|
wrapperDivRightSide.append(fieldContainer);
|
|
381
311
|
wrapperDiv.append(wrapperDivLeftSide);
|
|
382
312
|
wrapperDiv.append(wrapperDivRightSide);
|
|
383
313
|
that.allDataTabs[tabPointer].append(wrapperDiv);
|
|
384
|
-
|
|
314
|
+
let field = {
|
|
385
315
|
id: data.id,
|
|
386
316
|
full_id: data.id,
|
|
387
317
|
name: data.name,
|
|
@@ -392,73 +322,59 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
392
322
|
fieldArray.push(field);
|
|
393
323
|
that.fieldList.push(field);
|
|
394
324
|
that.fieldMap[field.full_id] = field;
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
subFieldList.push(subField); // stores required subField
|
|
405
|
-
|
|
325
|
+
let subFieldList = [];
|
|
326
|
+
//create subfields
|
|
327
|
+
let requiredSubField = [];
|
|
328
|
+
for (let i = 0; i < data.multiplexFields.length; i++) {
|
|
329
|
+
let subFieldData = data.multiplexFields[i];
|
|
330
|
+
let subField = that._makeSubField(field, subFieldData, tabPointer, fieldArray);
|
|
331
|
+
subFieldList.push(subField);
|
|
332
|
+
|
|
333
|
+
// stores required subField
|
|
406
334
|
if (subFieldData.required) {
|
|
407
335
|
requiredSubField.push(subField.id);
|
|
408
336
|
}
|
|
409
|
-
}
|
|
410
|
-
|
|
337
|
+
}
|
|
411
338
|
|
|
339
|
+
//store required field
|
|
412
340
|
if (field.required || requiredSubField.length) {
|
|
413
341
|
this.requiredField.push({
|
|
414
342
|
multiplexId: field.id,
|
|
415
343
|
subFields: requiredSubField
|
|
416
344
|
});
|
|
417
345
|
}
|
|
418
|
-
|
|
419
346
|
field.subFieldList = subFieldList;
|
|
420
|
-
|
|
421
347
|
that._createField(field);
|
|
422
|
-
|
|
423
348
|
that._addCheckBox(field);
|
|
424
|
-
|
|
425
349
|
subFieldList.forEach(function (subfield) {
|
|
426
350
|
subfield.mainMultiplexField = field;
|
|
427
|
-
|
|
428
351
|
that._createField(subfield);
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
352
|
+
that._addCheckBox(subfield);
|
|
353
|
+
// overwrite subField setvalue
|
|
433
354
|
subfield.onChange = function () {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
curVal[mainRefField.id] = curId;
|
|
440
|
-
|
|
355
|
+
let v = subfield.getValue();
|
|
356
|
+
let mainRefField = subfield.mainMultiplexField;
|
|
357
|
+
let curId = mainRefField.singleSelectValue();
|
|
358
|
+
//let curDataLs = mainRefField.detailData;
|
|
359
|
+
let curVal = {};
|
|
360
|
+
curVal[mainRefField.id] = curId;
|
|
361
|
+
//append subfields
|
|
441
362
|
curVal[subfield.id] = v;
|
|
442
|
-
|
|
363
|
+
let returnVal = {
|
|
443
364
|
id: curId,
|
|
444
365
|
value: curVal
|
|
445
366
|
};
|
|
446
|
-
|
|
447
367
|
field._changeMultiFieldValue(returnVal, null);
|
|
448
|
-
|
|
449
|
-
var curDataLs = mainRefField.detailData;
|
|
450
|
-
|
|
368
|
+
let curDataLs = mainRefField.detailData;
|
|
451
369
|
if (curDataLs !== null) {
|
|
452
370
|
curId = mainRefField.singleSelectValue();
|
|
453
371
|
curDataLs = curDataLs.map(function (curData) {
|
|
454
372
|
if (curData[mainRefField.id] === curId) {
|
|
455
373
|
curData[subfield.id] = v;
|
|
456
374
|
}
|
|
457
|
-
|
|
458
375
|
return curData;
|
|
459
376
|
});
|
|
460
377
|
}
|
|
461
|
-
|
|
462
378
|
mainRefField.detailData = curDataLs;
|
|
463
379
|
};
|
|
464
380
|
});
|
|
@@ -467,23 +383,20 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
467
383
|
};
|
|
468
384
|
};
|
|
469
385
|
})(jQuery);
|
|
470
|
-
|
|
471
386
|
var plateMapWidget = plateMapWidget || {};
|
|
472
|
-
|
|
473
387
|
(function ($) {
|
|
474
388
|
plateMapWidget.addWarningMsg = function () {
|
|
475
389
|
// For those check boxes associated with every field in the tab
|
|
476
390
|
return {
|
|
477
|
-
fieldWarningMsg: function
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
391
|
+
fieldWarningMsg: function (field, text, include) {
|
|
392
|
+
let that = this;
|
|
393
|
+
let imgId = "fieldWarning" + field.full_id;
|
|
394
|
+
let img = $("<span>").html(that._assets.warningImg).attr("id", imgId).addClass("plate-field-warning-image");
|
|
482
395
|
if (include) {
|
|
483
396
|
if (field.root.find("#" + imgId).length <= 0) {
|
|
484
397
|
field.root.find(".plate-setup-tab-name").text(" " + field.name);
|
|
485
398
|
field.root.find(".plate-setup-tab-name").prepend(img);
|
|
486
|
-
|
|
399
|
+
let popText = $("<div/>").addClass("pop-out-text");
|
|
487
400
|
popText.text(text);
|
|
488
401
|
field.root.find(".plate-setup-tab-name").append(popText);
|
|
489
402
|
$("#" + imgId).hover(function () {
|
|
@@ -499,14 +412,13 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
499
412
|
}
|
|
500
413
|
}
|
|
501
414
|
},
|
|
502
|
-
removeWarningMsg: function
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
415
|
+
removeWarningMsg: function (field, text, include) {
|
|
416
|
+
let that = this;
|
|
417
|
+
let imgId = "fieldWarning" + field.full_id;
|
|
506
418
|
if (include) {
|
|
507
|
-
|
|
419
|
+
let img = $("<span>").html(that._assets.warningImg).attr("id", imgId).addClass("plate-field-warning-image");
|
|
508
420
|
field.root.find(".plate-setup-tab-name").append(img);
|
|
509
|
-
|
|
421
|
+
let popText = $("<div/>").addClass("pop-out-text");
|
|
510
422
|
popText.text(text);
|
|
511
423
|
field.root.find(".plate-setup-tab-name").append(popText);
|
|
512
424
|
img.hover(function () {
|
|
@@ -518,15 +430,15 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
518
430
|
$("#" + imgId).remove();
|
|
519
431
|
}
|
|
520
432
|
},
|
|
521
|
-
applyFieldWarning: function
|
|
522
|
-
|
|
523
|
-
|
|
433
|
+
applyFieldWarning: function (wells) {
|
|
434
|
+
let that = this;
|
|
435
|
+
let fieldData = {};
|
|
524
436
|
that.fieldList.forEach(function (field) {
|
|
525
437
|
fieldData[field.id] = [];
|
|
526
438
|
});
|
|
527
439
|
wells.forEach(function (well) {
|
|
528
440
|
if (!that.engine.wellEmpty(well)) {
|
|
529
|
-
for (
|
|
441
|
+
for (let fieldId in fieldData) {
|
|
530
442
|
if (fieldData.hasOwnProperty(fieldId)) {
|
|
531
443
|
if (fieldId in well) {
|
|
532
444
|
fieldData[fieldId].push(well[fieldId]);
|
|
@@ -537,15 +449,13 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
537
449
|
}
|
|
538
450
|
}
|
|
539
451
|
});
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
var field = that.fieldList[i];
|
|
543
|
-
|
|
452
|
+
for (let i = 0; i < that.fieldList.length; i++) {
|
|
453
|
+
let field = that.fieldList[i];
|
|
544
454
|
if (field.applyMultiplexSubFieldColor) {
|
|
545
455
|
field.applyMultiplexSubFieldColor(fieldData[field.id]);
|
|
546
456
|
} else {
|
|
547
457
|
if (field.required) {
|
|
548
|
-
|
|
458
|
+
let include = false;
|
|
549
459
|
fieldData[field.id].forEach(function (val) {
|
|
550
460
|
// for multiselect
|
|
551
461
|
if (val instanceof Array) {
|
|
@@ -557,8 +467,8 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
557
467
|
include = true;
|
|
558
468
|
}
|
|
559
469
|
}
|
|
560
|
-
});
|
|
561
|
-
|
|
470
|
+
});
|
|
471
|
+
//field.root.find(".plate-setup-tab-name").css("background", color);
|
|
562
472
|
that.fieldWarningMsg(field, "required field", include);
|
|
563
473
|
}
|
|
564
474
|
}
|
|
@@ -567,14 +477,12 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
567
477
|
};
|
|
568
478
|
};
|
|
569
479
|
})(jQuery);
|
|
570
|
-
|
|
571
480
|
var plateMapWidget = plateMapWidget || {};
|
|
572
|
-
|
|
573
481
|
(function ($) {
|
|
574
482
|
plateMapWidget.bottomTable = function () {
|
|
575
483
|
// for bottom table
|
|
576
484
|
return {
|
|
577
|
-
_bottomScreen: function
|
|
485
|
+
_bottomScreen: function () {
|
|
578
486
|
this.bottomContainer = this._createElement("<div></div>").addClass("plate-setup-bottom-container");
|
|
579
487
|
this.bottomTableContainer = this._createElement("<div></div>").addClass("plate-setup-bottom-table-container");
|
|
580
488
|
this.bottomTable = this._createElement("<table></table>").addClass("plate-setup-bottom-table");
|
|
@@ -586,51 +494,43 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
586
494
|
this.bottomContainer.append(this.bottomTableContainer);
|
|
587
495
|
this.container.append(this.bottomContainer);
|
|
588
496
|
},
|
|
589
|
-
addBottomTableHeadings: function
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
row.prepend(singleField);
|
|
497
|
+
addBottomTableHeadings: function () {
|
|
498
|
+
let row = this._createElement("<tr></tr>");
|
|
499
|
+
let singleField = this._createElement("<th></th>").text("Group");
|
|
500
|
+
row.html(singleField);
|
|
595
501
|
this.rowCounter = 1;
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
var _singleField = this._createElement("<th></th>").text(field.name);
|
|
602
|
-
|
|
603
|
-
row.append(_singleField);
|
|
502
|
+
for (let i = 0; i < this.globalSelectedAttributes.length; i++) {
|
|
503
|
+
let attr = this.globalSelectedAttributes[i];
|
|
504
|
+
let field = this.fieldMap[attr];
|
|
505
|
+
let singleField = this._createElement("<th></th>").text(field.name);
|
|
506
|
+
row.append(singleField);
|
|
604
507
|
this.rowCounter = this.rowCounter + 1;
|
|
605
|
-
}
|
|
606
|
-
|
|
508
|
+
}
|
|
607
509
|
|
|
510
|
+
// Now we append all the captions at the place.
|
|
608
511
|
this.bottomTableBody.empty();
|
|
609
512
|
this.bottomTableHead.empty();
|
|
610
513
|
this.bottomTableHead.append(row);
|
|
611
514
|
this.adjustFieldWidth(row);
|
|
612
515
|
},
|
|
613
|
-
tileAttrText: function
|
|
614
|
-
|
|
615
|
-
|
|
516
|
+
tileAttrText: function (tile, attr) {
|
|
517
|
+
let well = this.engine.derivative[tile.index];
|
|
518
|
+
let field = this.fieldMap[attr];
|
|
616
519
|
return field.getText(well[attr]);
|
|
617
520
|
},
|
|
618
|
-
addBottomTableRow: function
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
var plateIdDiv = this._createElement("<td></td>").addClass("plate-setup-bottom-id");
|
|
625
|
-
|
|
626
|
-
var numberText = this._createElement("<button/>");
|
|
627
|
-
|
|
521
|
+
addBottomTableRow: function (color, singleStack) {
|
|
522
|
+
let that = this;
|
|
523
|
+
let modelTile = this.allTiles[singleStack[0]];
|
|
524
|
+
let row = this._createElement("<tr></tr>");
|
|
525
|
+
let plateIdDiv = this._createElement("<td></td>").addClass("plate-setup-bottom-id");
|
|
526
|
+
let numberText = this._createElement("<button/>");
|
|
628
527
|
numberText.addClass("plate-setup-color-text");
|
|
629
528
|
numberText.text(color);
|
|
630
529
|
plateIdDiv.append(numberText);
|
|
631
530
|
numberText.click(function (evt) {
|
|
632
|
-
|
|
633
|
-
|
|
531
|
+
// Arrow, not a bare method reference: .map() would pass the array
|
|
532
|
+
// position as indexToAddress's `dimensions` argument
|
|
533
|
+
let addressToSelect = singleStack.map(index => that.indexToAddress(index));
|
|
634
534
|
if (evt.ctrlKey) {
|
|
635
535
|
that.getSelectedAddresses().forEach(function (val) {
|
|
636
536
|
if (addressToSelect.indexOf(val) < 0) {
|
|
@@ -638,90 +538,83 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
638
538
|
}
|
|
639
539
|
});
|
|
640
540
|
}
|
|
641
|
-
|
|
642
541
|
that.setSelectedAddresses(addressToSelect);
|
|
643
542
|
});
|
|
644
|
-
|
|
645
543
|
if (color > 0) {
|
|
646
544
|
color = (color - 1) % (this.colorPairs.length - 1) + 1;
|
|
647
545
|
}
|
|
648
|
-
|
|
649
|
-
var colorStops = this.colorPairs[color];
|
|
546
|
+
let colorStops = this.colorPairs[color];
|
|
650
547
|
plateIdDiv.css("background", "linear-gradient(to right, " + colorStops[0] + " , " + colorStops[1] + ")");
|
|
651
548
|
row.append(plateIdDiv);
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
var dataDiv = this._createElement("<td></td>").text(text);
|
|
658
|
-
|
|
549
|
+
for (let i = 0; i < this.globalSelectedAttributes.length; i++) {
|
|
550
|
+
let attr = this.globalSelectedAttributes[i];
|
|
551
|
+
let text = this.tileAttrText(modelTile, attr);
|
|
552
|
+
let dataDiv = this._createElement("<td></td>").text(text);
|
|
659
553
|
row.append(dataDiv);
|
|
660
554
|
}
|
|
661
|
-
|
|
662
555
|
this.bottomTableBody.append(row);
|
|
663
556
|
this.adjustFieldWidth(row);
|
|
664
557
|
},
|
|
665
|
-
bottomForFirstTime: function
|
|
666
|
-
this.addBottomTableHeadings();
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
var plateIdDiv = this._createElement("<td></td>");
|
|
673
|
-
|
|
558
|
+
bottomForFirstTime: function () {
|
|
559
|
+
this.addBottomTableHeadings();
|
|
560
|
+
// This is executed for the very first time.. !
|
|
561
|
+
let row = this._createElement("<tr></tr>");
|
|
562
|
+
let colorStops = this.colorPairs[0];
|
|
563
|
+
let plateIdDiv = this._createElement("<td></td>");
|
|
674
564
|
plateIdDiv.css("background", "-webkit-linear-gradient(left, " + colorStops[0] + " , " + colorStops[1] + ")");
|
|
675
565
|
row.append(plateIdDiv);
|
|
676
566
|
this.bottomTableBody.append(row);
|
|
677
567
|
this.createExportButton();
|
|
678
568
|
},
|
|
679
|
-
adjustFieldWidth: function
|
|
680
|
-
|
|
681
|
-
|
|
569
|
+
adjustFieldWidth: function (row) {
|
|
570
|
+
let length = this.rowCounter;
|
|
682
571
|
if (length * 150 > 1024) {
|
|
683
572
|
row.css("width", length * 152 + "px");
|
|
684
573
|
}
|
|
685
574
|
},
|
|
686
|
-
downloadCSV: function
|
|
687
|
-
|
|
688
|
-
|
|
575
|
+
downloadCSV: function (csv, filename) {
|
|
576
|
+
let csvFile;
|
|
577
|
+
let downloadLink;
|
|
689
578
|
|
|
579
|
+
// CSV file
|
|
690
580
|
csvFile = new Blob([csv], {
|
|
691
581
|
type: "text/csv"
|
|
692
|
-
});
|
|
582
|
+
});
|
|
693
583
|
|
|
694
|
-
|
|
584
|
+
// Download link
|
|
585
|
+
downloadLink = document.createElement("a");
|
|
695
586
|
|
|
696
|
-
|
|
587
|
+
// File name
|
|
588
|
+
downloadLink.download = filename;
|
|
697
589
|
|
|
698
|
-
|
|
590
|
+
// Create a link to the file
|
|
591
|
+
downloadLink.href = window.URL.createObjectURL(csvFile);
|
|
699
592
|
|
|
700
|
-
|
|
593
|
+
// Hide download link
|
|
594
|
+
downloadLink.style.display = "none";
|
|
701
595
|
|
|
702
|
-
|
|
596
|
+
// Add the link to DOM
|
|
597
|
+
document.body.appendChild(downloadLink);
|
|
703
598
|
|
|
599
|
+
// Click download link
|
|
704
600
|
downloadLink.click();
|
|
705
601
|
},
|
|
706
|
-
exportData: function
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
for (var colorIdx in colorLocIdxMap) {
|
|
602
|
+
exportData: function (format) {
|
|
603
|
+
let data = [];
|
|
604
|
+
let rows = document.querySelectorAll("table tr");
|
|
605
|
+
let colorLocMap = {};
|
|
606
|
+
let colorLocIdxMap = this.engine.stackUpWithColor;
|
|
607
|
+
for (let colorIdx in colorLocIdxMap) {
|
|
713
608
|
if (colorLocIdxMap.hasOwnProperty(colorIdx)) {
|
|
714
|
-
|
|
609
|
+
// Arrow, not a bare method reference (see addBottomTableRow)
|
|
610
|
+
colorLocMap[colorIdx] = colorLocIdxMap[colorIdx].map(index => this.indexToAddress(index));
|
|
715
611
|
}
|
|
716
612
|
}
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
for (var j = 0; j < cols.length; j++) {
|
|
723
|
-
var v = "";
|
|
724
|
-
|
|
613
|
+
for (let i = 0; i < rows.length; i++) {
|
|
614
|
+
let row = [],
|
|
615
|
+
cols = rows[i].querySelectorAll("td, th");
|
|
616
|
+
for (let j = 0; j < cols.length; j++) {
|
|
617
|
+
let v = "";
|
|
725
618
|
if (cols[j].innerText) {
|
|
726
619
|
if (format === "csv") {
|
|
727
620
|
v = '"' + cols[j].innerText.replace(/"/g, '""') + '"';
|
|
@@ -729,95 +622,89 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
729
622
|
v = cols[j].innerText;
|
|
730
623
|
}
|
|
731
624
|
}
|
|
625
|
+
row.push(v);
|
|
732
626
|
|
|
733
|
-
|
|
734
|
-
|
|
627
|
+
// add location column
|
|
735
628
|
if (i === 0 && j === 0) {
|
|
736
629
|
if (format === "csv") {
|
|
737
630
|
row.push('"Location"');
|
|
738
|
-
} else if (format ===
|
|
631
|
+
} else if (format === "clipboard") {
|
|
739
632
|
row.push("Location");
|
|
740
633
|
}
|
|
741
634
|
}
|
|
742
|
-
|
|
743
635
|
if (i !== 0 && j === 0) {
|
|
744
|
-
|
|
745
|
-
|
|
636
|
+
let loc = "";
|
|
746
637
|
if (colorLocMap[parseInt(cols[j].innerText)]) {
|
|
747
638
|
if (format === "csv") {
|
|
748
639
|
loc = '"' + colorLocMap[parseInt(cols[j].innerText)].join(",") + '"';
|
|
749
|
-
} else if (format ===
|
|
640
|
+
} else if (format === "clipboard") {
|
|
750
641
|
loc = colorLocMap[parseInt(cols[j].innerText)].join(",");
|
|
751
642
|
}
|
|
752
643
|
}
|
|
753
|
-
|
|
754
644
|
row.push(loc);
|
|
755
645
|
}
|
|
756
646
|
}
|
|
757
|
-
|
|
758
647
|
if (format === "csv") {
|
|
759
648
|
data.push(row.join(","));
|
|
760
|
-
} else if (format ===
|
|
761
|
-
data.push(row.join("\t"));
|
|
649
|
+
} else if (format === "clipboard") {
|
|
650
|
+
data.push(row.join("\t"));
|
|
651
|
+
//data.push(row); // for text type
|
|
762
652
|
}
|
|
763
653
|
}
|
|
764
|
-
|
|
765
654
|
if (format === "csv") {
|
|
766
655
|
// Download CSV file
|
|
767
|
-
this.downloadCSV(data.join("\n"),
|
|
768
|
-
} else if (format ===
|
|
656
|
+
this.downloadCSV(data.join("\n"), "table.csv");
|
|
657
|
+
} else if (format === "clipboard") {
|
|
769
658
|
//return formatTableToString(data); // for text type
|
|
770
659
|
return data.join("\n");
|
|
771
660
|
}
|
|
772
661
|
},
|
|
773
|
-
createExportButton: function
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
662
|
+
createExportButton: function () {
|
|
663
|
+
let that = this;
|
|
664
|
+
let overlayContainer = $("<div>").addClass("plate-setup-bottom-control-container");
|
|
665
|
+
let descriptionDiv = $("<div>").addClass("plate-setup-overlay-text-container");
|
|
777
666
|
descriptionDiv.text("Color groups");
|
|
778
667
|
overlayContainer.append(descriptionDiv);
|
|
779
|
-
|
|
668
|
+
let buttonContainer = $("<div>").addClass("plate-setup-overlay-bottom-button-container");
|
|
780
669
|
|
|
781
|
-
|
|
670
|
+
// create export csv option
|
|
671
|
+
let exportButton = $("<button/>").addClass("plate-setup-button");
|
|
782
672
|
exportButton.text("Export CSV");
|
|
783
673
|
buttonContainer.append(exportButton);
|
|
784
674
|
exportButton.click(function () {
|
|
785
|
-
that.exportData(
|
|
675
|
+
that.exportData("csv");
|
|
786
676
|
exportButton.text("Exported");
|
|
787
677
|
exportButton[0].classList.remove("plate-setup-button");
|
|
788
678
|
exportButton.addClass("plate-setup-clicked-button");
|
|
789
679
|
setTimeout(resetExportText, 3000);
|
|
790
680
|
});
|
|
791
|
-
|
|
792
681
|
function resetExportText() {
|
|
793
682
|
exportButton.text("Export CSV");
|
|
794
683
|
exportButton[0].classList.remove("plate-setup-clicked-button");
|
|
795
684
|
exportButton.addClass("plate-setup-button");
|
|
796
|
-
}
|
|
797
|
-
|
|
685
|
+
}
|
|
798
686
|
|
|
799
|
-
|
|
687
|
+
// creat clipboard option, CLipboard is an external js file located in vendor/asset/javascripts
|
|
688
|
+
let clipboardButton = $("<button/>").addClass("plate-setup-button");
|
|
800
689
|
clipboardButton.text("Copy To Clipboard");
|
|
801
690
|
buttonContainer.append(clipboardButton);
|
|
802
|
-
|
|
803
|
-
text: function
|
|
691
|
+
let clipboard = new ClipboardJS(clipboardButton.get(0), {
|
|
692
|
+
text: function () {
|
|
804
693
|
return that.exportData("clipboard");
|
|
805
694
|
}
|
|
806
695
|
});
|
|
807
|
-
clipboard.on(
|
|
696
|
+
clipboard.on("success", function () {
|
|
808
697
|
clipboardButton.text("Copied as tab-delimited format");
|
|
809
698
|
clipboardButton[0].classList.remove("plate-setup-button");
|
|
810
699
|
clipboardButton.addClass("plate-setup-clicked-button");
|
|
811
700
|
setTimeout(resetClipboardText, 3000);
|
|
812
701
|
});
|
|
813
|
-
|
|
814
702
|
function resetClipboardText() {
|
|
815
703
|
clipboardButton.text("Copy To Clipboard");
|
|
816
704
|
clipboardButton[0].classList.remove("plate-setup-clicked-button");
|
|
817
705
|
clipboardButton.addClass("plate-setup-button");
|
|
818
706
|
}
|
|
819
|
-
|
|
820
|
-
clipboard.on('error', function () {
|
|
707
|
+
clipboard.on("error", function () {
|
|
821
708
|
clipboardButton.text("Failed to copy table to clipboard: browser may be incompatible");
|
|
822
709
|
setTimeout(resetClipboardText, 3000);
|
|
823
710
|
});
|
|
@@ -827,9 +714,7 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
827
714
|
};
|
|
828
715
|
};
|
|
829
716
|
})(jQuery);
|
|
830
|
-
|
|
831
717
|
var plateMapWidget = plateMapWidget || {};
|
|
832
|
-
|
|
833
718
|
(function ($) {
|
|
834
719
|
plateMapWidget.checkBox = function () {
|
|
835
720
|
// For those check boxes associated with every field in the tab
|
|
@@ -837,53 +722,46 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
837
722
|
globalSelectedAttributes: [],
|
|
838
723
|
globalSelectedMultiplexSubfield: [],
|
|
839
724
|
allCheckboxes: [],
|
|
840
|
-
_addCheckBox: function
|
|
841
|
-
|
|
842
|
-
|
|
725
|
+
_addCheckBox: function (field) {
|
|
726
|
+
let checkImage = $("<span>").html(this._assets.dontImg).addClass("plate-setup-tab-check-box bg-light").data("clicked", false);
|
|
727
|
+
let linkedFieldId = field.full_id;
|
|
843
728
|
checkImage.data("linkedFieldId", linkedFieldId);
|
|
844
729
|
field.root.find(".plate-setup-tab-field-left-side").empty().append(checkImage);
|
|
845
|
-
|
|
846
730
|
this._applyCheckboxHandler(checkImage); // Adding handler for change the image when clicked
|
|
847
|
-
|
|
848
|
-
|
|
849
731
|
field.checkbox = checkImage;
|
|
850
732
|
this.allCheckboxes.push(linkedFieldId);
|
|
851
733
|
},
|
|
852
|
-
_applyCheckboxHandler: function
|
|
853
|
-
|
|
734
|
+
_applyCheckboxHandler: function (checkBoxImage) {
|
|
735
|
+
let that = this;
|
|
854
736
|
checkBoxImage.click(function () {
|
|
855
|
-
|
|
856
|
-
|
|
737
|
+
let checkBox = $(this);
|
|
738
|
+
let changes = {};
|
|
857
739
|
changes[checkBox.data("linkedFieldId")] = !checkBox.data("clicked");
|
|
858
740
|
that.changeCheckboxes(changes);
|
|
859
741
|
});
|
|
860
742
|
},
|
|
861
|
-
getCheckboxes: function
|
|
743
|
+
getCheckboxes: function () {
|
|
862
744
|
return this.allCheckboxes.filter(function (fieldId) {
|
|
863
|
-
|
|
864
|
-
|
|
745
|
+
let field = this.fieldMap[fieldId];
|
|
865
746
|
if (field.mainMultiplexField) {
|
|
866
|
-
|
|
747
|
+
let subfields = this.globalSelectedMultiplexSubfield[field.mainMultiplexField.id] || [];
|
|
867
748
|
return subfields.indexOf(field.id);
|
|
868
749
|
} else {
|
|
869
750
|
return this.globalSelectedAttributes.indexOf(field.id) >= 0;
|
|
870
751
|
}
|
|
871
752
|
}, this);
|
|
872
753
|
},
|
|
873
|
-
changeSubFieldsCheckboxes: function
|
|
874
|
-
|
|
875
|
-
|
|
754
|
+
changeSubFieldsCheckboxes: function (field, changes) {
|
|
755
|
+
let that = this;
|
|
756
|
+
let subFieldToInclude = [];
|
|
876
757
|
field.subFieldList.forEach(function (subField) {
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
758
|
+
let checkImage = subField.checkbox;
|
|
759
|
+
let fieldId = checkImage.data("linkedFieldId");
|
|
760
|
+
let clicked = checkImage.data("clicked");
|
|
881
761
|
if (fieldId in changes) {
|
|
882
762
|
clicked = Boolean(changes[fieldId]);
|
|
883
763
|
}
|
|
884
|
-
|
|
885
764
|
checkImage.data("clicked", clicked);
|
|
886
|
-
|
|
887
765
|
if (clicked) {
|
|
888
766
|
checkImage.html(that._assets.doImg);
|
|
889
767
|
subFieldToInclude.push(subField.id);
|
|
@@ -893,28 +771,22 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
893
771
|
});
|
|
894
772
|
return subFieldToInclude;
|
|
895
773
|
},
|
|
896
|
-
changeCheckboxes: function
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
var field = this.fieldList[i];
|
|
902
|
-
|
|
774
|
+
changeCheckboxes: function (changes, noUndoRedo) {
|
|
775
|
+
let gsa = [];
|
|
776
|
+
let multiplexCheckedSubField = {};
|
|
777
|
+
for (let i = 0; i < this.fieldList.length; i++) {
|
|
778
|
+
let field = this.fieldList[i];
|
|
903
779
|
if (field.checkbox) {
|
|
904
780
|
if (field.subFieldList) {
|
|
905
781
|
multiplexCheckedSubField[field.id] = this.changeSubFieldsCheckboxes(field, changes);
|
|
906
782
|
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
var clicked = checkImage.data("clicked");
|
|
911
|
-
|
|
783
|
+
let checkImage = field.checkbox;
|
|
784
|
+
let fieldId = checkImage.data("linkedFieldId");
|
|
785
|
+
let clicked = checkImage.data("clicked");
|
|
912
786
|
if (fieldId in changes) {
|
|
913
787
|
clicked = Boolean(changes[fieldId]);
|
|
914
788
|
}
|
|
915
|
-
|
|
916
789
|
checkImage.data("clicked", clicked);
|
|
917
|
-
|
|
918
790
|
if (clicked) {
|
|
919
791
|
gsa.push(fieldId);
|
|
920
792
|
checkImage.html(this._assets.doImg);
|
|
@@ -923,27 +795,22 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
923
795
|
}
|
|
924
796
|
}
|
|
925
797
|
}
|
|
926
|
-
|
|
927
798
|
this.globalSelectedMultiplexSubfield = multiplexCheckedSubField;
|
|
928
799
|
this.globalSelectedAttributes = gsa;
|
|
929
|
-
|
|
930
800
|
this._clearPresetSelection();
|
|
931
|
-
|
|
932
801
|
this._colorMixer();
|
|
933
|
-
|
|
934
802
|
if (!noUndoRedo) {
|
|
935
803
|
this.addToUndoRedo();
|
|
936
804
|
}
|
|
937
805
|
},
|
|
938
|
-
setSubFieldCheckboxes: function
|
|
939
|
-
|
|
940
|
-
|
|
806
|
+
setSubFieldCheckboxes: function (field, fieldIds) {
|
|
807
|
+
let that = this;
|
|
808
|
+
let subFieldToInclude = [];
|
|
941
809
|
field.subFieldList.forEach(function (subField) {
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
810
|
+
let checkImage = subField.checkbox;
|
|
811
|
+
let fieldId = checkImage.data("linkedFieldId");
|
|
812
|
+
let clicked = fieldIds.indexOf(fieldId) >= 0;
|
|
945
813
|
checkImage.data("clicked", clicked);
|
|
946
|
-
|
|
947
814
|
if (clicked) {
|
|
948
815
|
checkImage.html(that._assets.doImg);
|
|
949
816
|
subFieldToInclude.push(subField.id);
|
|
@@ -953,25 +820,21 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
953
820
|
});
|
|
954
821
|
return subFieldToInclude;
|
|
955
822
|
},
|
|
956
|
-
setCheckboxes: function
|
|
823
|
+
setCheckboxes: function (fieldIds, noUndoRedo) {
|
|
957
824
|
fieldIds = fieldIds || [];
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
var field = this.fieldList[i];
|
|
963
|
-
|
|
825
|
+
let gsa = [];
|
|
826
|
+
let multiplexCheckedSubField = {};
|
|
827
|
+
for (let i = 0; i < this.fieldList.length; i++) {
|
|
828
|
+
let field = this.fieldList[i];
|
|
964
829
|
if (field.checkbox) {
|
|
965
830
|
// special handling for multiplex field
|
|
966
831
|
if (field.subFieldList) {
|
|
967
832
|
multiplexCheckedSubField[field.id] = this.setSubFieldCheckboxes(field, fieldIds);
|
|
968
833
|
}
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
var clicked = fieldIds.indexOf(fieldId) >= 0;
|
|
834
|
+
let checkImage = field.checkbox;
|
|
835
|
+
let fieldId = checkImage.data("linkedFieldId");
|
|
836
|
+
let clicked = fieldIds.indexOf(fieldId) >= 0;
|
|
973
837
|
checkImage.data("clicked", clicked);
|
|
974
|
-
|
|
975
838
|
if (clicked) {
|
|
976
839
|
gsa.push(fieldId);
|
|
977
840
|
checkImage.html(this._assets.doImg);
|
|
@@ -980,14 +843,10 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
980
843
|
}
|
|
981
844
|
}
|
|
982
845
|
}
|
|
983
|
-
|
|
984
846
|
this.globalSelectedMultiplexSubfield = multiplexCheckedSubField;
|
|
985
847
|
this.globalSelectedAttributes = gsa;
|
|
986
|
-
|
|
987
848
|
this._clearPresetSelection();
|
|
988
|
-
|
|
989
849
|
this._colorMixer();
|
|
990
|
-
|
|
991
850
|
if (!noUndoRedo) {
|
|
992
851
|
this.addToUndoRedo();
|
|
993
852
|
}
|
|
@@ -995,18 +854,14 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
995
854
|
};
|
|
996
855
|
};
|
|
997
856
|
})(jQuery);
|
|
998
|
-
|
|
999
857
|
var plateMapWidget = plateMapWidget || {};
|
|
1000
|
-
|
|
1001
858
|
plateMapWidget.colorManager = function () {
|
|
1002
859
|
return {
|
|
1003
860
|
// See these are color pairs for the gradient.
|
|
1004
861
|
colorPairs: [["#e6e6e6", "#808080"], ["#66e8ff", "#0082c8"], ["#ff7fb1", "#e6194b"], ["#a2ffb1", "#3cb44b"], ["#f784ff", "#911eb4"], ["#ffe897", "#f58231"], ["#6666ff", "#0000FF"], ["#ffff7f", "#ffe119"], ["#acffff", "#46f0f0"], ["#ff98ff", "#f032e6"], ["#ffffa2", "#d2f53c"], ["#ffffff", "#fabebe"], ["#66e6e6", "#008080"], ["#ffffff", "#e6beff"], ["#ffd48e", "#aa6e28"], ["#e66666", "#800000"], ["#ffffff", "#aaffc3"], ["#e6e666", "#808000"], ["#ffffff", "#ffd8b1"], ["#66a9ef", "#004389"], ["#ff6672", "#a7000c"], ["#66db72", "#00750c"], ["#b866db", "#520075"], ["#ffa966", "#b64300"], ["#ffff66", "#c0a200"], ["#6dffff", "#07b1b1"], ["#ff66ff", "#b100a7"], ["#f9ff66", "#93b600"], ["#ffe5e5", "#bb7f7f"], ["#66a7a7", "#004141"], ["#ffe5ff", "#a77fc0"], ["#d19566", "#6b2f00"], ["#ffffef", "#c0bb89"], ["#d1ffea", "#6bc084"], ["#a7a766", "#414100"], ["#ffffd8", "#c09972"], ["#a5ffff", "#3fc1ff"], ["#ffbef0", "#ff588a"], ["#e1fff0", "#7bf38a"], ["#ffc3ff", "#d05df3"], ["#ffffd6", "#ffc170"], ["#a5a5ff", "#3f3fff"], ["#ffffbe", "#ffff58"], ["#ebffff", "#85ffff"], ["#ffd7ff", "#ff71ff"], ["#a5ffff", "#3fbfbf"], ["#ffffcd", "#e9ad67"], ["#ffa5a5", "#bf3f3f"], ["#ffffa5", "#bfbf3f"]]
|
|
1005
862
|
};
|
|
1006
863
|
};
|
|
1007
|
-
|
|
1008
864
|
var plateMapWidget = plateMapWidget || {};
|
|
1009
|
-
|
|
1010
865
|
(function ($) {
|
|
1011
866
|
function select2close(ev) {
|
|
1012
867
|
if (ev.params.args.originalEvent) {
|
|
@@ -1019,68 +874,51 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
1019
874
|
});
|
|
1020
875
|
}
|
|
1021
876
|
}
|
|
1022
|
-
|
|
1023
877
|
function select2fix(input) {
|
|
1024
878
|
// prevents select2 open on clear as of v4.0.8
|
|
1025
879
|
input.on('select2:unselecting', select2close);
|
|
1026
880
|
}
|
|
1027
|
-
|
|
1028
881
|
function select2setData(input, data, selected) {
|
|
1029
882
|
input.empty();
|
|
1030
|
-
|
|
883
|
+
let dataAdapter = input.data('select2').dataAdapter;
|
|
1031
884
|
dataAdapter.addOptions(dataAdapter.convertToOptions(data));
|
|
1032
885
|
input.val(selected);
|
|
1033
886
|
}
|
|
1034
|
-
|
|
1035
887
|
plateMapWidget.createField = function () {
|
|
1036
888
|
// It creates those fields in the tab , there is 4 types of them.
|
|
1037
889
|
return {
|
|
1038
|
-
_createField: function
|
|
890
|
+
_createField: function (field) {
|
|
1039
891
|
switch (field.data.type) {
|
|
1040
892
|
case "text":
|
|
1041
893
|
this._createTextField(field);
|
|
1042
|
-
|
|
1043
894
|
this._handleFieldUnits(field);
|
|
1044
|
-
|
|
1045
895
|
break;
|
|
1046
|
-
|
|
1047
896
|
case "numeric":
|
|
1048
897
|
this._createNumericField(field);
|
|
1049
|
-
|
|
1050
898
|
this._handleFieldUnits(field);
|
|
1051
|
-
|
|
1052
899
|
break;
|
|
1053
|
-
|
|
1054
900
|
case "select":
|
|
1055
901
|
this._createSelectField(field);
|
|
1056
|
-
|
|
1057
902
|
this._handleFieldUnits(field);
|
|
1058
|
-
|
|
1059
903
|
break;
|
|
1060
|
-
|
|
1061
904
|
case "multiselect":
|
|
1062
905
|
this._createMultiSelectField(field);
|
|
1063
|
-
|
|
1064
906
|
break;
|
|
1065
|
-
|
|
1066
907
|
case "boolean":
|
|
1067
908
|
this._createBooleanField(field);
|
|
1068
|
-
|
|
1069
909
|
break;
|
|
1070
|
-
|
|
1071
910
|
case "multiplex":
|
|
1072
911
|
this._createMultiplexField(field);
|
|
1073
|
-
|
|
1074
912
|
break;
|
|
1075
913
|
}
|
|
1076
914
|
},
|
|
1077
|
-
_handleFieldUnits: function
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
var units = data.units || [];
|
|
1081
|
-
var defaultUnit = data.defaultUnit || null;
|
|
1082
|
-
var unitInput = null;
|
|
915
|
+
_handleFieldUnits: function (field) {
|
|
916
|
+
let data = field.data;
|
|
1083
917
|
|
|
918
|
+
// Adding unit
|
|
919
|
+
let units = data.units || [];
|
|
920
|
+
let defaultUnit = data.defaultUnit || null;
|
|
921
|
+
let unitInput = null;
|
|
1084
922
|
if (defaultUnit) {
|
|
1085
923
|
if (units.length) {
|
|
1086
924
|
if (units.indexOf(defaultUnit) < 0) {
|
|
@@ -1094,48 +932,43 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
1094
932
|
defaultUnit = units[0];
|
|
1095
933
|
}
|
|
1096
934
|
}
|
|
1097
|
-
|
|
1098
935
|
if (units.length) {
|
|
1099
936
|
field.units = units;
|
|
1100
937
|
field.hasUnits = true;
|
|
1101
938
|
field.defaultUnit = defaultUnit;
|
|
1102
|
-
|
|
1103
939
|
this._makeFieldUnits(field);
|
|
1104
940
|
}
|
|
1105
941
|
},
|
|
1106
|
-
_makeFieldUnits: function
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
942
|
+
_makeFieldUnits: function (field) {
|
|
943
|
+
let full_id = field.full_id;
|
|
944
|
+
let units = field.units;
|
|
945
|
+
let defaultUnit = field.defaultUnit;
|
|
946
|
+
let unitInput = null;
|
|
1111
947
|
field.disabledRegular = field.disabled;
|
|
1112
948
|
field.parseRegularValue = field.parseValue;
|
|
1113
949
|
field.setRegularValue = field.setValue;
|
|
1114
950
|
field.getRegularValue = field.getValue;
|
|
1115
951
|
field.getRegularText = field.getText;
|
|
1116
|
-
|
|
1117
952
|
if (units.length) {
|
|
1118
953
|
if (units.length === 1) {
|
|
1119
|
-
|
|
954
|
+
let unitText = $("<div></div>").addClass("plate-setup-tab-unit");
|
|
1120
955
|
unitText.text(defaultUnit);
|
|
1121
956
|
field.root.find(".plate-setup-tab-field-container").append(unitText);
|
|
1122
957
|
} else {
|
|
1123
958
|
unitInput = this._createElement("<select/>").attr("id", full_id + "Units").addClass("plate-setup-tab-unit-select-field");
|
|
1124
959
|
field.root.find(".plate-setup-tab-field-container").append(unitInput);
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
960
|
+
let selected = null;
|
|
961
|
+
let unitData = units.map(function (unit) {
|
|
962
|
+
let o = {
|
|
1128
963
|
id: unit,
|
|
1129
964
|
text: unit
|
|
1130
965
|
};
|
|
1131
|
-
|
|
1132
966
|
if (unit === defaultUnit) {
|
|
1133
967
|
selected = unit;
|
|
1134
968
|
}
|
|
1135
|
-
|
|
1136
969
|
return o;
|
|
1137
970
|
});
|
|
1138
|
-
|
|
971
|
+
let opts = {
|
|
1139
972
|
data: unitData,
|
|
1140
973
|
allowClear: false,
|
|
1141
974
|
minimumResultsForSearch: 10
|
|
@@ -1144,91 +977,63 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
1144
977
|
unitInput.val(selected);
|
|
1145
978
|
}
|
|
1146
979
|
}
|
|
1147
|
-
|
|
1148
980
|
field.disabled = function (bool) {
|
|
1149
981
|
bool = field.disabledRegular(bool);
|
|
1150
|
-
|
|
1151
982
|
if (unitInput) {
|
|
1152
983
|
unitInput.prop("disabled", bool);
|
|
1153
984
|
}
|
|
1154
|
-
|
|
1155
985
|
return bool;
|
|
1156
986
|
};
|
|
1157
|
-
|
|
1158
987
|
field.parseValue = function (value) {
|
|
1159
|
-
|
|
1160
|
-
|
|
988
|
+
let v;
|
|
1161
989
|
if ($.isPlainObject(value)) {
|
|
1162
990
|
v = field.parseRegularValue(value.value);
|
|
1163
|
-
|
|
1164
991
|
if (v === null) {
|
|
1165
992
|
return null;
|
|
1166
993
|
}
|
|
1167
|
-
|
|
1168
994
|
return {
|
|
1169
995
|
value: v,
|
|
1170
996
|
unit: field.parseUnit(value.unit)
|
|
1171
997
|
};
|
|
1172
998
|
} else {
|
|
1173
999
|
v = field.parseRegularValue(value);
|
|
1174
|
-
|
|
1175
1000
|
if (v === null) {
|
|
1176
1001
|
return null;
|
|
1177
1002
|
}
|
|
1178
|
-
|
|
1179
1003
|
return {
|
|
1180
1004
|
value: v,
|
|
1181
1005
|
unit: field.defaultUnit
|
|
1182
1006
|
};
|
|
1183
1007
|
}
|
|
1184
1008
|
};
|
|
1185
|
-
|
|
1186
1009
|
field.getValue = function () {
|
|
1187
|
-
|
|
1188
|
-
|
|
1010
|
+
let v = field.getRegularValue();
|
|
1189
1011
|
if (v === null) {
|
|
1190
1012
|
return null;
|
|
1191
1013
|
} else {
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
var _loop = function _loop(unitTypeKey) {
|
|
1203
|
-
if (!unitMap.hasOwnProperty(unitTypeKey)) {
|
|
1204
|
-
return "continue";
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
|
-
var unitTypeUnits = unitMap[unitTypeKey];
|
|
1208
|
-
unitTypeUnits.forEach(function (unit) {
|
|
1209
|
-
if (unit.text === returnVal.unit) {
|
|
1210
|
-
returnVal['unitTypeId'] = unitTypeKey;
|
|
1211
|
-
returnVal['unitId'] = unit.id;
|
|
1212
|
-
}
|
|
1213
|
-
});
|
|
1214
|
-
};
|
|
1215
|
-
|
|
1216
|
-
for (var unitTypeKey in unitMap) {
|
|
1217
|
-
var _ret2 = _loop(unitTypeKey);
|
|
1218
|
-
|
|
1219
|
-
if (_ret2 === "continue") continue;
|
|
1014
|
+
let returnVal = {
|
|
1015
|
+
value: v,
|
|
1016
|
+
unit: field.getUnit()
|
|
1017
|
+
};
|
|
1018
|
+
if (field.data.hasMultiplexUnit) {
|
|
1019
|
+
// include unitTypeId and UnitId to returnVal
|
|
1020
|
+
let unitMap = field.data.unitMap;
|
|
1021
|
+
for (let unitTypeKey in unitMap) {
|
|
1022
|
+
if (!unitMap.hasOwnProperty(unitTypeKey)) {
|
|
1023
|
+
continue;
|
|
1220
1024
|
}
|
|
1025
|
+
let unitTypeUnits = unitMap[unitTypeKey];
|
|
1026
|
+
unitTypeUnits.forEach(function (unit) {
|
|
1027
|
+
if (unit.text === returnVal.unit) {
|
|
1028
|
+
returnVal['unitTypeId'] = unitTypeKey;
|
|
1029
|
+
returnVal['unitId'] = unit.id;
|
|
1030
|
+
}
|
|
1031
|
+
});
|
|
1221
1032
|
}
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
v: returnVal
|
|
1225
|
-
};
|
|
1226
|
-
}();
|
|
1227
|
-
|
|
1228
|
-
if (_typeof(_ret) === "object") return _ret.v;
|
|
1033
|
+
}
|
|
1034
|
+
return returnVal;
|
|
1229
1035
|
}
|
|
1230
1036
|
};
|
|
1231
|
-
|
|
1232
1037
|
field.setValue = function (value) {
|
|
1233
1038
|
if ($.isPlainObject(value)) {
|
|
1234
1039
|
field.setUnit(value.unit || field.defaultUnit);
|
|
@@ -1238,46 +1043,37 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
1238
1043
|
field.setUnit(field.defaultUnit);
|
|
1239
1044
|
}
|
|
1240
1045
|
};
|
|
1241
|
-
|
|
1242
1046
|
field.setUnitOpts = function (opts) {
|
|
1243
1047
|
field.units = opts || null;
|
|
1244
1048
|
field.defaultUnit = null;
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1049
|
+
let newUnits = [];
|
|
1050
|
+
let selected = null;
|
|
1248
1051
|
if (field.units && field.units.length) {
|
|
1249
1052
|
field.defaultUnit = field.units[0];
|
|
1250
1053
|
newUnits = field.units.map(function (curUnit) {
|
|
1251
|
-
|
|
1054
|
+
let cleanUnit = {
|
|
1252
1055
|
id: curUnit,
|
|
1253
1056
|
text: curUnit
|
|
1254
1057
|
};
|
|
1255
|
-
|
|
1256
1058
|
if (curUnit === field.defaultUnit) {
|
|
1257
1059
|
selected = curUnit;
|
|
1258
1060
|
}
|
|
1259
|
-
|
|
1260
1061
|
return cleanUnit;
|
|
1261
1062
|
});
|
|
1262
1063
|
}
|
|
1263
|
-
|
|
1264
1064
|
select2setData(unitInput, newUnits, selected);
|
|
1265
1065
|
};
|
|
1266
|
-
|
|
1267
1066
|
field.parseUnit = function (unit) {
|
|
1268
1067
|
if (unit == null || unit === "") {
|
|
1269
1068
|
return field.defaultUnit;
|
|
1270
1069
|
}
|
|
1271
|
-
|
|
1272
|
-
for (var i = 0; i < units.length; i++) {
|
|
1070
|
+
for (let i = 0; i < units.length; i++) {
|
|
1273
1071
|
if (unit.toLowerCase() === units[i].toLowerCase()) {
|
|
1274
1072
|
return units[i];
|
|
1275
1073
|
}
|
|
1276
1074
|
}
|
|
1277
|
-
|
|
1278
1075
|
throw "Invalid unit " + unit + " for field " + full_id;
|
|
1279
1076
|
};
|
|
1280
|
-
|
|
1281
1077
|
field.getUnit = function () {
|
|
1282
1078
|
if (unitInput) {
|
|
1283
1079
|
return unitInput.val();
|
|
@@ -1285,45 +1081,37 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
1285
1081
|
return field.defaultUnit;
|
|
1286
1082
|
}
|
|
1287
1083
|
};
|
|
1288
|
-
|
|
1289
1084
|
field.setUnit = function (unit) {
|
|
1290
1085
|
if (unitInput) {
|
|
1291
1086
|
unit = unit || field.defaultUnit;
|
|
1292
1087
|
unitInput.val(unit);
|
|
1293
1088
|
unitInput.trigger("change.select2");
|
|
1294
1089
|
}
|
|
1295
|
-
};
|
|
1296
|
-
|
|
1090
|
+
};
|
|
1297
1091
|
|
|
1092
|
+
// val now contains unit
|
|
1298
1093
|
field.getText = function (val) {
|
|
1299
|
-
if (
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1094
|
+
if (typeof val === 'object' && val) {
|
|
1095
|
+
let v = val.value;
|
|
1096
|
+
let u = val.unit;
|
|
1303
1097
|
if (v == null) {
|
|
1304
1098
|
return "";
|
|
1305
1099
|
}
|
|
1306
|
-
|
|
1307
1100
|
v = v.toString();
|
|
1308
|
-
|
|
1309
1101
|
if (!u) {
|
|
1310
1102
|
u = defaultUnit;
|
|
1311
1103
|
}
|
|
1312
|
-
|
|
1313
1104
|
if (u) {
|
|
1314
1105
|
v = v + " " + u;
|
|
1315
1106
|
}
|
|
1316
|
-
|
|
1317
1107
|
return v;
|
|
1318
1108
|
} else {
|
|
1319
1109
|
return field.getRegularText(val);
|
|
1320
1110
|
}
|
|
1321
1111
|
};
|
|
1322
|
-
|
|
1323
1112
|
field.parseText = function (v) {
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
if (value && _typeof(value) === "object") {
|
|
1113
|
+
let value = field.parseValue(v);
|
|
1114
|
+
if (value && typeof value === "object") {
|
|
1327
1115
|
return field.getRegularText(value.value) + value.unit;
|
|
1328
1116
|
} else if (value != null) {
|
|
1329
1117
|
return field.getRegularText(value);
|
|
@@ -1331,267 +1119,212 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
1331
1119
|
return null;
|
|
1332
1120
|
}
|
|
1333
1121
|
};
|
|
1334
|
-
|
|
1335
1122
|
if (unitInput) {
|
|
1336
1123
|
unitInput.on("change", function () {
|
|
1337
1124
|
field.onChange();
|
|
1338
1125
|
});
|
|
1339
1126
|
}
|
|
1340
|
-
|
|
1341
1127
|
field.unitInput = unitInput;
|
|
1342
1128
|
},
|
|
1343
|
-
_createTextField: function
|
|
1344
|
-
|
|
1345
|
-
|
|
1129
|
+
_createTextField: function (field) {
|
|
1130
|
+
let input = this._createElement("<input>").attr("id", field.full_id).addClass("plate-setup-tab-input");
|
|
1346
1131
|
field.root.find(".plate-setup-tab-field-container").append(input);
|
|
1347
|
-
|
|
1348
1132
|
field.parseValue = function (v) {
|
|
1349
1133
|
if (v) {
|
|
1350
1134
|
v = String(v);
|
|
1351
1135
|
} else {
|
|
1352
1136
|
v = null;
|
|
1353
1137
|
}
|
|
1354
|
-
|
|
1355
1138
|
return v;
|
|
1356
1139
|
};
|
|
1357
|
-
|
|
1358
1140
|
field.getValue = function () {
|
|
1359
1141
|
return input.val().trim() || null;
|
|
1360
1142
|
};
|
|
1361
|
-
|
|
1362
1143
|
field.setValue = function (v) {
|
|
1144
|
+
// Leave the box alone while the user is typing in it; otherwise
|
|
1145
|
+
// the refresh after each keystroke replaces their text
|
|
1146
|
+
if (document.activeElement === input[0]) {
|
|
1147
|
+
return;
|
|
1148
|
+
}
|
|
1363
1149
|
input.val(v);
|
|
1364
1150
|
};
|
|
1365
|
-
|
|
1366
1151
|
field.getText = function (v) {
|
|
1367
1152
|
if (v == null) {
|
|
1368
1153
|
return "";
|
|
1369
1154
|
}
|
|
1370
|
-
|
|
1371
1155
|
return v;
|
|
1372
1156
|
};
|
|
1373
|
-
|
|
1374
1157
|
field.disabled = function (bool) {
|
|
1375
1158
|
bool = field.isDisabled || bool;
|
|
1376
1159
|
field.input.prop("disabled", bool);
|
|
1377
1160
|
return bool;
|
|
1378
1161
|
};
|
|
1379
|
-
|
|
1380
1162
|
field.parseText = field.parseValue;
|
|
1381
1163
|
input.on("input", function () {
|
|
1382
1164
|
field.onChange();
|
|
1383
1165
|
});
|
|
1384
1166
|
field.input = input;
|
|
1385
1167
|
},
|
|
1386
|
-
_createOpts: function
|
|
1387
|
-
|
|
1168
|
+
_createOpts: function (config) {
|
|
1169
|
+
let opts = {
|
|
1388
1170
|
allowClear: true,
|
|
1389
1171
|
placeholder: "select"
|
|
1390
1172
|
};
|
|
1391
|
-
|
|
1392
|
-
|
|
1173
|
+
let data_specified = false;
|
|
1393
1174
|
if (config.options) {
|
|
1394
1175
|
opts.data = config.options;
|
|
1395
1176
|
data_specified = true;
|
|
1396
1177
|
}
|
|
1397
|
-
|
|
1398
1178
|
if (config.ajax) {
|
|
1399
1179
|
opts.ajax = ajax;
|
|
1400
1180
|
data_specified = true;
|
|
1401
1181
|
}
|
|
1402
|
-
|
|
1403
1182
|
if (!data_specified) {
|
|
1404
1183
|
throw "Must specify data or ajax";
|
|
1405
1184
|
}
|
|
1406
|
-
|
|
1407
1185
|
return opts;
|
|
1408
1186
|
},
|
|
1409
|
-
_createSelectField: function
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
var input = this._createElement("<select/>").attr("id", full_id).addClass("plate-setup-tab-select-field").addClass("plate-setup-tab-input");
|
|
1414
|
-
|
|
1187
|
+
_createSelectField: function (field) {
|
|
1188
|
+
let full_id = field.full_id;
|
|
1189
|
+
let that = this;
|
|
1190
|
+
let input = this._createElement("<select/>").attr("id", full_id).addClass("plate-setup-tab-select-field").addClass("plate-setup-tab-input");
|
|
1415
1191
|
field.root.find(".plate-setup-tab-field-container").append(input);
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
var optMap = {};
|
|
1192
|
+
let opts = that._createOpts(field.data);
|
|
1193
|
+
let optMap = {};
|
|
1420
1194
|
opts.data.forEach(function (opt) {
|
|
1421
1195
|
optMap[String(opt.id)] = opt;
|
|
1422
1196
|
});
|
|
1423
1197
|
input.select2(opts);
|
|
1424
1198
|
select2fix(input);
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
var v = value;
|
|
1428
|
-
|
|
1199
|
+
let parseValue = function (value) {
|
|
1200
|
+
let v = value;
|
|
1429
1201
|
if (v === "") {
|
|
1430
1202
|
v = null;
|
|
1431
1203
|
}
|
|
1432
|
-
|
|
1433
1204
|
if (v == null) {
|
|
1434
1205
|
return null;
|
|
1435
1206
|
}
|
|
1436
|
-
|
|
1437
1207
|
v = String(v);
|
|
1438
|
-
|
|
1439
1208
|
if (v in optMap) {
|
|
1440
1209
|
return optMap[v].id;
|
|
1441
1210
|
} else {
|
|
1442
1211
|
throw "Invalid value " + value + " for select field " + full_id;
|
|
1443
1212
|
}
|
|
1444
1213
|
};
|
|
1445
|
-
|
|
1446
1214
|
field.parseValue = parseValue;
|
|
1447
|
-
|
|
1448
1215
|
field.disabled = function (bool) {
|
|
1449
1216
|
bool = field.isDisabled || bool;
|
|
1450
1217
|
field.input.prop("disabled", bool);
|
|
1451
1218
|
return bool;
|
|
1452
1219
|
};
|
|
1453
|
-
|
|
1454
1220
|
field.getValue = function () {
|
|
1455
1221
|
return parseValue(input.val());
|
|
1456
1222
|
};
|
|
1457
|
-
|
|
1458
1223
|
field.setValue = function (v) {
|
|
1459
1224
|
input.val(v);
|
|
1460
1225
|
input.trigger("change.select2");
|
|
1461
1226
|
};
|
|
1462
|
-
|
|
1463
1227
|
field.getText = function (v) {
|
|
1464
1228
|
if (v == null) {
|
|
1465
1229
|
return "";
|
|
1466
1230
|
}
|
|
1467
|
-
|
|
1468
1231
|
return optMap[String(v)].text;
|
|
1469
1232
|
};
|
|
1470
|
-
|
|
1471
1233
|
field.parseText = function (value) {
|
|
1472
|
-
|
|
1473
|
-
|
|
1234
|
+
let v = value;
|
|
1474
1235
|
if (v === "") {
|
|
1475
1236
|
v = null;
|
|
1476
1237
|
}
|
|
1477
|
-
|
|
1478
1238
|
if (v == null) {
|
|
1479
1239
|
return null;
|
|
1480
1240
|
}
|
|
1481
|
-
|
|
1482
1241
|
v = String(v);
|
|
1483
|
-
|
|
1484
1242
|
if (v in optMap) {
|
|
1485
1243
|
return optMap[v].text;
|
|
1486
1244
|
} else {
|
|
1487
1245
|
throw "Invalid text value " + value + " for select field " + full_id;
|
|
1488
1246
|
}
|
|
1489
1247
|
};
|
|
1490
|
-
|
|
1491
1248
|
input.on("change", function () {
|
|
1492
1249
|
field.onChange();
|
|
1493
1250
|
});
|
|
1494
1251
|
field.input = input;
|
|
1495
1252
|
},
|
|
1496
|
-
_createMultiSelectField: function
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
var input = this._createElement("<select/>").attr("id", full_id).addClass("plate-setup-tab-multiselect-field");
|
|
1501
|
-
|
|
1253
|
+
_createMultiSelectField: function (field) {
|
|
1254
|
+
let full_id = field.full_id;
|
|
1255
|
+
let that = this;
|
|
1256
|
+
let input = this._createElement("<select/>").attr("id", full_id).addClass("plate-setup-tab-multiselect-field");
|
|
1502
1257
|
input.attr("multiple", "multiple");
|
|
1503
1258
|
field.root.find(".plate-setup-tab-field-container").append(input);
|
|
1504
|
-
|
|
1505
|
-
var opts = that._createOpts(field.data);
|
|
1506
|
-
|
|
1259
|
+
let opts = that._createOpts(field.data);
|
|
1507
1260
|
opts.multiple = true;
|
|
1508
|
-
|
|
1261
|
+
let optMap = {};
|
|
1509
1262
|
opts.data.forEach(function (opt) {
|
|
1510
1263
|
optMap[String(opt.id)] = opt;
|
|
1511
1264
|
});
|
|
1512
1265
|
input.select2(opts);
|
|
1513
1266
|
select2fix(input);
|
|
1514
|
-
|
|
1515
1267
|
field.disabled = function (bool) {
|
|
1516
1268
|
bool = field.isDisabled || bool;
|
|
1517
1269
|
input.prop("disabled", bool);
|
|
1518
1270
|
return bool;
|
|
1519
1271
|
};
|
|
1520
|
-
|
|
1521
1272
|
field._parseOne = function (val) {
|
|
1522
1273
|
val = String(val);
|
|
1523
|
-
|
|
1524
1274
|
if (val in optMap) {
|
|
1525
1275
|
return optMap[val].id;
|
|
1526
1276
|
} else {
|
|
1527
1277
|
throw "Invalid value " + val + " for multiselect field " + full_id;
|
|
1528
1278
|
}
|
|
1529
1279
|
};
|
|
1530
|
-
|
|
1531
1280
|
field._parseMany = function (vals) {
|
|
1532
1281
|
if (vals && vals.length) {
|
|
1533
1282
|
vals = vals.map(field._parseOne, this);
|
|
1534
1283
|
} else {
|
|
1535
1284
|
vals = null;
|
|
1536
1285
|
}
|
|
1537
|
-
|
|
1538
1286
|
return vals;
|
|
1539
1287
|
};
|
|
1540
|
-
|
|
1541
1288
|
field.parseValue = function (value) {
|
|
1542
1289
|
return field._parseMany(value);
|
|
1543
1290
|
};
|
|
1544
|
-
|
|
1545
1291
|
field.getValue = function () {
|
|
1546
1292
|
return field._parseMany(input.val());
|
|
1547
1293
|
};
|
|
1548
|
-
|
|
1549
1294
|
field.setValue = function (v) {
|
|
1550
1295
|
v = v || [];
|
|
1551
1296
|
input.val(v);
|
|
1552
1297
|
input.trigger("change.select2");
|
|
1553
1298
|
};
|
|
1554
|
-
|
|
1555
1299
|
field.getText = function (v) {
|
|
1556
1300
|
if (v == null) {
|
|
1557
1301
|
return "";
|
|
1558
1302
|
}
|
|
1559
|
-
|
|
1560
1303
|
if (v.length > 0) {
|
|
1561
|
-
return v.map(
|
|
1562
|
-
return optMap[String(v)].text;
|
|
1563
|
-
}).join("; ");
|
|
1304
|
+
return v.map(v => optMap[String(v)].text).join("; ");
|
|
1564
1305
|
}
|
|
1565
|
-
|
|
1566
1306
|
return "";
|
|
1567
1307
|
};
|
|
1568
|
-
|
|
1569
1308
|
field.multiOnChange = function (added, removed) {
|
|
1570
1309
|
if (added) {
|
|
1571
1310
|
added = added.id;
|
|
1572
1311
|
}
|
|
1573
|
-
|
|
1574
1312
|
if (removed) {
|
|
1575
1313
|
removed = removed.id;
|
|
1576
1314
|
}
|
|
1577
|
-
|
|
1578
|
-
var data = {};
|
|
1315
|
+
let data = {};
|
|
1579
1316
|
data[field.id] = {
|
|
1580
1317
|
multi: true,
|
|
1581
1318
|
added: added,
|
|
1582
1319
|
removed: removed
|
|
1583
1320
|
};
|
|
1584
|
-
|
|
1585
1321
|
that._addAllData(data);
|
|
1586
1322
|
};
|
|
1587
|
-
|
|
1588
1323
|
field.parseText = function (value) {
|
|
1589
|
-
|
|
1590
|
-
|
|
1324
|
+
let v = value;
|
|
1591
1325
|
if (v && v.length) {
|
|
1592
1326
|
v = v.map(function (opt) {
|
|
1593
1327
|
opt = String(opt);
|
|
1594
|
-
|
|
1595
1328
|
if (opt in optMap) {
|
|
1596
1329
|
return optMap[opt].text;
|
|
1597
1330
|
} else {
|
|
@@ -1601,130 +1334,118 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
1601
1334
|
} else {
|
|
1602
1335
|
v = null;
|
|
1603
1336
|
}
|
|
1604
|
-
|
|
1605
1337
|
return v;
|
|
1606
1338
|
};
|
|
1607
|
-
|
|
1608
1339
|
input.on("select2:select", function (e) {
|
|
1609
|
-
|
|
1610
|
-
|
|
1340
|
+
let v = field._parseOne(e.params.data.id);
|
|
1611
1341
|
v = {
|
|
1612
1342
|
id: v
|
|
1613
1343
|
};
|
|
1614
1344
|
field.multiOnChange(v, null);
|
|
1615
1345
|
});
|
|
1616
1346
|
input.on("select2:unselect", function (e) {
|
|
1617
|
-
|
|
1618
|
-
|
|
1347
|
+
let v = field._parseOne(e.params.data.id);
|
|
1619
1348
|
v = {
|
|
1620
1349
|
id: v
|
|
1621
1350
|
};
|
|
1622
1351
|
field.multiOnChange(null, v);
|
|
1623
1352
|
});
|
|
1624
1353
|
field.input = input;
|
|
1625
|
-
|
|
1626
1354
|
that._createDeleteButton(field);
|
|
1627
1355
|
},
|
|
1628
|
-
_createNumericField: function
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1356
|
+
_createNumericField: function (field) {
|
|
1357
|
+
let full_id = field.full_id;
|
|
1358
|
+
let data = field.data;
|
|
1359
|
+
let input = this._createElement("<input>").addClass("plate-setup-tab-input").attr("placeholder", data.placeholder || "").attr("id", full_id).attr("inputmode", "decimal");
|
|
1360
|
+
// Last text in the box that matched allowedText; restored when an
|
|
1361
|
+
// edit would make it invalid
|
|
1362
|
+
let lastValidText = "";
|
|
1363
|
+
let allowedText = /^-?\d*\.?\d*$/;
|
|
1634
1364
|
field.root.find(".plate-setup-tab-field-container").append(input);
|
|
1635
|
-
|
|
1636
1365
|
field.disabled = function (bool) {
|
|
1637
1366
|
bool = field.isDisabled || bool;
|
|
1638
1367
|
field.input.prop("disabled", bool);
|
|
1639
1368
|
return bool;
|
|
1640
1369
|
};
|
|
1641
|
-
|
|
1642
|
-
var parseValue = function parseValue(value) {
|
|
1370
|
+
let parseValue = function (value) {
|
|
1643
1371
|
if (value == null) {
|
|
1644
1372
|
return null;
|
|
1645
1373
|
}
|
|
1646
|
-
|
|
1647
|
-
var v = String(value).trim();
|
|
1648
|
-
|
|
1374
|
+
let v = String(value).trim();
|
|
1649
1375
|
if (v === "") {
|
|
1650
1376
|
return null;
|
|
1651
1377
|
}
|
|
1652
|
-
|
|
1653
|
-
v = Number(value);
|
|
1654
|
-
|
|
1378
|
+
v = Number(v);
|
|
1655
1379
|
if (isNaN(v)) {
|
|
1656
1380
|
throw "Invalid value " + value + " for numeric field " + full_id;
|
|
1657
1381
|
}
|
|
1658
|
-
|
|
1659
1382
|
return v;
|
|
1660
1383
|
};
|
|
1661
|
-
|
|
1662
1384
|
field.parseValue = parseValue;
|
|
1663
|
-
|
|
1664
1385
|
field.getValue = function () {
|
|
1665
|
-
|
|
1666
|
-
|
|
1386
|
+
let v = input.val().trim();
|
|
1667
1387
|
if (v === "") {
|
|
1668
|
-
|
|
1669
|
-
}
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
v = null;
|
|
1674
|
-
}
|
|
1388
|
+
return null;
|
|
1389
|
+
}
|
|
1390
|
+
v = Number(v);
|
|
1391
|
+
if (isNaN(v)) {
|
|
1392
|
+
return null;
|
|
1675
1393
|
}
|
|
1676
|
-
|
|
1677
1394
|
return v;
|
|
1678
1395
|
};
|
|
1679
|
-
|
|
1680
1396
|
field.setValue = function (value) {
|
|
1397
|
+
// See _createTextField's setValue
|
|
1398
|
+
if (document.activeElement === input[0]) {
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1681
1401
|
input.val(value);
|
|
1402
|
+
lastValidText = input.val();
|
|
1682
1403
|
};
|
|
1683
|
-
|
|
1684
|
-
var getText = function getText(v) {
|
|
1404
|
+
let getText = function (v) {
|
|
1685
1405
|
if (v == null) {
|
|
1686
1406
|
return "";
|
|
1687
1407
|
}
|
|
1688
|
-
|
|
1689
1408
|
v = v.toString();
|
|
1690
1409
|
return v;
|
|
1691
1410
|
};
|
|
1692
|
-
|
|
1693
1411
|
field.getText = getText;
|
|
1694
|
-
|
|
1695
1412
|
field.parseText = function (v) {
|
|
1696
1413
|
return getText(parseValue(v));
|
|
1697
1414
|
};
|
|
1698
1415
|
|
|
1416
|
+
// Only allow an optional leading "-", digits and one "."; any other
|
|
1417
|
+
// keystroke or paste is undone. Surrounding whitespace (common when
|
|
1418
|
+
// pasting from a spreadsheet) is allowed; getValue trims it. A
|
|
1419
|
+
// typographic minus ("−", common when copying from Word or a
|
|
1420
|
+
// PDF) is replaced with "-"
|
|
1699
1421
|
input.on("input", function () {
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
input.addClass("invalid");
|
|
1705
|
-
} else {
|
|
1706
|
-
input.removeClass("invalid");
|
|
1422
|
+
let text = input.val();
|
|
1423
|
+
if (text.indexOf("−") >= 0) {
|
|
1424
|
+
text = text.replace(/−/g, "-");
|
|
1425
|
+
input.val(text);
|
|
1707
1426
|
}
|
|
1708
|
-
|
|
1427
|
+
if (!allowedText.test(text.trim())) {
|
|
1428
|
+
input.val(lastValidText);
|
|
1429
|
+
return;
|
|
1430
|
+
}
|
|
1431
|
+
lastValidText = text;
|
|
1709
1432
|
field.onChange();
|
|
1710
1433
|
});
|
|
1711
1434
|
field.input = input;
|
|
1712
1435
|
},
|
|
1713
|
-
_createBooleanField: function
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
var input = this._createElement("<select/>").attr("id", full_id).addClass("plate-setup-tab-select-field");
|
|
1717
|
-
|
|
1436
|
+
_createBooleanField: function (field) {
|
|
1437
|
+
let full_id = field.full_id;
|
|
1438
|
+
let input = this._createElement("<select/>").attr("id", full_id).addClass("plate-setup-tab-select-field");
|
|
1718
1439
|
field.root.find(".plate-setup-tab-field-container").append(input);
|
|
1719
|
-
|
|
1440
|
+
let tval = {
|
|
1720
1441
|
id: "true",
|
|
1721
1442
|
text: "true"
|
|
1722
1443
|
};
|
|
1723
|
-
|
|
1444
|
+
let fval = {
|
|
1724
1445
|
id: "false",
|
|
1725
1446
|
text: "false"
|
|
1726
1447
|
};
|
|
1727
|
-
|
|
1448
|
+
let opts = {
|
|
1728
1449
|
data: [tval, fval],
|
|
1729
1450
|
placeholder: "select",
|
|
1730
1451
|
allowClear: true,
|
|
@@ -1732,20 +1453,16 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
1732
1453
|
};
|
|
1733
1454
|
input.select2(opts);
|
|
1734
1455
|
select2fix(input);
|
|
1735
|
-
|
|
1736
1456
|
field.disabled = function (bool) {
|
|
1737
1457
|
bool = field.isDisabled || bool;
|
|
1738
1458
|
field.input.prop("disabled", bool);
|
|
1739
1459
|
return bool;
|
|
1740
1460
|
};
|
|
1741
|
-
|
|
1742
1461
|
field.parseValue = function (value) {
|
|
1743
1462
|
if (value == null) {
|
|
1744
1463
|
return null;
|
|
1745
1464
|
}
|
|
1746
|
-
|
|
1747
|
-
var v = String(value).trim().toLowerCase();
|
|
1748
|
-
|
|
1465
|
+
let v = String(value).trim().toLowerCase();
|
|
1749
1466
|
if (v === "true") {
|
|
1750
1467
|
v = true;
|
|
1751
1468
|
} else if (v === "false") {
|
|
@@ -1755,25 +1472,19 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
1755
1472
|
} else {
|
|
1756
1473
|
throw "Invalid value " + value + " for boolean field " + full_id;
|
|
1757
1474
|
}
|
|
1758
|
-
|
|
1759
1475
|
return v;
|
|
1760
1476
|
};
|
|
1761
|
-
|
|
1762
1477
|
field.getValue = function () {
|
|
1763
|
-
|
|
1764
|
-
|
|
1478
|
+
let v = input.val();
|
|
1765
1479
|
switch (v) {
|
|
1766
1480
|
case "true":
|
|
1767
1481
|
return true;
|
|
1768
|
-
|
|
1769
1482
|
case "false":
|
|
1770
1483
|
return false;
|
|
1771
|
-
|
|
1772
1484
|
default:
|
|
1773
1485
|
return null;
|
|
1774
1486
|
}
|
|
1775
1487
|
};
|
|
1776
|
-
|
|
1777
1488
|
field.setValue = function (v) {
|
|
1778
1489
|
if (v === 1 || v === true || v === "true") {
|
|
1779
1490
|
v = "true";
|
|
@@ -1782,39 +1493,33 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
1782
1493
|
} else {
|
|
1783
1494
|
v = null;
|
|
1784
1495
|
}
|
|
1785
|
-
|
|
1786
1496
|
input.val(v);
|
|
1787
1497
|
input.trigger("change.select2");
|
|
1788
1498
|
};
|
|
1789
|
-
|
|
1790
1499
|
field.getText = function (v) {
|
|
1791
1500
|
if (v == null) {
|
|
1792
1501
|
return "";
|
|
1793
1502
|
}
|
|
1794
|
-
|
|
1795
1503
|
return v.toString();
|
|
1796
1504
|
};
|
|
1797
|
-
|
|
1798
1505
|
field.parseText = field.parseValue;
|
|
1799
1506
|
input.on("change", function () {
|
|
1800
1507
|
field.onChange();
|
|
1801
1508
|
});
|
|
1802
1509
|
field.input = input;
|
|
1803
1510
|
},
|
|
1804
|
-
_createMultiplexField: function
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
this._createMultiSelectField(field);
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
var nameContainer1 = this._createElement("<div></div>").addClass("plate-setup-tab-name-singleSelect").text("Select to edit");
|
|
1811
|
-
|
|
1812
|
-
var fieldContainer1 = this._createElement("<div></div>").addClass("plate-setup-tab-field-container-singleSelect");
|
|
1511
|
+
_createMultiplexField: function (field) {
|
|
1512
|
+
let that = this;
|
|
1513
|
+
// make correct multiplex data
|
|
1514
|
+
this._createMultiSelectField(field);
|
|
1813
1515
|
|
|
1516
|
+
// single select
|
|
1517
|
+
let nameContainer1 = this._createElement("<div></div>").addClass("plate-setup-tab-name-singleSelect").text("Select to edit");
|
|
1518
|
+
let fieldContainer1 = this._createElement("<div></div>").addClass("plate-setup-tab-field-container-singleSelect");
|
|
1814
1519
|
field.root.find(".plate-setup-tab-field-right-side").append(nameContainer1, fieldContainer1);
|
|
1815
1520
|
field.singleSelect = this._createElement("<select/>").attr("id", field.full_id + "SingleSelect").addClass("plate-setup-tab-multiplex-single-select-field");
|
|
1816
1521
|
field.singleSelect.appendTo(fieldContainer1);
|
|
1817
|
-
|
|
1522
|
+
let opts = {
|
|
1818
1523
|
allowClear: false,
|
|
1819
1524
|
placeholder: "select",
|
|
1820
1525
|
minimumResultsForSearch: 10,
|
|
@@ -1822,44 +1527,35 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
1822
1527
|
};
|
|
1823
1528
|
field.singleSelect.select2(opts);
|
|
1824
1529
|
select2fix(field.singleSelect);
|
|
1825
|
-
|
|
1826
|
-
|
|
1530
|
+
let multiselectSetValue = field.setValue;
|
|
1827
1531
|
field.singleSelectValue = function () {
|
|
1828
|
-
|
|
1829
|
-
|
|
1532
|
+
let v = field.singleSelect.val();
|
|
1830
1533
|
if (v === "") {
|
|
1831
1534
|
return null;
|
|
1832
1535
|
}
|
|
1833
|
-
|
|
1834
1536
|
if (v == null) {
|
|
1835
1537
|
return null;
|
|
1836
1538
|
}
|
|
1837
|
-
|
|
1838
1539
|
if (v == '[ALL]') {
|
|
1839
1540
|
return v;
|
|
1840
1541
|
}
|
|
1841
|
-
|
|
1842
1542
|
return field._parseOne(v);
|
|
1843
1543
|
};
|
|
1844
|
-
|
|
1845
|
-
var setSingleSelectOptions = function setSingleSelectOptions(data, selected) {
|
|
1544
|
+
let setSingleSelectOptions = function (data, selected) {
|
|
1846
1545
|
data = data || [];
|
|
1847
|
-
|
|
1848
1546
|
if (field.allSelectedMultipleVal) {
|
|
1849
|
-
|
|
1547
|
+
const count = Object.values(field.allSelectedMultipleVal).reduce(function (a, b) {
|
|
1850
1548
|
return a + b;
|
|
1851
1549
|
}, 0);
|
|
1852
|
-
|
|
1853
1550
|
if (count) {
|
|
1854
|
-
|
|
1551
|
+
const all_option = {
|
|
1855
1552
|
id: '[ALL]',
|
|
1856
|
-
text:
|
|
1553
|
+
text: `[${count} well ${field.data.name}]`,
|
|
1857
1554
|
forAll: true
|
|
1858
1555
|
};
|
|
1859
1556
|
data = [all_option].concat(data);
|
|
1860
1557
|
}
|
|
1861
1558
|
}
|
|
1862
|
-
|
|
1863
1559
|
if (!selected) {
|
|
1864
1560
|
if (data.length) {
|
|
1865
1561
|
selected = data[0].id;
|
|
@@ -1867,28 +1563,24 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
1867
1563
|
selected = null;
|
|
1868
1564
|
}
|
|
1869
1565
|
}
|
|
1870
|
-
|
|
1871
1566
|
select2setData(field.singleSelect, data, selected);
|
|
1872
1567
|
field.singleSelect.prop("disabled", data.length === 0);
|
|
1873
1568
|
field.singleSelect.trigger("change.select2");
|
|
1874
1569
|
};
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
var v = field.singleSelectValue();
|
|
1570
|
+
let singleSelectChange = function () {
|
|
1571
|
+
let v = field.singleSelectValue();
|
|
1878
1572
|
field.updateSubFieldUnitOpts(v);
|
|
1879
|
-
|
|
1880
|
-
|
|
1573
|
+
let curSubField = null;
|
|
1881
1574
|
if (v === '[ALL]') {
|
|
1882
1575
|
curSubField = field.allSelectedMultipleData;
|
|
1883
1576
|
} else {
|
|
1884
|
-
|
|
1577
|
+
let curData = field.detailData || [];
|
|
1885
1578
|
curData.forEach(function (val) {
|
|
1886
1579
|
if (val[field.id] === v) {
|
|
1887
1580
|
curSubField = val;
|
|
1888
1581
|
}
|
|
1889
1582
|
});
|
|
1890
1583
|
}
|
|
1891
|
-
|
|
1892
1584
|
if (curSubField) {
|
|
1893
1585
|
// setvalue for subfield
|
|
1894
1586
|
field.subFieldList.forEach(function (subField) {
|
|
@@ -1901,23 +1593,17 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
1901
1593
|
subField.setValue(null);
|
|
1902
1594
|
});
|
|
1903
1595
|
}
|
|
1904
|
-
|
|
1905
1596
|
that.readOnlyHandler();
|
|
1906
1597
|
};
|
|
1907
|
-
|
|
1908
1598
|
setSingleSelectOptions([]);
|
|
1909
1599
|
field.singleSelect.on("change.select2", singleSelectChange);
|
|
1910
|
-
|
|
1911
1600
|
field._changeMultiFieldValue = function (added, removed) {
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
var subFieldId = field.subFieldList[i].id;
|
|
1601
|
+
let newSubFieldValue = {};
|
|
1602
|
+
for (let i = 0; i < field.subFieldList.length; i++) {
|
|
1603
|
+
let subFieldId = field.subFieldList[i].id;
|
|
1916
1604
|
newSubFieldValue[subFieldId] = null;
|
|
1917
1605
|
}
|
|
1918
|
-
|
|
1919
|
-
var val;
|
|
1920
|
-
|
|
1606
|
+
let val;
|
|
1921
1607
|
if (added) {
|
|
1922
1608
|
if (added.value) {
|
|
1923
1609
|
val = added.value;
|
|
@@ -1925,13 +1611,11 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
1925
1611
|
newSubFieldValue[field.id] = added.id;
|
|
1926
1612
|
val = newSubFieldValue;
|
|
1927
1613
|
}
|
|
1928
|
-
|
|
1929
1614
|
added = {
|
|
1930
1615
|
id: added.id,
|
|
1931
1616
|
value: val
|
|
1932
1617
|
};
|
|
1933
1618
|
}
|
|
1934
|
-
|
|
1935
1619
|
if (removed) {
|
|
1936
1620
|
if (removed.value) {
|
|
1937
1621
|
val = removed.value;
|
|
@@ -1939,65 +1623,51 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
1939
1623
|
newSubFieldValue[field.id] = removed.id;
|
|
1940
1624
|
val = newSubFieldValue;
|
|
1941
1625
|
}
|
|
1942
|
-
|
|
1943
1626
|
removed = {
|
|
1944
1627
|
id: removed.id,
|
|
1945
1628
|
value: val
|
|
1946
1629
|
};
|
|
1947
1630
|
}
|
|
1948
|
-
|
|
1949
|
-
var data = {};
|
|
1631
|
+
let data = {};
|
|
1950
1632
|
data[field.id] = {
|
|
1951
1633
|
multi: true,
|
|
1952
1634
|
added: added,
|
|
1953
1635
|
removed: removed
|
|
1954
1636
|
};
|
|
1955
|
-
|
|
1956
1637
|
that._addAllData(data);
|
|
1957
1638
|
};
|
|
1958
|
-
|
|
1959
1639
|
field.setValue = function (v) {
|
|
1960
1640
|
// used to keep track of initially loaded multiplex data
|
|
1961
1641
|
field.detailData = v;
|
|
1962
|
-
|
|
1963
|
-
|
|
1642
|
+
let multiselectValues = null;
|
|
1964
1643
|
if (v && v.length) {
|
|
1965
|
-
multiselectValues = v.map(
|
|
1966
|
-
return val[field.id];
|
|
1967
|
-
});
|
|
1644
|
+
multiselectValues = v.map(val => val[field.id]);
|
|
1968
1645
|
}
|
|
1969
|
-
|
|
1970
1646
|
multiselectSetValue(multiselectValues);
|
|
1971
|
-
|
|
1647
|
+
let newOptions = field.input.select2('data') || [];
|
|
1972
1648
|
setSingleSelectOptions(newOptions, field.singleSelectValue());
|
|
1973
1649
|
singleSelectChange();
|
|
1974
1650
|
};
|
|
1975
|
-
|
|
1976
1651
|
field.disabled = function (bool) {
|
|
1977
1652
|
bool = field.isDisabled || bool;
|
|
1978
1653
|
field.input.prop("disabled", bool);
|
|
1979
1654
|
field.subFieldList.forEach(function (subField) {
|
|
1980
1655
|
subField.disabled(bool);
|
|
1981
1656
|
});
|
|
1982
|
-
|
|
1983
1657
|
if (bool) {
|
|
1984
1658
|
nameContainer1.text("Select to inspect");
|
|
1985
1659
|
} else {
|
|
1986
1660
|
nameContainer1.text("Select to edit");
|
|
1987
1661
|
}
|
|
1988
|
-
|
|
1989
1662
|
return bool;
|
|
1990
1663
|
};
|
|
1991
|
-
|
|
1992
1664
|
field.parseValue = function (value) {
|
|
1993
|
-
|
|
1994
|
-
|
|
1665
|
+
let v = value;
|
|
1995
1666
|
if (v && v.length) {
|
|
1996
1667
|
v = v.map(function (opt) {
|
|
1997
|
-
|
|
1668
|
+
let valMap = {};
|
|
1998
1669
|
valMap[field.id] = opt[field.id];
|
|
1999
|
-
|
|
2000
|
-
var _loop2 = function _loop2(subFieldId) {
|
|
1670
|
+
for (let subFieldId in opt) {
|
|
2001
1671
|
if (opt.hasOwnProperty(subFieldId)) {
|
|
2002
1672
|
field.subFieldList.forEach(function (subField) {
|
|
2003
1673
|
if (subField.id === subFieldId) {
|
|
@@ -2005,23 +1675,16 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2005
1675
|
}
|
|
2006
1676
|
});
|
|
2007
1677
|
}
|
|
2008
|
-
};
|
|
2009
|
-
|
|
2010
|
-
for (var subFieldId in opt) {
|
|
2011
|
-
_loop2(subFieldId);
|
|
2012
1678
|
}
|
|
2013
|
-
|
|
2014
1679
|
return valMap;
|
|
2015
1680
|
});
|
|
2016
1681
|
} else {
|
|
2017
1682
|
v = null;
|
|
2018
1683
|
}
|
|
2019
|
-
|
|
2020
1684
|
return v;
|
|
2021
1685
|
};
|
|
2022
|
-
|
|
2023
1686
|
field.updateSubFieldUnitOpts = function (val) {
|
|
2024
|
-
|
|
1687
|
+
let curOpts;
|
|
2025
1688
|
field.data.options.forEach(function (opt) {
|
|
2026
1689
|
if (opt.id === val) {
|
|
2027
1690
|
curOpts = opt;
|
|
@@ -2037,24 +1700,18 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2037
1700
|
}
|
|
2038
1701
|
});
|
|
2039
1702
|
};
|
|
2040
|
-
|
|
2041
1703
|
field.multiOnChange = function (added, removed) {
|
|
2042
1704
|
field._changeMultiFieldValue(added, removed);
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
1705
|
+
let v = field.getValue();
|
|
1706
|
+
let curData = field.detailData;
|
|
1707
|
+
let curIds = [];
|
|
1708
|
+
let curOpt = null;
|
|
1709
|
+
//reshape data for saveback
|
|
2049
1710
|
if (curData) {
|
|
2050
|
-
curIds = curData.map(
|
|
2051
|
-
return val[field.id];
|
|
2052
|
-
});
|
|
1711
|
+
curIds = curData.map(val => val[field.id]);
|
|
2053
1712
|
}
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
var selectList = [];
|
|
2057
|
-
|
|
1713
|
+
let newMultiplexVal = [];
|
|
1714
|
+
let selectList = [];
|
|
2058
1715
|
if (v) {
|
|
2059
1716
|
v.forEach(function (selectedVal) {
|
|
2060
1717
|
if (curData) {
|
|
@@ -2063,11 +1720,10 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2063
1720
|
newMultiplexVal.push(val);
|
|
2064
1721
|
}
|
|
2065
1722
|
});
|
|
2066
|
-
}
|
|
2067
|
-
|
|
2068
|
-
|
|
1723
|
+
}
|
|
1724
|
+
// cases when adding new data
|
|
2069
1725
|
if (curIds.indexOf(selectedVal) < 0) {
|
|
2070
|
-
|
|
1726
|
+
let newVal = {};
|
|
2071
1727
|
newVal[field.id] = selectedVal;
|
|
2072
1728
|
field.updateSubFieldUnitOpts(selectedVal);
|
|
2073
1729
|
field.subFieldList.forEach(function (subfield) {
|
|
@@ -2077,7 +1733,7 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2077
1733
|
subfield.disabled(false);
|
|
2078
1734
|
field.data.options.forEach(function (opt) {
|
|
2079
1735
|
if (opt.id === selectedVal) {
|
|
2080
|
-
|
|
1736
|
+
let val = {
|
|
2081
1737
|
value: null,
|
|
2082
1738
|
unit: subfield.units[0]
|
|
2083
1739
|
};
|
|
@@ -2090,8 +1746,7 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2090
1746
|
subfield.disabled(false);
|
|
2091
1747
|
}
|
|
2092
1748
|
}
|
|
2093
|
-
|
|
2094
|
-
var val = {
|
|
1749
|
+
let val = {
|
|
2095
1750
|
value: null,
|
|
2096
1751
|
unit: subfield.defaultUnit
|
|
2097
1752
|
};
|
|
@@ -2103,8 +1758,9 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2103
1758
|
});
|
|
2104
1759
|
newMultiplexVal.push(newVal);
|
|
2105
1760
|
}
|
|
2106
|
-
});
|
|
1761
|
+
});
|
|
2107
1762
|
|
|
1763
|
+
// make data for single select options
|
|
2108
1764
|
v.forEach(function (selectVal) {
|
|
2109
1765
|
field.data.options.forEach(function (opt) {
|
|
2110
1766
|
if (opt.id === selectVal) {
|
|
@@ -2112,9 +1768,8 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2112
1768
|
}
|
|
2113
1769
|
});
|
|
2114
1770
|
});
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
for (var i = 0; i < v.length; i++) {
|
|
1771
|
+
let selected = field.singleSelectValue();
|
|
1772
|
+
for (let i = 0; i < v.length; i++) {
|
|
2118
1773
|
if (added && added.id === v[i]) {
|
|
2119
1774
|
curOpt = v[i];
|
|
2120
1775
|
break;
|
|
@@ -2125,131 +1780,90 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2125
1780
|
}
|
|
2126
1781
|
}
|
|
2127
1782
|
}
|
|
2128
|
-
|
|
2129
1783
|
field.detailData = newMultiplexVal;
|
|
2130
1784
|
setSingleSelectOptions(selectList, curOpt);
|
|
2131
1785
|
singleSelectChange();
|
|
2132
1786
|
};
|
|
2133
|
-
|
|
2134
1787
|
field.getText = function (v) {
|
|
2135
1788
|
if (v === null) {
|
|
2136
1789
|
return "";
|
|
2137
|
-
}
|
|
2138
|
-
|
|
2139
|
-
|
|
1790
|
+
}
|
|
1791
|
+
// get subfields that is selected from the checkbox
|
|
2140
1792
|
if (field.id in that.globalSelectedMultiplexSubfield) {
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
if (field.data.options.hasOwnProperty(optId)) {
|
|
2155
|
-
var opt = field.data.options[optId];
|
|
2156
|
-
|
|
2157
|
-
if (opt.id === subV[field.id]) {
|
|
2158
|
-
subText.push(opt.text);
|
|
2159
|
-
}
|
|
1793
|
+
let checkedSubfields = that.globalSelectedMultiplexSubfield[field.id];
|
|
1794
|
+
let returnVal = [];
|
|
1795
|
+
for (let valIdx in v) {
|
|
1796
|
+
if (!v.hasOwnProperty(valIdx)) {
|
|
1797
|
+
continue;
|
|
1798
|
+
}
|
|
1799
|
+
let subV = v[valIdx];
|
|
1800
|
+
let subText = [];
|
|
1801
|
+
for (let optId in field.data.options) {
|
|
1802
|
+
if (field.data.options.hasOwnProperty(optId)) {
|
|
1803
|
+
let opt = field.data.options[optId];
|
|
1804
|
+
if (opt.id === subV[field.id]) {
|
|
1805
|
+
subText.push(opt.text);
|
|
2160
1806
|
}
|
|
2161
1807
|
}
|
|
2162
|
-
|
|
2163
|
-
field.subFieldList.forEach(function (subField) {
|
|
2164
|
-
if (checkedSubfields.indexOf(subField.id) >= 0) {
|
|
2165
|
-
var x = subField.getText(subV[subField.id]);
|
|
2166
|
-
subText.push(subField.name + ": " + x);
|
|
2167
|
-
}
|
|
2168
|
-
});
|
|
2169
|
-
returnVal.push("{" + subText.join(", ") + "}");
|
|
2170
|
-
};
|
|
2171
|
-
|
|
2172
|
-
for (var valIdx in v) {
|
|
2173
|
-
var _ret4 = _loop3(valIdx);
|
|
2174
|
-
|
|
2175
|
-
if (_ret4 === "continue") continue;
|
|
2176
1808
|
}
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
1809
|
+
field.subFieldList.forEach(function (subField) {
|
|
1810
|
+
if (checkedSubfields.indexOf(subField.id) >= 0) {
|
|
1811
|
+
let x = subField.getText(subV[subField.id]);
|
|
1812
|
+
subText.push(subField.name + ": " + x);
|
|
1813
|
+
}
|
|
1814
|
+
});
|
|
1815
|
+
returnVal.push("{" + subText.join(", ") + "}");
|
|
1816
|
+
}
|
|
1817
|
+
return returnVal.join(";");
|
|
2184
1818
|
}
|
|
2185
1819
|
};
|
|
2186
|
-
|
|
2187
1820
|
field.parseText = function (v) {
|
|
2188
1821
|
if (v === null) {
|
|
2189
1822
|
return "";
|
|
2190
1823
|
} else {
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
var _loop4 = function _loop4(valIdx) {
|
|
1824
|
+
let returnVal = [];
|
|
1825
|
+
for (let valIdx in v) {
|
|
2194
1826
|
if (!v.hasOwnProperty(valIdx)) {
|
|
2195
|
-
|
|
1827
|
+
continue;
|
|
2196
1828
|
}
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
for (var optId in field.data.options) {
|
|
1829
|
+
let subV = v[valIdx];
|
|
1830
|
+
let subText = [];
|
|
1831
|
+
for (let optId in field.data.options) {
|
|
2202
1832
|
if (field.data.options.hasOwnProperty(optId)) {
|
|
2203
|
-
|
|
2204
|
-
|
|
1833
|
+
let opt = field.data.options[optId];
|
|
2205
1834
|
if (opt.id === subV[field.id]) {
|
|
2206
1835
|
subText.push(opt.text);
|
|
2207
1836
|
}
|
|
2208
1837
|
}
|
|
2209
1838
|
}
|
|
2210
|
-
|
|
2211
1839
|
field.subFieldList.forEach(function (subField) {
|
|
2212
|
-
|
|
2213
|
-
|
|
1840
|
+
let x = subField.getText(subV[subField.id]);
|
|
2214
1841
|
if (x) {
|
|
2215
1842
|
subText.push(x);
|
|
2216
1843
|
}
|
|
2217
1844
|
});
|
|
2218
1845
|
returnVal.push(subText);
|
|
2219
|
-
};
|
|
2220
|
-
|
|
2221
|
-
for (var valIdx in v) {
|
|
2222
|
-
var _ret5 = _loop4(valIdx);
|
|
2223
|
-
|
|
2224
|
-
if (_ret5 === "continue") continue;
|
|
2225
1846
|
}
|
|
2226
|
-
|
|
2227
1847
|
return returnVal;
|
|
2228
1848
|
}
|
|
2229
1849
|
};
|
|
2230
|
-
|
|
2231
1850
|
field.checkMultiplexCompletion = function (valList) {
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
1851
|
+
let valCount = 0;
|
|
1852
|
+
let completionPct = 0;
|
|
1853
|
+
let include = false;
|
|
2236
1854
|
function getSubfieldStatus(vals) {
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
for (var subFieldId in field.subFieldList) {
|
|
1855
|
+
let req = 0;
|
|
1856
|
+
let fill = 0;
|
|
1857
|
+
for (let subFieldId in field.subFieldList) {
|
|
2241
1858
|
if (!field.subFieldList.hasOwnProperty(subFieldId)) {
|
|
2242
1859
|
continue;
|
|
2243
1860
|
}
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
var curVal = vals[subField.id];
|
|
2247
|
-
|
|
1861
|
+
let subField = field.subFieldList[subFieldId];
|
|
1862
|
+
let curVal = vals[subField.id];
|
|
2248
1863
|
if (subField.required) {
|
|
2249
1864
|
include = true;
|
|
2250
1865
|
req++;
|
|
2251
|
-
|
|
2252
|
-
if (_typeof(curVal) === 'object' && curVal) {
|
|
1866
|
+
if (typeof curVal === 'object' && curVal) {
|
|
2253
1867
|
if (curVal.value) {
|
|
2254
1868
|
fill++;
|
|
2255
1869
|
}
|
|
@@ -2258,17 +1872,16 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2258
1872
|
}
|
|
2259
1873
|
}
|
|
2260
1874
|
}
|
|
2261
|
-
|
|
2262
1875
|
return fill / req;
|
|
2263
|
-
}
|
|
2264
|
-
|
|
1876
|
+
}
|
|
2265
1877
|
|
|
1878
|
+
// for cases has value in multiplex field
|
|
2266
1879
|
if (valList) {
|
|
2267
1880
|
if (valList.length > 0) {
|
|
2268
|
-
for (
|
|
1881
|
+
for (let idx in valList) {
|
|
2269
1882
|
if (valList.hasOwnProperty(idx)) {
|
|
2270
1883
|
valCount++;
|
|
2271
|
-
|
|
1884
|
+
let vals = valList[idx];
|
|
2272
1885
|
completionPct += getSubfieldStatus(vals);
|
|
2273
1886
|
}
|
|
2274
1887
|
}
|
|
@@ -2280,42 +1893,38 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2280
1893
|
include = true;
|
|
2281
1894
|
valCount = 1;
|
|
2282
1895
|
}
|
|
2283
|
-
|
|
2284
1896
|
return {
|
|
2285
1897
|
include: include,
|
|
2286
1898
|
completionPct: completionPct / valCount
|
|
2287
1899
|
};
|
|
2288
|
-
};
|
|
2289
|
-
|
|
1900
|
+
};
|
|
2290
1901
|
|
|
1902
|
+
// valList contains all of the vals for selected val
|
|
2291
1903
|
field.applyMultiplexSubFieldColor = function (valList) {
|
|
2292
1904
|
function updateSubFieldWarningMap(vals) {
|
|
2293
|
-
for (
|
|
1905
|
+
for (let subFieldId in field.subFieldList) {
|
|
2294
1906
|
if (!field.subFieldList.hasOwnProperty(subFieldId)) {
|
|
2295
1907
|
continue;
|
|
2296
1908
|
}
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
1909
|
+
let subField = field.subFieldList[subFieldId];
|
|
1910
|
+
// loop through each well's multiplexval list
|
|
2300
1911
|
if (vals === null) {
|
|
2301
1912
|
if (field.required && subField.required) {
|
|
2302
1913
|
subFieldWarningMap[subField.id].warningStatus.push(true);
|
|
2303
1914
|
}
|
|
2304
|
-
} else if (
|
|
1915
|
+
} else if (typeof vals === "object") {
|
|
2305
1916
|
if (vals.length === 0) {
|
|
2306
1917
|
if (field.required && subField.required) {
|
|
2307
1918
|
subFieldWarningMap[subField.id].warningStatus.push(true);
|
|
2308
1919
|
}
|
|
2309
1920
|
} else {
|
|
2310
|
-
for (
|
|
1921
|
+
for (let multiplexIdx in vals) {
|
|
2311
1922
|
if (!vals.hasOwnProperty(multiplexIdx)) {
|
|
2312
1923
|
continue;
|
|
2313
1924
|
}
|
|
2314
|
-
|
|
2315
|
-
var curVal = vals[multiplexIdx][subField.id];
|
|
2316
|
-
|
|
1925
|
+
let curVal = vals[multiplexIdx][subField.id];
|
|
2317
1926
|
if (subField.required) {
|
|
2318
|
-
if (
|
|
1927
|
+
if (typeof curVal === 'object' && curVal) {
|
|
2319
1928
|
if (!curVal.value) {
|
|
2320
1929
|
subFieldWarningMap[subField.id].warningStatus.push(true);
|
|
2321
1930
|
} else {
|
|
@@ -2332,8 +1941,7 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2332
1941
|
}
|
|
2333
1942
|
}
|
|
2334
1943
|
}
|
|
2335
|
-
|
|
2336
|
-
var subFieldWarningMap = {};
|
|
1944
|
+
let subFieldWarningMap = {};
|
|
2337
1945
|
field.subFieldList.forEach(function (subField) {
|
|
2338
1946
|
if (subField.required) {
|
|
2339
1947
|
subFieldWarningMap[subField.id] = {
|
|
@@ -2344,20 +1952,17 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2344
1952
|
});
|
|
2345
1953
|
valList.forEach(function (multiplexVals) {
|
|
2346
1954
|
updateSubFieldWarningMap(multiplexVals);
|
|
2347
|
-
});
|
|
2348
|
-
|
|
2349
|
-
var mainFieldStatus = [];
|
|
1955
|
+
});
|
|
1956
|
+
// turn off main field when all subfield are filled
|
|
2350
1957
|
|
|
2351
|
-
|
|
1958
|
+
let mainFieldStatus = [];
|
|
1959
|
+
for (let subFieldId in subFieldWarningMap) {
|
|
2352
1960
|
if (!subFieldWarningMap.hasOwnProperty(subFieldId)) {
|
|
2353
1961
|
continue;
|
|
2354
1962
|
}
|
|
2355
|
-
|
|
2356
|
-
var subField = subFieldWarningMap[subFieldId].field;
|
|
2357
|
-
|
|
1963
|
+
let subField = subFieldWarningMap[subFieldId].field;
|
|
2358
1964
|
if (subFieldWarningMap[subFieldId].warningStatus.indexOf(true) >= 0) {
|
|
2359
|
-
|
|
2360
|
-
|
|
1965
|
+
let text = subField.name + " is a required subfield for " + field.name + ", please make sure all " + field.name + " have " + subField.name;
|
|
2361
1966
|
if (field.required) {
|
|
2362
1967
|
that.fieldWarningMsg(subField, text, true);
|
|
2363
1968
|
mainFieldStatus.push(true);
|
|
@@ -2370,77 +1975,63 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2370
1975
|
mainFieldStatus.push(false);
|
|
2371
1976
|
}
|
|
2372
1977
|
}
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
var warningText;
|
|
2376
|
-
|
|
1978
|
+
let mainFieldWarning = mainFieldStatus.indexOf(true) >= 0;
|
|
1979
|
+
let warningText;
|
|
2377
1980
|
if (field.required) {
|
|
2378
1981
|
warningText = field.name + " is a required field, please also fix missing required subfield(s) below";
|
|
2379
1982
|
} else {
|
|
2380
1983
|
warningText = field.name + " is not a required field, please fix missing required subfield(s) below or remove selected " + field.name;
|
|
2381
1984
|
}
|
|
2382
|
-
|
|
2383
1985
|
that.fieldWarningMsg(field, warningText, mainFieldWarning);
|
|
2384
1986
|
};
|
|
2385
|
-
|
|
2386
1987
|
field.parseMainFieldVal = function (val) {
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
var curOpt = optMap[idx];
|
|
2391
|
-
|
|
1988
|
+
let optMap = field.data.options;
|
|
1989
|
+
for (let idx = 0; idx < optMap.length; idx++) {
|
|
1990
|
+
let curOpt = optMap[idx];
|
|
2392
1991
|
if (curOpt.id === val) {
|
|
2393
1992
|
return curOpt.text;
|
|
2394
1993
|
}
|
|
2395
1994
|
}
|
|
2396
1995
|
};
|
|
2397
1996
|
},
|
|
2398
|
-
_deleteDialog: function
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
1997
|
+
_deleteDialog: function (field) {
|
|
1998
|
+
let that = this;
|
|
1999
|
+
let valMap = field.allSelectedMultipleVal;
|
|
2000
|
+
let valToRemove;
|
|
2403
2001
|
if (valMap) {
|
|
2404
2002
|
valToRemove = Object.keys(valMap);
|
|
2405
2003
|
} else {
|
|
2406
2004
|
valToRemove = [];
|
|
2407
2005
|
}
|
|
2408
|
-
|
|
2409
|
-
var dialogDiv = $("<div/>").addClass("plate-modal");
|
|
2006
|
+
let dialogDiv = $("<div/>").addClass("plate-modal");
|
|
2410
2007
|
this.container.append(dialogDiv);
|
|
2411
|
-
|
|
2412
2008
|
function killDialog() {
|
|
2413
2009
|
dialogDiv.hide();
|
|
2414
2010
|
dialogDiv.remove();
|
|
2415
2011
|
}
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
var buttonRow = $("<div/>").addClass("dialog-buttons").css("justify-content", "flex-end").appendTo(dialogContent);
|
|
2420
|
-
|
|
2012
|
+
let dialogContent = $("<div/>").addClass("plate-modal-content").css('width', '550px').appendTo(dialogDiv);
|
|
2013
|
+
let tableArea = $("<div/>").appendTo(dialogContent);
|
|
2014
|
+
let buttonRow = $("<div/>").addClass("dialog-buttons").css("justify-content", "flex-end").appendTo(dialogContent);
|
|
2421
2015
|
if (valToRemove.length > 0) {
|
|
2422
2016
|
// apply CSS property for table
|
|
2423
2017
|
$("<p/>").text(field.name + " in selected wells: choose items to delete and click the delete button below").appendTo(tableArea);
|
|
2424
|
-
|
|
2425
|
-
var table = that._deleteDialogTable(field, valMap);
|
|
2426
|
-
|
|
2018
|
+
let table = that._deleteDialogTable(field, valMap);
|
|
2427
2019
|
table.appendTo(tableArea);
|
|
2428
2020
|
table.addClass("plate-popout-table");
|
|
2429
2021
|
table.find('td').addClass("plate-popout-td");
|
|
2430
2022
|
table.find('th').addClass("plate-popout-th");
|
|
2431
2023
|
table.find('tr').addClass("plate-popout-tr");
|
|
2432
|
-
|
|
2433
2024
|
if (!that.readOnly) {
|
|
2434
|
-
|
|
2025
|
+
let deleteCheckedButton = $("<button class='multiple-field-manage-delete-button'>Delete Checked Items</button>");
|
|
2435
2026
|
buttonRow.append(deleteCheckedButton);
|
|
2436
2027
|
deleteCheckedButton.click(function () {
|
|
2437
2028
|
table.find("input:checked").each(function () {
|
|
2438
|
-
|
|
2029
|
+
let val = this.value;
|
|
2439
2030
|
field.multiOnChange(null, {
|
|
2440
2031
|
id: val
|
|
2441
2032
|
});
|
|
2442
|
-
});
|
|
2443
|
-
|
|
2033
|
+
});
|
|
2034
|
+
// refresh selected fields after updating the multiplex field value
|
|
2444
2035
|
that.decideSelectedFields();
|
|
2445
2036
|
killDialog();
|
|
2446
2037
|
});
|
|
@@ -2448,56 +2039,48 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2448
2039
|
} else {
|
|
2449
2040
|
$("<p/>").text("No " + field.name + " in the selected wells").appendTo(tableArea);
|
|
2450
2041
|
}
|
|
2451
|
-
|
|
2452
|
-
var cancelButton = $("<button>Cancel</button>");
|
|
2042
|
+
let cancelButton = $("<button>Cancel</button>");
|
|
2453
2043
|
buttonRow.append(cancelButton);
|
|
2454
2044
|
cancelButton.click(killDialog);
|
|
2455
2045
|
dialogDiv.show();
|
|
2456
|
-
|
|
2457
2046
|
window.onclick = function (event) {
|
|
2458
2047
|
if (event.target === dialogDiv[0]) {
|
|
2459
2048
|
killDialog();
|
|
2460
2049
|
}
|
|
2461
2050
|
};
|
|
2462
2051
|
},
|
|
2463
|
-
_deleteDialogTable: function
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2052
|
+
_deleteDialogTable: function (field, valMap) {
|
|
2053
|
+
let that = this;
|
|
2054
|
+
let colName = [field.name, "Counts"]; //Added because it was missing... no idea what the original should have been
|
|
2467
2055
|
if (!that.readOnly) {
|
|
2468
2056
|
colName.push("Delete");
|
|
2469
2057
|
}
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
var tr = $('<tr/>').appendTo(thead);
|
|
2058
|
+
let table = $('<table/>');
|
|
2059
|
+
let thead = $('<thead/>').appendTo(table);
|
|
2060
|
+
let tr = $('<tr/>').appendTo(thead);
|
|
2474
2061
|
tr.append(colName.map(function (text) {
|
|
2475
2062
|
return $('<th/>').text(text);
|
|
2476
2063
|
}));
|
|
2477
|
-
|
|
2064
|
+
let tbody = $("<tbody/>").appendTo(table);
|
|
2478
2065
|
field.data.options.forEach(function (opt) {
|
|
2479
2066
|
if (opt.id in valMap) {
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
$("<td/>").text(opt.
|
|
2484
|
-
$("<td/>").text(valMap[opt.id]).appendTo(_tr);
|
|
2485
|
-
|
|
2067
|
+
let tr = $('<tr/>').appendTo(tbody);
|
|
2068
|
+
let checkbox = $("<input type='checkbox'>").prop("value", opt.id);
|
|
2069
|
+
$("<td/>").text(opt.text).appendTo(tr);
|
|
2070
|
+
$("<td/>").text(valMap[opt.id]).appendTo(tr);
|
|
2486
2071
|
if (!that.readOnly) {
|
|
2487
|
-
$("<td/>").append(checkbox).appendTo(
|
|
2072
|
+
$("<td/>").append(checkbox).appendTo(tr);
|
|
2488
2073
|
}
|
|
2489
2074
|
}
|
|
2490
2075
|
});
|
|
2491
2076
|
return table;
|
|
2492
2077
|
},
|
|
2493
|
-
_createDeleteButton: function
|
|
2494
|
-
|
|
2495
|
-
|
|
2078
|
+
_createDeleteButton: function (field) {
|
|
2079
|
+
let that = this;
|
|
2080
|
+
let deleteButton = $("<button/>").addClass("plate-setup-remove-all-button");
|
|
2496
2081
|
deleteButton.id = field.id + "Delete";
|
|
2497
2082
|
deleteButton.text("Manage " + field.name + "...");
|
|
2498
|
-
|
|
2499
|
-
var buttonContainer = that._createElement("<div></div>").addClass("plate-setup-remove-all-button-container");
|
|
2500
|
-
|
|
2083
|
+
let buttonContainer = that._createElement("<div></div>").addClass("plate-setup-remove-all-button-container");
|
|
2501
2084
|
buttonContainer.append(deleteButton);
|
|
2502
2085
|
field.deleteButton = deleteButton;
|
|
2503
2086
|
field.root.find(".plate-setup-tab-field-right-side").append(buttonContainer);
|
|
@@ -2508,9 +2091,7 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2508
2091
|
};
|
|
2509
2092
|
};
|
|
2510
2093
|
})(jQuery);
|
|
2511
|
-
|
|
2512
2094
|
var plateMapWidget = plateMapWidget || {};
|
|
2513
|
-
|
|
2514
2095
|
(function ($) {
|
|
2515
2096
|
plateMapWidget.engine = function (THIS) {
|
|
2516
2097
|
// Methods which look after data changes and stack up accordingly
|
|
@@ -2522,14 +2103,12 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2522
2103
|
colorMap: new Map(),
|
|
2523
2104
|
stackUpWithColor: {},
|
|
2524
2105
|
stackPointer: 2,
|
|
2525
|
-
wellEmpty: function
|
|
2526
|
-
for (
|
|
2106
|
+
wellEmpty: function (well) {
|
|
2107
|
+
for (let prop in well) {
|
|
2527
2108
|
if (!well.hasOwnProperty(prop)) {
|
|
2528
2109
|
continue;
|
|
2529
2110
|
}
|
|
2530
|
-
|
|
2531
|
-
var curVal = well[prop];
|
|
2532
|
-
|
|
2111
|
+
let curVal = well[prop];
|
|
2533
2112
|
if (curVal !== null && curVal !== undefined) {
|
|
2534
2113
|
if (Array.isArray(curVal)) {
|
|
2535
2114
|
if (curVal.length > 0) {
|
|
@@ -2540,50 +2119,36 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2540
2119
|
}
|
|
2541
2120
|
}
|
|
2542
2121
|
}
|
|
2543
|
-
|
|
2544
2122
|
return true;
|
|
2545
2123
|
},
|
|
2546
|
-
searchAndStack: function
|
|
2124
|
+
searchAndStack: function () {
|
|
2547
2125
|
// This method search and stack the change we made.
|
|
2548
2126
|
this.stackUpWithColor = {};
|
|
2549
2127
|
this.stackPointer = 1;
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
for (var idx in this.derivative) {
|
|
2128
|
+
let derivativeJson = {};
|
|
2129
|
+
for (let idx in this.derivative) {
|
|
2553
2130
|
if (!this.derivative.hasOwnProperty(idx)) {
|
|
2554
2131
|
continue;
|
|
2555
2132
|
}
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
for (var i = 0; i < THIS.globalSelectedAttributes.length; i++) {
|
|
2561
|
-
var attr = THIS.globalSelectedAttributes[i];
|
|
2562
|
-
|
|
2133
|
+
let data = this.derivative[idx];
|
|
2134
|
+
let wellData = {};
|
|
2135
|
+
for (let i = 0; i < THIS.globalSelectedAttributes.length; i++) {
|
|
2136
|
+
let attr = THIS.globalSelectedAttributes[i];
|
|
2563
2137
|
if (attr in THIS.globalSelectedMultiplexSubfield) {
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
var _loop5 = function _loop5(multiplexIdx) {
|
|
2138
|
+
let selectedSubFields = THIS.globalSelectedMultiplexSubfield[attr];
|
|
2139
|
+
let newMultiplexVal = [];
|
|
2140
|
+
for (let multiplexIdx in data[attr]) {
|
|
2568
2141
|
if (!data[attr].hasOwnProperty(multiplexIdx)) {
|
|
2569
|
-
|
|
2142
|
+
continue;
|
|
2570
2143
|
}
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
var newVal = {};
|
|
2144
|
+
let curMultiplexVals = data[attr][multiplexIdx];
|
|
2145
|
+
let newVal = {};
|
|
2574
2146
|
newVal[attr] = curMultiplexVals[attr];
|
|
2575
2147
|
selectedSubFields.forEach(function (subFieldId) {
|
|
2576
2148
|
newVal[subFieldId] = curMultiplexVals[subFieldId];
|
|
2577
2149
|
});
|
|
2578
2150
|
newMultiplexVal.push(newVal);
|
|
2579
|
-
};
|
|
2580
|
-
|
|
2581
|
-
for (var multiplexIdx in data[attr]) {
|
|
2582
|
-
var _ret6 = _loop5(multiplexIdx);
|
|
2583
|
-
|
|
2584
|
-
if (_ret6 === "continue") continue;
|
|
2585
2151
|
}
|
|
2586
|
-
|
|
2587
2152
|
wellData[attr] = newMultiplexVal;
|
|
2588
2153
|
} else {
|
|
2589
2154
|
if (data[attr] != null) {
|
|
@@ -2591,23 +2156,20 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2591
2156
|
}
|
|
2592
2157
|
}
|
|
2593
2158
|
}
|
|
2594
|
-
|
|
2595
2159
|
if ($.isEmptyObject(wellData)) {
|
|
2596
2160
|
derivativeJson[idx] = null;
|
|
2597
2161
|
} else {
|
|
2598
2162
|
derivativeJson[idx] = JSON.stringify(wellData);
|
|
2599
2163
|
}
|
|
2600
2164
|
}
|
|
2601
|
-
|
|
2602
2165
|
while (!$.isEmptyObject(derivativeJson)) {
|
|
2603
|
-
|
|
2166
|
+
let keys = Object.keys(derivativeJson).map(parseFloat);
|
|
2604
2167
|
keys.sort(function (a, b) {
|
|
2605
2168
|
return a - b;
|
|
2606
2169
|
});
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2170
|
+
let refDerivativeIndex = keys[0];
|
|
2171
|
+
let referenceDerivative = derivativeJson[refDerivativeIndex];
|
|
2172
|
+
let arr = [];
|
|
2611
2173
|
if (!referenceDerivative) {
|
|
2612
2174
|
// if no checked box has value, push it to first spot
|
|
2613
2175
|
if (this.stackUpWithColor[0]) {
|
|
@@ -2615,76 +2177,63 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2615
2177
|
} else {
|
|
2616
2178
|
this.stackUpWithColor[0] = [refDerivativeIndex];
|
|
2617
2179
|
}
|
|
2618
|
-
|
|
2619
2180
|
delete derivativeJson[refDerivativeIndex];
|
|
2620
2181
|
} else {
|
|
2621
2182
|
// if checked boxes have values
|
|
2622
|
-
for (
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
arr.push(_idx);
|
|
2183
|
+
for (let i = 0; i < keys.length; i++) {
|
|
2184
|
+
let idx = keys[i];
|
|
2185
|
+
if (referenceDerivative === derivativeJson[idx]) {
|
|
2186
|
+
arr.push(idx);
|
|
2627
2187
|
this.stackUpWithColor[this.stackPointer] = arr;
|
|
2628
|
-
delete derivativeJson[
|
|
2188
|
+
delete derivativeJson[idx];
|
|
2629
2189
|
}
|
|
2630
2190
|
}
|
|
2631
|
-
|
|
2632
2191
|
if (arr.length > 0) this.stackPointer++;
|
|
2633
2192
|
}
|
|
2634
2193
|
}
|
|
2635
2194
|
},
|
|
2636
|
-
applyColors: function
|
|
2637
|
-
|
|
2638
|
-
|
|
2195
|
+
applyColors: function () {
|
|
2196
|
+
let wholeNoTiles = 0;
|
|
2197
|
+
let wholePercentage = 0;
|
|
2639
2198
|
THIS.addBottomTableHeadings();
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
var tile = THIS.allTiles[i];
|
|
2199
|
+
for (let i = 0; i < THIS.allTiles.length; i++) {
|
|
2200
|
+
let tile = THIS.allTiles[i];
|
|
2643
2201
|
THIS.setTileVisible(tile, false);
|
|
2644
2202
|
}
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
var arr = this.stackUpWithColor[color];
|
|
2648
|
-
|
|
2203
|
+
for (let color = 0; color < this.stackPointer; color++) {
|
|
2204
|
+
let arr = this.stackUpWithColor[color];
|
|
2649
2205
|
if (arr) {
|
|
2650
2206
|
THIS.addBottomTableRow(color, arr);
|
|
2651
|
-
|
|
2652
|
-
for (var _i2 = 0; _i2 < arr.length; _i2++) {
|
|
2207
|
+
for (let i = 0; i < arr.length; i++) {
|
|
2653
2208
|
wholeNoTiles++;
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2209
|
+
let index = this.stackUpWithColor[color][i];
|
|
2210
|
+
let tile = THIS.allTiles[index];
|
|
2211
|
+
let well = this.derivative[index];
|
|
2657
2212
|
this.colorMap.set(index, color);
|
|
2658
|
-
THIS.setTileColor(
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
THIS.setTileComplete(
|
|
2213
|
+
THIS.setTileColor(tile, color);
|
|
2214
|
+
// Checks if all the required fields are filled
|
|
2215
|
+
let completion = this.checkCompletion(well, tile);
|
|
2216
|
+
THIS.setTileComplete(tile, completion === 1);
|
|
2662
2217
|
wholePercentage = wholePercentage + completion;
|
|
2663
2218
|
}
|
|
2664
2219
|
}
|
|
2665
2220
|
}
|
|
2666
|
-
|
|
2667
2221
|
wholePercentage = Math.floor(100 * wholePercentage / wholeNoTiles);
|
|
2668
|
-
|
|
2669
2222
|
if (isNaN(wholePercentage)) {
|
|
2670
2223
|
THIS.overLayTextContainer.text("Completion Percentage: 0%");
|
|
2671
2224
|
} else {
|
|
2672
2225
|
THIS.overLayTextContainer.text("Completion Percentage: " + wholePercentage + "%");
|
|
2673
2226
|
}
|
|
2674
|
-
|
|
2675
2227
|
THIS.selectObjectInBottomTab();
|
|
2676
2228
|
},
|
|
2677
|
-
checkCompletion: function
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
var field = THIS.fieldList[i];
|
|
2683
|
-
|
|
2229
|
+
checkCompletion: function (wellData) {
|
|
2230
|
+
let req = 0;
|
|
2231
|
+
let fill = 0;
|
|
2232
|
+
for (let i = 0; i < THIS.fieldList.length; i++) {
|
|
2233
|
+
let field = THIS.fieldList[i];
|
|
2684
2234
|
if (field.checkMultiplexCompletion) {
|
|
2685
2235
|
// also apply color
|
|
2686
|
-
|
|
2687
|
-
|
|
2236
|
+
let multiplexStatus = field.checkMultiplexCompletion(wellData[field.id]);
|
|
2688
2237
|
if (multiplexStatus.include) {
|
|
2689
2238
|
fill += multiplexStatus.completionPct;
|
|
2690
2239
|
req++;
|
|
@@ -2692,27 +2241,22 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2692
2241
|
} else {
|
|
2693
2242
|
if (field.required) {
|
|
2694
2243
|
req++;
|
|
2695
|
-
|
|
2696
2244
|
if (wellData[field.id] !== null) {
|
|
2697
2245
|
fill++;
|
|
2698
2246
|
}
|
|
2699
2247
|
}
|
|
2700
2248
|
}
|
|
2701
2249
|
}
|
|
2702
|
-
|
|
2703
2250
|
if (req === fill) {
|
|
2704
2251
|
return 1;
|
|
2705
2252
|
}
|
|
2706
|
-
|
|
2707
2253
|
return fill / req;
|
|
2708
2254
|
}
|
|
2709
2255
|
}
|
|
2710
2256
|
};
|
|
2711
2257
|
};
|
|
2712
2258
|
})(jQuery);
|
|
2713
|
-
|
|
2714
2259
|
var plateMapWidget = plateMapWidget || {};
|
|
2715
|
-
|
|
2716
2260
|
plateMapWidget.assets = function () {
|
|
2717
2261
|
return {
|
|
2718
2262
|
_assets: {
|
|
@@ -2722,58 +2266,45 @@ plateMapWidget.assets = function () {
|
|
|
2722
2266
|
}
|
|
2723
2267
|
};
|
|
2724
2268
|
};
|
|
2725
|
-
|
|
2726
2269
|
var plateMapWidget = plateMapWidget || {};
|
|
2727
|
-
|
|
2728
2270
|
(function ($) {
|
|
2729
|
-
plateMapWidget
|
|
2271
|
+
plateMapWidget.interface = function () {
|
|
2730
2272
|
// interface holds all the methods to put the interface in place
|
|
2731
2273
|
return {
|
|
2732
|
-
_createInterface: function
|
|
2733
|
-
|
|
2274
|
+
_createInterface: function () {
|
|
2275
|
+
let divIdentifier = '<div></div>';
|
|
2734
2276
|
this.container = this._createElement(divIdentifier).addClass("plate-setup-wrapper");
|
|
2735
2277
|
this.topSection = this._createElement(divIdentifier).addClass("plate-setup-top-section");
|
|
2736
2278
|
this.topLeft = this._createElement(divIdentifier).addClass("plate-setup-top-left");
|
|
2737
2279
|
this.topRight = this._createElement(divIdentifier).addClass("plate-setup-top-right");
|
|
2738
2280
|
this.overLayContainer = this._createElement(divIdentifier).addClass("plate-setup-overlay-container");
|
|
2739
2281
|
this.canvasContainer = this._createElement(divIdentifier).addClass("plate-setup-canvas-container");
|
|
2740
|
-
|
|
2741
2282
|
this._createOverLay();
|
|
2742
|
-
|
|
2743
2283
|
$(this.topLeft).append(this.overLayContainer);
|
|
2744
2284
|
$(this.topLeft).append(this.canvasContainer);
|
|
2745
2285
|
$(this.topSection).append(this.topLeft);
|
|
2746
2286
|
$(this.topSection).append(this.topRight);
|
|
2747
2287
|
$(this.container).append(this.topSection);
|
|
2748
2288
|
$(this.element).append(this.container);
|
|
2749
|
-
|
|
2750
2289
|
this._createSvg();
|
|
2751
|
-
|
|
2752
2290
|
this._createTabAtRight();
|
|
2753
|
-
|
|
2754
2291
|
this._createTabs();
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2292
|
+
this._placePresetTabs();
|
|
2293
|
+
// Bottom of the screen
|
|
2759
2294
|
this._bottomScreen();
|
|
2760
|
-
|
|
2761
2295
|
this.bottomForFirstTime();
|
|
2762
|
-
|
|
2763
|
-
|
|
2296
|
+
let that = this;
|
|
2764
2297
|
this._setShortcuts();
|
|
2765
|
-
|
|
2766
2298
|
$(document.body).keyup(function (e) {
|
|
2767
2299
|
that._handleShortcuts(e);
|
|
2768
2300
|
});
|
|
2769
|
-
|
|
2770
2301
|
this._configureUndoRedoArray();
|
|
2771
2302
|
},
|
|
2772
|
-
_createElement: function
|
|
2303
|
+
_createElement: function (element) {
|
|
2773
2304
|
return $(element);
|
|
2774
2305
|
},
|
|
2775
|
-
_setShortcuts: function
|
|
2776
|
-
|
|
2306
|
+
_setShortcuts: function () {
|
|
2307
|
+
let that = this;
|
|
2777
2308
|
window.addEventListener("cut", function (e) {
|
|
2778
2309
|
if (document.activeElement === document.body) {
|
|
2779
2310
|
that.copyCriteria();
|
|
@@ -2794,7 +2325,7 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2794
2325
|
}
|
|
2795
2326
|
});
|
|
2796
2327
|
},
|
|
2797
|
-
_handleShortcuts: function
|
|
2328
|
+
_handleShortcuts: function (e) {
|
|
2798
2329
|
if (document.activeElement === document.body) {
|
|
2799
2330
|
if (e.keyCode === 46) {
|
|
2800
2331
|
this.clearCriteria();
|
|
@@ -2806,7 +2337,6 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2806
2337
|
} else {
|
|
2807
2338
|
this.undo();
|
|
2808
2339
|
}
|
|
2809
|
-
|
|
2810
2340
|
e.preventDefault();
|
|
2811
2341
|
} else if (e.keyCode === 89) {
|
|
2812
2342
|
this.redo();
|
|
@@ -2818,87 +2348,76 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2818
2348
|
};
|
|
2819
2349
|
};
|
|
2820
2350
|
})(jQuery);
|
|
2821
|
-
|
|
2822
2351
|
var plateMapWidget = plateMapWidget || {};
|
|
2823
|
-
|
|
2824
2352
|
plateMapWidget.loadPlate = function () {
|
|
2825
2353
|
// Methods which look after data changes and stack up accordingly
|
|
2826
2354
|
// Remember THIS points to plateMapWidget and 'this' points to engine
|
|
2827
2355
|
return {
|
|
2828
|
-
loadPlate: function
|
|
2356
|
+
loadPlate: function (data) {
|
|
2829
2357
|
//sanitize input
|
|
2830
|
-
|
|
2831
|
-
|
|
2358
|
+
let derivative;
|
|
2832
2359
|
if (data.hasOwnProperty('wells')) {
|
|
2833
2360
|
derivative = {};
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
var index = this.addressToIndex(address);
|
|
2361
|
+
for (let address in data.wells) {
|
|
2362
|
+
let well = data.wells[address];
|
|
2363
|
+
let index = this.addressToIndex(address);
|
|
2838
2364
|
derivative[index] = this.sanitizeWell(well);
|
|
2839
2365
|
}
|
|
2840
2366
|
} else {
|
|
2841
2367
|
derivative = this.engine.derivative;
|
|
2842
2368
|
}
|
|
2843
|
-
|
|
2844
|
-
var checkboxes;
|
|
2845
|
-
|
|
2369
|
+
let checkboxes;
|
|
2846
2370
|
if (data.hasOwnProperty('checkboxes')) {
|
|
2847
2371
|
checkboxes = this.sanitizeCheckboxes(data.checkboxes);
|
|
2848
2372
|
} else {
|
|
2849
2373
|
checkboxes = this.getCheckboxes();
|
|
2850
2374
|
}
|
|
2851
|
-
|
|
2852
|
-
var sanitized = {
|
|
2375
|
+
let sanitized = {
|
|
2853
2376
|
"derivative": derivative,
|
|
2854
2377
|
"checkboxes": checkboxes
|
|
2855
2378
|
};
|
|
2856
2379
|
this.setData(sanitized);
|
|
2857
2380
|
},
|
|
2858
|
-
sanitizeCheckboxes: function
|
|
2381
|
+
sanitizeCheckboxes: function (checkboxes) {
|
|
2859
2382
|
checkboxes = checkboxes || [];
|
|
2860
|
-
return this.allCheckboxes.filter(
|
|
2861
|
-
return checkboxes.indexOf(fieldId) >= 0;
|
|
2862
|
-
});
|
|
2383
|
+
return this.allCheckboxes.filter(fieldId => checkboxes.indexOf(fieldId) >= 0);
|
|
2863
2384
|
},
|
|
2864
|
-
sanitizeAddresses: function
|
|
2385
|
+
sanitizeAddresses: function (selectedAddresses) {
|
|
2865
2386
|
selectedAddresses = selectedAddresses || [];
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
indices =
|
|
2869
|
-
|
|
2870
|
-
|
|
2387
|
+
// Arrow, not a bare method reference: .map() would pass the array
|
|
2388
|
+
// position as addressToIndex's `dimensions` argument
|
|
2389
|
+
let indices = selectedAddresses.map(address => this.addressToIndex(address));
|
|
2390
|
+
// Numeric comparator: the default sort compares as strings (10 < 2)
|
|
2391
|
+
indices.sort((a, b) => a - b);
|
|
2392
|
+
indices = indices.filter((index, i) => indices.indexOf(index) === i);
|
|
2871
2393
|
return indices;
|
|
2872
2394
|
},
|
|
2873
|
-
sanitizeWell: function
|
|
2874
|
-
|
|
2395
|
+
sanitizeWell: function (well) {
|
|
2396
|
+
let newWell = {};
|
|
2875
2397
|
this.fieldList.forEach(function (field) {
|
|
2876
2398
|
newWell[field.id] = field.parseValue(well[field.id]);
|
|
2877
2399
|
});
|
|
2878
2400
|
return newWell;
|
|
2879
2401
|
},
|
|
2880
|
-
setData: function
|
|
2402
|
+
setData: function (data, quiet) {
|
|
2881
2403
|
this.engine.derivative = data.derivative;
|
|
2882
2404
|
this.setCheckboxes(data.checkboxes, true);
|
|
2883
2405
|
this.setSelectedIndices(data.selectedIndices, true);
|
|
2884
2406
|
this.derivativeChange();
|
|
2885
|
-
|
|
2886
2407
|
if (!quiet) {
|
|
2887
2408
|
this.addToUndoRedo();
|
|
2888
2409
|
}
|
|
2889
2410
|
}
|
|
2890
2411
|
};
|
|
2891
2412
|
};
|
|
2892
|
-
|
|
2893
2413
|
var plateMapWidget = plateMapWidget || {};
|
|
2894
|
-
|
|
2895
2414
|
(function ($) {
|
|
2896
2415
|
plateMapWidget.overlay = function () {
|
|
2897
2416
|
// overlay holds all the methods to put the part just above the canvas which contains all those
|
|
2898
2417
|
// 'completion percentage' annd 'copy Criteria' button etc ...
|
|
2899
2418
|
return {
|
|
2900
|
-
_createOverLay: function
|
|
2901
|
-
|
|
2419
|
+
_createOverLay: function () {
|
|
2420
|
+
let that = this;
|
|
2902
2421
|
this.overLayTextContainer = this._createElement("<div></div>").addClass("plate-setup-overlay-text-container");
|
|
2903
2422
|
this.overLayTextContainer.text("Completion Percentage:");
|
|
2904
2423
|
this.overLayContainer.append(this.overLayTextContainer);
|
|
@@ -2935,15 +2454,13 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2935
2454
|
that.redo();
|
|
2936
2455
|
});
|
|
2937
2456
|
},
|
|
2938
|
-
clearCriteria: function
|
|
2457
|
+
clearCriteria: function () {
|
|
2939
2458
|
if (this.selectedIndices && this.selectedIndices.length) {
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
var index = selectedIndices[i];
|
|
2946
|
-
|
|
2459
|
+
let hasWellUpdate = false;
|
|
2460
|
+
let selectedIndices = this.selectedIndices;
|
|
2461
|
+
let well;
|
|
2462
|
+
for (let i = 0; i < selectedIndices.length; i++) {
|
|
2463
|
+
let index = selectedIndices[i];
|
|
2947
2464
|
if (index in this.engine.derivative) {
|
|
2948
2465
|
// handling for clearing well when not allowed to add or delete wells
|
|
2949
2466
|
if (this.disableAddDeleteWell) {
|
|
@@ -2954,14 +2471,11 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2954
2471
|
} else {
|
|
2955
2472
|
delete this.engine.derivative[index];
|
|
2956
2473
|
}
|
|
2957
|
-
|
|
2958
2474
|
hasWellUpdate = true;
|
|
2959
2475
|
}
|
|
2960
2476
|
}
|
|
2961
|
-
|
|
2962
2477
|
if (hasWellUpdate) {
|
|
2963
2478
|
this._colorMixer();
|
|
2964
|
-
|
|
2965
2479
|
this.decideSelectedFields();
|
|
2966
2480
|
this.derivativeChange();
|
|
2967
2481
|
this.addToUndoRedo();
|
|
@@ -2970,42 +2484,36 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
2970
2484
|
alert("Please select any well");
|
|
2971
2485
|
}
|
|
2972
2486
|
},
|
|
2973
|
-
copyCriteria: function
|
|
2487
|
+
copyCriteria: function () {
|
|
2974
2488
|
if (this.selectedIndices && this.selectedIndices.length) {
|
|
2975
|
-
|
|
2976
|
-
|
|
2489
|
+
let wells = this._getSelectedWells();
|
|
2977
2490
|
this.commonData = this._getCommonData(wells);
|
|
2978
2491
|
} else {
|
|
2979
2492
|
alert("Please select any well.");
|
|
2980
2493
|
}
|
|
2981
2494
|
},
|
|
2982
|
-
pasteCriteria: function
|
|
2495
|
+
pasteCriteria: function () {
|
|
2983
2496
|
if (this.commonData) {
|
|
2984
2497
|
this._addAllData(this.commonData);
|
|
2985
|
-
|
|
2986
2498
|
this.decideSelectedFields();
|
|
2987
2499
|
}
|
|
2988
2500
|
}
|
|
2989
2501
|
};
|
|
2990
2502
|
};
|
|
2991
2503
|
})(jQuery);
|
|
2992
|
-
|
|
2993
2504
|
$.widget("DNA.plateMap", {
|
|
2994
2505
|
plateMapWidget: {},
|
|
2995
2506
|
options: {
|
|
2996
2507
|
value: 0
|
|
2997
2508
|
},
|
|
2998
|
-
addressToLoc: function
|
|
2999
|
-
|
|
3000
|
-
|
|
2509
|
+
addressToLoc: function (address) {
|
|
2510
|
+
let m = /^([A-Z]+)(\d+)$/.exec(address.trim().toUpperCase());
|
|
3001
2511
|
if (m) {
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
var c = row_v.charCodeAt(i) - 65;
|
|
3008
|
-
|
|
2512
|
+
let row_v = m[1];
|
|
2513
|
+
let col = parseInt(m[2]) - 1;
|
|
2514
|
+
let row = 0;
|
|
2515
|
+
for (let i = 0; i < row_v.length; i++) {
|
|
2516
|
+
let c = row_v.charCodeAt(i) - 65;
|
|
3009
2517
|
if (i) {
|
|
3010
2518
|
row += 1;
|
|
3011
2519
|
row *= 26;
|
|
@@ -3014,7 +2522,6 @@ $.widget("DNA.plateMap", {
|
|
|
3014
2522
|
row = c;
|
|
3015
2523
|
}
|
|
3016
2524
|
}
|
|
3017
|
-
|
|
3018
2525
|
return {
|
|
3019
2526
|
r: row,
|
|
3020
2527
|
c: col
|
|
@@ -3023,126 +2530,111 @@ $.widget("DNA.plateMap", {
|
|
|
3023
2530
|
throw address + " not a proper plate address";
|
|
3024
2531
|
}
|
|
3025
2532
|
},
|
|
3026
|
-
locToIndex: function
|
|
2533
|
+
locToIndex: function (loc, dimensions) {
|
|
3027
2534
|
if (!dimensions) {
|
|
3028
2535
|
dimensions = this.dimensions;
|
|
3029
2536
|
}
|
|
3030
|
-
|
|
3031
2537
|
if (!(loc.r >= 0 && loc.r < dimensions.rows)) {
|
|
3032
2538
|
throw "Row index " + (loc.r + 1) + " invalid";
|
|
3033
2539
|
}
|
|
3034
|
-
|
|
3035
2540
|
if (!(loc.c >= 0 && loc.c < dimensions.cols)) {
|
|
3036
2541
|
throw "Column index " + (loc.c + 1) + " invalid";
|
|
3037
2542
|
}
|
|
3038
|
-
|
|
3039
2543
|
return loc.r * dimensions.cols + loc.c;
|
|
3040
2544
|
},
|
|
3041
|
-
addressToIndex: function
|
|
3042
|
-
|
|
2545
|
+
addressToIndex: function (address, dimensions) {
|
|
2546
|
+
let loc = this.addressToLoc(address);
|
|
3043
2547
|
return this.locToIndex(loc, dimensions);
|
|
3044
2548
|
},
|
|
3045
|
-
_rowKey: function
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
2549
|
+
_rowKey: function (i) {
|
|
2550
|
+
let c1 = i % 26;
|
|
2551
|
+
let c2 = (i - c1) / 26;
|
|
2552
|
+
let code = String.fromCharCode(65 + c1);
|
|
3050
2553
|
if (c2 > 0) {
|
|
3051
2554
|
code = String.fromCharCode(64 + c2) + code;
|
|
3052
2555
|
}
|
|
3053
|
-
|
|
3054
2556
|
return code;
|
|
3055
2557
|
},
|
|
3056
|
-
_colKey: function
|
|
2558
|
+
_colKey: function (i) {
|
|
3057
2559
|
return (i + 1).toString(10);
|
|
3058
2560
|
},
|
|
3059
|
-
indexToLoc: function
|
|
2561
|
+
indexToLoc: function (index, dimensions) {
|
|
3060
2562
|
if (!dimensions) {
|
|
3061
2563
|
dimensions = this.dimensions;
|
|
3062
2564
|
}
|
|
3063
|
-
|
|
3064
2565
|
if (index >= dimensions.rows * dimensions.cols) {
|
|
3065
2566
|
throw "Index too high: " + index.toString(10);
|
|
3066
2567
|
}
|
|
3067
|
-
|
|
3068
|
-
var loc = {};
|
|
2568
|
+
let loc = {};
|
|
3069
2569
|
loc.c = index % dimensions.cols;
|
|
3070
2570
|
loc.r = (index - loc.c) / dimensions.cols;
|
|
3071
2571
|
return loc;
|
|
3072
2572
|
},
|
|
3073
|
-
locToAddress: function
|
|
2573
|
+
locToAddress: function (loc) {
|
|
3074
2574
|
return this._rowKey(loc.r) + this._colKey(loc.c);
|
|
3075
2575
|
},
|
|
3076
|
-
indexToAddress: function
|
|
3077
|
-
|
|
2576
|
+
indexToAddress: function (index, dimensions) {
|
|
2577
|
+
let loc = this.indexToLoc(index, dimensions);
|
|
3078
2578
|
return this.locToAddress(loc);
|
|
3079
2579
|
},
|
|
3080
|
-
getDimensions: function
|
|
2580
|
+
getDimensions: function () {
|
|
3081
2581
|
return $.extend(true, {}, this.dimensions);
|
|
3082
2582
|
},
|
|
3083
|
-
_create: function
|
|
3084
|
-
|
|
3085
|
-
|
|
2583
|
+
_create: function () {
|
|
2584
|
+
let rows = parseInt(this.options.numRows || 8);
|
|
2585
|
+
let cols = parseInt(this.options.numCols || 12);
|
|
3086
2586
|
this.dimensions = {
|
|
3087
2587
|
rows: rows,
|
|
3088
2588
|
cols: cols
|
|
3089
2589
|
};
|
|
3090
2590
|
this.rowIndex = [];
|
|
3091
|
-
|
|
3092
|
-
for (var i = 0; i < rows; i++) {
|
|
2591
|
+
for (let i = 0; i < rows; i++) {
|
|
3093
2592
|
this.rowIndex.push(this._rowKey(i));
|
|
3094
2593
|
}
|
|
2594
|
+
this.target = this.element[0].id ? "#" + this.element[0].id : "." + this.element[0].className;
|
|
3095
2595
|
|
|
3096
|
-
|
|
2596
|
+
// Import classes from other files.. Here we import it using extend and add it to this
|
|
3097
2597
|
// object. internally we add to widget.DNA.getPlates.prototype.
|
|
3098
2598
|
// Helpers are methods which return other methods and objects.
|
|
3099
2599
|
// add Objects to plateMapWidget and it will be added to this object.
|
|
3100
2600
|
// set read only well
|
|
3101
|
-
|
|
3102
2601
|
if (this.options.readOnly) {
|
|
3103
2602
|
this.isReadOnly(true);
|
|
3104
2603
|
}
|
|
3105
|
-
|
|
3106
|
-
for (var component in plateMapWidget) {
|
|
2604
|
+
for (let component in plateMapWidget) {
|
|
3107
2605
|
if (plateMapWidget.hasOwnProperty(component)) {
|
|
3108
2606
|
// Incase some properties has to initialize with data from options hash,
|
|
3109
2607
|
// we provide it sending this object.
|
|
3110
2608
|
$.extend(this, new plateMapWidget[component](this));
|
|
3111
2609
|
}
|
|
3112
2610
|
}
|
|
3113
|
-
|
|
3114
2611
|
this._createInterface();
|
|
3115
|
-
|
|
3116
2612
|
this._trigger("created", null, this);
|
|
3117
|
-
|
|
3118
2613
|
return this;
|
|
3119
2614
|
},
|
|
3120
|
-
_init: function
|
|
2615
|
+
_init: function () {
|
|
2616
|
+
// This is invoked when the user use the plugin after _create is called.
|
|
3121
2617
|
// The point is _create is invoked for the very first time and for all other
|
|
3122
2618
|
// times _init is used.
|
|
3123
2619
|
},
|
|
3124
2620
|
// wellsData follows syntax: {A1:{field1: val1, field2: val2}, A2:{field1: val1, field2: val2}}
|
|
3125
|
-
getTextDerivative: function
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
for (var address in wellsData) {
|
|
2621
|
+
getTextDerivative: function (wellsData) {
|
|
2622
|
+
let textDerivative = {};
|
|
2623
|
+
let fieldMap = this.fieldMap;
|
|
2624
|
+
for (let address in wellsData) {
|
|
3130
2625
|
if (!wellsData.hasOwnProperty(address)) {
|
|
3131
2626
|
continue;
|
|
3132
2627
|
}
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
for (var fieldId in curWellData) {
|
|
2628
|
+
let textValWell = {};
|
|
2629
|
+
let textFieldIdWell = {};
|
|
2630
|
+
let curWellData = wellsData[address];
|
|
2631
|
+
for (let fieldId in curWellData) {
|
|
3139
2632
|
if (!curWellData.hasOwnProperty(fieldId)) {
|
|
3140
2633
|
continue;
|
|
3141
2634
|
}
|
|
3142
|
-
|
|
3143
2635
|
if (fieldId in fieldMap) {
|
|
3144
|
-
|
|
3145
|
-
|
|
2636
|
+
let field = fieldMap[fieldId];
|
|
2637
|
+
let textVal = field.parseText(curWellData[fieldId]);
|
|
3146
2638
|
textFieldIdWell[field.name] = textVal;
|
|
3147
2639
|
textValWell[fieldId] = textVal;
|
|
3148
2640
|
} else {
|
|
@@ -3151,76 +2643,59 @@ $.widget("DNA.plateMap", {
|
|
|
3151
2643
|
textValWell[fieldId] = curWellData[fieldId];
|
|
3152
2644
|
}
|
|
3153
2645
|
}
|
|
3154
|
-
|
|
3155
2646
|
textDerivative[address] = {
|
|
3156
2647
|
textVal: textValWell,
|
|
3157
2648
|
textFieldVal: textFieldIdWell
|
|
3158
2649
|
};
|
|
3159
2650
|
}
|
|
3160
|
-
|
|
3161
2651
|
return textDerivative;
|
|
3162
2652
|
},
|
|
3163
2653
|
// wellsData follows syntax: {A1:{field1: val1, field2: val2}, A1:{field1: val1, field2: val2}}
|
|
3164
|
-
getWellsDifferences: function
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
for (var wellId in wellsHash) {
|
|
2654
|
+
getWellsDifferences: function (wellsHash) {
|
|
2655
|
+
let wells = [];
|
|
2656
|
+
for (let wellId in wellsHash) {
|
|
3168
2657
|
if (wellsHash.hasOwnProperty(wellId)) {
|
|
3169
2658
|
wells.push(wellsHash[wellId]);
|
|
3170
2659
|
}
|
|
3171
2660
|
}
|
|
3172
|
-
|
|
3173
|
-
var differentWellsVals = {};
|
|
3174
|
-
|
|
2661
|
+
let differentWellsVals = {};
|
|
3175
2662
|
if (wells.length > 1) {
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
for (var fieldIdx in wells[0]) {
|
|
2663
|
+
let commonWell = this._getCommonWell(wells);
|
|
2664
|
+
let allFieldVal = {};
|
|
2665
|
+
for (let fieldIdx in wells[0]) {
|
|
3181
2666
|
if (wells[0].hasOwnProperty(fieldIdx)) {
|
|
3182
2667
|
allFieldVal[fieldIdx] = [];
|
|
3183
2668
|
}
|
|
3184
2669
|
}
|
|
3185
|
-
|
|
3186
|
-
for (var address in wellsHash) {
|
|
2670
|
+
for (let address in wellsHash) {
|
|
3187
2671
|
if (!wellsHash.hasOwnProperty(address)) {
|
|
3188
2672
|
continue;
|
|
3189
2673
|
}
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
for (var fieldId in curWellData) {
|
|
2674
|
+
let diffWellVal = {};
|
|
2675
|
+
let curWellData = wellsHash[address];
|
|
2676
|
+
for (let fieldId in curWellData) {
|
|
3195
2677
|
if (!curWellData.hasOwnProperty(fieldId)) {
|
|
3196
2678
|
continue;
|
|
3197
2679
|
}
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
var curVal = curWellData[fieldId];
|
|
3201
|
-
|
|
2680
|
+
let commonVal = commonWell[fieldId];
|
|
2681
|
+
let curVal = curWellData[fieldId];
|
|
3202
2682
|
if (commonVal === undefined) {
|
|
3203
2683
|
commonVal = null;
|
|
3204
2684
|
}
|
|
3205
|
-
|
|
3206
2685
|
if (curVal === undefined) {
|
|
3207
2686
|
curVal = null;
|
|
3208
2687
|
}
|
|
3209
|
-
|
|
3210
|
-
var newVal = null;
|
|
3211
|
-
|
|
2688
|
+
let newVal = null;
|
|
3212
2689
|
if (Array.isArray(curVal)) {
|
|
3213
|
-
commonVal = commonVal || [];
|
|
3214
|
-
|
|
2690
|
+
commonVal = commonVal || [];
|
|
2691
|
+
// get uncommonVal
|
|
3215
2692
|
newVal = [];
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
if (curMultiVal && _typeof(curMultiVal) === "object") {
|
|
2693
|
+
for (let idx = 0; idx < curVal.length; idx++) {
|
|
2694
|
+
let curMultiVal = curVal[idx];
|
|
2695
|
+
// multiplex field
|
|
2696
|
+
if (curMultiVal && typeof curMultiVal === "object") {
|
|
3221
2697
|
if (!this.containsObject(curMultiVal, commonVal)) {
|
|
3222
2698
|
newVal.push(curMultiVal);
|
|
3223
|
-
|
|
3224
2699
|
if (!this.containsObject(curMultiVal, allFieldVal[fieldId])) {
|
|
3225
2700
|
allFieldVal[fieldId].push(curMultiVal);
|
|
3226
2701
|
}
|
|
@@ -3228,104 +2703,88 @@ $.widget("DNA.plateMap", {
|
|
|
3228
2703
|
} else {
|
|
3229
2704
|
if (commonVal.indexOf(curMultiVal) < 0) {
|
|
3230
2705
|
newVal.push(curMultiVal);
|
|
3231
|
-
|
|
3232
2706
|
if (!allFieldVal[fieldId].indexOf(curMultiVal) >= 0) {
|
|
3233
2707
|
allFieldVal[fieldId].push(curMultiVal);
|
|
3234
2708
|
}
|
|
3235
2709
|
}
|
|
3236
2710
|
}
|
|
3237
2711
|
}
|
|
3238
|
-
} else if (curVal &&
|
|
3239
|
-
if (commonVal &&
|
|
2712
|
+
} else if (curVal && typeof curVal === "object") {
|
|
2713
|
+
if (commonVal && typeof commonVal === "object") {
|
|
3240
2714
|
if (!(curVal.value === commonVal.value || curVal.unit === commonVal.unit)) {
|
|
3241
2715
|
newVal = curVal;
|
|
3242
|
-
|
|
3243
2716
|
if (!this.containsObject(curVal, allFieldVal[fieldId])) {
|
|
3244
2717
|
allFieldVal[fieldId].push(curVal);
|
|
3245
2718
|
}
|
|
3246
2719
|
}
|
|
3247
2720
|
} else {
|
|
3248
2721
|
newVal = curVal;
|
|
3249
|
-
|
|
3250
2722
|
if (!this.containsObject(curVal, allFieldVal[fieldId])) {
|
|
3251
2723
|
allFieldVal[fieldId].push(curVal);
|
|
3252
2724
|
}
|
|
3253
2725
|
}
|
|
3254
2726
|
} else if (curVal !== commonVal) {
|
|
3255
2727
|
newVal = curVal;
|
|
3256
|
-
|
|
3257
2728
|
if (!allFieldVal[fieldId].indexOf(curVal) >= 0) {
|
|
3258
2729
|
allFieldVal[fieldId].push(curVal);
|
|
3259
2730
|
}
|
|
3260
2731
|
}
|
|
3261
|
-
|
|
3262
2732
|
diffWellVal[fieldId] = newVal;
|
|
3263
2733
|
}
|
|
3264
|
-
|
|
3265
2734
|
differentWellsVals[address] = diffWellVal;
|
|
3266
|
-
}
|
|
3267
|
-
|
|
2735
|
+
}
|
|
3268
2736
|
|
|
3269
|
-
for
|
|
3270
|
-
|
|
2737
|
+
// clean up step for fields that are empty
|
|
2738
|
+
for (let fieldId in allFieldVal) {
|
|
2739
|
+
if (!allFieldVal.hasOwnProperty(fieldId)) {
|
|
3271
2740
|
continue;
|
|
3272
2741
|
}
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
if (!differentWellsVals.hasOwnProperty(_address)) {
|
|
2742
|
+
if (allFieldVal[fieldId].length === 0) {
|
|
2743
|
+
for (let address in differentWellsVals) {
|
|
2744
|
+
if (!differentWellsVals.hasOwnProperty(address)) {
|
|
3277
2745
|
continue;
|
|
3278
2746
|
}
|
|
3279
|
-
|
|
3280
|
-
delete differentWellsVals[_address][_fieldId];
|
|
2747
|
+
delete differentWellsVals[address][fieldId];
|
|
3281
2748
|
}
|
|
3282
2749
|
}
|
|
3283
2750
|
}
|
|
3284
|
-
|
|
3285
2751
|
return differentWellsVals;
|
|
3286
2752
|
} else if (wells.length > 0) {
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
if (!wellsHash.hasOwnProperty(_address2)) {
|
|
2753
|
+
let differentWellsVals = {};
|
|
2754
|
+
for (let address in wellsHash) {
|
|
2755
|
+
if (!wellsHash.hasOwnProperty(address)) {
|
|
3291
2756
|
continue;
|
|
3292
2757
|
}
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
for (var _fieldId2 in _curWellData) {
|
|
3298
|
-
if (!_curWellData.hasOwnProperty(_fieldId2)) {
|
|
2758
|
+
let diffWellVal = {};
|
|
2759
|
+
let curWellData = wellsHash[address];
|
|
2760
|
+
for (let fieldId in curWellData) {
|
|
2761
|
+
if (!curWellData.hasOwnProperty(fieldId)) {
|
|
3299
2762
|
continue;
|
|
3300
2763
|
}
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
if (_curVal.length > 0) {
|
|
3306
|
-
_diffWellVal[_fieldId2] = _curVal;
|
|
2764
|
+
let curVal = curWellData[fieldId];
|
|
2765
|
+
if (Array.isArray(curVal)) {
|
|
2766
|
+
if (curVal.length > 0) {
|
|
2767
|
+
diffWellVal[fieldId] = curVal;
|
|
3307
2768
|
}
|
|
3308
|
-
} else if (
|
|
3309
|
-
|
|
2769
|
+
} else if (curVal) {
|
|
2770
|
+
diffWellVal[fieldId] = curVal;
|
|
3310
2771
|
}
|
|
3311
2772
|
}
|
|
3312
|
-
|
|
3313
|
-
_differentWellsVals[_address2] = _diffWellVal;
|
|
2773
|
+
differentWellsVals[address] = diffWellVal;
|
|
3314
2774
|
}
|
|
3315
|
-
|
|
3316
|
-
return _differentWellsVals;
|
|
2775
|
+
return differentWellsVals;
|
|
3317
2776
|
}
|
|
3318
2777
|
},
|
|
3319
|
-
setFieldsDisabled: function
|
|
2778
|
+
setFieldsDisabled: function (flag) {
|
|
3320
2779
|
this.fieldList.forEach(function (field) {
|
|
3321
2780
|
field.disabled(flag);
|
|
3322
2781
|
});
|
|
3323
2782
|
},
|
|
3324
|
-
isReadOnly: function
|
|
2783
|
+
isReadOnly: function (flag) {
|
|
3325
2784
|
this.readOnly = !!flag;
|
|
3326
2785
|
this.readOnlyHandler();
|
|
3327
2786
|
},
|
|
3328
|
-
readOnlyHandler: function
|
|
2787
|
+
readOnlyHandler: function () {
|
|
3329
2788
|
if (this.readOnly) {
|
|
3330
2789
|
this.overLayButtonContainer.css("display", "none");
|
|
3331
2790
|
$('.multiple-field-manage-delete-button').css("display", "none");
|
|
@@ -3333,7 +2792,6 @@ $.widget("DNA.plateMap", {
|
|
|
3333
2792
|
} else {
|
|
3334
2793
|
this.overLayButtonContainer.css("display", "flex");
|
|
3335
2794
|
$('.multiple-field-manage-delete-button').css("display", "none");
|
|
3336
|
-
|
|
3337
2795
|
if (!this.disableAddDeleteWell) {
|
|
3338
2796
|
this.setFieldsDisabled(false);
|
|
3339
2797
|
}
|
|
@@ -3341,12 +2799,11 @@ $.widget("DNA.plateMap", {
|
|
|
3341
2799
|
},
|
|
3342
2800
|
disableAddDeleteWell: null,
|
|
3343
2801
|
// column_with_default_val will be used to determine empty wells, format: {field_name: default_val}
|
|
3344
|
-
isDisableAddDeleteWell: function
|
|
2802
|
+
isDisableAddDeleteWell: function (flag, emptyDefaultWell) {
|
|
3345
2803
|
if (flag) {
|
|
3346
|
-
|
|
3347
|
-
|
|
2804
|
+
let emptyWellWithDefaultVal = $.extend(true, {}, this.defaultWell);
|
|
3348
2805
|
if (emptyDefaultWell) {
|
|
3349
|
-
for (
|
|
2806
|
+
for (let field in emptyDefaultWell) {
|
|
3350
2807
|
if (emptyDefaultWell.hasOwnProperty(field)) {
|
|
3351
2808
|
if (field in emptyWellWithDefaultVal) {
|
|
3352
2809
|
emptyWellWithDefaultVal[field] = emptyDefaultWell[field];
|
|
@@ -3356,10 +2813,9 @@ $.widget("DNA.plateMap", {
|
|
|
3356
2813
|
}
|
|
3357
2814
|
}
|
|
3358
2815
|
}
|
|
3359
|
-
|
|
3360
2816
|
this.disableAddDeleteWell = true;
|
|
3361
|
-
this.addressAllowToEdit = this.getWellSetAddressWithData();
|
|
3362
|
-
|
|
2817
|
+
this.addressAllowToEdit = this.getWellSetAddressWithData();
|
|
2818
|
+
// configure undo redo action
|
|
3363
2819
|
this.actionPointer = 0;
|
|
3364
2820
|
this.undoRedoArray = [this.createState()];
|
|
3365
2821
|
this.emptyWellWithDefaultVal = emptyWellWithDefaultVal;
|
|
@@ -3367,127 +2823,100 @@ $.widget("DNA.plateMap", {
|
|
|
3367
2823
|
this.disableAddDeleteWell = false;
|
|
3368
2824
|
this.emptyWellWithDefaultVal = null;
|
|
3369
2825
|
}
|
|
3370
|
-
|
|
3371
2826
|
this.readOnlyHandler();
|
|
3372
2827
|
},
|
|
3373
|
-
selectObjectInBottomTab: function
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
var well = this.engine.derivative[index];
|
|
3380
|
-
|
|
2828
|
+
selectObjectInBottomTab: function () {
|
|
2829
|
+
let colors = [];
|
|
2830
|
+
let selectedIndices = this.selectedIndices;
|
|
2831
|
+
for (let i = 0; i < selectedIndices.length; i++) {
|
|
2832
|
+
let index = selectedIndices[i];
|
|
2833
|
+
let well = this.engine.derivative[index];
|
|
3381
2834
|
if (well) {
|
|
3382
|
-
|
|
3383
|
-
|
|
2835
|
+
let color = this.engine.colorMap.get(index);
|
|
3384
2836
|
if (colors.indexOf(color) < 0) {
|
|
3385
2837
|
colors.push(color);
|
|
3386
2838
|
}
|
|
3387
2839
|
}
|
|
3388
2840
|
}
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
for (var _i3 = 1; _i3 < trs.length; _i3++) {
|
|
2841
|
+
let trs = document.querySelectorAll('table.plate-setup-bottom-table tr');
|
|
2842
|
+
for (let i = 1; i < trs.length; i++) {
|
|
3393
2843
|
// start at 1 to skip the table headers
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
2844
|
+
let tr = trs[i];
|
|
2845
|
+
let td = tr.children[0];
|
|
2846
|
+
let isSelected = colors.indexOf(Number(td.querySelector('button').innerHTML)) >= 0;
|
|
3397
2847
|
tr.classList.toggle("selected", isSelected);
|
|
3398
2848
|
}
|
|
3399
2849
|
},
|
|
3400
|
-
getSelectedIndices: function
|
|
2850
|
+
getSelectedIndices: function () {
|
|
3401
2851
|
return this.selectedIndices.slice();
|
|
3402
2852
|
},
|
|
3403
|
-
getSelectedAddresses: function
|
|
2853
|
+
getSelectedAddresses: function () {
|
|
3404
2854
|
return this.selectedIndices.map(function (index) {
|
|
3405
2855
|
return this.allTiles[index].address;
|
|
3406
2856
|
}, this);
|
|
3407
2857
|
},
|
|
3408
|
-
setSelectedAddresses: function
|
|
3409
|
-
|
|
2858
|
+
setSelectedAddresses: function (addresses, noUndoRedo) {
|
|
2859
|
+
let indices = this.sanitizeAddresses(addresses);
|
|
3410
2860
|
this.setSelectedIndices(indices, noUndoRedo);
|
|
3411
2861
|
},
|
|
3412
|
-
setSelectedIndices: function
|
|
2862
|
+
setSelectedIndices: function (indices, noUndoRedo) {
|
|
3413
2863
|
if (!indices || indices.length === 0) {
|
|
3414
2864
|
indices = [0];
|
|
3415
|
-
}
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
2865
|
+
}
|
|
2866
|
+
// Indices should be sanitized
|
|
2867
|
+
this.setSelection(indices);
|
|
2868
|
+
//this._colorMixer();
|
|
3420
2869
|
this.decideSelectedFields();
|
|
3421
|
-
|
|
3422
2870
|
this._trigger("selectedWells", null, {
|
|
3423
2871
|
selectedAddress: this.getSelectedAddresses()
|
|
3424
2872
|
});
|
|
3425
|
-
|
|
3426
2873
|
this.selectObjectInBottomTab();
|
|
3427
|
-
|
|
3428
2874
|
if (!noUndoRedo) {
|
|
3429
2875
|
this.addToUndoRedo();
|
|
3430
2876
|
}
|
|
3431
2877
|
}
|
|
3432
2878
|
});
|
|
3433
2879
|
var plateMapWidget = plateMapWidget || {};
|
|
3434
|
-
|
|
3435
2880
|
(function ($) {
|
|
3436
2881
|
plateMapWidget.preset = function () {
|
|
3437
2882
|
// All the preset action goes here
|
|
3438
2883
|
return {
|
|
3439
2884
|
presets: [],
|
|
3440
|
-
_placePresetTabs: function
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
var presets = this.options.attributes.presets;
|
|
3444
|
-
|
|
2885
|
+
_placePresetTabs: function () {
|
|
2886
|
+
let presets = this.options.attributes.presets;
|
|
3445
2887
|
if (presets && presets.length) {
|
|
3446
2888
|
this.wellAttrContainer = this._createElement("<div></div>").addClass("plate-setup-well-attr-container").text("Checkbox presets");
|
|
3447
2889
|
this.tabContainer.append(this.wellAttrContainer);
|
|
3448
2890
|
this.presetTabContainer = this._createElement("<div></div>").addClass("plate-setup-preset-container");
|
|
3449
2891
|
this.tabContainer.append(this.presetTabContainer);
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
var presetButton = _this._createElement("<div></div>").addClass("plate-setup-preset-tab").data("preset", preset.fields).append(divText);
|
|
3457
|
-
|
|
3458
|
-
_this.presetTabContainer.append(presetButton);
|
|
3459
|
-
|
|
3460
|
-
var that = _this;
|
|
2892
|
+
for (let i = 0; i < presets.length; i++) {
|
|
2893
|
+
let preset = presets[i];
|
|
2894
|
+
let divText = this._createElement("<div></div>").addClass("plate-setup-preset-tab-div").text(preset.title);
|
|
2895
|
+
let presetButton = this._createElement("<div></div>").addClass("plate-setup-preset-tab").data("preset", preset.fields).append(divText);
|
|
2896
|
+
this.presetTabContainer.append(presetButton);
|
|
2897
|
+
let that = this;
|
|
3461
2898
|
presetButton.click(function () {
|
|
3462
|
-
|
|
3463
|
-
|
|
2899
|
+
let preset = $(this);
|
|
3464
2900
|
that._selectPreset(preset);
|
|
3465
2901
|
});
|
|
3466
|
-
|
|
3467
|
-
_this.presets.push(presetButton);
|
|
3468
|
-
};
|
|
3469
|
-
|
|
3470
|
-
for (var i = 0; i < presets.length; i++) {
|
|
3471
|
-
_loop6(i);
|
|
2902
|
+
this.presets.push(presetButton);
|
|
3472
2903
|
}
|
|
3473
2904
|
}
|
|
3474
2905
|
},
|
|
3475
|
-
_clearPresetSelection: function
|
|
3476
|
-
for (
|
|
3477
|
-
|
|
2906
|
+
_clearPresetSelection: function () {
|
|
2907
|
+
for (let j = 0; j < this.presets.length; j++) {
|
|
2908
|
+
let p = this.presets[j];
|
|
3478
2909
|
p.removeClass("plate-setup-preset-tab-selected").addClass("plate-setup-preset-tab");
|
|
3479
2910
|
}
|
|
3480
2911
|
},
|
|
3481
|
-
_selectPreset: function
|
|
2912
|
+
_selectPreset: function (preset) {
|
|
3482
2913
|
this.setCheckboxes(preset.data("preset"));
|
|
3483
2914
|
preset.removeClass("plate-setup-preset-tab").addClass("plate-setup-preset-tab-selected");
|
|
3484
2915
|
}
|
|
3485
2916
|
};
|
|
3486
2917
|
};
|
|
3487
2918
|
})(jQuery);
|
|
3488
|
-
|
|
3489
2919
|
var plateMapWidget = plateMapWidget || {};
|
|
3490
|
-
|
|
3491
2920
|
(function (SVG) {
|
|
3492
2921
|
plateMapWidget.svgCreate = function () {
|
|
3493
2922
|
//
|
|
@@ -3504,10 +2933,10 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
3504
2933
|
gap: 2
|
|
3505
2934
|
},
|
|
3506
2935
|
allTiles: [],
|
|
3507
|
-
_createSvg: function
|
|
2936
|
+
_createSvg: function () {
|
|
3508
2937
|
this.svg = new SVG(this.canvasContainer[0]);
|
|
3509
2938
|
this.svg.attr('preserveAspectRatio', 'xMidYMin meet');
|
|
3510
|
-
|
|
2939
|
+
let ls = this.baseSizes.label_spacing;
|
|
3511
2940
|
this.svg.viewbox(-ls, -ls, ls + this.dimensions.cols * this.baseSizes.spacing, ls + this.dimensions.rows * this.baseSizes.spacing);
|
|
3512
2941
|
this.wellShadow = this.svg.gradient('radial', function (stop) {
|
|
3513
2942
|
stop.at(0.8, 'rgba(0,0,0,0.1)');
|
|
@@ -3519,52 +2948,45 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
3519
2948
|
stop.at(1, pair[1]);
|
|
3520
2949
|
}).from(0, 0).to(0, 1).id('wellColor' + i.toString());
|
|
3521
2950
|
}, this);
|
|
3522
|
-
|
|
3523
2951
|
this._fixRowAndColumn();
|
|
3524
|
-
|
|
3525
2952
|
this._putCircles();
|
|
3526
|
-
|
|
3527
2953
|
this._svgEvents();
|
|
3528
2954
|
},
|
|
3529
|
-
_fixRowAndColumn: function
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
2955
|
+
_fixRowAndColumn: function () {
|
|
2956
|
+
let cols = this.dimensions.cols;
|
|
2957
|
+
let rows = this.dimensions.rows;
|
|
2958
|
+
let rh = this.svg.nested().attr({
|
|
3533
2959
|
'x': -this.baseSizes.label_spacing / 2.0
|
|
3534
2960
|
}).addClass('rowHead');
|
|
3535
|
-
|
|
2961
|
+
let ch = this.svg.nested().attr({
|
|
3536
2962
|
'y': -this.baseSizes.label_spacing / 2.0
|
|
3537
2963
|
}).addClass('colHead');
|
|
3538
|
-
|
|
3539
|
-
for (var i = 0; i < rows; i++) {
|
|
2964
|
+
for (let i = 0; i < rows; i++) {
|
|
3540
2965
|
rh.plain(this._rowKey(i)).attr({
|
|
3541
2966
|
y: this.baseSizes.spacing * (i + 0.5)
|
|
3542
2967
|
});
|
|
3543
2968
|
}
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
x: this.baseSizes.spacing * (_i4 + 0.5)
|
|
2969
|
+
for (let i = 0; i < cols; i++) {
|
|
2970
|
+
ch.plain(this._colKey(i)).attr({
|
|
2971
|
+
x: this.baseSizes.spacing * (i + 0.5)
|
|
3548
2972
|
});
|
|
3549
2973
|
}
|
|
3550
2974
|
},
|
|
3551
|
-
_putCircles: function
|
|
3552
|
-
|
|
3553
|
-
|
|
2975
|
+
_putCircles: function () {
|
|
2976
|
+
let cols = this.dimensions.cols;
|
|
2977
|
+
let rows = this.dimensions.rows;
|
|
3554
2978
|
this.allTiles = Array(cols * rows);
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
var tile = this._createTile(row, col);
|
|
3559
|
-
|
|
2979
|
+
for (let row = 0; row < rows; row++) {
|
|
2980
|
+
for (let col = 0; col < cols; col++) {
|
|
2981
|
+
let tile = this._createTile(row, col);
|
|
3560
2982
|
this.allTiles[tile.index] = tile;
|
|
3561
2983
|
}
|
|
3562
2984
|
}
|
|
3563
2985
|
},
|
|
3564
|
-
_createTile: function
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
2986
|
+
_createTile: function (r, c) {
|
|
2987
|
+
let g = this.svg.nested().move(this.baseSizes.spacing * c, this.baseSizes.spacing * r).addClass('tile');
|
|
2988
|
+
let m = this.baseSizes.spacing / 2.0;
|
|
2989
|
+
let d = {
|
|
3568
2990
|
"tile": g
|
|
3569
2991
|
};
|
|
3570
2992
|
d.r = r;
|
|
@@ -3573,7 +2995,7 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
3573
2995
|
d.address = this.locToAddress(d);
|
|
3574
2996
|
g.rect(this.baseSizes.spacing, this.baseSizes.spacing).addClass('highlight');
|
|
3575
2997
|
g.circle(this.baseSizes.tile_radius * 2).center(m, m).addClass('well').fill(this.wellShadow);
|
|
3576
|
-
|
|
2998
|
+
let tf = g.group().addClass('fill');
|
|
3577
2999
|
d["circle"] = tf.circle(this.baseSizes.tile_radius * 2).center(m, m).addClass('circle').fill(this.wellColors[0]);
|
|
3578
3000
|
tf.circle(this.baseSizes.center_radius_complete * 2).center(m, m).addClass('center');
|
|
3579
3001
|
tf.circle(this.baseSizes.center_radius_incomplete * 2).center(m, m).addClass('center_incomplete');
|
|
@@ -3583,58 +3005,51 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
3583
3005
|
}).addClass('label');
|
|
3584
3006
|
return d;
|
|
3585
3007
|
},
|
|
3586
|
-
setTileComplete: function
|
|
3008
|
+
setTileComplete: function (tile, complete) {
|
|
3587
3009
|
if (complete) {
|
|
3588
3010
|
tile.tile.removeClass('incomplete');
|
|
3589
3011
|
} else {
|
|
3590
3012
|
tile.tile.addClass('incomplete');
|
|
3591
3013
|
}
|
|
3592
3014
|
},
|
|
3593
|
-
setTileVisible: function
|
|
3015
|
+
setTileVisible: function (tile, visible) {
|
|
3594
3016
|
if (visible) {
|
|
3595
3017
|
tile.tile.removeClass('empty');
|
|
3596
3018
|
} else {
|
|
3597
3019
|
tile.tile.addClass('empty');
|
|
3598
3020
|
}
|
|
3599
3021
|
},
|
|
3600
|
-
setTileColor: function
|
|
3022
|
+
setTileColor: function (tile, color) {
|
|
3601
3023
|
this.setTileVisible(tile, true);
|
|
3602
3024
|
tile.colorIndex = parseInt(color);
|
|
3603
3025
|
tile.label.plain(String(tile.colorIndex));
|
|
3604
|
-
|
|
3605
3026
|
if (color > 0) {
|
|
3606
3027
|
color = (color - 1) % (this.wellColors.length - 1) + 1;
|
|
3607
3028
|
}
|
|
3608
|
-
|
|
3609
3029
|
tile.circle.fill(this.wellColors[color]);
|
|
3610
3030
|
}
|
|
3611
3031
|
};
|
|
3612
3032
|
};
|
|
3613
3033
|
})(SVG);
|
|
3614
|
-
|
|
3615
3034
|
var plateMapWidget = plateMapWidget || {};
|
|
3616
|
-
|
|
3617
3035
|
(function ($) {
|
|
3618
3036
|
plateMapWidget.svgEvents = function () {
|
|
3619
3037
|
// This object contains Menu items and how it works;
|
|
3620
3038
|
return {
|
|
3621
3039
|
colorToIndex: {},
|
|
3622
3040
|
selectedIndices: [],
|
|
3623
|
-
_svgEvents: function
|
|
3041
|
+
_svgEvents: function () {
|
|
3624
3042
|
// Set up event handling.
|
|
3625
|
-
|
|
3626
|
-
|
|
3043
|
+
let that = this;
|
|
3627
3044
|
function getMousePosition(evt) {
|
|
3628
|
-
|
|
3045
|
+
let CTM = that.svg.node.getScreenCTM();
|
|
3629
3046
|
return {
|
|
3630
3047
|
x: (evt.clientX - CTM.e) / CTM.a,
|
|
3631
3048
|
y: (evt.clientY - CTM.f) / CTM.d
|
|
3632
3049
|
};
|
|
3633
3050
|
}
|
|
3634
|
-
|
|
3635
3051
|
function dimCoord(v, max) {
|
|
3636
3052
|
max = max - 1;
|
|
3637
|
-
|
|
3638
3053
|
if (v < 0) {
|
|
3639
3054
|
return 0;
|
|
3640
3055
|
} else if (v >= max) {
|
|
@@ -3643,34 +3058,29 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
3643
3058
|
return Math.trunc(v);
|
|
3644
3059
|
}
|
|
3645
3060
|
}
|
|
3646
|
-
|
|
3647
3061
|
function posToLoc(pos) {
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3062
|
+
let s = that.baseSizes.spacing;
|
|
3063
|
+
let c = dimCoord(pos.x / s, that.dimensions.cols);
|
|
3064
|
+
let r = dimCoord(pos.y / s, that.dimensions.rows);
|
|
3651
3065
|
return {
|
|
3652
3066
|
r: r,
|
|
3653
3067
|
c: c
|
|
3654
3068
|
};
|
|
3655
3069
|
}
|
|
3656
|
-
|
|
3657
3070
|
function selectionBoxPosition(pos0, pos1) {
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3071
|
+
let d0 = posToLoc(pos0);
|
|
3072
|
+
let d1 = posToLoc(pos1);
|
|
3073
|
+
let s = that.baseSizes.spacing;
|
|
3074
|
+
let x0 = Math.min(d0.c, d1.c) * s;
|
|
3075
|
+
let y0 = Math.min(d0.r, d1.r) * s;
|
|
3664
3076
|
if (pos0.x < 0) {
|
|
3665
3077
|
d0.c = that.dimensions.cols - 1;
|
|
3666
3078
|
}
|
|
3667
|
-
|
|
3668
3079
|
if (pos0.y < 0) {
|
|
3669
3080
|
d0.r = that.dimensions.rows - 1;
|
|
3670
3081
|
}
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
var y1 = (Math.max(d0.r, d1.r) + 1) * s;
|
|
3082
|
+
let x1 = (Math.max(d0.c, d1.c) + 1) * s;
|
|
3083
|
+
let y1 = (Math.max(d0.r, d1.r) + 1) * s;
|
|
3674
3084
|
return {
|
|
3675
3085
|
x: x0,
|
|
3676
3086
|
y: y0,
|
|
@@ -3678,43 +3088,35 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
3678
3088
|
height: y1 - y0
|
|
3679
3089
|
};
|
|
3680
3090
|
}
|
|
3681
|
-
|
|
3682
3091
|
function selectTiles(pos0, pos1, secondary) {
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3092
|
+
let d0 = posToLoc(pos0);
|
|
3093
|
+
let d1 = posToLoc(pos1);
|
|
3094
|
+
let extending = true;
|
|
3687
3095
|
if (secondary) {
|
|
3688
3096
|
// if d0 is already selected, we are deselecting
|
|
3689
|
-
|
|
3097
|
+
let startIdx = that.locToIndex(d0);
|
|
3690
3098
|
extending = that.selectedIndices.indexOf(startIdx) < 0;
|
|
3691
3099
|
}
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
var r0 = Math.min(d0.r, d1.r);
|
|
3695
|
-
|
|
3100
|
+
let c0 = Math.min(d0.c, d1.c);
|
|
3101
|
+
let r0 = Math.min(d0.r, d1.r);
|
|
3696
3102
|
if (pos0.x < 0) {
|
|
3697
3103
|
d0.c = that.dimensions.cols - 1;
|
|
3698
3104
|
}
|
|
3699
|
-
|
|
3700
3105
|
if (pos0.y < 0) {
|
|
3701
3106
|
d0.r = that.dimensions.rows - 1;
|
|
3702
3107
|
}
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
for (var c = c0; c <= c1; c++) {
|
|
3710
|
-
var index = that.locToIndex({
|
|
3108
|
+
let c1 = Math.max(d0.c, d1.c);
|
|
3109
|
+
let r1 = Math.max(d0.r, d1.r);
|
|
3110
|
+
let indices = [];
|
|
3111
|
+
for (let r = r0; r <= r1; r++) {
|
|
3112
|
+
for (let c = c0; c <= c1; c++) {
|
|
3113
|
+
let index = that.locToIndex({
|
|
3711
3114
|
'r': r,
|
|
3712
3115
|
'c': c
|
|
3713
3116
|
});
|
|
3714
3117
|
indices.push(index);
|
|
3715
3118
|
}
|
|
3716
3119
|
}
|
|
3717
|
-
|
|
3718
3120
|
if (secondary) {
|
|
3719
3121
|
if (extending) {
|
|
3720
3122
|
that.selectedIndices.forEach(function (index) {
|
|
@@ -3723,46 +3125,39 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
3723
3125
|
}
|
|
3724
3126
|
});
|
|
3725
3127
|
} else {
|
|
3726
|
-
indices = that.selectedIndices.filter(
|
|
3727
|
-
return indices.indexOf(index) < 0;
|
|
3728
|
-
});
|
|
3128
|
+
indices = that.selectedIndices.filter(index => indices.indexOf(index) < 0);
|
|
3729
3129
|
}
|
|
3730
3130
|
}
|
|
3731
3131
|
|
|
3732
|
-
|
|
3132
|
+
// Numeric comparator: the default sort compares as strings (10 < 2)
|
|
3133
|
+
that.setSelectedIndices(indices.sort((a, b) => a - b));
|
|
3733
3134
|
}
|
|
3734
|
-
|
|
3735
|
-
var selectionBox;
|
|
3736
|
-
|
|
3135
|
+
let selectionBox;
|
|
3737
3136
|
function startDrag(evt) {
|
|
3738
3137
|
if (selectionBox) {
|
|
3739
3138
|
selectionBox.remove();
|
|
3740
3139
|
}
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
var attrs = selectionBoxPosition(pos, pos);
|
|
3140
|
+
let pos = getMousePosition(evt);
|
|
3141
|
+
let attrs = selectionBoxPosition(pos, pos);
|
|
3744
3142
|
selectionBox = that.svg.rect().attr(attrs).fill('rgba(0, 0, 1, 0.2)');
|
|
3745
3143
|
selectionBox.data('origin', pos);
|
|
3746
3144
|
}
|
|
3747
|
-
|
|
3748
3145
|
function drag(evt) {
|
|
3749
3146
|
if (selectionBox) {
|
|
3750
|
-
|
|
3751
|
-
|
|
3147
|
+
let pos = getMousePosition(evt);
|
|
3148
|
+
let attrs = selectionBoxPosition(selectionBox.data('origin'), pos);
|
|
3752
3149
|
selectionBox.attr(attrs);
|
|
3753
3150
|
}
|
|
3754
3151
|
}
|
|
3755
|
-
|
|
3756
3152
|
function endDrag(evt) {
|
|
3757
3153
|
if (selectionBox) {
|
|
3758
|
-
|
|
3759
|
-
|
|
3154
|
+
let startPos = selectionBox.data('origin');
|
|
3155
|
+
let pos = getMousePosition(evt);
|
|
3760
3156
|
selectTiles(startPos, pos, evt.shiftKey);
|
|
3761
3157
|
selectionBox.remove();
|
|
3762
3158
|
selectionBox = null;
|
|
3763
3159
|
}
|
|
3764
3160
|
}
|
|
3765
|
-
|
|
3766
3161
|
this.svg.node.addEventListener('mousedown', startDrag);
|
|
3767
3162
|
this.svg.node.addEventListener('mousemove', drag);
|
|
3768
3163
|
this.svg.node.addEventListener('mouseleave', endDrag);
|
|
@@ -3772,19 +3167,16 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
3772
3167
|
that.loadPlate(JSON.parse(data));
|
|
3773
3168
|
});
|
|
3774
3169
|
},
|
|
3775
|
-
setSelection: function
|
|
3170
|
+
setSelection: function (selectedIndices) {
|
|
3776
3171
|
this.selectedIndices = selectedIndices;
|
|
3777
|
-
|
|
3778
3172
|
this._setSelectedTiles();
|
|
3779
|
-
|
|
3780
3173
|
document.activeElement.blur();
|
|
3781
3174
|
},
|
|
3782
|
-
_setSelectedTiles: function
|
|
3175
|
+
_setSelectedTiles: function () {
|
|
3783
3176
|
// Update selected tile display only
|
|
3784
|
-
|
|
3177
|
+
let selectedIndices = this.selectedIndices;
|
|
3785
3178
|
this.allTiles.forEach(function (tile) {
|
|
3786
|
-
|
|
3787
|
-
|
|
3179
|
+
let selected = selectedIndices.indexOf(tile.index) >= 0;
|
|
3788
3180
|
if (selected) {
|
|
3789
3181
|
tile.tile.addClass('selected');
|
|
3790
3182
|
} else {
|
|
@@ -3792,27 +3184,24 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
3792
3184
|
}
|
|
3793
3185
|
});
|
|
3794
3186
|
},
|
|
3795
|
-
_getSelectedWells: function
|
|
3187
|
+
_getSelectedWells: function () {
|
|
3796
3188
|
return this.selectedIndices.map(function (index) {
|
|
3797
|
-
|
|
3798
|
-
|
|
3189
|
+
let well = this.engine.derivative[index];
|
|
3799
3190
|
if (!well) {
|
|
3800
3191
|
well = this.defaultWell;
|
|
3801
3192
|
}
|
|
3802
|
-
|
|
3803
3193
|
return well;
|
|
3804
3194
|
}, this);
|
|
3805
3195
|
},
|
|
3806
|
-
containsObject: function
|
|
3196
|
+
containsObject: function (obj, list) {
|
|
3807
3197
|
function deepEqual(x, y) {
|
|
3808
3198
|
if (x === y) {
|
|
3809
3199
|
return true;
|
|
3810
|
-
} else if (
|
|
3200
|
+
} else if (typeof x == "object" && x != null && typeof y == "object" && y != null) {
|
|
3811
3201
|
if (Object.keys(x).length !== Object.keys(y).length) {
|
|
3812
3202
|
return false;
|
|
3813
3203
|
}
|
|
3814
|
-
|
|
3815
|
-
for (var prop in x) {
|
|
3204
|
+
for (let prop in x) {
|
|
3816
3205
|
if (x.hasOwnProperty(prop)) {
|
|
3817
3206
|
if (y.hasOwnProperty(prop)) {
|
|
3818
3207
|
if (!deepEqual(x[prop], y[prop])) {
|
|
@@ -3823,69 +3212,61 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
3823
3212
|
}
|
|
3824
3213
|
}
|
|
3825
3214
|
}
|
|
3826
|
-
|
|
3827
3215
|
return true;
|
|
3828
3216
|
} else {
|
|
3829
3217
|
return false;
|
|
3830
3218
|
}
|
|
3831
3219
|
}
|
|
3832
|
-
|
|
3833
3220
|
if (list) {
|
|
3834
|
-
for (
|
|
3221
|
+
for (let i = 0; i < list.length; i++) {
|
|
3835
3222
|
if (deepEqual(obj, list[i])) {
|
|
3836
3223
|
return true;
|
|
3837
3224
|
}
|
|
3838
3225
|
}
|
|
3839
3226
|
}
|
|
3840
|
-
|
|
3841
3227
|
return false;
|
|
3842
3228
|
},
|
|
3843
|
-
_buildCommonData: function
|
|
3844
|
-
|
|
3845
|
-
|
|
3229
|
+
_buildCommonData: function (commonData, obj, field) {
|
|
3230
|
+
let commonVal = commonData[field];
|
|
3846
3231
|
if (commonVal === undefined) {
|
|
3847
3232
|
commonVal = null;
|
|
3848
3233
|
}
|
|
3849
|
-
|
|
3850
|
-
var objVal = obj[field];
|
|
3851
|
-
|
|
3234
|
+
let objVal = obj[field];
|
|
3852
3235
|
if (objVal === undefined) {
|
|
3853
3236
|
objVal = null;
|
|
3854
3237
|
}
|
|
3855
|
-
|
|
3856
3238
|
if (Array.isArray(commonVal)) {
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3239
|
+
let commonArr = [];
|
|
3240
|
+
if (!objVal) {
|
|
3241
|
+
commonData[field] = commonArr;
|
|
3242
|
+
return;
|
|
3243
|
+
}
|
|
3244
|
+
for (let i = 0; i < commonVal.length; i++) {
|
|
3245
|
+
let v = commonVal[i];
|
|
3246
|
+
// for multiplex field
|
|
3247
|
+
if (v && typeof v === "object") {
|
|
3248
|
+
for (let j = 0; j < objVal.length; j++) {
|
|
3249
|
+
let v2 = objVal[j];
|
|
3866
3250
|
if (v[field] == v2[field]) {
|
|
3867
3251
|
v = $.extend(true, {}, v);
|
|
3868
|
-
|
|
3869
|
-
for (var oField in v) {
|
|
3252
|
+
for (let oField in v) {
|
|
3870
3253
|
this._buildCommonData(v, v2, oField);
|
|
3871
3254
|
}
|
|
3872
|
-
|
|
3873
3255
|
commonArr.push(v);
|
|
3874
3256
|
}
|
|
3875
|
-
}
|
|
3257
|
+
}
|
|
3258
|
+
// if (this.containsObject(v, objVal)) {
|
|
3876
3259
|
// commonArr.push(v);
|
|
3877
3260
|
// }
|
|
3878
|
-
|
|
3879
3261
|
} else {
|
|
3880
3262
|
if ($.inArray(v, objVal) >= 0) {
|
|
3881
3263
|
commonArr.push(v);
|
|
3882
3264
|
}
|
|
3883
3265
|
}
|
|
3884
3266
|
}
|
|
3885
|
-
|
|
3886
3267
|
commonData[field] = commonArr;
|
|
3887
3268
|
} else {
|
|
3888
|
-
if (objVal &&
|
|
3269
|
+
if (objVal && typeof objVal === "object" && commonVal && typeof commonVal === "object") {
|
|
3889
3270
|
if (objVal.value !== commonVal.value || objVal.unit !== commonVal.unit) {
|
|
3890
3271
|
delete commonData[field];
|
|
3891
3272
|
}
|
|
@@ -3894,63 +3275,53 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
3894
3275
|
}
|
|
3895
3276
|
}
|
|
3896
3277
|
},
|
|
3897
|
-
_getCommonData: function
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
var well = wells[i];
|
|
3902
|
-
|
|
3278
|
+
_getCommonData: function (wells) {
|
|
3279
|
+
let commonData = null;
|
|
3280
|
+
for (let i = 0; i < wells.length; i++) {
|
|
3281
|
+
let well = wells[i];
|
|
3903
3282
|
if (well == null) {
|
|
3904
3283
|
continue;
|
|
3905
3284
|
}
|
|
3906
|
-
|
|
3907
3285
|
if (commonData == null) {
|
|
3908
3286
|
commonData = $.extend(true, {}, wells[0]);
|
|
3909
3287
|
continue;
|
|
3910
3288
|
}
|
|
3911
|
-
|
|
3912
|
-
for (var field in commonData) {
|
|
3289
|
+
for (let field in commonData) {
|
|
3913
3290
|
if (!commonData.hasOwnProperty(field)) {
|
|
3914
3291
|
continue;
|
|
3915
3292
|
}
|
|
3916
|
-
|
|
3917
3293
|
this._buildCommonData(commonData, well, field);
|
|
3918
3294
|
}
|
|
3919
3295
|
}
|
|
3920
|
-
|
|
3921
3296
|
return commonData || this.defaultWell;
|
|
3922
3297
|
},
|
|
3923
|
-
_getCommonWell: function
|
|
3924
|
-
|
|
3925
|
-
|
|
3298
|
+
_getCommonWell: function (wells) {
|
|
3299
|
+
let commonData = this._getCommonData(wells);
|
|
3926
3300
|
return this.sanitizeWell(commonData);
|
|
3927
3301
|
},
|
|
3928
|
-
_getAllMultipleVal: function
|
|
3929
|
-
|
|
3930
|
-
|
|
3302
|
+
_getAllMultipleVal: function (wells) {
|
|
3303
|
+
let multipleFieldList = this.multipleFieldList;
|
|
3304
|
+
let that = this;
|
|
3931
3305
|
multipleFieldList.forEach(function (multiplexField) {
|
|
3932
3306
|
if (wells.length) {
|
|
3933
|
-
|
|
3934
|
-
|
|
3307
|
+
let curMultipleVal = {};
|
|
3308
|
+
let multiData = null;
|
|
3935
3309
|
wells.forEach(function (well) {
|
|
3936
3310
|
if (well == null) {
|
|
3937
3311
|
return;
|
|
3938
3312
|
}
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
var wellFieldVals = well[id];
|
|
3942
|
-
|
|
3313
|
+
let id = multiplexField.id;
|
|
3314
|
+
let wellFieldVals = well[id];
|
|
3943
3315
|
if (wellFieldVals && wellFieldVals.length) {
|
|
3944
3316
|
wellFieldVals.forEach(function (multipleVal) {
|
|
3945
|
-
if (
|
|
3317
|
+
if (typeof multipleVal === 'object') {
|
|
3946
3318
|
if (multiData == null) {
|
|
3947
3319
|
multiData = $.extend(true, {}, multipleVal);
|
|
3948
3320
|
} else {
|
|
3949
|
-
for (
|
|
3321
|
+
for (let oField in multiData) {
|
|
3950
3322
|
that._buildCommonData(multiData, multipleVal, oField);
|
|
3951
3323
|
}
|
|
3952
3324
|
}
|
|
3953
|
-
|
|
3954
3325
|
if (multipleVal[id] in curMultipleVal) {
|
|
3955
3326
|
curMultipleVal[multipleVal[id]]++;
|
|
3956
3327
|
} else {
|
|
@@ -3974,28 +3345,23 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
3974
3345
|
}
|
|
3975
3346
|
});
|
|
3976
3347
|
},
|
|
3977
|
-
decideSelectedFields: function
|
|
3978
|
-
|
|
3979
|
-
|
|
3348
|
+
decideSelectedFields: function () {
|
|
3349
|
+
let wells = this._getSelectedWells();
|
|
3980
3350
|
this._getAllMultipleVal(wells);
|
|
3981
|
-
|
|
3982
3351
|
this.applyFieldWarning(wells);
|
|
3983
|
-
|
|
3984
|
-
var well = this._getCommonWell(wells);
|
|
3985
|
-
|
|
3352
|
+
let well = this._getCommonWell(wells);
|
|
3986
3353
|
this._addDataToTabFields(well);
|
|
3987
3354
|
},
|
|
3988
3355
|
// get all wells that have data
|
|
3989
|
-
getWellSetAddressWithData: function
|
|
3990
|
-
|
|
3991
|
-
|
|
3356
|
+
getWellSetAddressWithData: function () {
|
|
3357
|
+
// Numeric sort and arrow map, as in load-plate.js's sanitizeAddresses
|
|
3358
|
+
let indices = Object.keys(this.engine.derivative).map(Number).sort((a, b) => a - b);
|
|
3359
|
+
return indices.map(index => this.indexToAddress(index));
|
|
3992
3360
|
}
|
|
3993
3361
|
};
|
|
3994
3362
|
};
|
|
3995
3363
|
})(jQuery);
|
|
3996
|
-
|
|
3997
3364
|
var plateMapWidget = plateMapWidget || {};
|
|
3998
|
-
|
|
3999
3365
|
(function ($) {
|
|
4000
3366
|
plateMapWidget.tabs = function () {
|
|
4001
3367
|
// Tabs create and manage tabs at the right side of widget.
|
|
@@ -4006,19 +3372,20 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
4006
3372
|
// To hold all the tab contents. this contains all the tabs and its elements and elements
|
|
4007
3373
|
// Settings as a whole. its very useful, when we have units for a specific field.
|
|
4008
3374
|
// it goes like tabs-> individual field-> units and checkbox
|
|
4009
|
-
|
|
3375
|
+
|
|
3376
|
+
_createTabAtRight: function () {
|
|
4010
3377
|
this.tabContainer = this._createElement("<div></div>").addClass("plate-setup-tab-container");
|
|
4011
3378
|
$(this.topRight).append(this.tabContainer);
|
|
4012
3379
|
},
|
|
4013
|
-
_createTabs: function
|
|
3380
|
+
_createTabs: function () {
|
|
4014
3381
|
// this could be done using z-index. just imagine few cards stacked up.
|
|
4015
3382
|
// Check if options has tab data.
|
|
4016
3383
|
// Originally we will be pulling tab data from developer.
|
|
4017
3384
|
// Now we are building upon dummy data.
|
|
4018
3385
|
this.tabHead = this._createElement("<div></div>").addClass("plate-setup-tab-head");
|
|
4019
3386
|
$(this.tabContainer).append(this.tabHead);
|
|
4020
|
-
|
|
4021
|
-
|
|
3387
|
+
let tabData = this.options.attributes.tabs;
|
|
3388
|
+
let that = this;
|
|
4022
3389
|
tabData.forEach(function (tab, tabIndex) {
|
|
4023
3390
|
that.allTabs[tabIndex] = that._createElement("<div></div>").addClass("plate-setup-tab");
|
|
4024
3391
|
$(that.allTabs[tabIndex]).data("index", tabIndex).text(tab.name);
|
|
@@ -4029,27 +3396,23 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
4029
3396
|
});
|
|
4030
3397
|
this.tabDataContainer = this._createElement("<div></div>").addClass("plate-setup-tab-data-container");
|
|
4031
3398
|
$(this.tabContainer).append(this.tabDataContainer);
|
|
4032
|
-
|
|
4033
3399
|
this._addDataTabs(tabData);
|
|
4034
|
-
|
|
4035
3400
|
$(this.allTabs[0]).click();
|
|
4036
|
-
|
|
4037
3401
|
this._addTabData();
|
|
4038
3402
|
},
|
|
4039
|
-
_tabClickHandler: function
|
|
3403
|
+
_tabClickHandler: function (clickedTab) {
|
|
4040
3404
|
if (this.selectedTab) {
|
|
4041
3405
|
$(this.selectedTab).removeClass("plate-setup-tab-selected").addClass("plate-setup-tab");
|
|
4042
|
-
|
|
3406
|
+
let previouslyClickedTabIndex = $(this.selectedTab).data("index");
|
|
4043
3407
|
$(this.allDataTabs[previouslyClickedTabIndex]).css("z-index", 0);
|
|
4044
3408
|
this.readOnlyHandler();
|
|
4045
3409
|
}
|
|
4046
|
-
|
|
4047
3410
|
$(clickedTab).addClass("plate-setup-tab-selected");
|
|
4048
3411
|
this.selectedTab = clickedTab;
|
|
4049
|
-
|
|
3412
|
+
let clickedTabIndex = $(clickedTab).data("index");
|
|
4050
3413
|
$(this.allDataTabs[clickedTabIndex]).css("z-index", 1000);
|
|
4051
3414
|
},
|
|
4052
|
-
_addDataTabs: function
|
|
3415
|
+
_addDataTabs: function (tabs) {
|
|
4053
3416
|
this.allDataTabs = tabs.map(function () {
|
|
4054
3417
|
return this._createElement("<div></div>").addClass("plate-setup-data-div").css("z-index", 0);
|
|
4055
3418
|
}, this);
|
|
@@ -4058,30 +3421,25 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
4058
3421
|
};
|
|
4059
3422
|
};
|
|
4060
3423
|
})(jQuery);
|
|
4061
|
-
|
|
4062
3424
|
var plateMapWidget = plateMapWidget || {};
|
|
4063
|
-
|
|
4064
3425
|
(function ($) {
|
|
4065
3426
|
plateMapWidget.undoRedoManager = function () {
|
|
4066
3427
|
return {
|
|
4067
3428
|
undoRedoArray: [],
|
|
4068
3429
|
actionPointer: null,
|
|
4069
|
-
addToUndoRedo: function
|
|
4070
|
-
|
|
4071
|
-
|
|
3430
|
+
addToUndoRedo: function () {
|
|
3431
|
+
let state = this.createState();
|
|
4072
3432
|
if (this.actionPointer != null) {
|
|
4073
|
-
|
|
4074
|
-
|
|
3433
|
+
let i = this.actionPointer + 1;
|
|
4075
3434
|
if (i < this.undoRedoArray.length) {
|
|
4076
3435
|
this.undoRedoArray.splice(i, this.undoRedoArray.length - i);
|
|
4077
3436
|
}
|
|
4078
3437
|
}
|
|
4079
|
-
|
|
4080
3438
|
this.actionPointer = null;
|
|
4081
3439
|
this.undoRedoArray.push(state);
|
|
4082
3440
|
},
|
|
4083
|
-
_configureUndoRedoArray: function
|
|
4084
|
-
|
|
3441
|
+
_configureUndoRedoArray: function () {
|
|
3442
|
+
let data = {
|
|
4085
3443
|
checkboxes: [],
|
|
4086
3444
|
derivative: {},
|
|
4087
3445
|
selectedIndices: [0]
|
|
@@ -4090,37 +3448,33 @@ var plateMapWidget = plateMapWidget || {};
|
|
|
4090
3448
|
this.actionPointer = null;
|
|
4091
3449
|
this.undoRedoArray.push($.extend({}, data));
|
|
4092
3450
|
},
|
|
4093
|
-
clearHistory: function
|
|
3451
|
+
clearHistory: function () {
|
|
4094
3452
|
this.undoRedoArray = this.undoRedoArray.slice(-1);
|
|
4095
3453
|
this.actionPointer = null;
|
|
4096
3454
|
},
|
|
4097
|
-
undo: function
|
|
3455
|
+
undo: function () {
|
|
4098
3456
|
console.log("undo");
|
|
4099
3457
|
return this.shiftUndoRedo(-1);
|
|
4100
3458
|
},
|
|
4101
|
-
redo: function
|
|
3459
|
+
redo: function () {
|
|
4102
3460
|
console.log("redo");
|
|
4103
3461
|
return this.shiftUndoRedo(1);
|
|
4104
3462
|
},
|
|
4105
|
-
shiftUndoRedo: function
|
|
4106
|
-
|
|
4107
|
-
|
|
3463
|
+
shiftUndoRedo: function (pointerDiff) {
|
|
3464
|
+
let pointer = this.actionPointer;
|
|
4108
3465
|
if (pointer == null) {
|
|
4109
3466
|
pointer = this.undoRedoArray.length - 1;
|
|
4110
3467
|
}
|
|
4111
|
-
|
|
4112
3468
|
pointer += pointerDiff;
|
|
4113
3469
|
return this.setUndoRedo(pointer);
|
|
4114
3470
|
},
|
|
4115
|
-
setUndoRedo: function
|
|
3471
|
+
setUndoRedo: function (pointer) {
|
|
4116
3472
|
if (pointer < 0) {
|
|
4117
3473
|
return false;
|
|
4118
3474
|
}
|
|
4119
|
-
|
|
4120
3475
|
if (pointer >= this.undoRedoArray.length) {
|
|
4121
3476
|
return false;
|
|
4122
3477
|
}
|
|
4123
|
-
|
|
4124
3478
|
this.actionPointer = pointer;
|
|
4125
3479
|
this.setData(this.undoRedoArray[pointer], true);
|
|
4126
3480
|
return true;
|