solid-ui 2.4.22-b483f37e → 2.4.22-b7eabfdf

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 CHANGED
@@ -7,13 +7,26 @@ User Interface widgets and utilities for Solid (solid-ui)
7
7
  These are HTML5 widgets which connect to a solid store. Building blocks for solid-based apps.
8
8
  Vanilla JS. Includes large widgets like chat, table, matrix, form fields, and small widgets.
9
9
 
10
+ See [Solid-Ui Storybook](http://solidos.github.io/solid-ui/examples/storybook/) for SolidUI widgets.
11
+ See [Solid-UI API](https://solidos.github.io/solid-ui/Documentation/api/) for SolidUI functions.
12
+ See [Forms introduction](./Documentation/FormsReadme.md) for UI vocabulary implementation.
13
+
14
+ Table of content:
15
+ - Getting started(#getting-started)
16
+ - Further documentation(#further-ocumentation)
17
+
18
+
10
19
  ## Getting started
20
+
21
+ Contributions of bug fixes and new functionality, documentation, and tests are
22
+ always appreciated.
23
+
11
24
  ### In npm-based projects
12
25
  When including solid-ui in an npm-based project, you can use it with:
13
26
 
14
27
  ```js
15
- import { ns, rdf, acl, aclControl, authn, create, dom, icons, log, matrix, media,
16
- messageArea, infiniteMessageArea, pad, preferences, store, style, table, tabs, utils, widgets, versionInfo
28
+ import { ns, rdf, acl, aclControl, create, dom, icons, log, matrix, media,
29
+ messageArea, infiniteMessageArea, pad, preferences, style, table, tabs, utils, widgets, versionInfo
17
30
  } from 'solid-ui'
18
31
 
19
32
  ```
@@ -23,10 +36,8 @@ Clone this repo, and in the repo root run:
23
36
  * `npm install`
24
37
  * `npm run build`
25
38
 
26
- This will generate a `lib/` folder containing, among other artifacts, `lib/webpack-bundle.js`.
27
- Now run `npx serve` and go to http://localhost:5000/examples/ with your browser to see some examples.
28
- See the ['examples' folder](https://github.com/solidos/solid-ui/tree/examples/examples) for the
29
- source code of those examples.
39
+ This will generate a `dist/` folder containing, among other artifacts, `dist/main.js`.
40
+ Now run `npx serve` and go to http://localhost:3000/Documentation/ with your browser to see some examples.
30
41
 
31
42
  While viewing one of those examples, you can open the web console in your browser and for instance
32
43
  try how you can create a button:
@@ -44,56 +55,7 @@ const chat = UI.infiniteMessageArea(document, store, UI.rdf.namedNode(chatChanne
44
55
  document.body.appendChild(chat)
45
56
  ```
46
57
 
47
- Or a full ACL Control Box:
48
- ```js
49
- const exampleFolder = 'https://example-user.inrupt.net/public/public-control/'
50
- const aclControlBox = UI.aclControl.ACLControlBox5(UI.rdf.namedNode(exampleFolder), { dom: document }, '', store)
51
- document.body.appendChild(aclControlBox)
52
- ```
53
-
54
-
55
- ## Documentation
56
- - [talk presentation](https://solidos.github.io/solid-ui/Documentation/talks/FormsTalk.html)
57
- - API https://solidos.github.io/solid-ui/Documentation/api/ for the API documentation.
58
- - The UI components are presented in a [storybook](http://solidos.github.io/solid-ui/examples/storybook/).
59
-
60
- ## Overview
61
- This has been a place to put any functionality from solid views which has been generalized to be usable in other views.
62
-
63
- - Authentication UI: manage the user's logged in/out state.
64
- - Discovery: finding the user's stuff, and leaving records of new things
65
- - Preferences: UI for managing a user's preferences with two axes of defaults
66
- - An Access Control List widget for Solid ACL system
67
- - Acess Control Logic
68
- - Create a new object from modules/extensions which have registered their ability to create things
69
-
70
- - A [form system](https://solidos.github.io/solid-ui/Documentation/forms-intro.html): Forms are defined in RDF, and create/edit RDF data, including form definitions
71
- - A collection of shortcut namespace objects for a selection of relevant RDF vocabularies.
72
- - Small atomic widgets (buttons etc) of which the others are constructed.
73
- - An error message panel
74
-
75
- Some of the larger controls include:
76
-
77
- - A chat widget: add discussion to any object. Infinite scroll, embedded images, social reactions, etc etc
78
- - A people picker widget for choosing a set of people or an existing group
79
- - A general purpose table display with built-in faceted browsing
80
- - A two-dimentional matrix of editable live data that extends in both dimensions.
81
- - A notepad of shared notes for real-time collaboration
82
- - Drag and drop code for linking things and uploading files
83
- - A set of tabs for holding other widgets and arbitrary UI elements
84
-
85
- The typical style of the widgets is to know what data it has been derived from,
86
- allow users to edit it, and to automatically sync with data as it changes in the future.
87
- To see how these are used, see the panes which use them within the data browser.
88
-
89
- The level of support for this varies.
90
-
91
- See also: [A short introduction to the Form system](https://solidos.github.io/solid-ui/Documentation/forms-intro.html)
92
-
93
- Contributions of bug fixes and new functionality, documentation, and tests are
94
- always appreciated.
95
-
96
- ## Development
58
+ ### Development new components
97
59
 
98
60
  When developing a component in solid-ui you can test it in isolation using storybook
99
61
 
@@ -104,5 +66,8 @@ npm run storybook
104
66
 
105
67
  If there is no story for the component yet, add a new one to `./src/stories`.
106
68
 
107
- When you want to test the component within a solid-pane, you can use the [development mode of solid-panes](https://github.com/solidos/solid-panes#development) or
108
- [mashlib-dev](https://github.com/solidos/mashlib-dev).
69
+ When you want to test the component within a solid-pane, you can use the [development mode of solid-panes](https://github.com/solidos/solid-panes#development).
70
+
71
+ ## Further documentation
72
+
73
+ - [Some code know-how](https://github.com/SolidOS/solidos/wiki/2.-Solid-UI-know-how)
package/dist/main.js CHANGED
@@ -15192,11 +15192,11 @@ Object.defineProperty(exports, "__esModule", ({
15192
15192
  }));
15193
15193
  exports.versionInfo = void 0;
15194
15194
  var versionInfo = {
15195
- buildTime: '2022-05-05T15:06:47Z',
15196
- commit: 'b483f37ed01c63f3a8c78fe6c10958236e1deade',
15195
+ buildTime: '2022-05-13T07:25:27Z',
15196
+ commit: 'b7eabfdfd23aee3e6270a39c191ab5ed2c7c5d73',
15197
15197
  npmInfo: {
15198
15198
  'solid-ui': '2.4.22',
15199
- npm: '6.14.16',
15199
+ npm: '6.14.17',
15200
15200
  ares: '1.18.1',
15201
15201
  brotli: '1.0.9',
15202
15202
  cldr: '40.0',
@@ -15205,12 +15205,12 @@ var versionInfo = {
15205
15205
  modules: '83',
15206
15206
  napi: '8',
15207
15207
  nghttp2: '1.42.0',
15208
- node: '14.19.1',
15208
+ node: '14.19.2',
15209
15209
  openssl: '1.1.1n',
15210
15210
  tz: '2021a3',
15211
15211
  unicode: '14.0',
15212
15212
  uv: '1.42.0',
15213
- v8: '8.4.371.23-node.85',
15213
+ v8: '8.4.371.23-node.87',
15214
15214
  zlib: '1.2.11'
15215
15215
  }
15216
15216
  };
@@ -16280,6 +16280,7 @@ function openHrefInOutlineMode(e) {
16280
16280
 
16281
16281
  if (dom.outlineManager) {
16282
16282
  // @@ TODO Remove the use of document as a global object
16283
+ // TODO fix dependency cycle to solid-panes by calling outlineManager
16283
16284
  ;
16284
16285
  dom.outlineManager.GotoSubject(_solidLogic.store.sym(uri), true, undefined, true, undefined);
16285
16286
  } else if (window && window.panes && window.panes.getOutliner) {
@@ -16407,6 +16408,7 @@ function linkButton(dom, object) {
16407
16408
  b.textContent = 'Goto ' + utils.label(object);
16408
16409
  b.addEventListener('click', function (_event) {
16409
16410
  // b.parentNode.removeChild(b)
16411
+ // TODO fix dependency cycle to solid-panes by calling outlineManager
16410
16412
  ;
16411
16413
  dom.outlineManager.GotoSubject(object, true, undefined, true, undefined);
16412
16414
  }, true);
@@ -17262,10 +17264,11 @@ _fieldFunction.field[ns.ui('Form').uri] = _fieldFunction.field[ns.ui('Group').ur
17262
17264
 
17263
17265
  if (already[key]) {
17264
17266
  // been there done that
17265
- box.appendChild(dom.createTextNode('Group: see above ' + key));
17266
- var plist = [$rdf.st(subject, ns.owl('sameAs'), subject)]; // @@ need prev subject
17267
+ box.appendChild(dom.createTextNode('Group: see above ' + key)); // TODO fix dependency cycle to solid-panes by calling outlineManager
17268
+ // const plist = [$rdf.st(subject, ns.owl('sameAs'), subject)] // @@ need prev subject
17269
+ // dom.outlineManager.appendPropertyTRs(box, plist)
17270
+ // dom.appendChild(plist)
17267
17271
 
17268
- dom.outlineManager.appendPropertyTRs(box, plist);
17269
17272
  return box;
17270
17273
  }
17271
17274
 
@@ -17694,7 +17697,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
17694
17697
  // delete button and move buttons
17695
17698
 
17696
17699
  if (kb.updater.editable(dataDoc.uri)) {
17697
- buttons.deleteButtonWithCheck(dom, subField, utils.label(property), deleteThisItem);
17700
+ buttons.deleteButtonWithCheck(dom, subField, multipleUIlabel, deleteThisItem);
17698
17701
 
17699
17702
  if (ordered) {
17700
17703
  // Add controsl in a frame
@@ -17745,7 +17748,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
17745
17748
 
17746
17749
  var _shim = dom.createElement('div');
17747
17750
 
17748
- _shim.appendChild(subField); // Subfield has its own laytout
17751
+ _shim.appendChild(subField); // Subfield has its own layout
17749
17752
 
17750
17753
 
17751
17754
  frame.appendChild(_shim);
@@ -17794,6 +17797,8 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
17794
17797
  return shim;
17795
17798
  }
17796
17799
 
17800
+ var multipleUIlabel = kb.any(form, ui('label'));
17801
+ if (!multipleUIlabel) multipleUIlabel = utils.label(property);
17797
17802
  var min = kb.any(form, ui('min')); // This is the minimum number -- default 0
17798
17803
 
17799
17804
  min = min ? 0 + min.value : 0;
@@ -17834,10 +17839,9 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
17834
17839
  img.setAttribute('src', plusIconURI); // plus sign
17835
17840
 
17836
17841
  img.setAttribute('style', 'margin: 0.2em; width: 1.5em; height:1.5em');
17837
- img.title = 'Click to add one or more ' + utils.predicateLabel(property, reverse);
17838
- var prompt = tail.appendChild(dom.createElement('span'));
17839
- prompt.textContent = (values.length === 0 ? 'Add one or more ' : 'Add more ') + utils.predicateLabel(property, reverse); // utils.label(property)
17840
-
17842
+ img.title = 'Click to add another ' + multipleUIlabel;
17843
+ var prompt = dom.createElement('span');
17844
+ prompt.textContent = (values.length === 0 ? 'Add another ' : 'Add ') + multipleUIlabel;
17841
17845
  tail.addEventListener('click', /*#__PURE__*/function () {
17842
17846
  var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(_eventNotUsed) {
17843
17847
  return _regenerator["default"].wrap(function _callee5$(_context5) {
@@ -17859,6 +17863,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
17859
17863
  return _ref3.apply(this, arguments);
17860
17864
  };
17861
17865
  }(), true);
17866
+ tail.appendChild(prompt);
17862
17867
  }
17863
17868
 
17864
17869
  function createListIfNecessary() {
@@ -18120,28 +18125,41 @@ _fieldFunction.field[ns.ui('Classifier').uri] = function (dom, container, alread
18120
18125
  **
18121
18126
  ** Not nested. Generates a link to something from a given class.
18122
18127
  ** Optional subform for the thing selected.
18128
+ ** Generates a subForm based on a ui:use form
18129
+ ** Will look like:
18130
+ ** <div id=dropDownDiv>
18131
+ ** <div id=labelOfDropDown>
18132
+ ** <div id=selectDiv>
18133
+ ** <select id=dropDownSelect>
18134
+ ** <option> ....
18135
+ ** <subForm>
18123
18136
  ** Alternative implementatons caould be:
18124
18137
  ** -- pop-up menu (as here)
18125
18138
  ** -- radio buttons
18126
18139
  ** -- auto-complete typing
18127
18140
  **
18128
- ** Todo: Deal with multiple. Maybe merge with multiple code.
18141
+ ** TODO: according to ontology ui:choice can also have ns.ui('default') - this is not implemented yet
18129
18142
  */
18130
18143
 
18131
18144
 
18132
18145
  _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) {
18133
18146
  var ui = ns.ui;
18134
18147
  var kb = _solidLogic.store;
18135
- var multiple = false;
18136
18148
  var formDoc = form.doc ? form.doc() : null; // @@ if blank no way to know
18137
18149
 
18150
+ var uiMultipleInUse = false; // this signals to ui:choice that it is part of a ui:multiple
18151
+
18152
+ var multiSelect = false;
18138
18153
  var p;
18139
- var box = dom.createElement('div'); // Set flexDirection column?
18154
+ var box = dom.createElement('div');
18155
+ box.setAttribute('class', 'choiceBox'); // Set flexDirection column?
18140
18156
 
18141
18157
  if (container) container.appendChild(box);
18142
18158
  var lhs = dom.createElement('div');
18159
+ lhs.setAttribute('class', 'formFieldName choiceBox-label');
18143
18160
  box.appendChild(lhs);
18144
18161
  var rhs = dom.createElement('div');
18162
+ rhs.setAttribute('class', 'formFieldValue choiceBox-selectBox');
18145
18163
  box.appendChild(rhs);
18146
18164
  var property = kb.any(form, ui('property'));
18147
18165
 
@@ -18150,9 +18168,9 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
18150
18168
  }
18151
18169
 
18152
18170
  lhs.appendChild((0, _basic.fieldLabel)(dom, property, form));
18153
- var from = kb.any(form, ui('from'));
18171
+ var uiFrom = kb.any(form, ui('from'));
18154
18172
 
18155
- if (!from) {
18173
+ if (!uiFrom) {
18156
18174
  return (0, _error.errorMessageBlock)(dom, "No 'from' for Choice: " + form);
18157
18175
  }
18158
18176
 
@@ -18162,26 +18180,39 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
18162
18180
 
18163
18181
  var possible = [];
18164
18182
  var possibleProperties;
18165
- var nullLabel = '--' + utils.label(property) + '-?';
18183
+ var firstSelectOptionText = '* Select for ' + utils.label(subject, true) + ' *'; // if we do NOT have a container it means it is a ui:Multiple
18184
+ // only important for the first option text in select
18185
+
18186
+ if (!container) {
18187
+ uiMultipleInUse = true;
18188
+ firstSelectOptionText = utils.label(subject, true);
18189
+ }
18190
+
18191
+ if (subject.termType === 'BlankNode') {
18192
+ firstSelectOptionText = '* Select for ' + utils.label(property) + ' *';
18193
+ }
18194
+
18166
18195
  var opts = {
18167
18196
  form: form,
18168
- multiple: multiple,
18169
- nullLabel: nullLabel,
18197
+ subForm: subForm,
18198
+ multiSelect: multiSelect,
18199
+ firstSelectOptionText: firstSelectOptionText,
18200
+ uiMultipleInUse: uiMultipleInUse,
18170
18201
  disambiguate: false
18171
18202
  };
18172
- possible = kb.each(undefined, ns.rdf('type'), from, formDoc);
18203
+ possible = kb.each(undefined, ns.rdf('type'), uiFrom, formDoc);
18173
18204
 
18174
- for (var x in kb.findMembersNT(from)) {
18205
+ for (var x in kb.findMembersNT(uiFrom)) {
18175
18206
  possible.push(kb.fromNT(x));
18176
18207
  } // Use rdfs
18177
18208
 
18178
18209
 
18179
- if (from.sameTerm(ns.rdfs('Class'))) {
18210
+ if (uiFrom.sameTerm(ns.rdfs('Class'))) {
18180
18211
  for (p in buttons.allClassURIs()) {
18181
18212
  possible.push(kb.sym(p));
18182
18213
  } // log.debug("%%% Choice field: possible.length 2 = "+possible.length)
18183
18214
 
18184
- } else if (from.sameTerm(ns.rdf('Property'))) {
18215
+ } else if (uiFrom.sameTerm(ns.rdf('Property'))) {
18185
18216
  possibleProperties = buttons.propertyTriage(kb);
18186
18217
 
18187
18218
  for (p in possibleProperties.op) {
@@ -18193,7 +18224,7 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
18193
18224
  }
18194
18225
 
18195
18226
  opts.disambiguate = true; // This is a big class, and the labels won't be enough.
18196
- } else if (from.sameTerm(ns.owl('ObjectProperty'))) {
18227
+ } else if (uiFrom.sameTerm(ns.owl('ObjectProperty'))) {
18197
18228
  possibleProperties = buttons.propertyTriage(kb);
18198
18229
 
18199
18230
  for (p in possibleProperties.op) {
@@ -18201,7 +18232,7 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
18201
18232
  }
18202
18233
 
18203
18234
  opts.disambiguate = true;
18204
- } else if (from.sameTerm(ns.owl('DatatypeProperty'))) {
18235
+ } else if (uiFrom.sameTerm(ns.owl('DatatypeProperty'))) {
18205
18236
  possibleProperties = buttons.propertyTriage(kb);
18206
18237
 
18207
18238
  for (p in possibleProperties.dp) {
@@ -18211,26 +18242,45 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
18211
18242
  opts.disambiguate = true;
18212
18243
  }
18213
18244
 
18214
- var object = kb.any(subject, property);
18245
+ var sortedPossible = sortByLabel(possible); // TODO: this checks for any occurrence, regardless of true or false setting
18215
18246
 
18216
- function addSubForm() {
18217
- object = kb.any(subject, property);
18218
- (0, _fieldFunction.fieldFunction)(dom, subForm)(dom, rhs, already, object, subForm, follow ? object.doc() : dataDoc, callbackFunction);
18247
+ if (kb.any(form, ui('canMintNew'))) {
18248
+ opts.mint = '* Create new *'; // @@ could be better
18219
18249
  }
18220
18250
 
18221
- var possible2 = sortByLabel(possible);
18251
+ var selector = makeSelectForOptions(dom, kb, subject, property, sortedPossible, uiFrom, opts, dataDoc, callbackFunction);
18252
+ rhs.appendChild(selector);
18253
+ var object;
18222
18254
 
18223
- if (kb.any(form, ui('canMintNew'))) {
18224
- opts.mint = '* New *'; // @@ could be better
18255
+ if (selector.currentURI) {
18256
+ object = $rdf.sym(selector.currentURI);
18257
+ } else {
18258
+ object = kb.any(subject, property);
18259
+ }
18225
18260
 
18226
- opts.subForm = subForm;
18261
+ if (object && subForm) {
18262
+ removeNextSiblingsAfterElement(selector);
18263
+ addSubFormChoice(dom, rhs, already, object, subForm, follow ? object.doc() : dataDoc, callbackFunction);
18227
18264
  }
18228
18265
 
18229
- var selector = makeSelectForOptions(dom, kb, subject, property, possible2, opts, dataDoc, callbackFunction);
18230
- rhs.appendChild(selector);
18231
- if (object && subForm) addSubForm();
18232
18266
  return box;
18233
- }; // Documentation - non-interactive fields
18267
+ };
18268
+ /**
18269
+ * Removes all sibling elements after specified
18270
+ * @param {HTMLElement} currentElement
18271
+ * @private
18272
+ */
18273
+
18274
+
18275
+ function removeNextSiblingsAfterElement(currentElement) {
18276
+ while (currentElement.nextElementSibling) {
18277
+ currentElement.nextElementSibling.remove();
18278
+ }
18279
+ }
18280
+
18281
+ function addSubFormChoice(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction) {
18282
+ (0, _fieldFunction.fieldFunction)(dom, subForm)(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction);
18283
+ } // Documentation - non-interactive fields
18234
18284
  //
18235
18285
 
18236
18286
 
@@ -18433,7 +18483,8 @@ function promptForNew(dom, kb, subject, predicate, theClass, form, dataDoc, call
18433
18483
  b.setAttribute('type', 'button');
18434
18484
  b.setAttribute('style', 'float: right;');
18435
18485
  b.innerHTML = 'Goto ' + utils.label(theClass);
18436
- b.addEventListener('click', function (_e) {
18486
+ b.addEventListener('click', // TODO fix dependency cycle to solid-panes by calling outlineManager
18487
+ function (_e) {
18437
18488
  dom.outlineManager.GotoSubject(theClass, true, undefined, true, undefined);
18438
18489
  }, false);
18439
18490
  return box;
@@ -18568,9 +18619,10 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
18568
18619
  // @param subject - a term, the subject of the statement(s) being edited.
18569
18620
  // @param predicate - a term, the predicate of the statement(s) being edited
18570
18621
  // @param possible - a list of terms, the possible value the object can take
18571
- // @param options.multiple - Boolean - Whether more than one at a time is allowed
18572
- // @param options.nullLabel - a string to be displayed as the
18573
- // option for none selected (for non multiple)
18622
+ // @param options.multiSelect - Boolean - Whether more than one at a time is allowed
18623
+ // @param options.firstSelectOptionText - a string to be displayed as the
18624
+ // option for none selected (for non multiSelect)
18625
+ // @param options.uiMultipleInUse - signals that the ui:choise is used with a ui:multiple
18574
18626
  // @param options.mint - User may create thing if this sent to the prompt string eg "New foo"
18575
18627
  // @param options.subForm - If mint, then the form to be used for minting the new thing
18576
18628
  // @param dataDoc - The web document being edited
@@ -18578,7 +18630,7 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
18578
18630
  */
18579
18631
 
18580
18632
 
18581
- function makeSelectForOptions(dom, kb, subject, predicate, possible, options, dataDoc, callbackFunction) {
18633
+ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, options, dataDoc, callbackFunction) {
18582
18634
  log.debug('Select list length now ' + possible.length);
18583
18635
  var n = 0;
18584
18636
  var uris = {}; // Count them
@@ -18609,7 +18661,9 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18609
18661
  actual = kb.findTypeURIs(subject);
18610
18662
  } else {
18611
18663
  kb.each(subject, predicate, null, dataDoc).forEach(function (x) {
18612
- actual[x.uri] = true;
18664
+ if (x.uri) {
18665
+ actual[x.uri] = true;
18666
+ }
18613
18667
  });
18614
18668
  }
18615
18669
 
@@ -18619,8 +18673,6 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18619
18673
  actual = getActual();
18620
18674
 
18621
18675
  var onChange = function onChange(_e) {
18622
- select.disabled = true; // until data written back - gives user feedback too
18623
-
18624
18676
  var ds = [];
18625
18677
  var is = [];
18626
18678
 
@@ -18636,6 +18688,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18636
18688
  var opt = select.options[_i];
18637
18689
 
18638
18690
  if (opt.selected && opt.AJAR_mint) {
18691
+ // not sure if this 'if' is used because I cannot find mintClass
18639
18692
  if (options.mintClass) {
18640
18693
  var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
18641
18694
  if (!ok) {
@@ -18650,11 +18703,14 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18650
18703
  newObject = newThing(dataDoc);
18651
18704
  }
18652
18705
 
18653
- is.push($rdf.st(subject, predicate, newObject, dataDoc));
18706
+ is.push($rdf.st(subject, predicate, kb.sym(newObject), dataDoc));
18707
+ 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
18654
18708
 
18655
18709
  if (options.mintStatementsFun) {
18656
18710
  is = is.concat(options.mintStatementsFun(newObject));
18657
18711
  }
18712
+
18713
+ select.currentURI = newObject;
18658
18714
  }
18659
18715
 
18660
18716
  if (!opt.AJAR_uri) continue; // a prompt or mint
@@ -18662,11 +18718,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18662
18718
  if (opt.selected && !(opt.AJAR_uri in actual)) {
18663
18719
  // new class
18664
18720
  is.push($rdf.st(subject, predicate, kb.sym(opt.AJAR_uri), dataDoc));
18665
- }
18666
-
18667
- if (!opt.selected && opt.AJAR_uri in actual) {
18668
- // old class
18669
- removeValue(kb.sym(opt.AJAR_uri));
18721
+ select.currentURI = opt.AJAR_uri;
18670
18722
  }
18671
18723
 
18672
18724
  if (opt.selected) select.currentURI = opt.AJAR_uri;
@@ -18686,38 +18738,29 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18686
18738
  sel = sel.superSelect;
18687
18739
  }
18688
18740
 
18689
- function doneNew(ok, _body) {
18690
- callbackFunction(ok, {
18691
- widget: 'select',
18692
- event: 'new'
18693
- });
18694
- }
18695
-
18696
- log.info('selectForOptions: data doc = ' + dataDoc);
18697
- kb.updater.update(ds, is, function (uri, ok, body) {
18698
- actual = getActual(); // refresh
18741
+ log.info('selectForOptions: data doc = ' + dataDoc); // refresh subForm
18699
18742
 
18743
+ removeNextSiblingsAfterElement(select);
18744
+ addSubFormChoice(dom, select.parentNode, {}, $rdf.sym(select.currentURI), options.subForm, dataDoc, function (ok, body) {
18700
18745
  if (ok) {
18701
- select.disabled = false; // data written back
18746
+ kb.updater.update(ds, is, function (uri, success, errorBody) {
18747
+ actual = getActual(); // refresh
18702
18748
 
18703
- if (newObject) {
18704
- var fn = (0, _fieldFunction.fieldFunction)(dom, options.subForm);
18705
- fn(dom, select.parentNode, {}, newObject, options.subForm, dataDoc, doneNew);
18706
- }
18749
+ if (!success) select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating select: ' + errorBody));
18750
+ });
18751
+ if (callbackFunction) callbackFunction(ok, {
18752
+ widget: 'select',
18753
+ event: 'new'
18754
+ });
18707
18755
  } else {
18708
- return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in select: ' + body));
18756
+ select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in field of select: ' + body));
18709
18757
  }
18710
-
18711
- if (callbackFunction) callbackFunction(ok, {
18712
- widget: 'select',
18713
- event: 'change'
18714
- });
18715
18758
  });
18716
18759
  };
18717
18760
 
18718
18761
  var select = dom.createElement('select');
18719
18762
  select.setAttribute('style', style.formSelectSTyle);
18720
- if (options.multiple) select.setAttribute('multiple', 'true');
18763
+ if (options.multiSelect) select.setAttribute('multiSelect', 'true');
18721
18764
  select.currentURI = null;
18722
18765
 
18723
18766
  select.refresh = function () {
@@ -18768,11 +18811,14 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18768
18811
  select.insertBefore(mint, select.firstChild);
18769
18812
  }
18770
18813
 
18771
- if (select.currentURI == null && !options.multiple) {
18814
+ if (!select.currentURI && options.uiMultipleInUse) {
18772
18815
  var prompt = dom.createElement('option');
18773
- prompt.appendChild(dom.createTextNode(options.nullLabel));
18774
- select.insertBefore(prompt, select.firstChild);
18816
+ prompt.appendChild(dom.createTextNode(options.firstSelectOptionText));
18817
+ prompt.disabled = true;
18818
+ prompt.value = true;
18819
+ prompt.hidden = true;
18775
18820
  prompt.selected = true;
18821
+ select.insertBefore(prompt, select.firstChild);
18776
18822
  }
18777
18823
 
18778
18824
  if (editable) {
@@ -18791,11 +18837,11 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18791
18837
  function makeSelectForCategory(dom, kb, subject, category, dataDoc, callbackFunction) {
18792
18838
  var du = kb.any(category, ns.owl('disjointUnionOf'));
18793
18839
  var subs;
18794
- var multiple = false;
18840
+ var multiSelect = false;
18795
18841
 
18796
18842
  if (!du) {
18797
18843
  subs = kb.each(undefined, ns.rdfs('subClassOf'), category);
18798
- multiple = true;
18844
+ multiSelect = true;
18799
18845
  } else {
18800
18846
  subs = du.elements;
18801
18847
  }
@@ -18803,16 +18849,15 @@ function makeSelectForCategory(dom, kb, subject, category, dataDoc, callbackFunc
18803
18849
  log.debug('Select list length ' + subs.length);
18804
18850
 
18805
18851
  if (subs.length === 0) {
18806
- return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with no subclasses of category: ' + category);
18852
+ return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiSelect ? 'multiple ' : '') + 'selector with no subclasses of category: ' + category);
18807
18853
  }
18808
18854
 
18809
18855
  if (subs.length === 1) {
18810
- return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with only 1 subclass of category: ' + category + ':' + subs[1]);
18856
+ return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiSelect ? 'multiple ' : '') + 'selector with only 1 subclass of category: ' + category + ':' + subs[1]);
18811
18857
  }
18812
18858
 
18813
- return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, {
18814
- multiple: multiple,
18815
- nullPrompt: '--classify--'
18859
+ return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, null, {
18860
+ multiSelect: multiSelect
18816
18861
  }, dataDoc, callbackFunction);
18817
18862
  }
18818
18863
  /** Make SELECT element to select subclasses recurively