@entryscape/rdforms 10.6.2 → 10.7.2

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.
Files changed (44) hide show
  1. package/dist/rdforms.bmd.js +7 -5
  2. package/dist/rdforms.bootstrap.js +17 -15
  3. package/dist/rdforms.jquery.js +6 -4
  4. package/dist/rdforms.node.js +273 -3
  5. package/dist/rdforms.react.js +79 -77
  6. package/package.json +4 -3
  7. package/src/template/Item.js +2 -1
  8. package/src/view/Presenter.js +32 -3
  9. package/src/view/Registry.js +1 -1
  10. package/src/view/ValidationPresenter.js +2 -2
  11. package/src/view/View.js +52 -10
  12. package/src/view/bmd/DateTimeMD.js +12 -14
  13. package/src/view/bmd/Selectize.js +5 -4
  14. package/src/view/bmd/style.css +9 -1
  15. package/src/view/bootstrap/DateTimeBootstrapDatepicker.js +6 -4
  16. package/src/view/bootstrap/RadioButtonsEditor.js +5 -2
  17. package/src/view/bootstrap/Select2.js +8 -5
  18. package/src/view/bootstrap/buttons.js +9 -5
  19. package/src/view/bootstrap/choice.js +6 -4
  20. package/src/view/bootstrap/durationEditor.js +3 -2
  21. package/src/view/bootstrap/labels.js +26 -15
  22. package/src/view/bootstrap/style.css +9 -3
  23. package/src/view/bootstrap/text.js +7 -4
  24. package/src/view/jquery/labels.js +18 -1
  25. package/src/view/jquery/text.js +3 -3
  26. package/src/view/react/buttons.js +3 -0
  27. package/src/view/react/choiceEditors/CheckBoxesEditor.js +8 -3
  28. package/src/view/react/choiceEditors/ChoiceLookup.js +4 -2
  29. package/src/view/react/choiceEditors/ChoiceLookupAndInlineSearch.js +24 -15
  30. package/src/view/react/choiceEditors/ChoiceSelector.js +7 -4
  31. package/src/view/react/choiceEditors/RadioButtonsEditor.js +8 -4
  32. package/src/view/react/choiceEditors/ShowButton.js +1 -0
  33. package/src/view/react/date.js +46 -15
  34. package/src/view/react/duration.js +4 -2
  35. package/src/view/react/hooks.js +3 -0
  36. package/src/view/react/labels.js +41 -5
  37. package/src/view/react/style.css +9 -5
  38. package/src/view/react/text.js +2 -2
  39. package/src/view/react/textEditors.js +5 -0
  40. package/src/view/renderingContext.js +5 -0
  41. package/src/view/resources/nls.json +1 -0
  42. package/src/view/resources/rdforms.css +39 -17
  43. package/src/view/{jquery/util.js → viewUtils.js} +11 -0
  44. package/src/view/react/util.js +0 -31
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "application profile",
9
9
  "linked data"
10
10
  ],
11
- "version": "10.6.2",
11
+ "version": "10.7.2",
12
12
  "main": "dist/rdforms.node.js",
13
13
  "browser": "dist/rdforms.react.js",
14
14
  "module": "main.js",
@@ -19,17 +19,19 @@
19
19
  "@emotion/react": "^11.4.1",
20
20
  "@emotion/styled": "^11.3.0",
21
21
  "@entryscape/rdfjson": "^2.5.4",
22
+ "@fortawesome/fontawesome-free": "^5.8.1",
22
23
  "@mui/icons-material": "^5.0.3",
23
24
  "@mui/lab": "^5.0.0-alpha.51",
24
25
  "@mui/material": "^5.0.3",
25
26
  "@mui/styles": "^5.0.1",
27
+ "@selectize/selectize": "^0.13.5",
26
28
  "arrive": "^2.4.1",
27
29
  "bootstrap": "^4.3.1",
28
30
  "bootstrap-datepicker": "^1.9.0",
29
31
  "bootstrap-material-datetimepicker": "https://bitbucket.org/metasolutions/bootstrap-material-datetimepicker.git#webpack",
30
32
  "bootstrap-material-design": "^4.1.1",
31
- "core-js": "^3.1.4",
32
33
  "circular-dependency-plugin": "^5.2.2",
34
+ "core-js": "^3.1.4",
33
35
  "ifdef-loader": "^2.1.1",
34
36
  "jquery": "^3.3.1",
35
37
  "jquery-mousewheel": "^3.1.13",
@@ -43,7 +45,6 @@
43
45
  "react-hooks-lib": "^0.1.5",
44
46
  "regenerator-runtime": "^0.13.2",
45
47
  "select2": "4.0.7",
46
- "selectize": "^0.12.6",
47
48
  "selectize-bootstrap4-theme": "^2.0.2",
48
49
  "sizzle": "^2.3.3",
49
50
  "terser-webpack-plugin": "^1.3.0",
@@ -54,7 +54,6 @@ export default class Item {
54
54
  'atLeastOneChild',
55
55
  'atMostOneChild',
56
56
  'exactlyOneChild',
57
- 'deprecated',
58
57
  'noLabelInPresent',
59
58
  'autoInitDate',
60
59
  'autoUpdateDate',
@@ -63,6 +62,8 @@ export default class Item {
63
62
  'showURI',
64
63
  'showLink',
65
64
  'showValue',
65
+ 'showDescriptionInPresent',
66
+ 'showDescriptionInEdit',
66
67
  'textAsChoice',
67
68
  'preserveOrderOfChoices',
68
69
  'linkWithLabel',
@@ -1,7 +1,35 @@
1
- import moment, {locale} from 'moment';
1
+ /* eslint-disable class-methods-use-this */
2
+ import moment from 'moment';
2
3
  import renderingContext from './renderingContext';
3
4
  import View from './View';
4
5
 
6
+
7
+ const showNow = (editor, item, bindings) => {
8
+ if (bindings.length === 0 ||
9
+ // item.hasStyle('deprecated') ||
10
+ item.hasStyle('invisible')) {
11
+ return false;
12
+ }
13
+ const prop = item.getProperty();
14
+ if (prop) {
15
+ return !editor.filterItem(item);
16
+ }
17
+
18
+ // Take care of layout grouping by checking recursively.
19
+ if (item.getType() === 'group') {
20
+ const groupedItemsArr = item.getChildren();
21
+ if (groupedItemsArr.length === 0) {
22
+ return true; // Corresponds to an extention or pure heading, since no children.
23
+ }
24
+ if (bindings[0].getItemGroupedChildBindings().find((childBindings, idx) =>
25
+ showNow(editor, groupedItemsArr[idx], childBindings))) {
26
+ return true;
27
+ }
28
+ return false;
29
+ }
30
+ return true;
31
+ };
32
+
5
33
  export default class Presenter extends View {
6
34
  _handleParams(params) {
7
35
  this.showLanguage = params.showLanguage !== false;
@@ -17,10 +45,11 @@ export default class Presenter extends View {
17
45
  * @param {Object} bindings
18
46
  */
19
47
  showNow(item, bindings) {
20
- if (item.hasStyle('deprecated') && bindings.length === 0) {
48
+ return showNow(this, item, bindings);
49
+ /* if (item.hasStyle('deprecated') && bindings.length === 0) {
21
50
  return false;
22
51
  }
23
- return bindings.length > 0 && !item.hasStyle('invisible');
52
+ return bindings.length > 0 && !item.hasStyle('invisible');*/
24
53
  }
25
54
 
26
55
  skipBinding(binding) {
@@ -272,4 +272,4 @@ export default class Registry {
272
272
  check(func) {
273
273
  return (new Filter(this)).check(func);
274
274
  }
275
- };
275
+ }
@@ -1,7 +1,7 @@
1
1
  import renderingContext from './renderingContext';
2
2
  import Presenter from './Presenter';
3
3
  import CODES from '../model/CODES';
4
- import engine from '../model/engine';
4
+ import { create } from '../model/engine';
5
5
  import { bindingReport } from '../model/validate';
6
6
 
7
7
  const localize = (bundle, key, val) => {
@@ -102,7 +102,7 @@ export default class ValidationPresenter extends Presenter {
102
102
  if (target > _bindings.length && groupChildRequirementHinder && !groupError) {
103
103
  _bindings = _bindings.concat([]);
104
104
  while (target > _bindings.length) {
105
- const binding = engine.create(this.binding, item);
105
+ const binding = create(this.binding, item);
106
106
  if (_bindings.length < min) {
107
107
  binding.setMatchingCode(CODES.TOO_FEW_VALUES_MIN);
108
108
  // binding.error = CODES.TOO_FEW_VALUES;
package/src/view/View.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /* eslint-disable class-methods-use-this,no-unused-vars */
2
+ import { namespaces } from '@entryscape/rdfjson';
2
3
  import renderingContext from './renderingContext';
3
4
  import GroupBinding from '../model/GroupBinding';
4
5
  import * as engine from '../model/engine';
5
6
  import { bindingReport } from '../model/validate';
6
- import {namespaces} from "@entryscape/rdfjson";
7
7
 
8
8
  let viewCounter = 0;
9
9
  export default class View {
@@ -18,10 +18,14 @@ export default class View {
18
18
  this.resource = params.resource || '';
19
19
  this.topLevel = params.topLevel !== false;
20
20
  this.compact = params.compact !== false;
21
+ this.showDescription = params.showDescription === true;
21
22
  this.styleCls = params.styleCls || '';
22
- this.filterPredicates = params.filterPredicates || null;
23
+ this.filterPredicates = Array.isArray(params.filterPredicates) ?
24
+ params.filterPredicates.reduce((prev, current) => { prev[current] = true; return prev; }, {}) :
25
+ params.filterPredicates || null;
23
26
  this.restrictToItem = params.restrictToItem;
24
27
  this.fuzzy = params.fuzzy === true;
28
+ this.markOrigin = params.markOrigin !== false;
25
29
  this._handleParams(params);
26
30
  this._labelIndex = {};
27
31
  this.domNode = renderingContext.createDomNode(srcNodeRef, this);
@@ -30,6 +34,32 @@ export default class View {
30
34
  this.render();
31
35
  }
32
36
 
37
+ getParentView() {
38
+ return this.parentView;
39
+ }
40
+
41
+ getNamedGraphId(namedGraph) {
42
+ if (!this.markOrigin) {
43
+ return undefined;
44
+ }
45
+ if (!this.namedGraphs) {
46
+ this.namedGraphs = {};
47
+ this.namedGraphCounter = 65; // 'A'
48
+ }
49
+
50
+ let id = this.namedGraphs[namedGraph];
51
+ if (id === undefined) {
52
+ id = String.fromCharCode(this.namedGraphCounter);
53
+ this.namedGraphs[namedGraph] = id;
54
+ this.namedGraphCounter += 1;
55
+ }
56
+ return id;
57
+ }
58
+
59
+ getNamedGraphFromId(id) {
60
+ return this.namedGraphs ? Object.keys(this.namedGraphs).find(key => this.namedGraphs[key] === id) : undefined;
61
+ }
62
+
33
63
  destroy() {
34
64
  renderingContext.destroyDomNode(this.domNode, this);
35
65
  }
@@ -192,6 +222,7 @@ export default class View {
192
222
  }
193
223
  }
194
224
  } else {
225
+ this.context = { view: this };
195
226
  lastRow = this.createRowNode(lastRow, null, item);
196
227
  }
197
228
 
@@ -244,6 +275,17 @@ export default class View {
244
275
  this.createEndOfRowNode(newRow, binding, item);
245
276
  }
246
277
  }
278
+ if (this.markOrigin) {
279
+ const ngId = this.getNamedGraphId(binding);
280
+ if (ngId) {
281
+ renderingContext.domClassToggle(fieldDiv, 'rdformsOrigin', true);
282
+ renderingContext.domClassToggle(fieldDiv, `rdformsOrigin_${ngId}`, true);
283
+ } else {
284
+ renderingContext.domClassToggle(fieldDiv, 'rdformsOrigin', true);
285
+ renderingContext.domClassToggle(fieldDiv, 'rdformsOrigin_default', true);
286
+ }
287
+ }
288
+
247
289
  if (item.getType() === 'group') {
248
290
  renderingContext.domClassToggle(fieldDiv, 'rdformsGroup', true);
249
291
  } else {
@@ -275,7 +317,8 @@ export default class View {
275
317
  renderingContext.domClassToggle(rowNode, 'rdformsTopLevel', this.topLevel);
276
318
  renderingContext.domClassToggle(rowNode, 'rdformsInvisibleGroup', item.hasStyle('invisibleGroup'));
277
319
  renderingContext.domClassToggle(rowNode, 'rdformsHeading', item.hasStyle('heading'));
278
- renderingContext.domClassToggle(rowNode, 'notCompact', item.getType() === 'group');
320
+ renderingContext.domClassToggle(rowNode, 'notCompact', item.getType() === 'group' || item.hasStyle('nonCompact'));
321
+ renderingContext.domClassToggle(rowNode, 'rdformsCompactItem', item.hasStyle('compact'));
279
322
 
280
323
  this.addLabel(rowNode, binding, item);
281
324
  if (binding && this.filterBinding(binding)) {
@@ -301,16 +344,15 @@ export default class View {
301
344
  const filter = (item, fp) => {
302
345
  // Exclude based on item id.
303
346
  const id = item.getId();
304
- if (id && fp && Object.keys(fp).includes(id)) {
347
+ if (id && Object.keys(fp).includes(id)) {
305
348
  return true;
306
349
  }
307
- // Exclude if property matches.
308
350
  const prop = item.getProperty();
309
- if (fp && prop) {
351
+ // Exclude if property matches.
352
+ if (prop) {
310
353
  return fp[prop] === true || fp[namespaces.shortenKnown(prop)] === true;
311
- }
312
- if (fp && item.getType() === 'group' && !item.getProperty()) {
313
- // Checks one level below if there is a child that is visible
354
+ } else if (item.getType() === 'group') {
355
+ // Exclude group headers if all children hidden
314
356
  const childBindings = item.getChildren() || [];
315
357
  let hasNonFilteredChild = false;
316
358
  childBindings.forEach((child) => {
@@ -322,7 +364,7 @@ export default class View {
322
364
  }
323
365
  return false;
324
366
  };
325
- return filter(itemToCheck, filterPredicates);
367
+ return filterPredicates ? filter(itemToCheck, filterPredicates) : false;
326
368
  }
327
369
 
328
370
  filterProperty(property) {
@@ -1,12 +1,14 @@
1
1
  import moment from 'moment';
2
2
  import jquery from 'jquery';
3
3
  import DateTimeBase from '../bootstrap/DateTimeBase';
4
+ import { getNamedGraphId } from '../viewUtils';
4
5
 
5
6
  /**
6
7
  * A Date and time picker.
7
8
  */
8
9
  export default class DateTimeMD extends DateTimeBase {
9
10
  buildUI() {
11
+ const disabledAttr = getNamedGraphId(this.binding, this.context) ? 'disabled' : '';
10
12
  this.tpdate = null;
11
13
  this.dpdate = null;
12
14
  const bundle = this.context.view.messages;
@@ -16,23 +18,23 @@ export default class DateTimeMD extends DateTimeBase {
16
18
 
17
19
  this.domNode.innerHTML = `<div class="rdformsDateValue rdformsFieldInput" xmlns="http://www.w3.org/1999/html">
18
20
  <div class="rdformsDatepicker form-group input" style="padding-right: 15px;">
19
- <input class="form-control dateInput date" type="text" placeholder="YYYY-MM-DD" />
21
+ <input ${disabledAttr} class="form-control dateInput date" type="text" placeholder="YYYY-MM-DD" />
20
22
  <span >
21
- <button type="button" class="btn btn-primary bmd-btn-fab bmd-btn-fab-sm dateButton"><span class="fa fa-calendar"></span>
23
+ <button ${disabledAttr} type="button" class="btn btn-primary bmd-btn-fab bmd-btn-fab-sm dateButton"><span class="fa fa-calendar"></span>
22
24
  <div class="ripple-container"></div></button>
23
25
  </span>
24
26
  </div>
25
27
  <div class="form-group input" style="display:none;">
26
- <input type="text" class="form-control timeInput" placeholder="HH:MM"/>
28
+ <input ${disabledAttr} type="text" class="form-control timeInput" placeholder="HH:MM"/>
27
29
  <span>
28
- <button type="button" class="btn btn-primary bmd-btn-fab bmd-btn-fab-sm timeButton"><span class="fa fa-clock"></span></button>
30
+ <button ${disabledAttr} type="button" class="btn btn-primary bmd-btn-fab bmd-btn-fab-sm timeButton"><span class="fa fa-clock"></span></button>
29
31
  </span>
30
32
  </div>
31
33
  <div class="form-group input" style="display:none;">
32
- <input type="text" class="form-control yearInput" placeholder="YYYY"/>
34
+ <input ${disabledAttr} type="text" class="form-control yearInput" placeholder="YYYY"/>
33
35
  </div>
34
36
 
35
- <select class="form-control dateControl">
37
+ <select ${disabledAttr} class="form-control dateControl">
36
38
  ${yearOption}
37
39
  ${dateOption}
38
40
  ${dateTimeOption}
@@ -68,10 +70,8 @@ export default class DateTimeMD extends DateTimeBase {
68
70
  jquery(this.dateButton).click(() => {
69
71
  this.$datepicker.bootstrapMaterialDatePicker('_fireCalendar');
70
72
  });
71
- this.$datepicker.on('change', (evt, m) => {
72
- if (!m) {
73
- m = moment(evt.target.value);
74
- }
73
+ this.$datepicker.on('change', (evt, mInstance) => {
74
+ const m = mInstance || moment(evt.target.value);
75
75
 
76
76
  if (this.tpdate) {
77
77
  const tpd = moment(this.tpdate);
@@ -90,10 +90,8 @@ export default class DateTimeMD extends DateTimeBase {
90
90
  this.$timepicker.bootstrapMaterialDatePicker('_fireCalendar');
91
91
  });
92
92
 
93
- this.$timepicker.on('change', (evt, m) => {
94
- if (!m) {
95
- m = moment(evt.target.value);
96
- }
93
+ this.$timepicker.on('change', (evt, mInstance) => {
94
+ const m = mInstance || moment(evt.target.value);
97
95
 
98
96
  if (this.dpdate != null) {
99
97
  const dpd = moment(this.dpdate);
@@ -1,7 +1,8 @@
1
- import 'selectize';
1
+ import '@selectize/selectize/dist/js/standalone/selectize.min';
2
+ //import '@selectize/selectize/dist/css/selectize.bootstrap4.css';
2
3
  import renderingContext from '../renderingContext';
3
- import system from '../../model/system';
4
4
  import utils from '../../utils';
5
+ import { getNamedGraphId } from '../viewUtils';
5
6
 
6
7
  renderingContext.renderSelect = function (fieldDiv, binding, context) {
7
8
  const formgroup = jquery('<div class="form-group selectizeException">').appendTo(fieldDiv);
@@ -48,7 +49,7 @@ renderingContext.renderSelect = function (fieldDiv, binding, context) {
48
49
  }
49
50
  sel = $select.selectize(settings)[0].selectize;
50
51
 
51
- if (disable) {
52
+ if (disable || getNamedGraphId(binding, context)) {
52
53
  sel.disable();
53
54
  }
54
55
 
@@ -60,7 +61,7 @@ renderingContext.renderSelect = function (fieldDiv, binding, context) {
60
61
  const label = utils.getLocalizedValue(choice.label).value || '';
61
62
  const op = sel.options[choice.value];
62
63
  if (!op) {
63
- sel.addOption({id: choice.value, text: label, choice});
64
+ sel.addOption({ id: choice.value, text: label, choice });
64
65
  }
65
66
  sel.addItem(choice.value, true);
66
67
  // $select.val(choice.value).trigger('change');
@@ -137,5 +137,13 @@
137
137
  }
138
138
 
139
139
  .rdforms.rdformsEditor .rdformsLangFieldControl>.action {
140
- margin-top: 0px;
140
+ margin-top: 10px;
141
+ }
142
+
143
+ .rdformsActionButton:focus {
144
+ color: #009688;
145
+ }
146
+
147
+ .rdforms .rdformsLabelRow>.rdformsActionButton.action {
148
+ margin-top: -5px;
141
149
  }
@@ -1,12 +1,14 @@
1
1
  import 'bootstrap-datepicker/dist/js/bootstrap-datepicker';
2
2
  import jquery from 'jquery';
3
3
  import DateTimeBase from './DateTimeBase';
4
+ import { getNamedGraphId } from '../viewUtils';
4
5
 
5
6
  /**
6
7
  * A Date and time picker.
7
8
  */
8
9
  export default class DateTimeBootstrapDatepicker extends DateTimeBase {
9
10
  buildUI() {
11
+ const disabledAttr = getNamedGraphId(this.binding, this.context) ? 'disabled' : '';
10
12
  const bundle = this.context.view.messages;
11
13
  const yearOption = this.includeYearOption() ? `<option value="Year">${bundle.date_year}</option>` : '';
12
14
  const dateOption = this.includeDateOption() ? `<option value="Date" selected="true">${bundle.date_date}</option>` : '';
@@ -14,7 +16,7 @@ export default class DateTimeBootstrapDatepicker extends DateTimeBase {
14
16
  this.domNode.innerHTML = `<div class="rdformsDateValue rdformsFieldInput" xmlns="http://www.w3.org/1999/html">
15
17
  <div class="rdformsDatepicker datepicker">
16
18
  <div class="input-group date">
17
- <input type="text" class="form-control">
19
+ <input ${disabledAttr} type="text" class="form-control">
18
20
  <div class="input-group-append">
19
21
  <span class="input-group-text">
20
22
  <i class="fas fa-calendar"></i>
@@ -23,12 +25,12 @@ export default class DateTimeBootstrapDatepicker extends DateTimeBase {
23
25
  </div>
24
26
  </div>
25
27
  <span style="display: none">
26
- <input type="text" class="form-control timeInput" placeholder="HH:MM"/>
28
+ <input ${disabledAttr} type="text" class="form-control timeInput" placeholder="HH:MM"/>
27
29
  </span>
28
30
  <span style="display: none">
29
- <input type="text" class="form-control yearInput" placeholder="YYYY"/>
31
+ <input ${disabledAttr} type="text" class="form-control yearInput" placeholder="YYYY"/>
30
32
  </span>
31
- <select class="form-control dateControl">
33
+ <select ${disabledAttr} class="form-control dateControl">
32
34
  ${yearOption}
33
35
  ${dateOption}
34
36
  ${dateTimeOption}
@@ -1,3 +1,5 @@
1
+ import { getNamedGraphId } from '../viewUtils';
2
+
1
3
  let uniqueRadioButtonGroupNr = 0;
2
4
 
3
5
  export default class RadioButtonsEditor {
@@ -49,7 +51,8 @@ export default class RadioButtonsEditor {
49
51
  || c.seeAlso || c.value);
50
52
  }
51
53
 
52
- const $input = jquery('<input type="radio">')
54
+ const disabledAttr = getNamedGraphId(this.binding, this.context) ? 'disabled' : '';
55
+ const $input = jquery(`<input ${disabledAttr} type="radio">`)
53
56
  .val(c.value)
54
57
  .attr('checked', c.value === currentValue)
55
58
  .attr('name', `rdformsRadio_${uniqueRadioButtonGroupNr}`)
@@ -60,7 +63,7 @@ export default class RadioButtonsEditor {
60
63
  $label.addClass('mismatch disabled');
61
64
  $input.attr('disabled', true);
62
65
  } else {
63
- $label.click((inp) => {
66
+ $label.click(() => {
64
67
  this.binding.setValue($input.val());
65
68
  });
66
69
  }
@@ -1,13 +1,16 @@
1
+ import ArrayAdapter from 'select2/src/js/select2/data/array';
2
+ import 'select2';
1
3
  import renderingContext from '../renderingContext';
2
4
  import utils from '../../utils';
3
- import ArrayAdapter from 'select2/src/js/select2/data/array';
4
5
  import Select2QueryAdapter from './Select2QueryAdapter';
5
- import 'select2';
6
- //import 'select2/src/js/jquery.select2';
6
+ import { getNamedGraphId } from '../viewUtils';
7
+ // import 'select2/src/js/jquery.select2';
8
+
7
9
 
8
10
  renderingContext.renderSelect = (fieldDiv, binding, context) => {
9
11
  const choices = context.choices;
10
- const $select = jquery('<select>').appendTo(fieldDiv).append('<option></option>');
12
+ const disabledAttr = getNamedGraphId(binding, context) ? 'disabled' : '';
13
+ const $select = jquery(`<select ${disabledAttr}>`).appendTo(fieldDiv).append('<option></option>');
11
14
 
12
15
  const options = {
13
16
  placeholder: binding.getItem().getPlaceholder() || '',
@@ -34,7 +37,7 @@ renderingContext.renderSelect = (fieldDiv, binding, context) => {
34
37
  $select.trigger({
35
38
  type: 'select2:select',
36
39
  params: {
37
- data: {id: choice.val, text: label, choice},
40
+ data: { id: choice.val, text: label, choice },
38
41
  },
39
42
  });
40
43
  } else {
@@ -1,8 +1,11 @@
1
1
  import renderingContext from '../renderingContext';
2
2
  import * as engine from '../../model/engine';
3
+ import { getNamedGraphId } from '../viewUtils';
4
+
3
5
 
4
6
  renderingContext.addRemoveButton = (fieldDiv, binding, context) => {
5
- const $remove = jquery('<span class="fas fa-times action">')
7
+ const disabledAttr = getNamedGraphId(binding, context) ? 'disabled' : '';
8
+ const $remove = jquery(`<button ${disabledAttr} class="fas fa-times action rdformsActionButton">`)
6
9
  .attr('title', context.view.messages.edit_remove)
7
10
  .appendTo(context.controlDiv);
8
11
  const cardTr = binding.getCardinalityTracker();
@@ -39,7 +42,7 @@ renderingContext.addRemoveButton = (fieldDiv, binding, context) => {
39
42
  };
40
43
 
41
44
  renderingContext.addExpandButton = (rowDiv, labelDiv, item, context) => {
42
- const $expand = jquery('<span class="fas fa-plus action">')
45
+ const $expand = jquery('<button class="fas fa-plus action rdformsActionButton">')
43
46
  .attr('title', context.view.messages.edit_expand)
44
47
  .appendTo(labelDiv)
45
48
  .click(() => {
@@ -62,7 +65,7 @@ renderingContext.addGroupButtons = (rowDiv, labelDiv, binding, context) => {
62
65
  const card = item.getCardinality();
63
66
  let $add;
64
67
  if (card.max !== 1) {
65
- $add = jquery('<span class="action fas fa-plus ">')
68
+ $add = jquery('<button class="action fas fa-plus rdformsActionButton">')
66
69
  .attr('title', context.view.messages.edit_add)
67
70
  .appendTo(labelDiv);
68
71
  $add.click(() => {
@@ -72,7 +75,8 @@ renderingContext.addGroupButtons = (rowDiv, labelDiv, binding, context) => {
72
75
  }
73
76
  });
74
77
  }
75
- const $remove = jquery('<span class="action fas fa-times">')
78
+ const disabledAttr = getNamedGraphId(binding, context) ? 'disabled' : '';
79
+ const $remove = jquery(`<button ${disabledAttr} class="action fas fa-times rdformsActionButton">`)
76
80
  .attr('title', context.view.messages.edit_remove)
77
81
  .appendTo(labelDiv);
78
82
 
@@ -127,7 +131,7 @@ renderingContext.addCreateChildButton = (rowDiv, labelDiv, binding, context) =>
127
131
  const parentBinding = binding.getParent();
128
132
  const item = binding.getItem();
129
133
  const cardTr = binding.getCardinalityTracker();
130
- const $add = jquery('<span class="action fas fa-plus">')
134
+ const $add = jquery('<button class="action fas fa-plus rdformsActionButton">')
131
135
  .attr('title', context.view.messages.edit_add)
132
136
  .appendTo(labelDiv)
133
137
  .click(() => {
@@ -1,6 +1,7 @@
1
1
  import renderingContext from '../renderingContext';
2
2
  import system from '../../model/system';
3
- import {default as RadioButtonsEditor} from './RadioButtonsEditor';
3
+ import RadioButtonsEditor from './RadioButtonsEditor';
4
+ import { getNamedGraphId } from '../viewUtils';
4
5
 
5
6
  const editors = renderingContext.editorRegistry;
6
7
 
@@ -14,7 +15,7 @@ const radioCheck = (item) => {
14
15
  };
15
16
  editors.itemtype('choice').choices().check(radioCheck).register((fieldDiv, binding, context) => {
16
17
  // eslint-disable-next-line no-new
17
- new RadioButtonsEditor({binding, context}, fieldDiv);
18
+ new RadioButtonsEditor({ binding, context }, fieldDiv);
18
19
  });
19
20
 
20
21
  editors.itemtype('choice').choices().register((fieldDiv, binding, context) => {
@@ -52,13 +53,14 @@ editors.itemtype('choice').choices('none').register((fieldDiv, binding, context)
52
53
  context.chooser = renderingContext.chooserRegistry.getComponent(binding.getItem());
53
54
  context.choices = undefined; // Reset choices so no bleeding over when reusing context between fields.
54
55
 
56
+ const disabledAttr = getNamedGraphId(binding, context) ? 'disabled' : '';
55
57
  const renderSelect = () => {
56
58
  renderingContext.renderSelect(fieldDiv, binding, context);
57
59
  // remember the function since the context object is reused and may
58
60
  // reference to the wrong setValue function later on.
59
61
  const setValue = context.setValue;
60
62
 
61
- const $search = jquery('<button class="btn btn-primary bmd-btn-fab bmd-btn-fab-sm browseChoices" type="button">')
63
+ const $search = jquery(`<button ${disabledAttr} class="btn btn-primary bmd-btn-fab bmd-btn-fab-sm browseChoices" type="button">`)
62
64
  .attr('title', context.view.messages.edit_browse)
63
65
  .appendTo(fieldDiv);
64
66
  if (context.chooser && context.chooser.supportsInlineCreate &&
@@ -109,7 +111,7 @@ editors.itemtype('choice').choices('none').register((fieldDiv, binding, context)
109
111
  c.load(() => {
110
112
  // If the value can be upgraded into its own entity.
111
113
  if (c.upgrade) {
112
- const $button = jquery('<button class="btn btn-default bmd-btn-fab bmd-btn-fab-sm' +
114
+ const $button = jquery(`<button ${disabledAttr} class="btn btn-default bmd-btn-fab bmd-btn-fab-sm` +
113
115
  ' browseChoices" type="button">')
114
116
  .attr('title', context.view.messages.edit_upgrade)
115
117
  .click(() => {
@@ -1,4 +1,4 @@
1
- import { fromDuration, toDuration } from '../jquery/util';
1
+ import { fromDuration, toDuration, getNamedGraphId } from '../viewUtils';
2
2
 
3
3
  let counter = 0;
4
4
  export default (fieldDiv, binding, context) => {
@@ -6,6 +6,7 @@ export default (fieldDiv, binding, context) => {
6
6
  let data = fromDuration(binding.getValue());
7
7
 
8
8
  const wrapper = jquery('<div>').addClass('rdformsDuration rdformsFieldInput').appendTo(fieldDiv);
9
+ const disabledAttr = getNamedGraphId(binding, context) ? 'disabled' : '';
9
10
  const render = () => {
10
11
  wrapper.empty();
11
12
  ['years', 'months', 'days', 'hours', 'minutes'].forEach((key) => {
@@ -17,7 +18,7 @@ export default (fieldDiv, binding, context) => {
17
18
  .attr('id', id)
18
19
  .text(bundle[`duration_${key}`])
19
20
  .appendTo(group);
20
- const inp = jquery('<input>').addClass('form-control')
21
+ const inp = jquery(`<input ${disabledAttr}>`).addClass('form-control')
21
22
  .attr('type', 'number')
22
23
  .attr('aria-describedby', id)
23
24
  .appendTo(group);
@@ -18,7 +18,7 @@ renderingContext.renderEditorLabel = (rowNode, binding, item, context) => {
18
18
  $labelDiv.attr('id', context.view.createLabelIndex(binding));
19
19
  }
20
20
  context.labelNode = $labelDiv[0];
21
- const $label = jquery('<span class="rdformsLabel">').text(label).appendTo($labelDiv);
21
+ const $label = jquery('<span class="rdformsLabel" tabindex="0">').text(label).appendTo($labelDiv);
22
22
  const card = item.getCardinality();
23
23
  const b = context.view.messages;
24
24
  if (card.min > 0) {
@@ -32,25 +32,36 @@ renderingContext.renderEditorLabel = (rowNode, binding, item, context) => {
32
32
  .appendTo($labelDiv);
33
33
  }
34
34
 
35
- renderingContext.attachItemInfo(item, $label[0], context);
36
-
35
+ // Buttons of various sorts
37
36
  if (binding == null) {
38
37
  renderingContext.addExpandButton(rowNode, $labelDiv[0], item, context);
39
- return undefined;
40
- }
41
- // If table, no add or remove buttons.
42
- if (context.view.showAsTable(item)) {
43
- return undefined;
44
- }
45
- if (card.max != null && (card.max === card.min)) {
46
- return undefined;
38
+ } else if (!context.view.showAsTable(item) &&
39
+ (card.max === null || card.max !== card.min)) {
40
+ // If not table or min and max are not the same, then add buttons.
41
+ if (item.getType() === 'group') {
42
+ renderingContext.addGroupButtons(rowNode, $labelDiv[0], binding, context);
43
+ } else {
44
+ renderingContext.addCreateChildButton(rowNode, $labelDiv[0], binding, context);
45
+ }
47
46
  }
48
47
 
49
- if (item.getType() === 'group') {
50
- renderingContext.addGroupButtons(rowNode, $labelDiv[0], binding, context);
51
- } else {
52
- renderingContext.addCreateChildButton(rowNode, $labelDiv[0], binding, context);
48
+ const view = context.view;
49
+ if (item.hasStyle('showDescriptionInEdit') || view.showDescription) {
50
+ // An item is compact if it is exclicitly set as compact or
51
+ // the view is set as compact and the item is not explicitly set as not compact AND
52
+ // we are at the top
53
+ const compactField = item.hasStyle('compact') ||
54
+ (view.compact && !item.hasStyle('nonCompact') && (
55
+ (view.topLevel && item.getType() !== 'group') ||
56
+ (view.parentView && view.parentView.topLevel && view.binding.getItem().hasStyle('heading'))));
57
+ const desc = context.view instanceof Editor ? item.getEditDescription() || item.getDescription() :
58
+ item.getDescription();
59
+ if (!compactField && desc) {
60
+ jquery('<div class="rdformsDescription" tabindex="0">').text(desc).appendTo(rowNode);
61
+ }
53
62
  }
63
+ renderingContext.attachItemInfo(item, $label[0], context);
64
+
54
65
  return undefined;
55
66
  };
56
67