solid-ui 2.4.22-b82de984 → 2.4.22-ba72be9b
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/README.md +23 -58
- package/dist/main.js +2102 -663
- package/dist/main.js.map +1 -1
- package/lib/chat/bookmarks.js +1 -2
- package/lib/chat/bookmarks.js.map +1 -1
- package/lib/iconBase.js +3 -2
- package/lib/iconBase.js.map +1 -1
- package/lib/login/login.d.ts +12 -8
- package/lib/login/login.d.ts.map +1 -1
- package/lib/login/login.js +260 -313
- package/lib/login/login.js.map +1 -1
- package/lib/style_multiSelect.js +67 -0
- package/lib/style_multiSelect.js.map +1 -0
- package/lib/tabs.d.ts +1 -1
- package/lib/tabs.d.ts.map +1 -1
- package/lib/tabs.js +34 -21
- package/lib/tabs.js.map +1 -1
- package/lib/utils/label.js +1 -1
- package/lib/utils/label.js.map +1 -1
- package/lib/versionInfo.js +6 -6
- package/lib/versionInfo.js.map +1 -1
- package/lib/widgets/buttons.d.ts.map +1 -1
- package/lib/widgets/buttons.js +2 -0
- package/lib/widgets/buttons.js.map +1 -1
- package/lib/widgets/error.d.ts +0 -12
- package/lib/widgets/error.d.ts.map +1 -1
- package/lib/widgets/error.js +5 -0
- package/lib/widgets/error.js.map +1 -1
- package/lib/widgets/forms.js +424 -182
- package/lib/widgets/forms.js.map +1 -1
- package/lib/widgets/multiSelect.js +784 -0
- package/lib/widgets/multiSelect.js.map +1 -0
- package/package.json +8 -6
package/lib/widgets/forms.js
CHANGED
|
@@ -22,6 +22,12 @@ Object.defineProperty(exports, "field", {
|
|
|
22
22
|
return _fieldFunction.field;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
+
Object.defineProperty(exports, "fieldFunction", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function get() {
|
|
28
|
+
return _fieldFunction.fieldFunction;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
25
31
|
Object.defineProperty(exports, "fieldLabel", {
|
|
26
32
|
enumerable: true,
|
|
27
33
|
get: function get() {
|
|
@@ -44,8 +50,15 @@ exports.findClosest = findClosest;
|
|
|
44
50
|
exports.formsFor = formsFor;
|
|
45
51
|
exports.makeDescription = makeDescription;
|
|
46
52
|
exports.makeSelectForCategory = makeSelectForCategory;
|
|
53
|
+
exports.makeSelectForChoice = makeSelectForChoice;
|
|
47
54
|
exports.makeSelectForNestedCategory = makeSelectForNestedCategory;
|
|
48
55
|
exports.makeSelectForOptions = makeSelectForOptions;
|
|
56
|
+
Object.defineProperty(exports, "mostSpecificClassURI", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function get() {
|
|
59
|
+
return _fieldFunction.mostSpecificClassURI;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
49
62
|
exports.newButton = newButton;
|
|
50
63
|
exports.newThing = newThing;
|
|
51
64
|
exports.promptForNew = promptForNew;
|
|
@@ -93,6 +106,8 @@ var _solidLogic = require("solid-logic");
|
|
|
93
106
|
|
|
94
107
|
var utils = _interopRequireWildcard(require("../utils"));
|
|
95
108
|
|
|
109
|
+
var _multiSelect = require("./multiSelect");
|
|
110
|
+
|
|
96
111
|
var widgets = _interopRequireWildcard(require("../widgets"));
|
|
97
112
|
|
|
98
113
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -155,14 +170,16 @@ _fieldFunction.field[ns.ui('Form').uri] = _fieldFunction.field[ns.ui('Group').ur
|
|
|
155
170
|
var ui = ns.ui;
|
|
156
171
|
if (container) container.appendChild(box); // Prevent loops
|
|
157
172
|
|
|
173
|
+
if (!form) return;
|
|
158
174
|
var key = subject.toNT() + '|' + form.toNT();
|
|
159
175
|
|
|
160
176
|
if (already[key]) {
|
|
161
177
|
// been there done that
|
|
162
|
-
box.appendChild(dom.createTextNode('Group: see above ' + key));
|
|
163
|
-
|
|
178
|
+
box.appendChild(dom.createTextNode('Group: see above ' + key)); // TODO fix dependency cycle to solid-panes by calling outlineManager
|
|
179
|
+
// const plist = [$rdf.st(subject, ns.owl('sameAs'), subject)] // @@ need prev subject
|
|
180
|
+
// dom.outlineManager.appendPropertyTRs(box, plist)
|
|
181
|
+
// dom.appendChild(plist)
|
|
164
182
|
|
|
165
|
-
dom.outlineManager.appendPropertyTRs(box, plist);
|
|
166
183
|
return box;
|
|
167
184
|
}
|
|
168
185
|
|
|
@@ -263,47 +280,43 @@ _fieldFunction.field[ns.ui('Options').uri] = function (dom, container, already,
|
|
|
263
280
|
values = kb.each(subject, dependingOn);
|
|
264
281
|
}
|
|
265
282
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
for (var i = 0; i < cases.length; i++) {
|
|
270
|
-
var c = cases[i];
|
|
271
|
-
var tests = kb.each(c, ui('for'), null, formDoc); // There can be multiple 'for'
|
|
283
|
+
for (var i = 0; i < cases.length; i++) {
|
|
284
|
+
var c = cases[i];
|
|
285
|
+
var tests = kb.each(c, ui('for'), null, formDoc); // There can be multiple 'for'
|
|
272
286
|
|
|
273
|
-
|
|
287
|
+
var match = false;
|
|
274
288
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
289
|
+
for (var j = 0; j < tests.length; j++) {
|
|
290
|
+
var _iterator = _createForOfIteratorHelper(values),
|
|
291
|
+
_step;
|
|
278
292
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
293
|
+
try {
|
|
294
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
295
|
+
var value = _step.value;
|
|
296
|
+
var test = tests[j];
|
|
283
297
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
298
|
+
if (value.sameTerm(tests) || value.termType === test.termType && value.value === test.value) {
|
|
299
|
+
match = true;
|
|
287
300
|
}
|
|
288
|
-
} catch (err) {
|
|
289
|
-
_iterator.e(err);
|
|
290
|
-
} finally {
|
|
291
|
-
_iterator.f();
|
|
292
301
|
}
|
|
302
|
+
} catch (err) {
|
|
303
|
+
_iterator.e(err);
|
|
304
|
+
} finally {
|
|
305
|
+
_iterator.f();
|
|
293
306
|
}
|
|
307
|
+
}
|
|
294
308
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
if (!_field3) {
|
|
299
|
-
box.appendChild((0, _error.errorMessageBlock)(dom, 'No "use" part for case in form ' + form));
|
|
300
|
-
return box;
|
|
301
|
-
} else {
|
|
302
|
-
appendForm(dom, box, already, subject, _field3, dataDoc, callbackFunction);
|
|
303
|
-
}
|
|
309
|
+
if (match) {
|
|
310
|
+
var _field3 = kb.the(c, ui('use'));
|
|
304
311
|
|
|
305
|
-
|
|
312
|
+
if (!_field3) {
|
|
313
|
+
box.appendChild((0, _error.errorMessageBlock)(dom, 'No "use" part for case in form ' + form));
|
|
314
|
+
return box;
|
|
315
|
+
} else {
|
|
316
|
+
appendForm(dom, box, already, subject, _field3, dataDoc, callbackFunction);
|
|
306
317
|
}
|
|
318
|
+
|
|
319
|
+
break;
|
|
307
320
|
}
|
|
308
321
|
} // @@ Add box.refresh() to sync fields with values
|
|
309
322
|
|
|
@@ -591,7 +604,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
591
604
|
// delete button and move buttons
|
|
592
605
|
|
|
593
606
|
if (kb.updater.editable(dataDoc.uri)) {
|
|
594
|
-
buttons.deleteButtonWithCheck(dom, subField,
|
|
607
|
+
buttons.deleteButtonWithCheck(dom, subField, multipleUIlabel, deleteThisItem);
|
|
595
608
|
|
|
596
609
|
if (ordered) {
|
|
597
610
|
// Add controsl in a frame
|
|
@@ -642,7 +655,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
642
655
|
|
|
643
656
|
var _shim = dom.createElement('div');
|
|
644
657
|
|
|
645
|
-
_shim.appendChild(subField); // Subfield has its own
|
|
658
|
+
_shim.appendChild(subField); // Subfield has its own layout
|
|
646
659
|
|
|
647
660
|
|
|
648
661
|
frame.appendChild(_shim);
|
|
@@ -691,6 +704,8 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
691
704
|
return shim;
|
|
692
705
|
}
|
|
693
706
|
|
|
707
|
+
var multipleUIlabel = kb.any(form, ui('label'));
|
|
708
|
+
if (!multipleUIlabel) multipleUIlabel = utils.label(property);
|
|
694
709
|
var min = kb.any(form, ui('min')); // This is the minimum number -- default 0
|
|
695
710
|
|
|
696
711
|
min = min ? 0 + min.value : 0;
|
|
@@ -731,10 +746,9 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
731
746
|
img.setAttribute('src', plusIconURI); // plus sign
|
|
732
747
|
|
|
733
748
|
img.setAttribute('style', 'margin: 0.2em; width: 1.5em; height:1.5em');
|
|
734
|
-
img.title = 'Click to add
|
|
735
|
-
var prompt =
|
|
736
|
-
prompt.textContent = (values.length === 0 ? 'Add
|
|
737
|
-
|
|
749
|
+
img.title = 'Click to add another ' + multipleUIlabel;
|
|
750
|
+
var prompt = dom.createElement('span');
|
|
751
|
+
prompt.textContent = (values.length === 0 ? 'Add another ' : 'Add ') + multipleUIlabel;
|
|
738
752
|
tail.addEventListener('click', /*#__PURE__*/function () {
|
|
739
753
|
var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(_eventNotUsed) {
|
|
740
754
|
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
@@ -756,6 +770,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
756
770
|
return _ref3.apply(this, arguments);
|
|
757
771
|
};
|
|
758
772
|
}(), true);
|
|
773
|
+
tail.appendChild(prompt);
|
|
759
774
|
}
|
|
760
775
|
|
|
761
776
|
function createListIfNecessary() {
|
|
@@ -1030,14 +1045,13 @@ _fieldFunction.field[ns.ui('Classifier').uri] = function (dom, container, alread
|
|
|
1030
1045
|
** -- radio buttons
|
|
1031
1046
|
** -- auto-complete typing
|
|
1032
1047
|
**
|
|
1033
|
-
**
|
|
1048
|
+
** TODO: according to ontology ui:choice can also have ns.ui('default') - this is not implemented yet
|
|
1034
1049
|
*/
|
|
1035
1050
|
|
|
1036
1051
|
|
|
1037
1052
|
_fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) {
|
|
1038
1053
|
var ui = ns.ui;
|
|
1039
1054
|
var kb = _solidLogic.store;
|
|
1040
|
-
var multiple = false;
|
|
1041
1055
|
var formDoc = form.doc ? form.doc() : null; // @@ if blank no way to know
|
|
1042
1056
|
|
|
1043
1057
|
var p;
|
|
@@ -1065,96 +1079,117 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
1065
1079
|
}
|
|
1066
1080
|
|
|
1067
1081
|
var subForm = kb.any(form, ui('use')); // Optional
|
|
1082
|
+
// const follow = kb.anyJS(form, ui('follow'), null, formDoc) // data doc moves to new subject?
|
|
1068
1083
|
|
|
1069
|
-
var follow = kb.anyJS(form, ui('follow'), null, formDoc); // data doc moves to new subject?
|
|
1070
|
-
|
|
1071
|
-
var possible = [];
|
|
1072
|
-
var possibleProperties;
|
|
1073
|
-
var firstSelectOptionText = '* Select from ' + utils.label(subject, true) + ' *';
|
|
1074
1084
|
var opts = {
|
|
1075
1085
|
form: form,
|
|
1076
1086
|
subForm: subForm,
|
|
1077
|
-
multiple: multiple,
|
|
1078
|
-
firstSelectOptionText: firstSelectOptionText,
|
|
1079
1087
|
disambiguate: false
|
|
1080
1088
|
};
|
|
1081
|
-
possible = kb.each(undefined, ns.rdf('type'), uiFrom, formDoc);
|
|
1082
1089
|
|
|
1083
|
-
|
|
1084
|
-
possible
|
|
1085
|
-
|
|
1090
|
+
function getSelectorOptions() {
|
|
1091
|
+
var possible = [];
|
|
1092
|
+
var possibleProperties;
|
|
1093
|
+
possible = kb.each(undefined, ns.rdf('type'), uiFrom, formDoc);
|
|
1086
1094
|
|
|
1095
|
+
for (var x in kb.findMembersNT(uiFrom)) {
|
|
1096
|
+
possible.push(kb.fromNT(x));
|
|
1097
|
+
} // Use rdfs
|
|
1087
1098
|
|
|
1088
|
-
if (uiFrom.sameTerm(ns.rdfs('Class'))) {
|
|
1089
|
-
for (p in buttons.allClassURIs()) {
|
|
1090
|
-
possible.push(kb.sym(p));
|
|
1091
|
-
} // log.debug("%%% Choice field: possible.length 2 = "+possible.length)
|
|
1092
1099
|
|
|
1093
|
-
|
|
1094
|
-
|
|
1100
|
+
if (uiFrom.sameTerm(ns.rdfs('Class'))) {
|
|
1101
|
+
for (p in buttons.allClassURIs()) {
|
|
1102
|
+
possible.push(kb.sym(p));
|
|
1103
|
+
} // log.debug("%%% Choice field: possible.length 2 = "+possible.length)
|
|
1095
1104
|
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
}
|
|
1105
|
+
} else if (uiFrom.sameTerm(ns.rdf('Property'))) {
|
|
1106
|
+
possibleProperties = buttons.propertyTriage(kb);
|
|
1099
1107
|
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1108
|
+
for (p in possibleProperties.op) {
|
|
1109
|
+
possible.push(kb.fromNT(p));
|
|
1110
|
+
}
|
|
1103
1111
|
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1112
|
+
for (p in possibleProperties.dp) {
|
|
1113
|
+
possible.push(kb.fromNT(p));
|
|
1114
|
+
}
|
|
1107
1115
|
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1116
|
+
opts.disambiguate = true; // This is a big class, and the labels won't be enough.
|
|
1117
|
+
} else if (uiFrom.sameTerm(ns.owl('ObjectProperty'))) {
|
|
1118
|
+
possibleProperties = buttons.propertyTriage(kb);
|
|
1111
1119
|
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1120
|
+
for (p in possibleProperties.op) {
|
|
1121
|
+
possible.push(kb.fromNT(p));
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
opts.disambiguate = true;
|
|
1125
|
+
} else if (uiFrom.sameTerm(ns.owl('DatatypeProperty'))) {
|
|
1126
|
+
possibleProperties = buttons.propertyTriage(kb);
|
|
1127
|
+
|
|
1128
|
+
for (p in possibleProperties.dp) {
|
|
1129
|
+
possible.push(kb.fromNT(p));
|
|
1130
|
+
}
|
|
1115
1131
|
|
|
1116
|
-
|
|
1117
|
-
possible.push(kb.fromNT(p));
|
|
1132
|
+
opts.disambiguate = true;
|
|
1118
1133
|
}
|
|
1119
1134
|
|
|
1120
|
-
|
|
1121
|
-
}
|
|
1135
|
+
return possible; // return sortByLabel(possible)
|
|
1136
|
+
} // TODO: this checks for any occurrence, regardless of true or false setting
|
|
1122
1137
|
|
|
1123
|
-
var sortedPossible = sortByLabel(possible); // TODO: this checks for any occurrence, regardless of true or false setting
|
|
1124
1138
|
|
|
1125
1139
|
if (kb.any(form, ui('canMintNew'))) {
|
|
1126
1140
|
opts.mint = '* Create new *'; // @@ could be better
|
|
1127
1141
|
}
|
|
1128
1142
|
|
|
1129
|
-
var
|
|
1130
|
-
|
|
1131
|
-
var
|
|
1143
|
+
var multiSelect = kb.any(form, ui('multiselect')); // Optional
|
|
1144
|
+
|
|
1145
|
+
var selector;
|
|
1146
|
+
|
|
1147
|
+
rhs.refresh = function () {
|
|
1148
|
+
// from ui:property
|
|
1149
|
+
var selectedOptions = kb.each(subject, property, null, dataDoc).map(function (object) {
|
|
1150
|
+
return object.value;
|
|
1151
|
+
}); // from ui:from + ui:property
|
|
1152
|
+
|
|
1153
|
+
var possibleOptions = getSelectorOptions();
|
|
1154
|
+
possibleOptions.push(selectedOptions);
|
|
1155
|
+
possibleOptions = sortByLabel(possibleOptions);
|
|
1156
|
+
selector = makeSelectForChoice(dom, rhs, kb, subject, property, possibleOptions, selectedOptions, uiFrom, opts, dataDoc, callbackFunction);
|
|
1157
|
+
rhs.innerHTML = '';
|
|
1158
|
+
rhs.appendChild(selector);
|
|
1159
|
+
|
|
1160
|
+
if (multiSelect) {
|
|
1161
|
+
var multiSelectDiv = new _multiSelect.IconicMultiSelect({
|
|
1162
|
+
placeholder: selector.selected,
|
|
1163
|
+
select: selector,
|
|
1164
|
+
container: rhs,
|
|
1165
|
+
textField: 'textField',
|
|
1166
|
+
valueField: 'valueField'
|
|
1167
|
+
});
|
|
1168
|
+
multiSelectDiv.init();
|
|
1169
|
+
multiSelectDiv.subscribe(function (event) {
|
|
1170
|
+
if (event.action === 'REMOVE_OPTION') {
|
|
1171
|
+
selectedOptions = selectedOptions.filter(function (value) {
|
|
1172
|
+
return value !== event.value;
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
if (event.action === 'CLEAR_ALL_OPTIONS') {
|
|
1177
|
+
selectedOptions = [];
|
|
1178
|
+
}
|
|
1132
1179
|
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
object = kb.any(subject, property);
|
|
1137
|
-
}
|
|
1180
|
+
if (event.action === 'ADD_OPTION') {
|
|
1181
|
+
selectedOptions.push(event.value);
|
|
1182
|
+
}
|
|
1138
1183
|
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
}
|
|
1184
|
+
selector.update(selectedOptions);
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
1187
|
+
};
|
|
1143
1188
|
|
|
1189
|
+
rhs.refresh();
|
|
1190
|
+
if (selector && selector.refresh) selector.refresh();
|
|
1144
1191
|
return box;
|
|
1145
1192
|
};
|
|
1146
|
-
/**
|
|
1147
|
-
* Removes all sibling elements after specified
|
|
1148
|
-
* @param {HTMLElement} currentElement
|
|
1149
|
-
* @private
|
|
1150
|
-
*/
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
function removeNextSiblingsAfterElement(currentElement) {
|
|
1154
|
-
while (currentElement.nextElementSibling) {
|
|
1155
|
-
currentElement.nextElementSibling.remove();
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
1193
|
|
|
1159
1194
|
function addSubFormChoice(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction) {
|
|
1160
1195
|
(0, _fieldFunction.fieldFunction)(dom, subForm)(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction);
|
|
@@ -1361,7 +1396,8 @@ function promptForNew(dom, kb, subject, predicate, theClass, form, dataDoc, call
|
|
|
1361
1396
|
b.setAttribute('type', 'button');
|
|
1362
1397
|
b.setAttribute('style', 'float: right;');
|
|
1363
1398
|
b.innerHTML = 'Goto ' + utils.label(theClass);
|
|
1364
|
-
b.addEventListener('click',
|
|
1399
|
+
b.addEventListener('click', // TODO fix dependency cycle to solid-panes by calling outlineManager
|
|
1400
|
+
function (_e) {
|
|
1365
1401
|
dom.outlineManager.GotoSubject(theClass, true, undefined, true, undefined);
|
|
1366
1402
|
}, false);
|
|
1367
1403
|
return box;
|
|
@@ -1496,17 +1532,15 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
|
|
|
1496
1532
|
// @param subject - a term, the subject of the statement(s) being edited.
|
|
1497
1533
|
// @param predicate - a term, the predicate of the statement(s) being edited
|
|
1498
1534
|
// @param possible - a list of terms, the possible value the object can take
|
|
1499
|
-
// @param options.
|
|
1500
|
-
// @param options.firstSelectOptionText - a string to be displayed as the
|
|
1535
|
+
// @param options.nullLabel - a string to be displayed as the
|
|
1501
1536
|
// option for none selected (for non multiple)
|
|
1502
|
-
// @param options.mint - User may create thing if this sent to the prompt string eg "New foo"
|
|
1503
1537
|
// @param options.subForm - If mint, then the form to be used for minting the new thing
|
|
1504
1538
|
// @param dataDoc - The web document being edited
|
|
1505
1539
|
// @param callbackFunction - takes (boolean ok, string errorBody)
|
|
1506
1540
|
*/
|
|
1507
1541
|
|
|
1508
1542
|
|
|
1509
|
-
function makeSelectForOptions(dom, kb, subject, predicate, possible,
|
|
1543
|
+
function makeSelectForOptions(dom, kb, subject, predicate, possible, options, dataDoc, callbackFunction) {
|
|
1510
1544
|
log.debug('Select list length now ' + possible.length);
|
|
1511
1545
|
var n = 0;
|
|
1512
1546
|
var uris = {}; // Count them
|
|
@@ -1523,7 +1557,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
1523
1557
|
} // uris is now the set of possible options
|
|
1524
1558
|
|
|
1525
1559
|
|
|
1526
|
-
if (n === 0
|
|
1560
|
+
if (n === 0) {
|
|
1527
1561
|
return (0, _error.errorMessageBlock)(dom, "Can't do selector with no options, subject= " + subject + ' property = ' + predicate + '.');
|
|
1528
1562
|
}
|
|
1529
1563
|
|
|
@@ -1549,6 +1583,8 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
1549
1583
|
actual = getActual();
|
|
1550
1584
|
|
|
1551
1585
|
var onChange = function onChange(_e) {
|
|
1586
|
+
select.disabled = true; // until data written back - gives user feedback too
|
|
1587
|
+
|
|
1552
1588
|
var ds = [];
|
|
1553
1589
|
var is = [];
|
|
1554
1590
|
|
|
@@ -1558,43 +1594,18 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
1558
1594
|
}
|
|
1559
1595
|
};
|
|
1560
1596
|
|
|
1561
|
-
var newObject;
|
|
1562
|
-
|
|
1563
1597
|
for (var _i = 0; _i < select.options.length; _i++) {
|
|
1564
1598
|
var opt = select.options[_i];
|
|
1565
|
-
|
|
1566
|
-
if (opt.selected && opt.AJAR_mint) {
|
|
1567
|
-
// not sure if this 'if' is used because I cannot find mintClass
|
|
1568
|
-
if (options.mintClass) {
|
|
1569
|
-
var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
|
|
1570
|
-
if (!ok) {
|
|
1571
|
-
callbackFunction(ok, body, {
|
|
1572
|
-
change: 'new'
|
|
1573
|
-
}); // @@ if ok, need some form of refresh of the select for the new thing
|
|
1574
|
-
}
|
|
1575
|
-
});
|
|
1576
|
-
select.parentNode.appendChild(thisForm);
|
|
1577
|
-
newObject = thisForm.AJAR_subject;
|
|
1578
|
-
} else {
|
|
1579
|
-
newObject = newThing(dataDoc);
|
|
1580
|
-
}
|
|
1581
|
-
|
|
1582
|
-
is.push($rdf.st(subject, predicate, kb.sym(newObject), dataDoc));
|
|
1583
|
-
if (uiFrom) is.push($rdf.st(newObject, ns.rdf('type'), kb.sym(uiFrom), dataDoc)); // not sure if this 'if' is used because I cannot find mintStatementsFun
|
|
1584
|
-
|
|
1585
|
-
if (options.mintStatementsFun) {
|
|
1586
|
-
is = is.concat(options.mintStatementsFun(newObject));
|
|
1587
|
-
}
|
|
1588
|
-
|
|
1589
|
-
select.currentURI = newObject;
|
|
1590
|
-
}
|
|
1591
|
-
|
|
1592
1599
|
if (!opt.AJAR_uri) continue; // a prompt or mint
|
|
1593
1600
|
|
|
1594
1601
|
if (opt.selected && !(opt.AJAR_uri in actual)) {
|
|
1595
1602
|
// new class
|
|
1596
1603
|
is.push($rdf.st(subject, predicate, kb.sym(opt.AJAR_uri), dataDoc));
|
|
1597
|
-
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
if (!opt.selected && opt.AJAR_uri in actual) {
|
|
1607
|
+
// old class
|
|
1608
|
+
removeValue(kb.sym(opt.AJAR_uri));
|
|
1598
1609
|
}
|
|
1599
1610
|
|
|
1600
1611
|
if (opt.selected) select.currentURI = opt.AJAR_uri;
|
|
@@ -1614,29 +1625,25 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
1614
1625
|
sel = sel.superSelect;
|
|
1615
1626
|
}
|
|
1616
1627
|
|
|
1617
|
-
log.info('selectForOptions: data doc = ' + dataDoc);
|
|
1628
|
+
log.info('selectForOptions: data doc = ' + dataDoc);
|
|
1629
|
+
kb.updater.update(ds, is, function (uri, ok, body) {
|
|
1630
|
+
actual = getActual(); // refresh
|
|
1618
1631
|
|
|
1619
|
-
removeNextSiblingsAfterElement(select);
|
|
1620
|
-
addSubFormChoice(dom, select.parentNode, {}, $rdf.sym(select.currentURI), options.subForm, dataDoc, function (ok, body) {
|
|
1621
1632
|
if (ok) {
|
|
1622
|
-
|
|
1623
|
-
actual = getActual(); // refresh
|
|
1624
|
-
|
|
1625
|
-
if (!success) select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating select: ' + errorBody));
|
|
1626
|
-
});
|
|
1627
|
-
if (callbackFunction) callbackFunction(ok, {
|
|
1628
|
-
widget: 'select',
|
|
1629
|
-
event: 'new'
|
|
1630
|
-
});
|
|
1633
|
+
select.disabled = false; // data written back
|
|
1631
1634
|
} else {
|
|
1632
|
-
select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in
|
|
1635
|
+
return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in select: ' + body));
|
|
1633
1636
|
}
|
|
1637
|
+
|
|
1638
|
+
if (callbackFunction) callbackFunction(ok, {
|
|
1639
|
+
widget: 'select',
|
|
1640
|
+
event: 'change'
|
|
1641
|
+
});
|
|
1634
1642
|
});
|
|
1635
1643
|
};
|
|
1636
1644
|
|
|
1637
1645
|
var select = dom.createElement('select');
|
|
1638
1646
|
select.setAttribute('style', style.formSelectSTyle);
|
|
1639
|
-
if (options.multiple) select.setAttribute('multiple', 'true');
|
|
1640
1647
|
select.currentURI = null;
|
|
1641
1648
|
|
|
1642
1649
|
select.refresh = function () {
|
|
@@ -1679,22 +1686,11 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
1679
1686
|
select.appendChild(option);
|
|
1680
1687
|
}
|
|
1681
1688
|
|
|
1682
|
-
if (
|
|
1683
|
-
var mint = dom.createElement('option');
|
|
1684
|
-
mint.appendChild(dom.createTextNode(options.mint));
|
|
1685
|
-
mint.AJAR_mint = true; // Flag it
|
|
1686
|
-
|
|
1687
|
-
select.insertBefore(mint, select.firstChild);
|
|
1688
|
-
}
|
|
1689
|
-
|
|
1690
|
-
if (!select.currentURI && !options.multiple) {
|
|
1689
|
+
if (!select.currentURI) {
|
|
1691
1690
|
var prompt = dom.createElement('option');
|
|
1692
|
-
prompt.appendChild(dom.createTextNode(options.
|
|
1693
|
-
prompt.disabled = true;
|
|
1694
|
-
prompt.value = true;
|
|
1695
|
-
prompt.hidden = true;
|
|
1696
|
-
prompt.selected = true;
|
|
1691
|
+
prompt.appendChild(dom.createTextNode(options.nullLabel));
|
|
1697
1692
|
select.insertBefore(prompt, select.firstChild);
|
|
1693
|
+
prompt.selected = true;
|
|
1698
1694
|
}
|
|
1699
1695
|
|
|
1700
1696
|
if (editable) {
|
|
@@ -1713,27 +1709,16 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
1713
1709
|
function makeSelectForCategory(dom, kb, subject, category, dataDoc, callbackFunction) {
|
|
1714
1710
|
var du = kb.any(category, ns.owl('disjointUnionOf'));
|
|
1715
1711
|
var subs;
|
|
1716
|
-
var multiple = false;
|
|
1717
1712
|
|
|
1718
1713
|
if (!du) {
|
|
1719
1714
|
subs = kb.each(undefined, ns.rdfs('subClassOf'), category);
|
|
1720
|
-
multiple = true;
|
|
1721
1715
|
} else {
|
|
1722
1716
|
subs = du.elements;
|
|
1723
1717
|
}
|
|
1724
1718
|
|
|
1725
1719
|
log.debug('Select list length ' + subs.length);
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with no subclasses of category: ' + category);
|
|
1729
|
-
}
|
|
1730
|
-
|
|
1731
|
-
if (subs.length === 1) {
|
|
1732
|
-
return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with only 1 subclass of category: ' + category + ':' + subs[1]);
|
|
1733
|
-
}
|
|
1734
|
-
|
|
1735
|
-
return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, null, {
|
|
1736
|
-
multiple: multiple
|
|
1720
|
+
return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, {
|
|
1721
|
+
nullLabel: '* Select type *'
|
|
1737
1722
|
}, dataDoc, callbackFunction);
|
|
1738
1723
|
}
|
|
1739
1724
|
/** Make SELECT element to select subclasses recurively
|
|
@@ -1767,8 +1752,7 @@ function makeSelectForNestedCategory(dom, kb, subject, category, dataDoc, callba
|
|
|
1767
1752
|
function onChange(ok, body) {
|
|
1768
1753
|
if (ok) update();
|
|
1769
1754
|
callbackFunction(ok, body);
|
|
1770
|
-
}
|
|
1771
|
-
|
|
1755
|
+
}
|
|
1772
1756
|
|
|
1773
1757
|
var select = makeSelectForCategory(dom, kb, subject, category, dataDoc, onChange);
|
|
1774
1758
|
container.appendChild(select);
|
|
@@ -1923,4 +1907,262 @@ function newThing(doc) {
|
|
|
1923
1907
|
var now = new Date();
|
|
1924
1908
|
return $rdf.sym(doc.uri + '#' + 'id' + ('' + now.getTime()));
|
|
1925
1909
|
}
|
|
1910
|
+
/** Make SELECT element to select options
|
|
1911
|
+
//
|
|
1912
|
+
// @param subject - a term, the subject of the statement(s) being edited.
|
|
1913
|
+
// @param predicate - a term, the predicate of the statement(s) being edited
|
|
1914
|
+
// @param possible - a list of terms, the possible value the object can take
|
|
1915
|
+
// @param options.mint - User may create thing if this sent to the prompt string eg "New foo"
|
|
1916
|
+
// @param options.subForm - If mint, then the form to be used for minting the new thing
|
|
1917
|
+
// @param dataDoc - The web document being edited
|
|
1918
|
+
// @param callbackFunction - takes (boolean ok, string errorBody)
|
|
1919
|
+
*/
|
|
1920
|
+
|
|
1921
|
+
|
|
1922
|
+
function makeSelectForChoice(dom, container, kb, subject, predicate, inputPossibleOptions, selectedOptions, uiFrom, options, dataDoc, callbackFunction) {
|
|
1923
|
+
var optionsFromClassUIfrom = {}; // Count them
|
|
1924
|
+
|
|
1925
|
+
var editable = kb.updater.editable(dataDoc.uri);
|
|
1926
|
+
|
|
1927
|
+
for (var i = 0; i < inputPossibleOptions.length; i++) {
|
|
1928
|
+
var sub = inputPossibleOptions[i]; // @@ Maybe; make this so it works with blank nodes too
|
|
1929
|
+
// if (!sub.uri) debug.warn(`makeSelectForChoice: option does not have an uri: ${sub}, with predicate: ${predicate}`)
|
|
1930
|
+
|
|
1931
|
+
if (!sub.uri || sub.uri in optionsFromClassUIfrom) continue;
|
|
1932
|
+
optionsFromClassUIfrom[sub.uri] = true;
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1935
|
+
var isEmpty = Object.keys(optionsFromClassUIfrom).length === 0;
|
|
1936
|
+
|
|
1937
|
+
if (isEmpty && !options.mint) {
|
|
1938
|
+
return (0, _error.errorMessageBlock)(dom, "Can't do selector with no options, subject= " + subject + ' property = ' + predicate + '.');
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
log.debug('makeSelectForChoice: dataDoc=' + dataDoc);
|
|
1942
|
+
|
|
1943
|
+
function createDefaultSelectOptionText() {
|
|
1944
|
+
var firstSelectOptionText = '--- choice ---';
|
|
1945
|
+
|
|
1946
|
+
if (predicate && !(predicate.termType === 'BlankNode')) {
|
|
1947
|
+
firstSelectOptionText = '* Select for property: ' + utils.label(predicate) + ' *';
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
if (subject && !(subject.termType === 'BlankNode')) {
|
|
1951
|
+
firstSelectOptionText = '* Select for ' + utils.label(subject, true) + ' *';
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
return firstSelectOptionText;
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
function createDefaultSelectOption() {
|
|
1958
|
+
var option = dom.createElement('option');
|
|
1959
|
+
option.appendChild(dom.createTextNode(createDefaultSelectOptionText()));
|
|
1960
|
+
option.disabled = true;
|
|
1961
|
+
option.value = true;
|
|
1962
|
+
option.hidden = true;
|
|
1963
|
+
option.selected = true;
|
|
1964
|
+
return option;
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
var onChange = function onChange(_e) {
|
|
1968
|
+
container.removeChild(container.lastChild);
|
|
1969
|
+
select.refresh();
|
|
1970
|
+
};
|
|
1971
|
+
|
|
1972
|
+
var select = dom.createElement('select');
|
|
1973
|
+
select.setAttribute('style', style.formSelectSTyle);
|
|
1974
|
+
select.setAttribute('id', 'formSelect');
|
|
1975
|
+
select.currentURI = null;
|
|
1976
|
+
|
|
1977
|
+
for (var uri in optionsFromClassUIfrom) {
|
|
1978
|
+
select.appendChild(createOption(uri));
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
if (editable && options.mint) {
|
|
1982
|
+
var mint = dom.createElement('option');
|
|
1983
|
+
mint.appendChild(dom.createTextNode(options.mint));
|
|
1984
|
+
mint.AJAR_mint = true; // Flag it
|
|
1985
|
+
|
|
1986
|
+
select.insertBefore(mint, select.firstChild);
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
if (select.children.length === 0) select.insertBefore(createDefaultSelectOption(), select.firstChild);
|
|
1990
|
+
|
|
1991
|
+
select.update = function (newSelectedOptions) {
|
|
1992
|
+
selectedOptions = newSelectedOptions;
|
|
1993
|
+
var ds = [];
|
|
1994
|
+
var is = [];
|
|
1995
|
+
|
|
1996
|
+
var removeValue = function removeValue(t) {
|
|
1997
|
+
if (kb.holds(subject, predicate, t, dataDoc)) {
|
|
1998
|
+
ds.push($rdf.st(subject, predicate, t, dataDoc));
|
|
1999
|
+
}
|
|
2000
|
+
};
|
|
2001
|
+
|
|
2002
|
+
var addValue = function addValue(t) {
|
|
2003
|
+
if (!kb.holds(subject, predicate, t, dataDoc)) {
|
|
2004
|
+
is.push($rdf.st(subject, predicate, t, dataDoc)); // console.log("----value added " + t)
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
if (uiFrom && !kb.holds(t, ns.rdf('type'), kb.sym(uiFrom), dataDoc)) {
|
|
2008
|
+
is.push($rdf.st(t, ns.rdf('type'), kb.sym(uiFrom), dataDoc)); // console.log("----added type to value " + uiFrom)
|
|
2009
|
+
}
|
|
2010
|
+
};
|
|
2011
|
+
|
|
2012
|
+
var existingValues = kb.each(subject, predicate, null, dataDoc).map(function (object) {
|
|
2013
|
+
return object.value;
|
|
2014
|
+
});
|
|
2015
|
+
|
|
2016
|
+
var _iterator2 = _createForOfIteratorHelper(existingValues),
|
|
2017
|
+
_step2;
|
|
2018
|
+
|
|
2019
|
+
try {
|
|
2020
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2021
|
+
var value = _step2.value;
|
|
2022
|
+
if (!containsObject(value, selectedOptions)) removeValue($rdf.sym(value));
|
|
2023
|
+
}
|
|
2024
|
+
} catch (err) {
|
|
2025
|
+
_iterator2.e(err);
|
|
2026
|
+
} finally {
|
|
2027
|
+
_iterator2.f();
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
var _iterator3 = _createForOfIteratorHelper(selectedOptions),
|
|
2031
|
+
_step3;
|
|
2032
|
+
|
|
2033
|
+
try {
|
|
2034
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
2035
|
+
var _value = _step3.value;
|
|
2036
|
+
if (!(_value in existingValues)) addValue($rdf.sym(_value));
|
|
2037
|
+
}
|
|
2038
|
+
} catch (err) {
|
|
2039
|
+
_iterator3.e(err);
|
|
2040
|
+
} finally {
|
|
2041
|
+
_iterator3.f();
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
kb.updater.update(ds, is, function (uri, ok, body) {
|
|
2045
|
+
if (!ok) return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in select: ' + body));
|
|
2046
|
+
select.refresh();
|
|
2047
|
+
if (callbackFunction) callbackFunction(ok, {
|
|
2048
|
+
widget: 'select',
|
|
2049
|
+
event: 'change'
|
|
2050
|
+
});
|
|
2051
|
+
});
|
|
2052
|
+
};
|
|
2053
|
+
|
|
2054
|
+
select.refresh = function () {
|
|
2055
|
+
select.disabled = true; // unlocked any conflict we had got into
|
|
2056
|
+
|
|
2057
|
+
var is = [];
|
|
2058
|
+
var newObject;
|
|
2059
|
+
|
|
2060
|
+
for (var _i3 = 0; _i3 < select.options.length; _i3++) {
|
|
2061
|
+
var opt = select.options[_i3];
|
|
2062
|
+
|
|
2063
|
+
if (opt.selected && opt.AJAR_mint) {
|
|
2064
|
+
// not sure if this 'if' is used because I cannot find mintClass
|
|
2065
|
+
if (options.mintClass) {
|
|
2066
|
+
var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
|
|
2067
|
+
if (!ok) {
|
|
2068
|
+
callbackFunction(ok, body, {
|
|
2069
|
+
change: 'new'
|
|
2070
|
+
}); // @@ if ok, need some form of refresh of the select for the new thing
|
|
2071
|
+
}
|
|
2072
|
+
});
|
|
2073
|
+
select.parentNode.appendChild(thisForm);
|
|
2074
|
+
newObject = thisForm.AJAR_subject;
|
|
2075
|
+
} else {
|
|
2076
|
+
newObject = newThing(dataDoc);
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
is.push($rdf.st(subject, predicate, kb.sym(newObject), dataDoc));
|
|
2080
|
+
if (uiFrom) is.push($rdf.st(newObject, ns.rdf('type'), kb.sym(uiFrom), dataDoc)); // not sure if this 'if' is used because I cannot find mintStatementsFun
|
|
2081
|
+
|
|
2082
|
+
if (options.mintStatementsFun) {
|
|
2083
|
+
is = is.concat(options.mintStatementsFun(newObject));
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
select.currentURI = newObject;
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
if (!opt.AJAR_uri) continue; // a prompt or mint
|
|
2090
|
+
|
|
2091
|
+
if (opt.selected && containsObject(opt.AJAR_uri, selectedOptions)) {
|
|
2092
|
+
select.currentURI = opt.AJAR_uri;
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2095
|
+
if (!containsObject(opt.AJAR_uri, selectedOptions)) opt.removeAttribute('selected');
|
|
2096
|
+
if (containsObject(opt.AJAR_uri, selectedOptions)) opt.setAttribute('selected', 'true');
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
log.info('selectForOptions: data doc = ' + dataDoc);
|
|
2100
|
+
|
|
2101
|
+
if (select.currentURI && options.subForm) {
|
|
2102
|
+
addSubFormChoice(dom, container, {}, $rdf.sym(select.currentURI), options.subForm, dataDoc, function (ok, body) {
|
|
2103
|
+
if (ok) {
|
|
2104
|
+
kb.updater.update([], is, function (uri, success, errorBody) {
|
|
2105
|
+
if (!success) container.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating select: ' + errorBody));
|
|
2106
|
+
});
|
|
2107
|
+
if (callbackFunction) callbackFunction(ok, {
|
|
2108
|
+
widget: 'select',
|
|
2109
|
+
event: 'new'
|
|
2110
|
+
});
|
|
2111
|
+
} else {
|
|
2112
|
+
container.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in field of select: ' + body));
|
|
2113
|
+
}
|
|
2114
|
+
});
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
select.disabled = false;
|
|
2118
|
+
};
|
|
2119
|
+
|
|
2120
|
+
function createOption(uri) {
|
|
2121
|
+
var option = dom.createElement('option');
|
|
2122
|
+
var c = kb.sym(uri);
|
|
2123
|
+
var label;
|
|
2124
|
+
|
|
2125
|
+
if (options.disambiguate) {
|
|
2126
|
+
label = utils.labelWithOntology(c, true); // Init. cap
|
|
2127
|
+
} else {
|
|
2128
|
+
label = utils.label(c, true);
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
option.appendChild(dom.createTextNode(label)); // Init.
|
|
2132
|
+
|
|
2133
|
+
option.setAttribute('value', uri);
|
|
2134
|
+
var backgroundColor = kb.any(c, kb.sym('http://www.w3.org/ns/ui#backgroundColor'));
|
|
2135
|
+
|
|
2136
|
+
if (backgroundColor) {
|
|
2137
|
+
option.setAttribute('style', 'background-color: ' + backgroundColor.value + '; ');
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
option.AJAR_uri = uri;
|
|
2141
|
+
|
|
2142
|
+
if (containsObject(c.value, selectedOptions)) {
|
|
2143
|
+
option.setAttribute('selected', 'true');
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
return option;
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
if (editable) {
|
|
2150
|
+
select.addEventListener('change', onChange, false);
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2153
|
+
return select;
|
|
2154
|
+
} // makeSelectForChoice
|
|
2155
|
+
|
|
2156
|
+
|
|
2157
|
+
function containsObject(obj, list) {
|
|
2158
|
+
var i;
|
|
2159
|
+
|
|
2160
|
+
for (i = 0; i < list.length; i++) {
|
|
2161
|
+
if (list[i] === obj) {
|
|
2162
|
+
return true;
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
return false;
|
|
2167
|
+
}
|
|
1926
2168
|
//# sourceMappingURL=forms.js.map
|