solid-ui 2.4.22-580e8bf6 → 2.4.22-68cc70d5
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 +1779 -1138
- 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.map +1 -1
- package/lib/versionInfo.js +4 -4
- package/lib/versionInfo.js.map +1 -1
- package/lib/widgets/buttons/iconLinks.js.map +1 -1
- 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 +230 -181
- 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
|
@@ -60,8 +60,6 @@ Object.defineProperty(exports, "renderNameValuePair", {
|
|
|
60
60
|
exports.sortByLabel = sortByLabel;
|
|
61
61
|
exports.sortBySequence = sortBySequence;
|
|
62
62
|
|
|
63
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
64
|
-
|
|
65
63
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
66
64
|
|
|
67
65
|
var buttons = _interopRequireWildcard(require("./buttons"));
|
|
@@ -94,12 +92,16 @@ var _solidLogic = require("solid-logic");
|
|
|
94
92
|
|
|
95
93
|
var utils = _interopRequireWildcard(require("../utils"));
|
|
96
94
|
|
|
95
|
+
var _multiSelect = require("./multiSelect");
|
|
96
|
+
|
|
97
97
|
var widgets = _interopRequireWildcard(require("../widgets"));
|
|
98
98
|
|
|
99
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); }
|
|
100
100
|
|
|
101
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; }
|
|
102
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
|
+
|
|
103
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; } } }; }
|
|
104
106
|
|
|
105
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); }
|
|
@@ -266,47 +268,43 @@ _fieldFunction.field[ns.ui('Options').uri] = function (dom, container, already,
|
|
|
266
268
|
values = kb.each(subject, dependingOn);
|
|
267
269
|
}
|
|
268
270
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
for (var i = 0; i < cases.length; i++) {
|
|
273
|
-
var c = cases[i];
|
|
274
|
-
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'
|
|
275
274
|
|
|
276
|
-
|
|
275
|
+
var match = false;
|
|
277
276
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
277
|
+
for (var j = 0; j < tests.length; j++) {
|
|
278
|
+
var _iterator = _createForOfIteratorHelper(values),
|
|
279
|
+
_step;
|
|
281
280
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
281
|
+
try {
|
|
282
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
283
|
+
var value = _step.value;
|
|
284
|
+
var test = tests[j];
|
|
286
285
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
}
|
|
286
|
+
if (value.sameTerm(tests) || value.termType === test.termType && value.value === test.value) {
|
|
287
|
+
match = true;
|
|
290
288
|
}
|
|
291
|
-
} catch (err) {
|
|
292
|
-
_iterator.e(err);
|
|
293
|
-
} finally {
|
|
294
|
-
_iterator.f();
|
|
295
289
|
}
|
|
290
|
+
} catch (err) {
|
|
291
|
+
_iterator.e(err);
|
|
292
|
+
} finally {
|
|
293
|
+
_iterator.f();
|
|
296
294
|
}
|
|
295
|
+
}
|
|
297
296
|
|
|
298
|
-
|
|
299
|
-
|
|
297
|
+
if (match) {
|
|
298
|
+
var _field3 = kb.the(c, ui('use'));
|
|
300
299
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
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);
|
|
309
305
|
}
|
|
306
|
+
|
|
307
|
+
break;
|
|
310
308
|
}
|
|
311
309
|
} // @@ Add box.refresh() to sync fields with values
|
|
312
310
|
|
|
@@ -356,9 +354,9 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
356
354
|
|
|
357
355
|
|
|
358
356
|
function _addItem() {
|
|
359
|
-
_addItem = (0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
357
|
+
_addItem = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
360
358
|
var object, toBeInserted, msg;
|
|
361
|
-
return
|
|
359
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
362
360
|
while (1) {
|
|
363
361
|
switch (_context6.prev = _context6.next) {
|
|
364
362
|
case 0:
|
|
@@ -421,9 +419,9 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
421
419
|
|
|
422
420
|
|
|
423
421
|
function _deleteThisItem() {
|
|
424
|
-
_deleteThisItem = (0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
422
|
+
_deleteThisItem = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
425
423
|
var i, del;
|
|
426
|
-
return
|
|
424
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
427
425
|
while (1) {
|
|
428
426
|
switch (_context3.prev = _context3.next) {
|
|
429
427
|
case 0:
|
|
@@ -496,9 +494,9 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
496
494
|
|
|
497
495
|
|
|
498
496
|
function _moveThisItem() {
|
|
499
|
-
_moveThisItem = (0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
497
|
+
_moveThisItem = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(event, upwards) {
|
|
500
498
|
var i;
|
|
501
|
-
return
|
|
499
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
502
500
|
while (1) {
|
|
503
501
|
switch (_context4.prev = _context4.next) {
|
|
504
502
|
case 0:
|
|
@@ -603,8 +601,8 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
603
601
|
frame.style.gridTemplateColumns = 'auto 3em';
|
|
604
602
|
frame.style.gridTemplateRows = '50% 50%';
|
|
605
603
|
var moveUpButton = buttons.button(dom, _iconBase.icons.iconBase + 'noun_1369237.svg', 'Move Up', /*#__PURE__*/function () {
|
|
606
|
-
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
607
|
-
return
|
|
604
|
+
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
|
|
605
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
608
606
|
while (1) {
|
|
609
607
|
switch (_context.prev = _context.next) {
|
|
610
608
|
case 0:
|
|
@@ -623,8 +621,8 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
623
621
|
};
|
|
624
622
|
}());
|
|
625
623
|
var moveDownButton = buttons.button(dom, _iconBase.icons.iconBase + 'noun_1369241.svg', 'Move Down', /*#__PURE__*/function () {
|
|
626
|
-
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
627
|
-
return
|
|
624
|
+
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(event) {
|
|
625
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
628
626
|
while (1) {
|
|
629
627
|
switch (_context2.prev = _context2.next) {
|
|
630
628
|
case 0:
|
|
@@ -740,8 +738,8 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
740
738
|
var prompt = dom.createElement('span');
|
|
741
739
|
prompt.textContent = (values.length === 0 ? 'Add another ' : 'Add ') + multipleUIlabel;
|
|
742
740
|
tail.addEventListener('click', /*#__PURE__*/function () {
|
|
743
|
-
var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
744
|
-
return
|
|
741
|
+
var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_eventNotUsed) {
|
|
742
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
745
743
|
while (1) {
|
|
746
744
|
switch (_context5.prev = _context5.next) {
|
|
747
745
|
case 0:
|
|
@@ -780,8 +778,8 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
780
778
|
}
|
|
781
779
|
|
|
782
780
|
function _saveListThenRefresh() {
|
|
783
|
-
_saveListThenRefresh = (0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
784
|
-
return
|
|
781
|
+
_saveListThenRefresh = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
782
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
785
783
|
while (1) {
|
|
786
784
|
switch (_context7.prev = _context7.next) {
|
|
787
785
|
case 0:
|
|
@@ -838,9 +836,9 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
|
|
|
838
836
|
}
|
|
839
837
|
|
|
840
838
|
function _asyncStuff() {
|
|
841
|
-
_asyncStuff = (0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
839
|
+
_asyncStuff = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
842
840
|
var extra, j;
|
|
843
|
-
return
|
|
841
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
844
842
|
while (1) {
|
|
845
843
|
switch (_context8.prev = _context8.next) {
|
|
846
844
|
case 0:
|
|
@@ -1044,7 +1042,6 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
1044
1042
|
var kb = _solidLogic.store;
|
|
1045
1043
|
var formDoc = form.doc ? form.doc() : null; // @@ if blank no way to know
|
|
1046
1044
|
|
|
1047
|
-
var multiSelect = false;
|
|
1048
1045
|
var p;
|
|
1049
1046
|
var box = dom.createElement('div');
|
|
1050
1047
|
box.setAttribute('class', 'choiceBox'); // Set flexDirection column?
|
|
@@ -1076,7 +1073,6 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
1076
1073
|
var opts = {
|
|
1077
1074
|
form: form,
|
|
1078
1075
|
subForm: subForm,
|
|
1079
|
-
multiSelect: multiSelect,
|
|
1080
1076
|
disambiguate: false
|
|
1081
1077
|
};
|
|
1082
1078
|
|
|
@@ -1125,7 +1121,7 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
1125
1121
|
opts.disambiguate = true;
|
|
1126
1122
|
}
|
|
1127
1123
|
|
|
1128
|
-
return sortByLabel(possible)
|
|
1124
|
+
return possible; // return sortByLabel(possible)
|
|
1129
1125
|
} // TODO: this checks for any occurrence, regardless of true or false setting
|
|
1130
1126
|
|
|
1131
1127
|
|
|
@@ -1133,31 +1129,81 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
1133
1129
|
opts.mint = '* Create new *'; // @@ could be better
|
|
1134
1130
|
}
|
|
1135
1131
|
|
|
1132
|
+
var multiSelect = kb.any(form, ui('multiselect')); // Optional
|
|
1133
|
+
|
|
1134
|
+
if (multiSelect) opts.multiSelect = true;
|
|
1136
1135
|
var selector;
|
|
1137
1136
|
|
|
1138
1137
|
rhs.refresh = function () {
|
|
1139
|
-
|
|
1140
|
-
|
|
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);
|
|
1141
1147
|
rhs.innerHTML = '';
|
|
1142
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
|
+
}
|
|
1165
|
+
|
|
1166
|
+
if (event.action === 'CLEAR_ALL_OPTIONS') {
|
|
1167
|
+
selectedOptions = [];
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
if (event.action === 'ADD_OPTION') {
|
|
1171
|
+
var stringValue = event.value + '';
|
|
1172
|
+
|
|
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
|
+
}
|
|
1197
|
+
|
|
1198
|
+
selector.update(selectedOptions);
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1143
1201
|
};
|
|
1144
1202
|
|
|
1145
1203
|
rhs.refresh();
|
|
1146
1204
|
if (selector && selector.refresh) selector.refresh();
|
|
1147
1205
|
return box;
|
|
1148
1206
|
};
|
|
1149
|
-
/**
|
|
1150
|
-
* Removes all sibling elements after specified
|
|
1151
|
-
* @param {HTMLElement} currentElement
|
|
1152
|
-
* @private
|
|
1153
|
-
*/
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
function removeNextSiblingsAfterElement(currentElement) {
|
|
1157
|
-
while (currentElement.nextElementSibling) {
|
|
1158
|
-
currentElement.nextElementSibling.remove();
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
1207
|
|
|
1162
1208
|
function addSubFormChoice(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction) {
|
|
1163
1209
|
(0, _fieldFunction.fieldFunction)(dom, subForm)(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction);
|
|
@@ -1500,10 +1546,8 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
|
|
|
1500
1546
|
// @param subject - a term, the subject of the statement(s) being edited.
|
|
1501
1547
|
// @param predicate - a term, the predicate of the statement(s) being edited
|
|
1502
1548
|
// @param possible - a list of terms, the possible value the object can take
|
|
1503
|
-
// @param options.multiple - Boolean - Whether more than one at a time is allowed
|
|
1504
1549
|
// @param options.nullLabel - a string to be displayed as the
|
|
1505
1550
|
// option for none selected (for non multiple)
|
|
1506
|
-
// @param options.mint - User may create thing if this sent to the prompt string eg "New foo"
|
|
1507
1551
|
// @param options.subForm - If mint, then the form to be used for minting the new thing
|
|
1508
1552
|
// @param dataDoc - The web document being edited
|
|
1509
1553
|
// @param callbackFunction - takes (boolean ok, string errorBody)
|
|
@@ -1527,7 +1571,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
|
|
|
1527
1571
|
} // uris is now the set of possible options
|
|
1528
1572
|
|
|
1529
1573
|
|
|
1530
|
-
if (n === 0
|
|
1574
|
+
if (n === 0) {
|
|
1531
1575
|
return (0, _error.errorMessageBlock)(dom, "Can't do selector with no options, subject= " + subject + ' property = ' + predicate + '.');
|
|
1532
1576
|
}
|
|
1533
1577
|
|
|
@@ -1564,34 +1608,8 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
|
|
|
1564
1608
|
}
|
|
1565
1609
|
};
|
|
1566
1610
|
|
|
1567
|
-
var newObject;
|
|
1568
|
-
|
|
1569
1611
|
for (var _i = 0; _i < select.options.length; _i++) {
|
|
1570
1612
|
var opt = select.options[_i];
|
|
1571
|
-
|
|
1572
|
-
if (opt.selected && opt.AJAR_mint) {
|
|
1573
|
-
// not sure if this 'if' is used because I cannot find mintClass
|
|
1574
|
-
if (options.mintClass) {
|
|
1575
|
-
var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
|
|
1576
|
-
if (!ok) {
|
|
1577
|
-
callbackFunction(ok, body, {
|
|
1578
|
-
change: 'new'
|
|
1579
|
-
}); // @@ if ok, need some form of refresh of the select for the new thing
|
|
1580
|
-
}
|
|
1581
|
-
});
|
|
1582
|
-
select.parentNode.appendChild(thisForm);
|
|
1583
|
-
newObject = thisForm.AJAR_subject;
|
|
1584
|
-
} else {
|
|
1585
|
-
newObject = newThing(dataDoc);
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1588
|
-
is.push($rdf.st(subject, predicate, newObject, dataDoc)); // not sure if this 'if' is used because I cannot find mintStatementsFun
|
|
1589
|
-
|
|
1590
|
-
if (options.mintStatementsFun) {
|
|
1591
|
-
is = is.concat(options.mintStatementsFun(newObject));
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
|
|
1595
1613
|
if (!opt.AJAR_uri) continue; // a prompt or mint
|
|
1596
1614
|
|
|
1597
1615
|
if (opt.selected && !(opt.AJAR_uri in actual)) {
|
|
@@ -1621,24 +1639,12 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
|
|
|
1621
1639
|
sel = sel.superSelect;
|
|
1622
1640
|
}
|
|
1623
1641
|
|
|
1624
|
-
function doneNew(ok, _body) {
|
|
1625
|
-
callbackFunction(ok, {
|
|
1626
|
-
widget: 'select',
|
|
1627
|
-
event: 'new'
|
|
1628
|
-
});
|
|
1629
|
-
}
|
|
1630
|
-
|
|
1631
1642
|
log.info('selectForOptions: data doc = ' + dataDoc);
|
|
1632
1643
|
kb.updater.update(ds, is, function (uri, ok, body) {
|
|
1633
1644
|
actual = getActual(); // refresh
|
|
1634
1645
|
|
|
1635
1646
|
if (ok) {
|
|
1636
1647
|
select.disabled = false; // data written back
|
|
1637
|
-
|
|
1638
|
-
if (newObject) {
|
|
1639
|
-
var fn = (0, _fieldFunction.fieldFunction)(dom, options.subForm);
|
|
1640
|
-
fn(dom, select.parentNode, {}, newObject, options.subForm, dataDoc, doneNew);
|
|
1641
|
-
}
|
|
1642
1648
|
} else {
|
|
1643
1649
|
return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in select: ' + body));
|
|
1644
1650
|
}
|
|
@@ -1652,7 +1658,6 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
|
|
|
1652
1658
|
|
|
1653
1659
|
var select = dom.createElement('select');
|
|
1654
1660
|
select.setAttribute('style', style.formSelectSTyle);
|
|
1655
|
-
if (options.multiple) select.setAttribute('multiple', 'true');
|
|
1656
1661
|
select.currentURI = null;
|
|
1657
1662
|
|
|
1658
1663
|
select.refresh = function () {
|
|
@@ -1695,15 +1700,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
|
|
|
1695
1700
|
select.appendChild(option);
|
|
1696
1701
|
}
|
|
1697
1702
|
|
|
1698
|
-
if (
|
|
1699
|
-
var mint = dom.createElement('option');
|
|
1700
|
-
mint.appendChild(dom.createTextNode(options.mint));
|
|
1701
|
-
mint.AJAR_mint = true; // Flag it
|
|
1702
|
-
|
|
1703
|
-
select.insertBefore(mint, select.firstChild);
|
|
1704
|
-
}
|
|
1705
|
-
|
|
1706
|
-
if (select.currentURI == null && !options.multiple) {
|
|
1703
|
+
if (!select.currentURI) {
|
|
1707
1704
|
var prompt = dom.createElement('option');
|
|
1708
1705
|
prompt.appendChild(dom.createTextNode(options.nullLabel));
|
|
1709
1706
|
select.insertBefore(prompt, select.firstChild);
|
|
@@ -1726,28 +1723,16 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
|
|
|
1726
1723
|
function makeSelectForCategory(dom, kb, subject, category, dataDoc, callbackFunction) {
|
|
1727
1724
|
var du = kb.any(category, ns.owl('disjointUnionOf'));
|
|
1728
1725
|
var subs;
|
|
1729
|
-
var multiple = false;
|
|
1730
1726
|
|
|
1731
1727
|
if (!du) {
|
|
1732
1728
|
subs = kb.each(undefined, ns.rdfs('subClassOf'), category);
|
|
1733
|
-
multiple = true;
|
|
1734
1729
|
} else {
|
|
1735
1730
|
subs = du.elements;
|
|
1736
1731
|
}
|
|
1737
1732
|
|
|
1738
1733
|
log.debug('Select list length ' + subs.length);
|
|
1739
|
-
|
|
1740
|
-
if (subs.length === 0) {
|
|
1741
|
-
return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with no subclasses of category: ' + category);
|
|
1742
|
-
}
|
|
1743
|
-
|
|
1744
|
-
if (subs.length === 1) {
|
|
1745
|
-
return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with only 1 subclass of category: ' + category + ':' + subs[1]);
|
|
1746
|
-
}
|
|
1747
|
-
|
|
1748
1734
|
return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, {
|
|
1749
|
-
|
|
1750
|
-
nullPrompt: '--classify--'
|
|
1735
|
+
nullLabel: '* Select type *'
|
|
1751
1736
|
}, dataDoc, callbackFunction);
|
|
1752
1737
|
}
|
|
1753
1738
|
/** Make SELECT element to select subclasses recurively
|
|
@@ -1781,8 +1766,7 @@ function makeSelectForNestedCategory(dom, kb, subject, category, dataDoc, callba
|
|
|
1781
1766
|
function onChange(ok, body) {
|
|
1782
1767
|
if (ok) update();
|
|
1783
1768
|
callbackFunction(ok, body);
|
|
1784
|
-
}
|
|
1785
|
-
|
|
1769
|
+
}
|
|
1786
1770
|
|
|
1787
1771
|
var select = makeSelectForCategory(dom, kb, subject, category, dataDoc, onChange);
|
|
1788
1772
|
container.appendChild(select);
|
|
@@ -1942,8 +1926,6 @@ function newThing(doc) {
|
|
|
1942
1926
|
// @param subject - a term, the subject of the statement(s) being edited.
|
|
1943
1927
|
// @param predicate - a term, the predicate of the statement(s) being edited
|
|
1944
1928
|
// @param possible - a list of terms, the possible value the object can take
|
|
1945
|
-
// @param options.multiSelect - Boolean - Whether more than one at a time is allowed
|
|
1946
|
-
// @param options.uiMultipleInUse - signals that the ui:choise is used with a ui:multiple
|
|
1947
1929
|
// @param options.mint - User may create thing if this sent to the prompt string eg "New foo"
|
|
1948
1930
|
// @param options.subForm - If mint, then the form to be used for minting the new thing
|
|
1949
1931
|
// @param dataDoc - The web document being edited
|
|
@@ -1951,31 +1933,29 @@ function newThing(doc) {
|
|
|
1951
1933
|
*/
|
|
1952
1934
|
|
|
1953
1935
|
|
|
1954
|
-
function makeSelectForChoice(dom, container, kb, subject, predicate,
|
|
1955
|
-
var
|
|
1956
|
-
var uris = {}; // Count them
|
|
1936
|
+
function makeSelectForChoice(dom, container, kb, subject, predicate, inputPossibleOptions, selectedOptions, uiFrom, options, dataDoc, callbackFunction) {
|
|
1937
|
+
var optionsFromClassUIfrom = {}; // Count them
|
|
1957
1938
|
|
|
1958
1939
|
var editable = kb.updater.editable(dataDoc.uri);
|
|
1959
1940
|
|
|
1960
|
-
for (var i = 0; i <
|
|
1961
|
-
var sub =
|
|
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}`)
|
|
1962
1944
|
|
|
1963
|
-
if (!sub.uri
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
n++;
|
|
1967
|
-
} // uris is now the set of possible options
|
|
1945
|
+
if (!sub.uri || sub.uri in optionsFromClassUIfrom) continue;
|
|
1946
|
+
optionsFromClassUIfrom[sub.uri] = true;
|
|
1947
|
+
}
|
|
1968
1948
|
|
|
1949
|
+
var isEmpty = Object.keys(optionsFromClassUIfrom).length === 0;
|
|
1969
1950
|
|
|
1970
|
-
if (
|
|
1951
|
+
if (isEmpty && !options.mint) {
|
|
1971
1952
|
return (0, _error.errorMessageBlock)(dom, "Can't do selector with no options, subject= " + subject + ' property = ' + predicate + '.');
|
|
1972
1953
|
}
|
|
1973
1954
|
|
|
1974
|
-
log.debug('
|
|
1955
|
+
log.debug('makeSelectForChoice: dataDoc=' + dataDoc);
|
|
1975
1956
|
|
|
1976
|
-
function
|
|
1977
|
-
var firstSelectOptionText = '---
|
|
1978
|
-
var option = dom.createElement('option');
|
|
1957
|
+
function createDefaultSelectOptionText() {
|
|
1958
|
+
var firstSelectOptionText = '--- choice ---';
|
|
1979
1959
|
|
|
1980
1960
|
if (predicate && !(predicate.termType === 'BlankNode')) {
|
|
1981
1961
|
firstSelectOptionText = '* Select for property: ' + utils.label(predicate) + ' *';
|
|
@@ -1985,7 +1965,12 @@ function makeSelectForChoice(dom, container, kb, subject, predicate, possible, u
|
|
|
1985
1965
|
firstSelectOptionText = '* Select for ' + utils.label(subject, true) + ' *';
|
|
1986
1966
|
}
|
|
1987
1967
|
|
|
1988
|
-
|
|
1968
|
+
return firstSelectOptionText;
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
function createDefaultSelectOption() {
|
|
1972
|
+
var option = dom.createElement('option');
|
|
1973
|
+
option.appendChild(dom.createTextNode(createDefaultSelectOptionText()));
|
|
1989
1974
|
option.disabled = true;
|
|
1990
1975
|
option.value = true;
|
|
1991
1976
|
option.hidden = true;
|
|
@@ -1994,17 +1979,16 @@ function makeSelectForChoice(dom, container, kb, subject, predicate, possible, u
|
|
|
1994
1979
|
}
|
|
1995
1980
|
|
|
1996
1981
|
var onChange = function onChange(_e) {
|
|
1982
|
+
container.removeChild(container.lastChild);
|
|
1997
1983
|
select.refresh();
|
|
1998
1984
|
};
|
|
1999
1985
|
|
|
2000
1986
|
var select = dom.createElement('select');
|
|
2001
1987
|
select.setAttribute('style', style.formSelectSTyle);
|
|
2002
|
-
|
|
1988
|
+
select.setAttribute('id', 'formSelect');
|
|
2003
1989
|
select.currentURI = null;
|
|
2004
|
-
var object = kb.any(subject, predicate);
|
|
2005
|
-
if (object) select.currentURI = object;
|
|
2006
1990
|
|
|
2007
|
-
for (var uri in
|
|
1991
|
+
for (var uri in optionsFromClassUIfrom) {
|
|
2008
1992
|
select.appendChild(createOption(uri));
|
|
2009
1993
|
}
|
|
2010
1994
|
|
|
@@ -2016,11 +2000,10 @@ function makeSelectForChoice(dom, container, kb, subject, predicate, possible, u
|
|
|
2016
2000
|
select.insertBefore(mint, select.firstChild);
|
|
2017
2001
|
}
|
|
2018
2002
|
|
|
2019
|
-
if (select.children.length === 0) select.insertBefore(
|
|
2020
|
-
|
|
2021
|
-
select.refresh = function () {
|
|
2022
|
-
select.disabled = true; // unlocked any conflict we had got into
|
|
2003
|
+
if (select.children.length === 0) select.insertBefore(createDefaultSelectOption(), select.firstChild);
|
|
2023
2004
|
|
|
2005
|
+
select.update = function (newSelectedOptions) {
|
|
2006
|
+
selectedOptions = newSelectedOptions;
|
|
2024
2007
|
var ds = [];
|
|
2025
2008
|
var is = [];
|
|
2026
2009
|
|
|
@@ -2030,6 +2013,62 @@ function makeSelectForChoice(dom, container, kb, subject, predicate, possible, u
|
|
|
2030
2013
|
}
|
|
2031
2014
|
};
|
|
2032
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 = [];
|
|
2033
2072
|
var newObject;
|
|
2034
2073
|
|
|
2035
2074
|
for (var _i3 = 0; _i3 < select.options.length; _i3++) {
|
|
@@ -2038,7 +2077,7 @@ function makeSelectForChoice(dom, container, kb, subject, predicate, possible, u
|
|
|
2038
2077
|
if (opt.selected && opt.AJAR_mint) {
|
|
2039
2078
|
// not sure if this 'if' is used because I cannot find mintClass
|
|
2040
2079
|
if (options.mintClass) {
|
|
2041
|
-
var thisForm = promptForNew(dom, kb, subject, predicate, options.
|
|
2080
|
+
var thisForm = promptForNew(dom, kb, subject, predicate, uiFrom, options.subForm, dataDoc, function (ok, body) {
|
|
2042
2081
|
if (!ok) {
|
|
2043
2082
|
callbackFunction(ok, body, {
|
|
2044
2083
|
change: 'new'
|
|
@@ -2063,36 +2102,26 @@ function makeSelectForChoice(dom, container, kb, subject, predicate, possible, u
|
|
|
2063
2102
|
|
|
2064
2103
|
if (!opt.AJAR_uri) continue; // a prompt or mint
|
|
2065
2104
|
|
|
2066
|
-
if (opt.selected
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
var sel = select.subSelect; // All subclasses must also go
|
|
2070
|
-
|
|
2071
|
-
while (sel && sel.currentURI) {
|
|
2072
|
-
removeValue(kb.sym(sel.currentURI));
|
|
2073
|
-
sel = sel.subSelect;
|
|
2074
|
-
}
|
|
2075
|
-
|
|
2076
|
-
sel = select.superSelect; // All superclasses are redundant
|
|
2105
|
+
if (opt.selected && containsObject(opt.AJAR_uri, selectedOptions)) {
|
|
2106
|
+
select.currentURI = opt.AJAR_uri;
|
|
2107
|
+
}
|
|
2077
2108
|
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
sel = sel.superSelect;
|
|
2109
|
+
if (!containsObject(opt.AJAR_uri, selectedOptions)) opt.removeAttribute('selected');
|
|
2110
|
+
if (containsObject(opt.AJAR_uri, selectedOptions)) opt.setAttribute('selected', 'true');
|
|
2081
2111
|
}
|
|
2082
2112
|
|
|
2083
2113
|
log.info('selectForOptions: data doc = ' + dataDoc);
|
|
2084
2114
|
|
|
2085
|
-
if (select.currentURI) {
|
|
2086
|
-
removeNextSiblingsAfterElement(select);
|
|
2115
|
+
if (select.currentURI && options.subForm && !options.multiSelect) {
|
|
2087
2116
|
addSubFormChoice(dom, container, {}, $rdf.sym(select.currentURI), options.subForm, dataDoc, function (ok, body) {
|
|
2088
2117
|
if (ok) {
|
|
2089
|
-
kb.updater.update(
|
|
2118
|
+
kb.updater.update([], is, function (uri, success, errorBody) {
|
|
2090
2119
|
if (!success) container.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating select: ' + errorBody));
|
|
2091
2120
|
});
|
|
2092
2121
|
if (callbackFunction) callbackFunction(ok, {
|
|
2093
2122
|
widget: 'select',
|
|
2094
2123
|
event: 'new'
|
|
2095
|
-
});
|
|
2124
|
+
});
|
|
2096
2125
|
} else {
|
|
2097
2126
|
container.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in field of select: ' + body));
|
|
2098
2127
|
}
|
|
@@ -2105,13 +2134,17 @@ function makeSelectForChoice(dom, container, kb, subject, predicate, possible, u
|
|
|
2105
2134
|
function createOption(uri) {
|
|
2106
2135
|
var option = dom.createElement('option');
|
|
2107
2136
|
var c = kb.sym(uri);
|
|
2137
|
+
var label;
|
|
2108
2138
|
|
|
2109
2139
|
if (options.disambiguate) {
|
|
2110
|
-
|
|
2140
|
+
label = utils.labelWithOntology(c, true); // Init. cap
|
|
2111
2141
|
} else {
|
|
2112
|
-
|
|
2142
|
+
label = utils.label(c, true);
|
|
2113
2143
|
}
|
|
2114
2144
|
|
|
2145
|
+
option.appendChild(dom.createTextNode(label)); // Init.
|
|
2146
|
+
|
|
2147
|
+
option.setAttribute('value', uri);
|
|
2115
2148
|
var backgroundColor = kb.any(c, kb.sym('http://www.w3.org/ns/ui#backgroundColor'));
|
|
2116
2149
|
|
|
2117
2150
|
if (backgroundColor) {
|
|
@@ -2119,7 +2152,11 @@ function makeSelectForChoice(dom, container, kb, subject, predicate, possible, u
|
|
|
2119
2152
|
}
|
|
2120
2153
|
|
|
2121
2154
|
option.AJAR_uri = uri;
|
|
2122
|
-
|
|
2155
|
+
|
|
2156
|
+
if (containsObject(c.value, selectedOptions)) {
|
|
2157
|
+
option.setAttribute('selected', 'true');
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2123
2160
|
return option;
|
|
2124
2161
|
}
|
|
2125
2162
|
|
|
@@ -2127,7 +2164,19 @@ function makeSelectForChoice(dom, container, kb, subject, predicate, possible, u
|
|
|
2127
2164
|
select.addEventListener('change', onChange, false);
|
|
2128
2165
|
}
|
|
2129
2166
|
|
|
2130
|
-
select.refresh();
|
|
2131
2167
|
return select;
|
|
2132
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
|
+
}
|
|
2133
2182
|
//# sourceMappingURL=forms.js.map
|