@entryscape/rdforms 10.6.0 → 10.7.0

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 (49) 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 +78 -76
  6. package/package.json +4 -2
  7. package/src/model/CODES.js +17 -0
  8. package/src/model/CardinalityTracker.js +2 -1
  9. package/src/model/ChoiceBinding.js +1 -1
  10. package/src/model/engine.js +1 -19
  11. package/src/model/validate.js +21 -20
  12. package/src/template/Item.js +2 -1
  13. package/src/view/Editor.js +4 -3
  14. package/src/view/Presenter.js +32 -3
  15. package/src/view/Registry.js +1 -1
  16. package/src/view/ValidationPresenter.js +3 -2
  17. package/src/view/View.js +52 -10
  18. package/src/view/bmd/DateTimeMD.js +12 -14
  19. package/src/view/bmd/Selectize.js +5 -4
  20. package/src/view/bmd/style.css +9 -1
  21. package/src/view/bootstrap/DateTimeBootstrapDatepicker.js +6 -4
  22. package/src/view/bootstrap/RadioButtonsEditor.js +5 -2
  23. package/src/view/bootstrap/Select2.js +8 -5
  24. package/src/view/bootstrap/buttons.js +9 -5
  25. package/src/view/bootstrap/choice.js +6 -4
  26. package/src/view/bootstrap/durationEditor.js +3 -2
  27. package/src/view/bootstrap/labels.js +26 -15
  28. package/src/view/bootstrap/style.css +9 -3
  29. package/src/view/bootstrap/text.js +7 -4
  30. package/src/view/jquery/labels.js +15 -0
  31. package/src/view/jquery/text.js +3 -3
  32. package/src/view/react/buttons.js +3 -0
  33. package/src/view/react/choiceEditors/CheckBoxesEditor.js +8 -3
  34. package/src/view/react/choiceEditors/ChoiceLookup.js +4 -2
  35. package/src/view/react/choiceEditors/ChoiceLookupAndInlineSearch.js +25 -16
  36. package/src/view/react/choiceEditors/ChoiceSelector.js +7 -4
  37. package/src/view/react/choiceEditors/RadioButtonsEditor.js +8 -4
  38. package/src/view/react/choiceEditors/ShowButton.js +1 -0
  39. package/src/view/react/date.js +7 -5
  40. package/src/view/react/duration.js +4 -2
  41. package/src/view/react/hooks.js +3 -0
  42. package/src/view/react/labels.js +41 -5
  43. package/src/view/react/style.css +6 -6
  44. package/src/view/react/text.js +2 -2
  45. package/src/view/react/textEditors.js +5 -0
  46. package/src/view/renderingContext.js +5 -0
  47. package/src/view/resources/rdforms.css +39 -17
  48. package/src/view/{jquery/util.js → viewUtils.js} +11 -0
  49. package/src/view/react/util.js +0 -31
@@ -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
 
@@ -108,13 +108,14 @@
108
108
  font-size: small;
109
109
  }
110
110
 
111
- .rdformsFieldControl>.fa.action {
111
+ .rdformsFieldControl>.fas.action {
112
112
  float: right;
113
113
  position: initial;
114
114
  margin-top: 8px;
115
115
  }
116
116
 
117
- .fa.action.disabled {
117
+ .fas.action:disabled,
118
+ .fas.action.disabled {
118
119
  cursor: default;
119
120
  }
120
121
 
@@ -185,7 +186,6 @@
185
186
  /* Autoexpand style */
186
187
  .rdforms .rdformsFields textarea.form-control {
187
188
  display: block;
188
- box-sizing: padding-box;
189
189
  overflow-x: hidden;
190
190
  overflow-y: auto;
191
191
  }
@@ -248,4 +248,10 @@
248
248
 
249
249
  .rdformsValidator .rdformsValidationMessageWrapper {
250
250
  margin-left: -22px;
251
+ }
252
+
253
+ .rdformsActionButton {
254
+ border: none;
255
+ background: transparent;
256
+ padding: 0;
251
257
  }
@@ -2,6 +2,8 @@ import moment from 'moment';
2
2
  import durationEditor from './durationEditor';
3
3
  import renderingContext from '../renderingContext';
4
4
  import utils from '../../utils';
5
+ import { getNamedGraphId } from '../viewUtils';
6
+
5
7
 
6
8
  /**
7
9
  * Try to guess the number of rows needed for a textarea element by looking at the value of the element
@@ -107,9 +109,10 @@ registerPattern('^(\\d+(\\.\\d+)?)$', 'xsd:decimal');
107
109
  editors.itemtype('text').register((fieldDiv, binding, context) => {
108
110
  const item = binding.getItem();
109
111
  let $input;
112
+ const disabledAttr = getNamedGraphId(binding, context) ? 'disabled' : '';
110
113
  if (item.hasStyle('multiline')) {
111
114
  const originalNrOfLines = countLines(binding.getGist());
112
- $input = jquery(`<textarea class="form-control rdformsFieldInput autoExpand" placeholder="${item.getPlaceholder() || ''}" rows="${originalNrOfLines}">`);
115
+ $input = jquery(`<textarea ${disabledAttr} class="form-control rdformsFieldInput autoExpand" placeholder="${item.getPlaceholder() || ''}" rows="${originalNrOfLines}">`);
113
116
  $input.on('input focus', function () {
114
117
  if (this.baseScrollHeight === undefined) {
115
118
  const originalHeight = $input.height();
@@ -121,9 +124,9 @@ editors.itemtype('text').register((fieldDiv, binding, context) => {
121
124
  this.rows = rows;
122
125
  });
123
126
  } else if (item.hasStyle('email')) {
124
- $input = jquery(`<input type="email" class="form-control rdformsFieldInput" placeholder="${item.getPlaceholder() || ''}">`);
127
+ $input = jquery(`<input ${disabledAttr} type="email" class="form-control rdformsFieldInput" placeholder="${item.getPlaceholder() || ''}">`);
125
128
  } else {
126
- $input = jquery(`<input type="text" class="form-control rdformsFieldInput" placeholder="${item.getPlaceholder() || ''}">`);
129
+ $input = jquery(`<input ${disabledAttr} type="text" class="form-control rdformsFieldInput" placeholder="${item.getPlaceholder() || ''}">`);
127
130
  }
128
131
  $input.val(binding.getGist())
129
132
  .appendTo(fieldDiv);
@@ -156,7 +159,7 @@ editors.itemtype('text').register((fieldDiv, binding, context) => {
156
159
  if (nodeType === 'LANGUAGE_LITERAL' || nodeType === 'PLAIN_LITERAL') {
157
160
  jquery(fieldDiv).addClass('rdformsLangcontrolledfield');
158
161
  jquery(context.controlDiv).addClass('rdformsLangFieldControl');
159
- const $lselect = jquery('<select class="form-control rdformsLanguage">')
162
+ const $lselect = jquery(`<select ${disabledAttr} class="form-control rdformsLanguage">`)
160
163
  .appendTo(context.controlDiv);
161
164
  let primaryLangs = renderingContext.getPrimaryLanguageList();
162
165
  let langList = renderingContext.getNonPrimaryLanguageList();
@@ -20,6 +20,21 @@ renderingContext.renderPresenterLabel = (rowNode, binding, item, context, labelR
20
20
  if (context) {
21
21
  context.labelNode = $labelDiv[0];
22
22
  }
23
+ const view = context.view;
24
+ if (item.hasStyle('showDescriptionInPresent') || view.showDescription) {
25
+ // An item is compact if it is exclicitly set as compact or
26
+ // the view is set as compact and the item is not explicitly set as not compact AND
27
+ // we are at the top
28
+ const compactField = item.hasStyle('compact') ||
29
+ (view.compact && !item.hasStyle('nonCompact') && (
30
+ (view.topLevel && item.getType() !== 'group') ||
31
+ (view.parentView && view.parentView.topLevel && view.binding.getItem().hasStyle('heading'))));
32
+ const desc = item.getDescription();
33
+ if (!compactField && desc) {
34
+ jquery('<div class="rdformsDescription" tabindex="0">').text(desc).appendTo(rowNode);
35
+ }
36
+ }
37
+
23
38
  renderingContext.attachItemInfo(item, $labelDiv[0], context);
24
39
  };
25
40
 
@@ -1,6 +1,6 @@
1
1
  import moment from 'moment';
2
2
  import { escape } from 'lodash-es';
3
- import { getDatePresentation, fromDuration } from './util';
3
+ import { getDatePresentation, fromDuration } from '../viewUtils';
4
4
  import renderingContext from '../renderingContext';
5
5
  import utils from '../../utils';
6
6
  import system from '../../model/system';
@@ -122,7 +122,7 @@ presenters.itemtype('text').datatype('xsd:duration').register((fieldDiv, binding
122
122
  const node = jquery('<div>').appendTo(fieldDiv)[0];
123
123
  ['years', 'months', 'days', 'hours', 'minutes'].forEach((key) => {
124
124
  if (data.hasOwnProperty(key)) {
125
- jquery(`<span class="durationlabel">${bundle[`duration_${key}`]}:</span><span class="durationValue">${data[key]}</span>`)
125
+ jquery(`<span class="durationLabel">${bundle[`duration_${key}`]}:</span><span class="durationValue">${data[key]}</span>`)
126
126
  .appendTo(node);
127
127
  }
128
128
  });
@@ -143,4 +143,4 @@ presenters.itemtype('text').datatype('xsd:time').register(datePresenter);
143
143
  presenters.itemtype('text').datatype('xsd:gYear').register(datePresenter);
144
144
  presenters.itemtype('text').datatype('xsd:gYearMonth').register(datePresenter);
145
145
  presenters.itemtype('text').datatype('xsd:gMonthDay').register(datePresenter);
146
- presenters.itemtype('text').datatype('dcterms:W3CDTF').register(datePresenter);
146
+ presenters.itemtype('text').datatype('dcterms:W3CDTF').register(datePresenter);
@@ -7,6 +7,7 @@ import AddIcon from '@mui/icons-material/Add';
7
7
  import IconButton from '@mui/material/IconButton';
8
8
  import renderingContext from '../renderingContext';
9
9
  import * as engine from '../../model/engine';
10
+ import { useNamedGraphId } from './hooks';
10
11
 
11
12
  renderingContext.addExpandButton = (rowDiv, labelDiv, item, context) => {
12
13
  console.log('Expand button not yet supported');
@@ -78,10 +79,12 @@ renderingContext.addRemoveButton = (rowDiv, binding, context) => () => {
78
79
  }
79
80
  });
80
81
 
82
+ const ngId = useNamedGraphId(binding, context);
81
83
  const title = clear ? context.view.messages.edit_clear : context.view.messages.edit_remove;
82
84
  return <IconButton
83
85
  size="small"
84
86
  aria-label={title}
87
+ disabled={!!ngId}
85
88
  title={title}
86
89
  onClick={onClick}
87
90
  >{clear ? (<CancelIcon fontSize="small"/>) : (<RemoveCircleIcon fontSize="small"/>)}</IconButton>;
@@ -3,9 +3,11 @@ import React, { useState, useEffect, useMemo } from 'react';
3
3
  import FormControlLabel from '@mui/material/FormControlLabel';
4
4
  import Checkbox from '@mui/material/Checkbox';
5
5
  import { FormGroup } from '@mui/material';
6
- import { useLocalizedSortedChoices, useName } from '../hooks';
6
+ import { useLocalizedSortedChoices, useNamedGraphId } from '../hooks';
7
+ import { getNamedGraphId } from '../../viewUtils';
7
8
  import * as engine from '../../../model/engine';
8
9
 
10
+
9
11
  const CheckOption = (props) => {
10
12
  const { choice, binding, onChoiceChange } = props;
11
13
  const [checked, setChecked] = React.useState(choice.value === binding.getValue());
@@ -16,6 +18,7 @@ const CheckOption = (props) => {
16
18
  onChoiceChange();
17
19
  };
18
20
  return <FormControlLabel
21
+ disabled={props.disabled}
19
22
  label={choice.label} control={<Checkbox checked={checked} onChange={handleChange}/>}
20
23
  {...(choice.mismatch ? { className: 'mismatch' } : {})}
21
24
  title={choice.description || choice.seeAlso || choice.value}/>;
@@ -35,9 +38,9 @@ export default function CheckBoxesEditor(props) {
35
38
  const existingbinding = val2binding[c.value];
36
39
  if (existingbinding) {
37
40
  delete val2binding[c.value];
38
- return [c, existingbinding];
41
+ return [c, existingbinding, getNamedGraphId(existingbinding, props.context)];
39
42
  }
40
- return [c, engine.create(parentBinding, item)];
43
+ return [c, engine.create(parentBinding, item), undefined];
41
44
  });
42
45
  // Add checks for values that are non-conforming (should have mismatch on their choices).
43
46
  Object.values(val2binding).forEach((b) => {
@@ -70,12 +73,14 @@ export default function CheckBoxesEditor(props) {
70
73
  setResetCount(resetCount + 1);
71
74
  };
72
75
 
76
+ const ngId = useNamedGraphId(binding, props.context);
73
77
  return (
74
78
  <><FormGroup {...row}>
75
79
  {choiceBindingPairs.map(pair => (
76
80
  <CheckOption key={`${resetCount}-${pair[1].getHash()}`}
77
81
  choice={pair[0]}
78
82
  binding={pair[1]}
83
+ disabled={!!pair[2] || !!ngId}
79
84
  onChoiceChange={onChoiceChange} />
80
85
  ))}
81
86
  </FormGroup>{error && (
@@ -2,7 +2,7 @@
2
2
  import React, { useState, useEffect } from 'react';
3
3
  import TextField from '@mui/material/TextField';
4
4
  import renderingContext from '../../renderingContext';
5
- import { loadLocalizedChoice } from '../hooks';
5
+ import { loadLocalizedChoice, useNamedGraphId } from '../hooks';
6
6
  import utils from '../../../utils';
7
7
  import ShowButton from './ShowButton';
8
8
 
@@ -38,10 +38,11 @@ export default (props) => {
38
38
  }, props.field);
39
39
  };
40
40
 
41
+ const ngId = useNamedGraphId(binding, props.context);
41
42
  return <><TextField
42
43
  inputProps={{ 'aria-labelledby': labelledBy }}
43
44
  className="rdformsSearch"
44
- disabled {...(choice && choice.mismatch ? { mismatch: true } : {})}
45
+ disabled {...(!!ngId || (choice && choice.mismatch) ? { mismatch: true } : {})}
45
46
  title={title}
46
47
  value={label}
47
48
  placeholder={binding.getItem().getPlaceholder()}
@@ -49,6 +50,7 @@ export default (props) => {
49
50
  variant={renderingContext.materialVariant}
50
51
  /><ShowButton
51
52
  {... props}
53
+ disabled={!!ngId}
52
54
  onClick={choiceSelectorHandler}/>{ error && (<div key="warning" className="rdformsWarning">{
53
55
  props.context.view.messages.wrongValueField}</div>)}</>;
54
56
  };
@@ -1,11 +1,11 @@
1
- /* eslint-disable no-unused-vars */
1
+ /* eslint-disable no-unused-vars,quotes */
2
2
  import React, { useState, useEffect } from 'react';
3
3
  import TextField from '@mui/material/TextField';
4
4
  import Autocomplete from '@mui/material/Autocomplete';
5
5
  import BuildIcon from '@mui/icons-material/Build';
6
6
  import IconButton from '@mui/material/IconButton';
7
7
  import renderingContext from '../../renderingContext';
8
- import { useLocalizedChoice, editLocalizedChoice } from '../hooks';
8
+ import { editLocalizedChoice, loadLocalizedChoice, useNamedGraphId } from '../hooks';
9
9
  import ShowButton from './ShowButton';
10
10
 
11
11
  let globalChoiceQueryThrottle;
@@ -13,7 +13,7 @@ let globalChoiceQueryThrottle;
13
13
  export default (props) => {
14
14
  const binding = props.binding;
15
15
  const [options, setOptions] = useState([]);
16
- const [value, setValue] = useLocalizedChoice(binding, options);
16
+ const [value, setValue] = loadLocalizedChoice(binding, true);
17
17
  const [inputValue, setInputValue] = useState('');
18
18
  const [open, setOpen] = useState(false);
19
19
  const [error, setError] = useState(binding.getChoice()?.mismatch === true);
@@ -78,7 +78,8 @@ export default (props) => {
78
78
  setOpen(true);
79
79
  }
80
80
  }}
81
- variant={renderingContext.materialVariant} />
81
+ variant={renderingContext.materialVariant}
82
+ />
82
83
  );
83
84
  };
84
85
 
@@ -97,6 +98,8 @@ export default (props) => {
97
98
  });
98
99
  };
99
100
 
101
+ const ngId = useNamedGraphId(binding, props.context);
102
+ const UpgradeComponent = value && value.original.upgradeComponent;
100
103
  return (
101
104
  <>
102
105
  <Autocomplete
@@ -105,29 +108,35 @@ export default (props) => {
105
108
  fullWidth={false}
106
109
  value={value}
107
110
  options={options}
108
- filterOptions={(fopts) => fopts}
111
+ filterOptions={fopts => fopts}
109
112
  open={open}
110
113
  onOpen={() => setOpen(true)}
111
114
  onClose={() => setOpen(false)}
112
115
  onInputChange={(event, newInputValue) => setInputValue(newInputValue)}
113
116
  onChange={onChange}
117
+ disabled={!!ngId}
114
118
  isOptionEqualToValue={(option, choice) => option.value === choice.value}
115
- getOptionLabel={(choice) =>
119
+ getOptionLabel={choice =>
116
120
  choice === null ? '' : choice.label || choice.value
117
121
  }
118
- getOptionDisabled={(option) => option.mismatch === true}
122
+ getOptionDisabled={option => option.mismatch === true}
119
123
  renderInput={renderInput}
124
+ disablePortal
120
125
  />
121
- <ShowButton {...props} onClick={showHandler} />
126
+ <ShowButton {...props} onClick={showHandler} disabled={!!ngId}/>
122
127
  {value && value.original.upgrade && (
123
- <IconButton
124
- aria-label={props.context.view.messages.edit_upgrade}
125
- title={props.context.view.messages.edit_upgrade}
126
- onClick={upgradeHandler}
127
- >
128
- <BuildIcon />
129
- </IconButton>
130
- )}
128
+ <>
129
+ <IconButton
130
+ aria-label={props.context.view.messages.edit_upgrade}
131
+ title={props.context.view.messages.edit_upgrade}
132
+ disabled={!!ngId}
133
+ onClick={upgradeHandler}
134
+ >
135
+ <BuildIcon />
136
+ </IconButton>
137
+ {UpgradeComponent}
138
+ </>
139
+ )}
131
140
  {error && (
132
141
  <div key="warning" className="rdformsWarning">
133
142
  {props.context.view.messages.wrongValueField}
@@ -1,9 +1,9 @@
1
- /* eslint-disable no-unused-vars */
1
+ /* eslint-disable no-unused-vars,quotes */
2
2
  import React, { useState, useEffect } from 'react';
3
3
  import TextField from '@mui/material/TextField';
4
4
  import Autocomplete from '@mui/material/Autocomplete';
5
5
  import renderingContext from '../../renderingContext';
6
- import { useLocalizedSortedChoices, useLocalizedChoice } from '../hooks';
6
+ import { useLocalizedSortedChoices, useLocalizedChoice, useNamedGraphId } from '../hooks';
7
7
 
8
8
  /**
9
9
  * Autocomplete with fixed choices.
@@ -50,6 +50,7 @@ export default (props) => {
50
50
  setError(newChoice.original.mismatch === true);
51
51
  };
52
52
 
53
+ const ngId = useNamedGraphId(binding, props.context);
53
54
  return (
54
55
  <>
55
56
  <Autocomplete
@@ -58,11 +59,13 @@ export default (props) => {
58
59
  value={value}
59
60
  options={choices}
60
61
  onChange={handleChange}
62
+ disabled={!!ngId}
61
63
  isOptionEqualToValue={(option, choice) => option.value === choice.value}
62
- getOptionLabel={(choice) => (choice === null ? '' : choice.label)}
63
- getOptionDisabled={(option) => option.mismatch === true}
64
+ getOptionLabel={choice => (choice === null ? '' : choice.label)}
65
+ getOptionDisabled={option => option.mismatch === true}
64
66
  filterSelectedOptions
65
67
  renderInput={renderInput}
68
+ disablePortal
66
69
  />
67
70
  {error && (
68
71
  <div key="warning" className="rdformsWarning">
@@ -1,12 +1,13 @@
1
- /* eslint-disable no-unused-vars */
1
+ /* eslint-disable no-unused-vars,quotes */
2
2
  import React, { useState, useEffect } from 'react';
3
3
  import Radio from '@mui/material/Radio';
4
4
  import RadioGroup from '@mui/material/RadioGroup';
5
5
  import FormControlLabel from '@mui/material/FormControlLabel';
6
6
  import FormControl from '@mui/material/FormControl';
7
- import { useLocalizedSortedChoices, useName } from '../hooks';
7
+ import { useLocalizedSortedChoices, useName, useNamedGraphId } from '../hooks';
8
8
 
9
9
  const ChoiceOption = props => <FormControlLabel
10
+ disabled={props.disabled}
10
11
  label={props.choice.label} value={props.choice.value} control={<Radio/>}
11
12
  {...(props.choice.mismatch ? { className: 'mismatch' } : {})}
12
13
  title={props.choice.description || props.choice.seeAlso || props.choice.value}/>;
@@ -46,6 +47,7 @@ export default function RadioButtonsEditor(props) {
46
47
  };
47
48
  }, []);
48
49
 
50
+ const ngId = useNamedGraphId(binding, props.context);
49
51
  return (
50
52
  <>
51
53
  <FormControl component="fieldset">
@@ -57,8 +59,10 @@ export default function RadioButtonsEditor(props) {
57
59
  value={value}
58
60
  onChange={handleChange}
59
61
  >
60
- {choices.map((choice) => (
61
- <ChoiceOption key={choice.value} choice={choice} />
62
+ {choices.map(choice => (
63
+ <ChoiceOption key={choice.value}
64
+ disabled={!!ngId}
65
+ choice={choice} />
62
66
  ))}
63
67
  </RadioGroup>
64
68
  </FormControl>
@@ -24,6 +24,7 @@ export default (props) => {
24
24
  props.context.view.messages.edit_browse;
25
25
  if (props.context.chooser.show) {
26
26
  return <IconButton
27
+ disabled={props.disabled}
27
28
  aria-label={title}
28
29
  title={title}
29
30
  onClick={props.onClick}
@@ -16,8 +16,8 @@ import {
16
16
  getDateValue,
17
17
  getAllowedDateAlternatives,
18
18
  getDatePresentation,
19
- } from '../jquery/util';
20
-
19
+ } from '../viewUtils';
20
+ import { useNamedGraphId } from './hooks';
21
21
 
22
22
  const getDatatypeFromBinding = binding => getDatatype(binding.getDatatype()) || getDatatypeFromItem(binding.getItem());
23
23
 
@@ -118,10 +118,11 @@ const dateEditor = (fieldDiv, binding, context) => {
118
118
  'aria-labelledby': context.view.getLabelIndex(binding),
119
119
  variant: renderingContext.materialVariant,
120
120
  };
121
+ const ngId = useNamedGraphId(binding, context);
121
122
  const visibleDatePicker = alternatives.Date || alternatives.DateTime || alternatives.Year
122
123
  || alternatives.YearMonth || alternatives.MonthDay;
123
- const enabledDatePicker = selectedDatatype === 'DateTime' || selectedDatatype === 'Date'
124
- || selectedDatatype === 'Year' || selectedDatatype === 'YearMonth' || selectedDatatype === 'MonthDay';
124
+ const enabledDatePicker = !ngId && (selectedDatatype === 'DateTime' || selectedDatatype === 'Date'
125
+ || selectedDatatype === 'Year' || selectedDatatype === 'YearMonth' || selectedDatatype === 'MonthDay');
125
126
  return (
126
127
  <LocalizationProvider dateAdapter={DateAdapter}>
127
128
  <span className="rdformsDatePicker">
@@ -146,7 +147,7 @@ const dateEditor = (fieldDiv, binding, context) => {
146
147
  <TimePicker
147
148
  renderInput={props => <TextField {...props} {...inputProps} />}
148
149
  label={bundle.date_time}
149
- {...(selectedDatatype === 'DateTime' || selectedDatatype === 'Time' ? {} : { disabled: true })}
150
+ {...(!ngId && (selectedDatatype === 'DateTime' || selectedDatatype === 'Time') ? {} : { disabled: true })}
150
151
  KeyboardButtonProps={{
151
152
  'aria-label': bundle.date_openTimePicker,
152
153
  }}
@@ -162,6 +163,7 @@ const dateEditor = (fieldDiv, binding, context) => {
162
163
  value={selectedDatatype}
163
164
  inputProps={inputProps}
164
165
  onChange={onDatatypeChange}
166
+ disabled={!!ngId}
165
167
  >
166
168
  {alternatives.Year && (
167
169
  <MenuItem value="Year">{bundle.date_year}</MenuItem>