@entryscape/rdforms 10.5.0 → 10.6.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.
- package/dist/rdforms.bmd.js +4 -4
- package/dist/rdforms.bootstrap.js +7 -7
- package/dist/rdforms.jquery.js +3 -3
- package/dist/rdforms.node.js +3 -3
- package/dist/rdforms.react.js +23 -23
- package/index.bmd.js +5 -4
- package/package.json +1 -1
- package/src/model/ChoiceBinding.js +7 -1
- package/src/template/Item.js +46 -51
- package/src/utils.js +1 -1
- package/src/view/Editor.js +4 -0
- package/src/view/Presenter.js +2 -1
- package/src/view/View.js +6 -3
- package/src/view/bootstrap/RadioButtonsEditor.js +4 -4
- package/src/view/bootstrap/choice.js +1 -1
- package/src/view/bootstrap/labels.js +12 -17
- package/src/view/bootstrap/style.css +11 -0
- package/src/view/bootstrap/table.js +5 -1
- package/src/view/bootstrap/text.js +29 -11
- package/src/view/jquery/components.js +12 -4
- package/src/view/jquery/labels.js +5 -1
- package/src/view/react/buttons.js +1 -1
- package/src/view/react/choice.js +16 -7
- package/src/view/react/choiceEditors/CheckBoxesEditor.js +1 -1
- package/src/view/react/choiceEditors/ChoiceLookup.js +2 -1
- package/src/view/react/choiceEditors/ChoiceLookupAndInlineSearch.js +6 -5
- package/src/view/react/choiceEditors/ChoiceSelector.js +2 -1
- package/src/view/react/choiceEditors/RadioButtonsEditor.js +2 -2
- package/src/view/react/components.js +6 -6
- package/src/view/react/date.js +0 -16
- package/src/view/react/hooks.js +17 -9
- package/src/view/react/labels.js +12 -7
- package/src/view/react/textEditors.js +5 -0
- package/src/view/renderingContext.js +2 -2
- package/src/view/resources/rdforms.css +1 -2
package/index.bmd.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import 'whatwg-fetch';
|
|
2
2
|
import 'core-js/stable';
|
|
3
3
|
import 'regenerator-runtime/runtime';
|
|
4
|
+
import bundleLoader from './src/template/bundleLoader';
|
|
5
|
+
import ItemStore from './src/template/ItemStore';
|
|
6
|
+
|
|
4
7
|
import './src/view/bmd/all';
|
|
5
8
|
import './src/view/bmd/style.css';
|
|
6
9
|
|
|
7
|
-
import ItemStore from './src/template/ItemStore';
|
|
8
10
|
import Editor from './src/view/Editor';
|
|
9
11
|
import Presenter from './src/view/Presenter';
|
|
10
|
-
import ValidationPresenter from './src/view/ValidationPresenter';
|
|
11
|
-
import bundleLoader from './src/template/bundleLoader';
|
|
12
12
|
import renderingContext from './src/view/renderingContext';
|
|
13
|
+
import ValidationPresenter from './src/view/ValidationPresenter';
|
|
13
14
|
import LevelEditor from './src/view/bootstrap/LevelEditor';
|
|
14
15
|
|
|
15
|
-
export {bundleLoader, ItemStore, Editor, Presenter, ValidationPresenter, LevelEditor, renderingContext};
|
|
16
|
+
export { bundleLoader, ItemStore, Editor, Presenter, ValidationPresenter, LevelEditor, renderingContext };
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ValueBinding from './ValueBinding';
|
|
2
|
+
import {CODES} from './engine';
|
|
2
3
|
|
|
3
4
|
const label = 'http://www.w3.org/2000/01/rdf-schema#label';
|
|
4
5
|
const seeAlso = 'http://www.w3.org/2000/01/rdf-schema#seeAlso';
|
|
@@ -24,6 +25,11 @@ export default class ChoiceBinding extends ValueBinding {
|
|
|
24
25
|
} else if (this.getValue() !== choice.value) {
|
|
25
26
|
this.setValue(choice.value, choice, silent);
|
|
26
27
|
}
|
|
28
|
+
if (choice && choice.mismatch) {
|
|
29
|
+
this.setMatchingCode(CODES.WRONG_VALUE);
|
|
30
|
+
} else if ((!choice || !choice.mismatch) && this.getMatchingCode() === CODES.WRONG_VALUE) {
|
|
31
|
+
this.setMatchingCode(CODES.OK);
|
|
32
|
+
}
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
getChoice() {
|
|
@@ -31,8 +37,8 @@ export default class ChoiceBinding extends ValueBinding {
|
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
setValue(value, choice, silent) {
|
|
34
|
-
super.setValue(value, choice, silent);
|
|
35
40
|
const oldval = this.getValue();
|
|
41
|
+
super.setValue(value, choice, silent);
|
|
36
42
|
const graph = this._statement.getGraph();
|
|
37
43
|
graph.findAndRemove(oldval, label, undefined, silent);
|
|
38
44
|
graph.findAndRemove(oldval, seeAlso, undefined, silent);
|
package/src/template/Item.js
CHANGED
|
@@ -49,6 +49,7 @@ export default class Item {
|
|
|
49
49
|
'strictmatch',
|
|
50
50
|
'relaxedDatatypeMatch',
|
|
51
51
|
'viewAllTranslations',
|
|
52
|
+
'filterTranslations',
|
|
52
53
|
'email',
|
|
53
54
|
'atLeastOneChild',
|
|
54
55
|
'atMostOneChild',
|
|
@@ -123,65 +124,59 @@ export default class Item {
|
|
|
123
124
|
return this.getExtends() != null;
|
|
124
125
|
}
|
|
125
126
|
|
|
126
|
-
|
|
127
|
+
_getText(attr, returnDetails, original) {
|
|
127
128
|
const s = this.getSource(original);
|
|
128
|
-
return returnDetails ? utils.getLocalizedValue(s
|
|
129
|
+
return returnDetails ? utils.getLocalizedValue(s[attr]) : utils.getLocalizedValue(s[attr]).value;
|
|
129
130
|
}
|
|
130
|
-
|
|
131
|
-
setLabel(value, lang) {
|
|
131
|
+
_setText(attr, value, lang) {
|
|
132
132
|
const s = this.getSource(true);
|
|
133
|
-
s
|
|
133
|
+
s[attr] = this._setLangHash(s[attr], value, lang);
|
|
134
134
|
this.refreshExtends();
|
|
135
135
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return this.getSource(original).label;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
setLabelMap(map) {
|
|
142
|
-
setObjAttr(this.getSource(true), 'label', map);
|
|
143
|
-
this.refreshExtends();
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
getDescription(returnDetails, original) {
|
|
147
|
-
const s = this.getSource(original);
|
|
148
|
-
return returnDetails ? utils.getLocalizedValue(s.description) : utils.getLocalizedValue(s.description).value;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
setDescription(value, lang) {
|
|
152
|
-
const s = this.getSource(true);
|
|
153
|
-
s.description = this._setLangHash(s.description, value, lang);
|
|
136
|
+
_setTextMap(attr, map) {
|
|
137
|
+
setObjAttr(this.getSource(true), attr, map);
|
|
154
138
|
this.refreshExtends();
|
|
155
139
|
}
|
|
156
140
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
141
|
+
getLabel(returnDetails, original) { return this._getText('label', returnDetails, original); }
|
|
142
|
+
setLabel(value, lang) { this._setText('label', value, lang); }
|
|
143
|
+
getLabelMap(original) { return this.getSource(original).label; }
|
|
144
|
+
setLabelMap(map) { this._setTextMap('label', map); }
|
|
145
|
+
|
|
146
|
+
getEditLabel(returnDetails, original) { return this._getText('editlabel', returnDetails, original); }
|
|
147
|
+
setEditLabel(value, lang) { this._setText('editlabel', value, lang); }
|
|
148
|
+
getEditLabelMap(original) { return this.getSource(original).editlabel; }
|
|
149
|
+
setEditLabelMap(map) { this._setTextMap('editlabel', map); }
|
|
150
|
+
|
|
151
|
+
getDescription(returnDetails, original) { return this._getText('description', returnDetails, original); }
|
|
152
|
+
setDescription(value, lang) { this._setText('description', value, lang); }
|
|
153
|
+
getDescriptionMap(original) { return this.getSource(original).description; }
|
|
154
|
+
setDescriptionMap(map) { this._setTextMap('description', map); }
|
|
155
|
+
|
|
156
|
+
getEditDescription(returnDetails, original) { return this._getText('editdescription', returnDetails, original); }
|
|
157
|
+
setEditDescription(value, lang) { this._setText('editdescription', value, lang); }
|
|
158
|
+
getEditDescriptionMap(original) { return this.getSource(original).editdescription; }
|
|
159
|
+
setEditDescriptionMap(map) { this._setTextMap('editdescription', map); }
|
|
160
|
+
|
|
161
|
+
getHelp(returnDetails, original) { return this._getText('help', returnDetails, original); }
|
|
162
|
+
setHelp(value, lang) { this._setText('help', value, lang); }
|
|
163
|
+
getHelpMap(original) { return this.getSource(original).help; }
|
|
164
|
+
setHelpMap(map) { this._setTextMap('help', map); }
|
|
165
|
+
|
|
166
|
+
getPlaceholder(returnDetails, original) { return this._getText('placeholder', returnDetails, original); }
|
|
167
|
+
setPlaceholder(value, lang) { this._setText('placeholder', value, lang); }
|
|
168
|
+
getPlaceholderMap(original) { return this.getSource(original).placeholder; }
|
|
169
|
+
setPlaceholderMap(map) { this._setTextMap('placeholder', map); }
|
|
170
|
+
|
|
171
|
+
getPurpose(returnDetails, original) { return this._getText('purpose', returnDetails, original); }
|
|
172
|
+
setPurpose(value, lang) { this._setText('purpose', value, lang); }
|
|
173
|
+
getPurposeMap(original) { return this.getSource(original).purpose; }
|
|
174
|
+
setPurposeMap(map) { this._setTextMap('purpose', map); }
|
|
175
|
+
|
|
176
|
+
getSpecification(returnDetails, original) { return this._getText('specification', returnDetails, original); }
|
|
177
|
+
setSpecification(value, lang) { this._setText('specification', value, lang); }
|
|
178
|
+
getSpecificationMap(original) { return this.getSource(original).specification; }
|
|
179
|
+
setSpecificationMap(map) { this._setTextMap('specification', map); }
|
|
185
180
|
|
|
186
181
|
/**
|
|
187
182
|
* @return {String|null} as a URI, may be null for Groups, never null for Text or choice
|
package/src/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ import { cloneDeep } from 'lodash-es';
|
|
|
3
3
|
import system from './model/system';
|
|
4
4
|
|
|
5
5
|
const getLocalizedValue = (hash) => {
|
|
6
|
-
const locale = moment.locale(
|
|
6
|
+
const locale = moment.locale();
|
|
7
7
|
if (hash == null) {
|
|
8
8
|
return { precision: 'none' };
|
|
9
9
|
} else if (typeof hash === 'string') {
|
package/src/view/Editor.js
CHANGED
|
@@ -61,6 +61,10 @@ export default class Editor extends Presenter {
|
|
|
61
61
|
super._handleParams(params);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
getSubEditorForBinding(binding) {
|
|
65
|
+
return this._subEditors.find(editor => editor.getBinding() === binding);
|
|
66
|
+
}
|
|
67
|
+
|
|
64
68
|
report(report) {
|
|
65
69
|
const _report = report || bindingReport(this.binding);
|
|
66
70
|
|
package/src/view/Presenter.js
CHANGED
|
@@ -43,7 +43,8 @@ export default class Presenter extends View {
|
|
|
43
43
|
* otherwise same as input bindings.
|
|
44
44
|
*/
|
|
45
45
|
prepareBindings(item, bindings) {
|
|
46
|
-
if (!
|
|
46
|
+
if (!item.hasStyle('filterTranslations') &&
|
|
47
|
+
(!this.filterTranslations || item.getNodetype() !== 'LANGUAGE_LITERAL' || item.hasStyle('viewAllTranslations'))) {
|
|
47
48
|
return bindings;
|
|
48
49
|
}
|
|
49
50
|
|
package/src/view/View.js
CHANGED
|
@@ -263,9 +263,9 @@ export default class View {
|
|
|
263
263
|
|
|
264
264
|
// New rowDiv since we have a label
|
|
265
265
|
if (lastRowNode == null) {
|
|
266
|
-
rowNode = renderingContext.domCreate('div', this.domNode);
|
|
266
|
+
rowNode = renderingContext.domCreate('div', this.domNode, binding ? this.getRowIndex(binding) : undefined);
|
|
267
267
|
} else {
|
|
268
|
-
rowNode = renderingContext.domCreateAfter('div', lastRowNode);
|
|
268
|
+
rowNode = renderingContext.domCreateAfter('div', lastRowNode, binding ? this.getRowIndex(binding) : undefined);
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
item.getClasses().forEach((cls) => {
|
|
@@ -331,7 +331,6 @@ export default class View {
|
|
|
331
331
|
}
|
|
332
332
|
|
|
333
333
|
getLabelIndex(binding) {
|
|
334
|
-
const labelItem = binding.getItem();
|
|
335
334
|
let idx;
|
|
336
335
|
binding.getParent().getChildBindingsFor(binding.getItem()).reverse().find((b) => {
|
|
337
336
|
idx = this._labelIndex[b.getHash()];
|
|
@@ -352,6 +351,10 @@ export default class View {
|
|
|
352
351
|
return idx;
|
|
353
352
|
}
|
|
354
353
|
|
|
354
|
+
getRowIndex(binding) {
|
|
355
|
+
return `${binding.getHash()}_${this._viewId}_row`;
|
|
356
|
+
}
|
|
357
|
+
|
|
355
358
|
isMultiValued(item) {
|
|
356
359
|
return false;
|
|
357
360
|
}
|
|
@@ -5,10 +5,10 @@ export default class RadioButtonsEditor {
|
|
|
5
5
|
this.binding = args.binding;
|
|
6
6
|
this.item = this.binding.getItem();
|
|
7
7
|
this.choices = this.item.getChoices().map(c => ({
|
|
8
|
-
label: c.label,
|
|
8
|
+
label: c.editlabel || c.label,
|
|
9
9
|
description: c.description,
|
|
10
10
|
value: c.value,
|
|
11
|
-
text: this.item._getLocalizedValue(c.label).value,
|
|
11
|
+
text: this.item._getLocalizedValue(c.editlabel || c.label).value,
|
|
12
12
|
choice: c,
|
|
13
13
|
}));
|
|
14
14
|
|
|
@@ -45,7 +45,7 @@ export default class RadioButtonsEditor {
|
|
|
45
45
|
.appendTo($divWrap);
|
|
46
46
|
}
|
|
47
47
|
if (c.description) {
|
|
48
|
-
$label.attr('title', this.item._getLocalizedValue(c.description).value
|
|
48
|
+
$label.attr('title', this.item._getLocalizedValue(c.editdescription || c.description).value
|
|
49
49
|
|| c.seeAlso || c.value);
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -54,7 +54,7 @@ export default class RadioButtonsEditor {
|
|
|
54
54
|
.attr('checked', c.value === currentValue)
|
|
55
55
|
.attr('name', `rdformsRadio_${uniqueRadioButtonGroupNr}`)
|
|
56
56
|
.appendTo($label);
|
|
57
|
-
$label.append(this.item._getLocalizedValue(c.label).value);
|
|
57
|
+
$label.append(this.item._getLocalizedValue(c.editlabel || c.label).value);
|
|
58
58
|
|
|
59
59
|
if (c.mismatch) {
|
|
60
60
|
$label.addClass('mismatch disabled');
|
|
@@ -21,7 +21,7 @@ editors.itemtype('choice').choices().register((fieldDiv, binding, context) => {
|
|
|
21
21
|
const item = binding.getItem();
|
|
22
22
|
const choices = item.getChoices().map(c => ({
|
|
23
23
|
id: c.value,
|
|
24
|
-
text: item._getLocalizedValue(c.label).value,
|
|
24
|
+
text: item._getLocalizedValue(c.editlabel || c.label).value,
|
|
25
25
|
choice: c,
|
|
26
26
|
}));
|
|
27
27
|
if (!item.hasStyle('preserveOrderOfChoices')) {
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import jquery from 'jquery';
|
|
2
2
|
import renderingContext from '../renderingContext';
|
|
3
|
+
import Editor from '../Editor';
|
|
3
4
|
|
|
4
5
|
renderingContext.renderEditorLabel = (rowNode, binding, item, context) => {
|
|
5
6
|
if (item.hasStyle('nonEditable') || item.hasStyle('heading')) {
|
|
6
7
|
return renderingContext.renderPresenterLabel(rowNode, binding, item, context, true);
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
let label = item.getLabel();
|
|
10
|
+
let label = item.getEditLabel() || item.getLabel();
|
|
10
11
|
if (label != null && label !== '') {
|
|
11
12
|
label = label.charAt(0).toUpperCase() + label.slice(1);
|
|
12
13
|
} else {
|
|
13
14
|
label = '';
|
|
14
15
|
}
|
|
15
16
|
const $labelDiv = jquery('<div class="rdformsLabelRow">').appendTo(rowNode);
|
|
17
|
+
if (binding) {
|
|
18
|
+
$labelDiv.attr('id', context.view.createLabelIndex(binding));
|
|
19
|
+
}
|
|
16
20
|
context.labelNode = $labelDiv[0];
|
|
17
21
|
const $label = jquery('<span class="rdformsLabel">').text(label).appendTo($labelDiv);
|
|
18
22
|
const card = item.getCardinality();
|
|
@@ -49,32 +53,23 @@ renderingContext.renderEditorLabel = (rowNode, binding, item, context) => {
|
|
|
49
53
|
}
|
|
50
54
|
return undefined;
|
|
51
55
|
};
|
|
52
|
-
// TODO this is listening for any click and popover showings... too much! especially considering
|
|
53
|
-
// that is being used in another application. Rewrite!
|
|
54
|
-
jquery(document).ready(() => {
|
|
55
|
-
jquery(document.body).on('show.bs.popover click', (e) => {
|
|
56
|
-
jquery('[data-toggle="popover"]').each((node, a) => {
|
|
57
|
-
if (e.target.innerHTML !== a.innerHTML) {
|
|
58
|
-
jquery(a).popover('hide');
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
56
|
|
|
64
|
-
renderingContext.attachItemInfo = function (item, aroundNode
|
|
65
|
-
if (item == null || (item.getProperty() == null && item.getDescription() == null
|
|
57
|
+
renderingContext.attachItemInfo = function (item, aroundNode, context) {
|
|
58
|
+
if (item == null || (item.getProperty() == null && item.getDescription() == null
|
|
59
|
+
&& item.getEditDescription() == null)) {
|
|
66
60
|
jquery(aroundNode).addClass('noPointer');
|
|
67
61
|
return;
|
|
68
62
|
}
|
|
69
63
|
|
|
70
|
-
const description =
|
|
64
|
+
const description = (context.view instanceof Editor ?
|
|
65
|
+
item.getEditDescription() || item.getDescription() : item.getDescription()) || '';
|
|
71
66
|
let propinfo = '';
|
|
72
67
|
if (item.getProperty()) {
|
|
73
68
|
propinfo = `<div class="property"><a target="_blank" href="${item.getProperty()}">${
|
|
74
69
|
item.getProperty()}</a></div>`;
|
|
75
70
|
}
|
|
76
71
|
|
|
77
|
-
let label = item.getLabel();
|
|
72
|
+
let label = context.view instanceof Editor ? item.getEditLabel() || item.getLabel() : item.getLabel();
|
|
78
73
|
if (label != null && label !== '') {
|
|
79
74
|
label = label.charAt(0).toUpperCase() + label.slice(1);
|
|
80
75
|
} else {
|
|
@@ -84,7 +79,7 @@ renderingContext.attachItemInfo = function (item, aroundNode/* , context */) {
|
|
|
84
79
|
html: true,
|
|
85
80
|
container: renderingContext.getPopoverContainer(),
|
|
86
81
|
placement: 'auto',
|
|
87
|
-
trigger: '
|
|
82
|
+
trigger: 'focus',
|
|
88
83
|
title: label,
|
|
89
84
|
content: `<div class="description">${
|
|
90
85
|
description.replace(/(\r\n|\r|\n)/g, '<br/>')
|
|
@@ -32,6 +32,17 @@
|
|
|
32
32
|
background-color: lightcoral;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
.rdformsHelp {
|
|
36
|
+
color: red;
|
|
37
|
+
font-size: small;
|
|
38
|
+
display: none;
|
|
39
|
+
padding: 2px 0 6px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.rdformsHelp.rdformsHelpActive {
|
|
43
|
+
display: block;
|
|
44
|
+
}
|
|
45
|
+
|
|
35
46
|
.rdformsDateValue .rdformsDatepicker {
|
|
36
47
|
width: 12em;
|
|
37
48
|
display: inline-block;
|
|
@@ -2,6 +2,7 @@ import renderingContext from '../renderingContext';
|
|
|
2
2
|
import * as engine from '../../model/engine';
|
|
3
3
|
import utils from '../../utils';
|
|
4
4
|
import jquery from 'jquery';
|
|
5
|
+
import Editor from '../Editor';
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
const createChildBindingsForFirstFixedColumn = (bindings/* , context*/) => {
|
|
@@ -108,8 +109,11 @@ renderingContext.addEditorTable = (newRow, firstBinding, context) => {
|
|
|
108
109
|
for (colInd = 0; colInd < childItems.length; colInd++) {
|
|
109
110
|
const $th = jquery('<th>').appendTo($tHeadRow);
|
|
110
111
|
jquery($th).addClass(`rdformsColumnHeader${colInd}`);
|
|
112
|
+
const childItem = childItems[colInd];
|
|
113
|
+
const label = context.view instanceof Editor ?
|
|
114
|
+
childItem.getEditLabel() || childItem.getLabel() : childItem.getLabel();
|
|
111
115
|
renderingContext.attachItemInfo(item,
|
|
112
|
-
jquery('<span>').text(
|
|
116
|
+
jquery('<span>').text(label).appendTo($th)[0], context);
|
|
113
117
|
}
|
|
114
118
|
if (!firstBinding.getItem().hasStyle('firstcolumnfixedtable')) {
|
|
115
119
|
const $addTh = jquery('<th>').addClass('rdformsTableControl').appendTo($tHeadRow);
|
|
@@ -32,18 +32,21 @@ editors.itemtype('text').datatype('xsd:duration').register(durationEditor);
|
|
|
32
32
|
tb.set('value', '');
|
|
33
33
|
}; */
|
|
34
34
|
|
|
35
|
-
const addChangeListener = (inp, binding, regex, extLink) => {
|
|
35
|
+
const addChangeListener = (inp, binding, regex, extLink, help) => {
|
|
36
36
|
let to = null;
|
|
37
37
|
const s = () => {
|
|
38
38
|
to = null;
|
|
39
|
-
const val = inp.val();
|
|
39
|
+
const val = inp.val().trim();
|
|
40
40
|
let disableExtLink = true;
|
|
41
|
-
if (!regex || regex.test(val)) {
|
|
41
|
+
if (val === '' || !regex || regex.test(val)) {
|
|
42
42
|
binding.setGist(val);
|
|
43
43
|
if (extLink && val) {
|
|
44
44
|
extLink.prop('href', binding.getValue());
|
|
45
45
|
disableExtLink = false;
|
|
46
46
|
}
|
|
47
|
+
help.toggleClass('rdformsHelpActive', false);
|
|
48
|
+
} else {
|
|
49
|
+
help.toggleClass('rdformsHelpActive', true);
|
|
47
50
|
}
|
|
48
51
|
if (extLink) {
|
|
49
52
|
extLink.toggleClass('rdformsExtLinkDisabled', disableExtLink);
|
|
@@ -63,19 +66,27 @@ const registerPattern = (pattern, datatype) => {
|
|
|
63
66
|
const regex = new RegExp(pattern);
|
|
64
67
|
editors.itemtype('text').datatype(datatype)
|
|
65
68
|
.register((fieldDiv, binding, context) => {
|
|
66
|
-
const $input = jquery(
|
|
69
|
+
const $input = jquery(`<input type="text" class="form-control rdformsFieldInput"
|
|
70
|
+
placeholder="${binding.getItem().getPlaceholder() || ''}">`);
|
|
67
71
|
$input.val(binding.getGist())
|
|
68
72
|
.attr('pattern', pattern)
|
|
69
73
|
.appendTo(fieldDiv);
|
|
70
74
|
|
|
75
|
+
const help = binding.getItem().getHelp();
|
|
76
|
+
let $help;
|
|
77
|
+
if (help) {
|
|
78
|
+
$help = jquery(`<span class="rdformsHelp">${help}</span>`);
|
|
79
|
+
$help.appendTo(fieldDiv);
|
|
80
|
+
}
|
|
81
|
+
|
|
71
82
|
if (binding.getItem().hasStyle('externalLink')) {
|
|
72
83
|
const $extLink = jquery(`<a class="fas fa-external-link-alt rdformsExtLink ${renderingContext.getExtLinkClass()}" target="_blank">`);
|
|
73
84
|
$extLink.appendTo(context.controlDiv);
|
|
74
85
|
jquery(fieldDiv).addClass('rdformsExtLinkControl');
|
|
75
|
-
addChangeListener($input, binding, regex, $extLink);
|
|
86
|
+
addChangeListener($input, binding, regex, $extLink, $help);
|
|
76
87
|
$input.keyup();
|
|
77
88
|
} else {
|
|
78
|
-
addChangeListener($input, binding, regex);
|
|
89
|
+
addChangeListener($input, binding, regex, undefined, $help);
|
|
79
90
|
}
|
|
80
91
|
|
|
81
92
|
|
|
@@ -98,7 +109,7 @@ editors.itemtype('text').register((fieldDiv, binding, context) => {
|
|
|
98
109
|
let $input;
|
|
99
110
|
if (item.hasStyle('multiline')) {
|
|
100
111
|
const originalNrOfLines = countLines(binding.getGist());
|
|
101
|
-
$input = jquery(`<textarea class="form-control rdformsFieldInput autoExpand" rows="${originalNrOfLines}">`);
|
|
112
|
+
$input = jquery(`<textarea class="form-control rdformsFieldInput autoExpand" placeholder="${item.getPlaceholder() || ''}" rows="${originalNrOfLines}">`);
|
|
102
113
|
$input.on('input focus', function () {
|
|
103
114
|
if (this.baseScrollHeight === undefined) {
|
|
104
115
|
const originalHeight = $input.height();
|
|
@@ -110,13 +121,20 @@ editors.itemtype('text').register((fieldDiv, binding, context) => {
|
|
|
110
121
|
this.rows = rows;
|
|
111
122
|
});
|
|
112
123
|
} else if (item.hasStyle('email')) {
|
|
113
|
-
$input = jquery(
|
|
124
|
+
$input = jquery(`<input type="email" class="form-control rdformsFieldInput" placeholder="${item.getPlaceholder() || ''}">`);
|
|
114
125
|
} else {
|
|
115
|
-
$input = jquery(
|
|
126
|
+
$input = jquery(`<input type="text" class="form-control rdformsFieldInput" placeholder="${item.getPlaceholder() || ''}">`);
|
|
116
127
|
}
|
|
117
128
|
$input.val(binding.getGist())
|
|
118
129
|
.appendTo(fieldDiv);
|
|
119
130
|
|
|
131
|
+
const help = item.getHelp();
|
|
132
|
+
let $help;
|
|
133
|
+
if (help) {
|
|
134
|
+
$help = jquery(`<span class="rdformsHelp">${help}</span>`);
|
|
135
|
+
$help.appendTo(fieldDiv);
|
|
136
|
+
}
|
|
137
|
+
|
|
120
138
|
const pattern = item.getPattern();
|
|
121
139
|
let regex = null;
|
|
122
140
|
if (pattern != null) {
|
|
@@ -127,10 +145,10 @@ editors.itemtype('text').register((fieldDiv, binding, context) => {
|
|
|
127
145
|
const $extLink = jquery(`<a class="fas fa-external-link-alt rdformsExtLink ${renderingContext.getExtLinkClass()}" target="_blank">`);
|
|
128
146
|
$extLink.appendTo(context.controlDiv);
|
|
129
147
|
jquery(fieldDiv).addClass('rdformsExtLinkControl');
|
|
130
|
-
addChangeListener($input, binding, regex, $extLink);
|
|
148
|
+
addChangeListener($input, binding, regex, $extLink, $help);
|
|
131
149
|
$input.keyup();
|
|
132
150
|
} else {
|
|
133
|
-
addChangeListener($input, binding, regex);
|
|
151
|
+
addChangeListener($input, binding, regex, undefined, $help);
|
|
134
152
|
}
|
|
135
153
|
|
|
136
154
|
// If language control should be present
|
|
@@ -4,12 +4,20 @@ import './text';
|
|
|
4
4
|
import './choice';
|
|
5
5
|
import './table';
|
|
6
6
|
|
|
7
|
+
const createElement = (nodeStr, id) => {
|
|
8
|
+
const el = document.createElement(nodeStr);
|
|
9
|
+
if (id) {
|
|
10
|
+
el.id = id;
|
|
11
|
+
}
|
|
12
|
+
return el;
|
|
13
|
+
};
|
|
14
|
+
|
|
7
15
|
renderingContext.domQuery = (selector, node) => node.querySelector(selector);
|
|
8
16
|
|
|
9
|
-
renderingContext.domCreate = (nodeStr, parent) => parent.appendChild(
|
|
17
|
+
renderingContext.domCreate = (nodeStr, parent, id) => parent.appendChild(createElement(nodeStr, id));
|
|
10
18
|
|
|
11
|
-
renderingContext.domCreateAfter = (nodeStr, sibling) =>
|
|
12
|
-
sibling.parentNode.insertBefore(
|
|
19
|
+
renderingContext.domCreateAfter = (nodeStr, sibling, id) =>
|
|
20
|
+
sibling.parentNode.insertBefore(createElement(nodeStr, id), sibling.nextSibling);
|
|
13
21
|
|
|
14
22
|
renderingContext.domSetAttr = (node, attr, value) => {
|
|
15
23
|
if (value === '' || value === null) {
|
|
@@ -33,4 +41,4 @@ renderingContext.domClassToggle = (node, classStr, addOrRemove) => {
|
|
|
33
41
|
});
|
|
34
42
|
};
|
|
35
43
|
|
|
36
|
-
renderingContext.prePresenterViewRenderer = renderingContext.preEditorViewRenderer;
|
|
44
|
+
renderingContext.prePresenterViewRenderer = renderingContext.preEditorViewRenderer;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import jquery from 'jquery';
|
|
2
2
|
import renderingContext from '../renderingContext';
|
|
3
|
+
import Editor from '../Editor';
|
|
3
4
|
|
|
4
5
|
renderingContext.renderPresenterLabel = (rowNode, binding, item, context, labelRow) => {
|
|
5
|
-
let label = item.getLabel();
|
|
6
|
+
let label = context.view instanceof Editor ? item.getEditLabel() || item.getLabel() : item.getLabel();
|
|
6
7
|
if (label != null && label !== '') {
|
|
7
8
|
label = label.charAt(0).toUpperCase() + label.slice(1);
|
|
8
9
|
} else {
|
|
@@ -10,6 +11,9 @@ renderingContext.renderPresenterLabel = (rowNode, binding, item, context, labelR
|
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
const $labelDiv = jquery('<div class="rdformsLabel" tabindex="0">').text(label).appendTo(rowNode);
|
|
14
|
+
if (binding) {
|
|
15
|
+
$labelDiv.attr('id', context.view.createLabelIndex(binding));
|
|
16
|
+
}
|
|
13
17
|
if (labelRow) {
|
|
14
18
|
$labelDiv.addClass('rdformsLabelRow');
|
|
15
19
|
}
|
|
@@ -104,7 +104,7 @@ renderingContext.addCreateChildButton = (rowDiv, labelDiv, binding, context) =>
|
|
|
104
104
|
context.view.addRow(rowDiv, nBinding); // not the first binding...
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
|
-
let label = item.getLabel();
|
|
107
|
+
let label = item.getEditLabel() || item.getLabel();
|
|
108
108
|
if (label != null && label !== '') {
|
|
109
109
|
label = label.charAt(0).toUpperCase() + label.slice(1);
|
|
110
110
|
} else {
|
package/src/view/react/choice.js
CHANGED
|
@@ -3,20 +3,26 @@ import React, { useState, useEffect } from 'react';
|
|
|
3
3
|
import renderingContext from '../renderingContext';
|
|
4
4
|
import system from '../../model/system';
|
|
5
5
|
import utils from '../../utils';
|
|
6
|
+
import { Editor } from './Wrappers';
|
|
6
7
|
|
|
7
8
|
// -------------- Presenters ----------------
|
|
8
9
|
const presenters = renderingContext.presenterRegistry;
|
|
9
10
|
|
|
10
|
-
const choicify = func => (fieldDiv, binding) => {
|
|
11
|
+
const choicify = func => (fieldDiv, binding, context) => {
|
|
11
12
|
const choice = binding.getChoice();
|
|
13
|
+
const isEditor = context.view instanceof Editor;
|
|
12
14
|
let desc;
|
|
13
15
|
if (!choice) {
|
|
14
16
|
return;
|
|
15
17
|
}
|
|
16
|
-
|
|
18
|
+
|
|
19
|
+
if (isEditor && choice.editdescription) {
|
|
20
|
+
desc = utils.getLocalizedValue(choice.editdescription).value;
|
|
21
|
+
} else if (choice.description) {
|
|
17
22
|
desc = utils.getLocalizedValue(choice.description).value;
|
|
18
23
|
}
|
|
19
|
-
|
|
24
|
+
|
|
25
|
+
func(fieldDiv, binding, choice, desc, isEditor);
|
|
20
26
|
};
|
|
21
27
|
|
|
22
28
|
// Presenter for image.
|
|
@@ -34,13 +40,16 @@ presenters.itemtype('choice').style('stars').register(choicify(
|
|
|
34
40
|
}
|
|
35
41
|
}));
|
|
36
42
|
|
|
43
|
+
const getLocalizedLabel = (choice, isEditor) =>
|
|
44
|
+
utils.getLocalizedValue(isEditor ? choice.editlabel || choice.label : choice.label);
|
|
45
|
+
|
|
37
46
|
// Presenter for choices.
|
|
38
47
|
presenters.itemtype('choice').register(choicify(
|
|
39
|
-
(fieldDiv, binding, choice, desc) => {
|
|
48
|
+
(fieldDiv, binding, choice, desc, isEditor) => {
|
|
40
49
|
const item = binding.getItem();
|
|
41
50
|
const title = desc || choice.seeAlso || choice.value;
|
|
42
51
|
if ((item.hasStaticChoices() && !item.hasStyle('externalLink')) || item.hasStyle('noLink')) {
|
|
43
|
-
const locValue =
|
|
52
|
+
const locValue = getLocalizedLabel(choice, isEditor);
|
|
44
53
|
const langAttr = locValue.lang ? { lang: locValue.lang } : {};
|
|
45
54
|
fieldDiv.appendChild(<div key={binding.getHash()} {...langAttr} title={title} src={choice.value
|
|
46
55
|
}>{locValue.value}</div>);
|
|
@@ -55,11 +64,11 @@ presenters.itemtype('choice').register(choicify(
|
|
|
55
64
|
delete attrs.component;
|
|
56
65
|
|
|
57
66
|
fieldDiv.appendChild(React.createElement(() => {
|
|
58
|
-
const [locValue, setLocValue] = useState(
|
|
67
|
+
const [locValue, setLocValue] = useState(getLocalizedLabel(choice, isEditor));
|
|
59
68
|
useEffect(() => {
|
|
60
69
|
if (choice.load != null) {
|
|
61
70
|
choice.load(() => {
|
|
62
|
-
setLocValue(
|
|
71
|
+
setLocValue(getLocalizedLabel(choice, isEditor));
|
|
63
72
|
});
|
|
64
73
|
}
|
|
65
74
|
}, []);
|
|
@@ -25,7 +25,7 @@ export default function CheckBoxesEditor(props) {
|
|
|
25
25
|
const [resetCount, setResetCount] = React.useState(0);
|
|
26
26
|
const binding = props.binding;
|
|
27
27
|
const item = binding.getItem();
|
|
28
|
-
const choices = useLocalizedSortedChoices(binding);
|
|
28
|
+
const choices = useLocalizedSortedChoices(binding, true);
|
|
29
29
|
const choiceBindingPairs = useMemo(() => {
|
|
30
30
|
const parentBinding = binding.getParent();
|
|
31
31
|
const val2binding = {};
|
|
@@ -8,7 +8,7 @@ import ShowButton from './ShowButton';
|
|
|
8
8
|
|
|
9
9
|
export default (props) => {
|
|
10
10
|
const binding = props.binding;
|
|
11
|
-
const [choice, setChoice] = loadLocalizedChoice(binding);
|
|
11
|
+
const [choice, setChoice] = loadLocalizedChoice(binding, true);
|
|
12
12
|
const [error, setError] = useState(binding.getChoice()?.mismatch === true);
|
|
13
13
|
|
|
14
14
|
useEffect(() => {
|
|
@@ -44,6 +44,7 @@ export default (props) => {
|
|
|
44
44
|
disabled {...(choice && choice.mismatch ? { mismatch: true } : {})}
|
|
45
45
|
title={title}
|
|
46
46
|
value={label}
|
|
47
|
+
placeholder={binding.getItem().getPlaceholder()}
|
|
47
48
|
error={error}
|
|
48
49
|
variant={renderingContext.materialVariant}
|
|
49
50
|
/><ShowButton
|