@entryscape/rdforms 10.6.0 → 10.6.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/dist/rdforms.bmd.js +5 -5
- package/dist/rdforms.bootstrap.js +9 -9
- package/dist/rdforms.jquery.js +3 -3
- package/dist/rdforms.node.js +1 -1
- package/dist/rdforms.react.js +23 -23
- package/package.json +2 -1
- package/src/model/CODES.js +17 -0
- package/src/model/CardinalityTracker.js +2 -1
- package/src/model/ChoiceBinding.js +1 -1
- package/src/model/engine.js +1 -19
- package/src/model/validate.js +21 -20
- package/src/view/Editor.js +4 -3
- package/src/view/ValidationPresenter.js +2 -1
- package/src/view/react/labels.js +1 -1
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"application profile",
|
|
9
9
|
"linked data"
|
|
10
10
|
],
|
|
11
|
-
"version": "10.6.
|
|
11
|
+
"version": "10.6.1",
|
|
12
12
|
"main": "dist/rdforms.node.js",
|
|
13
13
|
"browser": "dist/rdforms.react.js",
|
|
14
14
|
"module": "main.js",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"bootstrap-material-datetimepicker": "https://bitbucket.org/metasolutions/bootstrap-material-datetimepicker.git#webpack",
|
|
30
30
|
"bootstrap-material-design": "^4.1.1",
|
|
31
31
|
"core-js": "^3.1.4",
|
|
32
|
+
"circular-dependency-plugin": "^5.2.2",
|
|
32
33
|
"ifdef-loader": "^2.1.1",
|
|
33
34
|
"jquery": "^3.3.1",
|
|
34
35
|
"jquery-mousewheel": "^3.1.13",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
UNKNOWN: 'unknown', // Used as a marker initially, to not mark everything red initially
|
|
3
|
+
OK: 'correct',
|
|
4
|
+
TOO_FEW_VALUES: 'few', // deprecated
|
|
5
|
+
TOO_FEW_VALUES_MIN: 'min',
|
|
6
|
+
TOO_FEW_VALUES_PREF: 'pref',
|
|
7
|
+
TOO_MANY_VALUES: 'many',
|
|
8
|
+
AT_MOST_ONE_CHILD: 'atmostonechild',
|
|
9
|
+
AT_LEAST_ONE_CHILD: 'atleastonechild',
|
|
10
|
+
EXACTLY_ONE_CHILD: 'exactlyonechild',
|
|
11
|
+
WRONG_VALUE: 'value',
|
|
12
|
+
WRONG_PATTERN: 'pattern',
|
|
13
|
+
WRONG_NODETYPE: 'nodetype',
|
|
14
|
+
WRONG_DATATYPE: 'datatype',
|
|
15
|
+
MISSING_LANGUAGE: 'language',
|
|
16
|
+
MISSING_CONSTRAINTS: 'constraints',
|
|
17
|
+
};
|
package/src/model/engine.js
CHANGED
|
@@ -11,6 +11,7 @@ import ValueBinding from './ValueBinding';
|
|
|
11
11
|
import ChoiceBinding from './ChoiceBinding';
|
|
12
12
|
import GroupURIBinding from './GroupURIBinding';
|
|
13
13
|
import utils from '../utils';
|
|
14
|
+
import CODES from './CODES';
|
|
14
15
|
|
|
15
16
|
// See public API at the bottom of this file.
|
|
16
17
|
|
|
@@ -871,27 +872,8 @@ export { levelProfile };
|
|
|
871
872
|
*/
|
|
872
873
|
export { detectLevel };
|
|
873
874
|
|
|
874
|
-
const CODES = {
|
|
875
|
-
UNKNOWN: 'unknown', // Used as a marker initially, to not mark everything red initially
|
|
876
|
-
OK: 'correct',
|
|
877
|
-
TOO_FEW_VALUES: 'few', // deprecated
|
|
878
|
-
TOO_FEW_VALUES_MIN: 'min',
|
|
879
|
-
TOO_FEW_VALUES_PREF: 'pref',
|
|
880
|
-
TOO_MANY_VALUES: 'many',
|
|
881
|
-
AT_MOST_ONE_CHILD: 'atmostonechild',
|
|
882
|
-
AT_LEAST_ONE_CHILD: 'atleastonechild',
|
|
883
|
-
EXACTLY_ONE_CHILD: 'exactlyonechild',
|
|
884
|
-
WRONG_VALUE: 'value',
|
|
885
|
-
WRONG_PATTERN: 'pattern',
|
|
886
|
-
WRONG_NODETYPE: 'nodetype',
|
|
887
|
-
WRONG_DATATYPE: 'datatype',
|
|
888
|
-
MISSING_LANGUAGE: 'language',
|
|
889
|
-
MISSING_CONSTRAINTS: 'constraints',
|
|
890
|
-
};
|
|
891
|
-
|
|
892
875
|
export { CODES };
|
|
893
876
|
|
|
894
|
-
|
|
895
877
|
export default { // TODO @valentino anti-pattern. This is done because engine is used in EntryScape. It shouldn't really...
|
|
896
878
|
detectLevel,
|
|
897
879
|
levelProfile,
|
package/src/model/validate.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { namespaces as ns } from '@entryscape/rdfjson';
|
|
2
|
-
import
|
|
2
|
+
import { fuzzyMatch, findBindingRelativeToParentBinding, matchPathBelowBinding } from './engine';
|
|
3
|
+
import CODES from './CODES';
|
|
3
4
|
|
|
4
5
|
const _clearMatchingCodes = (binding) => {
|
|
5
|
-
binding.setMatchingCode(
|
|
6
|
+
binding.setMatchingCode(CODES.OK);
|
|
6
7
|
if (binding.getItem().getType() === 'group') {
|
|
7
8
|
binding.getChildBindings().forEach(childBinding => _clearMatchingCodes(childBinding));
|
|
8
9
|
}
|
|
@@ -66,8 +67,8 @@ const doNotProceedFurther = (groupBinding, childItem) => {
|
|
|
66
67
|
// Don't check further if the binding is hidden due to missing dependencies
|
|
67
68
|
const childPath = childItem.getDeps();
|
|
68
69
|
if (childPath) {
|
|
69
|
-
const fromBinding =
|
|
70
|
-
if (!
|
|
70
|
+
const fromBinding = findBindingRelativeToParentBinding(groupBinding, childPath);
|
|
71
|
+
if (!matchPathBelowBinding(fromBinding, childPath)) {
|
|
71
72
|
return true;
|
|
72
73
|
}
|
|
73
74
|
}
|
|
@@ -75,7 +76,7 @@ const doNotProceedFurther = (groupBinding, childItem) => {
|
|
|
75
76
|
};
|
|
76
77
|
|
|
77
78
|
const _createReport = (groupbinding, report, firstLevel) => {
|
|
78
|
-
if (groupbinding.getMatchingCode() !==
|
|
79
|
+
if (groupbinding.getMatchingCode() !== CODES.OK) {
|
|
79
80
|
return undefined;
|
|
80
81
|
}
|
|
81
82
|
const groupitem = groupbinding.getItem();
|
|
@@ -84,8 +85,8 @@ const _createReport = (groupbinding, report, firstLevel) => {
|
|
|
84
85
|
// Check disabled since it is done for each child before recursive call
|
|
85
86
|
/* const path = groupitem.getDeps();
|
|
86
87
|
if (path && groupbinding.getParent() != null) {
|
|
87
|
-
const fromBinding =
|
|
88
|
-
if (!
|
|
88
|
+
const fromBinding = findBindingRelativeToParentBinding(groupbinding.getParent(), path);
|
|
89
|
+
if (!matchPathBelowBinding(fromBinding, path)) {
|
|
89
90
|
return undefined;
|
|
90
91
|
}
|
|
91
92
|
} */
|
|
@@ -101,11 +102,11 @@ const _createReport = (groupbinding, report, firstLevel) => {
|
|
|
101
102
|
const nrOfValid = _countValidBindings(bindings);
|
|
102
103
|
let code;
|
|
103
104
|
if (nrOfValid > 1 && (groupitem.hasStyle('disjoint') || groupitem.hasStyle('atMostOneChild'))) {
|
|
104
|
-
code =
|
|
105
|
+
code = CODES.AT_MOST_ONE_CHILD;
|
|
105
106
|
} else if (nrOfValid !== 1 && groupitem.hasStyle('exactlyOneChild')) {
|
|
106
|
-
code =
|
|
107
|
+
code = CODES.EXACTLY_ONE_CHILD;
|
|
107
108
|
} else if (nrOfValid === 0 && groupitem.hasStyle('atLeastOneChild')) {
|
|
108
|
-
code =
|
|
109
|
+
code = CODES.AT_LEAST_ONE_CHILD;
|
|
109
110
|
}
|
|
110
111
|
if (code) {
|
|
111
112
|
updateViaCardinalityTracker([groupbinding], code);
|
|
@@ -129,15 +130,15 @@ const _createReport = (groupbinding, report, firstLevel) => {
|
|
|
129
130
|
report.errors.push({
|
|
130
131
|
parentBinding: groupbinding,
|
|
131
132
|
item: childItem,
|
|
132
|
-
code:
|
|
133
|
+
code: CODES.TOO_FEW_VALUES_MIN,
|
|
133
134
|
});
|
|
134
|
-
updateViaCardinalityTracker(bindings,
|
|
135
|
+
updateViaCardinalityTracker(bindings, CODES.TOO_FEW_VALUES_MIN);
|
|
135
136
|
/* let counter = 0;
|
|
136
137
|
bindings.forEach((binding) => {
|
|
137
138
|
if (!binding.isValid()) {
|
|
138
139
|
if (counter < card.min) {
|
|
139
140
|
counter += 1;
|
|
140
|
-
binding.setMatchingCode(
|
|
141
|
+
binding.setMatchingCode(CODES.TOO_FEW_VALUES_MIN);
|
|
141
142
|
}
|
|
142
143
|
}
|
|
143
144
|
}); */
|
|
@@ -145,23 +146,23 @@ const _createReport = (groupbinding, report, firstLevel) => {
|
|
|
145
146
|
report.warnings.push({
|
|
146
147
|
parentBinding: groupbinding,
|
|
147
148
|
item: childItem,
|
|
148
|
-
code:
|
|
149
|
+
code: CODES.TOO_FEW_VALUES_PREF,
|
|
149
150
|
});
|
|
150
|
-
// updateViaCardinalityTracker(bindings,
|
|
151
|
+
// updateViaCardinalityTracker(bindings, CODES.TOO_FEW_VALUES_PREF);
|
|
151
152
|
}
|
|
152
153
|
if (card.max != null && card.max < nrOfValid) {
|
|
153
154
|
report.errors.push({
|
|
154
155
|
parentBinding: groupbinding,
|
|
155
156
|
item: childItem,
|
|
156
|
-
code:
|
|
157
|
+
code: CODES.TOO_MANY_VALUES,
|
|
157
158
|
});
|
|
158
|
-
updateViaCardinalityTracker(bindings,
|
|
159
|
+
updateViaCardinalityTracker(bindings, CODES.TOO_MANY_VALUES);
|
|
159
160
|
/* let counter = 0;
|
|
160
161
|
bindings.forEach((binding) => {
|
|
161
162
|
if (binding.isValid()) {
|
|
162
163
|
counter += 1;
|
|
163
164
|
if (counter > card.max) {
|
|
164
|
-
binding.setMatchingCode(
|
|
165
|
+
binding.setMatchingCode(CODES.TOO_MANY_VALUES);
|
|
165
166
|
}
|
|
166
167
|
}
|
|
167
168
|
}); */
|
|
@@ -172,7 +173,7 @@ const _createReport = (groupbinding, report, firstLevel) => {
|
|
|
172
173
|
|
|
173
174
|
groupbinding.getChildBindings().forEach((binding) => {
|
|
174
175
|
const item = binding.getItem();
|
|
175
|
-
if (binding.getMatchingCode() !==
|
|
176
|
+
if (binding.getMatchingCode() !== CODES.OK) {
|
|
176
177
|
report.errors.push({
|
|
177
178
|
parentBinding: binding,
|
|
178
179
|
item,
|
|
@@ -330,7 +331,7 @@ const _simplifyReport = (report) => {
|
|
|
330
331
|
};
|
|
331
332
|
|
|
332
333
|
const _resourceReport = (resource, graph, template, ignoreResources) => {
|
|
333
|
-
const binding =
|
|
334
|
+
const binding = fuzzyMatch(graph, resource, template);
|
|
334
335
|
const report = bindingReport(binding);
|
|
335
336
|
_filterReport(report, resource, ignoreResources || {});
|
|
336
337
|
_simplifyReport(report);
|
package/src/view/Editor.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import renderingContext from './renderingContext';
|
|
2
2
|
import Presenter from './Presenter';
|
|
3
|
+
import CODES from '../model/CODES';
|
|
3
4
|
import * as engine from '../model/engine';
|
|
4
5
|
import { bindingReport } from '../model/validate';
|
|
5
6
|
|
|
@@ -74,7 +75,7 @@ export default class Editor extends Presenter {
|
|
|
74
75
|
for (let j = 0; j < _report.errors.length; j++) {
|
|
75
76
|
const err = _report.errors[j];
|
|
76
77
|
if (err.parentBinding === this.binding) {
|
|
77
|
-
if (err.code ===
|
|
78
|
+
if (err.code === CODES.TOO_FEW_VALUES_MIN) {
|
|
78
79
|
const item = err.item;
|
|
79
80
|
let counter = item.getCardinality().min;
|
|
80
81
|
|
|
@@ -86,9 +87,9 @@ export default class Editor extends Presenter {
|
|
|
86
87
|
}
|
|
87
88
|
return counter === 0;
|
|
88
89
|
});
|
|
89
|
-
} else if (err.code ===
|
|
90
|
+
} else if (err.code === CODES.AT_MOST_ONE_CHILD) {
|
|
90
91
|
this.binding.getChildBindings().forEach((binding) => {
|
|
91
|
-
if (binding.getMatchingCode() !==
|
|
92
|
+
if (binding.getMatchingCode() !== CODES.OK) {
|
|
92
93
|
renderingContext.domClassToggle(this._binding2node[binding.getHash()],
|
|
93
94
|
'errorReport', true);
|
|
94
95
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import renderingContext from './renderingContext';
|
|
2
2
|
import Presenter from './Presenter';
|
|
3
|
-
import
|
|
3
|
+
import CODES from '../model/CODES';
|
|
4
|
+
import engine from '../model/engine';
|
|
4
5
|
import { bindingReport } from '../model/validate';
|
|
5
6
|
|
|
6
7
|
const localize = (bundle, key, val) => {
|
package/src/view/react/labels.js
CHANGED
|
@@ -5,7 +5,7 @@ import { styled } from '@mui/material/styles';
|
|
|
5
5
|
import ClickAwayListener from '@mui/material/ClickAwayListener';
|
|
6
6
|
import renderingContext from '../renderingContext';
|
|
7
7
|
import { Editor } from './Wrappers';
|
|
8
|
-
import
|
|
8
|
+
import CODES from '../../model/CODES';
|
|
9
9
|
|
|
10
10
|
const StyledTooltip = styled(
|
|
11
11
|
forwardRef(({ className, ...props }, ref) => (
|