@jinntec/fore 1.8.0 → 1.10.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/README.md +17 -0
- package/dist/fore-dev.js +2 -2
- package/dist/fore-dev.js.map +1 -1
- package/dist/fore.js +2 -2
- package/dist/fore.js.map +1 -1
- package/package.json +7 -2
- package/resources/fore.css +4 -0
- package/src/DependencyNotifyingDomFacade.js +2 -2
- package/src/actions/abstract-action.js +24 -11
- package/src/actions/fx-insert.js +13 -6
- package/src/actions/fx-setfocus.js +1 -1
- package/src/fore.js +238 -1
- package/src/fx-bind.js +12 -6
- package/src/fx-fore.js +86 -9
- package/src/fx-instance.js +9 -3
- package/src/fx-model.js +3 -1
- package/src/fx-submission.js +46 -157
- package/src/tools/adi.js +16 -7
- package/src/tools/fx-action-log.js +1 -1
- package/src/ui/abstract-control.js +8 -7
- package/src/ui/fx-control.js +18 -7
- package/src/ui/fx-dialog.js +2 -0
- package/src/ui/fx-group.js +4 -1
- package/src/ui/fx-repeat-attributes.js +4 -1
- package/src/ui/fx-repeat.js +11 -2
- package/src/ui/fx-repeatitem.js +5 -3
- package/src/ui/fx-trigger.js +3 -1
- package/src/xpath-evaluation.js +101 -4
- package/src/xpath-util.js +9 -12
package/src/fx-fore.js
CHANGED
|
@@ -29,6 +29,12 @@ export class FxFore extends HTMLElement {
|
|
|
29
29
|
|
|
30
30
|
static get properties() {
|
|
31
31
|
return {
|
|
32
|
+
/**
|
|
33
|
+
* ignore certain nodes for template expression search
|
|
34
|
+
*/
|
|
35
|
+
ignoreExpressions:{
|
|
36
|
+
type: String
|
|
37
|
+
},
|
|
32
38
|
/**
|
|
33
39
|
* merge-partial
|
|
34
40
|
*/
|
|
@@ -173,8 +179,8 @@ export class FxFore extends HTMLElement {
|
|
|
173
179
|
|
|
174
180
|
<jinn-toast id="message" gravity="bottom" position="left"></jinn-toast>
|
|
175
181
|
<jinn-toast id="sticky" gravity="bottom" position="left" duration="-1" close="true" data-class="sticky-message"></jinn-toast>
|
|
176
|
-
<jinn-toast id="error" text="error" duration="-1" data-class="error" close="true" position="
|
|
177
|
-
<jinn-toast id="warn" text="warning" duration="
|
|
182
|
+
<jinn-toast id="error" text="error" duration="-1" data-class="error" close="true" position="right" gravity="top" escape-markup="false"></jinn-toast>
|
|
183
|
+
<jinn-toast id="warn" text="warning" duration="5000" data-class="warning" position="left" gravity="top"></jinn-toast>
|
|
178
184
|
<slot id="default"></slot>
|
|
179
185
|
<slot name="messages"></slot>
|
|
180
186
|
<div id="modalMessage" class="overlay">
|
|
@@ -225,6 +231,7 @@ export class FxFore extends HTMLElement {
|
|
|
225
231
|
// e.stopImmediatePropagation();
|
|
226
232
|
},true);
|
|
227
233
|
*/
|
|
234
|
+
this.ignoreExpressions = this.hasAttribute('ignore-expressions') ? this.getAttribute('ignore-expressions'): null;
|
|
228
235
|
|
|
229
236
|
this.lazyRefresh = this.hasAttribute('refresh-on-view');
|
|
230
237
|
if (this.lazyRefresh) {
|
|
@@ -254,6 +261,10 @@ export class FxFore extends HTMLElement {
|
|
|
254
261
|
return;
|
|
255
262
|
}
|
|
256
263
|
|
|
264
|
+
if(this.ignoreExpressions){
|
|
265
|
+
this.ignoredNodes = Array.from(this.querySelectorAll(this.ignoreExpressions));
|
|
266
|
+
}
|
|
267
|
+
|
|
257
268
|
const children = event.target.assignedElements();
|
|
258
269
|
let modelElement = children.find(
|
|
259
270
|
modelElem => modelElem.nodeName.toUpperCase() === 'FX-MODEL',
|
|
@@ -284,6 +295,7 @@ export class FxFore extends HTMLElement {
|
|
|
284
295
|
this.addEventListener('path-mutated', () => {
|
|
285
296
|
this.someInstanceDataStructureChanged = true;
|
|
286
297
|
});
|
|
298
|
+
|
|
287
299
|
}
|
|
288
300
|
|
|
289
301
|
_injectDevtools(){
|
|
@@ -438,7 +450,42 @@ export class FxFore extends HTMLElement {
|
|
|
438
450
|
// console.timeEnd('refresh');
|
|
439
451
|
}
|
|
440
452
|
|
|
441
|
-
async refresh(force) {
|
|
453
|
+
async refresh(force, changedPaths) {
|
|
454
|
+
if (!changedPaths) {
|
|
455
|
+
changedPaths = this.toRefresh.map(item => item.path);
|
|
456
|
+
} else {
|
|
457
|
+
this.toRefresh.push(
|
|
458
|
+
...changedPaths
|
|
459
|
+
.map(
|
|
460
|
+
path =>
|
|
461
|
+
this.getModel()
|
|
462
|
+
.modelItems
|
|
463
|
+
.find(item => item.path === path)
|
|
464
|
+
)
|
|
465
|
+
.filter(Boolean)
|
|
466
|
+
);
|
|
467
|
+
|
|
468
|
+
for(const changedPath of changedPaths) {
|
|
469
|
+
for (const repeat of this.querySelectorAll('fx-repeat')) {
|
|
470
|
+
if (repeat.closest('fx-fore') !== this) {
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
if (repeat.touchedPaths.has(changedPath)) {
|
|
475
|
+
// Make a temporary model-item-like structure for this
|
|
476
|
+
this.toRefresh.push({
|
|
477
|
+
path: changedPath,
|
|
478
|
+
boundControls: [repeat]
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
console.log('Found a repeat to update!!!', repeat)
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
if (this.isRefreshing) {
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
442
489
|
// refresh () {
|
|
443
490
|
// ### refresh Fore UI elements
|
|
444
491
|
// if (!this.initialRun && this.toRefresh.length !== 0) {
|
|
@@ -457,7 +504,7 @@ export class FxFore extends HTMLElement {
|
|
|
457
504
|
}
|
|
458
505
|
|
|
459
506
|
// ### check if other controls depend on current modelItem
|
|
460
|
-
const {mainGraph} = this.getModel();
|
|
507
|
+
const { mainGraph } = this.getModel();
|
|
461
508
|
if (mainGraph && mainGraph.hasNode(modelItem.path)) {
|
|
462
509
|
const deps = this.getModel().mainGraph.dependentsOf(modelItem.path, false);
|
|
463
510
|
// ### iterate dependant modelItems and refresh all their boundControls
|
|
@@ -490,7 +537,9 @@ export class FxFore extends HTMLElement {
|
|
|
490
537
|
});
|
|
491
538
|
*/
|
|
492
539
|
|
|
493
|
-
|
|
540
|
+
if(this.inited){
|
|
541
|
+
Fore.refreshChildren(this, true);
|
|
542
|
+
}
|
|
494
543
|
// console.timeEnd('refreshChildren');
|
|
495
544
|
}
|
|
496
545
|
|
|
@@ -506,6 +555,13 @@ export class FxFore extends HTMLElement {
|
|
|
506
555
|
// this.initialRun = false;
|
|
507
556
|
this.style.visibility='visible';
|
|
508
557
|
Fore.dispatch(this, 'refresh-done', {});
|
|
558
|
+
|
|
559
|
+
this.isRefreshing = true;
|
|
560
|
+
this.parentNode.closest('fx-fore')?.refresh(false, changedPaths);
|
|
561
|
+
for (const subFore of this.querySelectorAll('fx-fore')) {
|
|
562
|
+
subFore.refresh(false, changedPaths);
|
|
563
|
+
}
|
|
564
|
+
this.isRefreshing = false;
|
|
509
565
|
}
|
|
510
566
|
|
|
511
567
|
/**
|
|
@@ -547,7 +603,9 @@ export class FxFore extends HTMLElement {
|
|
|
547
603
|
const expr = this._getTemplateExpression(node);
|
|
548
604
|
|
|
549
605
|
// console.log('storedTemplateExpressionByNode', this.storedTemplateExpressionByNode);
|
|
550
|
-
|
|
606
|
+
if(expr){
|
|
607
|
+
this.storedTemplateExpressionByNode.set(node, expr);
|
|
608
|
+
}
|
|
551
609
|
});
|
|
552
610
|
// console.log('stored template expressions ', this.storedTemplateExpressionByNode);
|
|
553
611
|
|
|
@@ -629,6 +687,13 @@ export class FxFore extends HTMLElement {
|
|
|
629
687
|
|
|
630
688
|
// eslint-disable-next-line class-methods-use-this
|
|
631
689
|
_getTemplateExpression(node) {
|
|
690
|
+
if(this.ignoredNodes){
|
|
691
|
+
if(node.nodeType === Node.ATTRIBUTE_NODE){
|
|
692
|
+
node = node.ownerElement;
|
|
693
|
+
}
|
|
694
|
+
const found = this.ignoredNodes.find( (n) => n.contains(node));
|
|
695
|
+
if(found) return null;
|
|
696
|
+
}
|
|
632
697
|
if (node.nodeType === Node.ATTRIBUTE_NODE) {
|
|
633
698
|
return node.value;
|
|
634
699
|
}
|
|
@@ -685,6 +750,18 @@ export class FxFore extends HTMLElement {
|
|
|
685
750
|
*/
|
|
686
751
|
async _lazyCreateInstance() {
|
|
687
752
|
const model = this.querySelector('fx-model');
|
|
753
|
+
// Inherit shared models from the parent component
|
|
754
|
+
|
|
755
|
+
const parentFore = this.parentNode.closest('fx-fore');
|
|
756
|
+
if (parentFore) {
|
|
757
|
+
const sharedInstances = Array.from(parentFore.getModel().querySelectorAll('fx-instance')).filter(instance => instance.hasAttribute('shared'));
|
|
758
|
+
for(const instance of sharedInstances) {
|
|
759
|
+
this.getModel().instances.push(instance);
|
|
760
|
+
}
|
|
761
|
+
this.getModel().updateModel();
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
|
|
688
765
|
if (model.instances.length === 0) {
|
|
689
766
|
// console.log('### lazy creation of instance');
|
|
690
767
|
const generatedInstance = document.createElement('fx-instance');
|
|
@@ -696,7 +773,7 @@ export class FxFore extends HTMLElement {
|
|
|
696
773
|
generatedInstance.instanceData = generated;
|
|
697
774
|
model.instances.push(generatedInstance);
|
|
698
775
|
// console.log('generatedInstance ', this.getModel().getDefaultInstanceData());
|
|
699
|
-
Fore.dispatch(this,'instance-loaded',{instance:this})
|
|
776
|
+
Fore.dispatch(this,'instance-loaded',{instance:this});
|
|
700
777
|
}
|
|
701
778
|
}
|
|
702
779
|
|
|
@@ -920,9 +997,9 @@ export class FxFore extends HTMLElement {
|
|
|
920
997
|
this.shadowRoot.getElementById('messageContent').innerText = msg;
|
|
921
998
|
// this.shadowRoot.getElementById('modalMessage').open();
|
|
922
999
|
this.shadowRoot.getElementById('modalMessage').classList.add('show');
|
|
923
|
-
} else if (level === 'sticky') {
|
|
1000
|
+
} else if (level === 'sticky' || level === 'error' || level === 'warn') {
|
|
924
1001
|
// const notification = this.$.modeless;
|
|
925
|
-
this.shadowRoot.querySelector(
|
|
1002
|
+
this.shadowRoot.querySelector(`#${level}`).showToast(msg);
|
|
926
1003
|
} else {
|
|
927
1004
|
const toast = this.shadowRoot.querySelector('#message');
|
|
928
1005
|
toast.showToast(msg);
|
package/src/fx-instance.js
CHANGED
|
@@ -52,6 +52,7 @@ export class FxInstance extends HTMLElement {
|
|
|
52
52
|
this.attachShadow({ mode: 'open' });
|
|
53
53
|
this.originalInstance = null;
|
|
54
54
|
this.partialInstance = null;
|
|
55
|
+
this.credentials = '';
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
connectedCallback() {
|
|
@@ -66,6 +67,13 @@ export class FxInstance extends HTMLElement {
|
|
|
66
67
|
this.id = 'default';
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
this.credentials = this.hasAttribute('credentials')
|
|
71
|
+
? this.getAttribute('credentials')
|
|
72
|
+
: 'same-origin';
|
|
73
|
+
if (!['same-origin', 'include', 'omit'].includes(this.credentials)) {
|
|
74
|
+
console.error(`fx-submission: the value of credentials is not valid. Expected 'same-origin', 'include' or 'omit' but got '${this.credentials}'`, this);
|
|
75
|
+
}
|
|
76
|
+
|
|
69
77
|
if (this.hasAttribute('type')) {
|
|
70
78
|
this.type = this.getAttribute('type');
|
|
71
79
|
} else {
|
|
@@ -243,10 +251,8 @@ export class FxInstance extends HTMLElement {
|
|
|
243
251
|
try {
|
|
244
252
|
const response = await fetch(url, {
|
|
245
253
|
method: 'GET',
|
|
246
|
-
|
|
254
|
+
credentials: this.credentials,
|
|
247
255
|
mode: 'cors',
|
|
248
|
-
credentials: 'include',
|
|
249
|
-
*/
|
|
250
256
|
headers: {
|
|
251
257
|
'Content-Type': contentType,
|
|
252
258
|
},
|
package/src/fx-model.js
CHANGED
|
@@ -67,7 +67,9 @@ export class FxModel extends HTMLElement {
|
|
|
67
67
|
// const path = fx.evaluateXPath('path()',node);
|
|
68
68
|
let path;
|
|
69
69
|
if (node.nodeType) {
|
|
70
|
-
|
|
70
|
+
const instance = XPathUtil.resolveInstance(model, ref);
|
|
71
|
+
|
|
72
|
+
path = XPathUtil.getPath(node, instance);
|
|
71
73
|
} else {
|
|
72
74
|
path = null;
|
|
73
75
|
targetNode = node;
|
package/src/fx-submission.js
CHANGED
|
@@ -12,6 +12,7 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
|
|
|
12
12
|
constructor() {
|
|
13
13
|
super();
|
|
14
14
|
this.attachShadow({mode: 'open'});
|
|
15
|
+
this.credentials = '';
|
|
15
16
|
this.parameters = new Map();
|
|
16
17
|
}
|
|
17
18
|
|
|
@@ -56,6 +57,12 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
|
|
|
56
57
|
: 'application/xml';
|
|
57
58
|
|
|
58
59
|
this.validate = this.getAttribute('validate') ? this.getAttribute('validate') : 'true';
|
|
60
|
+
this.credentials = this.hasAttribute('credentials')
|
|
61
|
+
? this.getAttribute('credentials')
|
|
62
|
+
: 'same-origin';
|
|
63
|
+
if (!['same-origin', 'include', 'omit'].includes(this.credentials)) {
|
|
64
|
+
console.error(`fx-submission: the value of credentials is not valid. Expected 'same-origin', 'include' or 'omit' but got '${this.credentials}'`, this);
|
|
65
|
+
}
|
|
59
66
|
this.shadowRoot.innerHTML = this.renderHTML();
|
|
60
67
|
}
|
|
61
68
|
|
|
@@ -96,9 +103,8 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
|
|
|
96
103
|
_getProperty(attrName){
|
|
97
104
|
if(this.parameters.has(attrName)){
|
|
98
105
|
return this.parameters.get(attrName);
|
|
99
|
-
} else {
|
|
100
|
-
return this.getAttribute(attrName);
|
|
101
106
|
}
|
|
107
|
+
return this.getAttribute(attrName);
|
|
102
108
|
}
|
|
103
109
|
|
|
104
110
|
/**
|
|
@@ -191,10 +197,8 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
|
|
|
191
197
|
try {
|
|
192
198
|
const response = await fetch(resolvedUrl, {
|
|
193
199
|
method: this.method,
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
credentials: 'include',
|
|
197
|
-
*/
|
|
200
|
+
credentials: this.credentials,
|
|
201
|
+
mode:'cors',
|
|
198
202
|
headers,
|
|
199
203
|
body: serialized,
|
|
200
204
|
});
|
|
@@ -207,9 +211,7 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
|
|
|
207
211
|
|
|
208
212
|
const contentType = response.headers.get('content-type').toLowerCase();
|
|
209
213
|
if (
|
|
210
|
-
contentType.startsWith('text/
|
|
211
|
-
contentType.startsWith('text/html') ||
|
|
212
|
-
contentType.startsWith('text/markdown')
|
|
214
|
+
contentType.startsWith('text/')
|
|
213
215
|
) {
|
|
214
216
|
const text = await response.text();
|
|
215
217
|
this._handleResponse(text, resolvedUrl,contentType);
|
|
@@ -231,6 +233,10 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
|
|
|
231
233
|
Fore.dispatch(this, 'submit-error', {error: error.message});
|
|
232
234
|
} finally {
|
|
233
235
|
this.parameters.clear();
|
|
236
|
+
const download = document.querySelector('[download]');
|
|
237
|
+
if(download){
|
|
238
|
+
document.body.removeChild(download);
|
|
239
|
+
}
|
|
234
240
|
}
|
|
235
241
|
}
|
|
236
242
|
|
|
@@ -333,26 +339,20 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
|
|
|
333
339
|
|
|
334
340
|
/*
|
|
335
341
|
if(this.replace === 'merge'){
|
|
342
|
+
if(targetInstance.type !== 'xml') {
|
|
343
|
+
Fore.dispatch(this, "warn", {'message': 'merging of instances only work for type xml'});
|
|
344
|
+
}
|
|
336
345
|
if (targetInstance && targetInstance.type === 'xml') {
|
|
337
346
|
targetInstance.partialInstance = data;
|
|
338
|
-
|
|
339
|
-
|
|
347
|
+
// const resultDoc = new DOMParser(`${data.nodeName}`, 'application/xml');
|
|
348
|
+
// console.log('resultDoc', resultDoc)
|
|
349
|
+
const merged = Fore.combine(targetInstance.instanceData.firstElementChild, data.firstElementChild, this,null);
|
|
340
350
|
console.log('merged', merged);
|
|
341
351
|
|
|
342
352
|
targetInstance.instanceData = merged;
|
|
343
353
|
console.log('merging partial instance',targetInstance.partialInstance)
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
*!/
|
|
347
|
-
|
|
348
|
-
// Skip any refreshes if the model is not yet inited#
|
|
349
|
-
// duplicate from replace='instance'
|
|
350
|
-
// if (this.model.inited) {
|
|
351
|
-
this.model.updateModel(); // force update
|
|
352
|
-
const owner = this.getOwnerForm();
|
|
353
|
-
// owner.mergePartial = true;
|
|
354
|
-
owner.refresh(true);
|
|
355
|
-
// }
|
|
354
|
+
this.model.updateModel();
|
|
355
|
+
this.getOwnerForm().refresh(true);
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
358
|
*/
|
|
@@ -399,11 +399,19 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
|
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
401
|
|
|
402
|
+
if (this.replace === 'download') {
|
|
403
|
+
const target = this._getProperty('target');
|
|
404
|
+
const downloadLink = document.createElement('a');
|
|
405
|
+
downloadLink.setAttribute('download',target);
|
|
406
|
+
downloadLink.setAttribute('href',`data:${contentType},${data}`);
|
|
407
|
+
document.body.appendChild(downloadLink);
|
|
408
|
+
downloadLink.click();
|
|
409
|
+
}
|
|
402
410
|
if (this.replace === 'all') {
|
|
403
411
|
const target = this._getProperty('target');
|
|
404
412
|
if(target && target === '_blank'){
|
|
405
413
|
const win = window.open("", "_blank");
|
|
406
|
-
win.document.write(data);
|
|
414
|
+
win.document.write(`<pre>${data}</pre>`);
|
|
407
415
|
win.document.close();
|
|
408
416
|
}else{
|
|
409
417
|
document.open();
|
|
@@ -428,51 +436,22 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
|
|
|
428
436
|
}
|
|
429
437
|
}
|
|
430
438
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
}
|
|
445
|
-
*/
|
|
446
|
-
|
|
447
|
-
/*
|
|
448
|
-
_mergeNodes(node1, node2) {
|
|
449
|
-
const childNodes1 = node1.childNodes;
|
|
450
|
-
const childNodes2 = node2.childNodes;
|
|
451
|
-
|
|
452
|
-
for (let i = 0; i < childNodes2.length; i++) {
|
|
453
|
-
const child2 = childNodes2[i];
|
|
454
|
-
let nodeMerged = false;
|
|
455
|
-
|
|
456
|
-
if (child2.nodeType === 1) { // Element Node
|
|
457
|
-
for (let j = 0; j < childNodes1.length; j++) {
|
|
458
|
-
const child1 = childNodes1[j];
|
|
459
|
-
if (child1.nodeType === 1 && child1.tagName === child2.tagName) {
|
|
460
|
-
this._mergeNodes(child1, child2);
|
|
461
|
-
nodeMerged = true;
|
|
462
|
-
break;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
if (!nodeMerged) {
|
|
468
|
-
const clonedNode = child2.cloneNode(true);
|
|
469
|
-
node1.appendChild(clonedNode);
|
|
470
|
-
}
|
|
471
|
-
}
|
|
439
|
+
_handleError() {
|
|
440
|
+
// this.dispatch('submit-error', {});
|
|
441
|
+
Fore.dispatch(this, 'submit-error', {});
|
|
442
|
+
/*
|
|
443
|
+
console.log('ERRRORRRRR');
|
|
444
|
+
this.dispatchEvent(
|
|
445
|
+
new CustomEvent('submit-error', {
|
|
446
|
+
composed: true,
|
|
447
|
+
bubbles: true,
|
|
448
|
+
detail: {},
|
|
449
|
+
}),
|
|
450
|
+
);
|
|
451
|
+
*/
|
|
472
452
|
}
|
|
473
|
-
*/
|
|
474
453
|
|
|
475
|
-
/*
|
|
454
|
+
/*
|
|
476
455
|
mergeNodes(node1, node2) {
|
|
477
456
|
// Overwrite attributes in node1 with values from node2
|
|
478
457
|
for (const { name, value } of node2.attributes) {
|
|
@@ -503,97 +482,7 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
|
|
|
503
482
|
});
|
|
504
483
|
}
|
|
505
484
|
*/
|
|
506
|
-
/**
|
|
507
|
-
* select relevant nodes
|
|
508
|
-
*
|
|
509
|
-
* @returns {*}
|
|
510
|
-
*/
|
|
511
|
-
/*
|
|
512
|
-
selectRelevant(type) {
|
|
513
|
-
console.log('selectRelevant' ,type)
|
|
514
|
-
switch (type){
|
|
515
|
-
case 'xml':
|
|
516
|
-
return this._relevantXmlNodes();
|
|
517
|
-
default:
|
|
518
|
-
console.warn(`relevance selection not supported for type:${this.type}`);
|
|
519
|
-
return this.nodeset;
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
*/
|
|
523
|
-
|
|
524
|
-
// todo: support for 'empty'
|
|
525
|
-
/*
|
|
526
|
-
_relevantXmlNodes() {
|
|
527
|
-
// ### no relevance selection - current nodeset is used 'as-is'
|
|
528
|
-
if (this.nonrelevant === 'keep') {
|
|
529
|
-
return this.nodeset;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
// first check if nodeset of submission is relevant - otherwise bail out
|
|
533
|
-
const mi = this.getModel().getModelItem(this.nodeset);
|
|
534
|
-
if (mi && !mi.relevant) return null;
|
|
535
|
-
|
|
536
|
-
const doc = new DOMParser().parseFromString('<data></data>', 'application/xml');
|
|
537
|
-
const root = doc.firstElementChild;
|
|
538
|
-
|
|
539
|
-
if (this.nodeset.children.length === 0 && this._isRelevant(this.nodeset)) {
|
|
540
|
-
return this.nodeset;
|
|
541
|
-
}
|
|
542
|
-
return this._filterRelevant(this.nodeset, root);
|
|
543
|
-
}
|
|
544
|
-
*/
|
|
545
|
-
|
|
546
|
-
/*
|
|
547
|
-
_filterRelevant(node, result) {
|
|
548
|
-
const { childNodes } = node;
|
|
549
|
-
Array.from(childNodes).forEach(n => {
|
|
550
|
-
if (this._isRelevant(n)) {
|
|
551
|
-
const clone = n.cloneNode(false);
|
|
552
|
-
result.appendChild(clone);
|
|
553
|
-
const { attributes } = n;
|
|
554
|
-
if (attributes) {
|
|
555
|
-
Array.from(attributes).forEach(attr => {
|
|
556
|
-
if (this._isRelevant(attr)) {
|
|
557
|
-
clone.setAttribute(attr.nodeName, attr.value);
|
|
558
|
-
} else if (this.nonrelevant === 'empty') {
|
|
559
|
-
clone.setAttribute(attr.nodeName, '');
|
|
560
|
-
} else {
|
|
561
|
-
clone.removeAttribute(attr.nodeName);
|
|
562
|
-
}
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
return this._filterRelevant(n, clone);
|
|
566
|
-
}
|
|
567
|
-
return null;
|
|
568
|
-
});
|
|
569
|
-
return result;
|
|
570
|
-
}
|
|
571
|
-
*/
|
|
572
485
|
|
|
573
|
-
/*
|
|
574
|
-
_isRelevant(node) {
|
|
575
|
-
const mi = this.getModel().getModelItem(node);
|
|
576
|
-
if (!mi || mi.relevant) {
|
|
577
|
-
return true;
|
|
578
|
-
}
|
|
579
|
-
return false;
|
|
580
|
-
}
|
|
581
|
-
*/
|
|
582
|
-
|
|
583
|
-
_handleError() {
|
|
584
|
-
// this.dispatch('submit-error', {});
|
|
585
|
-
Fore.dispatch(this, 'submit-error', {});
|
|
586
|
-
/*
|
|
587
|
-
console.log('ERRRORRRRR');
|
|
588
|
-
this.dispatchEvent(
|
|
589
|
-
new CustomEvent('submit-error', {
|
|
590
|
-
composed: true,
|
|
591
|
-
bubbles: true,
|
|
592
|
-
detail: {},
|
|
593
|
-
}),
|
|
594
|
-
);
|
|
595
|
-
*/
|
|
596
|
-
}
|
|
597
486
|
}
|
|
598
487
|
|
|
599
488
|
if (!customElements.get('fx-submission')) {
|
package/src/tools/adi.js
CHANGED
|
@@ -11,8 +11,10 @@ import {
|
|
|
11
11
|
|
|
12
12
|
import {Fore} from '../fore.js';
|
|
13
13
|
|
|
14
|
-
function isAttributeShown(name) {
|
|
15
|
-
|
|
14
|
+
function isAttributeShown(name, sourceNode) {
|
|
15
|
+
if(name === 'style') return false;
|
|
16
|
+
return true;
|
|
17
|
+
// return name === 'id' || name === 'ref' || name === 'event';
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
class ADI {
|
|
@@ -187,10 +189,16 @@ class ADI {
|
|
|
187
189
|
if (sourceNode.nodeType !== Node.DOCUMENT_NODE) {
|
|
188
190
|
// tagStart.textContent = '<' + node.nodeName.toLowerCase() + '>';
|
|
189
191
|
|
|
192
|
+
/*
|
|
193
|
+
let attrString = `<${sourceNode.nodeName.toLowerCase()} `;
|
|
194
|
+
if(sourceNode.attributes){
|
|
195
|
+
Array.from(sourceNode.attributes).forEach(attr => {
|
|
196
|
+
attrString += `${attr.nodeName}="${attr.nodeValue}" `;
|
|
197
|
+
});
|
|
198
|
+
console.log('ATTRSTRING',attrString);
|
|
199
|
+
}
|
|
190
200
|
if (sourceNode.nodeName === 'FX-BIND') {
|
|
191
|
-
tagStart.textContent = `<${sourceNode.nodeName.toLowerCase()} ref="${sourceNode.getAttribute(
|
|
192
|
-
'ref',
|
|
193
|
-
)}">`;
|
|
201
|
+
tagStart.textContent = `<${sourceNode.nodeName.toLowerCase()} ref="${sourceNode.getAttribute('ref')}">`;
|
|
194
202
|
} else if (sourceNode.nodeName === 'FX-INSERT') {
|
|
195
203
|
tagStart.textContent = `<${sourceNode.nodeName.toLowerCase()} ref="${sourceNode.getAttribute('ref')}">`;
|
|
196
204
|
} else if (sourceNode.nodeName === 'FX-INSTANCE') {
|
|
@@ -204,16 +212,17 @@ class ADI {
|
|
|
204
212
|
} else if (sourceNode.nodeName === 'FX-SUBMISSION') {
|
|
205
213
|
tagStart.textContent = `<${sourceNode.nodeName.toLowerCase()} id="${sourceNode.getAttribute('id')}">`;
|
|
206
214
|
} else {
|
|
215
|
+
*/
|
|
207
216
|
const attrString = Array.from(sourceNode.attributes)
|
|
208
217
|
.filter(
|
|
209
|
-
attr => this.isInstanceViewer ? true : isAttributeShown(attr.name))
|
|
218
|
+
attr => this.isInstanceViewer ? true : isAttributeShown(attr.name, sourceNode))
|
|
210
219
|
.map(attr => `${attr.name}="${attr.value}"`).join(' ');
|
|
211
220
|
tagStart.textContent = `<${
|
|
212
221
|
sourceNode.nodeName.toLowerCase()
|
|
213
222
|
}${
|
|
214
223
|
attrString ? (` ${attrString}`) : ''
|
|
215
224
|
}>`;
|
|
216
|
-
}
|
|
225
|
+
// }
|
|
217
226
|
|
|
218
227
|
if (withChildren) {
|
|
219
228
|
tagEnd = newElement('span');
|
|
@@ -459,7 +459,7 @@ export class FxActionLog extends HTMLElement {
|
|
|
459
459
|
*/
|
|
460
460
|
_logDetails(e) {
|
|
461
461
|
const eventType = e.type;
|
|
462
|
-
const path = XPathUtil.getPath(e.target);
|
|
462
|
+
const path = XPathUtil.getPath(e.target, 'unknown');
|
|
463
463
|
// console.log('>>>> _logDetails', path);
|
|
464
464
|
const cut = path.substring(path.indexOf('/fx-fore'), path.length);
|
|
465
465
|
const xpath = `/${cut}`;
|
|
@@ -2,8 +2,8 @@ import '../fx-model.js';
|
|
|
2
2
|
import { foreElementMixin } from '../ForeElementMixin.js';
|
|
3
3
|
import { ModelItem } from '../modelitem.js';
|
|
4
4
|
import { Fore } from '../fore.js';
|
|
5
|
-
import {XPathUtil} from
|
|
6
|
-
import getInScopeContext from
|
|
5
|
+
import { XPathUtil } from '../xpath-util.js';
|
|
6
|
+
import getInScopeContext from '../getInScopeContext.js';
|
|
7
7
|
import { evaluateXPathToFirstNode} from '../xpath-evaluation.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -76,7 +76,7 @@ export default class AbstractControl extends foreElementMixin(HTMLElement) {
|
|
|
76
76
|
const create = this.closest('[create]');
|
|
77
77
|
if(create){
|
|
78
78
|
// ### check if parent element exists
|
|
79
|
-
let attrName
|
|
79
|
+
let attrName; let parentPath; let parentNode;
|
|
80
80
|
|
|
81
81
|
if(this.ref.includes('/')){
|
|
82
82
|
parentPath = this.ref.substring(0, this.ref.indexOf('/'));
|
|
@@ -92,7 +92,7 @@ export default class AbstractControl extends foreElementMixin(HTMLElement) {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
}else{
|
|
95
|
-
|
|
95
|
+
const inscope = getInScopeContext(this, this.ref);
|
|
96
96
|
|
|
97
97
|
if(this.ref.includes('@')) {
|
|
98
98
|
attrName = this.ref.substring(this.ref.indexOf('@') + 1);
|
|
@@ -206,12 +206,13 @@ export default class AbstractControl extends foreElementMixin(HTMLElement) {
|
|
|
206
206
|
// eslint-disable-next-line class-methods-use-this
|
|
207
207
|
handleRequired() {
|
|
208
208
|
// console.log('mip required', this.modelItem.required);
|
|
209
|
-
|
|
209
|
+
this.widget = this.getWidget();
|
|
210
|
+
const wasRequired = this.isRequired();
|
|
210
211
|
|
|
211
212
|
if(!this.modelItem.required){
|
|
212
213
|
this.widget.removeAttribute('required');
|
|
213
214
|
this.removeAttribute('required');
|
|
214
|
-
if (
|
|
215
|
+
if (wasRequired !== this.modelItem.required){
|
|
215
216
|
this._dispatchEvent('optional');
|
|
216
217
|
}
|
|
217
218
|
return;
|
|
@@ -229,7 +230,7 @@ export default class AbstractControl extends foreElementMixin(HTMLElement) {
|
|
|
229
230
|
}
|
|
230
231
|
this.widget.setAttribute('required', '');
|
|
231
232
|
this.setAttribute('required', '');
|
|
232
|
-
if (
|
|
233
|
+
if (wasRequired !== this.modelItem.required) {
|
|
233
234
|
this._dispatchEvent('required');
|
|
234
235
|
}
|
|
235
236
|
|