@jinntec/fore 1.1.0 → 1.2.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/fore-dev.js +3 -3
- package/dist/fore-dev.js.map +1 -1
- package/dist/fore.js +3 -3
- package/dist/fore.js.map +1 -1
- package/package.json +1 -1
- package/src/ForeElementMixin.js +1 -1
- package/src/actions/abstract-action.js +9 -3
- package/src/actions/fx-action.js +1 -0
- package/src/actions/fx-refresh.js +9 -0
- package/src/actions/fx-replace.js +1 -0
- package/src/fx-bind.js +1 -1
- package/src/fx-fore.js +7 -7
- package/src/fx-model.js +1 -4
- package/src/fx-submission.js +2 -3
- package/src/ui/abstract-control.js +7 -6
- package/src/ui/fx-container.js +1 -1
- package/src/ui/fx-control.js +6 -0
- package/src/ui/fx-inspector.js +0 -2
- package/src/ui/fx-output.js +3 -1
- package/src/xpath-evaluation.js +3 -1
package/package.json
CHANGED
package/src/ForeElementMixin.js
CHANGED
|
@@ -120,7 +120,8 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
120
120
|
if(e && e.code){
|
|
121
121
|
const vars = new Map();
|
|
122
122
|
vars.set('code',e.code);
|
|
123
|
-
this.setInScopeVariables(vars);
|
|
123
|
+
// this.setInScopeVariables(vars);
|
|
124
|
+
this.setInScopeVariables(new Map([...vars, ...this.inScopeVariables]));
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
if (e && e.detail) {
|
|
@@ -132,11 +133,15 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
132
133
|
vars.set(key,e.detail[key]);
|
|
133
134
|
});
|
|
134
135
|
console.log("event detail vars", vars);
|
|
135
|
-
this.setInScopeVariables(vars);
|
|
136
|
+
this.setInScopeVariables(new Map([...vars, ...this.inScopeVariables]));
|
|
136
137
|
}
|
|
137
138
|
this.needsUpdate = false;
|
|
138
139
|
|
|
139
|
-
|
|
140
|
+
try{
|
|
141
|
+
this.evalInContext();
|
|
142
|
+
}catch (error){
|
|
143
|
+
console.warn('evaluation faild',error);
|
|
144
|
+
}
|
|
140
145
|
if (this.targetElement && this.targetElement.nodeset) {
|
|
141
146
|
this.nodeset = this.targetElement.nodeset;
|
|
142
147
|
}
|
|
@@ -172,6 +177,7 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
172
177
|
// After loop is done call actionPerformed to update the model and UI
|
|
173
178
|
await loop();
|
|
174
179
|
this.actionPerformed();
|
|
180
|
+
Fore.dispatch(this, 'while-performed', {});
|
|
175
181
|
return;
|
|
176
182
|
}
|
|
177
183
|
|
package/src/actions/fx-action.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AbstractAction } from './abstract-action.js';
|
|
2
2
|
import { Fore } from '../fore.js';
|
|
3
|
+
import {resolveId} from "../xpath-evaluation.js";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* `fx-refresh`
|
|
@@ -20,6 +21,14 @@ class FxRefresh extends AbstractAction {
|
|
|
20
21
|
this.getOwnerForm().forceRefresh();
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
24
|
+
if(this.hasAttribute('control')){
|
|
25
|
+
const targetId = this.getAttribute('control');
|
|
26
|
+
const ctrl = resolveId(targetId, this);
|
|
27
|
+
if (Fore.isUiElement(ctrl.nodeName) && typeof ctrl.refresh === 'function') {
|
|
28
|
+
ctrl.refresh();
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
23
32
|
this.getOwnerForm().refresh();
|
|
24
33
|
}
|
|
25
34
|
}
|
|
@@ -47,6 +47,7 @@ export default class FxReplace extends AbstractAction {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
replace(toReplace, replaceWith) {
|
|
50
|
+
console.log('replace', toReplace, replaceWith);
|
|
50
51
|
if (!toReplace || !replaceWith) return; // bail out silently
|
|
51
52
|
if (!toReplace.nodeName || !replaceWith.nodeName) {
|
|
52
53
|
console.warn('fx-replace: one argument is not a node');
|
package/src/fx-bind.js
CHANGED
|
@@ -273,7 +273,7 @@ export class FxBind extends foreElementMixin(HTMLElement) {
|
|
|
273
273
|
*/
|
|
274
274
|
if (XPathUtil.isSelfReference(this.ref)) {
|
|
275
275
|
const parentBoundElement = Fore.getClosest('fx-bind[ref]', this.parentElement);
|
|
276
|
-
console.log('parent bound element ', parentBoundElement);
|
|
276
|
+
// console.log('parent bound element ', parentBoundElement);
|
|
277
277
|
|
|
278
278
|
if (parentBoundElement) {
|
|
279
279
|
// todo: Could be fancier by combining them
|
package/src/fx-fore.js
CHANGED
|
@@ -380,11 +380,11 @@ export class FxFore extends HTMLElement {
|
|
|
380
380
|
console.time('refresh');
|
|
381
381
|
|
|
382
382
|
// ### refresh Fore UI elements
|
|
383
|
-
console.time('refreshChildren');
|
|
383
|
+
// console.time('refreshChildren');
|
|
384
384
|
console.log('toRefresh', this.toRefresh);
|
|
385
385
|
|
|
386
386
|
// if (!this.initialRun && this.toRefresh.length !== 0) {
|
|
387
|
-
if (!this.initialRun && this.toRefresh.length !== 0) {
|
|
387
|
+
if (!force && !this.initialRun && this.toRefresh.length !== 0) {
|
|
388
388
|
let needsRefresh = false;
|
|
389
389
|
|
|
390
390
|
// ### after recalculation the changed modelItems are copied to 'toRefresh' array for processing
|
|
@@ -422,7 +422,7 @@ export class FxFore extends HTMLElement {
|
|
|
422
422
|
}
|
|
423
423
|
} else {
|
|
424
424
|
Fore.refreshChildren(this, true);
|
|
425
|
-
console.timeEnd('refreshChildren');
|
|
425
|
+
// console.timeEnd('refreshChildren');
|
|
426
426
|
}
|
|
427
427
|
|
|
428
428
|
// ### refresh template expressions
|
|
@@ -460,7 +460,7 @@ export class FxFore extends HTMLElement {
|
|
|
460
460
|
this.storedTemplateExpressions = [];
|
|
461
461
|
}
|
|
462
462
|
|
|
463
|
-
console.log('######### storedTemplateExpressions', this.storedTemplateExpressions.length);
|
|
463
|
+
// console.log('######### storedTemplateExpressions', this.storedTemplateExpressions.length);
|
|
464
464
|
|
|
465
465
|
/*
|
|
466
466
|
storing expressions and their nodes for re-evaluation
|
|
@@ -475,7 +475,7 @@ export class FxFore extends HTMLElement {
|
|
|
475
475
|
// console.log('storedTemplateExpressionByNode', this.storedTemplateExpressionByNode);
|
|
476
476
|
this.storedTemplateExpressionByNode.set(node, expr);
|
|
477
477
|
});
|
|
478
|
-
console.log('stored template expressions ', this.storedTemplateExpressionByNode);
|
|
478
|
+
// console.log('stored template expressions ', this.storedTemplateExpressionByNode);
|
|
479
479
|
|
|
480
480
|
// TODO: Should we clean up nodes that existed but are now gone?
|
|
481
481
|
this._processTemplateExpressions();
|
|
@@ -690,7 +690,7 @@ export class FxFore extends HTMLElement {
|
|
|
690
690
|
registerVariables(child);
|
|
691
691
|
}
|
|
692
692
|
})(this);
|
|
693
|
-
console.log('Found variables:', variables);
|
|
693
|
+
// console.log('Found variables:', variables);
|
|
694
694
|
|
|
695
695
|
/*
|
|
696
696
|
const options = {
|
|
@@ -708,7 +708,7 @@ export class FxFore extends HTMLElement {
|
|
|
708
708
|
this.ready = true;
|
|
709
709
|
this.initialRun = false;
|
|
710
710
|
// console.log('### >>>>> dispatching ready >>>>>', this);
|
|
711
|
-
console.log('modelItems: ', this.getModel().modelItems);
|
|
711
|
+
console.log('### modelItems: ', this.getModel().modelItems);
|
|
712
712
|
console.log('### <<<<< FORE: form fully initialized...', this);
|
|
713
713
|
Fore.dispatch(this, 'ready', {});
|
|
714
714
|
}
|
package/src/fx-model.js
CHANGED
|
@@ -272,10 +272,7 @@ export class FxModel extends HTMLElement {
|
|
|
272
272
|
console.log(`recalculated ${this.computes} modelItems`);
|
|
273
273
|
|
|
274
274
|
console.timeEnd('recalculate');
|
|
275
|
-
console.log(
|
|
276
|
-
`recalculate finished with modelItems ${this.modelItems.length} item(s)`,
|
|
277
|
-
this.modelItems,
|
|
278
|
-
);
|
|
275
|
+
console.log('recalculate finished with modelItems ',this.modelItems);
|
|
279
276
|
console.groupEnd();
|
|
280
277
|
}
|
|
281
278
|
|
package/src/fx-submission.js
CHANGED
|
@@ -72,7 +72,7 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
async _submit() {
|
|
75
|
-
console.log('submitting....');
|
|
75
|
+
console.log('submitting....', this.getAttribute('id'));
|
|
76
76
|
this.evalInContext();
|
|
77
77
|
const model = this.getModel();
|
|
78
78
|
|
|
@@ -349,8 +349,7 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
|
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
this.model.updateModel(); // force update
|
|
352
|
-
|
|
353
|
-
this.getOwnerForm().refresh();
|
|
352
|
+
this.getOwnerForm().refresh(true);
|
|
354
353
|
} else {
|
|
355
354
|
throw new Error(`target instance not found: ${targetInstance}`);
|
|
356
355
|
}
|
|
@@ -43,7 +43,7 @@ export default class AbstractControl extends foreElementMixin(HTMLElement) {
|
|
|
43
43
|
if (this.isBound()) {
|
|
44
44
|
// this.control = this.querySelector('#control');
|
|
45
45
|
|
|
46
|
-
if
|
|
46
|
+
if(!this.nodeset){
|
|
47
47
|
this.style.display = 'none';
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
@@ -54,8 +54,9 @@ export default class AbstractControl extends foreElementMixin(HTMLElement) {
|
|
|
54
54
|
// console.log('### XfAbstractControl.refresh modelItem : ', this.modelItem);
|
|
55
55
|
|
|
56
56
|
if (this.hasAttribute('as') && this.getAttribute('as') === 'node') {
|
|
57
|
-
console.log('as', this.nodeset);
|
|
58
|
-
this.modelItem.value = this.nodeset;
|
|
57
|
+
// console.log('as', this.nodeset);
|
|
58
|
+
// this.modelItem.value = this.nodeset;
|
|
59
|
+
this.modelItem.node = this.nodeset;
|
|
59
60
|
this.value = this.modelItem.node;
|
|
60
61
|
} else {
|
|
61
62
|
this.value = this.modelItem.value;
|
|
@@ -135,7 +136,7 @@ export default class AbstractControl extends foreElementMixin(HTMLElement) {
|
|
|
135
136
|
// console.log('mip required', this.modelItem.required);
|
|
136
137
|
this.widget = this.getWidget();
|
|
137
138
|
// if (this.required !== this.modelItem.required) {
|
|
138
|
-
|
|
139
|
+
if (this.isRequired() !== this.modelItem.required) {
|
|
139
140
|
if (this.modelItem.required) {
|
|
140
141
|
if (this.getOwnerForm().ready){
|
|
141
142
|
if(this.widget.value === ''){
|
|
@@ -152,7 +153,7 @@ export default class AbstractControl extends foreElementMixin(HTMLElement) {
|
|
|
152
153
|
this.removeAttribute('required');
|
|
153
154
|
this._dispatchEvent('optional');
|
|
154
155
|
}
|
|
155
|
-
|
|
156
|
+
}
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
handleReadonly() {
|
|
@@ -189,7 +190,7 @@ export default class AbstractControl extends foreElementMixin(HTMLElement) {
|
|
|
189
190
|
}
|
|
190
191
|
if (this.modelItem.alerts.length !== 0) {
|
|
191
192
|
const { alerts } = this.modelItem;
|
|
192
|
-
console.log('alerts from bind: ', alerts);
|
|
193
|
+
// console.log('alerts from bind: ', alerts);
|
|
193
194
|
|
|
194
195
|
const controlAlert = this.querySelector('fx-alert');
|
|
195
196
|
if (!controlAlert) {
|
package/src/ui/fx-container.js
CHANGED
|
@@ -44,7 +44,7 @@ export class FxContainer extends foreElementMixin(HTMLElement) {
|
|
|
44
44
|
if (this.isBound()) {
|
|
45
45
|
this.evalInContext();
|
|
46
46
|
this.modelItem = this.getModelItem();
|
|
47
|
-
if (!this.modelItem.boundControls.includes(this)) {
|
|
47
|
+
if (this.modelItem && !this.modelItem.boundControls.includes(this)) {
|
|
48
48
|
this.modelItem.boundControls.push(this);
|
|
49
49
|
}
|
|
50
50
|
|
package/src/ui/fx-control.js
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
} from '../xpath-evaluation.js';
|
|
7
7
|
import getInScopeContext from '../getInScopeContext.js';
|
|
8
8
|
import { Fore } from '../fore.js';
|
|
9
|
+
import {ModelItem} from "../modelitem.js";
|
|
9
10
|
|
|
10
11
|
const WIDGETCLASS = 'widget';
|
|
11
12
|
|
|
@@ -166,6 +167,11 @@ export default class FxControl extends XfAbstractControl {
|
|
|
166
167
|
}
|
|
167
168
|
const setval = this.shadowRoot.getElementById('setvalue');
|
|
168
169
|
setval.setValue(modelitem, val);
|
|
170
|
+
|
|
171
|
+
if (this.modelItem instanceof ModelItem && !this.modelItem?.boundControls.includes(this)) {
|
|
172
|
+
this.modelItem.boundControls.push(this);
|
|
173
|
+
}
|
|
174
|
+
|
|
169
175
|
setval.actionPerformed();
|
|
170
176
|
}
|
|
171
177
|
|
package/src/ui/fx-inspector.js
CHANGED
|
@@ -121,7 +121,6 @@ export class FxInspector extends HTMLElement {
|
|
|
121
121
|
</div>
|
|
122
122
|
`;
|
|
123
123
|
|
|
124
|
-
/*
|
|
125
124
|
const handle = this.shadowRoot.querySelector('.handle');
|
|
126
125
|
handle.addEventListener('click', e => {
|
|
127
126
|
// console.log('toggling');
|
|
@@ -132,7 +131,6 @@ export class FxInspector extends HTMLElement {
|
|
|
132
131
|
this.setAttribute('open', 'open');
|
|
133
132
|
}
|
|
134
133
|
});
|
|
135
|
-
*/
|
|
136
134
|
}
|
|
137
135
|
|
|
138
136
|
serializeDOM(data) {
|
package/src/ui/fx-output.js
CHANGED
|
@@ -67,9 +67,11 @@ export class FxOutput extends XfAbstractControl {
|
|
|
67
67
|
// console.log('widget ', this.widget);
|
|
68
68
|
this.mediatype = this.hasAttribute('mediatype') ? this.getAttribute('mediatype') : null;
|
|
69
69
|
|
|
70
|
+
/*
|
|
70
71
|
this.addEventListener('slotchange', e => {
|
|
71
72
|
console.log('slotchange ', e);
|
|
72
73
|
});
|
|
74
|
+
*/
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
async refresh() {
|
|
@@ -112,7 +114,7 @@ export class FxOutput extends XfAbstractControl {
|
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
async updateWidgetValue() {
|
|
115
|
-
console.log('updateWidgetValue');
|
|
117
|
+
// console.log('updateWidgetValue');
|
|
116
118
|
const valueWrapper = this.shadowRoot.getElementById('value');
|
|
117
119
|
|
|
118
120
|
if (this.mediatype === 'markdown') {
|
package/src/xpath-evaluation.js
CHANGED
|
@@ -327,7 +327,9 @@ function getVariablesInScope(formElement) {
|
|
|
327
327
|
if (closestActualFormElement.inScopeVariables) {
|
|
328
328
|
for (const key of closestActualFormElement.inScopeVariables.keys()) {
|
|
329
329
|
const varElement = closestActualFormElement.inScopeVariables.get(key);
|
|
330
|
-
|
|
330
|
+
if(varElement){
|
|
331
|
+
variables[key] = varElement.value;
|
|
332
|
+
}
|
|
331
333
|
}
|
|
332
334
|
}
|
|
333
335
|
return variables;
|