@entryscape/rdforms 10.11.2 → 10.12.1

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/package.json CHANGED
@@ -8,17 +8,20 @@
8
8
  "application profile",
9
9
  "linked data"
10
10
  ],
11
- "version": "10.11.2",
11
+ "version": "10.12.1",
12
12
  "main": "dist/rdforms.node.js",
13
13
  "browser": "dist/rdforms.react.js",
14
14
  "module": "main.js",
15
15
  "repository": "https://bitbucket.org/metasolutions/rdforms.git",
16
16
  "license": "LGPL-3.0-only",
17
17
  "homepage": "https://rdforms.org",
18
+ "peerDependencies": {
19
+ "@entryscape/rdfjson": "2.7.6"
20
+ },
18
21
  "dependencies": {
22
+ "@entryscape/rdfjson": "2.7.6",
19
23
  "@emotion/react": "^11.4.1",
20
24
  "@emotion/styled": "^11.3.0",
21
- "@entryscape/rdfjson": "2.7.6",
22
25
  "@fortawesome/fontawesome-free": "^5.8.1",
23
26
  "@mui/icons-material": "^5.0.3",
24
27
  "@mui/material": "^5.0.3",
@@ -83,7 +86,7 @@
83
86
  "ttf-loader": "^1.0.2",
84
87
  "webpack": "^5.88.2",
85
88
  "webpack-cli": "^5.1.4",
86
- "webpack-dev-server": "^4.15.1",
89
+ "webpack-dev-server": "^4.15.2",
87
90
  "webpack-merge": "^5.8.0"
88
91
  },
89
92
  "files": [
@@ -661,7 +661,7 @@ const matchPathBelowBinding = (bindingTree, path) => {
661
661
  return res;
662
662
  }
663
663
  }
664
- if (pred === '*' || pred === b.getPredicate()) {
664
+ if (pred === '*' || pred === b.getPredicate() || pred === item.getId()) {
665
665
  if (item.getType() === 'group') {
666
666
  res = matchPathBelowBinding(b, _path.slice(1));
667
667
  if (res) {
@@ -203,6 +203,37 @@ export default class Item {
203
203
  this.refreshExtends();
204
204
  }
205
205
 
206
+ getEnhanced(attribute) {
207
+ const s = this.getSource(true);
208
+ if (typeof s.enhanced === 'boolean') {
209
+ return s.enhanced;
210
+ }
211
+ return (s.enhanced && s.enhanced[attribute]) || false;
212
+ }
213
+
214
+ setEnhanced(attribute, enhanced) {
215
+ const s = this.getSource(true);
216
+ if (typeof attribute === 'boolean') {
217
+ if (attribute === true) {
218
+ s.enhanced = true;
219
+ } else {
220
+ delete s.enhanced;
221
+ }
222
+ } else {
223
+ s.enhanced = typeof s.enhanced === 'boolean' ? {} : s.enhanced || {};
224
+ if (enhanced) {
225
+ s.enhanced[attribute] = true;
226
+ } else {
227
+ delete s.enhanced[attribute];
228
+ if (Object.keys(s).length === 0) {
229
+ delete s.enhanced;
230
+ }
231
+ }
232
+ }
233
+ // Simple way to refresh this._source which is a cache including potential enhancements
234
+ this.setExtends(this.getExtends());
235
+ }
236
+
206
237
  /**
207
238
  * @return {String|null} as a URI, may be null for Groups, never null for Text or choice
208
239
  * item types.
@@ -487,7 +518,7 @@ export default class Item {
487
518
  return source.styles.some(s => s.toLowerCase() === sty.toLowerCase());
488
519
  }
489
520
 
490
- getSource(original) {
521
+ getSource(original, attribute) {
491
522
  if (original === true) { // Get the original source
492
523
  return this._source._extendedSource || this._source;
493
524
  } else if (original === false) { // Get the extended source
@@ -7,6 +7,26 @@ import OntologyStore from './OntologyStore';
7
7
  import Bundle from './Bundle';
8
8
  import { constructTemplate } from '../model/engine';
9
9
 
10
+ const deepMerge = (source1, source2) => {
11
+ if (!source1 || !source2) {
12
+ return source2 === undefined ? source1 : source2;
13
+ }
14
+
15
+ if (Array.isArray(source1) && Array.isArray(source2)) {
16
+ return [].concat(origSource[key], extSource[key]);
17
+ }
18
+
19
+ if (typeof source1 === 'object' && typeof source2 === 'object') {
20
+ const obj = {};
21
+ Object.keys(source1).concat(Object.keys(source2)).forEach(key => {
22
+ obj[key] = deepMerge(source1[key], source2[key]);
23
+ });
24
+ return obj;
25
+ }
26
+
27
+ return source2;
28
+ }
29
+
10
30
  export default class ItemStore {
11
31
  /**
12
32
  * Keeps a registry of templates and reusable items.
@@ -49,7 +69,11 @@ export default class ItemStore {
49
69
  }
50
70
  const ext = this.getItem(origSource.extends);
51
71
  if (ext) {
52
- return ext.getChildren().concat(group.getChildren(true));
72
+ const children = group.getChildren(true);
73
+ if (group.getEnhanced('items') || children.length === 0) {
74
+ return ext.getChildren().concat(children);
75
+ }
76
+ return children;
53
77
  }
54
78
  return group.getChildren(true);
55
79
  }
@@ -166,7 +190,18 @@ export default class ItemStore {
166
190
 
167
191
  // eslint-disable-next-line class-methods-use-this
168
192
  createExtendedSource(origSource, extSource) {
169
- const newSource = Object.assign(Object.assign({}, origSource), extSource);
193
+ const newSource = Object.assign({}, origSource, extSource);
194
+ if (extSource.enhanced) {
195
+ let keys;
196
+ if (extSource.enhanced === true) {
197
+ keys = Object.keys(origSource).concat(Object.keys(extSource));
198
+ } else {
199
+ keys = Object.keys(extSource.enhanced);
200
+ }
201
+ keys.forEach(key => {
202
+ newSource[key] = deepMerge(origSource[key], extSource[key]);
203
+ });
204
+ }
170
205
  newSource._extendedSource = extSource;
171
206
  newSource.extends = null; // Avoid infinite recursion when creating the fleshed out item.
172
207
  delete newSource.children;
package/src/utils.js CHANGED
@@ -2,21 +2,21 @@ import moment from 'moment';
2
2
  import { cloneDeep } from 'lodash-es';
3
3
  import system from './model/system';
4
4
 
5
- const getLocalizedValue = (hash) => {
6
- const locale = moment.locale();
5
+ const getLocalizedValue = (hash, locale) => {
6
+ const _locale = locale || moment.locale();
7
7
  if (hash == null) {
8
8
  return { precision: 'none' };
9
9
  } else if (typeof hash === 'string') {
10
10
  return { value: hash, precision: 'nolang', lang: '' };
11
- } else if (hash.hasOwnProperty(locale)) {
12
- return { value: hash[locale], precision: 'exact', lang: locale };
11
+ } else if (hash.hasOwnProperty(_locale)) {
12
+ return { value: hash[_locale], precision: 'exact', lang: _locale };
13
13
  }
14
- const pos = locale.indexOf('_');
15
- if (pos > -1 && hash.hasOwnProperty(locale.substr(0, 2))) {
14
+ const pos = _locale.indexOf('_');
15
+ if (pos > -1 && hash.hasOwnProperty(_locale.substr(0, 2))) {
16
16
  return {
17
- value: hash[locale.substr(0, 2)],
17
+ value: hash[_locale.substr(0, 2)],
18
18
  precision: 'coarsen',
19
- lang: locale.substr(0, 2),
19
+ lang: _locale.substr(0, 2),
20
20
  };
21
21
  } else if (hash.hasOwnProperty('en')) {
22
22
  return { value: hash.en, precision: 'default', lang: 'en' };
@@ -1,5 +1,4 @@
1
1
  /* eslint-disable class-methods-use-this */
2
- import moment from 'moment';
3
2
  import renderingContext from './renderingContext';
4
3
  import View from './View';
5
4
 
@@ -77,7 +76,7 @@ export default class Presenter extends View {
77
76
  return bindings;
78
77
  }
79
78
 
80
- return renderingContext.filterTranslations(bindings, moment.locale(), this.defaultLanguage);
79
+ return renderingContext.filterTranslations(bindings, this.getLocale(), this.defaultLanguage);
81
80
  }
82
81
 
83
82
  addLabel(rowDiv, binding, item) {
package/src/view/View.js CHANGED
@@ -4,12 +4,16 @@ import renderingContext from './renderingContext';
4
4
  import GroupBinding from '../model/GroupBinding';
5
5
  import * as engine from '../model/engine';
6
6
  import { bindingReport } from '../model/validate';
7
+ import moment from 'moment';
7
8
 
8
9
  let viewCounter = 0;
9
10
  export default class View {
10
11
  constructor(params, srcNodeRef) {
11
12
  this._viewId = viewCounter;
12
13
  viewCounter += 1;
14
+ this.locale = params.locale;
15
+ this.defaultTextLanguage = params.defaultTextLanguage;
16
+ this.messages = params.messages;
13
17
  this.parentView = params.parentView;
14
18
  this.srcNodeRef = srcNodeRef;
15
19
  this.binding = params.binding || null;
@@ -166,8 +170,9 @@ export default class View {
166
170
  return;
167
171
  }
168
172
 
169
- const messages = renderingContext.getMessages();
170
- this.messages = messages;
173
+ if (!this.messages) {
174
+ this.messages = renderingContext.getMessages();
175
+ }
171
176
  if (this.binding == null) {
172
177
  // Just in case loading messages takes time
173
178
  // and someone does a reset of the view meanwhile.
@@ -456,4 +461,12 @@ export default class View {
456
461
  truncateAt(item, bindings) {
457
462
  return -1;
458
463
  }
464
+
465
+ getLocale() {
466
+ return this.locale || (this.parentView ? this.parentView.getLocale() : moment.locale());
467
+ }
468
+
469
+ getDefaultTextLanguage() {
470
+ return this.defaultTextLanguage || (this.parentView ? this.parentView.getDefaultTextLanguage() : this.getLocale());
471
+ }
459
472
  }
@@ -54,7 +54,7 @@ export default class DateTimeMD extends DateTimeBase {
54
54
  date: true,
55
55
  triggerEvent: 'none',
56
56
  switchOnClick: true,
57
- lang: moment.locale(),
57
+ lang: this.context.view.getLocale(),
58
58
  });
59
59
 
60
60
  // time
@@ -64,17 +64,17 @@ export default class DateTimeMD extends DateTimeBase {
64
64
  date: false,
65
65
  triggerEvent: 'none',
66
66
  switchOnClick: true,
67
- lang: moment.locale(),
67
+ lang: this.context.view.getLocale(),
68
68
  });
69
69
 
70
70
  jquery(this.dateButton).click(() => {
71
71
  this.$datepicker.bootstrapMaterialDatePicker('_fireCalendar');
72
72
  });
73
73
  this.$datepicker.on('change', (evt, mInstance) => {
74
- const m = mInstance || moment(evt.target.value);
74
+ const m = mInstance || moment(evt.target.value, undefined, this.context.view.getLocale());
75
75
 
76
76
  if (this.tpdate) {
77
- const tpd = moment(this.tpdate);
77
+ const tpd = moment(this.tpdate, undefined, this.context.view.getLocale());
78
78
  m.minute(tpd.minute());
79
79
  m.hour(tpd.hour());
80
80
  }
@@ -91,10 +91,10 @@ export default class DateTimeMD extends DateTimeBase {
91
91
  });
92
92
 
93
93
  this.$timepicker.on('change', (evt, mInstance) => {
94
- const m = mInstance || moment(evt.target.value);
94
+ const m = mInstance || moment(evt.target.value, undefined, this.context.view.getLocale());
95
95
 
96
96
  if (this.dpdate != null) {
97
- const dpd = moment(this.dpdate);
97
+ const dpd = moment(this.dpdate, undefined, this.context.view.getLocale());
98
98
  dpd.minute(m.minute());
99
99
  dpd.hour(m.hour());
100
100
  this.tpdate = dpd.toDate();
@@ -41,7 +41,7 @@ renderingContext.renderSelect = function (fieldDiv, binding, context) {
41
41
  context.chooser.search(binding, query).then((choices) => {
42
42
  callback(choices.map(c => ({
43
43
  id: c.value,
44
- text: utils.getLocalizedValue(c.label).value || '',
44
+ text: utils.getLocalizedValue(c.editlabel || c.label, context.view.getLocale()).value || '',
45
45
  choice: c,
46
46
  })));
47
47
  });
@@ -58,7 +58,7 @@ renderingContext.renderSelect = function (fieldDiv, binding, context) {
58
58
  };
59
59
  context.setValue = (choice) => {
60
60
  $select.toggleClass('mismatch', choice.mismatch === true);
61
- const label = utils.getLocalizedValue(choice.label).value || '';
61
+ const label = utils.getLocalizedValue(choice.editlabel || choice.label, context.view.getLocale()).value || '';
62
62
  const op = sel.options[choice.value];
63
63
  if (!op) {
64
64
  sel.addOption({ id: choice.value, text: label, choice });
@@ -8,9 +8,9 @@ export default class RadioButtonsEditor {
8
8
  this.item = this.binding.getItem();
9
9
  this.choices = this.item.getChoices().map(c => ({
10
10
  label: c.editlabel || c.label,
11
- description: c.description,
11
+ description: c.editDescription || c.description,
12
12
  value: c.value,
13
- text: this.item._getLocalizedValue(c.editlabel || c.label).value,
13
+ text: this.item._getLocalizedValue(c.editlabel || c.label, args.context.view.getLocale()).value,
14
14
  choice: c,
15
15
  }));
16
16
 
@@ -46,8 +46,9 @@ export default class RadioButtonsEditor {
46
46
  $label = jquery('<label class="form-check-label">')
47
47
  .appendTo($divWrap);
48
48
  }
49
- if (c.description) {
50
- $label.attr('title', this.item._getLocalizedValue(c.editdescription || c.description).value
49
+ if (c.description || c.editdescription) {
50
+ $label.attr('title', this.item._getLocalizedValue(c.editdescription || c.description,
51
+ this.context.view.getLocale()).value
51
52
  || c.seeAlso || c.value);
52
53
  }
53
54
 
@@ -57,7 +58,7 @@ export default class RadioButtonsEditor {
57
58
  .attr('checked', c.value === currentValue)
58
59
  .attr('name', `rdformsRadio_${uniqueRadioButtonGroupNr}`)
59
60
  .appendTo($label);
60
- $label.append(this.item._getLocalizedValue(c.editlabel || c.label).value);
61
+ $label.append(this.item._getLocalizedValue(c.editlabel || c.label, this.context.view.getLocale()).value);
61
62
 
62
63
  if (c.mismatch) {
63
64
  $label.addClass('mismatch disabled');
@@ -4,7 +4,6 @@ import renderingContext from '../renderingContext';
4
4
  import utils from '../../utils';
5
5
  import Select2QueryAdapter from './Select2QueryAdapter';
6
6
  import { getNamedGraphId } from '../viewUtils';
7
- // import 'select2/src/js/jquery.select2';
8
7
 
9
8
 
10
9
  renderingContext.renderSelect = (fieldDiv, binding, context) => {
@@ -32,7 +31,7 @@ renderingContext.renderSelect = (fieldDiv, binding, context) => {
32
31
  };
33
32
  context.setValue = (choice) => {
34
33
  $select.toggleClass('mismatch', choice.mismatch === true);
35
- const label = utils.getLocalizedValue(choice.label).value || '';
34
+ const label = utils.getLocalizedValue(choice.editlabel || choice.label, context.view.getLocale()).value || '';
36
35
  if ($select.find(`option[value='${choice.value}']`).length === 0) {
37
36
  $select.append(new Option(label, choice.value, true, true)).trigger('change');
38
37
  $select.trigger({
@@ -52,7 +51,8 @@ renderingContext.renderSelect = (fieldDiv, binding, context) => {
52
51
  $select.toggleClass('mismatch', choice.mismatch);
53
52
  const $node = $select.next().find('.select2-selection__rendered');
54
53
  if (choice.description) {
55
- $node.attr('title', utils.getLocalizedValue(choice.description).value);
54
+ $node.attr('title',
55
+ utils.getLocalizedValue(choice.editdescription || choice.description, context.view.getLocale()).value);
56
56
  }
57
57
  });
58
58
  };
@@ -22,7 +22,7 @@ editors.itemtype('choice').choices().register((fieldDiv, binding, context) => {
22
22
  const item = binding.getItem();
23
23
  const choices = item.getChoices().map(c => ({
24
24
  id: c.value,
25
- text: item._getLocalizedValue(c.editlabel || c.label).value,
25
+ text: item._getLocalizedValue(c.editlabel || c.label, context.view.getLocale()).value,
26
26
  choice: c,
27
27
  }));
28
28
  if (!item.hasStyle('preserveOrderOfChoices')) {
@@ -1,13 +1,16 @@
1
1
  import jquery from 'jquery';
2
2
  import renderingContext from '../renderingContext';
3
3
  import Editor from '../Editor';
4
+ import utils from '../../utils';
5
+
4
6
 
5
7
  renderingContext.renderEditorLabel = (rowNode, binding, item, context) => {
6
8
  if (item.hasStyle('nonEditable') || item.hasStyle('heading')) {
7
9
  return renderingContext.renderPresenterLabel(rowNode, binding, item, context, true);
8
10
  }
9
11
 
10
- let label = item.getEditLabel() || item.getLabel();
12
+ const labelMap = item.getEditLabelMap() || item.getLabelMap();
13
+ let label = utils.getLocalizedValue(labelMap, context.view.getLocale()).value
11
14
  if (label != null && label !== '') {
12
15
  label = label.charAt(0).toUpperCase() + label.slice(1);
13
16
  } else {
@@ -59,8 +62,10 @@ renderingContext.renderEditorLabel = (rowNode, binding, item, context) => {
59
62
  (view.compact && !item.hasStyle('nonCompact') && (
60
63
  (view.topLevel && item.getType() !== 'group') ||
61
64
  (view.parentView && view.parentView.topLevel && view.binding.getItem().hasStyle('heading'))));
62
- const desc = context.view instanceof Editor ? item.getEditDescription() || item.getDescription() :
63
- item.getDescription();
65
+ const descMap = context.view instanceof Editor ? item.getEditDescriptionMap() || item.getDescriptionMap() :
66
+ item.getDescriptionMap();
67
+ let desc = utils.getLocalizedValue(descMap, context.view.getLocale()).value
68
+
64
69
  if (!compactField && desc) {
65
70
  jquery('<div class="rdformsDescription" tabindex="0">').text(desc).appendTo(rowNode);
66
71
  }
@@ -71,21 +76,25 @@ renderingContext.renderEditorLabel = (rowNode, binding, item, context) => {
71
76
  };
72
77
 
73
78
  renderingContext.attachItemInfo = function (item, aroundNode, context) {
74
- if (item == null || (item.getProperty() == null && item.getDescription() == null
75
- && item.getEditDescription() == null)) {
79
+ if (item == null || (item.getProperty() == null && item.getDescriptionMap() == null
80
+ && item.getEditDescriptionMap() == null)) {
76
81
  jquery(aroundNode).addClass('noPointer');
77
82
  return;
78
83
  }
79
84
 
80
- const description = (context.view instanceof Editor ?
81
- item.getEditDescription() || item.getDescription() : item.getDescription()) || '';
85
+ const descriptionMap = (context.view instanceof Editor ?
86
+ item.getEditDescriptionMap() || item.getDescriptionMap() : item.getDescriptionMap()) || {};
87
+ const description = utils.getLocalizedValue(descriptionMap, context.view.getLocale()).value || '';
88
+
82
89
  let propinfo = '';
83
90
  if (item.getProperty()) {
84
91
  propinfo = `<div class="property"><a target="_blank" href="${item.getProperty()}">${
85
92
  item.getProperty()}</a></div>`;
86
93
  }
87
94
 
88
- let label = context.view instanceof Editor ? item.getEditLabel() || item.getLabel() : item.getLabel();
95
+ const labelMap = context.view instanceof Editor ? item.getEditLabelMap() || item.getLabelMap() : item.getLabelMap();
96
+ let label = utils.getLocalizedValue(labelMap, context.view.getLocale()).value
97
+
89
98
  if (label != null && label !== '') {
90
99
  label = label.charAt(0).toUpperCase() + label.slice(1);
91
100
  } else {
@@ -106,12 +106,13 @@ renderingContext.addEditorTable = (newRow, firstBinding, context) => {
106
106
  const $tHead = jquery('<thead>').appendTo($table);
107
107
  const $tBody = jquery('<tbody>').appendTo($table);
108
108
  const $tHeadRow = jquery('<tr>').appendTo($tHead);
109
- for (colInd = 0; colInd < childItems.length; colInd++) {
109
+ for (let colInd = 0; colInd < childItems.length; colInd++) {
110
110
  const $th = jquery('<th>').appendTo($tHeadRow);
111
111
  jquery($th).addClass(`rdformsColumnHeader${colInd}`);
112
112
  const childItem = childItems[colInd];
113
- const label = context.view instanceof Editor ?
114
- childItem.getEditLabel() || childItem.getLabel() : childItem.getLabel();
113
+ const labelMap = context.view instanceof Editor ?
114
+ childItem.getEditLabelMap() || childItem.getLabelMap() : childItem.getLabelMap();
115
+ const label = utils.getLocalizedValue(labelMap, context.view.getLocale()).value
115
116
  renderingContext.attachItemInfo(item,
116
117
  jquery('<span>').text(label).appendTo($th)[0], context);
117
118
  }
@@ -1,4 +1,3 @@
1
- import moment from 'moment';
2
1
  import durationEditor from './durationEditor';
3
2
  import renderingContext from '../renderingContext';
4
3
  import utils from '../../utils';
@@ -184,7 +183,7 @@ editors.itemtype('text').register((fieldDiv, binding, context) => {
184
183
  if (binding.isValid()) {
185
184
  $lselect.val(binding.getLanguage());
186
185
  } else {
187
- const defLang = moment.locale();
186
+ const defLang = context.view.getDefaultTextLanguage();
188
187
  if (typeof defLang === 'string' && defLang !== '') {
189
188
  $lselect.val(defLang);
190
189
  binding.setLanguage(defLang);
@@ -5,16 +5,16 @@ import utils from '../../utils';
5
5
  // -------------- Presenters ----------------
6
6
  const presenters = renderingContext.presenterRegistry;
7
7
 
8
- const choicify = func => (fieldDiv, binding) => {
8
+ const choicify = func => (fieldDiv, binding, context) => {
9
9
  const choice = binding.getChoice();
10
10
  let desc;
11
11
  if (!choice) {
12
12
  return;
13
13
  }
14
14
  if (choice.description) {
15
- desc = utils.getLocalizedValue(choice.description).value;
15
+ desc = utils.getLocalizedValue(choice.description, context.view.getLocale()).value;
16
16
  }
17
- func(fieldDiv, binding, choice, desc);
17
+ func(fieldDiv, binding, choice, desc, context.view.getLocale());
18
18
  };
19
19
 
20
20
  // Presenter for image.
@@ -36,15 +36,15 @@ presenters.itemtype('choice').style('stars').register(choicify(
36
36
 
37
37
  // Presenter for choices.
38
38
  presenters.itemtype('choice').register(choicify(
39
- (fieldDiv, binding, choice, desc) => {
39
+ (fieldDiv, binding, choice, desc, locale) => {
40
40
  const item = binding.getItem();
41
- const locValue = utils.getLocalizedValue(choice.label);
41
+ const locValue = utils.getLocalizedValue(choice.label, locale);
42
42
  let $el;
43
43
 
44
44
  if (item.hasStaticChoices() && !item.hasStyle('externalLink') || item.hasStyle('noLink')) {
45
45
  $el = jquery('<div>')
46
46
  .attr('title', desc || choice.seeAlso || choice.value)
47
- .text(utils.getLocalizedValue(choice.label).value)
47
+ .text(utils.getLocalizedValue(choice.label, locale).value)
48
48
  .appendTo(fieldDiv);
49
49
  } else {
50
50
  $el = jquery('<a class="rdformsUrl">')
@@ -60,7 +60,7 @@ presenters.itemtype('choice').register(choicify(
60
60
  }
61
61
  if (choice.load != null) {
62
62
  choice.load(() => {
63
- const locValue2 = utils.getLocalizedValue(choice.label);
63
+ const locValue2 = utils.getLocalizedValue(choice.label, locale);
64
64
  $el.text(locValue2.value);
65
65
  if (locValue2.lang) {
66
66
  $el.attr('lang', locValue2.lang);
@@ -1,9 +1,11 @@
1
1
  import jquery from 'jquery';
2
2
  import renderingContext from '../renderingContext';
3
3
  import Editor from '../Editor';
4
+ import utils from '../../utils';
4
5
 
5
6
  renderingContext.renderPresenterLabel = (rowNode, binding, item, context, labelRow) => {
6
- let label = context.view instanceof Editor ? item.getEditLabel() || item.getLabel() : item.getLabel();
7
+ let labelMap = context.view instanceof Editor ? item.getEditLabelMap() || item.getLabelMap() : item.getLabelMap();
8
+ let label = utils.getLocalizedValue(labelMap, context.view.getLocale()).value
7
9
  if (label != null && label !== '') {
8
10
  label = label.charAt(0).toUpperCase() + label.slice(1);
9
11
  } else {
@@ -31,7 +33,8 @@ renderingContext.renderPresenterLabel = (rowNode, binding, item, context, labelR
31
33
  (view.compact && !item.hasStyle('nonCompact') && (
32
34
  (view.topLevel && item.getType() !== 'group') ||
33
35
  (view.parentView && view.parentView.topLevel && view.binding.getItem().hasStyle('heading'))));
34
- const desc = item.getDescription();
36
+ const desc = utils.getLocalizedValue(item.getDescriptionMap(), context.view.getLocale()).value
37
+
35
38
  if (!compactField && desc) {
36
39
  jquery('<div class="rdformsDescription" tabindex="0">').text(desc).appendTo(rowNode);
37
40
  }
@@ -40,10 +43,10 @@ renderingContext.renderPresenterLabel = (rowNode, binding, item, context, labelR
40
43
  renderingContext.attachItemInfo(item, $labelDiv[0], context);
41
44
  };
42
45
 
43
- renderingContext.attachItemInfo = function (item, aroundNode/* , context */) {
44
- if (item == null || item.getDescription() == null) {
46
+ renderingContext.attachItemInfo = function (item, aroundNode, context) {
47
+ if (item == null || item.getDescriptionMap() == null) {
45
48
  return;
46
49
  }
47
- const desc = item.getDescription();
50
+ const desc = utils.getLocalizedValue(item.getDescriptionMap(), context.view.getLocale()).value
48
51
  aroundNode.setAttribute('title', desc);
49
52
  };
@@ -1,5 +1,6 @@
1
1
  import renderingContext from '../renderingContext';
2
2
  import jquery from 'jquery';
3
+ import utils from '../../utils';
3
4
 
4
5
  renderingContext.addPresenterTable = (newRow, firstBinding, context) => {
5
6
  const item = firstBinding.getItem();
@@ -9,7 +10,8 @@ renderingContext.addPresenterTable = (newRow, firstBinding, context) => {
9
10
  const $tHeadRow = jquery('<tr>').appendTo($table);
10
11
  for (let colInd = 0; colInd < childItems.length; colInd++) {
11
12
  const $th = jquery('<th>').appendTo($tHeadRow);
12
- renderingContext.attachItemInfo(item, jquery('<span>').text(childItems[colInd].getLabel()).appendTo($th), context);
13
+ let label = utils.getLocalizedValue(childItems[colInd].getLabel(), context.view.getLocale()).value
14
+ renderingContext.attachItemInfo(item, jquery('<span>').text(label).appendTo($th), context);
13
15
  }
14
16
  return $table[0];
15
17
  };
@@ -1,4 +1,3 @@
1
- import moment from 'moment';
2
1
  import { escape } from 'lodash-es';
3
2
  import { getDatePresentation, fromDuration } from '../viewUtils';
4
3
  import renderingContext from '../renderingContext';
@@ -35,12 +34,12 @@ presenters.itemtype('group').nodetype('URI').style('linkWithLabel').register((fi
35
34
  const val = binding.getValue();
36
35
  const labelItem = binding.getItem().getChildren().find(i => i.hasStyle('label'));
37
36
  const labelBindings = labelItem ?
38
- renderingContext.filterTranslations(binding.getChildBindingsFor(labelItem), moment.locale(),
37
+ renderingContext.filterTranslations(binding.getChildBindingsFor(labelItem), context.view.getLocale(),
39
38
  context.view.defaultLanguage) : [];
40
39
 
41
40
  const tooltipItem = binding.getItem().getChildren().find(i => i.hasStyle('tooltip'));
42
41
  const tooltipBindings = tooltipItem ?
43
- renderingContext.filterTranslations(binding.getChildBindingsFor(tooltipItem), moment.locale(),
42
+ renderingContext.filterTranslations(binding.getChildBindingsFor(tooltipItem), context.view.getLocale(),
44
43
  context.view.defaultLanguage) : [];
45
44
  const tooltip = tooltipBindings.length > 0 ? tooltipBindings[0].getValue() : val;
46
45
 
@@ -128,9 +127,9 @@ presenters.itemtype('text').datatype('xsd:duration').register((fieldDiv, binding
128
127
  });
129
128
  });
130
129
 
131
- const datePresenter = (fieldDiv, binding) => {
130
+ const datePresenter = (fieldDiv, binding, context) => {
132
131
  try {
133
- const pres = getDatePresentation(binding);
132
+ const pres = getDatePresentation(binding, context.view.getLocale());
134
133
  jquery('<div>').html(pres).appendTo(fieldDiv);
135
134
  } catch (e) {
136
135
  console.warn(`Could not present date, expected ISO8601 format in the form 2001-01-01
@@ -8,6 +8,8 @@ import IconButton from '@mui/material/IconButton';
8
8
  import renderingContext from '../renderingContext';
9
9
  import * as engine from '../../model/engine';
10
10
  import { useNamedGraphId } from './hooks';
11
+ import utils from '../../utils';
12
+
11
13
 
12
14
  renderingContext.addExpandButton = (rowDiv, labelDiv, item, context) => {
13
15
  console.log('Expand button not yet supported');
@@ -107,7 +109,8 @@ renderingContext.addCreateChildButton = (rowDiv, labelDiv, binding, context) =>
107
109
  context.view.addRow(rowDiv, nBinding); // not the first binding...
108
110
  }
109
111
  };
110
- let label = item.getEditLabel() || item.getLabel();
112
+ let labelMap = item.getEditLabelMap() || item.getLabelMap();
113
+ let label = utils.getLocalizedValue(labelMap, context.view.getLocale()).value
111
114
  if (label != null && label !== '') {
112
115
  label = label.charAt(0).toUpperCase() + label.slice(1);
113
116
  } else {