solid-ui 2.4.23 → 2.4.24
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/dist/main.js +2159 -5039
- package/dist/main.js.map +1 -1
- package/lib/acl/access-controller.js +4 -67
- package/lib/acl/access-controller.js.map +1 -1
- package/lib/acl/access-groups.js +59 -137
- package/lib/acl/access-groups.js.map +1 -1
- package/lib/acl/acl-control.js +14 -54
- package/lib/acl/acl-control.js.map +1 -1
- package/lib/acl/acl.js +32 -107
- package/lib/acl/acl.js.map +1 -1
- package/lib/acl/add-agent-buttons.js +0 -92
- package/lib/acl/add-agent-buttons.js.map +1 -1
- package/lib/acl/index.js +1 -3
- package/lib/acl/index.js.map +1 -1
- package/lib/acl/styles.js +1 -2
- package/lib/acl/styles.js.map +1 -1
- package/lib/chat/bookmarks.js +8 -80
- package/lib/chat/bookmarks.js.map +1 -1
- package/lib/chat/chatLogic.js +109 -180
- package/lib/chat/chatLogic.js.map +1 -1
- package/lib/chat/dateFolder.js +6 -91
- package/lib/chat/dateFolder.js.map +1 -1
- package/lib/chat/infinite.js +33 -185
- package/lib/chat/infinite.js.map +1 -1
- package/lib/chat/message.js +37 -150
- package/lib/chat/message.js.map +1 -1
- package/lib/chat/messageTools.js +23 -96
- package/lib/chat/messageTools.js.map +1 -1
- package/lib/chat/thread.js +33 -91
- package/lib/chat/thread.js.map +1 -1
- package/lib/create/create.js +19 -51
- package/lib/create/create.js.map +1 -1
- package/lib/create/index.js +0 -2
- package/lib/create/index.js.map +1 -1
- package/lib/debug.js +0 -8
- package/lib/debug.js.map +1 -1
- package/lib/folders.js +4 -27
- package/lib/folders.js.map +1 -1
- package/lib/footer/index.js +2 -24
- package/lib/footer/index.js.map +1 -1
- package/lib/footer/styleMap.js.map +1 -1
- package/lib/header/empty-profile.js.map +1 -1
- package/lib/header/index.js +3 -72
- package/lib/header/index.js.map +1 -1
- package/lib/header/styleMap.js +4 -3
- package/lib/header/styleMap.js.map +1 -1
- package/lib/iconBase.js +3 -4
- package/lib/iconBase.js.map +1 -1
- package/lib/index.js +5 -46
- package/lib/index.js.map +1 -1
- package/lib/jss/index.js +3 -9
- package/lib/jss/index.js.map +1 -1
- package/lib/log.js +15 -51
- package/lib/log.js.map +1 -1
- package/lib/login/login.js +74 -303
- package/lib/login/login.js.map +1 -1
- package/lib/matrix/index.js +0 -2
- package/lib/matrix/index.js.map +1 -1
- package/lib/matrix/matrix.js +7 -55
- package/lib/matrix/matrix.js.map +1 -1
- package/lib/media/index.js +0 -2
- package/lib/media/index.js.map +1 -1
- package/lib/media/media-capture.js +13 -33
- package/lib/media/media-capture.js.map +1 -1
- package/lib/messageArea.js +23 -64
- package/lib/messageArea.js.map +1 -1
- package/lib/noun_Camera_1618446_000000.js.map +1 -1
- package/lib/ns.js +5 -7
- package/lib/ns.js.map +1 -1
- package/lib/pad.js +48 -234
- package/lib/pad.js.map +1 -1
- package/lib/participation.js +10 -65
- package/lib/participation.js.map +1 -1
- package/lib/preferences.js +21 -42
- package/lib/preferences.js.map +1 -1
- package/lib/signup/config-default.js +1 -8
- package/lib/signup/config-default.js.map +1 -1
- package/lib/signup/signup.js +6 -13
- package/lib/signup/signup.js.map +1 -1
- package/lib/stories/decorators.js +0 -2
- package/lib/stories/decorators.js.map +1 -1
- package/lib/style.js +8 -5
- package/lib/style.js.map +1 -1
- package/lib/style_multiSelect.js +1 -5
- package/lib/style_multiSelect.js.map +1 -1
- package/lib/table.js +309 -322
- package/lib/table.js.map +1 -1
- package/lib/tabs.js +20 -100
- package/lib/tabs.js.map +1 -1
- package/lib/utils/headerFooterHelpers.js +4 -52
- package/lib/utils/headerFooterHelpers.js.map +1 -1
- package/lib/utils/index.js +41 -135
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/label.js +13 -34
- package/lib/utils/label.js.map +1 -1
- package/lib/versionInfo.js +4 -4
- package/lib/versionInfo.js.map +1 -1
- package/lib/widgets/buttons/iconLinks.js +0 -8
- package/lib/widgets/buttons/iconLinks.js.map +1 -1
- package/lib/widgets/buttons.js +115 -291
- package/lib/widgets/buttons.js.map +1 -1
- package/lib/widgets/dragAndDrop.js +12 -41
- package/lib/widgets/dragAndDrop.js.map +1 -1
- package/lib/widgets/error.js +3 -9
- package/lib/widgets/error.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompleteBar.js +8 -71
- package/lib/widgets/forms/autocomplete/autocompleteBar.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompleteField.js +13 -65
- package/lib/widgets/forms/autocomplete/autocompleteField.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompletePicker.js +15 -107
- package/lib/widgets/forms/autocomplete/autocompletePicker.js.map +1 -1
- package/lib/widgets/forms/autocomplete/language.js +6 -55
- package/lib/widgets/forms/autocomplete/language.js.map +1 -1
- package/lib/widgets/forms/autocomplete/publicData.js +12 -131
- package/lib/widgets/forms/autocomplete/publicData.js.map +1 -1
- package/lib/widgets/forms/basic.js +12 -55
- package/lib/widgets/forms/basic.js.map +1 -1
- package/lib/widgets/forms/comment.js +1 -15
- package/lib/widgets/forms/comment.js.map +1 -1
- package/lib/widgets/forms/fieldFunction.js +3 -16
- package/lib/widgets/forms/fieldFunction.js.map +1 -1
- package/lib/widgets/forms/fieldParams.js +0 -12
- package/lib/widgets/forms/fieldParams.js.map +1 -1
- package/lib/widgets/forms/formStyle.js +1 -14
- package/lib/widgets/forms/formStyle.js.map +1 -1
- package/lib/widgets/forms.js +70 -474
- package/lib/widgets/forms.js.map +1 -1
- package/lib/widgets/index.js +0 -21
- package/lib/widgets/index.js.map +1 -1
- package/lib/widgets/multiSelect.js +48 -171
- package/lib/widgets/multiSelect.js.map +1 -1
- package/lib/widgets/peoplePicker.js +20 -90
- package/lib/widgets/peoplePicker.js.map +1 -1
- package/lib/widgets/widgetHelpers.js +2 -9
- package/lib/widgets/widgetHelpers.js.map +1 -1
- package/package.json +28 -28
package/lib/widgets/forms.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
@@ -72,65 +70,41 @@ Object.defineProperty(exports, "renderNameValuePair", {
|
|
|
72
70
|
});
|
|
73
71
|
exports.sortByLabel = sortByLabel;
|
|
74
72
|
exports.sortBySequence = sortBySequence;
|
|
75
|
-
|
|
76
73
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
77
|
-
|
|
78
74
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
79
|
-
|
|
80
75
|
var buttons = _interopRequireWildcard(require("./buttons"));
|
|
81
|
-
|
|
82
76
|
var _fieldParams = require("./forms/fieldParams");
|
|
83
|
-
|
|
84
77
|
var _fieldFunction = require("./forms/fieldFunction");
|
|
85
|
-
|
|
86
78
|
var _formStyle = require("./forms/formStyle");
|
|
87
|
-
|
|
88
79
|
var debug = _interopRequireWildcard(require("../debug"));
|
|
89
|
-
|
|
90
80
|
var _error = require("./error");
|
|
91
|
-
|
|
92
81
|
var _basic = require("./forms/basic");
|
|
93
|
-
|
|
94
82
|
var _autocompleteField = require("./forms/autocomplete/autocompleteField");
|
|
95
|
-
|
|
96
83
|
var style = _interopRequireWildcard(require("../style"));
|
|
97
|
-
|
|
98
84
|
var _iconBase = require("../iconBase");
|
|
99
|
-
|
|
100
85
|
var log = _interopRequireWildcard(require("../log"));
|
|
101
|
-
|
|
102
86
|
var ns = _interopRequireWildcard(require("../ns"));
|
|
103
|
-
|
|
104
87
|
var $rdf = _interopRequireWildcard(require("rdflib"));
|
|
105
|
-
|
|
106
88
|
var _solidLogic = require("solid-logic");
|
|
107
|
-
|
|
108
89
|
var utils = _interopRequireWildcard(require("../utils"));
|
|
109
|
-
|
|
110
90
|
var _multiSelect = require("./multiSelect");
|
|
111
|
-
|
|
112
91
|
var widgets = _interopRequireWildcard(require("../widgets"));
|
|
113
|
-
|
|
114
92
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
115
|
-
|
|
116
93
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
117
|
-
|
|
118
94
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
119
|
-
|
|
120
95
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
121
|
-
|
|
122
96
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
123
|
-
|
|
124
97
|
var checkMarkCharacter = "\u2713";
|
|
125
98
|
var cancelCharacter = "\u2715";
|
|
126
99
|
var dashCharacter = '-';
|
|
127
100
|
var kb = _solidLogic.store;
|
|
128
|
-
_fieldFunction.field[ns.ui('AutocompleteField').uri] = _autocompleteField.autocompleteField;
|
|
101
|
+
_fieldFunction.field[ns.ui('AutocompleteField').uri] = _autocompleteField.autocompleteField;
|
|
102
|
+
|
|
103
|
+
// ///////////////////////////////////////////////////////////////////////
|
|
129
104
|
|
|
130
105
|
/* Form Field implementations
|
|
131
106
|
**
|
|
132
107
|
*/
|
|
133
|
-
|
|
134
108
|
/** Group of different fields
|
|
135
109
|
**
|
|
136
110
|
** One type of form field is an ordered Group of other fields.
|
|
@@ -146,20 +120,16 @@ _fieldFunction.field[ns.ui('AutocompleteField').uri] = _autocompleteField.autoco
|
|
|
146
120
|
**
|
|
147
121
|
** @returns {Element} The HTML widget created
|
|
148
122
|
*/
|
|
149
|
-
|
|
150
123
|
function refreshOpionsSubfieldinGroup(dom, already, subject, dataDoc, callbackFunction, groupDiv, subfields) {
|
|
151
124
|
var eles = groupDiv.children;
|
|
152
|
-
|
|
153
125
|
for (var j = 0; j < subfields.length; j++) {
|
|
154
126
|
// This is really messy.
|
|
155
127
|
var _field = subfields[j];
|
|
156
128
|
var t = (0, _fieldFunction.mostSpecificClassURI)(_field); // Field type
|
|
157
|
-
|
|
158
129
|
if (t === ns.ui('Options').uri) {
|
|
159
130
|
var optionsRender = (0, _fieldFunction.fieldFunction)(dom, _field);
|
|
160
131
|
var newOne = optionsRender(dom, null, already, subject, _field, dataDoc, callbackFunction);
|
|
161
132
|
debug.log('Refreshing Options field by replacing it.'); // better to support actual refresh
|
|
162
|
-
|
|
163
133
|
groupDiv.insertBefore(newOne, eles[j]);
|
|
164
134
|
groupDiv.removeChild(eles[j + 1]); // Remove the old one
|
|
165
135
|
}
|
|
@@ -169,54 +139,44 @@ function refreshOpionsSubfieldinGroup(dom, already, subject, dataDoc, callbackFu
|
|
|
169
139
|
_fieldFunction.field[ns.ui('Form').uri] = _fieldFunction.field[ns.ui('Group').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) {
|
|
170
140
|
var box = dom.createElement('div');
|
|
171
141
|
var ui = ns.ui;
|
|
172
|
-
if (container) container.appendChild(box);
|
|
142
|
+
if (container) container.appendChild(box);
|
|
173
143
|
|
|
144
|
+
// Prevent loops
|
|
174
145
|
if (!form) return;
|
|
175
146
|
var key = subject.toNT() + '|' + form.toNT();
|
|
176
|
-
|
|
177
147
|
if (already[key]) {
|
|
178
148
|
// been there done that
|
|
179
|
-
box.appendChild(dom.createTextNode('Group: see above ' + key));
|
|
149
|
+
box.appendChild(dom.createTextNode('Group: see above ' + key));
|
|
150
|
+
// TODO fix dependency cycle to solid-panes by calling outlineManager
|
|
180
151
|
// const plist = [$rdf.st(subject, ns.owl('sameAs'), subject)] // @@ need prev subject
|
|
181
152
|
// dom.outlineManager.appendPropertyTRs(box, plist)
|
|
182
153
|
// dom.appendChild(plist)
|
|
183
|
-
|
|
184
154
|
return box;
|
|
185
155
|
}
|
|
186
|
-
|
|
187
156
|
var already2 = {};
|
|
188
|
-
|
|
189
157
|
for (var x in already) {
|
|
190
158
|
already2[x] = 1;
|
|
191
159
|
}
|
|
192
|
-
|
|
193
160
|
already2[key] = 1;
|
|
194
161
|
var formDoc = form.doc ? form.doc() : null; // @@ if blank no way to know
|
|
195
|
-
|
|
196
162
|
var weight0 = kb.any(form, ui('weight'), null, formDoc); // Say 0-3
|
|
197
|
-
|
|
198
163
|
var weight = weight0 ? Number(weight0.value) : 1;
|
|
199
164
|
if (weight > 3 || weight < 0) return box.appendChild((0, _error.errorMessageBlock)(dom, "Form Group weight ".concat(weight, " should be 0-3")));
|
|
200
165
|
box.setAttribute('style', style.formGroupStyle[weight]); // Indent a group
|
|
201
|
-
|
|
202
166
|
box.style.display = 'flex';
|
|
203
167
|
box.style.flexDirection = 'column';
|
|
204
168
|
box["class"] = 'form-weight-' + weight;
|
|
205
169
|
var parts = kb.any(form, ui('parts'), null, formDoc);
|
|
206
170
|
var subfields;
|
|
207
|
-
|
|
208
171
|
if (parts) {
|
|
209
172
|
subfields = parts.elements;
|
|
210
173
|
} else {
|
|
211
174
|
parts = kb.each(form, ui('part'), null, formDoc); // Warning: unordered
|
|
212
|
-
|
|
213
175
|
subfields = sortBySequence(parts);
|
|
214
176
|
}
|
|
215
|
-
|
|
216
177
|
if (!parts) {
|
|
217
178
|
return box.appendChild((0, _error.errorMessageBlock)(dom, 'No parts to form! '));
|
|
218
179
|
}
|
|
219
|
-
|
|
220
180
|
for (var i = 0; i < subfields.length; i++) {
|
|
221
181
|
var _field2 = subfields[i];
|
|
222
182
|
var subFieldFunction = (0, _fieldFunction.fieldFunction)(dom, _field2); //
|
|
@@ -225,18 +185,16 @@ _fieldFunction.field[ns.ui('Form').uri] = _fieldFunction.field[ns.ui('Group').ur
|
|
|
225
185
|
if (ok && body && body.widget && body.widget === 'select') {
|
|
226
186
|
refreshOpionsSubfieldinGroup(dom, already, subject, dataDoc, callbackFunction, box, subfields);
|
|
227
187
|
}
|
|
228
|
-
|
|
229
188
|
callbackFunction(ok, {
|
|
230
189
|
widget: 'group',
|
|
231
190
|
change: body
|
|
232
191
|
});
|
|
233
192
|
};
|
|
234
|
-
|
|
235
193
|
box.appendChild(subFieldFunction(dom, null, already2, subject, _field2, dataDoc, itemChanged));
|
|
236
194
|
}
|
|
237
|
-
|
|
238
195
|
return box;
|
|
239
196
|
};
|
|
197
|
+
|
|
240
198
|
/** Options field: Select one or more cases
|
|
241
199
|
**
|
|
242
200
|
** @param {Document} dom The HTML Document object aka Document Object Model
|
|
@@ -250,7 +208,6 @@ _fieldFunction.field[ns.ui('Form').uri] = _fieldFunction.field[ns.ui('Group').ur
|
|
|
250
208
|
** @returns {Element} The HTML widget created
|
|
251
209
|
*/
|
|
252
210
|
|
|
253
|
-
|
|
254
211
|
_fieldFunction.field[ns.ui('Options').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) {
|
|
255
212
|
var kb = _solidLogic.store;
|
|
256
213
|
var box = dom.createElement('div');
|
|
@@ -259,20 +216,14 @@ _fieldFunction.field[ns.ui('Options').uri] = function (dom, container, already,
|
|
|
259
216
|
var ui = ns.ui;
|
|
260
217
|
if (container) container.appendChild(box);
|
|
261
218
|
var dependingOn = kb.any(form, ui('dependingOn'));
|
|
262
|
-
|
|
263
219
|
if (!dependingOn) {
|
|
264
220
|
dependingOn = ns.rdf('type');
|
|
265
221
|
} // @@ default to type (do we want defaults?)
|
|
266
|
-
|
|
267
|
-
|
|
268
222
|
var cases = kb.each(form, ui('case'), null, formDoc);
|
|
269
|
-
|
|
270
223
|
if (!cases) {
|
|
271
224
|
box.appendChild((0, _error.errorMessageBlock)(dom, 'No cases to Options form. '));
|
|
272
225
|
}
|
|
273
|
-
|
|
274
226
|
var values;
|
|
275
|
-
|
|
276
227
|
if (dependingOn.sameTerm(ns.rdf('type'))) {
|
|
277
228
|
values = Object.keys(kb.findTypeURIs(subject)).map(function (uri) {
|
|
278
229
|
return $rdf.sym(uri);
|
|
@@ -280,22 +231,17 @@ _fieldFunction.field[ns.ui('Options').uri] = function (dom, container, already,
|
|
|
280
231
|
} else {
|
|
281
232
|
values = kb.each(subject, dependingOn);
|
|
282
233
|
}
|
|
283
|
-
|
|
284
234
|
for (var i = 0; i < cases.length; i++) {
|
|
285
235
|
var c = cases[i];
|
|
286
236
|
var tests = kb.each(c, ui('for'), null, formDoc); // There can be multiple 'for'
|
|
287
|
-
|
|
288
237
|
var match = false;
|
|
289
|
-
|
|
290
238
|
for (var j = 0; j < tests.length; j++) {
|
|
291
239
|
var _iterator = _createForOfIteratorHelper(values),
|
|
292
|
-
|
|
293
|
-
|
|
240
|
+
_step;
|
|
294
241
|
try {
|
|
295
242
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
296
243
|
var value = _step.value;
|
|
297
244
|
var test = tests[j];
|
|
298
|
-
|
|
299
245
|
if (value.sameTerm(tests) || value.termType === test.termType && value.value === test.value) {
|
|
300
246
|
match = true;
|
|
301
247
|
}
|
|
@@ -306,24 +252,21 @@ _fieldFunction.field[ns.ui('Options').uri] = function (dom, container, already,
|
|
|
306
252
|
_iterator.f();
|
|
307
253
|
}
|
|
308
254
|
}
|
|
309
|
-
|
|
310
255
|
if (match) {
|
|
311
256
|
var _field3 = kb.the(c, ui('use'));
|
|
312
|
-
|
|
313
257
|
if (!_field3) {
|
|
314
258
|
box.appendChild((0, _error.errorMessageBlock)(dom, 'No "use" part for case in form ' + form));
|
|
315
259
|
return box;
|
|
316
260
|
} else {
|
|
317
261
|
appendForm(dom, box, already, subject, _field3, dataDoc, callbackFunction);
|
|
318
262
|
}
|
|
319
|
-
|
|
320
263
|
break;
|
|
321
264
|
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
|
|
265
|
+
}
|
|
266
|
+
// @@ Add box.refresh() to sync fields with values
|
|
325
267
|
return box;
|
|
326
268
|
};
|
|
269
|
+
|
|
327
270
|
/** Multiple field: zero or more similar subFields
|
|
328
271
|
**
|
|
329
272
|
** @param {Document} dom The HTML Document object aka Document Object Model
|
|
@@ -341,8 +284,6 @@ _fieldFunction.field[ns.ui('Options').uri] = function (dom, container, already,
|
|
|
341
284
|
** @param {NamedNode} property The property to be written in the data
|
|
342
285
|
** @param {Boolean} ordered Is the list an ordered one where the user defined the order
|
|
343
286
|
*/
|
|
344
|
-
|
|
345
|
-
|
|
346
287
|
_fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) {
|
|
347
288
|
/** Diagnostic function
|
|
348
289
|
*/
|
|
@@ -351,12 +292,11 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
351
292
|
return x.toString().slice(-7);
|
|
352
293
|
}).join(', ');
|
|
353
294
|
}
|
|
295
|
+
|
|
354
296
|
/** Add an item to the local quadstore not the UI or the web
|
|
355
297
|
*
|
|
356
298
|
* @param {Node} object The RDF object to be represented by this item.
|
|
357
299
|
*/
|
|
358
|
-
|
|
359
|
-
|
|
360
300
|
function addItem() {
|
|
361
301
|
return _addItem.apply(this, arguments);
|
|
362
302
|
}
|
|
@@ -364,8 +304,6 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
364
304
|
* @param {Event} anyEvent if used as an event handler
|
|
365
305
|
* @param {Node} object The RDF object to be represented by this item.
|
|
366
306
|
*/
|
|
367
|
-
|
|
368
|
-
|
|
369
307
|
function _addItem() {
|
|
370
308
|
_addItem = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
|
|
371
309
|
var object, toBeInserted, msg;
|
|
@@ -374,43 +312,34 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
374
312
|
switch (_context6.prev = _context6.next) {
|
|
375
313
|
case 0:
|
|
376
314
|
object = newThing(dataDoc); // by default just add new nodes
|
|
377
|
-
|
|
378
315
|
if (!ordered) {
|
|
379
316
|
_context6.next = 8;
|
|
380
317
|
break;
|
|
381
318
|
}
|
|
382
|
-
|
|
383
319
|
createListIfNecessary(); // Sets list and unsavedList
|
|
384
|
-
|
|
385
320
|
list.elements.push(object);
|
|
386
321
|
_context6.next = 6;
|
|
387
322
|
return saveListThenRefresh();
|
|
388
|
-
|
|
389
323
|
case 6:
|
|
390
324
|
_context6.next = 20;
|
|
391
325
|
break;
|
|
392
|
-
|
|
393
326
|
case 8:
|
|
394
327
|
// eslint-disable-next-line multiline-ternary
|
|
395
328
|
toBeInserted = reverse ? [$rdf.st(object, property, subject, dataDoc)] : [$rdf.st(subject, property, object, dataDoc)];
|
|
396
329
|
_context6.prev = 9;
|
|
397
330
|
_context6.next = 12;
|
|
398
331
|
return kb.updater.update([], toBeInserted);
|
|
399
|
-
|
|
400
332
|
case 12:
|
|
401
333
|
_context6.next = 19;
|
|
402
334
|
break;
|
|
403
|
-
|
|
404
335
|
case 14:
|
|
405
336
|
_context6.prev = 14;
|
|
406
337
|
_context6.t0 = _context6["catch"](9);
|
|
407
338
|
msg = 'Error adding to unordered multiple: ' + _context6.t0;
|
|
408
339
|
box.appendChild((0, _error.errorMessageBlock)(dom, msg));
|
|
409
340
|
debug.error(msg);
|
|
410
|
-
|
|
411
341
|
case 19:
|
|
412
342
|
refresh();
|
|
413
|
-
|
|
414
343
|
case 20:
|
|
415
344
|
case "end":
|
|
416
345
|
return _context6.stop();
|
|
@@ -420,7 +349,6 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
420
349
|
}));
|
|
421
350
|
return _addItem.apply(this, arguments);
|
|
422
351
|
}
|
|
423
|
-
|
|
424
352
|
function renderItem(object) {
|
|
425
353
|
function deleteThisItem() {
|
|
426
354
|
return _deleteThisItem.apply(this, arguments);
|
|
@@ -429,8 +357,6 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
429
357
|
* @param {Event} anyEvent if used as an event handler
|
|
430
358
|
* @param {Boolean} upwards Move this up (true) or down (false).
|
|
431
359
|
*/
|
|
432
|
-
|
|
433
|
-
|
|
434
360
|
function _deleteThisItem() {
|
|
435
361
|
_deleteThisItem = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
436
362
|
var i, del;
|
|
@@ -442,37 +368,29 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
442
368
|
_context3.next = 14;
|
|
443
369
|
break;
|
|
444
370
|
}
|
|
445
|
-
|
|
446
371
|
debug.log('pre delete: ' + debugString(list.elements));
|
|
447
372
|
i = 0;
|
|
448
|
-
|
|
449
373
|
case 3:
|
|
450
374
|
if (!(i < list.elements.length)) {
|
|
451
375
|
_context3.next = 12;
|
|
452
376
|
break;
|
|
453
377
|
}
|
|
454
|
-
|
|
455
378
|
if (!list.elements[i].sameTerm(object)) {
|
|
456
379
|
_context3.next = 9;
|
|
457
380
|
break;
|
|
458
381
|
}
|
|
459
|
-
|
|
460
382
|
list.elements.splice(i, 1);
|
|
461
383
|
_context3.next = 8;
|
|
462
384
|
return saveListThenRefresh();
|
|
463
|
-
|
|
464
385
|
case 8:
|
|
465
386
|
return _context3.abrupt("return");
|
|
466
|
-
|
|
467
387
|
case 9:
|
|
468
388
|
i++;
|
|
469
389
|
_context3.next = 3;
|
|
470
390
|
break;
|
|
471
|
-
|
|
472
391
|
case 12:
|
|
473
392
|
_context3.next = 15;
|
|
474
393
|
break;
|
|
475
|
-
|
|
476
394
|
case 14:
|
|
477
395
|
// unordered
|
|
478
396
|
if (kb.holds(subject, property, object, dataDoc)) {
|
|
@@ -485,7 +403,6 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
485
403
|
}
|
|
486
404
|
});
|
|
487
405
|
}
|
|
488
|
-
|
|
489
406
|
case 15:
|
|
490
407
|
case "end":
|
|
491
408
|
return _context3.stop();
|
|
@@ -495,7 +412,6 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
495
412
|
}));
|
|
496
413
|
return _deleteThisItem.apply(this, arguments);
|
|
497
414
|
}
|
|
498
|
-
|
|
499
415
|
function moveThisItem(_x, _x2) {
|
|
500
416
|
return _moveThisItem.apply(this, arguments);
|
|
501
417
|
}
|
|
@@ -504,8 +420,6 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
504
420
|
* One possibility is to not actually make the link to the thing until
|
|
505
421
|
* this callback happens to avoid widow links
|
|
506
422
|
*/
|
|
507
|
-
|
|
508
|
-
|
|
509
423
|
function _moveThisItem() {
|
|
510
424
|
_moveThisItem = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(event, upwards) {
|
|
511
425
|
var i;
|
|
@@ -516,66 +430,50 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
516
430
|
// @@ possibly, allow shift+click to do move to top or bottom?
|
|
517
431
|
debug.log('pre move: ' + debugString(list.elements));
|
|
518
432
|
i = 0;
|
|
519
|
-
|
|
520
433
|
case 2:
|
|
521
434
|
if (!(i < list.elements.length)) {
|
|
522
435
|
_context4.next = 8;
|
|
523
436
|
break;
|
|
524
437
|
}
|
|
525
|
-
|
|
526
438
|
if (!list.elements[i].sameTerm(object)) {
|
|
527
439
|
_context4.next = 5;
|
|
528
440
|
break;
|
|
529
441
|
}
|
|
530
|
-
|
|
531
442
|
return _context4.abrupt("break", 8);
|
|
532
|
-
|
|
533
443
|
case 5:
|
|
534
444
|
i++;
|
|
535
445
|
_context4.next = 2;
|
|
536
446
|
break;
|
|
537
|
-
|
|
538
447
|
case 8:
|
|
539
448
|
if (i === list.elements.length) {
|
|
540
449
|
alert('list move: not found element for ' + object);
|
|
541
450
|
}
|
|
542
|
-
|
|
543
451
|
if (!upwards) {
|
|
544
452
|
_context4.next = 16;
|
|
545
453
|
break;
|
|
546
454
|
}
|
|
547
|
-
|
|
548
455
|
if (!(i === 0)) {
|
|
549
456
|
_context4.next = 13;
|
|
550
457
|
break;
|
|
551
458
|
}
|
|
552
|
-
|
|
553
459
|
alert('@@ boop - already at top -temp message'); // @@ make boop sound
|
|
554
|
-
|
|
555
460
|
return _context4.abrupt("return");
|
|
556
|
-
|
|
557
461
|
case 13:
|
|
558
462
|
list.elements.splice(i - 1, 2, list.elements[i], list.elements[i - 1]);
|
|
559
463
|
_context4.next = 20;
|
|
560
464
|
break;
|
|
561
|
-
|
|
562
465
|
case 16:
|
|
563
466
|
if (!(i === list.elements.length - 1)) {
|
|
564
467
|
_context4.next = 19;
|
|
565
468
|
break;
|
|
566
469
|
}
|
|
567
|
-
|
|
568
470
|
alert('@@ boop - already at bottom -temp message'); // @@ make boop sound
|
|
569
|
-
|
|
570
471
|
return _context4.abrupt("return");
|
|
571
|
-
|
|
572
472
|
case 19:
|
|
573
473
|
list.elements.splice(i, 2, list.elements[i + 1], list.elements[i]);
|
|
574
|
-
|
|
575
474
|
case 20:
|
|
576
475
|
_context4.next = 22;
|
|
577
476
|
return saveListThenRefresh();
|
|
578
|
-
|
|
579
477
|
case 22:
|
|
580
478
|
case "end":
|
|
581
479
|
return _context4.stop();
|
|
@@ -585,28 +483,22 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
585
483
|
}));
|
|
586
484
|
return _moveThisItem.apply(this, arguments);
|
|
587
485
|
}
|
|
588
|
-
|
|
589
486
|
function itemDone(ok, message) {
|
|
590
487
|
debug.log("Item done callback for item ".concat(object.toString()));
|
|
591
|
-
|
|
592
488
|
if (!ok) {
|
|
593
489
|
// when does this happen? errors typically deal with upstream
|
|
594
490
|
debug.error(' Item done callback: Error: ' + message);
|
|
595
491
|
}
|
|
596
|
-
|
|
597
492
|
callbackFunction(ok, message);
|
|
598
493
|
}
|
|
599
|
-
|
|
600
494
|
log.debug('Multiple: render object: ' + object);
|
|
601
495
|
var fn = (0, _fieldFunction.fieldFunction)(dom, element);
|
|
602
496
|
var subField = fn(dom, null, already, object, element, dataDoc, itemDone); // subfields was: body. moving to not passing that
|
|
603
|
-
|
|
604
497
|
subField.subject = object; // Keep a back pointer between the DOM array and the RDF objects
|
|
605
|
-
// delete button and move buttons
|
|
606
498
|
|
|
499
|
+
// delete button and move buttons
|
|
607
500
|
if (kb.updater.editable(dataDoc.uri)) {
|
|
608
501
|
buttons.deleteButtonWithCheck(dom, subField, multipleUIlabel, deleteThisItem);
|
|
609
|
-
|
|
610
502
|
if (ordered) {
|
|
611
503
|
// Add controsl in a frame
|
|
612
504
|
var frame = dom.createElement('div');
|
|
@@ -620,7 +512,6 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
620
512
|
switch (_context.prev = _context.next) {
|
|
621
513
|
case 0:
|
|
622
514
|
return _context.abrupt("return", moveThisItem(event, true));
|
|
623
|
-
|
|
624
515
|
case 1:
|
|
625
516
|
case "end":
|
|
626
517
|
return _context.stop();
|
|
@@ -628,7 +519,6 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
628
519
|
}
|
|
629
520
|
}, _callee);
|
|
630
521
|
}));
|
|
631
|
-
|
|
632
522
|
return function (_x3) {
|
|
633
523
|
return _ref.apply(this, arguments);
|
|
634
524
|
};
|
|
@@ -640,7 +530,6 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
640
530
|
switch (_context2.prev = _context2.next) {
|
|
641
531
|
case 0:
|
|
642
532
|
return _context2.abrupt("return", moveThisItem(event, false));
|
|
643
|
-
|
|
644
533
|
case 1:
|
|
645
534
|
case "end":
|
|
646
535
|
return _context2.stop();
|
|
@@ -648,17 +537,12 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
648
537
|
}
|
|
649
538
|
}, _callee2);
|
|
650
539
|
}));
|
|
651
|
-
|
|
652
540
|
return function (_x4) {
|
|
653
541
|
return _ref2.apply(this, arguments);
|
|
654
542
|
};
|
|
655
543
|
}());
|
|
656
|
-
|
|
657
544
|
var _shim = dom.createElement('div');
|
|
658
|
-
|
|
659
545
|
_shim.appendChild(subField); // Subfield has its own layout
|
|
660
|
-
|
|
661
|
-
|
|
662
546
|
frame.appendChild(_shim);
|
|
663
547
|
frame.appendChild(moveUpButton);
|
|
664
548
|
frame.appendChild(moveDownButton);
|
|
@@ -666,21 +550,18 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
666
550
|
moveDownButton.style.gridColumn = 2;
|
|
667
551
|
moveUpButton.style.gridRow = 1;
|
|
668
552
|
moveDownButton.style.padding = '0em'; // don't take too much space
|
|
669
|
-
|
|
670
553
|
moveUpButton.style.padding = '0em';
|
|
671
554
|
moveDownButton.style.gridRow = 2;
|
|
672
555
|
_shim.style.gridColumn = 1;
|
|
673
556
|
_shim.style.gridRowStart = 'span 2'; // Cover both rows
|
|
674
557
|
// shim.style.gridRowEnd = 2 // Cover both rows
|
|
675
|
-
|
|
676
558
|
return frame;
|
|
677
559
|
}
|
|
678
560
|
}
|
|
679
|
-
|
|
680
561
|
return subField; // unused
|
|
681
562
|
} // renderItem
|
|
682
|
-
/// ///////// Body of Multiple form field implementation
|
|
683
563
|
|
|
564
|
+
/// ///////// Body of Multiple form field implementation
|
|
684
565
|
|
|
685
566
|
var plusIconURI = _iconBase.icons.iconBase + 'noun_19460_green.svg'; // white plus in green circle
|
|
686
567
|
|
|
@@ -691,44 +572,33 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
691
572
|
var shim = box; // no shim
|
|
692
573
|
// We don't indent multiple as it is a sort of a prefix of the next field and has contents of one.
|
|
693
574
|
// box.setAttribute('style', 'padding-left: 2em; border: 0.05em solid green;') // Indent a multiple
|
|
694
|
-
|
|
695
575
|
var ui = ns.ui;
|
|
696
576
|
if (container) container.appendChild(box);
|
|
697
577
|
var orderedNode = kb.any(form, ui('ordered'));
|
|
698
578
|
var ordered = orderedNode ? $rdf.Node.toJS(orderedNode) : false;
|
|
699
579
|
var property = kb.any(form, ui('property'));
|
|
700
580
|
var reverse = kb.anyJS(form, ui('reverse'), null, formDoc);
|
|
701
|
-
|
|
702
581
|
if (!property) {
|
|
703
582
|
box.appendChild((0, _error.errorMessageBlock)(dom, 'No property to multiple: ' + form)); // used for arcs in the data
|
|
704
|
-
|
|
705
583
|
return shim;
|
|
706
584
|
}
|
|
707
|
-
|
|
708
585
|
var multipleUIlabel = kb.any(form, ui('label'));
|
|
709
586
|
if (!multipleUIlabel) multipleUIlabel = utils.label(property);
|
|
710
587
|
var min = kb.any(form, ui('min')); // This is the minimum number -- default 0
|
|
711
|
-
|
|
712
588
|
min = min ? 0 + min.value : 0;
|
|
713
589
|
var element = kb.any(form, ui('part')); // This is the form to use for each one
|
|
714
|
-
|
|
715
590
|
if (!element) {
|
|
716
591
|
box.appendChild((0, _error.errorMessageBlock)(dom, 'No part to multiple: ' + form));
|
|
717
592
|
return shim;
|
|
718
593
|
}
|
|
719
|
-
|
|
720
594
|
var body = box.appendChild(dom.createElement('div'));
|
|
721
595
|
body.style.display = 'flex';
|
|
722
596
|
body.style.flexDirection = 'column';
|
|
723
597
|
var list; // The RDF collection which keeps the ordered version or null
|
|
724
|
-
|
|
725
598
|
var values; // Initial values - always an array. Even when no list yet.
|
|
726
|
-
|
|
727
599
|
values = reverse ? kb.any(null, property, subject, dataDoc) : kb.any(subject, property, null, dataDoc);
|
|
728
|
-
|
|
729
600
|
if (ordered) {
|
|
730
601
|
list = reverse ? kb.any(null, property, subject, dataDoc) : kb.any(subject, property, null, dataDoc);
|
|
731
|
-
|
|
732
602
|
if (list) {
|
|
733
603
|
values = list.elements;
|
|
734
604
|
} else {
|
|
@@ -737,15 +607,13 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
737
607
|
} else {
|
|
738
608
|
values = reverse ? kb.each(null, property, subject, dataDoc) : kb.each(subject, property, null, dataDoc);
|
|
739
609
|
list = null;
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
|
|
610
|
+
}
|
|
611
|
+
// Add control on the bottom for adding more items
|
|
743
612
|
if (kb.updater.editable(dataDoc.uri)) {
|
|
744
613
|
var tail = box.appendChild(dom.createElement('div'));
|
|
745
614
|
tail.style.padding = '0.5em';
|
|
746
615
|
var img = tail.appendChild(dom.createElement('img'));
|
|
747
616
|
img.setAttribute('src', plusIconURI); // plus sign
|
|
748
|
-
|
|
749
617
|
img.setAttribute('style', 'margin: 0.2em; width: 1.5em; height:1.5em');
|
|
750
618
|
img.title = 'Click to add another ' + multipleUIlabel;
|
|
751
619
|
var prompt = dom.createElement('span');
|
|
@@ -758,7 +626,6 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
758
626
|
case 0:
|
|
759
627
|
_context5.next = 2;
|
|
760
628
|
return addItem();
|
|
761
|
-
|
|
762
629
|
case 2:
|
|
763
630
|
case "end":
|
|
764
631
|
return _context5.stop();
|
|
@@ -766,18 +633,15 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
766
633
|
}
|
|
767
634
|
}, _callee5);
|
|
768
635
|
}));
|
|
769
|
-
|
|
770
636
|
return function (_x5) {
|
|
771
637
|
return _ref3.apply(this, arguments);
|
|
772
638
|
};
|
|
773
639
|
}(), true);
|
|
774
640
|
tail.appendChild(prompt);
|
|
775
641
|
}
|
|
776
|
-
|
|
777
642
|
function createListIfNecessary() {
|
|
778
643
|
if (!list) {
|
|
779
644
|
list = new $rdf.Collection();
|
|
780
|
-
|
|
781
645
|
if (reverse) {
|
|
782
646
|
kb.add(list, property, subject, dataDoc);
|
|
783
647
|
} else {
|
|
@@ -785,11 +649,9 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
785
649
|
}
|
|
786
650
|
}
|
|
787
651
|
}
|
|
788
|
-
|
|
789
652
|
function saveListThenRefresh() {
|
|
790
653
|
return _saveListThenRefresh.apply(this, arguments);
|
|
791
654
|
}
|
|
792
|
-
|
|
793
655
|
function _saveListThenRefresh() {
|
|
794
656
|
_saveListThenRefresh = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
|
|
795
657
|
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
@@ -802,20 +664,16 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
802
664
|
_context7.prev = 2;
|
|
803
665
|
_context7.next = 5;
|
|
804
666
|
return kb.fetcher.putBack(dataDoc);
|
|
805
|
-
|
|
806
667
|
case 5:
|
|
807
668
|
_context7.next = 11;
|
|
808
669
|
break;
|
|
809
|
-
|
|
810
670
|
case 7:
|
|
811
671
|
_context7.prev = 7;
|
|
812
672
|
_context7.t0 = _context7["catch"](2);
|
|
813
673
|
box.appendChild((0, _error.errorMessageBlock)(dom, 'Error trying to put back a list: ' + _context7.t0));
|
|
814
674
|
return _context7.abrupt("return");
|
|
815
|
-
|
|
816
675
|
case 11:
|
|
817
676
|
refresh();
|
|
818
|
-
|
|
819
677
|
case 12:
|
|
820
678
|
case "end":
|
|
821
679
|
return _context7.stop();
|
|
@@ -825,10 +683,8 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
825
683
|
}));
|
|
826
684
|
return _saveListThenRefresh.apply(this, arguments);
|
|
827
685
|
}
|
|
828
|
-
|
|
829
686
|
function refresh() {
|
|
830
687
|
var vals;
|
|
831
|
-
|
|
832
688
|
if (ordered) {
|
|
833
689
|
var li = reverse ? kb.the(null, property, subject, dataDoc) : kb.the(subject, property, null, dataDoc);
|
|
834
690
|
vals = li ? li.elements : [];
|
|
@@ -839,15 +695,11 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
839
695
|
|
|
840
696
|
utils.syncTableToArrayReOrdered(body, vals, renderItem);
|
|
841
697
|
}
|
|
842
|
-
|
|
843
698
|
body.refresh = refresh; // Allow live update
|
|
844
|
-
|
|
845
699
|
refresh();
|
|
846
|
-
|
|
847
700
|
function asyncStuff() {
|
|
848
701
|
return _asyncStuff.apply(this, arguments);
|
|
849
702
|
}
|
|
850
|
-
|
|
851
703
|
function _asyncStuff() {
|
|
852
704
|
_asyncStuff = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
|
|
853
705
|
var extra, j;
|
|
@@ -856,33 +708,26 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
856
708
|
switch (_context8.prev = _context8.next) {
|
|
857
709
|
case 0:
|
|
858
710
|
extra = min - values.length;
|
|
859
|
-
|
|
860
711
|
if (!(extra > 0)) {
|
|
861
712
|
_context8.next = 12;
|
|
862
713
|
break;
|
|
863
714
|
}
|
|
864
|
-
|
|
865
715
|
j = 0;
|
|
866
|
-
|
|
867
716
|
case 3:
|
|
868
717
|
if (!(j < extra)) {
|
|
869
718
|
_context8.next = 10;
|
|
870
719
|
break;
|
|
871
720
|
}
|
|
872
|
-
|
|
873
721
|
debug.log('Adding extra: min ' + min);
|
|
874
722
|
_context8.next = 7;
|
|
875
723
|
return addItem();
|
|
876
|
-
|
|
877
724
|
case 7:
|
|
878
725
|
j++;
|
|
879
726
|
_context8.next = 3;
|
|
880
727
|
break;
|
|
881
|
-
|
|
882
728
|
case 10:
|
|
883
729
|
_context8.next = 12;
|
|
884
730
|
return saveListThenRefresh();
|
|
885
|
-
|
|
886
731
|
case 12:
|
|
887
732
|
case "end":
|
|
888
733
|
return _context8.stop();
|
|
@@ -892,7 +737,6 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
892
737
|
}));
|
|
893
738
|
return _asyncStuff.apply(this, arguments);
|
|
894
739
|
}
|
|
895
|
-
|
|
896
740
|
asyncStuff().then(function () {
|
|
897
741
|
debug.log(' Multiple render: async stuff ok');
|
|
898
742
|
}, function (err) {
|
|
@@ -909,7 +753,6 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
909
753
|
// or use HTML5: http://www.w3.org/TR/2011/WD-html-markup-20110113/input.date.html
|
|
910
754
|
//
|
|
911
755
|
|
|
912
|
-
|
|
913
756
|
_fieldFunction.field[ns.ui('PhoneField').uri] = _basic.basicField;
|
|
914
757
|
_fieldFunction.field[ns.ui('EmailField').uri] = _basic.basicField;
|
|
915
758
|
_fieldFunction.field[ns.ui('ColorField').uri] = _basic.basicField;
|
|
@@ -923,6 +766,7 @@ _fieldFunction.field[ns.ui('FloatField').uri] = _basic.basicField;
|
|
|
923
766
|
_fieldFunction.field[ns.ui('TextField').uri] = _basic.basicField;
|
|
924
767
|
_fieldFunction.field[ns.ui('SingleLineTextField').uri] = _basic.basicField;
|
|
925
768
|
_fieldFunction.field[ns.ui('NamedNodeURIField').uri] = _basic.basicField;
|
|
769
|
+
|
|
926
770
|
/* Multiline Text field
|
|
927
771
|
**
|
|
928
772
|
*/
|
|
@@ -933,11 +777,9 @@ _fieldFunction.field[ns.ui('MultiLineTextField').uri] = function (dom, container
|
|
|
933
777
|
var formDoc = form.doc ? form.doc() : null; // @@ if blank no way to know
|
|
934
778
|
|
|
935
779
|
var property = kb.any(form, ui('property'));
|
|
936
|
-
|
|
937
780
|
if (!property) {
|
|
938
781
|
return (0, _error.errorMessageBlock)(dom, 'No property to text field: ' + form);
|
|
939
782
|
}
|
|
940
|
-
|
|
941
783
|
var box = dom.createElement('div');
|
|
942
784
|
box.style.display = 'flex';
|
|
943
785
|
box.style.flexDirection = 'row';
|
|
@@ -949,58 +791,48 @@ _fieldFunction.field[ns.ui('MultiLineTextField').uri] = function (dom, container
|
|
|
949
791
|
var text = kb.anyJS(subject, property, null, dataDoc) || '';
|
|
950
792
|
var editable = kb.updater.editable(dataDoc.uri);
|
|
951
793
|
var suppressEmptyUneditable = form && kb.anyJS(form, ns.ui('suppressEmptyUneditable'), null, formDoc);
|
|
952
|
-
|
|
953
794
|
if (!editable && suppressEmptyUneditable && text === '') {
|
|
954
795
|
box.style.display = 'none';
|
|
955
796
|
}
|
|
956
|
-
|
|
957
797
|
var field = makeDescription(dom, kb, subject, property, dataDoc, callbackFunction);
|
|
958
798
|
right.appendChild(field);
|
|
959
799
|
if (container) container.appendChild(box);
|
|
960
800
|
return box;
|
|
961
801
|
};
|
|
802
|
+
|
|
962
803
|
/* Boolean field and Tri-state version (true/false/null)
|
|
963
804
|
**
|
|
964
805
|
** @@ todo: remove tristate param
|
|
965
806
|
*/
|
|
966
|
-
|
|
967
|
-
|
|
968
807
|
function booleanField(dom, container, already, subject, form, dataDoc, callbackFunction, tristate) {
|
|
969
808
|
var ui = ns.ui;
|
|
970
809
|
var kb = _solidLogic.store;
|
|
971
810
|
var property = kb.any(form, ui('property'));
|
|
972
|
-
|
|
973
811
|
if (!property) {
|
|
974
812
|
var errorBlock = (0, _error.errorMessageBlock)(dom, 'No property to boolean field: ' + form);
|
|
975
813
|
if (container) container.appendChild(errorBlock);
|
|
976
814
|
return errorBlock;
|
|
977
815
|
}
|
|
978
|
-
|
|
979
816
|
var lab = kb.any(form, ui('label'));
|
|
980
817
|
if (!lab) lab = utils.label(property, true); // Init capital
|
|
981
|
-
|
|
982
818
|
dataDoc = (0, _basic.fieldStore)(subject, property, dataDoc);
|
|
983
819
|
var state = kb.any(subject, property);
|
|
984
|
-
|
|
985
820
|
if (state === undefined) {
|
|
986
821
|
state = false;
|
|
987
822
|
} // @@ sure we want that -- or three-state?
|
|
988
|
-
|
|
989
|
-
|
|
990
823
|
var ins = $rdf.st(subject, property, true, dataDoc);
|
|
991
824
|
var del = $rdf.st(subject, property, false, dataDoc);
|
|
992
825
|
var box = buildCheckboxForm(dom, kb, lab, del, ins, form, dataDoc, tristate);
|
|
993
826
|
if (container) container.appendChild(box);
|
|
994
827
|
return box;
|
|
995
828
|
}
|
|
996
|
-
|
|
997
829
|
_fieldFunction.field[ns.ui('BooleanField').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) {
|
|
998
830
|
return booleanField(dom, container, already, subject, form, dataDoc, callbackFunction, false);
|
|
999
831
|
};
|
|
1000
|
-
|
|
1001
832
|
_fieldFunction.field[ns.ui('TristateField').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) {
|
|
1002
833
|
return booleanField(dom, container, already, subject, form, dataDoc, callbackFunction, true);
|
|
1003
834
|
};
|
|
835
|
+
|
|
1004
836
|
/* Classifier field
|
|
1005
837
|
**
|
|
1006
838
|
** Nested categories
|
|
@@ -1008,27 +840,23 @@ _fieldFunction.field[ns.ui('TristateField').uri] = function (dom, container, alr
|
|
|
1008
840
|
** @@ To do: If a classification changes, then change any dependent Options fields.
|
|
1009
841
|
*/
|
|
1010
842
|
|
|
1011
|
-
|
|
1012
843
|
_fieldFunction.field[ns.ui('Classifier').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) {
|
|
1013
844
|
var kb = _solidLogic.store;
|
|
1014
845
|
var ui = ns.ui;
|
|
1015
846
|
var category = kb.any(form, ui('category'));
|
|
1016
|
-
|
|
1017
847
|
if (!category) {
|
|
1018
848
|
return (0, _error.errorMessageBlock)(dom, 'No category for classifier: ' + form);
|
|
1019
849
|
}
|
|
1020
|
-
|
|
1021
850
|
log.debug('Classifier: dataDoc=' + dataDoc);
|
|
1022
|
-
|
|
1023
851
|
var checkOptions = function checkOptions(ok, body) {
|
|
1024
852
|
if (!ok) return callbackFunction(ok, body);
|
|
1025
853
|
return callbackFunction(ok, body);
|
|
1026
854
|
};
|
|
1027
|
-
|
|
1028
855
|
var box = makeSelectForNestedCategory(dom, kb, subject, category, dataDoc, checkOptions);
|
|
1029
856
|
if (container) container.appendChild(box);
|
|
1030
857
|
return box;
|
|
1031
858
|
};
|
|
859
|
+
|
|
1032
860
|
/** Choice field
|
|
1033
861
|
**
|
|
1034
862
|
** Not nested. Generates a link to something from a given class.
|
|
@@ -1049,7 +877,6 @@ _fieldFunction.field[ns.ui('Classifier').uri] = function (dom, container, alread
|
|
|
1049
877
|
** TODO: according to ontology ui:choice can also have ns.ui('default') - this is not implemented yet
|
|
1050
878
|
*/
|
|
1051
879
|
|
|
1052
|
-
|
|
1053
880
|
_fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) {
|
|
1054
881
|
var ui = ns.ui;
|
|
1055
882
|
var kb = _solidLogic.store;
|
|
@@ -1057,8 +884,8 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
1057
884
|
|
|
1058
885
|
var p;
|
|
1059
886
|
var box = dom.createElement('div');
|
|
1060
|
-
box.setAttribute('class', 'choiceBox');
|
|
1061
|
-
|
|
887
|
+
box.setAttribute('class', 'choiceBox');
|
|
888
|
+
// Set flexDirection column?
|
|
1062
889
|
if (container) container.appendChild(box);
|
|
1063
890
|
var lhs = dom.createElement('div');
|
|
1064
891
|
lhs.setAttribute('class', 'formFieldName choiceBox-label');
|
|
@@ -1067,18 +894,14 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
1067
894
|
rhs.setAttribute('class', 'formFieldValue choiceBox-selectBox');
|
|
1068
895
|
box.appendChild(rhs);
|
|
1069
896
|
var property = kb.any(form, ui('property'));
|
|
1070
|
-
|
|
1071
897
|
if (!property) {
|
|
1072
898
|
return box.appendChild((0, _error.errorMessageBlock)(dom, 'No property for Choice: ' + form));
|
|
1073
899
|
}
|
|
1074
|
-
|
|
1075
900
|
lhs.appendChild((0, _basic.fieldLabel)(dom, property, form));
|
|
1076
901
|
var uiFrom = kb.any(form, ui('from'));
|
|
1077
|
-
|
|
1078
902
|
if (!uiFrom) {
|
|
1079
903
|
return (0, _error.errorMessageBlock)(dom, "No 'from' for Choice: " + form);
|
|
1080
904
|
}
|
|
1081
|
-
|
|
1082
905
|
var subForm = kb.any(form, ui('use')); // Optional
|
|
1083
906
|
// const follow = kb.anyJS(form, ui('follow'), null, formDoc) // data doc moves to new subject?
|
|
1084
907
|
|
|
@@ -1087,78 +910,65 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
1087
910
|
subForm: subForm,
|
|
1088
911
|
disambiguate: false
|
|
1089
912
|
};
|
|
1090
|
-
|
|
1091
913
|
function getSelectorOptions() {
|
|
1092
914
|
var possible = [];
|
|
1093
915
|
var possibleProperties;
|
|
1094
916
|
possible = kb.each(undefined, ns.rdf('type'), uiFrom, formDoc);
|
|
1095
|
-
|
|
1096
917
|
for (var x in findMembersNT(kb, uiFrom, dataDoc)) {
|
|
1097
918
|
possible.push(kb.fromNT(x));
|
|
1098
919
|
} // Use rdfs
|
|
1099
920
|
|
|
1100
|
-
|
|
1101
921
|
if (uiFrom.sameTerm(ns.rdfs('Class'))) {
|
|
1102
922
|
for (p in buttons.allClassURIs()) {
|
|
1103
923
|
possible.push(kb.sym(p));
|
|
1104
|
-
}
|
|
1105
|
-
|
|
924
|
+
}
|
|
925
|
+
// log.debug("%%% Choice field: possible.length 2 = "+possible.length)
|
|
1106
926
|
} else if (uiFrom.sameTerm(ns.rdf('Property'))) {
|
|
1107
927
|
possibleProperties = buttons.propertyTriage(kb);
|
|
1108
|
-
|
|
1109
928
|
for (p in possibleProperties.op) {
|
|
1110
929
|
possible.push(kb.fromNT(p));
|
|
1111
930
|
}
|
|
1112
|
-
|
|
1113
931
|
for (p in possibleProperties.dp) {
|
|
1114
932
|
possible.push(kb.fromNT(p));
|
|
1115
933
|
}
|
|
1116
|
-
|
|
1117
934
|
opts.disambiguate = true; // This is a big class, and the labels won't be enough.
|
|
1118
935
|
} else if (uiFrom.sameTerm(ns.owl('ObjectProperty'))) {
|
|
1119
936
|
possibleProperties = buttons.propertyTriage(kb);
|
|
1120
|
-
|
|
1121
937
|
for (p in possibleProperties.op) {
|
|
1122
938
|
possible.push(kb.fromNT(p));
|
|
1123
939
|
}
|
|
1124
|
-
|
|
1125
940
|
opts.disambiguate = true;
|
|
1126
941
|
} else if (uiFrom.sameTerm(ns.owl('DatatypeProperty'))) {
|
|
1127
942
|
possibleProperties = buttons.propertyTriage(kb);
|
|
1128
|
-
|
|
1129
943
|
for (p in possibleProperties.dp) {
|
|
1130
944
|
possible.push(kb.fromNT(p));
|
|
1131
945
|
}
|
|
1132
|
-
|
|
1133
946
|
opts.disambiguate = true;
|
|
1134
947
|
}
|
|
948
|
+
return possible;
|
|
949
|
+
// return sortByLabel(possible)
|
|
950
|
+
}
|
|
1135
951
|
|
|
1136
|
-
|
|
1137
|
-
} // TODO: this checks for any occurrence, regardless of true or false setting
|
|
1138
|
-
|
|
1139
|
-
|
|
952
|
+
// TODO: this checks for any occurrence, regardless of true or false setting
|
|
1140
953
|
if (kb.any(form, ui('canMintNew'))) {
|
|
1141
954
|
opts.mint = '* Create new *'; // @@ could be better
|
|
1142
955
|
}
|
|
1143
956
|
|
|
1144
957
|
var multiSelect = kb.any(form, ui('multiselect')); // Optional
|
|
1145
|
-
|
|
1146
958
|
if (multiSelect) opts.multiSelect = true;
|
|
1147
959
|
var selector;
|
|
1148
|
-
|
|
1149
960
|
rhs.refresh = function () {
|
|
1150
961
|
// from ui:property
|
|
1151
962
|
var selectedOptions = kb.each(subject, property, null, dataDoc).map(function (object) {
|
|
1152
963
|
return object.value;
|
|
1153
|
-
});
|
|
1154
|
-
|
|
964
|
+
});
|
|
965
|
+
// from ui:from + ui:property
|
|
1155
966
|
var possibleOptions = getSelectorOptions();
|
|
1156
967
|
possibleOptions.push(selectedOptions);
|
|
1157
968
|
possibleOptions = sortByLabel(possibleOptions);
|
|
1158
969
|
selector = makeSelectForChoice(dom, rhs, kb, subject, property, possibleOptions, selectedOptions, uiFrom, opts, dataDoc, callbackFunction);
|
|
1159
970
|
rhs.innerHTML = '';
|
|
1160
971
|
rhs.appendChild(selector);
|
|
1161
|
-
|
|
1162
972
|
if (multiSelect) {
|
|
1163
973
|
var multiSelectDiv = new _multiSelect.IconicMultiSelect({
|
|
1164
974
|
placeholder: selector.selected,
|
|
@@ -1174,20 +984,16 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
1174
984
|
return value !== event.value;
|
|
1175
985
|
});
|
|
1176
986
|
}
|
|
1177
|
-
|
|
1178
987
|
if (event.action === 'CLEAR_ALL_OPTIONS') {
|
|
1179
988
|
selectedOptions = [];
|
|
1180
989
|
}
|
|
1181
|
-
|
|
1182
990
|
if (event.action === 'ADD_OPTION') {
|
|
1183
991
|
var stringValue = event.value + '';
|
|
1184
|
-
|
|
1185
992
|
if (stringValue.includes('Create new')) {
|
|
1186
993
|
var newObject = newThing(dataDoc);
|
|
1187
994
|
var is = [];
|
|
1188
995
|
is.push($rdf.st(subject, property, kb.sym(newObject), dataDoc));
|
|
1189
996
|
if (uiFrom) is.push($rdf.st(newObject, ns.rdf('type'), kb.sym(uiFrom), dataDoc));
|
|
1190
|
-
|
|
1191
997
|
if (subForm) {
|
|
1192
998
|
addSubFormChoice(dom, rhs, {}, $rdf.sym(newObject), subForm, dataDoc, function (ok, body) {
|
|
1193
999
|
if (ok) {
|
|
@@ -1206,22 +1012,20 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
1206
1012
|
}
|
|
1207
1013
|
} else selectedOptions.push(event.value);
|
|
1208
1014
|
}
|
|
1209
|
-
|
|
1210
1015
|
selector.update(selectedOptions);
|
|
1211
1016
|
});
|
|
1212
1017
|
}
|
|
1213
1018
|
};
|
|
1214
|
-
|
|
1215
1019
|
rhs.refresh();
|
|
1216
1020
|
if (selector && selector.refresh) selector.refresh();
|
|
1217
1021
|
return box;
|
|
1218
1022
|
};
|
|
1219
|
-
|
|
1220
1023
|
function addSubFormChoice(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction) {
|
|
1221
1024
|
(0, _fieldFunction.fieldFunction)(dom, subForm)(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction);
|
|
1222
|
-
}
|
|
1223
|
-
//
|
|
1025
|
+
}
|
|
1224
1026
|
|
|
1027
|
+
// Documentation - non-interactive fields
|
|
1028
|
+
//
|
|
1225
1029
|
|
|
1226
1030
|
_fieldFunction.field[ns.ui('Comment').uri] = _fieldFunction.field[ns.ui('Heading').uri] = function (dom, container, already, subject, form, dataDoc, _callbackFunction) {
|
|
1227
1031
|
var ui = ns.ui;
|
|
@@ -1236,23 +1040,22 @@ _fieldFunction.field[ns.ui('Comment').uri] = _fieldFunction.field[ns.ui('Heading
|
|
|
1236
1040
|
if (container) container.appendChild(box);
|
|
1237
1041
|
var p = box.appendChild(dom.createElement(params.element));
|
|
1238
1042
|
p.textContent = contents;
|
|
1239
|
-
(0, _formStyle.setFieldStyle)(p, form);
|
|
1043
|
+
(0, _formStyle.setFieldStyle)(p, form);
|
|
1240
1044
|
|
|
1045
|
+
// Some headings and prompts are only useful to guide user input
|
|
1241
1046
|
var suppressIfUneditable = kb.anyJS(form, ns.ui('suppressIfUneditable'), null, formDoc);
|
|
1242
1047
|
var editable = kb.updater.editable(dataDoc.uri);
|
|
1243
|
-
|
|
1244
1048
|
if (suppressIfUneditable && !editable) {
|
|
1245
1049
|
box.style.display = 'none';
|
|
1246
1050
|
}
|
|
1247
|
-
|
|
1248
1051
|
return box;
|
|
1249
|
-
};
|
|
1052
|
+
};
|
|
1053
|
+
|
|
1054
|
+
// A button for editing a form (in place, at the moment)
|
|
1250
1055
|
//
|
|
1251
1056
|
// When editing forms, make it yellow, when editing thr form form, pink
|
|
1252
1057
|
// Help people understand how many levels down they are.
|
|
1253
1058
|
//
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
1059
|
function editFormButton(dom, container, form, dataDoc, callbackFunction) {
|
|
1257
1060
|
var b = dom.createElement('button');
|
|
1258
1061
|
b.setAttribute('type', 'button');
|
|
@@ -1264,10 +1067,10 @@ function editFormButton(dom, container, form, dataDoc, callbackFunction) {
|
|
|
1264
1067
|
}, true);
|
|
1265
1068
|
return b;
|
|
1266
1069
|
}
|
|
1267
|
-
|
|
1268
1070
|
function appendForm(dom, container, already, subject, form, dataDoc, itemDone) {
|
|
1269
1071
|
return (0, _fieldFunction.fieldFunction)(dom, form)(dom, container, already, subject, form, dataDoc, itemDone);
|
|
1270
1072
|
}
|
|
1073
|
+
|
|
1271
1074
|
/** Find list of properties for class
|
|
1272
1075
|
//
|
|
1273
1076
|
// Three possible sources: Those mentioned in schemas, which exludes many
|
|
@@ -1276,87 +1079,72 @@ function appendForm(dom, container, already, subject, form, dataDoc, itemDone) {
|
|
|
1276
1079
|
// being used with this class.
|
|
1277
1080
|
*/
|
|
1278
1081
|
|
|
1279
|
-
|
|
1280
1082
|
function propertiesForClass(kb, c) {
|
|
1281
1083
|
var explicit = kb.each(undefined, ns.rdf('range'), c);
|
|
1282
|
-
[ns.rdfs('comment'), ns.dc('title'),
|
|
1084
|
+
[ns.rdfs('comment'), ns.dc('title'),
|
|
1085
|
+
// Generic things
|
|
1283
1086
|
ns.foaf('name'), ns.foaf('homepage')].forEach(function (x) {
|
|
1284
1087
|
explicit.push(x);
|
|
1285
1088
|
});
|
|
1286
1089
|
var members = kb.each(undefined, ns.rdf('type'), c);
|
|
1287
1090
|
if (members.length > 60) members = members.slice(0, 60); // Array supports slice?
|
|
1288
|
-
|
|
1289
1091
|
var used = {};
|
|
1290
|
-
|
|
1291
1092
|
for (var i = 0; i < (members.length > 60 ? 60 : members.length); i++) {
|
|
1292
1093
|
kb.statementsMatching(members[i], undefined, undefined).forEach(function (st) {
|
|
1293
1094
|
used[st.predicate.uri] = true;
|
|
1294
1095
|
});
|
|
1295
1096
|
}
|
|
1296
|
-
|
|
1297
1097
|
explicit.forEach(function (p) {
|
|
1298
1098
|
used[p.uri] = true;
|
|
1299
1099
|
});
|
|
1300
1100
|
var result = [];
|
|
1301
|
-
|
|
1302
1101
|
for (var uri in used) {
|
|
1303
1102
|
result.push(kb.sym(uri));
|
|
1304
1103
|
}
|
|
1305
|
-
|
|
1306
1104
|
return result;
|
|
1307
1105
|
}
|
|
1106
|
+
|
|
1308
1107
|
/** Find the closest class
|
|
1309
1108
|
* @param kb The quad store
|
|
1310
1109
|
* @param cla - the URI of the class
|
|
1311
1110
|
* @param prop
|
|
1312
1111
|
*/
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
1112
|
function findClosest(kb, cla, prop) {
|
|
1316
1113
|
var agenda = [kb.sym(cla)]; // ordered - this is breadth first search
|
|
1317
|
-
|
|
1318
1114
|
while (agenda.length > 0) {
|
|
1319
1115
|
var c = agenda.shift(); // first
|
|
1320
|
-
|
|
1321
1116
|
var lists = kb.each(c, prop);
|
|
1322
1117
|
log.debug('Lists for ' + c + ', ' + prop + ': ' + lists.length);
|
|
1323
1118
|
if (lists.length !== 0) return lists;
|
|
1324
1119
|
var supers = kb.each(c, ns.rdfs('subClassOf'));
|
|
1325
|
-
|
|
1326
1120
|
for (var i = 0; i < supers.length; i++) {
|
|
1327
1121
|
agenda.push(supers[i]);
|
|
1328
1122
|
log.debug('findClosest: add super: ' + supers[i]);
|
|
1329
1123
|
}
|
|
1330
1124
|
}
|
|
1331
|
-
|
|
1332
1125
|
return [];
|
|
1333
|
-
}
|
|
1126
|
+
}
|
|
1334
1127
|
|
|
1128
|
+
// Which forms apply to a given existing subject?
|
|
1335
1129
|
|
|
1336
1130
|
function formsFor(subject) {
|
|
1337
1131
|
var kb = _solidLogic.store;
|
|
1338
1132
|
log.debug('formsFor: subject=' + subject);
|
|
1339
1133
|
var t = kb.findTypeURIs(subject);
|
|
1340
1134
|
var t1;
|
|
1341
|
-
|
|
1342
1135
|
for (t1 in t) {
|
|
1343
1136
|
log.debug(' type: ' + t1);
|
|
1344
1137
|
}
|
|
1345
|
-
|
|
1346
1138
|
var bottom = kb.bottomTypeURIs(t); // most specific
|
|
1347
|
-
|
|
1348
1139
|
var candidates = [];
|
|
1349
|
-
|
|
1350
1140
|
for (var b in bottom) {
|
|
1351
1141
|
// Find the most specific
|
|
1352
1142
|
log.debug('candidatesFor: trying bottom type =' + b);
|
|
1353
1143
|
candidates = candidates.concat(findClosest(kb, b, ns.ui('creationForm')));
|
|
1354
1144
|
candidates = candidates.concat(findClosest(kb, b, ns.ui('annotationForm')));
|
|
1355
1145
|
}
|
|
1356
|
-
|
|
1357
1146
|
return candidates;
|
|
1358
1147
|
}
|
|
1359
|
-
|
|
1360
1148
|
function sortBySequence(list) {
|
|
1361
1149
|
var subfields = list.map(function (p) {
|
|
1362
1150
|
var k = kb.any(p, ns.ui('sequence'));
|
|
@@ -1369,7 +1157,6 @@ function sortBySequence(list) {
|
|
|
1369
1157
|
return pair[1];
|
|
1370
1158
|
});
|
|
1371
1159
|
}
|
|
1372
|
-
|
|
1373
1160
|
function sortByLabel(list) {
|
|
1374
1161
|
var subfields = list.map(function (p) {
|
|
1375
1162
|
return [utils.label(p).toLowerCase(), p];
|
|
@@ -1379,13 +1166,12 @@ function sortByLabel(list) {
|
|
|
1379
1166
|
return pair[1];
|
|
1380
1167
|
});
|
|
1381
1168
|
}
|
|
1169
|
+
|
|
1382
1170
|
/** Button to add a new whatever using a form
|
|
1383
1171
|
//
|
|
1384
1172
|
// @param form - optional form , else will look for one
|
|
1385
1173
|
// @param dataDoc - optional dataDoc else will prompt for one (unimplemented)
|
|
1386
1174
|
*/
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
1175
|
function newButton(dom, kb, subject, predicate, theClass, form, dataDoc, callbackFunction) {
|
|
1390
1176
|
var b = dom.createElement('button');
|
|
1391
1177
|
b.setAttribute('type', 'button');
|
|
@@ -1395,6 +1181,7 @@ function newButton(dom, kb, subject, predicate, theClass, form, dataDoc, callbac
|
|
|
1395
1181
|
}, false);
|
|
1396
1182
|
return b;
|
|
1397
1183
|
}
|
|
1184
|
+
|
|
1398
1185
|
/** Prompt for new object of a given class
|
|
1399
1186
|
//
|
|
1400
1187
|
// @param dom - the document DOM for the user interface
|
|
@@ -1407,14 +1194,10 @@ function newButton(dom, kb, subject, predicate, theClass, form, dataDoc, callbac
|
|
|
1407
1194
|
// @param callbackFunction - takes (boolean ok, string errorBody)
|
|
1408
1195
|
// @returns a dom object with the form DOM
|
|
1409
1196
|
*/
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
1197
|
function promptForNew(dom, kb, subject, predicate, theClass, form, dataDoc, callbackFunction) {
|
|
1413
1198
|
var box = dom.createElement('form');
|
|
1414
|
-
|
|
1415
1199
|
if (!form) {
|
|
1416
1200
|
var lists = findClosest(kb, theClass.uri, ns.ui('creationForm'));
|
|
1417
|
-
|
|
1418
1201
|
if (lists.length === 0) {
|
|
1419
1202
|
var p = box.appendChild(dom.createElement('p'));
|
|
1420
1203
|
p.textContent = 'I am sorry, you need to provide information about a ' + utils.label(theClass) + " but I don't know enough information about those to ask you.";
|
|
@@ -1422,52 +1205,44 @@ function promptForNew(dom, kb, subject, predicate, theClass, form, dataDoc, call
|
|
|
1422
1205
|
b.setAttribute('type', 'button');
|
|
1423
1206
|
b.setAttribute('style', 'float: right;');
|
|
1424
1207
|
b.innerHTML = 'Goto ' + utils.label(theClass);
|
|
1425
|
-
b.addEventListener('click',
|
|
1208
|
+
b.addEventListener('click',
|
|
1209
|
+
// TODO fix dependency cycle to solid-panes by calling outlineManager
|
|
1426
1210
|
function (_e) {
|
|
1427
1211
|
dom.outlineManager.GotoSubject(theClass, true, undefined, true, undefined);
|
|
1428
1212
|
}, false);
|
|
1429
1213
|
return box;
|
|
1430
1214
|
}
|
|
1431
|
-
|
|
1432
1215
|
log.debug('lists[0] is ' + lists[0]);
|
|
1433
1216
|
form = lists[0]; // Pick any one
|
|
1434
1217
|
}
|
|
1435
1218
|
|
|
1436
1219
|
log.debug('form is ' + form);
|
|
1437
1220
|
box.setAttribute('style', "border: 0.05em solid ".concat(style.formBorderColor, "; color: ").concat(style.formBorderColor)); // @@color?
|
|
1438
|
-
|
|
1439
1221
|
box.innerHTML = '<h3>New ' + utils.label(theClass) + '</h3>';
|
|
1440
1222
|
var formFunction = (0, _fieldFunction.fieldFunction)(dom, form);
|
|
1441
1223
|
var object = newThing(dataDoc);
|
|
1442
1224
|
var gotButton = false;
|
|
1443
|
-
|
|
1444
1225
|
var itemDone = function itemDone(ok, body) {
|
|
1445
1226
|
if (!ok) return callbackFunction(ok, body);
|
|
1446
1227
|
var insertMe = [];
|
|
1447
|
-
|
|
1448
1228
|
if (subject && !kb.holds(subject, predicate, object, dataDoc)) {
|
|
1449
1229
|
insertMe.push($rdf.st(subject, predicate, object, dataDoc));
|
|
1450
1230
|
}
|
|
1451
|
-
|
|
1452
1231
|
if (subject && !kb.holds(object, ns.rdf('type'), theClass, dataDoc)) {
|
|
1453
1232
|
insertMe.push($rdf.st(object, ns.rdf('type'), theClass, dataDoc));
|
|
1454
1233
|
}
|
|
1455
|
-
|
|
1456
1234
|
if (insertMe.length) {
|
|
1457
1235
|
kb.updater.update([], insertMe, linkDone);
|
|
1458
1236
|
} else {
|
|
1459
1237
|
callbackFunction(true, body);
|
|
1460
1238
|
}
|
|
1461
|
-
|
|
1462
1239
|
if (!gotButton) {
|
|
1463
1240
|
gotButton = box.appendChild(buttons.linkButton(dom, object));
|
|
1464
1241
|
}
|
|
1465
1242
|
};
|
|
1466
|
-
|
|
1467
1243
|
function linkDone(uri, ok, body) {
|
|
1468
1244
|
return callbackFunction(ok, body);
|
|
1469
1245
|
}
|
|
1470
|
-
|
|
1471
1246
|
log.info('paneUtils Object is ' + object);
|
|
1472
1247
|
var f = formFunction(dom, box, {}, object, form, dataDoc, itemDone);
|
|
1473
1248
|
var rb = buttons.removeButton(dom, f);
|
|
@@ -1475,7 +1250,6 @@ function promptForNew(dom, kb, subject, predicate, theClass, form, dataDoc, call
|
|
|
1475
1250
|
box.AJAR_subject = object;
|
|
1476
1251
|
return box;
|
|
1477
1252
|
}
|
|
1478
|
-
|
|
1479
1253
|
function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction) {
|
|
1480
1254
|
var group = dom.createElement('div');
|
|
1481
1255
|
var desc = kb.anyJS(subject, predicate, null, dataDoc) || '';
|
|
@@ -1484,7 +1258,6 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
|
|
|
1484
1258
|
field.rows = desc ? desc.split('\n').length + 2 : 2;
|
|
1485
1259
|
field.cols = 80;
|
|
1486
1260
|
field.setAttribute('style', style.multilineTextInputStyle);
|
|
1487
|
-
|
|
1488
1261
|
if (desc !== null) {
|
|
1489
1262
|
field.value = desc;
|
|
1490
1263
|
} else {
|
|
@@ -1495,7 +1268,6 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
|
|
|
1495
1268
|
|
|
1496
1269
|
group.refresh = function () {
|
|
1497
1270
|
var v = kb.any(subject, predicate, null, dataDoc);
|
|
1498
|
-
|
|
1499
1271
|
if (v && v.value !== field.value) {
|
|
1500
1272
|
field.value = v.value; // don't touch widget if no change
|
|
1501
1273
|
// @@ this is the place to color the field from the user who chanaged it
|
|
@@ -1505,10 +1277,8 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
|
|
|
1505
1277
|
function saveChange(_e) {
|
|
1506
1278
|
submit.disabled = true;
|
|
1507
1279
|
submit.setAttribute('style', 'visibility: hidden; float: right;'); // Keep UI clean
|
|
1508
|
-
|
|
1509
1280
|
field.disabled = true;
|
|
1510
1281
|
field.style.color = style.textInputColorPending; // setAttribute('style', style + 'color: gray;') // pending
|
|
1511
|
-
|
|
1512
1282
|
var ds = kb.statementsMatching(subject, predicate, null, dataDoc);
|
|
1513
1283
|
var is = $rdf.st(subject, predicate, field.value, dataDoc);
|
|
1514
1284
|
kb.updater.update(ds, is, function (uri, ok, body) {
|
|
@@ -1518,27 +1288,22 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
|
|
|
1518
1288
|
} else {
|
|
1519
1289
|
group.appendChild((0, _error.errorMessageBlock)(dom, 'Error (while saving change to ' + dataDoc.uri + '): ' + body));
|
|
1520
1290
|
}
|
|
1521
|
-
|
|
1522
1291
|
if (callbackFunction) {
|
|
1523
1292
|
callbackFunction(ok, body);
|
|
1524
1293
|
}
|
|
1525
1294
|
});
|
|
1526
1295
|
}
|
|
1527
|
-
|
|
1528
1296
|
var editable = kb.updater.editable(dataDoc.uri);
|
|
1529
1297
|
var submit;
|
|
1530
|
-
|
|
1531
1298
|
if (editable) {
|
|
1532
1299
|
submit = widgets.continueButton(dom, saveChange);
|
|
1533
1300
|
submit.disabled = true; // until the filled has been modified
|
|
1534
|
-
|
|
1535
1301
|
submit.style.visibility = 'hidden';
|
|
1536
1302
|
submit.style["float"] = 'right';
|
|
1537
1303
|
group.appendChild(submit);
|
|
1538
1304
|
field.addEventListener('keyup', function (_e) {
|
|
1539
1305
|
// Green means has been changed, not saved yet
|
|
1540
1306
|
field.style.color = 'green'; // setAttribute('style', style + 'color: green;')
|
|
1541
|
-
|
|
1542
1307
|
if (submit) {
|
|
1543
1308
|
submit.disabled = false;
|
|
1544
1309
|
submit.style.visibility = ''; // Remove visibility: hidden
|
|
@@ -1547,12 +1312,11 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
|
|
|
1547
1312
|
field.addEventListener('change', saveChange, true);
|
|
1548
1313
|
} else {
|
|
1549
1314
|
field.disabled = true; // @@ change color too
|
|
1550
|
-
|
|
1551
1315
|
field.style.backgroundColor = style.textInputBackgroundColorUneditable;
|
|
1552
1316
|
}
|
|
1553
|
-
|
|
1554
1317
|
return group;
|
|
1555
1318
|
}
|
|
1319
|
+
|
|
1556
1320
|
/** Make SELECT element to select options
|
|
1557
1321
|
//
|
|
1558
1322
|
// @param subject - a term, the subject of the statement(s) being edited.
|
|
@@ -1566,35 +1330,25 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
|
|
|
1566
1330
|
// @param dataDoc - The web document being edited
|
|
1567
1331
|
// @param callbackFunction - takes (boolean ok, string errorBody)
|
|
1568
1332
|
*/
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
1333
|
function makeSelectForClassifierOptions(dom, kb, subject, predicate, possible, options, dataDoc, callbackFunction) {
|
|
1572
1334
|
log.debug('Select list length now ' + possible.length);
|
|
1573
1335
|
var n = 0;
|
|
1574
1336
|
var uris = {}; // Count them
|
|
1575
|
-
|
|
1576
1337
|
var editable = kb.updater.editable(dataDoc.uri);
|
|
1577
|
-
|
|
1578
1338
|
for (var i = 0; i < possible.length; i++) {
|
|
1579
1339
|
var sub = possible[i]; // @@ Maybe; make this so it works with blank nodes too
|
|
1580
|
-
|
|
1581
1340
|
if (!sub.uri) debug.warn("makeSelectForClassifierOptions: option does not have an uri: ".concat(sub, ", with predicate: ").concat(predicate));
|
|
1582
1341
|
if (!sub.uri || sub.uri in uris) continue;
|
|
1583
1342
|
uris[sub.uri] = true;
|
|
1584
1343
|
n++;
|
|
1585
1344
|
} // uris is now the set of possible options
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
1345
|
if (n === 0 && !options.mint) {
|
|
1589
1346
|
return (0, _error.errorMessageBlock)(dom, "Can't do selector with no options, subject= " + subject + ' property = ' + predicate + '.');
|
|
1590
1347
|
}
|
|
1591
|
-
|
|
1592
1348
|
log.debug('makeSelectForClassifierOptions: dataDoc=' + dataDoc);
|
|
1593
1349
|
var actual;
|
|
1594
|
-
|
|
1595
1350
|
var getActual = function getActual() {
|
|
1596
1351
|
actual = {};
|
|
1597
|
-
|
|
1598
1352
|
if (predicate.sameTerm(ns.rdf('type'))) {
|
|
1599
1353
|
actual = kb.findTypeURIs(subject);
|
|
1600
1354
|
} else {
|
|
@@ -1602,29 +1356,21 @@ function makeSelectForClassifierOptions(dom, kb, subject, predicate, possible, o
|
|
|
1602
1356
|
actual[x.uri] = true;
|
|
1603
1357
|
});
|
|
1604
1358
|
}
|
|
1605
|
-
|
|
1606
1359
|
return actual;
|
|
1607
1360
|
};
|
|
1608
|
-
|
|
1609
1361
|
actual = getActual();
|
|
1610
|
-
|
|
1611
1362
|
var onChange = function onChange(_e) {
|
|
1612
1363
|
select.disabled = true; // until data written back - gives user feedback too
|
|
1613
|
-
|
|
1614
1364
|
var ds = [];
|
|
1615
1365
|
var is = [];
|
|
1616
|
-
|
|
1617
1366
|
var removeValue = function removeValue(t) {
|
|
1618
1367
|
if (kb.holds(subject, predicate, t, dataDoc)) {
|
|
1619
1368
|
ds.push($rdf.st(subject, predicate, t, dataDoc));
|
|
1620
1369
|
}
|
|
1621
1370
|
};
|
|
1622
|
-
|
|
1623
1371
|
var newObject;
|
|
1624
|
-
|
|
1625
1372
|
for (var _i = 0; _i < select.options.length; _i++) {
|
|
1626
1373
|
var opt = select.options[_i];
|
|
1627
|
-
|
|
1628
1374
|
if (opt.selected && opt.AJAR_mint) {
|
|
1629
1375
|
if (options.mintClass) {
|
|
1630
1376
|
var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
|
|
@@ -1634,62 +1380,49 @@ function makeSelectForClassifierOptions(dom, kb, subject, predicate, possible, o
|
|
|
1634
1380
|
}); // @@ if ok, need some form of refresh of the select for the new thing
|
|
1635
1381
|
}
|
|
1636
1382
|
});
|
|
1383
|
+
|
|
1637
1384
|
select.parentNode.appendChild(thisForm);
|
|
1638
1385
|
newObject = thisForm.AJAR_subject;
|
|
1639
1386
|
} else {
|
|
1640
1387
|
newObject = newThing(dataDoc);
|
|
1641
1388
|
}
|
|
1642
|
-
|
|
1643
1389
|
is.push($rdf.st(subject, predicate, newObject, dataDoc));
|
|
1644
|
-
|
|
1645
1390
|
if (options.mintStatementsFun) {
|
|
1646
1391
|
is = is.concat(options.mintStatementsFun(newObject));
|
|
1647
1392
|
}
|
|
1648
1393
|
}
|
|
1649
|
-
|
|
1650
1394
|
if (!opt.AJAR_uri) continue; // a prompt or mint
|
|
1651
|
-
|
|
1652
1395
|
if (opt.selected && !(opt.AJAR_uri in actual)) {
|
|
1653
1396
|
// new class
|
|
1654
1397
|
is.push($rdf.st(subject, predicate, kb.sym(opt.AJAR_uri), dataDoc));
|
|
1655
1398
|
}
|
|
1656
|
-
|
|
1657
1399
|
if (!opt.selected && opt.AJAR_uri in actual) {
|
|
1658
1400
|
// old class
|
|
1659
1401
|
removeValue(kb.sym(opt.AJAR_uri));
|
|
1660
1402
|
}
|
|
1661
|
-
|
|
1662
1403
|
if (opt.selected) select.currentURI = opt.AJAR_uri;
|
|
1663
1404
|
}
|
|
1664
|
-
|
|
1665
1405
|
var sel = select.subSelect; // All subclasses must also go
|
|
1666
|
-
|
|
1667
1406
|
while (sel && sel.currentURI) {
|
|
1668
1407
|
removeValue(kb.sym(sel.currentURI));
|
|
1669
1408
|
sel = sel.subSelect;
|
|
1670
1409
|
}
|
|
1671
|
-
|
|
1672
1410
|
sel = select.superSelect; // All superclasses are redundant
|
|
1673
|
-
|
|
1674
1411
|
while (sel && sel.currentURI) {
|
|
1675
1412
|
removeValue(kb.sym(sel.currentURI));
|
|
1676
1413
|
sel = sel.superSelect;
|
|
1677
1414
|
}
|
|
1678
|
-
|
|
1679
1415
|
function doneNew(ok, _body) {
|
|
1680
1416
|
callbackFunction(ok, {
|
|
1681
1417
|
widget: 'select',
|
|
1682
1418
|
event: 'new'
|
|
1683
1419
|
});
|
|
1684
1420
|
}
|
|
1685
|
-
|
|
1686
1421
|
log.info('makeSelectForClassifierOptions: data doc = ' + dataDoc);
|
|
1687
1422
|
kb.updater.update(ds, is, function (uri, ok, body) {
|
|
1688
1423
|
actual = getActual(); // refresh
|
|
1689
|
-
|
|
1690
1424
|
if (ok) {
|
|
1691
1425
|
select.disabled = false; // data written back
|
|
1692
|
-
|
|
1693
1426
|
if (newObject) {
|
|
1694
1427
|
var fn = (0, _fieldFunction.fieldFunction)(dom, options.subForm);
|
|
1695
1428
|
fn(dom, select.parentNode, {}, newObject, options.subForm, dataDoc, doneNew);
|
|
@@ -1697,37 +1430,30 @@ function makeSelectForClassifierOptions(dom, kb, subject, predicate, possible, o
|
|
|
1697
1430
|
} else {
|
|
1698
1431
|
return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in select: ' + body));
|
|
1699
1432
|
}
|
|
1700
|
-
|
|
1701
1433
|
if (callbackFunction) callbackFunction(ok, {
|
|
1702
1434
|
widget: 'select',
|
|
1703
1435
|
event: 'change'
|
|
1704
1436
|
});
|
|
1705
1437
|
});
|
|
1706
1438
|
};
|
|
1707
|
-
|
|
1708
1439
|
var select = dom.createElement('select');
|
|
1709
1440
|
select.setAttribute('style', style.formSelectSTyle);
|
|
1710
1441
|
if (options.multiple) select.setAttribute('multiple', 'true');
|
|
1711
1442
|
select.currentURI = null;
|
|
1712
|
-
|
|
1713
1443
|
select.refresh = function () {
|
|
1714
1444
|
actual = getActual(); // refresh
|
|
1715
|
-
|
|
1716
1445
|
for (var _i2 = 0; _i2 < select.children.length; _i2++) {
|
|
1717
1446
|
var option = select.children[_i2];
|
|
1718
|
-
|
|
1719
1447
|
if (option.AJAR_uri) {
|
|
1720
1448
|
option.selected = option.AJAR_uri in actual;
|
|
1721
1449
|
}
|
|
1722
1450
|
}
|
|
1723
|
-
|
|
1724
1451
|
select.disabled = false; // unlocked any conflict we had got into
|
|
1725
1452
|
};
|
|
1726
1453
|
|
|
1727
1454
|
for (var uri in uris) {
|
|
1728
1455
|
var c = kb.sym(uri);
|
|
1729
1456
|
var option = dom.createElement('option');
|
|
1730
|
-
|
|
1731
1457
|
if (options.disambiguate) {
|
|
1732
1458
|
option.appendChild(dom.createTextNode(utils.labelWithOntology(c, true))); // Init. cap
|
|
1733
1459
|
} else {
|
|
@@ -1735,40 +1461,33 @@ function makeSelectForClassifierOptions(dom, kb, subject, predicate, possible, o
|
|
|
1735
1461
|
}
|
|
1736
1462
|
|
|
1737
1463
|
var backgroundColor = kb.any(c, kb.sym('http://www.w3.org/ns/ui#backgroundColor'));
|
|
1738
|
-
|
|
1739
1464
|
if (backgroundColor) {
|
|
1740
1465
|
option.setAttribute('style', 'background-color: ' + backgroundColor.value + '; ');
|
|
1741
1466
|
}
|
|
1742
|
-
|
|
1743
1467
|
option.AJAR_uri = uri;
|
|
1744
|
-
|
|
1745
1468
|
if (uri in actual) {
|
|
1746
1469
|
option.setAttribute('selected', 'true');
|
|
1747
|
-
select.currentURI = uri;
|
|
1470
|
+
select.currentURI = uri;
|
|
1471
|
+
// dump("Already in class: "+ uri+"\n")
|
|
1748
1472
|
}
|
|
1749
1473
|
|
|
1750
1474
|
select.appendChild(option);
|
|
1751
1475
|
}
|
|
1752
|
-
|
|
1753
1476
|
if (editable && options.mint) {
|
|
1754
1477
|
var mint = dom.createElement('option');
|
|
1755
1478
|
mint.appendChild(dom.createTextNode(options.mint));
|
|
1756
1479
|
mint.AJAR_mint = true; // Flag it
|
|
1757
|
-
|
|
1758
1480
|
select.insertBefore(mint, select.firstChild);
|
|
1759
1481
|
}
|
|
1760
|
-
|
|
1761
1482
|
if (select.currentURI == null && !options.multiple) {
|
|
1762
1483
|
var prompt = dom.createElement('option');
|
|
1763
1484
|
prompt.appendChild(dom.createTextNode(options.nullLabel));
|
|
1764
1485
|
select.insertBefore(prompt, select.firstChild);
|
|
1765
1486
|
prompt.selected = true;
|
|
1766
1487
|
}
|
|
1767
|
-
|
|
1768
1488
|
if (editable) {
|
|
1769
1489
|
select.addEventListener('change', onChange, false);
|
|
1770
1490
|
}
|
|
1771
|
-
|
|
1772
1491
|
return select;
|
|
1773
1492
|
} // makeSelectForClassifierOptions
|
|
1774
1493
|
|
|
@@ -1783,35 +1502,25 @@ function makeSelectForClassifierOptions(dom, kb, subject, predicate, possible, o
|
|
|
1783
1502
|
// @param dataDoc - The web document being edited
|
|
1784
1503
|
// @param callbackFunction - takes (boolean ok, string errorBody)
|
|
1785
1504
|
*/
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
1505
|
function makeSelectForOptions(dom, kb, subject, predicate, possible, options, dataDoc, callbackFunction) {
|
|
1789
1506
|
log.debug('Select list length now ' + possible.length);
|
|
1790
1507
|
var n = 0;
|
|
1791
1508
|
var uris = {}; // Count them
|
|
1792
|
-
|
|
1793
1509
|
var editable = kb.updater.editable(dataDoc.uri);
|
|
1794
|
-
|
|
1795
1510
|
for (var i = 0; i < possible.length; i++) {
|
|
1796
1511
|
var sub = possible[i]; // @@ Maybe; make this so it works with blank nodes too
|
|
1797
|
-
|
|
1798
1512
|
if (!sub.uri) debug.warn("makeSelectForOptions: option does not have an uri: ".concat(sub, ", with predicate: ").concat(predicate));
|
|
1799
1513
|
if (!sub.uri || sub.uri in uris) continue;
|
|
1800
1514
|
uris[sub.uri] = true;
|
|
1801
1515
|
n++;
|
|
1802
1516
|
} // uris is now the set of possible options
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
1517
|
if (n === 0) {
|
|
1806
1518
|
return (0, _error.errorMessageBlock)(dom, "Can't do selector with no options, subject= " + subject + ' property = ' + predicate + '.');
|
|
1807
1519
|
}
|
|
1808
|
-
|
|
1809
1520
|
log.debug('makeSelectForOptions: dataDoc=' + dataDoc);
|
|
1810
1521
|
var actual;
|
|
1811
|
-
|
|
1812
1522
|
var getActual = function getActual() {
|
|
1813
1523
|
actual = {};
|
|
1814
|
-
|
|
1815
1524
|
if (predicate.sameTerm(ns.rdf('type'))) {
|
|
1816
1525
|
actual = kb.findTypeURIs(subject);
|
|
1817
1526
|
} else {
|
|
@@ -1821,94 +1530,72 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
|
|
|
1821
1530
|
}
|
|
1822
1531
|
});
|
|
1823
1532
|
}
|
|
1824
|
-
|
|
1825
1533
|
return actual;
|
|
1826
1534
|
};
|
|
1827
|
-
|
|
1828
1535
|
actual = getActual();
|
|
1829
|
-
|
|
1830
1536
|
var onChange = function onChange(_e) {
|
|
1831
1537
|
select.disabled = true; // until data written back - gives user feedback too
|
|
1832
|
-
|
|
1833
1538
|
var ds = [];
|
|
1834
1539
|
var is = [];
|
|
1835
|
-
|
|
1836
1540
|
var removeValue = function removeValue(t) {
|
|
1837
1541
|
if (kb.holds(subject, predicate, t, dataDoc)) {
|
|
1838
1542
|
ds.push($rdf.st(subject, predicate, t, dataDoc));
|
|
1839
1543
|
}
|
|
1840
1544
|
};
|
|
1841
|
-
|
|
1842
1545
|
for (var _i3 = 0; _i3 < select.options.length; _i3++) {
|
|
1843
1546
|
var opt = select.options[_i3];
|
|
1844
1547
|
if (!opt.AJAR_uri) continue; // a prompt or mint
|
|
1845
|
-
|
|
1846
1548
|
if (opt.selected && !(opt.AJAR_uri in actual)) {
|
|
1847
1549
|
// new class
|
|
1848
1550
|
is.push($rdf.st(subject, predicate, kb.sym(opt.AJAR_uri), dataDoc));
|
|
1849
1551
|
}
|
|
1850
|
-
|
|
1851
1552
|
if (!opt.selected && opt.AJAR_uri in actual) {
|
|
1852
1553
|
// old class
|
|
1853
1554
|
removeValue(kb.sym(opt.AJAR_uri));
|
|
1854
1555
|
}
|
|
1855
|
-
|
|
1856
1556
|
if (opt.selected) select.currentURI = opt.AJAR_uri;
|
|
1857
1557
|
}
|
|
1858
|
-
|
|
1859
1558
|
var sel = select.subSelect; // All subclasses must also go
|
|
1860
|
-
|
|
1861
1559
|
while (sel && sel.currentURI) {
|
|
1862
1560
|
removeValue(kb.sym(sel.currentURI));
|
|
1863
1561
|
sel = sel.subSelect;
|
|
1864
1562
|
}
|
|
1865
|
-
|
|
1866
1563
|
sel = select.superSelect; // All superclasses are redundant
|
|
1867
|
-
|
|
1868
1564
|
while (sel && sel.currentURI) {
|
|
1869
1565
|
removeValue(kb.sym(sel.currentURI));
|
|
1870
1566
|
sel = sel.superSelect;
|
|
1871
1567
|
}
|
|
1872
|
-
|
|
1873
1568
|
log.info('selectForOptions: data doc = ' + dataDoc);
|
|
1874
1569
|
kb.updater.update(ds, is, function (uri, ok, body) {
|
|
1875
1570
|
actual = getActual(); // refresh
|
|
1876
|
-
|
|
1877
1571
|
if (ok) {
|
|
1878
1572
|
select.disabled = false; // data written back
|
|
1879
1573
|
} else {
|
|
1880
1574
|
return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in select: ' + body));
|
|
1881
1575
|
}
|
|
1882
|
-
|
|
1883
1576
|
if (callbackFunction) callbackFunction(ok, {
|
|
1884
1577
|
widget: 'select',
|
|
1885
1578
|
event: 'change'
|
|
1886
1579
|
});
|
|
1887
1580
|
});
|
|
1888
1581
|
};
|
|
1889
|
-
|
|
1890
1582
|
var select = dom.createElement('select');
|
|
1891
1583
|
select.setAttribute('style', style.formSelectSTyle);
|
|
1892
1584
|
select.currentURI = null;
|
|
1893
|
-
|
|
1894
1585
|
select.refresh = function () {
|
|
1895
1586
|
actual = getActual(); // refresh
|
|
1896
|
-
|
|
1897
1587
|
for (var _i4 = 0; _i4 < select.children.length; _i4++) {
|
|
1898
1588
|
var option = select.children[_i4];
|
|
1899
|
-
|
|
1900
1589
|
if (option.AJAR_uri) {
|
|
1901
1590
|
option.selected = option.AJAR_uri in actual;
|
|
1902
1591
|
}
|
|
1903
1592
|
}
|
|
1904
|
-
|
|
1905
1593
|
select.disabled = false; // unlocked any conflict we had got into
|
|
1906
1594
|
};
|
|
1907
1595
|
|
|
1908
1596
|
for (var uri in uris) {
|
|
1909
1597
|
var c = kb.sym(uri);
|
|
1910
1598
|
var option = dom.createElement('option');
|
|
1911
|
-
|
|
1912
1599
|
if (options.disambiguate) {
|
|
1913
1600
|
option.appendChild(dom.createTextNode(utils.labelWithOntology(c, true))); // Init. cap
|
|
1914
1601
|
} else {
|
|
@@ -1916,68 +1603,59 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
|
|
|
1916
1603
|
}
|
|
1917
1604
|
|
|
1918
1605
|
var backgroundColor = kb.any(c, kb.sym('http://www.w3.org/ns/ui#backgroundColor'));
|
|
1919
|
-
|
|
1920
1606
|
if (backgroundColor) {
|
|
1921
1607
|
option.setAttribute('style', 'background-color: ' + backgroundColor.value + '; ');
|
|
1922
1608
|
}
|
|
1923
|
-
|
|
1924
1609
|
option.AJAR_uri = uri;
|
|
1925
|
-
|
|
1926
1610
|
if (uri in actual) {
|
|
1927
1611
|
option.setAttribute('selected', 'true');
|
|
1928
|
-
select.currentURI = uri;
|
|
1612
|
+
select.currentURI = uri;
|
|
1613
|
+
// dump("Already in class: "+ uri+"\n")
|
|
1929
1614
|
}
|
|
1930
1615
|
|
|
1931
1616
|
select.appendChild(option);
|
|
1932
1617
|
}
|
|
1933
|
-
|
|
1934
1618
|
if (!select.currentURI) {
|
|
1935
1619
|
var prompt = dom.createElement('option');
|
|
1936
1620
|
prompt.appendChild(dom.createTextNode(options.nullLabel));
|
|
1937
1621
|
select.insertBefore(prompt, select.firstChild);
|
|
1938
1622
|
prompt.selected = true;
|
|
1939
1623
|
}
|
|
1940
|
-
|
|
1941
1624
|
if (editable) {
|
|
1942
1625
|
select.addEventListener('change', onChange, false);
|
|
1943
1626
|
}
|
|
1944
|
-
|
|
1945
1627
|
return select;
|
|
1946
1628
|
} // makeSelectForOptions
|
|
1629
|
+
|
|
1947
1630
|
// Make SELECT element to select subclasses
|
|
1948
1631
|
//
|
|
1949
1632
|
// If there is any disjoint union it will so a mutually exclusive dropdown
|
|
1950
1633
|
// Failing that it will do a multiple selection of subclasses.
|
|
1951
1634
|
// Callback takes (boolean ok, string errorBody)
|
|
1952
1635
|
|
|
1953
|
-
|
|
1954
1636
|
function makeSelectForCategory(dom, kb, subject, category, dataDoc, callbackFunction) {
|
|
1955
1637
|
var du = kb.any(category, ns.owl('disjointUnionOf'));
|
|
1956
1638
|
var subs;
|
|
1957
1639
|
var multiple = false;
|
|
1958
|
-
|
|
1959
1640
|
if (!du) {
|
|
1960
1641
|
subs = kb.each(undefined, ns.rdfs('subClassOf'), category);
|
|
1961
1642
|
multiple = true;
|
|
1962
1643
|
} else {
|
|
1963
1644
|
subs = du.elements;
|
|
1964
1645
|
}
|
|
1965
|
-
|
|
1966
1646
|
log.debug('Select list length ' + subs.length);
|
|
1967
|
-
|
|
1968
1647
|
if (subs.length === 0) {
|
|
1969
1648
|
return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with no subclasses of category: ' + category);
|
|
1970
1649
|
}
|
|
1971
|
-
|
|
1972
1650
|
if (subs.length === 1) {
|
|
1973
1651
|
return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with only 1 subclass of category: ' + category + ':' + subs[1]);
|
|
1974
1652
|
}
|
|
1975
|
-
|
|
1976
1653
|
return makeSelectForClassifierOptions(dom, kb, subject, ns.rdf('type'), subs, {
|
|
1977
1654
|
multiple: multiple,
|
|
1978
1655
|
nullLabel: '* Select type *'
|
|
1979
1656
|
}, dataDoc, callbackFunction);
|
|
1980
1657
|
}
|
|
1658
|
+
|
|
1981
1659
|
/** Make SELECT element to select subclasses recurively
|
|
1982
1660
|
//
|
|
1983
1661
|
// It will so a mutually exclusive dropdown, with another if there are nested
|
|
@@ -1985,15 +1663,12 @@ function makeSelectForCategory(dom, kb, subject, category, dataDoc, callbackFunc
|
|
|
1985
1663
|
//
|
|
1986
1664
|
// @param callbackFunction takes (boolean ok, string errorBody)
|
|
1987
1665
|
*/
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
1666
|
function makeSelectForNestedCategory(dom, kb, subject, category, dataDoc, callbackFunction) {
|
|
1991
1667
|
function update() {
|
|
1992
1668
|
if (child) {
|
|
1993
1669
|
container.removeChild(child);
|
|
1994
1670
|
child = null;
|
|
1995
1671
|
}
|
|
1996
|
-
|
|
1997
1672
|
if (select.currentURI && kb.any(kb.sym(select.currentURI), ns.owl('disjointUnionOf'))) {
|
|
1998
1673
|
child = makeSelectForNestedCategory(dom, kb, subject, kb.sym(select.currentURI), dataDoc, callbackFunction);
|
|
1999
1674
|
select.subSelect = child.firstChild;
|
|
@@ -2001,21 +1676,18 @@ function makeSelectForNestedCategory(dom, kb, subject, category, dataDoc, callba
|
|
|
2001
1676
|
container.appendChild(child);
|
|
2002
1677
|
}
|
|
2003
1678
|
}
|
|
2004
|
-
|
|
2005
1679
|
var container = dom.createElement('span'); // Container
|
|
2006
|
-
|
|
2007
1680
|
var child = null;
|
|
2008
|
-
|
|
2009
1681
|
function onChange(ok, body) {
|
|
2010
1682
|
if (ok) update();
|
|
2011
1683
|
callbackFunction(ok, body);
|
|
2012
1684
|
}
|
|
2013
|
-
|
|
2014
1685
|
var select = makeSelectForCategory(dom, kb, subject, category, dataDoc, onChange);
|
|
2015
1686
|
container.appendChild(select);
|
|
2016
1687
|
update();
|
|
2017
1688
|
return container;
|
|
2018
1689
|
}
|
|
1690
|
+
|
|
2019
1691
|
/* Build a checkbox from a given statement(s)
|
|
2020
1692
|
**
|
|
2021
1693
|
** If the source document is editable, make the checkbox editable
|
|
@@ -2024,8 +1696,6 @@ function makeSelectForNestedCategory(dom, kb, subject, category, dataDoc, callba
|
|
|
2024
1696
|
** made if the checkbox is checed and unchecked respectively.
|
|
2025
1697
|
** tristate: Allow ins, or del, or neither
|
|
2026
1698
|
*/
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
1699
|
function buildCheckboxForm(dom, kb, lab, del, ins, form, dataDoc, tristate) {
|
|
2030
1700
|
var box = dom.createElement('div');
|
|
2031
1701
|
var rhs = (0, _basic.renderNameValuePair)(dom, kb, box, form, lab);
|
|
@@ -2034,10 +1704,8 @@ function buildCheckboxForm(dom, kb, lab, del, ins, form, dataDoc, tristate) {
|
|
|
2034
1704
|
var colorCarrier = input;
|
|
2035
1705
|
input.style = style.checkboxInputStyle;
|
|
2036
1706
|
rhs.appendChild(input);
|
|
2037
|
-
|
|
2038
1707
|
function fix(x) {
|
|
2039
1708
|
if (!x) return []; // no statements
|
|
2040
|
-
|
|
2041
1709
|
if (x.object) {
|
|
2042
1710
|
if (!x.why) {
|
|
2043
1711
|
x.why = dataDoc; // be back-compaitible with old code
|
|
@@ -2049,36 +1717,29 @@ function buildCheckboxForm(dom, kb, lab, del, ins, form, dataDoc, tristate) {
|
|
|
2049
1717
|
if (x instanceof Array) return x;
|
|
2050
1718
|
throw new Error('buildCheckboxForm: bad param ' + x);
|
|
2051
1719
|
}
|
|
2052
|
-
|
|
2053
1720
|
ins = fix(ins);
|
|
2054
1721
|
del = fix(del);
|
|
2055
|
-
|
|
2056
1722
|
function holdsAll(a) {
|
|
2057
1723
|
var missing = a.filter(function (st) {
|
|
2058
1724
|
return !kb.holds(st.subject, st.predicate, st.object, st.why);
|
|
2059
1725
|
});
|
|
2060
1726
|
return missing.length === 0;
|
|
2061
1727
|
}
|
|
2062
|
-
|
|
2063
1728
|
function refresh() {
|
|
2064
1729
|
var state = holdsAll(ins);
|
|
2065
1730
|
var displayState = state;
|
|
2066
|
-
|
|
2067
1731
|
if (del.length) {
|
|
2068
1732
|
var negation = holdsAll(del);
|
|
2069
|
-
|
|
2070
1733
|
if (state && negation) {
|
|
2071
1734
|
box.appendChild(widgets.errorMessageBlock(dom, 'Inconsistent data in dataDoc!\n' + ins + ' and\n' + del));
|
|
2072
1735
|
return box;
|
|
2073
1736
|
}
|
|
2074
|
-
|
|
2075
1737
|
if (!state && !negation) {
|
|
2076
1738
|
state = null;
|
|
2077
1739
|
var defa = kb.any(form, ns.ui('default'));
|
|
2078
1740
|
displayState = defa ? defa.value === '1' : tristate ? null : false;
|
|
2079
1741
|
}
|
|
2080
1742
|
}
|
|
2081
|
-
|
|
2082
1743
|
input.state = state;
|
|
2083
1744
|
input.textContent = {
|
|
2084
1745
|
"true": checkMarkCharacter,
|
|
@@ -2087,13 +1748,10 @@ function buildCheckboxForm(dom, kb, lab, del, ins, form, dataDoc, tristate) {
|
|
|
2087
1748
|
"null": dashCharacter
|
|
2088
1749
|
}[displayState];
|
|
2089
1750
|
}
|
|
2090
|
-
|
|
2091
1751
|
refresh();
|
|
2092
1752
|
if (!editable) return box;
|
|
2093
|
-
|
|
2094
1753
|
var boxHandler = function boxHandler(_e) {
|
|
2095
1754
|
colorCarrier.style.color = '#bbb'; // grey -- not saved yet
|
|
2096
|
-
|
|
2097
1755
|
var toDelete = input.state === true ? ins : input.state === false ? del : [];
|
|
2098
1756
|
input.newState = input.state === null ? true : input.state === true ? false : tristate ? null : true;
|
|
2099
1757
|
var toInsert = input.newState === true ? ins : input.newState === false ? del : [];
|
|
@@ -2103,12 +1761,10 @@ function buildCheckboxForm(dom, kb, lab, del, ins, form, dataDoc, tristate) {
|
|
|
2103
1761
|
if (!success) {
|
|
2104
1762
|
if (toDelete.why) {
|
|
2105
1763
|
var hmmm = kb.holds(toDelete.subject, toDelete.predicate, toDelete.object, toDelete.why);
|
|
2106
|
-
|
|
2107
1764
|
if (hmmm) {
|
|
2108
1765
|
debug.log(' @@@@@ weird if 409 - does hold statement');
|
|
2109
1766
|
}
|
|
2110
1767
|
}
|
|
2111
|
-
|
|
2112
1768
|
colorCarrier.style.color = '#000';
|
|
2113
1769
|
colorCarrier.style.backgroundColor = '#fee';
|
|
2114
1770
|
box.appendChild((0, _error.errorMessageBlock)(dom, "Checkbox: Error updating dataDoc from ".concat(input.state, " to ").concat(input.newState, ":\n\n").concat(errorBody)));
|
|
@@ -2154,16 +1810,14 @@ export function fieldStore (subject, predicate, def) {
|
|
|
2154
1810
|
return def
|
|
2155
1811
|
}
|
|
2156
1812
|
*/
|
|
2157
|
-
|
|
2158
1813
|
/** Mint local ID using timestamp
|
|
2159
1814
|
* @param {NamedNode} doc - the document in which the ID is to be generated
|
|
2160
1815
|
*/
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
1816
|
function newThing(doc) {
|
|
2164
1817
|
var now = new Date();
|
|
2165
1818
|
return $rdf.sym(doc.uri + '#' + 'id' + ('' + now.getTime()));
|
|
2166
1819
|
}
|
|
1820
|
+
|
|
2167
1821
|
/** Make SELECT element to select options
|
|
2168
1822
|
//
|
|
2169
1823
|
// @param subject - a term, the subject of the statement(s) being edited.
|
|
@@ -2174,43 +1828,30 @@ function newThing(doc) {
|
|
|
2174
1828
|
// @param dataDoc - The web document being edited
|
|
2175
1829
|
// @param callbackFunction - takes (boolean ok, string errorBody)
|
|
2176
1830
|
*/
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
1831
|
function makeSelectForChoice(dom, container, kb, subject, predicate, inputPossibleOptions, selectedOptions, uiFrom, options, dataDoc, callbackFunction) {
|
|
2180
1832
|
var optionsFromClassUIfrom = {}; // Count them
|
|
2181
|
-
|
|
2182
1833
|
var editable = kb.updater.editable(dataDoc.uri);
|
|
2183
|
-
|
|
2184
1834
|
for (var i = 0; i < inputPossibleOptions.length; i++) {
|
|
2185
1835
|
var sub = inputPossibleOptions[i]; // @@ Maybe; make this so it works with blank nodes too
|
|
2186
1836
|
// if (!sub.uri) debug.warn(`makeSelectForChoice: option does not have an uri: ${sub}, with predicate: ${predicate}`)
|
|
2187
|
-
|
|
2188
1837
|
if (!sub.uri || sub.uri in optionsFromClassUIfrom) continue;
|
|
2189
1838
|
optionsFromClassUIfrom[sub.uri] = true;
|
|
2190
1839
|
}
|
|
2191
|
-
|
|
2192
1840
|
var isEmpty = Object.keys(optionsFromClassUIfrom).length === 0;
|
|
2193
|
-
|
|
2194
1841
|
if (isEmpty && !options.mint) {
|
|
2195
1842
|
return (0, _error.errorMessageBlock)(dom, "Can't do selector with no options, subject= " + subject + ' property = ' + predicate + '.');
|
|
2196
1843
|
}
|
|
2197
|
-
|
|
2198
1844
|
log.debug('makeSelectForChoice: dataDoc=' + dataDoc);
|
|
2199
|
-
|
|
2200
1845
|
function createDefaultSelectOptionText() {
|
|
2201
1846
|
var firstSelectOptionText = '--- choice ---';
|
|
2202
|
-
|
|
2203
1847
|
if (predicate && !(predicate.termType === 'BlankNode')) {
|
|
2204
1848
|
firstSelectOptionText = '* Select for property: ' + utils.label(predicate) + ' *';
|
|
2205
1849
|
}
|
|
2206
|
-
|
|
2207
1850
|
if (subject && !(subject.termType === 'BlankNode')) {
|
|
2208
1851
|
firstSelectOptionText = '* Select for ' + utils.label(subject, true) + ' *';
|
|
2209
1852
|
}
|
|
2210
|
-
|
|
2211
1853
|
return firstSelectOptionText;
|
|
2212
1854
|
}
|
|
2213
|
-
|
|
2214
1855
|
function createDefaultSelectOption() {
|
|
2215
1856
|
var option = dom.createElement('option');
|
|
2216
1857
|
option.appendChild(dom.createTextNode(createDefaultSelectOptionText()));
|
|
@@ -2220,59 +1861,50 @@ function makeSelectForChoice(dom, container, kb, subject, predicate, inputPossib
|
|
|
2220
1861
|
option.selected = true;
|
|
2221
1862
|
return option;
|
|
2222
1863
|
}
|
|
2223
|
-
|
|
2224
1864
|
var onChange = function onChange(_e) {
|
|
2225
1865
|
container.removeChild(container.lastChild);
|
|
2226
1866
|
select.refresh();
|
|
2227
1867
|
};
|
|
2228
|
-
|
|
2229
1868
|
var select = dom.createElement('select');
|
|
2230
1869
|
select.setAttribute('style', style.formSelectSTyle);
|
|
2231
1870
|
select.setAttribute('id', 'formSelect');
|
|
2232
1871
|
select.currentURI = null;
|
|
2233
|
-
|
|
2234
1872
|
for (var uri in optionsFromClassUIfrom) {
|
|
2235
1873
|
select.appendChild(createOption(uri));
|
|
2236
1874
|
}
|
|
2237
|
-
|
|
2238
1875
|
if (editable && options.mint) {
|
|
2239
1876
|
var mint = dom.createElement('option');
|
|
2240
1877
|
mint.appendChild(dom.createTextNode(options.mint));
|
|
2241
1878
|
mint.AJAR_mint = true; // Flag it
|
|
2242
|
-
|
|
2243
1879
|
select.insertBefore(mint, select.firstChild);
|
|
2244
1880
|
}
|
|
2245
|
-
|
|
2246
1881
|
if (select.children.length === 0) select.insertBefore(createDefaultSelectOption(), select.firstChild);
|
|
2247
|
-
|
|
2248
1882
|
select.update = function (newSelectedOptions) {
|
|
2249
1883
|
selectedOptions = newSelectedOptions;
|
|
2250
1884
|
var ds = [];
|
|
2251
1885
|
var is = [];
|
|
2252
|
-
|
|
2253
1886
|
var removeValue = function removeValue(t) {
|
|
2254
1887
|
if (kb.holds(subject, predicate, t, dataDoc)) {
|
|
2255
1888
|
ds.push($rdf.st(subject, predicate, t, dataDoc));
|
|
2256
1889
|
}
|
|
2257
1890
|
};
|
|
2258
|
-
|
|
2259
1891
|
var addValue = function addValue(t) {
|
|
2260
1892
|
if (!kb.holds(subject, predicate, t, dataDoc)) {
|
|
2261
|
-
is.push($rdf.st(subject, predicate, t, dataDoc));
|
|
1893
|
+
is.push($rdf.st(subject, predicate, t, dataDoc));
|
|
1894
|
+
// console.log("----value added " + t)
|
|
2262
1895
|
}
|
|
2263
1896
|
|
|
2264
1897
|
if (uiFrom && !kb.holds(t, ns.rdf('type'), kb.sym(uiFrom), dataDoc)) {
|
|
2265
|
-
is.push($rdf.st(t, ns.rdf('type'), kb.sym(uiFrom), dataDoc));
|
|
1898
|
+
is.push($rdf.st(t, ns.rdf('type'), kb.sym(uiFrom), dataDoc));
|
|
1899
|
+
// console.log("----added type to value " + uiFrom)
|
|
2266
1900
|
}
|
|
2267
1901
|
};
|
|
2268
1902
|
|
|
2269
1903
|
var existingValues = kb.each(subject, predicate, null, dataDoc).map(function (object) {
|
|
2270
1904
|
return object.value;
|
|
2271
1905
|
});
|
|
2272
|
-
|
|
2273
1906
|
var _iterator2 = _createForOfIteratorHelper(existingValues),
|
|
2274
|
-
|
|
2275
|
-
|
|
1907
|
+
_step2;
|
|
2276
1908
|
try {
|
|
2277
1909
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2278
1910
|
var value = _step2.value;
|
|
@@ -2283,10 +1915,8 @@ function makeSelectForChoice(dom, container, kb, subject, predicate, inputPossib
|
|
|
2283
1915
|
} finally {
|
|
2284
1916
|
_iterator2.f();
|
|
2285
1917
|
}
|
|
2286
|
-
|
|
2287
1918
|
var _iterator3 = _createForOfIteratorHelper(selectedOptions),
|
|
2288
|
-
|
|
2289
|
-
|
|
1919
|
+
_step3;
|
|
2290
1920
|
try {
|
|
2291
1921
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
2292
1922
|
var _value = _step3.value;
|
|
@@ -2297,7 +1927,6 @@ function makeSelectForChoice(dom, container, kb, subject, predicate, inputPossib
|
|
|
2297
1927
|
} finally {
|
|
2298
1928
|
_iterator3.f();
|
|
2299
1929
|
}
|
|
2300
|
-
|
|
2301
1930
|
kb.updater.update(ds, is, function (uri, ok, body) {
|
|
2302
1931
|
if (!ok) return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in select: ' + body));
|
|
2303
1932
|
select.refresh();
|
|
@@ -2307,16 +1936,12 @@ function makeSelectForChoice(dom, container, kb, subject, predicate, inputPossib
|
|
|
2307
1936
|
});
|
|
2308
1937
|
});
|
|
2309
1938
|
};
|
|
2310
|
-
|
|
2311
1939
|
select.refresh = function () {
|
|
2312
1940
|
select.disabled = true; // unlocked any conflict we had got into
|
|
2313
|
-
|
|
2314
1941
|
var is = [];
|
|
2315
1942
|
var newObject;
|
|
2316
|
-
|
|
2317
1943
|
for (var _i5 = 0; _i5 < select.options.length; _i5++) {
|
|
2318
1944
|
var opt = select.options[_i5];
|
|
2319
|
-
|
|
2320
1945
|
if (opt.selected && opt.AJAR_mint) {
|
|
2321
1946
|
// not sure if this 'if' is used because I cannot find mintClass
|
|
2322
1947
|
if (options.mintClass) {
|
|
@@ -2327,34 +1952,29 @@ function makeSelectForChoice(dom, container, kb, subject, predicate, inputPossib
|
|
|
2327
1952
|
}); // @@ if ok, need some form of refresh of the select for the new thing
|
|
2328
1953
|
}
|
|
2329
1954
|
});
|
|
1955
|
+
|
|
2330
1956
|
select.parentNode.appendChild(thisForm);
|
|
2331
1957
|
newObject = thisForm.AJAR_subject;
|
|
2332
1958
|
} else {
|
|
2333
1959
|
newObject = newThing(dataDoc);
|
|
2334
1960
|
}
|
|
2335
|
-
|
|
2336
1961
|
is.push($rdf.st(subject, predicate, kb.sym(newObject), dataDoc));
|
|
2337
|
-
if (uiFrom) is.push($rdf.st(newObject, ns.rdf('type'), kb.sym(uiFrom), dataDoc));
|
|
1962
|
+
if (uiFrom) is.push($rdf.st(newObject, ns.rdf('type'), kb.sym(uiFrom), dataDoc));
|
|
2338
1963
|
|
|
1964
|
+
// not sure if this 'if' is used because I cannot find mintStatementsFun
|
|
2339
1965
|
if (options.mintStatementsFun) {
|
|
2340
1966
|
is = is.concat(options.mintStatementsFun(newObject));
|
|
2341
1967
|
}
|
|
2342
|
-
|
|
2343
1968
|
select.currentURI = newObject;
|
|
2344
1969
|
}
|
|
2345
|
-
|
|
2346
1970
|
if (!opt.AJAR_uri) continue; // a prompt or mint
|
|
2347
|
-
|
|
2348
1971
|
if (opt.selected && containsObject(opt.AJAR_uri, selectedOptions)) {
|
|
2349
1972
|
select.currentURI = opt.AJAR_uri;
|
|
2350
1973
|
}
|
|
2351
|
-
|
|
2352
1974
|
if (!containsObject(opt.AJAR_uri, selectedOptions)) opt.removeAttribute('selected');
|
|
2353
1975
|
if (containsObject(opt.AJAR_uri, selectedOptions)) opt.setAttribute('selected', 'true');
|
|
2354
1976
|
}
|
|
2355
|
-
|
|
2356
1977
|
log.info('selectForOptions: data doc = ' + dataDoc);
|
|
2357
|
-
|
|
2358
1978
|
if (select.currentURI && options.subForm && !options.multiSelect) {
|
|
2359
1979
|
addSubFormChoice(dom, container, {}, $rdf.sym(select.currentURI), options.subForm, dataDoc, function (ok, body) {
|
|
2360
1980
|
if (ok) {
|
|
@@ -2370,59 +1990,46 @@ function makeSelectForChoice(dom, container, kb, subject, predicate, inputPossib
|
|
|
2370
1990
|
}
|
|
2371
1991
|
});
|
|
2372
1992
|
}
|
|
2373
|
-
|
|
2374
1993
|
select.disabled = false;
|
|
2375
1994
|
};
|
|
2376
|
-
|
|
2377
1995
|
function createOption(uri) {
|
|
2378
1996
|
var option = dom.createElement('option');
|
|
2379
1997
|
var c = kb.sym(uri);
|
|
2380
1998
|
var label;
|
|
2381
|
-
|
|
2382
1999
|
if (options.disambiguate) {
|
|
2383
2000
|
label = utils.labelWithOntology(c, true); // Init. cap
|
|
2384
2001
|
} else {
|
|
2385
2002
|
label = utils.label(c, true);
|
|
2386
2003
|
}
|
|
2387
|
-
|
|
2388
2004
|
option.appendChild(dom.createTextNode(label)); // Init.
|
|
2389
|
-
|
|
2390
2005
|
option.setAttribute('value', uri);
|
|
2391
2006
|
var backgroundColor = kb.any(c, kb.sym('http://www.w3.org/ns/ui#backgroundColor'));
|
|
2392
|
-
|
|
2393
2007
|
if (backgroundColor) {
|
|
2394
2008
|
option.setAttribute('style', 'background-color: ' + backgroundColor.value + '; ');
|
|
2395
2009
|
}
|
|
2396
|
-
|
|
2397
2010
|
option.AJAR_uri = uri;
|
|
2398
|
-
|
|
2399
2011
|
if (containsObject(c.value, selectedOptions)) {
|
|
2400
2012
|
option.setAttribute('selected', 'true');
|
|
2401
2013
|
}
|
|
2402
|
-
|
|
2403
2014
|
return option;
|
|
2404
2015
|
}
|
|
2405
|
-
|
|
2406
2016
|
if (editable) {
|
|
2407
2017
|
select.addEventListener('change', onChange, false);
|
|
2408
2018
|
}
|
|
2409
|
-
|
|
2410
2019
|
return select;
|
|
2411
2020
|
} // makeSelectForChoice
|
|
2412
2021
|
|
|
2413
|
-
|
|
2414
2022
|
function containsObject(obj, list) {
|
|
2415
2023
|
var i;
|
|
2416
|
-
|
|
2417
2024
|
for (i = 0; i < list.length; i++) {
|
|
2418
2025
|
if (list[i] === obj) {
|
|
2419
2026
|
return true;
|
|
2420
2027
|
}
|
|
2421
2028
|
}
|
|
2422
|
-
|
|
2423
2029
|
return false;
|
|
2424
|
-
}
|
|
2030
|
+
}
|
|
2425
2031
|
|
|
2032
|
+
// This functions replaces the findMembersNT (thisClass) from rdflib until we fix: https://github.com/linkeddata/rdflib.js/issues/565
|
|
2426
2033
|
/**
|
|
2427
2034
|
* For anything which has thisClass (or any subclass) as its type,
|
|
2428
2035
|
* or is the object of something which has thisClass (or any subclass) as its range,
|
|
@@ -2432,8 +2039,6 @@ function containsObject(obj, list) {
|
|
|
2432
2039
|
* Get all the Classes of which we can RDFS-infer the subject is a member
|
|
2433
2040
|
* @return a hash of URIs
|
|
2434
2041
|
*/
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
2042
|
function findMembersNT(store, thisClass, quad) {
|
|
2438
2043
|
var len2;
|
|
2439
2044
|
var len4;
|
|
@@ -2450,40 +2055,31 @@ function findMembersNT(store, thisClass, quad) {
|
|
|
2450
2055
|
seeds[thisClass.toNT()] = true;
|
|
2451
2056
|
var members = {};
|
|
2452
2057
|
var ref = store.transitiveClosure(seeds, store.rdfFactory.namedNode('http://www.w3.org/2000/01/rdf-schema#subClassOf'), true);
|
|
2453
|
-
|
|
2454
2058
|
for (var t in ref) {
|
|
2455
2059
|
ref1 = store.statementsMatching(null, store.rdfFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), store.fromNT(t), quad);
|
|
2456
|
-
|
|
2457
2060
|
for (var i = 0, len = ref1.length; i < len; i++) {
|
|
2458
2061
|
st = ref1[i];
|
|
2459
2062
|
members[st.subject.toNT()] = st;
|
|
2460
2063
|
}
|
|
2461
|
-
|
|
2462
2064
|
ref2 = store.each(null, store.rdfFactory.namedNode('http://www.w3.org/2000/01/rdf-schema#domain'), store.fromNT(t), quad);
|
|
2463
|
-
|
|
2464
2065
|
for (var l = 0, len1 = ref2.length; l < len1; l++) {
|
|
2465
2066
|
pred = ref2[l];
|
|
2466
2067
|
ref3 = store.statementsMatching(null, pred, null, quad);
|
|
2467
|
-
|
|
2468
2068
|
for (m = 0, len2 = ref3.length; m < len2; m++) {
|
|
2469
2069
|
st = ref3[m];
|
|
2470
2070
|
members[st.subject.toNT()] = st;
|
|
2471
2071
|
}
|
|
2472
2072
|
}
|
|
2473
|
-
|
|
2474
2073
|
ref4 = store.each(null, store.rdfFactory.namedNode('http://www.w3.org/2000/01/rdf-schema#range'), store.fromNT(t), quad);
|
|
2475
|
-
|
|
2476
2074
|
for (var q = 0, len3 = ref4.length; q < len3; q++) {
|
|
2477
2075
|
pred = ref4[q];
|
|
2478
2076
|
ref5 = store.statementsMatching(null, pred, null, quad);
|
|
2479
|
-
|
|
2480
2077
|
for (u = 0, len4 = ref5.length; u < len4; u++) {
|
|
2481
2078
|
st = ref5[u];
|
|
2482
2079
|
members[st.object.toNT()] = st;
|
|
2483
2080
|
}
|
|
2484
2081
|
}
|
|
2485
2082
|
}
|
|
2486
|
-
|
|
2487
2083
|
return members;
|
|
2488
2084
|
}
|
|
2489
2085
|
//# sourceMappingURL=forms.js.map
|