solid-ui 2.4.22-4e7a23dc → 2.4.22-62779f1d
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 +365 -186
- package/dist/main.js.map +1 -1
- 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 +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 +323 -159
- package/lib/widgets/forms.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -13914,9 +13914,9 @@ function tabWidget(options) {
|
|
|
13914
13914
|
var marginsPrepped = margins.concat(margins).slice(orientation, orientation + 4);
|
|
13915
13915
|
var marginsStyle = "margin: ".concat(marginsPrepped.join(' '), ";");
|
|
13916
13916
|
var paddingStyle = "padding: ".concat(marginsPrepped.join(' '), ";");
|
|
13917
|
-
var tabStyle = cornersStyle + "padding: 0.7em; max-width: 20em; color: ".concat(color, ";");
|
|
13918
|
-
var unselectedStyle = "".concat(tabStyle + marginsStyle, "opacity: 50%; background-color: ").concat(backgroundColor, ";");
|
|
13919
|
-
var selectedStyle = "".concat(tabStyle + marginsStyle, "background-color: ").concat(selectedColor, ";");
|
|
13917
|
+
var tabStyle = cornersStyle + "position: relative; padding: 0.7em; max-width: 20em; color: ".concat(color, ";");
|
|
13918
|
+
var unselectedStyle = "".concat(tabStyle + marginsStyle, " opacity: 50%; background-color: ").concat(backgroundColor, ";");
|
|
13919
|
+
var selectedStyle = "".concat(tabStyle + marginsStyle, " background-color: ").concat(selectedColor, ";");
|
|
13920
13920
|
var shownStyle = 'height: 100%; width: 100%;';
|
|
13921
13921
|
var hiddenStyle = shownStyle + 'display: none;';
|
|
13922
13922
|
rootElement.refresh = orderedSync;
|
|
@@ -13976,35 +13976,50 @@ function tabWidget(options) {
|
|
|
13976
13976
|
|
|
13977
13977
|
function makeNewSlot(item) {
|
|
13978
13978
|
var ele = dom.createElement(tabElement);
|
|
13979
|
+
ele.setAttribute('style', unselectedStyle);
|
|
13979
13980
|
ele.subject = item;
|
|
13980
|
-
var div = ele.appendChild(dom.createElement('
|
|
13981
|
-
div.setAttribute('style',
|
|
13982
|
-
|
|
13983
|
-
|
|
13984
|
-
|
|
13985
|
-
|
|
13981
|
+
var div = ele.appendChild(dom.createElement('button'));
|
|
13982
|
+
div.setAttribute('style', 'background: none; border: none; font: inherit; cursor: pointer');
|
|
13983
|
+
var ellipsis = dom.createElement('button');
|
|
13984
|
+
ellipsis.textContent = '...';
|
|
13985
|
+
ellipsis.setAttribute('style', 'position: absolute; right: 0; bottom: 0; width: 20%; background: none; color: inherit; border: none; padding: 0; font: inherit; cursor: pointer; outline: inherit;');
|
|
13986
|
+
|
|
13987
|
+
div.onclick = function () {
|
|
13988
|
+
resetTabStyle();
|
|
13989
|
+
resetBodyStyle();
|
|
13990
|
+
ele.setAttribute('style', selectedStyle);
|
|
13991
|
+
if (!ele.bodyTR) return;
|
|
13992
|
+
ele.bodyTR.setAttribute('style', shownStyle);
|
|
13993
|
+
var bodyMain = getOrCreateContainerElement(ele);
|
|
13994
|
+
|
|
13995
|
+
if (options.renderMain && ele.subject && bodyMain.asSettings !== false) {
|
|
13996
|
+
bodyMain.innerHTML = 'loading item ...' + item;
|
|
13997
|
+
options.renderMain(bodyMain, ele.subject);
|
|
13998
|
+
bodyMain.asSettings = false;
|
|
13986
13999
|
}
|
|
14000
|
+
};
|
|
13987
14001
|
|
|
13988
|
-
|
|
14002
|
+
ellipsis.onclick = function () {
|
|
14003
|
+
resetTabStyle();
|
|
14004
|
+
resetBodyStyle();
|
|
14005
|
+
ele.setAttribute('style', selectedStyle);
|
|
13989
14006
|
if (!ele.bodyTR) return;
|
|
13990
14007
|
ele.bodyTR.setAttribute('style', shownStyle);
|
|
13991
14008
|
var bodyMain = getOrCreateContainerElement(ele);
|
|
13992
14009
|
|
|
13993
|
-
if (options.renderTabSettings &&
|
|
14010
|
+
if (options.renderTabSettings && ele.subject && bodyMain.asSettings !== true) {
|
|
13994
14011
|
bodyMain.innerHTML = 'loading settings ...' + item;
|
|
13995
14012
|
options.renderTabSettings(bodyMain, ele.subject);
|
|
13996
14013
|
bodyMain.asSettings = true;
|
|
13997
|
-
} else if (options.renderMain && ele.subject && bodyMain.asSettings !== false) {
|
|
13998
|
-
bodyMain.innerHTML = 'loading item ...' + item;
|
|
13999
|
-
options.renderMain(bodyMain, ele.subject);
|
|
14000
|
-
bodyMain.asSettings = false;
|
|
14001
14014
|
}
|
|
14002
|
-
}
|
|
14015
|
+
};
|
|
14003
14016
|
|
|
14004
14017
|
if (options.renderTab) {
|
|
14005
14018
|
options.renderTab(div, item);
|
|
14019
|
+
ele.appendChild(ellipsis);
|
|
14006
14020
|
} else {
|
|
14007
|
-
div.
|
|
14021
|
+
div.innerHTML = (0, _utils.label)(item);
|
|
14022
|
+
ele.appendChild(ellipsis);
|
|
14008
14023
|
}
|
|
14009
14024
|
|
|
14010
14025
|
return ele;
|
|
@@ -14084,10 +14099,8 @@ function tabWidget(options) {
|
|
|
14084
14099
|
|
|
14085
14100
|
if (_tab.classList.contains('unstyled')) {
|
|
14086
14101
|
continue;
|
|
14087
|
-
}
|
|
14088
|
-
|
|
14089
|
-
if (_tab.children[0]) {
|
|
14090
|
-
_tab.children[0].setAttribute('style', unselectedStyle);
|
|
14102
|
+
} else {
|
|
14103
|
+
_tab.setAttribute('style', unselectedStyle);
|
|
14091
14104
|
}
|
|
14092
14105
|
}
|
|
14093
14106
|
}
|
|
@@ -15172,7 +15185,7 @@ function slice(s, suffix) {
|
|
|
15172
15185
|
|
|
15173
15186
|
function getWellKnownLabel(thing) {
|
|
15174
15187
|
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'));
|
|
15188
|
+
_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
15189
|
}
|
|
15177
15190
|
//# sourceMappingURL=label.js.map
|
|
15178
15191
|
|
|
@@ -15192,11 +15205,11 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
15192
15205
|
}));
|
|
15193
15206
|
exports.versionInfo = void 0;
|
|
15194
15207
|
var versionInfo = {
|
|
15195
|
-
buildTime: '2022-05-
|
|
15196
|
-
commit: '
|
|
15208
|
+
buildTime: '2022-05-25T07:28:38Z',
|
|
15209
|
+
commit: '62779f1dbf177b64898b43dc69f011f10a8b1cf8',
|
|
15197
15210
|
npmInfo: {
|
|
15198
15211
|
'solid-ui': '2.4.22',
|
|
15199
|
-
npm: '6.14.
|
|
15212
|
+
npm: '6.14.17',
|
|
15200
15213
|
ares: '1.18.1',
|
|
15201
15214
|
brotli: '1.0.9',
|
|
15202
15215
|
cldr: '40.0',
|
|
@@ -15205,12 +15218,12 @@ var versionInfo = {
|
|
|
15205
15218
|
modules: '83',
|
|
15206
15219
|
napi: '8',
|
|
15207
15220
|
nghttp2: '1.42.0',
|
|
15208
|
-
node: '14.19.
|
|
15221
|
+
node: '14.19.2',
|
|
15209
15222
|
openssl: '1.1.1n',
|
|
15210
15223
|
tz: '2021a3',
|
|
15211
15224
|
unicode: '14.0',
|
|
15212
15225
|
uv: '1.42.0',
|
|
15213
|
-
v8: '8.4.371.23-node.
|
|
15226
|
+
v8: '8.4.371.23-node.87',
|
|
15214
15227
|
zlib: '1.2.11'
|
|
15215
15228
|
}
|
|
15216
15229
|
};
|
|
@@ -16280,6 +16293,7 @@ function openHrefInOutlineMode(e) {
|
|
|
16280
16293
|
|
|
16281
16294
|
if (dom.outlineManager) {
|
|
16282
16295
|
// @@ TODO Remove the use of document as a global object
|
|
16296
|
+
// TODO fix dependency cycle to solid-panes by calling outlineManager
|
|
16283
16297
|
;
|
|
16284
16298
|
dom.outlineManager.GotoSubject(_solidLogic.store.sym(uri), true, undefined, true, undefined);
|
|
16285
16299
|
} else if (window && window.panes && window.panes.getOutliner) {
|
|
@@ -16407,6 +16421,7 @@ function linkButton(dom, object) {
|
|
|
16407
16421
|
b.textContent = 'Goto ' + utils.label(object);
|
|
16408
16422
|
b.addEventListener('click', function (_event) {
|
|
16409
16423
|
// b.parentNode.removeChild(b)
|
|
16424
|
+
// TODO fix dependency cycle to solid-panes by calling outlineManager
|
|
16410
16425
|
;
|
|
16411
16426
|
dom.outlineManager.GotoSubject(object, true, undefined, true, undefined);
|
|
16412
16427
|
}, true);
|
|
@@ -17147,6 +17162,7 @@ exports.findClosest = findClosest;
|
|
|
17147
17162
|
exports.formsFor = formsFor;
|
|
17148
17163
|
exports.makeDescription = makeDescription;
|
|
17149
17164
|
exports.makeSelectForCategory = makeSelectForCategory;
|
|
17165
|
+
exports.makeSelectForChoice = makeSelectForChoice;
|
|
17150
17166
|
exports.makeSelectForNestedCategory = makeSelectForNestedCategory;
|
|
17151
17167
|
exports.makeSelectForOptions = makeSelectForOptions;
|
|
17152
17168
|
exports.newButton = newButton;
|
|
@@ -17258,14 +17274,16 @@ _fieldFunction.field[ns.ui('Form').uri] = _fieldFunction.field[ns.ui('Group').ur
|
|
|
17258
17274
|
var ui = ns.ui;
|
|
17259
17275
|
if (container) container.appendChild(box); // Prevent loops
|
|
17260
17276
|
|
|
17277
|
+
if (!form) return;
|
|
17261
17278
|
var key = subject.toNT() + '|' + form.toNT();
|
|
17262
17279
|
|
|
17263
17280
|
if (already[key]) {
|
|
17264
17281
|
// been there done that
|
|
17265
|
-
box.appendChild(dom.createTextNode('Group: see above ' + key));
|
|
17266
|
-
|
|
17282
|
+
box.appendChild(dom.createTextNode('Group: see above ' + key)); // TODO fix dependency cycle to solid-panes by calling outlineManager
|
|
17283
|
+
// const plist = [$rdf.st(subject, ns.owl('sameAs'), subject)] // @@ need prev subject
|
|
17284
|
+
// dom.outlineManager.appendPropertyTRs(box, plist)
|
|
17285
|
+
// dom.appendChild(plist)
|
|
17267
17286
|
|
|
17268
|
-
dom.outlineManager.appendPropertyTRs(box, plist);
|
|
17269
17287
|
return box;
|
|
17270
17288
|
}
|
|
17271
17289
|
|
|
@@ -17366,47 +17384,43 @@ _fieldFunction.field[ns.ui('Options').uri] = function (dom, container, already,
|
|
|
17366
17384
|
values = kb.each(subject, dependingOn);
|
|
17367
17385
|
}
|
|
17368
17386
|
|
|
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'
|
|
17387
|
+
for (var i = 0; i < cases.length; i++) {
|
|
17388
|
+
var c = cases[i];
|
|
17389
|
+
var tests = kb.each(c, ui('for'), null, formDoc); // There can be multiple 'for'
|
|
17375
17390
|
|
|
17376
|
-
|
|
17391
|
+
var match = false;
|
|
17377
17392
|
|
|
17378
|
-
|
|
17379
|
-
|
|
17380
|
-
|
|
17393
|
+
for (var j = 0; j < tests.length; j++) {
|
|
17394
|
+
var _iterator = _createForOfIteratorHelper(values),
|
|
17395
|
+
_step;
|
|
17381
17396
|
|
|
17382
|
-
|
|
17383
|
-
|
|
17384
|
-
|
|
17385
|
-
|
|
17397
|
+
try {
|
|
17398
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
17399
|
+
var value = _step.value;
|
|
17400
|
+
var test = tests[j];
|
|
17386
17401
|
|
|
17387
|
-
|
|
17388
|
-
|
|
17389
|
-
}
|
|
17402
|
+
if (value.sameTerm(tests) || value.termType === test.termType && value.value === test.value) {
|
|
17403
|
+
match = true;
|
|
17390
17404
|
}
|
|
17391
|
-
} catch (err) {
|
|
17392
|
-
_iterator.e(err);
|
|
17393
|
-
} finally {
|
|
17394
|
-
_iterator.f();
|
|
17395
17405
|
}
|
|
17406
|
+
} catch (err) {
|
|
17407
|
+
_iterator.e(err);
|
|
17408
|
+
} finally {
|
|
17409
|
+
_iterator.f();
|
|
17396
17410
|
}
|
|
17411
|
+
}
|
|
17397
17412
|
|
|
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
|
-
}
|
|
17413
|
+
if (match) {
|
|
17414
|
+
var _field3 = kb.the(c, ui('use'));
|
|
17407
17415
|
|
|
17408
|
-
|
|
17416
|
+
if (!_field3) {
|
|
17417
|
+
box.appendChild((0, _error.errorMessageBlock)(dom, 'No "use" part for case in form ' + form));
|
|
17418
|
+
return box;
|
|
17419
|
+
} else {
|
|
17420
|
+
appendForm(dom, box, already, subject, _field3, dataDoc, callbackFunction);
|
|
17409
17421
|
}
|
|
17422
|
+
|
|
17423
|
+
break;
|
|
17410
17424
|
}
|
|
17411
17425
|
} // @@ Add box.refresh() to sync fields with values
|
|
17412
17426
|
|
|
@@ -17694,7 +17708,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
17694
17708
|
// delete button and move buttons
|
|
17695
17709
|
|
|
17696
17710
|
if (kb.updater.editable(dataDoc.uri)) {
|
|
17697
|
-
buttons.deleteButtonWithCheck(dom, subField,
|
|
17711
|
+
buttons.deleteButtonWithCheck(dom, subField, multipleUIlabel, deleteThisItem);
|
|
17698
17712
|
|
|
17699
17713
|
if (ordered) {
|
|
17700
17714
|
// Add controsl in a frame
|
|
@@ -17745,7 +17759,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
17745
17759
|
|
|
17746
17760
|
var _shim = dom.createElement('div');
|
|
17747
17761
|
|
|
17748
|
-
_shim.appendChild(subField); // Subfield has its own
|
|
17762
|
+
_shim.appendChild(subField); // Subfield has its own layout
|
|
17749
17763
|
|
|
17750
17764
|
|
|
17751
17765
|
frame.appendChild(_shim);
|
|
@@ -17794,6 +17808,8 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
17794
17808
|
return shim;
|
|
17795
17809
|
}
|
|
17796
17810
|
|
|
17811
|
+
var multipleUIlabel = kb.any(form, ui('label'));
|
|
17812
|
+
if (!multipleUIlabel) multipleUIlabel = utils.label(property);
|
|
17797
17813
|
var min = kb.any(form, ui('min')); // This is the minimum number -- default 0
|
|
17798
17814
|
|
|
17799
17815
|
min = min ? 0 + min.value : 0;
|
|
@@ -17834,10 +17850,9 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
17834
17850
|
img.setAttribute('src', plusIconURI); // plus sign
|
|
17835
17851
|
|
|
17836
17852
|
img.setAttribute('style', 'margin: 0.2em; width: 1.5em; height:1.5em');
|
|
17837
|
-
img.title = 'Click to add
|
|
17838
|
-
var prompt =
|
|
17839
|
-
prompt.textContent = (values.length === 0 ? 'Add
|
|
17840
|
-
|
|
17853
|
+
img.title = 'Click to add another ' + multipleUIlabel;
|
|
17854
|
+
var prompt = dom.createElement('span');
|
|
17855
|
+
prompt.textContent = (values.length === 0 ? 'Add another ' : 'Add ') + multipleUIlabel;
|
|
17841
17856
|
tail.addEventListener('click', /*#__PURE__*/function () {
|
|
17842
17857
|
var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(_eventNotUsed) {
|
|
17843
17858
|
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
@@ -17859,6 +17874,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
17859
17874
|
return _ref3.apply(this, arguments);
|
|
17860
17875
|
};
|
|
17861
17876
|
}(), true);
|
|
17877
|
+
tail.appendChild(prompt);
|
|
17862
17878
|
}
|
|
17863
17879
|
|
|
17864
17880
|
function createListIfNecessary() {
|
|
@@ -18120,28 +18136,39 @@ _fieldFunction.field[ns.ui('Classifier').uri] = function (dom, container, alread
|
|
|
18120
18136
|
**
|
|
18121
18137
|
** Not nested. Generates a link to something from a given class.
|
|
18122
18138
|
** Optional subform for the thing selected.
|
|
18139
|
+
** Generates a subForm based on a ui:use form
|
|
18140
|
+
** Will look like:
|
|
18141
|
+
** <div id=dropDownDiv>
|
|
18142
|
+
** <div id=labelOfDropDown>
|
|
18143
|
+
** <div id=selectDiv>
|
|
18144
|
+
** <select id=dropDownSelect>
|
|
18145
|
+
** <option> ....
|
|
18146
|
+
** <subForm>
|
|
18123
18147
|
** Alternative implementatons caould be:
|
|
18124
18148
|
** -- pop-up menu (as here)
|
|
18125
18149
|
** -- radio buttons
|
|
18126
18150
|
** -- auto-complete typing
|
|
18127
18151
|
**
|
|
18128
|
-
**
|
|
18152
|
+
** TODO: according to ontology ui:choice can also have ns.ui('default') - this is not implemented yet
|
|
18129
18153
|
*/
|
|
18130
18154
|
|
|
18131
18155
|
|
|
18132
18156
|
_fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) {
|
|
18133
18157
|
var ui = ns.ui;
|
|
18134
18158
|
var kb = _solidLogic.store;
|
|
18135
|
-
var multiple = false;
|
|
18136
18159
|
var formDoc = form.doc ? form.doc() : null; // @@ if blank no way to know
|
|
18137
18160
|
|
|
18161
|
+
var multiSelect = false;
|
|
18138
18162
|
var p;
|
|
18139
|
-
var box = dom.createElement('div');
|
|
18163
|
+
var box = dom.createElement('div');
|
|
18164
|
+
box.setAttribute('class', 'choiceBox'); // Set flexDirection column?
|
|
18140
18165
|
|
|
18141
18166
|
if (container) container.appendChild(box);
|
|
18142
18167
|
var lhs = dom.createElement('div');
|
|
18168
|
+
lhs.setAttribute('class', 'formFieldName choiceBox-label');
|
|
18143
18169
|
box.appendChild(lhs);
|
|
18144
18170
|
var rhs = dom.createElement('div');
|
|
18171
|
+
rhs.setAttribute('class', 'formFieldValue choiceBox-selectBox');
|
|
18145
18172
|
box.appendChild(rhs);
|
|
18146
18173
|
var property = kb.any(form, ui('property'));
|
|
18147
18174
|
|
|
@@ -18150,9 +18177,9 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
18150
18177
|
}
|
|
18151
18178
|
|
|
18152
18179
|
lhs.appendChild((0, _basic.fieldLabel)(dom, property, form));
|
|
18153
|
-
var
|
|
18180
|
+
var uiFrom = kb.any(form, ui('from'));
|
|
18154
18181
|
|
|
18155
|
-
if (!
|
|
18182
|
+
if (!uiFrom) {
|
|
18156
18183
|
return (0, _error.errorMessageBlock)(dom, "No 'from' for Choice: " + form);
|
|
18157
18184
|
}
|
|
18158
18185
|
|
|
@@ -18160,77 +18187,97 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
18160
18187
|
|
|
18161
18188
|
var follow = kb.anyJS(form, ui('follow'), null, formDoc); // data doc moves to new subject?
|
|
18162
18189
|
|
|
18163
|
-
var possible = [];
|
|
18164
|
-
var possibleProperties;
|
|
18165
|
-
var nullLabel = '--' + utils.label(property) + '-?';
|
|
18166
18190
|
var opts = {
|
|
18167
18191
|
form: form,
|
|
18168
|
-
|
|
18169
|
-
|
|
18192
|
+
subForm: subForm,
|
|
18193
|
+
multiSelect: multiSelect,
|
|
18170
18194
|
disambiguate: false
|
|
18171
18195
|
};
|
|
18172
|
-
possible = kb.each(undefined, ns.rdf('type'), from, formDoc);
|
|
18173
18196
|
|
|
18174
|
-
|
|
18175
|
-
possible
|
|
18176
|
-
|
|
18197
|
+
function getSelectorOptions() {
|
|
18198
|
+
var possible = [];
|
|
18199
|
+
var possibleProperties;
|
|
18200
|
+
possible = kb.each(undefined, ns.rdf('type'), uiFrom, formDoc);
|
|
18177
18201
|
|
|
18202
|
+
for (var x in kb.findMembersNT(uiFrom)) {
|
|
18203
|
+
possible.push(kb.fromNT(x));
|
|
18204
|
+
} // Use rdfs
|
|
18178
18205
|
|
|
18179
|
-
if (from.sameTerm(ns.rdfs('Class'))) {
|
|
18180
|
-
for (p in buttons.allClassURIs()) {
|
|
18181
|
-
possible.push(kb.sym(p));
|
|
18182
|
-
} // log.debug("%%% Choice field: possible.length 2 = "+possible.length)
|
|
18183
18206
|
|
|
18184
|
-
|
|
18185
|
-
|
|
18207
|
+
if (uiFrom.sameTerm(ns.rdfs('Class'))) {
|
|
18208
|
+
for (p in buttons.allClassURIs()) {
|
|
18209
|
+
possible.push(kb.sym(p));
|
|
18210
|
+
} // log.debug("%%% Choice field: possible.length 2 = "+possible.length)
|
|
18186
18211
|
|
|
18187
|
-
|
|
18188
|
-
|
|
18189
|
-
}
|
|
18212
|
+
} else if (uiFrom.sameTerm(ns.rdf('Property'))) {
|
|
18213
|
+
possibleProperties = buttons.propertyTriage(kb);
|
|
18190
18214
|
|
|
18191
|
-
|
|
18192
|
-
|
|
18193
|
-
|
|
18215
|
+
for (p in possibleProperties.op) {
|
|
18216
|
+
possible.push(kb.fromNT(p));
|
|
18217
|
+
}
|
|
18194
18218
|
|
|
18195
|
-
|
|
18196
|
-
|
|
18197
|
-
|
|
18219
|
+
for (p in possibleProperties.dp) {
|
|
18220
|
+
possible.push(kb.fromNT(p));
|
|
18221
|
+
}
|
|
18198
18222
|
|
|
18199
|
-
|
|
18200
|
-
|
|
18201
|
-
|
|
18223
|
+
opts.disambiguate = true; // This is a big class, and the labels won't be enough.
|
|
18224
|
+
} else if (uiFrom.sameTerm(ns.owl('ObjectProperty'))) {
|
|
18225
|
+
possibleProperties = buttons.propertyTriage(kb);
|
|
18202
18226
|
|
|
18203
|
-
|
|
18204
|
-
|
|
18205
|
-
|
|
18227
|
+
for (p in possibleProperties.op) {
|
|
18228
|
+
possible.push(kb.fromNT(p));
|
|
18229
|
+
}
|
|
18206
18230
|
|
|
18207
|
-
|
|
18208
|
-
|
|
18231
|
+
opts.disambiguate = true;
|
|
18232
|
+
} else if (uiFrom.sameTerm(ns.owl('DatatypeProperty'))) {
|
|
18233
|
+
possibleProperties = buttons.propertyTriage(kb);
|
|
18234
|
+
|
|
18235
|
+
for (p in possibleProperties.dp) {
|
|
18236
|
+
possible.push(kb.fromNT(p));
|
|
18237
|
+
}
|
|
18238
|
+
|
|
18239
|
+
opts.disambiguate = true;
|
|
18209
18240
|
}
|
|
18210
18241
|
|
|
18211
|
-
|
|
18212
|
-
|
|
18242
|
+
var object = kb.any(subject, property);
|
|
18243
|
+
if (object) possible.push(object);
|
|
18244
|
+
return sortByLabel(possible);
|
|
18245
|
+
} // TODO: this checks for any occurrence, regardless of true or false setting
|
|
18213
18246
|
|
|
18214
|
-
var object = kb.any(subject, property);
|
|
18215
18247
|
|
|
18216
|
-
|
|
18217
|
-
|
|
18218
|
-
(0, _fieldFunction.fieldFunction)(dom, subForm)(dom, rhs, already, object, subForm, follow ? object.doc() : dataDoc, callbackFunction);
|
|
18248
|
+
if (kb.any(form, ui('canMintNew'))) {
|
|
18249
|
+
opts.mint = '* Create new *'; // @@ could be better
|
|
18219
18250
|
}
|
|
18220
18251
|
|
|
18221
|
-
var
|
|
18252
|
+
var selector;
|
|
18222
18253
|
|
|
18223
|
-
|
|
18224
|
-
|
|
18254
|
+
rhs.refresh = function () {
|
|
18255
|
+
var selectorOptions = getSelectorOptions();
|
|
18256
|
+
selector = makeSelectForChoice(dom, rhs, kb, subject, property, selectorOptions, uiFrom, opts, dataDoc, callbackFunction);
|
|
18257
|
+
rhs.innerHTML = '';
|
|
18258
|
+
rhs.appendChild(selector);
|
|
18259
|
+
};
|
|
18225
18260
|
|
|
18226
|
-
|
|
18261
|
+
rhs.refresh();
|
|
18262
|
+
if (selector && selector.refresh) selector.refresh();
|
|
18263
|
+
return box;
|
|
18264
|
+
};
|
|
18265
|
+
/**
|
|
18266
|
+
* Removes all sibling elements after specified
|
|
18267
|
+
* @param {HTMLElement} currentElement
|
|
18268
|
+
* @private
|
|
18269
|
+
*/
|
|
18270
|
+
|
|
18271
|
+
|
|
18272
|
+
function removeNextSiblingsAfterElement(currentElement) {
|
|
18273
|
+
while (currentElement.nextElementSibling) {
|
|
18274
|
+
currentElement.nextElementSibling.remove();
|
|
18227
18275
|
}
|
|
18276
|
+
}
|
|
18228
18277
|
|
|
18229
|
-
|
|
18230
|
-
|
|
18231
|
-
|
|
18232
|
-
return box;
|
|
18233
|
-
}; // Documentation - non-interactive fields
|
|
18278
|
+
function addSubFormChoice(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction) {
|
|
18279
|
+
(0, _fieldFunction.fieldFunction)(dom, subForm)(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction);
|
|
18280
|
+
} // Documentation - non-interactive fields
|
|
18234
18281
|
//
|
|
18235
18282
|
|
|
18236
18283
|
|
|
@@ -18433,7 +18480,8 @@ function promptForNew(dom, kb, subject, predicate, theClass, form, dataDoc, call
|
|
|
18433
18480
|
b.setAttribute('type', 'button');
|
|
18434
18481
|
b.setAttribute('style', 'float: right;');
|
|
18435
18482
|
b.innerHTML = 'Goto ' + utils.label(theClass);
|
|
18436
|
-
b.addEventListener('click',
|
|
18483
|
+
b.addEventListener('click', // TODO fix dependency cycle to solid-panes by calling outlineManager
|
|
18484
|
+
function (_e) {
|
|
18437
18485
|
dom.outlineManager.GotoSubject(theClass, true, undefined, true, undefined);
|
|
18438
18486
|
}, false);
|
|
18439
18487
|
return box;
|
|
@@ -18568,10 +18616,8 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
|
|
|
18568
18616
|
// @param subject - a term, the subject of the statement(s) being edited.
|
|
18569
18617
|
// @param predicate - a term, the predicate of the statement(s) being edited
|
|
18570
18618
|
// @param possible - a list of terms, the possible value the object can take
|
|
18571
|
-
// @param options.multiple - Boolean - Whether more than one at a time is allowed
|
|
18572
18619
|
// @param options.nullLabel - a string to be displayed as the
|
|
18573
18620
|
// option for none selected (for non multiple)
|
|
18574
|
-
// @param options.mint - User may create thing if this sent to the prompt string eg "New foo"
|
|
18575
18621
|
// @param options.subForm - If mint, then the form to be used for minting the new thing
|
|
18576
18622
|
// @param dataDoc - The web document being edited
|
|
18577
18623
|
// @param callbackFunction - takes (boolean ok, string errorBody)
|
|
@@ -18595,7 +18641,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
|
|
|
18595
18641
|
} // uris is now the set of possible options
|
|
18596
18642
|
|
|
18597
18643
|
|
|
18598
|
-
if (n === 0
|
|
18644
|
+
if (n === 0) {
|
|
18599
18645
|
return (0, _error.errorMessageBlock)(dom, "Can't do selector with no options, subject= " + subject + ' property = ' + predicate + '.');
|
|
18600
18646
|
}
|
|
18601
18647
|
|
|
@@ -18609,7 +18655,9 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
|
|
|
18609
18655
|
actual = kb.findTypeURIs(subject);
|
|
18610
18656
|
} else {
|
|
18611
18657
|
kb.each(subject, predicate, null, dataDoc).forEach(function (x) {
|
|
18612
|
-
|
|
18658
|
+
if (x.uri) {
|
|
18659
|
+
actual[x.uri] = true;
|
|
18660
|
+
}
|
|
18613
18661
|
});
|
|
18614
18662
|
}
|
|
18615
18663
|
|
|
@@ -18630,33 +18678,8 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
|
|
|
18630
18678
|
}
|
|
18631
18679
|
};
|
|
18632
18680
|
|
|
18633
|
-
var newObject;
|
|
18634
|
-
|
|
18635
18681
|
for (var _i = 0; _i < select.options.length; _i++) {
|
|
18636
18682
|
var opt = select.options[_i];
|
|
18637
|
-
|
|
18638
|
-
if (opt.selected && opt.AJAR_mint) {
|
|
18639
|
-
if (options.mintClass) {
|
|
18640
|
-
var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
|
|
18641
|
-
if (!ok) {
|
|
18642
|
-
callbackFunction(ok, body, {
|
|
18643
|
-
change: 'new'
|
|
18644
|
-
}); // @@ if ok, need some form of refresh of the select for the new thing
|
|
18645
|
-
}
|
|
18646
|
-
});
|
|
18647
|
-
select.parentNode.appendChild(thisForm);
|
|
18648
|
-
newObject = thisForm.AJAR_subject;
|
|
18649
|
-
} else {
|
|
18650
|
-
newObject = newThing(dataDoc);
|
|
18651
|
-
}
|
|
18652
|
-
|
|
18653
|
-
is.push($rdf.st(subject, predicate, newObject, dataDoc));
|
|
18654
|
-
|
|
18655
|
-
if (options.mintStatementsFun) {
|
|
18656
|
-
is = is.concat(options.mintStatementsFun(newObject));
|
|
18657
|
-
}
|
|
18658
|
-
}
|
|
18659
|
-
|
|
18660
18683
|
if (!opt.AJAR_uri) continue; // a prompt or mint
|
|
18661
18684
|
|
|
18662
18685
|
if (opt.selected && !(opt.AJAR_uri in actual)) {
|
|
@@ -18686,24 +18709,12 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
|
|
|
18686
18709
|
sel = sel.superSelect;
|
|
18687
18710
|
}
|
|
18688
18711
|
|
|
18689
|
-
function doneNew(ok, _body) {
|
|
18690
|
-
callbackFunction(ok, {
|
|
18691
|
-
widget: 'select',
|
|
18692
|
-
event: 'new'
|
|
18693
|
-
});
|
|
18694
|
-
}
|
|
18695
|
-
|
|
18696
18712
|
log.info('selectForOptions: data doc = ' + dataDoc);
|
|
18697
18713
|
kb.updater.update(ds, is, function (uri, ok, body) {
|
|
18698
18714
|
actual = getActual(); // refresh
|
|
18699
18715
|
|
|
18700
18716
|
if (ok) {
|
|
18701
18717
|
select.disabled = false; // data written back
|
|
18702
|
-
|
|
18703
|
-
if (newObject) {
|
|
18704
|
-
var fn = (0, _fieldFunction.fieldFunction)(dom, options.subForm);
|
|
18705
|
-
fn(dom, select.parentNode, {}, newObject, options.subForm, dataDoc, doneNew);
|
|
18706
|
-
}
|
|
18707
18718
|
} else {
|
|
18708
18719
|
return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in select: ' + body));
|
|
18709
18720
|
}
|
|
@@ -18717,7 +18728,6 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
|
|
|
18717
18728
|
|
|
18718
18729
|
var select = dom.createElement('select');
|
|
18719
18730
|
select.setAttribute('style', style.formSelectSTyle);
|
|
18720
|
-
if (options.multiple) select.setAttribute('multiple', 'true');
|
|
18721
18731
|
select.currentURI = null;
|
|
18722
18732
|
|
|
18723
18733
|
select.refresh = function () {
|
|
@@ -18760,15 +18770,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
|
|
|
18760
18770
|
select.appendChild(option);
|
|
18761
18771
|
}
|
|
18762
18772
|
|
|
18763
|
-
if (
|
|
18764
|
-
var mint = dom.createElement('option');
|
|
18765
|
-
mint.appendChild(dom.createTextNode(options.mint));
|
|
18766
|
-
mint.AJAR_mint = true; // Flag it
|
|
18767
|
-
|
|
18768
|
-
select.insertBefore(mint, select.firstChild);
|
|
18769
|
-
}
|
|
18770
|
-
|
|
18771
|
-
if (select.currentURI == null && !options.multiple) {
|
|
18773
|
+
if (!select.currentURI) {
|
|
18772
18774
|
var prompt = dom.createElement('option');
|
|
18773
18775
|
prompt.appendChild(dom.createTextNode(options.nullLabel));
|
|
18774
18776
|
select.insertBefore(prompt, select.firstChild);
|
|
@@ -18791,28 +18793,16 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
|
|
|
18791
18793
|
function makeSelectForCategory(dom, kb, subject, category, dataDoc, callbackFunction) {
|
|
18792
18794
|
var du = kb.any(category, ns.owl('disjointUnionOf'));
|
|
18793
18795
|
var subs;
|
|
18794
|
-
var multiple = false;
|
|
18795
18796
|
|
|
18796
18797
|
if (!du) {
|
|
18797
18798
|
subs = kb.each(undefined, ns.rdfs('subClassOf'), category);
|
|
18798
|
-
multiple = true;
|
|
18799
18799
|
} else {
|
|
18800
18800
|
subs = du.elements;
|
|
18801
18801
|
}
|
|
18802
18802
|
|
|
18803
18803
|
log.debug('Select list length ' + subs.length);
|
|
18804
|
-
|
|
18805
|
-
if (subs.length === 0) {
|
|
18806
|
-
return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with no subclasses of category: ' + category);
|
|
18807
|
-
}
|
|
18808
|
-
|
|
18809
|
-
if (subs.length === 1) {
|
|
18810
|
-
return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with only 1 subclass of category: ' + category + ':' + subs[1]);
|
|
18811
|
-
}
|
|
18812
|
-
|
|
18813
18804
|
return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, {
|
|
18814
|
-
|
|
18815
|
-
nullPrompt: '--classify--'
|
|
18805
|
+
nullLabel: '* Select type *'
|
|
18816
18806
|
}, dataDoc, callbackFunction);
|
|
18817
18807
|
}
|
|
18818
18808
|
/** Make SELECT element to select subclasses recurively
|
|
@@ -18846,8 +18836,7 @@ function makeSelectForNestedCategory(dom, kb, subject, category, dataDoc, callba
|
|
|
18846
18836
|
function onChange(ok, body) {
|
|
18847
18837
|
if (ok) update();
|
|
18848
18838
|
callbackFunction(ok, body);
|
|
18849
|
-
}
|
|
18850
|
-
|
|
18839
|
+
}
|
|
18851
18840
|
|
|
18852
18841
|
var select = makeSelectForCategory(dom, kb, subject, category, dataDoc, onChange);
|
|
18853
18842
|
container.appendChild(select);
|
|
@@ -19002,6 +18991,196 @@ function newThing(doc) {
|
|
|
19002
18991
|
var now = new Date();
|
|
19003
18992
|
return $rdf.sym(doc.uri + '#' + 'id' + ('' + now.getTime()));
|
|
19004
18993
|
}
|
|
18994
|
+
/** Make SELECT element to select options
|
|
18995
|
+
//
|
|
18996
|
+
// @param subject - a term, the subject of the statement(s) being edited.
|
|
18997
|
+
// @param predicate - a term, the predicate of the statement(s) being edited
|
|
18998
|
+
// @param possible - a list of terms, the possible value the object can take
|
|
18999
|
+
// @param options.multiSelect - Boolean - Whether more than one at a time is allowed
|
|
19000
|
+
// @param options.uiMultipleInUse - signals that the ui:choise is used with a ui:multiple
|
|
19001
|
+
// @param options.mint - User may create thing if this sent to the prompt string eg "New foo"
|
|
19002
|
+
// @param options.subForm - If mint, then the form to be used for minting the new thing
|
|
19003
|
+
// @param dataDoc - The web document being edited
|
|
19004
|
+
// @param callbackFunction - takes (boolean ok, string errorBody)
|
|
19005
|
+
*/
|
|
19006
|
+
|
|
19007
|
+
|
|
19008
|
+
function makeSelectForChoice(dom, container, kb, subject, predicate, possible, uiFrom, options, dataDoc, callbackFunction) {
|
|
19009
|
+
var n = 0;
|
|
19010
|
+
var uris = {}; // Count them
|
|
19011
|
+
|
|
19012
|
+
var editable = kb.updater.editable(dataDoc.uri);
|
|
19013
|
+
|
|
19014
|
+
for (var i = 0; i < possible.length; i++) {
|
|
19015
|
+
var sub = possible[i]; // @@ Maybe; make this so it works with blank nodes too
|
|
19016
|
+
|
|
19017
|
+
if (!sub.uri) debug.warn("makeSelectForOptions: option does not have an uri: ".concat(sub, ", with predicate: ").concat(predicate));
|
|
19018
|
+
if (!sub.uri || sub.uri in uris) continue;
|
|
19019
|
+
uris[sub.uri] = true;
|
|
19020
|
+
n++;
|
|
19021
|
+
} // uris is now the set of possible options
|
|
19022
|
+
|
|
19023
|
+
|
|
19024
|
+
if (n === 0 && !options.mint) {
|
|
19025
|
+
return (0, _error.errorMessageBlock)(dom, "Can't do selector with no options, subject= " + subject + ' property = ' + predicate + '.');
|
|
19026
|
+
}
|
|
19027
|
+
|
|
19028
|
+
log.debug('makeSelectForOptions: dataDoc=' + dataDoc);
|
|
19029
|
+
|
|
19030
|
+
function determinFirstSelectOption() {
|
|
19031
|
+
var firstSelectOptionText = '--- classify ---';
|
|
19032
|
+
var option = dom.createElement('option');
|
|
19033
|
+
|
|
19034
|
+
if (predicate && !(predicate.termType === 'BlankNode')) {
|
|
19035
|
+
firstSelectOptionText = '* Select for property: ' + utils.label(predicate) + ' *';
|
|
19036
|
+
}
|
|
19037
|
+
|
|
19038
|
+
if (subject && !(subject.termType === 'BlankNode')) {
|
|
19039
|
+
firstSelectOptionText = '* Select for ' + utils.label(subject, true) + ' *';
|
|
19040
|
+
}
|
|
19041
|
+
|
|
19042
|
+
option.appendChild(dom.createTextNode(firstSelectOptionText));
|
|
19043
|
+
option.disabled = true;
|
|
19044
|
+
option.value = true;
|
|
19045
|
+
option.hidden = true;
|
|
19046
|
+
option.selected = true;
|
|
19047
|
+
return option;
|
|
19048
|
+
}
|
|
19049
|
+
|
|
19050
|
+
var onChange = function onChange(_e) {
|
|
19051
|
+
select.refresh();
|
|
19052
|
+
};
|
|
19053
|
+
|
|
19054
|
+
var select = dom.createElement('select');
|
|
19055
|
+
select.setAttribute('style', style.formSelectSTyle);
|
|
19056
|
+
if (options.multiSelect) select.setAttribute('multiSelect', 'true');
|
|
19057
|
+
select.currentURI = null;
|
|
19058
|
+
|
|
19059
|
+
for (var uri in uris) {
|
|
19060
|
+
select.appendChild(createOption(uri));
|
|
19061
|
+
}
|
|
19062
|
+
|
|
19063
|
+
if (editable && options.mint) {
|
|
19064
|
+
var mint = dom.createElement('option');
|
|
19065
|
+
mint.appendChild(dom.createTextNode(options.mint));
|
|
19066
|
+
mint.AJAR_mint = true; // Flag it
|
|
19067
|
+
|
|
19068
|
+
select.insertBefore(mint, select.firstChild);
|
|
19069
|
+
}
|
|
19070
|
+
|
|
19071
|
+
if (select.children.length === 0) select.insertBefore(determinFirstSelectOption(), select.firstChild);
|
|
19072
|
+
|
|
19073
|
+
select.refresh = function () {
|
|
19074
|
+
select.disabled = true; // unlocked any conflict we had got into
|
|
19075
|
+
|
|
19076
|
+
var ds = [];
|
|
19077
|
+
var is = [];
|
|
19078
|
+
|
|
19079
|
+
var removeValue = function removeValue(t) {
|
|
19080
|
+
if (kb.holds(subject, predicate, t, dataDoc)) {
|
|
19081
|
+
ds.push($rdf.st(subject, predicate, t, dataDoc));
|
|
19082
|
+
}
|
|
19083
|
+
};
|
|
19084
|
+
|
|
19085
|
+
var newObject;
|
|
19086
|
+
|
|
19087
|
+
for (var _i3 = 0; _i3 < select.options.length; _i3++) {
|
|
19088
|
+
var opt = select.options[_i3];
|
|
19089
|
+
|
|
19090
|
+
if (opt.selected && opt.AJAR_mint) {
|
|
19091
|
+
// not sure if this 'if' is used because I cannot find mintClass
|
|
19092
|
+
if (options.mintClass) {
|
|
19093
|
+
var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
|
|
19094
|
+
if (!ok) {
|
|
19095
|
+
callbackFunction(ok, body, {
|
|
19096
|
+
change: 'new'
|
|
19097
|
+
}); // @@ if ok, need some form of refresh of the select for the new thing
|
|
19098
|
+
}
|
|
19099
|
+
});
|
|
19100
|
+
select.parentNode.appendChild(thisForm);
|
|
19101
|
+
newObject = thisForm.AJAR_subject;
|
|
19102
|
+
} else {
|
|
19103
|
+
newObject = newThing(dataDoc);
|
|
19104
|
+
}
|
|
19105
|
+
|
|
19106
|
+
is.push($rdf.st(subject, predicate, kb.sym(newObject), dataDoc));
|
|
19107
|
+
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
|
|
19108
|
+
|
|
19109
|
+
if (options.mintStatementsFun) {
|
|
19110
|
+
is = is.concat(options.mintStatementsFun(newObject));
|
|
19111
|
+
}
|
|
19112
|
+
|
|
19113
|
+
select.currentURI = newObject;
|
|
19114
|
+
}
|
|
19115
|
+
|
|
19116
|
+
if (!opt.AJAR_uri) continue; // a prompt or mint
|
|
19117
|
+
|
|
19118
|
+
if (opt.selected) select.currentURI = opt.AJAR_uri;
|
|
19119
|
+
}
|
|
19120
|
+
|
|
19121
|
+
var sel = select.subSelect; // All subclasses must also go
|
|
19122
|
+
|
|
19123
|
+
while (sel && sel.currentURI) {
|
|
19124
|
+
removeValue(kb.sym(sel.currentURI));
|
|
19125
|
+
sel = sel.subSelect;
|
|
19126
|
+
}
|
|
19127
|
+
|
|
19128
|
+
sel = select.superSelect; // All superclasses are redundant
|
|
19129
|
+
|
|
19130
|
+
while (sel && sel.currentURI) {
|
|
19131
|
+
removeValue(kb.sym(sel.currentURI));
|
|
19132
|
+
sel = sel.superSelect;
|
|
19133
|
+
}
|
|
19134
|
+
|
|
19135
|
+
log.info('selectForOptions: data doc = ' + dataDoc);
|
|
19136
|
+
|
|
19137
|
+
if (select.currentURI) {
|
|
19138
|
+
removeNextSiblingsAfterElement(select);
|
|
19139
|
+
addSubFormChoice(dom, container, {}, $rdf.sym(select.currentURI), options.subForm, dataDoc, function (ok, body) {
|
|
19140
|
+
if (ok) {
|
|
19141
|
+
kb.updater.update(ds, is, function (uri, success, errorBody) {
|
|
19142
|
+
if (!success) container.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating select: ' + errorBody));
|
|
19143
|
+
});
|
|
19144
|
+
if (callbackFunction) callbackFunction(ok, {
|
|
19145
|
+
widget: 'select',
|
|
19146
|
+
event: 'new'
|
|
19147
|
+
}); // widgets.refreshTree(container)
|
|
19148
|
+
} else {
|
|
19149
|
+
container.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in field of select: ' + body));
|
|
19150
|
+
}
|
|
19151
|
+
});
|
|
19152
|
+
}
|
|
19153
|
+
|
|
19154
|
+
select.disabled = false;
|
|
19155
|
+
};
|
|
19156
|
+
|
|
19157
|
+
function createOption(uri) {
|
|
19158
|
+
var option = dom.createElement('option');
|
|
19159
|
+
var c = kb.sym(uri);
|
|
19160
|
+
|
|
19161
|
+
if (options.disambiguate) {
|
|
19162
|
+
option.appendChild(dom.createTextNode(utils.labelWithOntology(c, true))); // Init. cap
|
|
19163
|
+
} else {
|
|
19164
|
+
option.appendChild(dom.createTextNode(utils.label(c, true))); // Init.
|
|
19165
|
+
}
|
|
19166
|
+
|
|
19167
|
+
var backgroundColor = kb.any(c, kb.sym('http://www.w3.org/ns/ui#backgroundColor'));
|
|
19168
|
+
|
|
19169
|
+
if (backgroundColor) {
|
|
19170
|
+
option.setAttribute('style', 'background-color: ' + backgroundColor.value + '; ');
|
|
19171
|
+
}
|
|
19172
|
+
|
|
19173
|
+
option.AJAR_uri = uri;
|
|
19174
|
+
if (c.toString() === '' + select.currentURI) option.selected = true;
|
|
19175
|
+
return option;
|
|
19176
|
+
}
|
|
19177
|
+
|
|
19178
|
+
if (editable) {
|
|
19179
|
+
select.addEventListener('change', onChange, false);
|
|
19180
|
+
}
|
|
19181
|
+
|
|
19182
|
+
return select;
|
|
19183
|
+
} // makeSelectForChoice
|
|
19005
19184
|
//# sourceMappingURL=forms.js.map
|
|
19006
19185
|
|
|
19007
19186
|
/***/ }),
|