solid-ui 2.4.22-be8b238b → 2.4.22-c7419dec
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 +2110 -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 +11 -7
- package/lib/login/login.d.ts.map +1 -1
- package/lib/login/login.js +259 -309
- 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 +433 -186
- 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
|
-
|
|
309
|
+
if (match) {
|
|
310
|
+
var _field3 = kb.the(c, ui('use'));
|
|
297
311
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
break;
|
|
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,23 +1045,25 @@ _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;
|
|
1044
|
-
var box = dom.createElement('div');
|
|
1058
|
+
var box = dom.createElement('div');
|
|
1059
|
+
box.setAttribute('class', 'choiceBox'); // Set flexDirection column?
|
|
1045
1060
|
|
|
1046
1061
|
if (container) container.appendChild(box);
|
|
1047
1062
|
var lhs = dom.createElement('div');
|
|
1063
|
+
lhs.setAttribute('class', 'formFieldName choiceBox-label');
|
|
1048
1064
|
box.appendChild(lhs);
|
|
1049
1065
|
var rhs = dom.createElement('div');
|
|
1066
|
+
rhs.setAttribute('class', 'formFieldValue choiceBox-selectBox');
|
|
1050
1067
|
box.appendChild(rhs);
|
|
1051
1068
|
var property = kb.any(form, ui('property'));
|
|
1052
1069
|
|
|
@@ -1055,103 +1072,124 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
1055
1072
|
}
|
|
1056
1073
|
|
|
1057
1074
|
lhs.appendChild((0, _basic.fieldLabel)(dom, property, form));
|
|
1058
|
-
var
|
|
1075
|
+
var uiFrom = kb.any(form, ui('from'));
|
|
1059
1076
|
|
|
1060
|
-
|
|
1077
|
+
if (!uiFrom) {
|
|
1078
|
+
return (0, _error.errorMessageBlock)(dom, "No 'from' for Choice: " + form);
|
|
1079
|
+
}
|
|
1080
|
+
|
|
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?
|
|
1061
1083
|
|
|
1062
|
-
var possible = [];
|
|
1063
|
-
var possibleProperties;
|
|
1064
|
-
var firstSelectOptionText = '* Select from ' + utils.label(subject, true) + ' *';
|
|
1065
1084
|
var opts = {
|
|
1066
1085
|
form: form,
|
|
1067
1086
|
subForm: subForm,
|
|
1068
|
-
multiple: multiple,
|
|
1069
|
-
firstSelectOptionText: firstSelectOptionText,
|
|
1070
1087
|
disambiguate: false
|
|
1071
1088
|
};
|
|
1072
|
-
var uiFrom = kb.any(form, ui('from'));
|
|
1073
1089
|
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1090
|
+
function getSelectorOptions() {
|
|
1091
|
+
var possible = [];
|
|
1092
|
+
var possibleProperties;
|
|
1093
|
+
possible = kb.each(undefined, ns.rdf('type'), uiFrom, formDoc);
|
|
1077
1094
|
|
|
1078
|
-
|
|
1095
|
+
for (var x in kb.findMembersNT(uiFrom)) {
|
|
1096
|
+
possible.push(kb.fromNT(x));
|
|
1097
|
+
} // Use rdfs
|
|
1079
1098
|
|
|
1080
|
-
for (var x in kb.findMembersNT(uiFrom)) {
|
|
1081
|
-
possible.push(kb.fromNT(x));
|
|
1082
|
-
} // Use rdfs
|
|
1083
1099
|
|
|
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)
|
|
1084
1104
|
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
possible.push(kb.sym(p));
|
|
1088
|
-
} // log.debug("%%% Choice field: possible.length 2 = "+possible.length)
|
|
1105
|
+
} else if (uiFrom.sameTerm(ns.rdf('Property'))) {
|
|
1106
|
+
possibleProperties = buttons.propertyTriage(kb);
|
|
1089
1107
|
|
|
1090
|
-
|
|
1091
|
-
|
|
1108
|
+
for (p in possibleProperties.op) {
|
|
1109
|
+
possible.push(kb.fromNT(p));
|
|
1110
|
+
}
|
|
1092
1111
|
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1112
|
+
for (p in possibleProperties.dp) {
|
|
1113
|
+
possible.push(kb.fromNT(p));
|
|
1114
|
+
}
|
|
1096
1115
|
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
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);
|
|
1100
1119
|
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1120
|
+
for (p in possibleProperties.op) {
|
|
1121
|
+
possible.push(kb.fromNT(p));
|
|
1122
|
+
}
|
|
1104
1123
|
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1124
|
+
opts.disambiguate = true;
|
|
1125
|
+
} else if (uiFrom.sameTerm(ns.owl('DatatypeProperty'))) {
|
|
1126
|
+
possibleProperties = buttons.propertyTriage(kb);
|
|
1108
1127
|
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1128
|
+
for (p in possibleProperties.dp) {
|
|
1129
|
+
possible.push(kb.fromNT(p));
|
|
1130
|
+
}
|
|
1112
1131
|
|
|
1113
|
-
|
|
1114
|
-
possible.push(kb.fromNT(p));
|
|
1132
|
+
opts.disambiguate = true;
|
|
1115
1133
|
}
|
|
1116
1134
|
|
|
1117
|
-
|
|
1118
|
-
}
|
|
1135
|
+
return possible; // return sortByLabel(possible)
|
|
1136
|
+
} // TODO: this checks for any occurrence, regardless of true or false setting
|
|
1119
1137
|
|
|
1120
|
-
var sortedPossible = sortByLabel(possible); // TODO: this checks for any occurance regardles if it is set to true or false
|
|
1121
1138
|
|
|
1122
1139
|
if (kb.any(form, ui('canMintNew'))) {
|
|
1123
1140
|
opts.mint = '* Create new *'; // @@ could be better
|
|
1124
1141
|
}
|
|
1125
1142
|
|
|
1126
|
-
var
|
|
1127
|
-
|
|
1128
|
-
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
|
+
}
|
|
1129
1175
|
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
object = kb.any(subject, property);
|
|
1134
|
-
}
|
|
1176
|
+
if (event.action === 'CLEAR_ALL_OPTIONS') {
|
|
1177
|
+
selectedOptions = [];
|
|
1178
|
+
}
|
|
1135
1179
|
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1180
|
+
if (event.action === 'ADD_OPTION') {
|
|
1181
|
+
selectedOptions.push(event.value);
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
selector.update(selectedOptions);
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
1187
|
+
};
|
|
1140
1188
|
|
|
1189
|
+
rhs.refresh();
|
|
1190
|
+
if (selector && selector.refresh) selector.refresh();
|
|
1141
1191
|
return box;
|
|
1142
1192
|
};
|
|
1143
|
-
/**
|
|
1144
|
-
* Removes all sibling elements after specified
|
|
1145
|
-
* @param {HTMLElement} currentElement
|
|
1146
|
-
* @private
|
|
1147
|
-
*/
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
function removeNextSiblingsAfterElement(currentElement) {
|
|
1151
|
-
while (currentElement.nextElementSibling) {
|
|
1152
|
-
currentElement.nextElementSibling.remove();
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
1193
|
|
|
1156
1194
|
function addSubFormChoice(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction) {
|
|
1157
1195
|
(0, _fieldFunction.fieldFunction)(dom, subForm)(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction);
|
|
@@ -1358,7 +1396,8 @@ function promptForNew(dom, kb, subject, predicate, theClass, form, dataDoc, call
|
|
|
1358
1396
|
b.setAttribute('type', 'button');
|
|
1359
1397
|
b.setAttribute('style', 'float: right;');
|
|
1360
1398
|
b.innerHTML = 'Goto ' + utils.label(theClass);
|
|
1361
|
-
b.addEventListener('click',
|
|
1399
|
+
b.addEventListener('click', // TODO fix dependency cycle to solid-panes by calling outlineManager
|
|
1400
|
+
function (_e) {
|
|
1362
1401
|
dom.outlineManager.GotoSubject(theClass, true, undefined, true, undefined);
|
|
1363
1402
|
}, false);
|
|
1364
1403
|
return box;
|
|
@@ -1493,17 +1532,15 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
|
|
|
1493
1532
|
// @param subject - a term, the subject of the statement(s) being edited.
|
|
1494
1533
|
// @param predicate - a term, the predicate of the statement(s) being edited
|
|
1495
1534
|
// @param possible - a list of terms, the possible value the object can take
|
|
1496
|
-
// @param options.
|
|
1497
|
-
// @param options.firstSelectOptionText - a string to be displayed as the
|
|
1535
|
+
// @param options.nullLabel - a string to be displayed as the
|
|
1498
1536
|
// option for none selected (for non multiple)
|
|
1499
|
-
// @param options.mint - User may create thing if this sent to the prompt string eg "New foo"
|
|
1500
1537
|
// @param options.subForm - If mint, then the form to be used for minting the new thing
|
|
1501
1538
|
// @param dataDoc - The web document being edited
|
|
1502
1539
|
// @param callbackFunction - takes (boolean ok, string errorBody)
|
|
1503
1540
|
*/
|
|
1504
1541
|
|
|
1505
1542
|
|
|
1506
|
-
function makeSelectForOptions(dom, kb, subject, predicate, possible,
|
|
1543
|
+
function makeSelectForOptions(dom, kb, subject, predicate, possible, options, dataDoc, callbackFunction) {
|
|
1507
1544
|
log.debug('Select list length now ' + possible.length);
|
|
1508
1545
|
var n = 0;
|
|
1509
1546
|
var uris = {}; // Count them
|
|
@@ -1520,7 +1557,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
1520
1557
|
} // uris is now the set of possible options
|
|
1521
1558
|
|
|
1522
1559
|
|
|
1523
|
-
if (n === 0
|
|
1560
|
+
if (n === 0) {
|
|
1524
1561
|
return (0, _error.errorMessageBlock)(dom, "Can't do selector with no options, subject= " + subject + ' property = ' + predicate + '.');
|
|
1525
1562
|
}
|
|
1526
1563
|
|
|
@@ -1546,6 +1583,8 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
1546
1583
|
actual = getActual();
|
|
1547
1584
|
|
|
1548
1585
|
var onChange = function onChange(_e) {
|
|
1586
|
+
select.disabled = true; // until data written back - gives user feedback too
|
|
1587
|
+
|
|
1549
1588
|
var ds = [];
|
|
1550
1589
|
var is = [];
|
|
1551
1590
|
|
|
@@ -1555,43 +1594,18 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
1555
1594
|
}
|
|
1556
1595
|
};
|
|
1557
1596
|
|
|
1558
|
-
var newObject;
|
|
1559
|
-
|
|
1560
1597
|
for (var _i = 0; _i < select.options.length; _i++) {
|
|
1561
1598
|
var opt = select.options[_i];
|
|
1562
|
-
|
|
1563
|
-
if (opt.selected && opt.AJAR_mint) {
|
|
1564
|
-
// not sure if this if is used because I cannot find mintClass
|
|
1565
|
-
if (options.mintClass) {
|
|
1566
|
-
var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
|
|
1567
|
-
if (!ok) {
|
|
1568
|
-
callbackFunction(ok, body, {
|
|
1569
|
-
change: 'new'
|
|
1570
|
-
}); // @@ if ok, need some form of refresh of the select for the new thing
|
|
1571
|
-
}
|
|
1572
|
-
});
|
|
1573
|
-
select.parentNode.appendChild(thisForm);
|
|
1574
|
-
newObject = thisForm.AJAR_subject;
|
|
1575
|
-
} else {
|
|
1576
|
-
newObject = newThing(dataDoc);
|
|
1577
|
-
}
|
|
1578
|
-
|
|
1579
|
-
is.push($rdf.st(subject, predicate, kb.sym(newObject), dataDoc));
|
|
1580
|
-
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
|
|
1581
|
-
|
|
1582
|
-
if (options.mintStatementsFun) {
|
|
1583
|
-
is = is.concat(options.mintStatementsFun(newObject));
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
|
-
select.currentURI = newObject;
|
|
1587
|
-
}
|
|
1588
|
-
|
|
1589
1599
|
if (!opt.AJAR_uri) continue; // a prompt or mint
|
|
1590
1600
|
|
|
1591
1601
|
if (opt.selected && !(opt.AJAR_uri in actual)) {
|
|
1592
1602
|
// new class
|
|
1593
1603
|
is.push($rdf.st(subject, predicate, kb.sym(opt.AJAR_uri), dataDoc));
|
|
1594
|
-
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
if (!opt.selected && opt.AJAR_uri in actual) {
|
|
1607
|
+
// old class
|
|
1608
|
+
removeValue(kb.sym(opt.AJAR_uri));
|
|
1595
1609
|
}
|
|
1596
1610
|
|
|
1597
1611
|
if (opt.selected) select.currentURI = opt.AJAR_uri;
|
|
@@ -1611,27 +1625,25 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
1611
1625
|
sel = sel.superSelect;
|
|
1612
1626
|
}
|
|
1613
1627
|
|
|
1614
|
-
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
|
|
1615
1631
|
|
|
1616
|
-
removeNextSiblingsAfterElement(select);
|
|
1617
|
-
addSubFormChoice(dom, select.parentNode, {}, $rdf.sym(select.currentURI), options.subForm, dataDoc, function (ok, body) {
|
|
1618
1632
|
if (ok) {
|
|
1619
|
-
|
|
1620
|
-
|
|
1633
|
+
select.disabled = false; // data written back
|
|
1634
|
+
} else {
|
|
1635
|
+
return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in select: ' + body));
|
|
1636
|
+
}
|
|
1621
1637
|
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
});
|
|
1627
|
-
});
|
|
1628
|
-
} else return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in field of select: ' + body));
|
|
1638
|
+
if (callbackFunction) callbackFunction(ok, {
|
|
1639
|
+
widget: 'select',
|
|
1640
|
+
event: 'change'
|
|
1641
|
+
});
|
|
1629
1642
|
});
|
|
1630
1643
|
};
|
|
1631
1644
|
|
|
1632
1645
|
var select = dom.createElement('select');
|
|
1633
1646
|
select.setAttribute('style', style.formSelectSTyle);
|
|
1634
|
-
if (options.multiple) select.setAttribute('multiple', 'true');
|
|
1635
1647
|
select.currentURI = null;
|
|
1636
1648
|
|
|
1637
1649
|
select.refresh = function () {
|
|
@@ -1674,22 +1686,11 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
1674
1686
|
select.appendChild(option);
|
|
1675
1687
|
}
|
|
1676
1688
|
|
|
1677
|
-
if (
|
|
1678
|
-
var mint = dom.createElement('option');
|
|
1679
|
-
mint.appendChild(dom.createTextNode(options.mint));
|
|
1680
|
-
mint.AJAR_mint = true; // Flag it
|
|
1681
|
-
|
|
1682
|
-
select.insertBefore(mint, select.firstChild);
|
|
1683
|
-
}
|
|
1684
|
-
|
|
1685
|
-
if (!select.currentURI && !options.multiple) {
|
|
1689
|
+
if (!select.currentURI) {
|
|
1686
1690
|
var prompt = dom.createElement('option');
|
|
1687
|
-
prompt.appendChild(dom.createTextNode(options.
|
|
1688
|
-
prompt.selected = true;
|
|
1689
|
-
prompt.disabled = true;
|
|
1690
|
-
prompt.value = true;
|
|
1691
|
-
prompt.hidden = true;
|
|
1691
|
+
prompt.appendChild(dom.createTextNode(options.nullLabel));
|
|
1692
1692
|
select.insertBefore(prompt, select.firstChild);
|
|
1693
|
+
prompt.selected = true;
|
|
1693
1694
|
}
|
|
1694
1695
|
|
|
1695
1696
|
if (editable) {
|
|
@@ -1708,27 +1709,16 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
1708
1709
|
function makeSelectForCategory(dom, kb, subject, category, dataDoc, callbackFunction) {
|
|
1709
1710
|
var du = kb.any(category, ns.owl('disjointUnionOf'));
|
|
1710
1711
|
var subs;
|
|
1711
|
-
var multiple = false;
|
|
1712
1712
|
|
|
1713
1713
|
if (!du) {
|
|
1714
1714
|
subs = kb.each(undefined, ns.rdfs('subClassOf'), category);
|
|
1715
|
-
multiple = true;
|
|
1716
1715
|
} else {
|
|
1717
1716
|
subs = du.elements;
|
|
1718
1717
|
}
|
|
1719
1718
|
|
|
1720
1719
|
log.debug('Select list length ' + subs.length);
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with no subclasses of category: ' + category);
|
|
1724
|
-
}
|
|
1725
|
-
|
|
1726
|
-
if (subs.length === 1) {
|
|
1727
|
-
return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with only 1 subclass of category: ' + category + ':' + subs[1]);
|
|
1728
|
-
}
|
|
1729
|
-
|
|
1730
|
-
return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, null, {
|
|
1731
|
-
multiple: multiple
|
|
1720
|
+
return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, {
|
|
1721
|
+
nullLabel: '* Select type *'
|
|
1732
1722
|
}, dataDoc, callbackFunction);
|
|
1733
1723
|
}
|
|
1734
1724
|
/** Make SELECT element to select subclasses recurively
|
|
@@ -1762,8 +1752,7 @@ function makeSelectForNestedCategory(dom, kb, subject, category, dataDoc, callba
|
|
|
1762
1752
|
function onChange(ok, body) {
|
|
1763
1753
|
if (ok) update();
|
|
1764
1754
|
callbackFunction(ok, body);
|
|
1765
|
-
}
|
|
1766
|
-
|
|
1755
|
+
}
|
|
1767
1756
|
|
|
1768
1757
|
var select = makeSelectForCategory(dom, kb, subject, category, dataDoc, onChange);
|
|
1769
1758
|
container.appendChild(select);
|
|
@@ -1918,4 +1907,262 @@ function newThing(doc) {
|
|
|
1918
1907
|
var now = new Date();
|
|
1919
1908
|
return $rdf.sym(doc.uri + '#' + 'id' + ('' + now.getTime()));
|
|
1920
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
|
+
}
|
|
1921
2168
|
//# sourceMappingURL=forms.js.map
|