solid-ui 2.4.22-c76aca59 → 2.4.22-d904f259
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -58
- package/dist/main.js +2082 -1163
- package/dist/main.js.map +1 -1
- package/lib/acl/access-controller.js +9 -14
- package/lib/acl/access-controller.js.map +1 -1
- package/lib/acl/access-groups.js +10 -15
- package/lib/acl/access-groups.js.map +1 -1
- package/lib/acl/acl-control.js +9 -13
- package/lib/acl/acl-control.js.map +1 -1
- package/lib/acl/acl.js +7 -11
- package/lib/acl/acl.js.map +1 -1
- package/lib/acl/add-agent-buttons.js +13 -19
- package/lib/acl/add-agent-buttons.js.map +1 -1
- package/lib/acl/index.js.map +1 -1
- package/lib/acl/styles.js.map +1 -1
- package/lib/acl/types.js.map +1 -1
- package/lib/chat/bookmarks.js +14 -19
- package/lib/chat/bookmarks.js.map +1 -1
- package/lib/chat/chatLogic.js +9 -15
- package/lib/chat/chatLogic.js.map +1 -1
- package/lib/chat/dateFolder.js +12 -17
- package/lib/chat/dateFolder.js.map +1 -1
- package/lib/chat/infinite.js +29 -37
- package/lib/chat/infinite.js.map +1 -1
- package/lib/chat/message.js +14 -14
- package/lib/chat/message.js.map +1 -1
- package/lib/chat/messageTools.js +10 -23
- package/lib/chat/messageTools.js.map +1 -1
- package/lib/chat/thread.js +4 -9
- package/lib/chat/thread.js.map +1 -1
- package/lib/create/create.js.map +1 -1
- package/lib/create/index.js.map +1 -1
- package/lib/create/types.js.map +1 -1
- package/lib/debug.js.map +1 -1
- package/lib/folders.js.map +1 -1
- package/lib/footer/index.js +8 -10
- 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 +9 -17
- package/lib/header/index.js.map +1 -1
- package/lib/header/styleMap.js.map +1 -1
- package/lib/iconBase.js.map +1 -1
- package/lib/icons/solid_logo.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/jss/index.js.map +1 -1
- package/lib/log.js.map +1 -1
- package/lib/login/login.js +21 -63
- package/lib/login/login.js.map +1 -1
- package/lib/matrix/index.js.map +1 -1
- package/lib/matrix/matrix.js.map +1 -1
- package/lib/matrix/types.js.map +1 -1
- package/lib/media/index.js.map +1 -1
- package/lib/media/media-capture.js +4 -20
- package/lib/media/media-capture.js.map +1 -1
- package/lib/messageArea.js.map +1 -1
- package/lib/noun_Camera_1618446_000000.js.map +1 -1
- package/lib/ns.js.map +1 -1
- package/lib/pad.js.map +1 -1
- package/lib/participation.js.map +1 -1
- package/lib/preferences.js.map +1 -1
- package/lib/signup/config-default.js.map +1 -1
- package/lib/signup/signup.js.map +1 -1
- package/lib/stories/decorators.js.map +1 -1
- package/lib/style.js.map +1 -1
- package/lib/style_multiSelect.js +67 -0
- package/lib/style_multiSelect.js.map +1 -0
- package/lib/table.js.map +1 -1
- package/lib/tabs.d.ts +1 -1
- package/lib/tabs.d.ts.map +1 -1
- package/lib/tabs.js +34 -21
- package/lib/tabs.js.map +1 -1
- package/lib/typings.d.js.map +1 -1
- package/lib/utils/headerFooterHelpers.js +5 -7
- package/lib/utils/headerFooterHelpers.js.map +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/label.js +1 -1
- package/lib/utils/label.js.map +1 -1
- package/lib/versionInfo.js +7 -7
- package/lib/versionInfo.js.map +1 -1
- package/lib/widgets/buttons/iconLinks.js.map +1 -1
- package/lib/widgets/buttons.d.ts.map +1 -1
- package/lib/widgets/buttons.js +2 -0
- package/lib/widgets/buttons.js.map +1 -1
- package/lib/widgets/dragAndDrop.js.map +1 -1
- package/lib/widgets/error.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompleteBar.js +17 -15
- package/lib/widgets/forms/autocomplete/autocompleteBar.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompleteField.js +5 -8
- package/lib/widgets/forms/autocomplete/autocompleteField.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompletePicker.js +21 -19
- package/lib/widgets/forms/autocomplete/autocompletePicker.js.map +1 -1
- package/lib/widgets/forms/autocomplete/language.js +8 -15
- package/lib/widgets/forms/autocomplete/language.js.map +1 -1
- package/lib/widgets/forms/autocomplete/publicData.js +22 -27
- package/lib/widgets/forms/autocomplete/publicData.js.map +1 -1
- package/lib/widgets/forms/basic.js.map +1 -1
- package/lib/widgets/forms/comment.js.map +1 -1
- package/lib/widgets/forms/fieldFunction.js.map +1 -1
- package/lib/widgets/forms/fieldParams.js.map +1 -1
- package/lib/widgets/forms/formStyle.js.map +1 -1
- package/lib/widgets/forms.js +527 -202
- package/lib/widgets/forms.js.map +1 -1
- package/lib/widgets/index.js.map +1 -1
- package/lib/widgets/multiSelect.js +784 -0
- package/lib/widgets/multiSelect.js.map +1 -0
- package/lib/widgets/peoplePicker.js.map +1 -1
- package/lib/widgets/widgetHelpers.js.map +1 -1
- package/package.json +5 -3
package/lib/widgets/forms.js
CHANGED
|
@@ -44,6 +44,7 @@ exports.findClosest = findClosest;
|
|
|
44
44
|
exports.formsFor = formsFor;
|
|
45
45
|
exports.makeDescription = makeDescription;
|
|
46
46
|
exports.makeSelectForCategory = makeSelectForCategory;
|
|
47
|
+
exports.makeSelectForChoice = makeSelectForChoice;
|
|
47
48
|
exports.makeSelectForNestedCategory = makeSelectForNestedCategory;
|
|
48
49
|
exports.makeSelectForOptions = makeSelectForOptions;
|
|
49
50
|
exports.newButton = newButton;
|
|
@@ -59,8 +60,6 @@ Object.defineProperty(exports, "renderNameValuePair", {
|
|
|
59
60
|
exports.sortByLabel = sortByLabel;
|
|
60
61
|
exports.sortBySequence = sortBySequence;
|
|
61
62
|
|
|
62
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
63
|
-
|
|
64
63
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
65
64
|
|
|
66
65
|
var buttons = _interopRequireWildcard(require("./buttons"));
|
|
@@ -93,12 +92,16 @@ var _solidLogic = require("solid-logic");
|
|
|
93
92
|
|
|
94
93
|
var utils = _interopRequireWildcard(require("../utils"));
|
|
95
94
|
|
|
95
|
+
var _multiSelect = require("./multiSelect");
|
|
96
|
+
|
|
96
97
|
var widgets = _interopRequireWildcard(require("../widgets"));
|
|
97
98
|
|
|
98
99
|
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); }
|
|
99
100
|
|
|
100
101
|
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; }
|
|
101
102
|
|
|
103
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
104
|
+
|
|
102
105
|
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; } } }; }
|
|
103
106
|
|
|
104
107
|
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); }
|
|
@@ -155,14 +158,16 @@ _fieldFunction.field[ns.ui('Form').uri] = _fieldFunction.field[ns.ui('Group').ur
|
|
|
155
158
|
var ui = ns.ui;
|
|
156
159
|
if (container) container.appendChild(box); // Prevent loops
|
|
157
160
|
|
|
161
|
+
if (!form) return;
|
|
158
162
|
var key = subject.toNT() + '|' + form.toNT();
|
|
159
163
|
|
|
160
164
|
if (already[key]) {
|
|
161
165
|
// been there done that
|
|
162
|
-
box.appendChild(dom.createTextNode('Group: see above ' + key));
|
|
163
|
-
|
|
166
|
+
box.appendChild(dom.createTextNode('Group: see above ' + key)); // TODO fix dependency cycle to solid-panes by calling outlineManager
|
|
167
|
+
// const plist = [$rdf.st(subject, ns.owl('sameAs'), subject)] // @@ need prev subject
|
|
168
|
+
// dom.outlineManager.appendPropertyTRs(box, plist)
|
|
169
|
+
// dom.appendChild(plist)
|
|
164
170
|
|
|
165
|
-
dom.outlineManager.appendPropertyTRs(box, plist);
|
|
166
171
|
return box;
|
|
167
172
|
}
|
|
168
173
|
|
|
@@ -263,47 +268,43 @@ _fieldFunction.field[ns.ui('Options').uri] = function (dom, container, already,
|
|
|
263
268
|
values = kb.each(subject, dependingOn);
|
|
264
269
|
}
|
|
265
270
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
for (var i = 0; i < cases.length; i++) {
|
|
270
|
-
var c = cases[i];
|
|
271
|
-
var tests = kb.each(c, ui('for'), null, formDoc); // There can be multiple 'for'
|
|
271
|
+
for (var i = 0; i < cases.length; i++) {
|
|
272
|
+
var c = cases[i];
|
|
273
|
+
var tests = kb.each(c, ui('for'), null, formDoc); // There can be multiple 'for'
|
|
272
274
|
|
|
273
|
-
|
|
275
|
+
var match = false;
|
|
274
276
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
277
|
+
for (var j = 0; j < tests.length; j++) {
|
|
278
|
+
var _iterator = _createForOfIteratorHelper(values),
|
|
279
|
+
_step;
|
|
278
280
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
281
|
+
try {
|
|
282
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
283
|
+
var value = _step.value;
|
|
284
|
+
var test = tests[j];
|
|
283
285
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
286
|
+
if (value.sameTerm(tests) || value.termType === test.termType && value.value === test.value) {
|
|
287
|
+
match = true;
|
|
287
288
|
}
|
|
288
|
-
} catch (err) {
|
|
289
|
-
_iterator.e(err);
|
|
290
|
-
} finally {
|
|
291
|
-
_iterator.f();
|
|
292
289
|
}
|
|
290
|
+
} catch (err) {
|
|
291
|
+
_iterator.e(err);
|
|
292
|
+
} finally {
|
|
293
|
+
_iterator.f();
|
|
293
294
|
}
|
|
295
|
+
}
|
|
294
296
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
+
if (match) {
|
|
298
|
+
var _field3 = kb.the(c, ui('use'));
|
|
297
299
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
break;
|
|
300
|
+
if (!_field3) {
|
|
301
|
+
box.appendChild((0, _error.errorMessageBlock)(dom, 'No "use" part for case in form ' + form));
|
|
302
|
+
return box;
|
|
303
|
+
} else {
|
|
304
|
+
appendForm(dom, box, already, subject, _field3, dataDoc, callbackFunction);
|
|
306
305
|
}
|
|
306
|
+
|
|
307
|
+
break;
|
|
307
308
|
}
|
|
308
309
|
} // @@ Add box.refresh() to sync fields with values
|
|
309
310
|
|
|
@@ -353,9 +354,9 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
353
354
|
|
|
354
355
|
|
|
355
356
|
function _addItem() {
|
|
356
|
-
_addItem = (0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
357
|
+
_addItem = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
357
358
|
var object, toBeInserted, msg;
|
|
358
|
-
return
|
|
359
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
359
360
|
while (1) {
|
|
360
361
|
switch (_context6.prev = _context6.next) {
|
|
361
362
|
case 0:
|
|
@@ -418,9 +419,9 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
418
419
|
|
|
419
420
|
|
|
420
421
|
function _deleteThisItem() {
|
|
421
|
-
_deleteThisItem = (0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
422
|
+
_deleteThisItem = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
422
423
|
var i, del;
|
|
423
|
-
return
|
|
424
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
424
425
|
while (1) {
|
|
425
426
|
switch (_context3.prev = _context3.next) {
|
|
426
427
|
case 0:
|
|
@@ -493,9 +494,9 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
493
494
|
|
|
494
495
|
|
|
495
496
|
function _moveThisItem() {
|
|
496
|
-
_moveThisItem = (0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
497
|
+
_moveThisItem = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(event, upwards) {
|
|
497
498
|
var i;
|
|
498
|
-
return
|
|
499
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
499
500
|
while (1) {
|
|
500
501
|
switch (_context4.prev = _context4.next) {
|
|
501
502
|
case 0:
|
|
@@ -591,7 +592,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
591
592
|
// delete button and move buttons
|
|
592
593
|
|
|
593
594
|
if (kb.updater.editable(dataDoc.uri)) {
|
|
594
|
-
buttons.deleteButtonWithCheck(dom, subField,
|
|
595
|
+
buttons.deleteButtonWithCheck(dom, subField, multipleUIlabel, deleteThisItem);
|
|
595
596
|
|
|
596
597
|
if (ordered) {
|
|
597
598
|
// Add controsl in a frame
|
|
@@ -600,8 +601,8 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
600
601
|
frame.style.gridTemplateColumns = 'auto 3em';
|
|
601
602
|
frame.style.gridTemplateRows = '50% 50%';
|
|
602
603
|
var moveUpButton = buttons.button(dom, _iconBase.icons.iconBase + 'noun_1369237.svg', 'Move Up', /*#__PURE__*/function () {
|
|
603
|
-
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
604
|
-
return
|
|
604
|
+
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
|
|
605
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
605
606
|
while (1) {
|
|
606
607
|
switch (_context.prev = _context.next) {
|
|
607
608
|
case 0:
|
|
@@ -620,8 +621,8 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
620
621
|
};
|
|
621
622
|
}());
|
|
622
623
|
var moveDownButton = buttons.button(dom, _iconBase.icons.iconBase + 'noun_1369241.svg', 'Move Down', /*#__PURE__*/function () {
|
|
623
|
-
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
624
|
-
return
|
|
624
|
+
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(event) {
|
|
625
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
625
626
|
while (1) {
|
|
626
627
|
switch (_context2.prev = _context2.next) {
|
|
627
628
|
case 0:
|
|
@@ -642,7 +643,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
642
643
|
|
|
643
644
|
var _shim = dom.createElement('div');
|
|
644
645
|
|
|
645
|
-
_shim.appendChild(subField); // Subfield has its own
|
|
646
|
+
_shim.appendChild(subField); // Subfield has its own layout
|
|
646
647
|
|
|
647
648
|
|
|
648
649
|
frame.appendChild(_shim);
|
|
@@ -691,6 +692,8 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
691
692
|
return shim;
|
|
692
693
|
}
|
|
693
694
|
|
|
695
|
+
var multipleUIlabel = kb.any(form, ui('label'));
|
|
696
|
+
if (!multipleUIlabel) multipleUIlabel = utils.label(property);
|
|
694
697
|
var min = kb.any(form, ui('min')); // This is the minimum number -- default 0
|
|
695
698
|
|
|
696
699
|
min = min ? 0 + min.value : 0;
|
|
@@ -731,13 +734,12 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
731
734
|
img.setAttribute('src', plusIconURI); // plus sign
|
|
732
735
|
|
|
733
736
|
img.setAttribute('style', 'margin: 0.2em; width: 1.5em; height:1.5em');
|
|
734
|
-
img.title = 'Click to add
|
|
735
|
-
var prompt =
|
|
736
|
-
prompt.textContent = (values.length === 0 ? 'Add
|
|
737
|
-
|
|
737
|
+
img.title = 'Click to add another ' + multipleUIlabel;
|
|
738
|
+
var prompt = dom.createElement('span');
|
|
739
|
+
prompt.textContent = (values.length === 0 ? 'Add another ' : 'Add ') + multipleUIlabel;
|
|
738
740
|
tail.addEventListener('click', /*#__PURE__*/function () {
|
|
739
|
-
var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
740
|
-
return
|
|
741
|
+
var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_eventNotUsed) {
|
|
742
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
741
743
|
while (1) {
|
|
742
744
|
switch (_context5.prev = _context5.next) {
|
|
743
745
|
case 0:
|
|
@@ -756,6 +758,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
756
758
|
return _ref3.apply(this, arguments);
|
|
757
759
|
};
|
|
758
760
|
}(), true);
|
|
761
|
+
tail.appendChild(prompt);
|
|
759
762
|
}
|
|
760
763
|
|
|
761
764
|
function createListIfNecessary() {
|
|
@@ -775,8 +778,8 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
775
778
|
}
|
|
776
779
|
|
|
777
780
|
function _saveListThenRefresh() {
|
|
778
|
-
_saveListThenRefresh = (0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
779
|
-
return
|
|
781
|
+
_saveListThenRefresh = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
782
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
780
783
|
while (1) {
|
|
781
784
|
switch (_context7.prev = _context7.next) {
|
|
782
785
|
case 0:
|
|
@@ -833,9 +836,9 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
833
836
|
}
|
|
834
837
|
|
|
835
838
|
function _asyncStuff() {
|
|
836
|
-
_asyncStuff = (0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
839
|
+
_asyncStuff = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
837
840
|
var extra, j;
|
|
838
|
-
return
|
|
841
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
839
842
|
while (1) {
|
|
840
843
|
switch (_context8.prev = _context8.next) {
|
|
841
844
|
case 0:
|
|
@@ -1030,23 +1033,25 @@ _fieldFunction.field[ns.ui('Classifier').uri] = function (dom, container, alread
|
|
|
1030
1033
|
** -- radio buttons
|
|
1031
1034
|
** -- auto-complete typing
|
|
1032
1035
|
**
|
|
1033
|
-
**
|
|
1036
|
+
** TODO: according to ontology ui:choice can also have ns.ui('default') - this is not implemented yet
|
|
1034
1037
|
*/
|
|
1035
1038
|
|
|
1036
1039
|
|
|
1037
1040
|
_fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) {
|
|
1038
1041
|
var ui = ns.ui;
|
|
1039
1042
|
var kb = _solidLogic.store;
|
|
1040
|
-
var multiple = false;
|
|
1041
1043
|
var formDoc = form.doc ? form.doc() : null; // @@ if blank no way to know
|
|
1042
1044
|
|
|
1043
1045
|
var p;
|
|
1044
|
-
var box = dom.createElement('div');
|
|
1046
|
+
var box = dom.createElement('div');
|
|
1047
|
+
box.setAttribute('class', 'choiceBox'); // Set flexDirection column?
|
|
1045
1048
|
|
|
1046
1049
|
if (container) container.appendChild(box);
|
|
1047
1050
|
var lhs = dom.createElement('div');
|
|
1051
|
+
lhs.setAttribute('class', 'formFieldName choiceBox-label');
|
|
1048
1052
|
box.appendChild(lhs);
|
|
1049
1053
|
var rhs = dom.createElement('div');
|
|
1054
|
+
rhs.setAttribute('class', 'formFieldValue choiceBox-selectBox');
|
|
1050
1055
|
box.appendChild(rhs);
|
|
1051
1056
|
var property = kb.any(form, ui('property'));
|
|
1052
1057
|
|
|
@@ -1055,103 +1060,150 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
1055
1060
|
}
|
|
1056
1061
|
|
|
1057
1062
|
lhs.appendChild((0, _basic.fieldLabel)(dom, property, form));
|
|
1063
|
+
var uiFrom = kb.any(form, ui('from'));
|
|
1064
|
+
|
|
1065
|
+
if (!uiFrom) {
|
|
1066
|
+
return (0, _error.errorMessageBlock)(dom, "No 'from' for Choice: " + form);
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1058
1069
|
var subForm = kb.any(form, ui('use')); // Optional
|
|
1059
1070
|
|
|
1060
1071
|
var follow = kb.anyJS(form, ui('follow'), null, formDoc); // data doc moves to new subject?
|
|
1061
1072
|
|
|
1062
|
-
var possible = [];
|
|
1063
|
-
var possibleProperties;
|
|
1064
|
-
var firstSelectOptionText = '* Select from ' + utils.label(subject, true) + ' *';
|
|
1065
1073
|
var opts = {
|
|
1066
1074
|
form: form,
|
|
1067
1075
|
subForm: subForm,
|
|
1068
|
-
multiple: multiple,
|
|
1069
|
-
firstSelectOptionText: firstSelectOptionText,
|
|
1070
1076
|
disambiguate: false
|
|
1071
1077
|
};
|
|
1072
|
-
var uiFrom = kb.any(form, ui('from'));
|
|
1073
1078
|
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1079
|
+
function getSelectorOptions() {
|
|
1080
|
+
var possible = [];
|
|
1081
|
+
var possibleProperties;
|
|
1082
|
+
possible = kb.each(undefined, ns.rdf('type'), uiFrom, formDoc);
|
|
1077
1083
|
|
|
1078
|
-
|
|
1084
|
+
for (var x in findMembersNT(kb, uiFrom, dataDoc)) {
|
|
1085
|
+
possible.push(kb.fromNT(x));
|
|
1086
|
+
} // Use rdfs
|
|
1079
1087
|
|
|
1080
|
-
for (var x in kb.findMembersNT(uiFrom)) {
|
|
1081
|
-
possible.push(kb.fromNT(x));
|
|
1082
|
-
} // Use rdfs
|
|
1083
1088
|
|
|
1089
|
+
if (uiFrom.sameTerm(ns.rdfs('Class'))) {
|
|
1090
|
+
for (p in buttons.allClassURIs()) {
|
|
1091
|
+
possible.push(kb.sym(p));
|
|
1092
|
+
} // log.debug("%%% Choice field: possible.length 2 = "+possible.length)
|
|
1084
1093
|
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
possible.push(kb.sym(p));
|
|
1088
|
-
} // log.debug("%%% Choice field: possible.length 2 = "+possible.length)
|
|
1094
|
+
} else if (uiFrom.sameTerm(ns.rdf('Property'))) {
|
|
1095
|
+
possibleProperties = buttons.propertyTriage(kb);
|
|
1089
1096
|
|
|
1090
|
-
|
|
1091
|
-
|
|
1097
|
+
for (p in possibleProperties.op) {
|
|
1098
|
+
possible.push(kb.fromNT(p));
|
|
1099
|
+
}
|
|
1092
1100
|
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1101
|
+
for (p in possibleProperties.dp) {
|
|
1102
|
+
possible.push(kb.fromNT(p));
|
|
1103
|
+
}
|
|
1096
1104
|
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1105
|
+
opts.disambiguate = true; // This is a big class, and the labels won't be enough.
|
|
1106
|
+
} else if (uiFrom.sameTerm(ns.owl('ObjectProperty'))) {
|
|
1107
|
+
possibleProperties = buttons.propertyTriage(kb);
|
|
1100
1108
|
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1109
|
+
for (p in possibleProperties.op) {
|
|
1110
|
+
possible.push(kb.fromNT(p));
|
|
1111
|
+
}
|
|
1104
1112
|
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1113
|
+
opts.disambiguate = true;
|
|
1114
|
+
} else if (uiFrom.sameTerm(ns.owl('DatatypeProperty'))) {
|
|
1115
|
+
possibleProperties = buttons.propertyTriage(kb);
|
|
1108
1116
|
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1117
|
+
for (p in possibleProperties.dp) {
|
|
1118
|
+
possible.push(kb.fromNT(p));
|
|
1119
|
+
}
|
|
1112
1120
|
|
|
1113
|
-
|
|
1114
|
-
possible.push(kb.fromNT(p));
|
|
1121
|
+
opts.disambiguate = true;
|
|
1115
1122
|
}
|
|
1116
1123
|
|
|
1117
|
-
|
|
1118
|
-
}
|
|
1124
|
+
return possible; // return sortByLabel(possible)
|
|
1125
|
+
} // TODO: this checks for any occurrence, regardless of true or false setting
|
|
1119
1126
|
|
|
1120
|
-
var sortedPossible = sortByLabel(possible); // TODO: this checks for any occurance regardles if it is set to true or false
|
|
1121
1127
|
|
|
1122
1128
|
if (kb.any(form, ui('canMintNew'))) {
|
|
1123
1129
|
opts.mint = '* Create new *'; // @@ could be better
|
|
1124
1130
|
}
|
|
1125
1131
|
|
|
1126
|
-
var
|
|
1127
|
-
|
|
1128
|
-
|
|
1132
|
+
var multiSelect = kb.any(form, ui('multiselect')); // Optional
|
|
1133
|
+
|
|
1134
|
+
if (multiSelect) opts.multiSelect = true;
|
|
1135
|
+
var selector;
|
|
1136
|
+
|
|
1137
|
+
rhs.refresh = function () {
|
|
1138
|
+
// from ui:property
|
|
1139
|
+
var selectedOptions = kb.each(subject, property, null, dataDoc).map(function (object) {
|
|
1140
|
+
return object.value;
|
|
1141
|
+
}); // from ui:from + ui:property
|
|
1142
|
+
|
|
1143
|
+
var possibleOptions = getSelectorOptions();
|
|
1144
|
+
possibleOptions.push(selectedOptions);
|
|
1145
|
+
possibleOptions = sortByLabel(possibleOptions);
|
|
1146
|
+
selector = makeSelectForChoice(dom, rhs, kb, subject, property, possibleOptions, selectedOptions, uiFrom, opts, dataDoc, callbackFunction);
|
|
1147
|
+
rhs.innerHTML = '';
|
|
1148
|
+
rhs.appendChild(selector);
|
|
1149
|
+
|
|
1150
|
+
if (multiSelect) {
|
|
1151
|
+
var multiSelectDiv = new _multiSelect.IconicMultiSelect({
|
|
1152
|
+
placeholder: selector.selected,
|
|
1153
|
+
select: selector,
|
|
1154
|
+
container: rhs,
|
|
1155
|
+
textField: 'textField',
|
|
1156
|
+
valueField: 'valueField'
|
|
1157
|
+
});
|
|
1158
|
+
multiSelectDiv.init();
|
|
1159
|
+
multiSelectDiv.subscribe(function (event) {
|
|
1160
|
+
if (event.action === 'REMOVE_OPTION') {
|
|
1161
|
+
selectedOptions = selectedOptions.filter(function (value) {
|
|
1162
|
+
return value !== event.value;
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1129
1165
|
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
object = kb.any(subject, property);
|
|
1134
|
-
}
|
|
1166
|
+
if (event.action === 'CLEAR_ALL_OPTIONS') {
|
|
1167
|
+
selectedOptions = [];
|
|
1168
|
+
}
|
|
1135
1169
|
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
addSubFormChoice(dom, rhs, already, object, subForm, follow ? object.doc() : dataDoc, callbackFunction);
|
|
1139
|
-
}
|
|
1170
|
+
if (event.action === 'ADD_OPTION') {
|
|
1171
|
+
var stringValue = event.value + '';
|
|
1140
1172
|
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1173
|
+
if (stringValue.includes('Create new')) {
|
|
1174
|
+
var newObject = newThing(dataDoc);
|
|
1175
|
+
var is = [];
|
|
1176
|
+
is.push($rdf.st(subject, property, kb.sym(newObject), dataDoc));
|
|
1177
|
+
if (uiFrom) is.push($rdf.st(newObject, ns.rdf('type'), kb.sym(uiFrom), dataDoc));
|
|
1178
|
+
|
|
1179
|
+
if (subForm) {
|
|
1180
|
+
addSubFormChoice(dom, rhs, {}, $rdf.sym(newObject), subForm, dataDoc, function (ok, body) {
|
|
1181
|
+
if (ok) {
|
|
1182
|
+
kb.updater.update([], is, function (uri, success, errorBody) {
|
|
1183
|
+
if (!success) rhs.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating select: ' + errorBody));
|
|
1184
|
+
});
|
|
1185
|
+
selectedOptions.push(newObject);
|
|
1186
|
+
if (callbackFunction) callbackFunction(ok, {
|
|
1187
|
+
widget: 'select',
|
|
1188
|
+
event: 'new'
|
|
1189
|
+
});
|
|
1190
|
+
} else {
|
|
1191
|
+
rhs.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in field of select: ' + body));
|
|
1192
|
+
}
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
} else selectedOptions.push(event.value);
|
|
1196
|
+
}
|
|
1148
1197
|
|
|
1198
|
+
selector.update(selectedOptions);
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
};
|
|
1149
1202
|
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
}
|
|
1203
|
+
rhs.refresh();
|
|
1204
|
+
if (selector && selector.refresh) selector.refresh();
|
|
1205
|
+
return box;
|
|
1206
|
+
};
|
|
1155
1207
|
|
|
1156
1208
|
function addSubFormChoice(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction) {
|
|
1157
1209
|
(0, _fieldFunction.fieldFunction)(dom, subForm)(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction);
|
|
@@ -1358,7 +1410,8 @@ function promptForNew(dom, kb, subject, predicate, theClass, form, dataDoc, call
|
|
|
1358
1410
|
b.setAttribute('type', 'button');
|
|
1359
1411
|
b.setAttribute('style', 'float: right;');
|
|
1360
1412
|
b.innerHTML = 'Goto ' + utils.label(theClass);
|
|
1361
|
-
b.addEventListener('click',
|
|
1413
|
+
b.addEventListener('click', // TODO fix dependency cycle to solid-panes by calling outlineManager
|
|
1414
|
+
function (_e) {
|
|
1362
1415
|
dom.outlineManager.GotoSubject(theClass, true, undefined, true, undefined);
|
|
1363
1416
|
}, false);
|
|
1364
1417
|
return box;
|
|
@@ -1493,17 +1546,15 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
|
|
|
1493
1546
|
// @param subject - a term, the subject of the statement(s) being edited.
|
|
1494
1547
|
// @param predicate - a term, the predicate of the statement(s) being edited
|
|
1495
1548
|
// @param possible - a list of terms, the possible value the object can take
|
|
1496
|
-
// @param options.
|
|
1497
|
-
// @param options.firstSelectOptionText - a string to be displayed as the
|
|
1549
|
+
// @param options.nullLabel - a string to be displayed as the
|
|
1498
1550
|
// option for none selected (for non multiple)
|
|
1499
|
-
// @param options.mint - User may create thing if this sent to the prompt string eg "New foo"
|
|
1500
1551
|
// @param options.subForm - If mint, then the form to be used for minting the new thing
|
|
1501
1552
|
// @param dataDoc - The web document being edited
|
|
1502
1553
|
// @param callbackFunction - takes (boolean ok, string errorBody)
|
|
1503
1554
|
*/
|
|
1504
1555
|
|
|
1505
1556
|
|
|
1506
|
-
function makeSelectForOptions(dom, kb, subject, predicate, possible,
|
|
1557
|
+
function makeSelectForOptions(dom, kb, subject, predicate, possible, options, dataDoc, callbackFunction) {
|
|
1507
1558
|
log.debug('Select list length now ' + possible.length);
|
|
1508
1559
|
var n = 0;
|
|
1509
1560
|
var uris = {}; // Count them
|
|
@@ -1520,7 +1571,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
1520
1571
|
} // uris is now the set of possible options
|
|
1521
1572
|
|
|
1522
1573
|
|
|
1523
|
-
if (n === 0
|
|
1574
|
+
if (n === 0) {
|
|
1524
1575
|
return (0, _error.errorMessageBlock)(dom, "Can't do selector with no options, subject= " + subject + ' property = ' + predicate + '.');
|
|
1525
1576
|
}
|
|
1526
1577
|
|
|
@@ -1546,6 +1597,8 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
1546
1597
|
actual = getActual();
|
|
1547
1598
|
|
|
1548
1599
|
var onChange = function onChange(_e) {
|
|
1600
|
+
select.disabled = true; // until data written back - gives user feedback too
|
|
1601
|
+
|
|
1549
1602
|
var ds = [];
|
|
1550
1603
|
var is = [];
|
|
1551
1604
|
|
|
@@ -1555,43 +1608,18 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
1555
1608
|
}
|
|
1556
1609
|
};
|
|
1557
1610
|
|
|
1558
|
-
var newObject;
|
|
1559
|
-
|
|
1560
1611
|
for (var _i = 0; _i < select.options.length; _i++) {
|
|
1561
1612
|
var opt = select.options[_i];
|
|
1562
|
-
|
|
1563
|
-
if (opt.selected && opt.AJAR_mint) {
|
|
1564
|
-
// not sure if this if is used because I cannot find mintClass
|
|
1565
|
-
if (options.mintClass) {
|
|
1566
|
-
var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
|
|
1567
|
-
if (!ok) {
|
|
1568
|
-
callbackFunction(ok, body, {
|
|
1569
|
-
change: 'new'
|
|
1570
|
-
}); // @@ if ok, need some form of refresh of the select for the new thing
|
|
1571
|
-
}
|
|
1572
|
-
});
|
|
1573
|
-
select.parentNode.appendChild(thisForm);
|
|
1574
|
-
newObject = thisForm.AJAR_subject;
|
|
1575
|
-
} else {
|
|
1576
|
-
newObject = newThing(dataDoc);
|
|
1577
|
-
}
|
|
1578
|
-
|
|
1579
|
-
is.push($rdf.st(subject, predicate, kb.sym(newObject), dataDoc));
|
|
1580
|
-
if (uiFrom) is.push($rdf.st(newObject, ns.rdf('type'), kb.sym(uiFrom), dataDoc)); // not sure if this if is used because I cannot find mintStatementsFun
|
|
1581
|
-
|
|
1582
|
-
if (options.mintStatementsFun) {
|
|
1583
|
-
is = is.concat(options.mintStatementsFun(newObject));
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
|
-
select.currentURI = newObject;
|
|
1587
|
-
}
|
|
1588
|
-
|
|
1589
1613
|
if (!opt.AJAR_uri) continue; // a prompt or mint
|
|
1590
1614
|
|
|
1591
1615
|
if (opt.selected && !(opt.AJAR_uri in actual)) {
|
|
1592
1616
|
// new class
|
|
1593
1617
|
is.push($rdf.st(subject, predicate, kb.sym(opt.AJAR_uri), dataDoc));
|
|
1594
|
-
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
if (!opt.selected && opt.AJAR_uri in actual) {
|
|
1621
|
+
// old class
|
|
1622
|
+
removeValue(kb.sym(opt.AJAR_uri));
|
|
1595
1623
|
}
|
|
1596
1624
|
|
|
1597
1625
|
if (opt.selected) select.currentURI = opt.AJAR_uri;
|
|
@@ -1611,27 +1639,25 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
1611
1639
|
sel = sel.superSelect;
|
|
1612
1640
|
}
|
|
1613
1641
|
|
|
1614
|
-
log.info('selectForOptions: data doc = ' + dataDoc);
|
|
1642
|
+
log.info('selectForOptions: data doc = ' + dataDoc);
|
|
1643
|
+
kb.updater.update(ds, is, function (uri, ok, body) {
|
|
1644
|
+
actual = getActual(); // refresh
|
|
1615
1645
|
|
|
1616
|
-
removeNextSiblingsAfterElement(select);
|
|
1617
|
-
addSubFormChoice(dom, select.parentNode, {}, $rdf.sym(select.currentURI), options.subForm, dataDoc, function (ok, body) {
|
|
1618
1646
|
if (ok) {
|
|
1619
|
-
|
|
1620
|
-
|
|
1647
|
+
select.disabled = false; // data written back
|
|
1648
|
+
} else {
|
|
1649
|
+
return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in select: ' + body));
|
|
1650
|
+
}
|
|
1621
1651
|
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
});
|
|
1627
|
-
});
|
|
1628
|
-
} else return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in field of select: ' + body));
|
|
1652
|
+
if (callbackFunction) callbackFunction(ok, {
|
|
1653
|
+
widget: 'select',
|
|
1654
|
+
event: 'change'
|
|
1655
|
+
});
|
|
1629
1656
|
});
|
|
1630
1657
|
};
|
|
1631
1658
|
|
|
1632
1659
|
var select = dom.createElement('select');
|
|
1633
1660
|
select.setAttribute('style', style.formSelectSTyle);
|
|
1634
|
-
if (options.multiple) select.setAttribute('multiple', 'true');
|
|
1635
1661
|
select.currentURI = null;
|
|
1636
1662
|
|
|
1637
1663
|
select.refresh = function () {
|
|
@@ -1674,22 +1700,11 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
1674
1700
|
select.appendChild(option);
|
|
1675
1701
|
}
|
|
1676
1702
|
|
|
1677
|
-
if (
|
|
1678
|
-
var mint = dom.createElement('option');
|
|
1679
|
-
mint.appendChild(dom.createTextNode(options.mint));
|
|
1680
|
-
mint.AJAR_mint = true; // Flag it
|
|
1681
|
-
|
|
1682
|
-
select.insertBefore(mint, select.firstChild);
|
|
1683
|
-
}
|
|
1684
|
-
|
|
1685
|
-
if (!select.currentURI && !options.multiple) {
|
|
1703
|
+
if (!select.currentURI) {
|
|
1686
1704
|
var prompt = dom.createElement('option');
|
|
1687
|
-
prompt.appendChild(dom.createTextNode(options.
|
|
1688
|
-
prompt.selected = true;
|
|
1689
|
-
prompt.disabled = true;
|
|
1690
|
-
prompt.value = true;
|
|
1691
|
-
prompt.hidden = true;
|
|
1705
|
+
prompt.appendChild(dom.createTextNode(options.nullLabel));
|
|
1692
1706
|
select.insertBefore(prompt, select.firstChild);
|
|
1707
|
+
prompt.selected = true;
|
|
1693
1708
|
}
|
|
1694
1709
|
|
|
1695
1710
|
if (editable) {
|
|
@@ -1708,27 +1723,16 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
1708
1723
|
function makeSelectForCategory(dom, kb, subject, category, dataDoc, callbackFunction) {
|
|
1709
1724
|
var du = kb.any(category, ns.owl('disjointUnionOf'));
|
|
1710
1725
|
var subs;
|
|
1711
|
-
var multiple = false;
|
|
1712
1726
|
|
|
1713
1727
|
if (!du) {
|
|
1714
1728
|
subs = kb.each(undefined, ns.rdfs('subClassOf'), category);
|
|
1715
|
-
multiple = true;
|
|
1716
1729
|
} else {
|
|
1717
1730
|
subs = du.elements;
|
|
1718
1731
|
}
|
|
1719
1732
|
|
|
1720
1733
|
log.debug('Select list length ' + subs.length);
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with no subclasses of category: ' + category);
|
|
1724
|
-
}
|
|
1725
|
-
|
|
1726
|
-
if (subs.length === 1) {
|
|
1727
|
-
return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with only 1 subclass of category: ' + category + ':' + subs[1]);
|
|
1728
|
-
}
|
|
1729
|
-
|
|
1730
|
-
return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, null, {
|
|
1731
|
-
multiple: multiple
|
|
1734
|
+
return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, {
|
|
1735
|
+
nullLabel: '* Select type *'
|
|
1732
1736
|
}, dataDoc, callbackFunction);
|
|
1733
1737
|
}
|
|
1734
1738
|
/** Make SELECT element to select subclasses recurively
|
|
@@ -1762,8 +1766,7 @@ function makeSelectForNestedCategory(dom, kb, subject, category, dataDoc, callba
|
|
|
1762
1766
|
function onChange(ok, body) {
|
|
1763
1767
|
if (ok) update();
|
|
1764
1768
|
callbackFunction(ok, body);
|
|
1765
|
-
}
|
|
1766
|
-
|
|
1769
|
+
}
|
|
1767
1770
|
|
|
1768
1771
|
var select = makeSelectForCategory(dom, kb, subject, category, dataDoc, onChange);
|
|
1769
1772
|
container.appendChild(select);
|
|
@@ -1918,4 +1921,326 @@ function newThing(doc) {
|
|
|
1918
1921
|
var now = new Date();
|
|
1919
1922
|
return $rdf.sym(doc.uri + '#' + 'id' + ('' + now.getTime()));
|
|
1920
1923
|
}
|
|
1924
|
+
/** Make SELECT element to select options
|
|
1925
|
+
//
|
|
1926
|
+
// @param subject - a term, the subject of the statement(s) being edited.
|
|
1927
|
+
// @param predicate - a term, the predicate of the statement(s) being edited
|
|
1928
|
+
// @param possible - a list of terms, the possible value the object can take
|
|
1929
|
+
// @param options.mint - User may create thing if this sent to the prompt string eg "New foo"
|
|
1930
|
+
// @param options.subForm - If mint, then the form to be used for minting the new thing
|
|
1931
|
+
// @param dataDoc - The web document being edited
|
|
1932
|
+
// @param callbackFunction - takes (boolean ok, string errorBody)
|
|
1933
|
+
*/
|
|
1934
|
+
|
|
1935
|
+
|
|
1936
|
+
function makeSelectForChoice(dom, container, kb, subject, predicate, inputPossibleOptions, selectedOptions, uiFrom, options, dataDoc, callbackFunction) {
|
|
1937
|
+
var optionsFromClassUIfrom = {}; // Count them
|
|
1938
|
+
|
|
1939
|
+
var editable = kb.updater.editable(dataDoc.uri);
|
|
1940
|
+
|
|
1941
|
+
for (var i = 0; i < inputPossibleOptions.length; i++) {
|
|
1942
|
+
var sub = inputPossibleOptions[i]; // @@ Maybe; make this so it works with blank nodes too
|
|
1943
|
+
// if (!sub.uri) debug.warn(`makeSelectForChoice: option does not have an uri: ${sub}, with predicate: ${predicate}`)
|
|
1944
|
+
|
|
1945
|
+
if (!sub.uri || sub.uri in optionsFromClassUIfrom) continue;
|
|
1946
|
+
optionsFromClassUIfrom[sub.uri] = true;
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1949
|
+
var isEmpty = Object.keys(optionsFromClassUIfrom).length === 0;
|
|
1950
|
+
|
|
1951
|
+
if (isEmpty && !options.mint) {
|
|
1952
|
+
return (0, _error.errorMessageBlock)(dom, "Can't do selector with no options, subject= " + subject + ' property = ' + predicate + '.');
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
log.debug('makeSelectForChoice: dataDoc=' + dataDoc);
|
|
1956
|
+
|
|
1957
|
+
function createDefaultSelectOptionText() {
|
|
1958
|
+
var firstSelectOptionText = '--- choice ---';
|
|
1959
|
+
|
|
1960
|
+
if (predicate && !(predicate.termType === 'BlankNode')) {
|
|
1961
|
+
firstSelectOptionText = '* Select for property: ' + utils.label(predicate) + ' *';
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
if (subject && !(subject.termType === 'BlankNode')) {
|
|
1965
|
+
firstSelectOptionText = '* Select for ' + utils.label(subject, true) + ' *';
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
return firstSelectOptionText;
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
function createDefaultSelectOption() {
|
|
1972
|
+
var option = dom.createElement('option');
|
|
1973
|
+
option.appendChild(dom.createTextNode(createDefaultSelectOptionText()));
|
|
1974
|
+
option.disabled = true;
|
|
1975
|
+
option.value = true;
|
|
1976
|
+
option.hidden = true;
|
|
1977
|
+
option.selected = true;
|
|
1978
|
+
return option;
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
var onChange = function onChange(_e) {
|
|
1982
|
+
container.removeChild(container.lastChild);
|
|
1983
|
+
select.refresh();
|
|
1984
|
+
};
|
|
1985
|
+
|
|
1986
|
+
var select = dom.createElement('select');
|
|
1987
|
+
select.setAttribute('style', style.formSelectSTyle);
|
|
1988
|
+
select.setAttribute('id', 'formSelect');
|
|
1989
|
+
select.currentURI = null;
|
|
1990
|
+
|
|
1991
|
+
for (var uri in optionsFromClassUIfrom) {
|
|
1992
|
+
select.appendChild(createOption(uri));
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
if (editable && options.mint) {
|
|
1996
|
+
var mint = dom.createElement('option');
|
|
1997
|
+
mint.appendChild(dom.createTextNode(options.mint));
|
|
1998
|
+
mint.AJAR_mint = true; // Flag it
|
|
1999
|
+
|
|
2000
|
+
select.insertBefore(mint, select.firstChild);
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
if (select.children.length === 0) select.insertBefore(createDefaultSelectOption(), select.firstChild);
|
|
2004
|
+
|
|
2005
|
+
select.update = function (newSelectedOptions) {
|
|
2006
|
+
selectedOptions = newSelectedOptions;
|
|
2007
|
+
var ds = [];
|
|
2008
|
+
var is = [];
|
|
2009
|
+
|
|
2010
|
+
var removeValue = function removeValue(t) {
|
|
2011
|
+
if (kb.holds(subject, predicate, t, dataDoc)) {
|
|
2012
|
+
ds.push($rdf.st(subject, predicate, t, dataDoc));
|
|
2013
|
+
}
|
|
2014
|
+
};
|
|
2015
|
+
|
|
2016
|
+
var addValue = function addValue(t) {
|
|
2017
|
+
if (!kb.holds(subject, predicate, t, dataDoc)) {
|
|
2018
|
+
is.push($rdf.st(subject, predicate, t, dataDoc)); // console.log("----value added " + t)
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
if (uiFrom && !kb.holds(t, ns.rdf('type'), kb.sym(uiFrom), dataDoc)) {
|
|
2022
|
+
is.push($rdf.st(t, ns.rdf('type'), kb.sym(uiFrom), dataDoc)); // console.log("----added type to value " + uiFrom)
|
|
2023
|
+
}
|
|
2024
|
+
};
|
|
2025
|
+
|
|
2026
|
+
var existingValues = kb.each(subject, predicate, null, dataDoc).map(function (object) {
|
|
2027
|
+
return object.value;
|
|
2028
|
+
});
|
|
2029
|
+
|
|
2030
|
+
var _iterator2 = _createForOfIteratorHelper(existingValues),
|
|
2031
|
+
_step2;
|
|
2032
|
+
|
|
2033
|
+
try {
|
|
2034
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2035
|
+
var value = _step2.value;
|
|
2036
|
+
if (!containsObject(value, selectedOptions)) removeValue($rdf.sym(value));
|
|
2037
|
+
}
|
|
2038
|
+
} catch (err) {
|
|
2039
|
+
_iterator2.e(err);
|
|
2040
|
+
} finally {
|
|
2041
|
+
_iterator2.f();
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
var _iterator3 = _createForOfIteratorHelper(selectedOptions),
|
|
2045
|
+
_step3;
|
|
2046
|
+
|
|
2047
|
+
try {
|
|
2048
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
2049
|
+
var _value = _step3.value;
|
|
2050
|
+
if (!(_value in existingValues)) addValue($rdf.sym(_value));
|
|
2051
|
+
}
|
|
2052
|
+
} catch (err) {
|
|
2053
|
+
_iterator3.e(err);
|
|
2054
|
+
} finally {
|
|
2055
|
+
_iterator3.f();
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
kb.updater.update(ds, is, function (uri, ok, body) {
|
|
2059
|
+
if (!ok) return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in select: ' + body));
|
|
2060
|
+
select.refresh();
|
|
2061
|
+
if (callbackFunction) callbackFunction(ok, {
|
|
2062
|
+
widget: 'select',
|
|
2063
|
+
event: 'change'
|
|
2064
|
+
});
|
|
2065
|
+
});
|
|
2066
|
+
};
|
|
2067
|
+
|
|
2068
|
+
select.refresh = function () {
|
|
2069
|
+
select.disabled = true; // unlocked any conflict we had got into
|
|
2070
|
+
|
|
2071
|
+
var is = [];
|
|
2072
|
+
var newObject;
|
|
2073
|
+
|
|
2074
|
+
for (var _i3 = 0; _i3 < select.options.length; _i3++) {
|
|
2075
|
+
var opt = select.options[_i3];
|
|
2076
|
+
|
|
2077
|
+
if (opt.selected && opt.AJAR_mint) {
|
|
2078
|
+
// not sure if this 'if' is used because I cannot find mintClass
|
|
2079
|
+
if (options.mintClass) {
|
|
2080
|
+
var thisForm = promptForNew(dom, kb, subject, predicate, uiFrom, options.subForm, dataDoc, function (ok, body) {
|
|
2081
|
+
if (!ok) {
|
|
2082
|
+
callbackFunction(ok, body, {
|
|
2083
|
+
change: 'new'
|
|
2084
|
+
}); // @@ if ok, need some form of refresh of the select for the new thing
|
|
2085
|
+
}
|
|
2086
|
+
});
|
|
2087
|
+
select.parentNode.appendChild(thisForm);
|
|
2088
|
+
newObject = thisForm.AJAR_subject;
|
|
2089
|
+
} else {
|
|
2090
|
+
newObject = newThing(dataDoc);
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
is.push($rdf.st(subject, predicate, kb.sym(newObject), dataDoc));
|
|
2094
|
+
if (uiFrom) is.push($rdf.st(newObject, ns.rdf('type'), kb.sym(uiFrom), dataDoc)); // not sure if this 'if' is used because I cannot find mintStatementsFun
|
|
2095
|
+
|
|
2096
|
+
if (options.mintStatementsFun) {
|
|
2097
|
+
is = is.concat(options.mintStatementsFun(newObject));
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
select.currentURI = newObject;
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
if (!opt.AJAR_uri) continue; // a prompt or mint
|
|
2104
|
+
|
|
2105
|
+
if (opt.selected && containsObject(opt.AJAR_uri, selectedOptions)) {
|
|
2106
|
+
select.currentURI = opt.AJAR_uri;
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
if (!containsObject(opt.AJAR_uri, selectedOptions)) opt.removeAttribute('selected');
|
|
2110
|
+
if (containsObject(opt.AJAR_uri, selectedOptions)) opt.setAttribute('selected', 'true');
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
log.info('selectForOptions: data doc = ' + dataDoc);
|
|
2114
|
+
|
|
2115
|
+
if (select.currentURI && options.subForm && !options.multiSelect) {
|
|
2116
|
+
addSubFormChoice(dom, container, {}, $rdf.sym(select.currentURI), options.subForm, dataDoc, function (ok, body) {
|
|
2117
|
+
if (ok) {
|
|
2118
|
+
kb.updater.update([], is, function (uri, success, errorBody) {
|
|
2119
|
+
if (!success) container.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating select: ' + errorBody));
|
|
2120
|
+
});
|
|
2121
|
+
if (callbackFunction) callbackFunction(ok, {
|
|
2122
|
+
widget: 'select',
|
|
2123
|
+
event: 'new'
|
|
2124
|
+
});
|
|
2125
|
+
} else {
|
|
2126
|
+
container.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in field of select: ' + body));
|
|
2127
|
+
}
|
|
2128
|
+
});
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
select.disabled = false;
|
|
2132
|
+
};
|
|
2133
|
+
|
|
2134
|
+
function createOption(uri) {
|
|
2135
|
+
var option = dom.createElement('option');
|
|
2136
|
+
var c = kb.sym(uri);
|
|
2137
|
+
var label;
|
|
2138
|
+
|
|
2139
|
+
if (options.disambiguate) {
|
|
2140
|
+
label = utils.labelWithOntology(c, true); // Init. cap
|
|
2141
|
+
} else {
|
|
2142
|
+
label = utils.label(c, true);
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
option.appendChild(dom.createTextNode(label)); // Init.
|
|
2146
|
+
|
|
2147
|
+
option.setAttribute('value', uri);
|
|
2148
|
+
var backgroundColor = kb.any(c, kb.sym('http://www.w3.org/ns/ui#backgroundColor'));
|
|
2149
|
+
|
|
2150
|
+
if (backgroundColor) {
|
|
2151
|
+
option.setAttribute('style', 'background-color: ' + backgroundColor.value + '; ');
|
|
2152
|
+
}
|
|
2153
|
+
|
|
2154
|
+
option.AJAR_uri = uri;
|
|
2155
|
+
|
|
2156
|
+
if (containsObject(c.value, selectedOptions)) {
|
|
2157
|
+
option.setAttribute('selected', 'true');
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
return option;
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
if (editable) {
|
|
2164
|
+
select.addEventListener('change', onChange, false);
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
return select;
|
|
2168
|
+
} // makeSelectForChoice
|
|
2169
|
+
|
|
2170
|
+
|
|
2171
|
+
function containsObject(obj, list) {
|
|
2172
|
+
var i;
|
|
2173
|
+
|
|
2174
|
+
for (i = 0; i < list.length; i++) {
|
|
2175
|
+
if (list[i] === obj) {
|
|
2176
|
+
return true;
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
return false;
|
|
2181
|
+
} // This functions replaces the findMembersNT (thisClass) from rdflib until we fix: https://github.com/linkeddata/rdflib.js/issues/565
|
|
2182
|
+
|
|
2183
|
+
/**
|
|
2184
|
+
* For thisClass or any subclass, anything which has it is its type
|
|
2185
|
+
* or is the object of something which has the type as its range, or subject
|
|
2186
|
+
* of something which has the type as its domain
|
|
2187
|
+
* We don't bother doing subproperty (yet?)as it doesn't seeem to be used
|
|
2188
|
+
* much.
|
|
2189
|
+
* Get all the Classes of which we can RDFS-infer the subject is a member
|
|
2190
|
+
* @return a hash of URIs
|
|
2191
|
+
*/
|
|
2192
|
+
|
|
2193
|
+
|
|
2194
|
+
function findMembersNT(store, thisClass, quad) {
|
|
2195
|
+
var len2;
|
|
2196
|
+
var len4;
|
|
2197
|
+
var m;
|
|
2198
|
+
var pred;
|
|
2199
|
+
var ref1;
|
|
2200
|
+
var ref2;
|
|
2201
|
+
var ref3;
|
|
2202
|
+
var ref4;
|
|
2203
|
+
var ref5;
|
|
2204
|
+
var st;
|
|
2205
|
+
var u;
|
|
2206
|
+
var seeds = {};
|
|
2207
|
+
seeds[thisClass.toNT()] = true;
|
|
2208
|
+
var members = {};
|
|
2209
|
+
var ref = store.transitiveClosure(seeds, store.rdfFactory.namedNode('http://www.w3.org/2000/01/rdf-schema#subClassOf'), true);
|
|
2210
|
+
|
|
2211
|
+
for (var t in ref) {
|
|
2212
|
+
ref1 = store.statementsMatching(null, store.rdfFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), store.fromNT(t), quad);
|
|
2213
|
+
|
|
2214
|
+
for (var i = 0, len = ref1.length; i < len; i++) {
|
|
2215
|
+
st = ref1[i];
|
|
2216
|
+
members[st.subject.toNT()] = st;
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
ref2 = store.each(null, store.rdfFactory.namedNode('http://www.w3.org/2000/01/rdf-schema#domain'), store.fromNT(t), quad);
|
|
2220
|
+
|
|
2221
|
+
for (var l = 0, len1 = ref2.length; l < len1; l++) {
|
|
2222
|
+
pred = ref2[l];
|
|
2223
|
+
ref3 = store.statementsMatching(null, pred, null, quad);
|
|
2224
|
+
|
|
2225
|
+
for (m = 0, len2 = ref3.length; m < len2; m++) {
|
|
2226
|
+
st = ref3[m];
|
|
2227
|
+
members[st.subject.toNT()] = st;
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
ref4 = store.each(null, store.rdfFactory.namedNode('http://www.w3.org/2000/01/rdf-schema#range'), store.fromNT(t), quad);
|
|
2232
|
+
|
|
2233
|
+
for (var q = 0, len3 = ref4.length; q < len3; q++) {
|
|
2234
|
+
pred = ref4[q];
|
|
2235
|
+
ref5 = store.statementsMatching(null, pred, null, quad);
|
|
2236
|
+
|
|
2237
|
+
for (u = 0, len4 = ref5.length; u < len4; u++) {
|
|
2238
|
+
st = ref5[u];
|
|
2239
|
+
members[st.object.toNT()] = st;
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
return members;
|
|
2245
|
+
}
|
|
1921
2246
|
//# sourceMappingURL=forms.js.map
|