solid-ui 2.4.22-34747cd0 → 2.4.22-39d66c72
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 +303 -70
- 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 +295 -64
- package/lib/widgets/forms.js.map +1 -1
- package/package.json +3 -2
package/lib/widgets/forms.js
CHANGED
|
@@ -44,6 +44,7 @@ exports.findClosest = findClosest;
|
|
|
44
44
|
exports.formsFor = formsFor;
|
|
45
45
|
exports.makeDescription = makeDescription;
|
|
46
46
|
exports.makeSelectForCategory = makeSelectForCategory;
|
|
47
|
+
exports.makeSelectForChoice = makeSelectForChoice;
|
|
47
48
|
exports.makeSelectForNestedCategory = makeSelectForNestedCategory;
|
|
48
49
|
exports.makeSelectForOptions = makeSelectForOptions;
|
|
49
50
|
exports.newButton = newButton;
|
|
@@ -155,14 +156,16 @@ _fieldFunction.field[ns.ui('Form').uri] = _fieldFunction.field[ns.ui('Group').ur
|
|
|
155
156
|
var ui = ns.ui;
|
|
156
157
|
if (container) container.appendChild(box); // Prevent loops
|
|
157
158
|
|
|
159
|
+
if (!form) return;
|
|
158
160
|
var key = subject.toNT() + '|' + form.toNT();
|
|
159
161
|
|
|
160
162
|
if (already[key]) {
|
|
161
163
|
// been there done that
|
|
162
|
-
box.appendChild(dom.createTextNode('Group: see above ' + key));
|
|
163
|
-
|
|
164
|
+
box.appendChild(dom.createTextNode('Group: see above ' + key)); // TODO fix dependency cycle to solid-panes by calling outlineManager
|
|
165
|
+
// const plist = [$rdf.st(subject, ns.owl('sameAs'), subject)] // @@ need prev subject
|
|
166
|
+
// dom.outlineManager.appendPropertyTRs(box, plist)
|
|
167
|
+
// dom.appendChild(plist)
|
|
164
168
|
|
|
165
|
-
dom.outlineManager.appendPropertyTRs(box, plist);
|
|
166
169
|
return box;
|
|
167
170
|
}
|
|
168
171
|
|
|
@@ -591,7 +594,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
591
594
|
// delete button and move buttons
|
|
592
595
|
|
|
593
596
|
if (kb.updater.editable(dataDoc.uri)) {
|
|
594
|
-
buttons.deleteButtonWithCheck(dom, subField,
|
|
597
|
+
buttons.deleteButtonWithCheck(dom, subField, multipleUIlabel, deleteThisItem);
|
|
595
598
|
|
|
596
599
|
if (ordered) {
|
|
597
600
|
// Add controsl in a frame
|
|
@@ -642,7 +645,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
642
645
|
|
|
643
646
|
var _shim = dom.createElement('div');
|
|
644
647
|
|
|
645
|
-
_shim.appendChild(subField); // Subfield has its own
|
|
648
|
+
_shim.appendChild(subField); // Subfield has its own layout
|
|
646
649
|
|
|
647
650
|
|
|
648
651
|
frame.appendChild(_shim);
|
|
@@ -691,6 +694,8 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
691
694
|
return shim;
|
|
692
695
|
}
|
|
693
696
|
|
|
697
|
+
var multipleUIlabel = kb.any(form, ui('label'));
|
|
698
|
+
if (!multipleUIlabel) multipleUIlabel = utils.label(property);
|
|
694
699
|
var min = kb.any(form, ui('min')); // This is the minimum number -- default 0
|
|
695
700
|
|
|
696
701
|
min = min ? 0 + min.value : 0;
|
|
@@ -731,10 +736,9 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
731
736
|
img.setAttribute('src', plusIconURI); // plus sign
|
|
732
737
|
|
|
733
738
|
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
|
-
|
|
739
|
+
img.title = 'Click to add another ' + multipleUIlabel;
|
|
740
|
+
var prompt = dom.createElement('span');
|
|
741
|
+
prompt.textContent = (values.length === 0 ? 'Add another ' : 'Add ') + multipleUIlabel;
|
|
738
742
|
tail.addEventListener('click', /*#__PURE__*/function () {
|
|
739
743
|
var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(_eventNotUsed) {
|
|
740
744
|
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
@@ -756,6 +760,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
756
760
|
return _ref3.apply(this, arguments);
|
|
757
761
|
};
|
|
758
762
|
}(), true);
|
|
763
|
+
tail.appendChild(prompt);
|
|
759
764
|
}
|
|
760
765
|
|
|
761
766
|
function createListIfNecessary() {
|
|
@@ -1017,28 +1022,39 @@ _fieldFunction.field[ns.ui('Classifier').uri] = function (dom, container, alread
|
|
|
1017
1022
|
**
|
|
1018
1023
|
** Not nested. Generates a link to something from a given class.
|
|
1019
1024
|
** Optional subform for the thing selected.
|
|
1025
|
+
** Generates a subForm based on a ui:use form
|
|
1026
|
+
** Will look like:
|
|
1027
|
+
** <div id=dropDownDiv>
|
|
1028
|
+
** <div id=labelOfDropDown>
|
|
1029
|
+
** <div id=selectDiv>
|
|
1030
|
+
** <select id=dropDownSelect>
|
|
1031
|
+
** <option> ....
|
|
1032
|
+
** <subForm>
|
|
1020
1033
|
** Alternative implementatons caould be:
|
|
1021
1034
|
** -- pop-up menu (as here)
|
|
1022
1035
|
** -- radio buttons
|
|
1023
1036
|
** -- auto-complete typing
|
|
1024
1037
|
**
|
|
1025
|
-
**
|
|
1038
|
+
** TODO: according to ontology ui:choice can also have ns.ui('default') - this is not implemented yet
|
|
1026
1039
|
*/
|
|
1027
1040
|
|
|
1028
1041
|
|
|
1029
1042
|
_fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) {
|
|
1030
1043
|
var ui = ns.ui;
|
|
1031
1044
|
var kb = _solidLogic.store;
|
|
1032
|
-
var multiple = false;
|
|
1033
1045
|
var formDoc = form.doc ? form.doc() : null; // @@ if blank no way to know
|
|
1034
1046
|
|
|
1047
|
+
var multiSelect = false;
|
|
1035
1048
|
var p;
|
|
1036
|
-
var box = dom.createElement('div');
|
|
1049
|
+
var box = dom.createElement('div');
|
|
1050
|
+
box.setAttribute('class', 'choiceBox'); // Set flexDirection column?
|
|
1037
1051
|
|
|
1038
1052
|
if (container) container.appendChild(box);
|
|
1039
1053
|
var lhs = dom.createElement('div');
|
|
1054
|
+
lhs.setAttribute('class', 'formFieldName choiceBox-label');
|
|
1040
1055
|
box.appendChild(lhs);
|
|
1041
1056
|
var rhs = dom.createElement('div');
|
|
1057
|
+
rhs.setAttribute('class', 'formFieldValue choiceBox-selectBox');
|
|
1042
1058
|
box.appendChild(rhs);
|
|
1043
1059
|
var property = kb.any(form, ui('property'));
|
|
1044
1060
|
|
|
@@ -1047,9 +1063,9 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
1047
1063
|
}
|
|
1048
1064
|
|
|
1049
1065
|
lhs.appendChild((0, _basic.fieldLabel)(dom, property, form));
|
|
1050
|
-
var
|
|
1066
|
+
var uiFrom = kb.any(form, ui('from'));
|
|
1051
1067
|
|
|
1052
|
-
if (!
|
|
1068
|
+
if (!uiFrom) {
|
|
1053
1069
|
return (0, _error.errorMessageBlock)(dom, "No 'from' for Choice: " + form);
|
|
1054
1070
|
}
|
|
1055
1071
|
|
|
@@ -1057,77 +1073,95 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
1057
1073
|
|
|
1058
1074
|
var follow = kb.anyJS(form, ui('follow'), null, formDoc); // data doc moves to new subject?
|
|
1059
1075
|
|
|
1060
|
-
var possible = [];
|
|
1061
|
-
var possibleProperties;
|
|
1062
|
-
var nullLabel = '--' + utils.label(property) + '-?';
|
|
1063
1076
|
var opts = {
|
|
1064
1077
|
form: form,
|
|
1065
|
-
|
|
1066
|
-
|
|
1078
|
+
subForm: subForm,
|
|
1079
|
+
multiSelect: multiSelect,
|
|
1067
1080
|
disambiguate: false
|
|
1068
1081
|
};
|
|
1069
|
-
possible = kb.each(undefined, ns.rdf('type'), from, formDoc);
|
|
1070
1082
|
|
|
1071
|
-
|
|
1072
|
-
possible
|
|
1073
|
-
|
|
1083
|
+
function getSelectorOptions() {
|
|
1084
|
+
var possible = [];
|
|
1085
|
+
var possibleProperties;
|
|
1086
|
+
possible = kb.each(undefined, ns.rdf('type'), uiFrom, formDoc);
|
|
1074
1087
|
|
|
1088
|
+
for (var x in kb.findMembersNT(uiFrom)) {
|
|
1089
|
+
possible.push(kb.fromNT(x));
|
|
1090
|
+
} // Use rdfs
|
|
1075
1091
|
|
|
1076
|
-
if (from.sameTerm(ns.rdfs('Class'))) {
|
|
1077
|
-
for (p in buttons.allClassURIs()) {
|
|
1078
|
-
possible.push(kb.sym(p));
|
|
1079
|
-
} // log.debug("%%% Choice field: possible.length 2 = "+possible.length)
|
|
1080
1092
|
|
|
1081
|
-
|
|
1082
|
-
|
|
1093
|
+
if (uiFrom.sameTerm(ns.rdfs('Class'))) {
|
|
1094
|
+
for (p in buttons.allClassURIs()) {
|
|
1095
|
+
possible.push(kb.sym(p));
|
|
1096
|
+
} // log.debug("%%% Choice field: possible.length 2 = "+possible.length)
|
|
1083
1097
|
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
}
|
|
1098
|
+
} else if (uiFrom.sameTerm(ns.rdf('Property'))) {
|
|
1099
|
+
possibleProperties = buttons.propertyTriage(kb);
|
|
1087
1100
|
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1101
|
+
for (p in possibleProperties.op) {
|
|
1102
|
+
possible.push(kb.fromNT(p));
|
|
1103
|
+
}
|
|
1091
1104
|
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1105
|
+
for (p in possibleProperties.dp) {
|
|
1106
|
+
possible.push(kb.fromNT(p));
|
|
1107
|
+
}
|
|
1095
1108
|
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1109
|
+
opts.disambiguate = true; // This is a big class, and the labels won't be enough.
|
|
1110
|
+
} else if (uiFrom.sameTerm(ns.owl('ObjectProperty'))) {
|
|
1111
|
+
possibleProperties = buttons.propertyTriage(kb);
|
|
1112
|
+
|
|
1113
|
+
for (p in possibleProperties.op) {
|
|
1114
|
+
possible.push(kb.fromNT(p));
|
|
1115
|
+
}
|
|
1099
1116
|
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1117
|
+
opts.disambiguate = true;
|
|
1118
|
+
} else if (uiFrom.sameTerm(ns.owl('DatatypeProperty'))) {
|
|
1119
|
+
possibleProperties = buttons.propertyTriage(kb);
|
|
1103
1120
|
|
|
1104
|
-
|
|
1105
|
-
|
|
1121
|
+
for (p in possibleProperties.dp) {
|
|
1122
|
+
possible.push(kb.fromNT(p));
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
opts.disambiguate = true;
|
|
1106
1126
|
}
|
|
1107
1127
|
|
|
1108
|
-
|
|
1109
|
-
}
|
|
1128
|
+
return sortByLabel(possible);
|
|
1129
|
+
} // TODO: this checks for any occurrence, regardless of true or false setting
|
|
1110
1130
|
|
|
1111
|
-
var object = kb.any(subject, property);
|
|
1112
1131
|
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
(0, _fieldFunction.fieldFunction)(dom, subForm)(dom, rhs, already, object, subForm, follow ? object.doc() : dataDoc, callbackFunction);
|
|
1132
|
+
if (kb.any(form, ui('canMintNew'))) {
|
|
1133
|
+
opts.mint = '* Create new *'; // @@ could be better
|
|
1116
1134
|
}
|
|
1117
1135
|
|
|
1118
|
-
var
|
|
1136
|
+
var selector;
|
|
1137
|
+
|
|
1138
|
+
rhs.refresh = function () {
|
|
1139
|
+
var selectorOptions = getSelectorOptions();
|
|
1140
|
+
selector = makeSelectForChoice(dom, rhs, kb, subject, property, selectorOptions, uiFrom, opts, dataDoc, callbackFunction);
|
|
1141
|
+
rhs.innerHTML = '';
|
|
1142
|
+
rhs.appendChild(selector);
|
|
1143
|
+
};
|
|
1144
|
+
|
|
1145
|
+
rhs.refresh();
|
|
1146
|
+
if (selector && selector.refresh) selector.refresh();
|
|
1147
|
+
return box;
|
|
1148
|
+
};
|
|
1149
|
+
/**
|
|
1150
|
+
* Removes all sibling elements after specified
|
|
1151
|
+
* @param {HTMLElement} currentElement
|
|
1152
|
+
* @private
|
|
1153
|
+
*/
|
|
1119
1154
|
|
|
1120
|
-
if (kb.any(form, ui('canMintNew'))) {
|
|
1121
|
-
opts.mint = '* New *'; // @@ could be better
|
|
1122
1155
|
|
|
1123
|
-
|
|
1156
|
+
function removeNextSiblingsAfterElement(currentElement) {
|
|
1157
|
+
while (currentElement.nextElementSibling) {
|
|
1158
|
+
currentElement.nextElementSibling.remove();
|
|
1124
1159
|
}
|
|
1160
|
+
}
|
|
1125
1161
|
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
return box;
|
|
1130
|
-
}; // Documentation - non-interactive fields
|
|
1162
|
+
function addSubFormChoice(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction) {
|
|
1163
|
+
(0, _fieldFunction.fieldFunction)(dom, subForm)(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction);
|
|
1164
|
+
} // Documentation - non-interactive fields
|
|
1131
1165
|
//
|
|
1132
1166
|
|
|
1133
1167
|
|
|
@@ -1330,7 +1364,8 @@ function promptForNew(dom, kb, subject, predicate, theClass, form, dataDoc, call
|
|
|
1330
1364
|
b.setAttribute('type', 'button');
|
|
1331
1365
|
b.setAttribute('style', 'float: right;');
|
|
1332
1366
|
b.innerHTML = 'Goto ' + utils.label(theClass);
|
|
1333
|
-
b.addEventListener('click',
|
|
1367
|
+
b.addEventListener('click', // TODO fix dependency cycle to solid-panes by calling outlineManager
|
|
1368
|
+
function (_e) {
|
|
1334
1369
|
dom.outlineManager.GotoSubject(theClass, true, undefined, true, undefined);
|
|
1335
1370
|
}, false);
|
|
1336
1371
|
return box;
|
|
@@ -1506,7 +1541,9 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
|
|
|
1506
1541
|
actual = kb.findTypeURIs(subject);
|
|
1507
1542
|
} else {
|
|
1508
1543
|
kb.each(subject, predicate, null, dataDoc).forEach(function (x) {
|
|
1509
|
-
|
|
1544
|
+
if (x.uri) {
|
|
1545
|
+
actual[x.uri] = true;
|
|
1546
|
+
}
|
|
1510
1547
|
});
|
|
1511
1548
|
}
|
|
1512
1549
|
|
|
@@ -1533,6 +1570,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
|
|
|
1533
1570
|
var opt = select.options[_i];
|
|
1534
1571
|
|
|
1535
1572
|
if (opt.selected && opt.AJAR_mint) {
|
|
1573
|
+
// not sure if this 'if' is used because I cannot find mintClass
|
|
1536
1574
|
if (options.mintClass) {
|
|
1537
1575
|
var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
|
|
1538
1576
|
if (!ok) {
|
|
@@ -1547,7 +1585,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
|
|
|
1547
1585
|
newObject = newThing(dataDoc);
|
|
1548
1586
|
}
|
|
1549
1587
|
|
|
1550
|
-
is.push($rdf.st(subject, predicate, newObject, dataDoc));
|
|
1588
|
+
is.push($rdf.st(subject, predicate, newObject, dataDoc)); // not sure if this 'if' is used because I cannot find mintStatementsFun
|
|
1551
1589
|
|
|
1552
1590
|
if (options.mintStatementsFun) {
|
|
1553
1591
|
is = is.concat(options.mintStatementsFun(newObject));
|
|
@@ -1899,4 +1937,197 @@ function newThing(doc) {
|
|
|
1899
1937
|
var now = new Date();
|
|
1900
1938
|
return $rdf.sym(doc.uri + '#' + 'id' + ('' + now.getTime()));
|
|
1901
1939
|
}
|
|
1940
|
+
/** Make SELECT element to select options
|
|
1941
|
+
//
|
|
1942
|
+
// @param subject - a term, the subject of the statement(s) being edited.
|
|
1943
|
+
// @param predicate - a term, the predicate of the statement(s) being edited
|
|
1944
|
+
// @param possible - a list of terms, the possible value the object can take
|
|
1945
|
+
// @param options.multiSelect - Boolean - Whether more than one at a time is allowed
|
|
1946
|
+
// @param options.uiMultipleInUse - signals that the ui:choise is used with a ui:multiple
|
|
1947
|
+
// @param options.mint - User may create thing if this sent to the prompt string eg "New foo"
|
|
1948
|
+
// @param options.subForm - If mint, then the form to be used for minting the new thing
|
|
1949
|
+
// @param dataDoc - The web document being edited
|
|
1950
|
+
// @param callbackFunction - takes (boolean ok, string errorBody)
|
|
1951
|
+
*/
|
|
1952
|
+
|
|
1953
|
+
|
|
1954
|
+
function makeSelectForChoice(dom, container, kb, subject, predicate, possible, uiFrom, options, dataDoc, callbackFunction) {
|
|
1955
|
+
var n = 0;
|
|
1956
|
+
var uris = {}; // Count them
|
|
1957
|
+
|
|
1958
|
+
var editable = kb.updater.editable(dataDoc.uri);
|
|
1959
|
+
|
|
1960
|
+
for (var i = 0; i < possible.length; i++) {
|
|
1961
|
+
var sub = possible[i]; // @@ Maybe; make this so it works with blank nodes too
|
|
1962
|
+
|
|
1963
|
+
if (!sub.uri) debug.warn("makeSelectForOptions: option does not have an uri: ".concat(sub, ", with predicate: ").concat(predicate));
|
|
1964
|
+
if (!sub.uri || sub.uri in uris) continue;
|
|
1965
|
+
uris[sub.uri] = true;
|
|
1966
|
+
n++;
|
|
1967
|
+
} // uris is now the set of possible options
|
|
1968
|
+
|
|
1969
|
+
|
|
1970
|
+
if (n === 0 && !options.mint) {
|
|
1971
|
+
return (0, _error.errorMessageBlock)(dom, "Can't do selector with no options, subject= " + subject + ' property = ' + predicate + '.');
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
log.debug('makeSelectForOptions: dataDoc=' + dataDoc);
|
|
1975
|
+
|
|
1976
|
+
function determinFirstSelectOption() {
|
|
1977
|
+
var firstSelectOptionText = '--- classify ---';
|
|
1978
|
+
var option = dom.createElement('option');
|
|
1979
|
+
|
|
1980
|
+
if (predicate && !(predicate.termType === 'BlankNode')) {
|
|
1981
|
+
firstSelectOptionText = '* Select for property: ' + utils.label(predicate) + ' *';
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
if (subject && !(subject.termType === 'BlankNode')) {
|
|
1985
|
+
firstSelectOptionText = '* Select for ' + utils.label(subject, true) + ' *';
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
option.appendChild(dom.createTextNode(firstSelectOptionText));
|
|
1989
|
+
option.disabled = true;
|
|
1990
|
+
option.value = true;
|
|
1991
|
+
option.hidden = true;
|
|
1992
|
+
option.selected = true;
|
|
1993
|
+
return option;
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
var onChange = function onChange(_e) {
|
|
1997
|
+
select.refresh();
|
|
1998
|
+
};
|
|
1999
|
+
|
|
2000
|
+
var select = dom.createElement('select');
|
|
2001
|
+
select.setAttribute('style', style.formSelectSTyle);
|
|
2002
|
+
if (options.multiSelect) select.setAttribute('multiSelect', 'true');
|
|
2003
|
+
select.currentURI = null;
|
|
2004
|
+
var object = kb.any(subject, predicate);
|
|
2005
|
+
if (object) select.currentURI = object;
|
|
2006
|
+
|
|
2007
|
+
for (var uri in uris) {
|
|
2008
|
+
select.appendChild(createOption(uri));
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
if (editable && options.mint) {
|
|
2012
|
+
var mint = dom.createElement('option');
|
|
2013
|
+
mint.appendChild(dom.createTextNode(options.mint));
|
|
2014
|
+
mint.AJAR_mint = true; // Flag it
|
|
2015
|
+
|
|
2016
|
+
select.insertBefore(mint, select.firstChild);
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
if (select.children.length === 0) select.insertBefore(determinFirstSelectOption(), select.firstChild);
|
|
2020
|
+
|
|
2021
|
+
select.refresh = function () {
|
|
2022
|
+
select.disabled = true; // unlocked any conflict we had got into
|
|
2023
|
+
|
|
2024
|
+
var ds = [];
|
|
2025
|
+
var is = [];
|
|
2026
|
+
|
|
2027
|
+
var removeValue = function removeValue(t) {
|
|
2028
|
+
if (kb.holds(subject, predicate, t, dataDoc)) {
|
|
2029
|
+
ds.push($rdf.st(subject, predicate, t, dataDoc));
|
|
2030
|
+
}
|
|
2031
|
+
};
|
|
2032
|
+
|
|
2033
|
+
var newObject;
|
|
2034
|
+
|
|
2035
|
+
for (var _i3 = 0; _i3 < select.options.length; _i3++) {
|
|
2036
|
+
var opt = select.options[_i3];
|
|
2037
|
+
|
|
2038
|
+
if (opt.selected && opt.AJAR_mint) {
|
|
2039
|
+
// not sure if this 'if' is used because I cannot find mintClass
|
|
2040
|
+
if (options.mintClass) {
|
|
2041
|
+
var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
|
|
2042
|
+
if (!ok) {
|
|
2043
|
+
callbackFunction(ok, body, {
|
|
2044
|
+
change: 'new'
|
|
2045
|
+
}); // @@ if ok, need some form of refresh of the select for the new thing
|
|
2046
|
+
}
|
|
2047
|
+
});
|
|
2048
|
+
select.parentNode.appendChild(thisForm);
|
|
2049
|
+
newObject = thisForm.AJAR_subject;
|
|
2050
|
+
} else {
|
|
2051
|
+
newObject = newThing(dataDoc);
|
|
2052
|
+
}
|
|
2053
|
+
|
|
2054
|
+
is.push($rdf.st(subject, predicate, kb.sym(newObject), dataDoc));
|
|
2055
|
+
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
|
|
2056
|
+
|
|
2057
|
+
if (options.mintStatementsFun) {
|
|
2058
|
+
is = is.concat(options.mintStatementsFun(newObject));
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
select.currentURI = newObject;
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
if (!opt.AJAR_uri) continue; // a prompt or mint
|
|
2065
|
+
|
|
2066
|
+
if (opt.selected) select.currentURI = opt.AJAR_uri;
|
|
2067
|
+
}
|
|
2068
|
+
|
|
2069
|
+
var sel = select.subSelect; // All subclasses must also go
|
|
2070
|
+
|
|
2071
|
+
while (sel && sel.currentURI) {
|
|
2072
|
+
removeValue(kb.sym(sel.currentURI));
|
|
2073
|
+
sel = sel.subSelect;
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
sel = select.superSelect; // All superclasses are redundant
|
|
2077
|
+
|
|
2078
|
+
while (sel && sel.currentURI) {
|
|
2079
|
+
removeValue(kb.sym(sel.currentURI));
|
|
2080
|
+
sel = sel.superSelect;
|
|
2081
|
+
}
|
|
2082
|
+
|
|
2083
|
+
log.info('selectForOptions: data doc = ' + dataDoc);
|
|
2084
|
+
|
|
2085
|
+
if (select.currentURI) {
|
|
2086
|
+
removeNextSiblingsAfterElement(select);
|
|
2087
|
+
addSubFormChoice(dom, container, {}, $rdf.sym(select.currentURI), options.subForm, dataDoc, function (ok, body) {
|
|
2088
|
+
if (ok) {
|
|
2089
|
+
kb.updater.update(ds, is, function (uri, success, errorBody) {
|
|
2090
|
+
if (!success) container.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating select: ' + errorBody));
|
|
2091
|
+
});
|
|
2092
|
+
if (callbackFunction) callbackFunction(ok, {
|
|
2093
|
+
widget: 'select',
|
|
2094
|
+
event: 'new'
|
|
2095
|
+
}); // widgets.refreshTree(container)
|
|
2096
|
+
} else {
|
|
2097
|
+
container.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in field of select: ' + body));
|
|
2098
|
+
}
|
|
2099
|
+
});
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
select.disabled = false;
|
|
2103
|
+
};
|
|
2104
|
+
|
|
2105
|
+
function createOption(uri) {
|
|
2106
|
+
var option = dom.createElement('option');
|
|
2107
|
+
var c = kb.sym(uri);
|
|
2108
|
+
|
|
2109
|
+
if (options.disambiguate) {
|
|
2110
|
+
option.appendChild(dom.createTextNode(utils.labelWithOntology(c, true))); // Init. cap
|
|
2111
|
+
} else {
|
|
2112
|
+
option.appendChild(dom.createTextNode(utils.label(c, true))); // Init.
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
var backgroundColor = kb.any(c, kb.sym('http://www.w3.org/ns/ui#backgroundColor'));
|
|
2116
|
+
|
|
2117
|
+
if (backgroundColor) {
|
|
2118
|
+
option.setAttribute('style', 'background-color: ' + backgroundColor.value + '; ');
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
option.AJAR_uri = uri;
|
|
2122
|
+
if (c.toString() === '' + select.currentURI) option.selected = true;
|
|
2123
|
+
return option;
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
if (editable) {
|
|
2127
|
+
select.addEventListener('change', onChange, false);
|
|
2128
|
+
}
|
|
2129
|
+
|
|
2130
|
+
select.refresh();
|
|
2131
|
+
return select;
|
|
2132
|
+
} // makeSelectForChoice
|
|
1902
2133
|
//# sourceMappingURL=forms.js.map
|