solid-ui 2.4.22-dc624c1d → 2.4.22-e7c66f56

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.
@@ -159,10 +159,11 @@ _fieldFunction.field[ns.ui('Form').uri] = _fieldFunction.field[ns.ui('Group').ur
159
159
 
160
160
  if (already[key]) {
161
161
  // been there done that
162
- box.appendChild(dom.createTextNode('Group: see above ' + key));
163
- var plist = [$rdf.st(subject, ns.owl('sameAs'), subject)]; // @@ need prev subject
162
+ box.appendChild(dom.createTextNode('Group: see above ' + key)); // TODO fix dependency cycle to solid-panes by calling outlineManager
163
+ // const plist = [$rdf.st(subject, ns.owl('sameAs'), subject)] // @@ need prev subject
164
+ // dom.outlineManager.appendPropertyTRs(box, plist)
165
+ // dom.appendChild(plist)
164
166
 
165
- dom.outlineManager.appendPropertyTRs(box, plist);
166
167
  return box;
167
168
  }
168
169
 
@@ -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, utils.label(property), deleteThisItem);
595
+ buttons.deleteButtonWithCheck(dom, subField, multipleUIlabel, deleteThisItem);
595
596
 
596
597
  if (ordered) {
597
598
  // Add controsl in a frame
@@ -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 laytout
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,10 +734,9 @@ _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 one or more ' + utils.predicateLabel(property, reverse);
735
- var prompt = tail.appendChild(dom.createElement('span'));
736
- prompt.textContent = (values.length === 0 ? 'Add one or more ' : 'Add more ') + utils.predicateLabel(property, reverse); // utils.label(property)
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
741
  var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(_eventNotUsed) {
740
742
  return _regenerator["default"].wrap(function _callee5$(_context5) {
@@ -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() {
@@ -1030,23 +1033,28 @@ _fieldFunction.field[ns.ui('Classifier').uri] = function (dom, container, alread
1030
1033
  ** -- radio buttons
1031
1034
  ** -- auto-complete typing
1032
1035
  **
1033
- ** Todo: Deal with multiple. Maybe merge with multiple code.
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
 
1045
+ var uiMultipleInUse = false; // this signals to ui:choice that it is part of a ui:multiple
1046
+
1047
+ var multiSelect = false;
1043
1048
  var p;
1044
- var box = dom.createElement('div'); // Set flexDirection column?
1049
+ var box = dom.createElement('div');
1050
+ box.setAttribute('class', 'choiceBox'); // Set flexDirection column?
1045
1051
 
1046
1052
  if (container) container.appendChild(box);
1047
1053
  var lhs = dom.createElement('div');
1054
+ lhs.setAttribute('class', 'formFieldName choiceBox-label');
1048
1055
  box.appendChild(lhs);
1049
1056
  var rhs = dom.createElement('div');
1057
+ rhs.setAttribute('class', 'formFieldValue choiceBox-selectBox');
1050
1058
  box.appendChild(rhs);
1051
1059
  var property = kb.any(form, ui('property'));
1052
1060
 
@@ -1055,26 +1063,38 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
1055
1063
  }
1056
1064
 
1057
1065
  lhs.appendChild((0, _basic.fieldLabel)(dom, property, form));
1066
+ var uiFrom = kb.any(form, ui('from'));
1067
+
1068
+ if (!uiFrom) {
1069
+ return (0, _error.errorMessageBlock)(dom, "No 'from' for Choice: " + form);
1070
+ }
1071
+
1058
1072
  var subForm = kb.any(form, ui('use')); // Optional
1059
1073
 
1060
1074
  var follow = kb.anyJS(form, ui('follow'), null, formDoc); // data doc moves to new subject?
1061
1075
 
1062
1076
  var possible = [];
1063
1077
  var possibleProperties;
1064
- var firstSelectOptionText = '* Select from ' + utils.label(subject, true) + ' *';
1078
+ var firstSelectOptionText = '* Select for ' + utils.label(subject, true) + ' *'; // if we do NOT have a container it means it is a ui:Multiple
1079
+ // only important for the first option text in select
1080
+
1081
+ if (!container) {
1082
+ uiMultipleInUse = true;
1083
+ firstSelectOptionText = utils.label(subject, true);
1084
+ }
1085
+
1086
+ if (subject.termType === 'BlankNode') {
1087
+ firstSelectOptionText = '* Select for ' + utils.label(property) + ' *';
1088
+ }
1089
+
1065
1090
  var opts = {
1066
1091
  form: form,
1067
1092
  subForm: subForm,
1068
- multiple: multiple,
1093
+ multiSelect: multiSelect,
1069
1094
  firstSelectOptionText: firstSelectOptionText,
1095
+ uiMultipleInUse: uiMultipleInUse,
1070
1096
  disambiguate: false
1071
1097
  };
1072
- var uiFrom = kb.any(form, ui('from'));
1073
-
1074
- if (!uiFrom) {
1075
- return (0, _error.errorMessageBlock)(dom, "No 'from' for Choice: " + form);
1076
- }
1077
-
1078
1098
  possible = kb.each(undefined, ns.rdf('type'), uiFrom, formDoc);
1079
1099
 
1080
1100
  for (var x in kb.findMembersNT(uiFrom)) {
@@ -1117,7 +1137,7 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
1117
1137
  opts.disambiguate = true;
1118
1138
  }
1119
1139
 
1120
- var sortedPossible = sortByLabel(possible); // TODO: this checks for any occurance regardles if it is set to true or false
1140
+ var sortedPossible = sortByLabel(possible); // TODO: this checks for any occurrence, regardless of true or false setting
1121
1141
 
1122
1142
  if (kb.any(form, ui('canMintNew'))) {
1123
1143
  opts.mint = '* Create new *'; // @@ could be better
@@ -1358,7 +1378,8 @@ function promptForNew(dom, kb, subject, predicate, theClass, form, dataDoc, call
1358
1378
  b.setAttribute('type', 'button');
1359
1379
  b.setAttribute('style', 'float: right;');
1360
1380
  b.innerHTML = 'Goto ' + utils.label(theClass);
1361
- b.addEventListener('click', function (_e) {
1381
+ b.addEventListener('click', // TODO fix dependency cycle to solid-panes by calling outlineManager
1382
+ function (_e) {
1362
1383
  dom.outlineManager.GotoSubject(theClass, true, undefined, true, undefined);
1363
1384
  }, false);
1364
1385
  return box;
@@ -1493,9 +1514,10 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
1493
1514
  // @param subject - a term, the subject of the statement(s) being edited.
1494
1515
  // @param predicate - a term, the predicate of the statement(s) being edited
1495
1516
  // @param possible - a list of terms, the possible value the object can take
1496
- // @param options.multiple - Boolean - Whether more than one at a time is allowed
1517
+ // @param options.multiSelect - Boolean - Whether more than one at a time is allowed
1497
1518
  // @param options.firstSelectOptionText - a string to be displayed as the
1498
- // option for none selected (for non multiple)
1519
+ // option for none selected (for non multiSelect)
1520
+ // @param options.uiMultipleInUse - signals that the ui:choise is used with a ui:multiple
1499
1521
  // @param options.mint - User may create thing if this sent to the prompt string eg "New foo"
1500
1522
  // @param options.subForm - If mint, then the form to be used for minting the new thing
1501
1523
  // @param dataDoc - The web document being edited
@@ -1561,7 +1583,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
1561
1583
  var opt = select.options[_i];
1562
1584
 
1563
1585
  if (opt.selected && opt.AJAR_mint) {
1564
- // not sure if this if is used because I cannot find mintClass
1586
+ // not sure if this 'if' is used because I cannot find mintClass
1565
1587
  if (options.mintClass) {
1566
1588
  var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
1567
1589
  if (!ok) {
@@ -1577,7 +1599,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
1577
1599
  }
1578
1600
 
1579
1601
  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
1602
+ 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
1603
 
1582
1604
  if (options.mintStatementsFun) {
1583
1605
  is = is.concat(options.mintStatementsFun(newObject));
@@ -1620,7 +1642,11 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
1620
1642
  actual = getActual(); // refresh
1621
1643
 
1622
1644
  if (!success) select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating select: ' + errorBody));
1623
- }); // if (callbackFunction) callbackFunction(ok, { widget: 'select', event: 'new' })
1645
+ });
1646
+ if (callbackFunction) callbackFunction(ok, {
1647
+ widget: 'select',
1648
+ event: 'new'
1649
+ });
1624
1650
  } else {
1625
1651
  select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in field of select: ' + body));
1626
1652
  }
@@ -1629,7 +1655,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
1629
1655
 
1630
1656
  var select = dom.createElement('select');
1631
1657
  select.setAttribute('style', style.formSelectSTyle);
1632
- if (options.multiple) select.setAttribute('multiple', 'true');
1658
+ if (options.multiSelect) select.setAttribute('multiSelect', 'true');
1633
1659
  select.currentURI = null;
1634
1660
 
1635
1661
  select.refresh = function () {
@@ -1680,13 +1706,13 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
1680
1706
  select.insertBefore(mint, select.firstChild);
1681
1707
  }
1682
1708
 
1683
- if (!select.currentURI && !options.multiple) {
1709
+ if (!select.currentURI && options.uiMultipleInUse) {
1684
1710
  var prompt = dom.createElement('option');
1685
1711
  prompt.appendChild(dom.createTextNode(options.firstSelectOptionText));
1686
- prompt.selected = true;
1687
1712
  prompt.disabled = true;
1688
1713
  prompt.value = true;
1689
1714
  prompt.hidden = true;
1715
+ prompt.selected = true;
1690
1716
  select.insertBefore(prompt, select.firstChild);
1691
1717
  }
1692
1718
 
@@ -1706,11 +1732,11 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
1706
1732
  function makeSelectForCategory(dom, kb, subject, category, dataDoc, callbackFunction) {
1707
1733
  var du = kb.any(category, ns.owl('disjointUnionOf'));
1708
1734
  var subs;
1709
- var multiple = false;
1735
+ var multiSelect = false;
1710
1736
 
1711
1737
  if (!du) {
1712
1738
  subs = kb.each(undefined, ns.rdfs('subClassOf'), category);
1713
- multiple = true;
1739
+ multiSelect = true;
1714
1740
  } else {
1715
1741
  subs = du.elements;
1716
1742
  }
@@ -1718,15 +1744,15 @@ function makeSelectForCategory(dom, kb, subject, category, dataDoc, callbackFunc
1718
1744
  log.debug('Select list length ' + subs.length);
1719
1745
 
1720
1746
  if (subs.length === 0) {
1721
- return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with no subclasses of category: ' + category);
1747
+ return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiSelect ? 'multiple ' : '') + 'selector with no subclasses of category: ' + category);
1722
1748
  }
1723
1749
 
1724
1750
  if (subs.length === 1) {
1725
- return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with only 1 subclass of category: ' + category + ':' + subs[1]);
1751
+ return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiSelect ? 'multiple ' : '') + 'selector with only 1 subclass of category: ' + category + ':' + subs[1]);
1726
1752
  }
1727
1753
 
1728
1754
  return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, null, {
1729
- multiple: multiple
1755
+ multiSelect: multiSelect
1730
1756
  }, dataDoc, callbackFunction);
1731
1757
  }
1732
1758
  /** Make SELECT element to select subclasses recurively