solid-ui 2.4.22-8fef4f19 → 2.4.22-993ab4aa
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 +315 -183
- package/dist/main.js.map +1 -1
- package/lib/utils/label.js +1 -1
- package/lib/utils/label.js.map +1 -1
- package/lib/versionInfo.js +5 -5
- 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/forms.js +307 -177
- package/lib/widgets/forms.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -15172,7 +15172,7 @@ function slice(s, suffix) {
|
|
|
15172
15172
|
|
|
15173
15173
|
function getWellKnownLabel(thing) {
|
|
15174
15174
|
return _solidLogic.store.any(thing, UI.ns.ui('label')) || // Prioritize ui:label
|
|
15175
|
-
_solidLogic.store.any(thing, UI.ns.link('message')) || _solidLogic.store.any(thing, UI.ns.vcard('fn')) || _solidLogic.store.any(thing, UI.ns.foaf('name')) || _solidLogic.store.any(thing, UI.ns.dct('title')) || _solidLogic.store.any(thing, UI.ns.dc('title')) || _solidLogic.store.any(thing, UI.ns.rss('title')) || _solidLogic.store.any(thing, UI.ns.contact('fullName')) || _solidLogic.store.any(thing, _solidLogic.store.sym('http://www.w3.org/2001/04/roadmap/org#name')) || _solidLogic.store.any(thing, UI.ns.cal('summary')) || _solidLogic.store.any(thing, UI.ns.foaf('nick')) || _solidLogic.store.any(thing, UI.ns.as('name')) || _solidLogic.store.any(thing, UI.ns.schema('name')) || _solidLogic.store.any(thing, UI.ns.rdfs('label'));
|
|
15175
|
+
_solidLogic.store.any(thing, UI.ns.link('message')) || _solidLogic.store.any(thing, UI.ns.vcard('fn')) || _solidLogic.store.any(thing, UI.ns.foaf('name')) || _solidLogic.store.any(thing, UI.ns.dct('title')) || _solidLogic.store.any(thing, UI.ns.dc('title')) || _solidLogic.store.any(thing, UI.ns.rss('title')) || _solidLogic.store.any(thing, UI.ns.contact('fullName')) || _solidLogic.store.any(thing, _solidLogic.store.sym('http://www.w3.org/2001/04/roadmap/org#name')) || _solidLogic.store.any(thing, UI.ns.cal('summary')) || _solidLogic.store.any(thing, UI.ns.foaf('nick')) || _solidLogic.store.any(thing, UI.ns.as('name')) || _solidLogic.store.any(thing, UI.ns.schema('name')) || _solidLogic.store.any(thing, UI.ns.rdfs('label')) || _solidLogic.store.any(thing, _solidLogic.store.sym('http://www.w3.org/2004/02/skos/core#prefLabel'));
|
|
15176
15176
|
}
|
|
15177
15177
|
//# sourceMappingURL=label.js.map
|
|
15178
15178
|
|
|
@@ -15192,11 +15192,11 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
15192
15192
|
}));
|
|
15193
15193
|
exports.versionInfo = void 0;
|
|
15194
15194
|
var versionInfo = {
|
|
15195
|
-
buildTime: '2022-05-
|
|
15196
|
-
commit: '
|
|
15195
|
+
buildTime: '2022-05-20T13:40:58Z',
|
|
15196
|
+
commit: '993ab4aa29f540e8920023c0f3fec29c660dd28d',
|
|
15197
15197
|
npmInfo: {
|
|
15198
15198
|
'solid-ui': '2.4.22',
|
|
15199
|
-
npm: '6.14.
|
|
15199
|
+
npm: '6.14.17',
|
|
15200
15200
|
ares: '1.18.1',
|
|
15201
15201
|
brotli: '1.0.9',
|
|
15202
15202
|
cldr: '40.0',
|
|
@@ -15205,12 +15205,12 @@ var versionInfo = {
|
|
|
15205
15205
|
modules: '83',
|
|
15206
15206
|
napi: '8',
|
|
15207
15207
|
nghttp2: '1.42.0',
|
|
15208
|
-
node: '14.19.
|
|
15208
|
+
node: '14.19.2',
|
|
15209
15209
|
openssl: '1.1.1n',
|
|
15210
15210
|
tz: '2021a3',
|
|
15211
15211
|
unicode: '14.0',
|
|
15212
15212
|
uv: '1.42.0',
|
|
15213
|
-
v8: '8.4.371.23-node.
|
|
15213
|
+
v8: '8.4.371.23-node.87',
|
|
15214
15214
|
zlib: '1.2.11'
|
|
15215
15215
|
}
|
|
15216
15216
|
};
|
|
@@ -16280,6 +16280,7 @@ function openHrefInOutlineMode(e) {
|
|
|
16280
16280
|
|
|
16281
16281
|
if (dom.outlineManager) {
|
|
16282
16282
|
// @@ TODO Remove the use of document as a global object
|
|
16283
|
+
// TODO fix dependency cycle to solid-panes by calling outlineManager
|
|
16283
16284
|
;
|
|
16284
16285
|
dom.outlineManager.GotoSubject(_solidLogic.store.sym(uri), true, undefined, true, undefined);
|
|
16285
16286
|
} else if (window && window.panes && window.panes.getOutliner) {
|
|
@@ -16407,6 +16408,7 @@ function linkButton(dom, object) {
|
|
|
16407
16408
|
b.textContent = 'Goto ' + utils.label(object);
|
|
16408
16409
|
b.addEventListener('click', function (_event) {
|
|
16409
16410
|
// b.parentNode.removeChild(b)
|
|
16411
|
+
// TODO fix dependency cycle to solid-panes by calling outlineManager
|
|
16410
16412
|
;
|
|
16411
16413
|
dom.outlineManager.GotoSubject(object, true, undefined, true, undefined);
|
|
16412
16414
|
}, true);
|
|
@@ -17147,6 +17149,7 @@ exports.findClosest = findClosest;
|
|
|
17147
17149
|
exports.formsFor = formsFor;
|
|
17148
17150
|
exports.makeDescription = makeDescription;
|
|
17149
17151
|
exports.makeSelectForCategory = makeSelectForCategory;
|
|
17152
|
+
exports.makeSelectForChoice = makeSelectForChoice;
|
|
17150
17153
|
exports.makeSelectForNestedCategory = makeSelectForNestedCategory;
|
|
17151
17154
|
exports.makeSelectForOptions = makeSelectForOptions;
|
|
17152
17155
|
exports.newButton = newButton;
|
|
@@ -17258,14 +17261,16 @@ _fieldFunction.field[ns.ui('Form').uri] = _fieldFunction.field[ns.ui('Group').ur
|
|
|
17258
17261
|
var ui = ns.ui;
|
|
17259
17262
|
if (container) container.appendChild(box); // Prevent loops
|
|
17260
17263
|
|
|
17264
|
+
if (!form) return;
|
|
17261
17265
|
var key = subject.toNT() + '|' + form.toNT();
|
|
17262
17266
|
|
|
17263
17267
|
if (already[key]) {
|
|
17264
17268
|
// been there done that
|
|
17265
|
-
box.appendChild(dom.createTextNode('Group: see above ' + key));
|
|
17266
|
-
|
|
17269
|
+
box.appendChild(dom.createTextNode('Group: see above ' + key)); // TODO fix dependency cycle to solid-panes by calling outlineManager
|
|
17270
|
+
// const plist = [$rdf.st(subject, ns.owl('sameAs'), subject)] // @@ need prev subject
|
|
17271
|
+
// dom.outlineManager.appendPropertyTRs(box, plist)
|
|
17272
|
+
// dom.appendChild(plist)
|
|
17267
17273
|
|
|
17268
|
-
dom.outlineManager.appendPropertyTRs(box, plist);
|
|
17269
17274
|
return box;
|
|
17270
17275
|
}
|
|
17271
17276
|
|
|
@@ -17366,47 +17371,43 @@ _fieldFunction.field[ns.ui('Options').uri] = function (dom, container, already,
|
|
|
17366
17371
|
values = kb.each(subject, dependingOn);
|
|
17367
17372
|
}
|
|
17368
17373
|
|
|
17369
|
-
|
|
17370
|
-
|
|
17371
|
-
|
|
17372
|
-
for (var i = 0; i < cases.length; i++) {
|
|
17373
|
-
var c = cases[i];
|
|
17374
|
-
var tests = kb.each(c, ui('for'), null, formDoc); // There can be multiple 'for'
|
|
17374
|
+
for (var i = 0; i < cases.length; i++) {
|
|
17375
|
+
var c = cases[i];
|
|
17376
|
+
var tests = kb.each(c, ui('for'), null, formDoc); // There can be multiple 'for'
|
|
17375
17377
|
|
|
17376
|
-
|
|
17378
|
+
var match = false;
|
|
17377
17379
|
|
|
17378
|
-
|
|
17379
|
-
|
|
17380
|
-
|
|
17380
|
+
for (var j = 0; j < tests.length; j++) {
|
|
17381
|
+
var _iterator = _createForOfIteratorHelper(values),
|
|
17382
|
+
_step;
|
|
17381
17383
|
|
|
17382
|
-
|
|
17383
|
-
|
|
17384
|
-
|
|
17385
|
-
|
|
17384
|
+
try {
|
|
17385
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
17386
|
+
var value = _step.value;
|
|
17387
|
+
var test = tests[j];
|
|
17386
17388
|
|
|
17387
|
-
|
|
17388
|
-
|
|
17389
|
-
}
|
|
17389
|
+
if (value.sameTerm(tests) || value.termType === test.termType && value.value === test.value) {
|
|
17390
|
+
match = true;
|
|
17390
17391
|
}
|
|
17391
|
-
} catch (err) {
|
|
17392
|
-
_iterator.e(err);
|
|
17393
|
-
} finally {
|
|
17394
|
-
_iterator.f();
|
|
17395
17392
|
}
|
|
17393
|
+
} catch (err) {
|
|
17394
|
+
_iterator.e(err);
|
|
17395
|
+
} finally {
|
|
17396
|
+
_iterator.f();
|
|
17396
17397
|
}
|
|
17398
|
+
}
|
|
17397
17399
|
|
|
17398
|
-
|
|
17399
|
-
|
|
17400
|
-
|
|
17401
|
-
if (!_field3) {
|
|
17402
|
-
box.appendChild((0, _error.errorMessageBlock)(dom, 'No "use" part for case in form ' + form));
|
|
17403
|
-
return box;
|
|
17404
|
-
} else {
|
|
17405
|
-
appendForm(dom, box, already, subject, _field3, dataDoc, callbackFunction);
|
|
17406
|
-
}
|
|
17400
|
+
if (match) {
|
|
17401
|
+
var _field3 = kb.the(c, ui('use'));
|
|
17407
17402
|
|
|
17408
|
-
|
|
17403
|
+
if (!_field3) {
|
|
17404
|
+
box.appendChild((0, _error.errorMessageBlock)(dom, 'No "use" part for case in form ' + form));
|
|
17405
|
+
return box;
|
|
17406
|
+
} else {
|
|
17407
|
+
appendForm(dom, box, already, subject, _field3, dataDoc, callbackFunction);
|
|
17409
17408
|
}
|
|
17409
|
+
|
|
17410
|
+
break;
|
|
17410
17411
|
}
|
|
17411
17412
|
} // @@ Add box.refresh() to sync fields with values
|
|
17412
17413
|
|
|
@@ -17694,7 +17695,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
17694
17695
|
// delete button and move buttons
|
|
17695
17696
|
|
|
17696
17697
|
if (kb.updater.editable(dataDoc.uri)) {
|
|
17697
|
-
buttons.deleteButtonWithCheck(dom, subField,
|
|
17698
|
+
buttons.deleteButtonWithCheck(dom, subField, multipleUIlabel, deleteThisItem);
|
|
17698
17699
|
|
|
17699
17700
|
if (ordered) {
|
|
17700
17701
|
// Add controsl in a frame
|
|
@@ -17794,6 +17795,8 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
17794
17795
|
return shim;
|
|
17795
17796
|
}
|
|
17796
17797
|
|
|
17798
|
+
var multipleUIlabel = kb.any(form, ui('label'));
|
|
17799
|
+
if (!multipleUIlabel) multipleUIlabel = utils.label(property);
|
|
17797
17800
|
var min = kb.any(form, ui('min')); // This is the minimum number -- default 0
|
|
17798
17801
|
|
|
17799
17802
|
min = min ? 0 + min.value : 0;
|
|
@@ -17830,16 +17833,13 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
17830
17833
|
if (kb.updater.editable(dataDoc.uri)) {
|
|
17831
17834
|
var tail = box.appendChild(dom.createElement('div'));
|
|
17832
17835
|
tail.style.padding = '0.5em';
|
|
17833
|
-
var label = kb.any(form, ui('label'));
|
|
17834
|
-
if (!label) label = utils.label(property, true); // Init capital
|
|
17835
|
-
|
|
17836
17836
|
var img = tail.appendChild(dom.createElement('img'));
|
|
17837
17837
|
img.setAttribute('src', plusIconURI); // plus sign
|
|
17838
17838
|
|
|
17839
17839
|
img.setAttribute('style', 'margin: 0.2em; width: 1.5em; height:1.5em');
|
|
17840
|
-
img.title = 'Click to add
|
|
17840
|
+
img.title = 'Click to add another ' + multipleUIlabel;
|
|
17841
17841
|
var prompt = dom.createElement('span');
|
|
17842
|
-
prompt.textContent = (values.length === 0 ? 'Add
|
|
17842
|
+
prompt.textContent = (values.length === 0 ? 'Add another ' : 'Add ') + multipleUIlabel;
|
|
17843
17843
|
tail.addEventListener('click', /*#__PURE__*/function () {
|
|
17844
17844
|
var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(_eventNotUsed) {
|
|
17845
17845
|
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
@@ -18136,7 +18136,7 @@ _fieldFunction.field[ns.ui('Classifier').uri] = function (dom, container, alread
|
|
|
18136
18136
|
** -- radio buttons
|
|
18137
18137
|
** -- auto-complete typing
|
|
18138
18138
|
**
|
|
18139
|
-
**
|
|
18139
|
+
** TODO: according to ontology ui:choice can also have ns.ui('default') - this is not implemented yet
|
|
18140
18140
|
*/
|
|
18141
18141
|
|
|
18142
18142
|
|
|
@@ -18145,6 +18145,7 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
18145
18145
|
var kb = _solidLogic.store;
|
|
18146
18146
|
var formDoc = form.doc ? form.doc() : null; // @@ if blank no way to know
|
|
18147
18147
|
|
|
18148
|
+
var multiSelect = false;
|
|
18148
18149
|
var p;
|
|
18149
18150
|
var box = dom.createElement('div');
|
|
18150
18151
|
box.setAttribute('class', 'choiceBox'); // Set flexDirection column?
|
|
@@ -18173,87 +18174,79 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
18173
18174
|
|
|
18174
18175
|
var follow = kb.anyJS(form, ui('follow'), null, formDoc); // data doc moves to new subject?
|
|
18175
18176
|
|
|
18176
|
-
var possible = [];
|
|
18177
|
-
var possibleProperties;
|
|
18178
|
-
var multiple = false;
|
|
18179
|
-
var firstSelectOptionText = '* Select for ' + utils.label(subject, true) + ' *'; // if we do NOT have a container it means it is a ui:Multiple
|
|
18180
|
-
// only important for the first option text in select
|
|
18181
|
-
|
|
18182
|
-
if (!container) {
|
|
18183
|
-
multiple = true;
|
|
18184
|
-
firstSelectOptionText = utils.label(subject, true);
|
|
18185
|
-
}
|
|
18186
|
-
|
|
18187
18177
|
var opts = {
|
|
18188
18178
|
form: form,
|
|
18189
18179
|
subForm: subForm,
|
|
18190
|
-
|
|
18191
|
-
firstSelectOptionText: firstSelectOptionText,
|
|
18180
|
+
multiSelect: multiSelect,
|
|
18192
18181
|
disambiguate: false
|
|
18193
18182
|
};
|
|
18194
|
-
possible = kb.each(undefined, ns.rdf('type'), uiFrom, formDoc);
|
|
18195
18183
|
|
|
18196
|
-
|
|
18197
|
-
possible
|
|
18198
|
-
|
|
18184
|
+
function getSelectorOptions() {
|
|
18185
|
+
var possible = [];
|
|
18186
|
+
var possibleProperties;
|
|
18187
|
+
possible = kb.each(undefined, ns.rdf('type'), uiFrom, formDoc);
|
|
18199
18188
|
|
|
18189
|
+
for (var x in kb.findMembersNT(uiFrom)) {
|
|
18190
|
+
possible.push(kb.fromNT(x));
|
|
18191
|
+
} // Use rdfs
|
|
18200
18192
|
|
|
18201
|
-
if (uiFrom.sameTerm(ns.rdfs('Class'))) {
|
|
18202
|
-
for (p in buttons.allClassURIs()) {
|
|
18203
|
-
possible.push(kb.sym(p));
|
|
18204
|
-
} // log.debug("%%% Choice field: possible.length 2 = "+possible.length)
|
|
18205
18193
|
|
|
18206
|
-
|
|
18207
|
-
|
|
18194
|
+
if (uiFrom.sameTerm(ns.rdfs('Class'))) {
|
|
18195
|
+
for (p in buttons.allClassURIs()) {
|
|
18196
|
+
possible.push(kb.sym(p));
|
|
18197
|
+
} // log.debug("%%% Choice field: possible.length 2 = "+possible.length)
|
|
18208
18198
|
|
|
18209
|
-
|
|
18210
|
-
|
|
18211
|
-
}
|
|
18199
|
+
} else if (uiFrom.sameTerm(ns.rdf('Property'))) {
|
|
18200
|
+
possibleProperties = buttons.propertyTriage(kb);
|
|
18212
18201
|
|
|
18213
|
-
|
|
18214
|
-
|
|
18215
|
-
|
|
18202
|
+
for (p in possibleProperties.op) {
|
|
18203
|
+
possible.push(kb.fromNT(p));
|
|
18204
|
+
}
|
|
18216
18205
|
|
|
18217
|
-
|
|
18218
|
-
|
|
18219
|
-
|
|
18206
|
+
for (p in possibleProperties.dp) {
|
|
18207
|
+
possible.push(kb.fromNT(p));
|
|
18208
|
+
}
|
|
18220
18209
|
|
|
18221
|
-
|
|
18222
|
-
|
|
18223
|
-
|
|
18210
|
+
opts.disambiguate = true; // This is a big class, and the labels won't be enough.
|
|
18211
|
+
} else if (uiFrom.sameTerm(ns.owl('ObjectProperty'))) {
|
|
18212
|
+
possibleProperties = buttons.propertyTriage(kb);
|
|
18224
18213
|
|
|
18225
|
-
|
|
18226
|
-
|
|
18227
|
-
|
|
18214
|
+
for (p in possibleProperties.op) {
|
|
18215
|
+
possible.push(kb.fromNT(p));
|
|
18216
|
+
}
|
|
18217
|
+
|
|
18218
|
+
opts.disambiguate = true;
|
|
18219
|
+
} else if (uiFrom.sameTerm(ns.owl('DatatypeProperty'))) {
|
|
18220
|
+
possibleProperties = buttons.propertyTriage(kb);
|
|
18221
|
+
|
|
18222
|
+
for (p in possibleProperties.dp) {
|
|
18223
|
+
possible.push(kb.fromNT(p));
|
|
18224
|
+
}
|
|
18228
18225
|
|
|
18229
|
-
|
|
18230
|
-
possible.push(kb.fromNT(p));
|
|
18226
|
+
opts.disambiguate = true;
|
|
18231
18227
|
}
|
|
18232
18228
|
|
|
18233
|
-
|
|
18234
|
-
|
|
18229
|
+
var object = kb.any(subject, property);
|
|
18230
|
+
if (object) possible.push(object);
|
|
18231
|
+
return sortByLabel(possible);
|
|
18232
|
+
} // TODO: this checks for any occurrence, regardless of true or false setting
|
|
18235
18233
|
|
|
18236
|
-
var sortedPossible = sortByLabel(possible); // TODO: this checks for any occurrence, regardless of true or false setting
|
|
18237
18234
|
|
|
18238
18235
|
if (kb.any(form, ui('canMintNew'))) {
|
|
18239
18236
|
opts.mint = '* Create new *'; // @@ could be better
|
|
18240
18237
|
}
|
|
18241
18238
|
|
|
18242
|
-
var selector
|
|
18243
|
-
rhs.appendChild(selector);
|
|
18244
|
-
var object;
|
|
18245
|
-
|
|
18246
|
-
if (selector.currentURI) {
|
|
18247
|
-
object = $rdf.sym(selector.currentURI);
|
|
18248
|
-
} else {
|
|
18249
|
-
object = kb.any(subject, property);
|
|
18250
|
-
}
|
|
18239
|
+
var selector;
|
|
18251
18240
|
|
|
18252
|
-
|
|
18253
|
-
|
|
18254
|
-
|
|
18255
|
-
|
|
18241
|
+
rhs.refresh = function () {
|
|
18242
|
+
var selectorOptions = getSelectorOptions();
|
|
18243
|
+
selector = makeSelectForChoice(dom, rhs, kb, subject, property, selectorOptions, uiFrom, opts, dataDoc, callbackFunction);
|
|
18244
|
+
rhs.innerHTML = '';
|
|
18245
|
+
rhs.appendChild(selector);
|
|
18246
|
+
};
|
|
18256
18247
|
|
|
18248
|
+
rhs.refresh();
|
|
18249
|
+
if (selector && selector.refresh) selector.refresh();
|
|
18257
18250
|
return box;
|
|
18258
18251
|
};
|
|
18259
18252
|
/**
|
|
@@ -18474,7 +18467,8 @@ function promptForNew(dom, kb, subject, predicate, theClass, form, dataDoc, call
|
|
|
18474
18467
|
b.setAttribute('type', 'button');
|
|
18475
18468
|
b.setAttribute('style', 'float: right;');
|
|
18476
18469
|
b.innerHTML = 'Goto ' + utils.label(theClass);
|
|
18477
|
-
b.addEventListener('click',
|
|
18470
|
+
b.addEventListener('click', // TODO fix dependency cycle to solid-panes by calling outlineManager
|
|
18471
|
+
function (_e) {
|
|
18478
18472
|
dom.outlineManager.GotoSubject(theClass, true, undefined, true, undefined);
|
|
18479
18473
|
}, false);
|
|
18480
18474
|
return box;
|
|
@@ -18609,17 +18603,15 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
|
|
|
18609
18603
|
// @param subject - a term, the subject of the statement(s) being edited.
|
|
18610
18604
|
// @param predicate - a term, the predicate of the statement(s) being edited
|
|
18611
18605
|
// @param possible - a list of terms, the possible value the object can take
|
|
18612
|
-
// @param options.
|
|
18613
|
-
// @param options.firstSelectOptionText - a string to be displayed as the
|
|
18606
|
+
// @param options.nullLabel - a string to be displayed as the
|
|
18614
18607
|
// option for none selected (for non multiple)
|
|
18615
|
-
// @param options.mint - User may create thing if this sent to the prompt string eg "New foo"
|
|
18616
18608
|
// @param options.subForm - If mint, then the form to be used for minting the new thing
|
|
18617
18609
|
// @param dataDoc - The web document being edited
|
|
18618
18610
|
// @param callbackFunction - takes (boolean ok, string errorBody)
|
|
18619
18611
|
*/
|
|
18620
18612
|
|
|
18621
18613
|
|
|
18622
|
-
function makeSelectForOptions(dom, kb, subject, predicate, possible,
|
|
18614
|
+
function makeSelectForOptions(dom, kb, subject, predicate, possible, options, dataDoc, callbackFunction) {
|
|
18623
18615
|
log.debug('Select list length now ' + possible.length);
|
|
18624
18616
|
var n = 0;
|
|
18625
18617
|
var uris = {}; // Count them
|
|
@@ -18636,7 +18628,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
18636
18628
|
} // uris is now the set of possible options
|
|
18637
18629
|
|
|
18638
18630
|
|
|
18639
|
-
if (n === 0
|
|
18631
|
+
if (n === 0) {
|
|
18640
18632
|
return (0, _error.errorMessageBlock)(dom, "Can't do selector with no options, subject= " + subject + ' property = ' + predicate + '.');
|
|
18641
18633
|
}
|
|
18642
18634
|
|
|
@@ -18662,6 +18654,8 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
18662
18654
|
actual = getActual();
|
|
18663
18655
|
|
|
18664
18656
|
var onChange = function onChange(_e) {
|
|
18657
|
+
select.disabled = true; // until data written back - gives user feedback too
|
|
18658
|
+
|
|
18665
18659
|
var ds = [];
|
|
18666
18660
|
var is = [];
|
|
18667
18661
|
|
|
@@ -18671,43 +18665,18 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
18671
18665
|
}
|
|
18672
18666
|
};
|
|
18673
18667
|
|
|
18674
|
-
var newObject;
|
|
18675
|
-
|
|
18676
18668
|
for (var _i = 0; _i < select.options.length; _i++) {
|
|
18677
18669
|
var opt = select.options[_i];
|
|
18678
|
-
|
|
18679
|
-
if (opt.selected && opt.AJAR_mint) {
|
|
18680
|
-
// not sure if this 'if' is used because I cannot find mintClass
|
|
18681
|
-
if (options.mintClass) {
|
|
18682
|
-
var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
|
|
18683
|
-
if (!ok) {
|
|
18684
|
-
callbackFunction(ok, body, {
|
|
18685
|
-
change: 'new'
|
|
18686
|
-
}); // @@ if ok, need some form of refresh of the select for the new thing
|
|
18687
|
-
}
|
|
18688
|
-
});
|
|
18689
|
-
select.parentNode.appendChild(thisForm);
|
|
18690
|
-
newObject = thisForm.AJAR_subject;
|
|
18691
|
-
} else {
|
|
18692
|
-
newObject = newThing(dataDoc);
|
|
18693
|
-
}
|
|
18694
|
-
|
|
18695
|
-
is.push($rdf.st(subject, predicate, kb.sym(newObject), dataDoc));
|
|
18696
|
-
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
|
|
18697
|
-
|
|
18698
|
-
if (options.mintStatementsFun) {
|
|
18699
|
-
is = is.concat(options.mintStatementsFun(newObject));
|
|
18700
|
-
}
|
|
18701
|
-
|
|
18702
|
-
select.currentURI = newObject;
|
|
18703
|
-
}
|
|
18704
|
-
|
|
18705
18670
|
if (!opt.AJAR_uri) continue; // a prompt or mint
|
|
18706
18671
|
|
|
18707
18672
|
if (opt.selected && !(opt.AJAR_uri in actual)) {
|
|
18708
18673
|
// new class
|
|
18709
18674
|
is.push($rdf.st(subject, predicate, kb.sym(opt.AJAR_uri), dataDoc));
|
|
18710
|
-
|
|
18675
|
+
}
|
|
18676
|
+
|
|
18677
|
+
if (!opt.selected && opt.AJAR_uri in actual) {
|
|
18678
|
+
// old class
|
|
18679
|
+
removeValue(kb.sym(opt.AJAR_uri));
|
|
18711
18680
|
}
|
|
18712
18681
|
|
|
18713
18682
|
if (opt.selected) select.currentURI = opt.AJAR_uri;
|
|
@@ -18727,29 +18696,25 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
18727
18696
|
sel = sel.superSelect;
|
|
18728
18697
|
}
|
|
18729
18698
|
|
|
18730
|
-
log.info('selectForOptions: data doc = ' + dataDoc);
|
|
18699
|
+
log.info('selectForOptions: data doc = ' + dataDoc);
|
|
18700
|
+
kb.updater.update(ds, is, function (uri, ok, body) {
|
|
18701
|
+
actual = getActual(); // refresh
|
|
18731
18702
|
|
|
18732
|
-
removeNextSiblingsAfterElement(select);
|
|
18733
|
-
addSubFormChoice(dom, select.parentNode, {}, $rdf.sym(select.currentURI), options.subForm, dataDoc, function (ok, body) {
|
|
18734
18703
|
if (ok) {
|
|
18735
|
-
|
|
18736
|
-
actual = getActual(); // refresh
|
|
18737
|
-
|
|
18738
|
-
if (!success) select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating select: ' + errorBody));
|
|
18739
|
-
});
|
|
18740
|
-
if (callbackFunction) callbackFunction(ok, {
|
|
18741
|
-
widget: 'select',
|
|
18742
|
-
event: 'new'
|
|
18743
|
-
});
|
|
18704
|
+
select.disabled = false; // data written back
|
|
18744
18705
|
} else {
|
|
18745
|
-
select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in
|
|
18706
|
+
return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in select: ' + body));
|
|
18746
18707
|
}
|
|
18708
|
+
|
|
18709
|
+
if (callbackFunction) callbackFunction(ok, {
|
|
18710
|
+
widget: 'select',
|
|
18711
|
+
event: 'change'
|
|
18712
|
+
});
|
|
18747
18713
|
});
|
|
18748
18714
|
};
|
|
18749
18715
|
|
|
18750
18716
|
var select = dom.createElement('select');
|
|
18751
|
-
select.setAttribute('style', style.formSelectSTyle);
|
|
18752
|
-
|
|
18717
|
+
select.setAttribute('style', style.formSelectSTyle);
|
|
18753
18718
|
select.currentURI = null;
|
|
18754
18719
|
|
|
18755
18720
|
select.refresh = function () {
|
|
@@ -18792,22 +18757,11 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
18792
18757
|
select.appendChild(option);
|
|
18793
18758
|
}
|
|
18794
18759
|
|
|
18795
|
-
if (
|
|
18796
|
-
var mint = dom.createElement('option');
|
|
18797
|
-
mint.appendChild(dom.createTextNode(options.mint));
|
|
18798
|
-
mint.AJAR_mint = true; // Flag it
|
|
18799
|
-
|
|
18800
|
-
select.insertBefore(mint, select.firstChild);
|
|
18801
|
-
}
|
|
18802
|
-
|
|
18803
|
-
if (!select.currentURI && options.multiple) {
|
|
18760
|
+
if (!select.currentURI) {
|
|
18804
18761
|
var prompt = dom.createElement('option');
|
|
18805
|
-
prompt.appendChild(dom.createTextNode(options.
|
|
18806
|
-
prompt.disabled = true;
|
|
18807
|
-
prompt.value = true;
|
|
18808
|
-
prompt.hidden = true;
|
|
18809
|
-
prompt.selected = true;
|
|
18762
|
+
prompt.appendChild(dom.createTextNode(options.nullLabel));
|
|
18810
18763
|
select.insertBefore(prompt, select.firstChild);
|
|
18764
|
+
prompt.selected = true;
|
|
18811
18765
|
}
|
|
18812
18766
|
|
|
18813
18767
|
if (editable) {
|
|
@@ -18826,27 +18780,16 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
18826
18780
|
function makeSelectForCategory(dom, kb, subject, category, dataDoc, callbackFunction) {
|
|
18827
18781
|
var du = kb.any(category, ns.owl('disjointUnionOf'));
|
|
18828
18782
|
var subs;
|
|
18829
|
-
var multiple = false;
|
|
18830
18783
|
|
|
18831
18784
|
if (!du) {
|
|
18832
18785
|
subs = kb.each(undefined, ns.rdfs('subClassOf'), category);
|
|
18833
|
-
multiple = true;
|
|
18834
18786
|
} else {
|
|
18835
18787
|
subs = du.elements;
|
|
18836
18788
|
}
|
|
18837
18789
|
|
|
18838
18790
|
log.debug('Select list length ' + subs.length);
|
|
18839
|
-
|
|
18840
|
-
|
|
18841
|
-
return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with no subclasses of category: ' + category);
|
|
18842
|
-
}
|
|
18843
|
-
|
|
18844
|
-
if (subs.length === 1) {
|
|
18845
|
-
return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with only 1 subclass of category: ' + category + ':' + subs[1]);
|
|
18846
|
-
}
|
|
18847
|
-
|
|
18848
|
-
return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, null, {
|
|
18849
|
-
multiple: multiple
|
|
18791
|
+
return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, {
|
|
18792
|
+
nullLabel: '* Select type *'
|
|
18850
18793
|
}, dataDoc, callbackFunction);
|
|
18851
18794
|
}
|
|
18852
18795
|
/** Make SELECT element to select subclasses recurively
|
|
@@ -18880,8 +18823,7 @@ function makeSelectForNestedCategory(dom, kb, subject, category, dataDoc, callba
|
|
|
18880
18823
|
function onChange(ok, body) {
|
|
18881
18824
|
if (ok) update();
|
|
18882
18825
|
callbackFunction(ok, body);
|
|
18883
|
-
}
|
|
18884
|
-
|
|
18826
|
+
}
|
|
18885
18827
|
|
|
18886
18828
|
var select = makeSelectForCategory(dom, kb, subject, category, dataDoc, onChange);
|
|
18887
18829
|
container.appendChild(select);
|
|
@@ -19036,6 +18978,196 @@ function newThing(doc) {
|
|
|
19036
18978
|
var now = new Date();
|
|
19037
18979
|
return $rdf.sym(doc.uri + '#' + 'id' + ('' + now.getTime()));
|
|
19038
18980
|
}
|
|
18981
|
+
/** Make SELECT element to select options
|
|
18982
|
+
//
|
|
18983
|
+
// @param subject - a term, the subject of the statement(s) being edited.
|
|
18984
|
+
// @param predicate - a term, the predicate of the statement(s) being edited
|
|
18985
|
+
// @param possible - a list of terms, the possible value the object can take
|
|
18986
|
+
// @param options.multiSelect - Boolean - Whether more than one at a time is allowed
|
|
18987
|
+
// @param options.uiMultipleInUse - signals that the ui:choise is used with a ui:multiple
|
|
18988
|
+
// @param options.mint - User may create thing if this sent to the prompt string eg "New foo"
|
|
18989
|
+
// @param options.subForm - If mint, then the form to be used for minting the new thing
|
|
18990
|
+
// @param dataDoc - The web document being edited
|
|
18991
|
+
// @param callbackFunction - takes (boolean ok, string errorBody)
|
|
18992
|
+
*/
|
|
18993
|
+
|
|
18994
|
+
|
|
18995
|
+
function makeSelectForChoice(dom, container, kb, subject, predicate, possible, uiFrom, options, dataDoc, callbackFunction) {
|
|
18996
|
+
var n = 0;
|
|
18997
|
+
var uris = {}; // Count them
|
|
18998
|
+
|
|
18999
|
+
var editable = kb.updater.editable(dataDoc.uri);
|
|
19000
|
+
|
|
19001
|
+
for (var i = 0; i < possible.length; i++) {
|
|
19002
|
+
var sub = possible[i]; // @@ Maybe; make this so it works with blank nodes too
|
|
19003
|
+
|
|
19004
|
+
if (!sub.uri) debug.warn("makeSelectForOptions: option does not have an uri: ".concat(sub, ", with predicate: ").concat(predicate));
|
|
19005
|
+
if (!sub.uri || sub.uri in uris) continue;
|
|
19006
|
+
uris[sub.uri] = true;
|
|
19007
|
+
n++;
|
|
19008
|
+
} // uris is now the set of possible options
|
|
19009
|
+
|
|
19010
|
+
|
|
19011
|
+
if (n === 0 && !options.mint) {
|
|
19012
|
+
return (0, _error.errorMessageBlock)(dom, "Can't do selector with no options, subject= " + subject + ' property = ' + predicate + '.');
|
|
19013
|
+
}
|
|
19014
|
+
|
|
19015
|
+
log.debug('makeSelectForOptions: dataDoc=' + dataDoc);
|
|
19016
|
+
|
|
19017
|
+
function determinFirstSelectOption() {
|
|
19018
|
+
var firstSelectOptionText = '--- classify ---';
|
|
19019
|
+
var option = dom.createElement('option');
|
|
19020
|
+
|
|
19021
|
+
if (predicate && !(predicate.termType === 'BlankNode')) {
|
|
19022
|
+
firstSelectOptionText = '* Select for property: ' + utils.label(predicate) + ' *';
|
|
19023
|
+
}
|
|
19024
|
+
|
|
19025
|
+
if (subject && !(subject.termType === 'BlankNode')) {
|
|
19026
|
+
firstSelectOptionText = '* Select for ' + utils.label(subject, true) + ' *';
|
|
19027
|
+
}
|
|
19028
|
+
|
|
19029
|
+
option.appendChild(dom.createTextNode(firstSelectOptionText));
|
|
19030
|
+
option.disabled = true;
|
|
19031
|
+
option.value = true;
|
|
19032
|
+
option.hidden = true;
|
|
19033
|
+
option.selected = true;
|
|
19034
|
+
return option;
|
|
19035
|
+
}
|
|
19036
|
+
|
|
19037
|
+
var onChange = function onChange(_e) {
|
|
19038
|
+
select.refresh();
|
|
19039
|
+
};
|
|
19040
|
+
|
|
19041
|
+
var select = dom.createElement('select');
|
|
19042
|
+
select.setAttribute('style', style.formSelectSTyle);
|
|
19043
|
+
if (options.multiSelect) select.setAttribute('multiSelect', 'true');
|
|
19044
|
+
select.currentURI = null;
|
|
19045
|
+
|
|
19046
|
+
for (var uri in uris) {
|
|
19047
|
+
select.appendChild(createOption(uri));
|
|
19048
|
+
}
|
|
19049
|
+
|
|
19050
|
+
if (editable && options.mint) {
|
|
19051
|
+
var mint = dom.createElement('option');
|
|
19052
|
+
mint.appendChild(dom.createTextNode(options.mint));
|
|
19053
|
+
mint.AJAR_mint = true; // Flag it
|
|
19054
|
+
|
|
19055
|
+
select.insertBefore(mint, select.firstChild);
|
|
19056
|
+
}
|
|
19057
|
+
|
|
19058
|
+
if (select.children.length === 0) select.insertBefore(determinFirstSelectOption(), select.firstChild);
|
|
19059
|
+
|
|
19060
|
+
select.refresh = function () {
|
|
19061
|
+
select.disabled = true; // unlocked any conflict we had got into
|
|
19062
|
+
|
|
19063
|
+
var ds = [];
|
|
19064
|
+
var is = [];
|
|
19065
|
+
|
|
19066
|
+
var removeValue = function removeValue(t) {
|
|
19067
|
+
if (kb.holds(subject, predicate, t, dataDoc)) {
|
|
19068
|
+
ds.push($rdf.st(subject, predicate, t, dataDoc));
|
|
19069
|
+
}
|
|
19070
|
+
};
|
|
19071
|
+
|
|
19072
|
+
var newObject;
|
|
19073
|
+
|
|
19074
|
+
for (var _i3 = 0; _i3 < select.options.length; _i3++) {
|
|
19075
|
+
var opt = select.options[_i3];
|
|
19076
|
+
|
|
19077
|
+
if (opt.selected && opt.AJAR_mint) {
|
|
19078
|
+
// not sure if this 'if' is used because I cannot find mintClass
|
|
19079
|
+
if (options.mintClass) {
|
|
19080
|
+
var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
|
|
19081
|
+
if (!ok) {
|
|
19082
|
+
callbackFunction(ok, body, {
|
|
19083
|
+
change: 'new'
|
|
19084
|
+
}); // @@ if ok, need some form of refresh of the select for the new thing
|
|
19085
|
+
}
|
|
19086
|
+
});
|
|
19087
|
+
select.parentNode.appendChild(thisForm);
|
|
19088
|
+
newObject = thisForm.AJAR_subject;
|
|
19089
|
+
} else {
|
|
19090
|
+
newObject = newThing(dataDoc);
|
|
19091
|
+
}
|
|
19092
|
+
|
|
19093
|
+
is.push($rdf.st(subject, predicate, kb.sym(newObject), dataDoc));
|
|
19094
|
+
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
|
|
19095
|
+
|
|
19096
|
+
if (options.mintStatementsFun) {
|
|
19097
|
+
is = is.concat(options.mintStatementsFun(newObject));
|
|
19098
|
+
}
|
|
19099
|
+
|
|
19100
|
+
select.currentURI = newObject;
|
|
19101
|
+
}
|
|
19102
|
+
|
|
19103
|
+
if (!opt.AJAR_uri) continue; // a prompt or mint
|
|
19104
|
+
|
|
19105
|
+
if (opt.selected) select.currentURI = opt.AJAR_uri;
|
|
19106
|
+
}
|
|
19107
|
+
|
|
19108
|
+
var sel = select.subSelect; // All subclasses must also go
|
|
19109
|
+
|
|
19110
|
+
while (sel && sel.currentURI) {
|
|
19111
|
+
removeValue(kb.sym(sel.currentURI));
|
|
19112
|
+
sel = sel.subSelect;
|
|
19113
|
+
}
|
|
19114
|
+
|
|
19115
|
+
sel = select.superSelect; // All superclasses are redundant
|
|
19116
|
+
|
|
19117
|
+
while (sel && sel.currentURI) {
|
|
19118
|
+
removeValue(kb.sym(sel.currentURI));
|
|
19119
|
+
sel = sel.superSelect;
|
|
19120
|
+
}
|
|
19121
|
+
|
|
19122
|
+
log.info('selectForOptions: data doc = ' + dataDoc);
|
|
19123
|
+
|
|
19124
|
+
if (select.currentURI) {
|
|
19125
|
+
removeNextSiblingsAfterElement(select);
|
|
19126
|
+
addSubFormChoice(dom, container, {}, $rdf.sym(select.currentURI), options.subForm, dataDoc, function (ok, body) {
|
|
19127
|
+
if (ok) {
|
|
19128
|
+
kb.updater.update(ds, is, function (uri, success, errorBody) {
|
|
19129
|
+
if (!success) container.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating select: ' + errorBody));
|
|
19130
|
+
});
|
|
19131
|
+
if (callbackFunction) callbackFunction(ok, {
|
|
19132
|
+
widget: 'select',
|
|
19133
|
+
event: 'new'
|
|
19134
|
+
}); // widgets.refreshTree(container)
|
|
19135
|
+
} else {
|
|
19136
|
+
container.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in field of select: ' + body));
|
|
19137
|
+
}
|
|
19138
|
+
});
|
|
19139
|
+
}
|
|
19140
|
+
|
|
19141
|
+
select.disabled = false;
|
|
19142
|
+
};
|
|
19143
|
+
|
|
19144
|
+
function createOption(uri) {
|
|
19145
|
+
var option = dom.createElement('option');
|
|
19146
|
+
var c = kb.sym(uri);
|
|
19147
|
+
|
|
19148
|
+
if (options.disambiguate) {
|
|
19149
|
+
option.appendChild(dom.createTextNode(utils.labelWithOntology(c, true))); // Init. cap
|
|
19150
|
+
} else {
|
|
19151
|
+
option.appendChild(dom.createTextNode(utils.label(c, true))); // Init.
|
|
19152
|
+
}
|
|
19153
|
+
|
|
19154
|
+
var backgroundColor = kb.any(c, kb.sym('http://www.w3.org/ns/ui#backgroundColor'));
|
|
19155
|
+
|
|
19156
|
+
if (backgroundColor) {
|
|
19157
|
+
option.setAttribute('style', 'background-color: ' + backgroundColor.value + '; ');
|
|
19158
|
+
}
|
|
19159
|
+
|
|
19160
|
+
option.AJAR_uri = uri;
|
|
19161
|
+
if (c.toString() === '' + select.currentURI) option.selected = true;
|
|
19162
|
+
return option;
|
|
19163
|
+
}
|
|
19164
|
+
|
|
19165
|
+
if (editable) {
|
|
19166
|
+
select.addEventListener('change', onChange, false);
|
|
19167
|
+
}
|
|
19168
|
+
|
|
19169
|
+
return select;
|
|
19170
|
+
} // makeSelectForChoice
|
|
19039
19171
|
//# sourceMappingURL=forms.js.map
|
|
19040
19172
|
|
|
19041
19173
|
/***/ }),
|