@jinntec/fore 2.0.0 → 2.1.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/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/index.js +3 -0
- package/package.json +1 -1
- package/src/actions/abstract-action.js +100 -66
- package/src/actions/fx-confirm.js +3 -3
- package/src/actions/fx-construct-done.js +28 -0
- package/src/actions/fx-insert.js +53 -51
- package/src/actions/fx-setattribute.js +68 -0
- package/src/fore.js +3 -1
- package/src/fx-bind.js +1 -0
- package/src/fx-fore.js +48 -1
- package/src/fx-model.js +6 -3
- package/src/fx-submission.js +24 -4
- package/src/fx-var.js +7 -2
- package/src/getInScopeContext.js +11 -1
- package/src/json-util.js +27 -0
- package/src/relevance.js +18 -0
- package/src/ui/abstract-control.js +2 -0
- package/src/ui/fx-droptarget.js +9 -0
- package/src/ui/fx-repeat-attributes.js +4 -2
- package/src/ui/fx-repeat.js +366 -356
- package/src/ui/fx-repeatitem.js +78 -86
- package/src/ui/fx-trigger.js +3 -2
- package/src/withDraggability.js +218 -0
- package/src/xpath-evaluation.js +140 -1
package/src/fx-model.js
CHANGED
|
@@ -447,7 +447,10 @@ export class FxModel extends HTMLElement {
|
|
|
447
447
|
}
|
|
448
448
|
|
|
449
449
|
getDefaultInstance() {
|
|
450
|
-
|
|
450
|
+
if (this.instances.length) {
|
|
451
|
+
return this.instances[0];
|
|
452
|
+
}
|
|
453
|
+
return this.getInstance('default');
|
|
451
454
|
}
|
|
452
455
|
|
|
453
456
|
getDefaultInstanceData() {
|
|
@@ -461,11 +464,11 @@ export class FxModel extends HTMLElement {
|
|
|
461
464
|
|
|
462
465
|
let found;
|
|
463
466
|
if(id === 'default'){
|
|
464
|
-
found = this.
|
|
467
|
+
found = this.instances[0];
|
|
465
468
|
}
|
|
466
469
|
// ### lookup in local instances first
|
|
467
470
|
if(!found) {
|
|
468
|
-
|
|
471
|
+
const instArray = Array.from(this.instances);
|
|
469
472
|
found = instArray.find(inst => inst.id === id);
|
|
470
473
|
const parentFore = this.fore.parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE
|
|
471
474
|
? this.fore.parentNode.host.closest('fx-fore')
|
package/src/fx-submission.js
CHANGED
|
@@ -48,14 +48,16 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
|
|
|
48
48
|
? this.getAttribute('serialization')
|
|
49
49
|
: 'xml';
|
|
50
50
|
|
|
51
|
-
this.url = this.hasAttribute('url') ? this.getAttribute('url'):null;
|
|
52
|
-
|
|
53
|
-
this.targetref = this.hasAttribute('targetref') ? this.getAttribute('targetref') : null;
|
|
54
|
-
|
|
55
51
|
this.mediatype = this.hasAttribute('mediatype')
|
|
56
52
|
? this.getAttribute('mediatype')
|
|
57
53
|
: 'application/xml';
|
|
58
54
|
|
|
55
|
+
this.responseMediatype = this.hasAttribute('response-mediatype') ? this.getAttribute('response-mediatype') : this.mediatype;
|
|
56
|
+
this.url = this.hasAttribute('url') ? this.getAttribute('url') : null;
|
|
57
|
+
|
|
58
|
+
this.targetref = this.hasAttribute('targetref') ? this.getAttribute('targetref') : null;
|
|
59
|
+
|
|
60
|
+
|
|
59
61
|
this.validate = this.getAttribute('validate') ? this.getAttribute('validate') : 'true';
|
|
60
62
|
this.credentials = this.hasAttribute('credentials')
|
|
61
63
|
? this.getAttribute('credentials')
|
|
@@ -134,6 +136,23 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
|
|
|
134
136
|
|
|
135
137
|
// let serialized = serializer.serializeToString(relevant);
|
|
136
138
|
if (this.method.toLowerCase() === 'get') {
|
|
139
|
+
/*
|
|
140
|
+
todo: serialize the bound instance element names as get parameters and using their text values
|
|
141
|
+
as param values. leave out empty params and create querystring from the result.Elements may
|
|
142
|
+
have exactly level deep or are otherwise ignored.
|
|
143
|
+
<data>
|
|
144
|
+
<id>1234</id>
|
|
145
|
+
<name>john</name>
|
|
146
|
+
<zip></zip>
|
|
147
|
+
<!-- ignored as no direct text value -->
|
|
148
|
+
<phone>
|
|
149
|
+
<mobile></mobile>
|
|
150
|
+
<phone>
|
|
151
|
+
</data>
|
|
152
|
+
results in: ?id=1234&name=john to be appended to this.url on fetch
|
|
153
|
+
|
|
154
|
+
*/
|
|
155
|
+
|
|
137
156
|
serialized = undefined;
|
|
138
157
|
}
|
|
139
158
|
// console.log('data being send', serialized);
|
|
@@ -182,6 +201,7 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
|
|
|
182
201
|
const key = resolvedUrl.substring(resolvedUrl.indexOf(':') + 1);
|
|
183
202
|
localStorage.removeItem(key);
|
|
184
203
|
const newInst = new DOMParser().parseFromString('<data></data>', 'application/xml');
|
|
204
|
+
this.replace = 'instance';
|
|
185
205
|
this._handleResponse(newInst);
|
|
186
206
|
console.log('### <<<<< submit-done >>>>>');
|
|
187
207
|
Fore.dispatch(this, 'submit-done', {});
|
package/src/fx-var.js
CHANGED
|
@@ -25,8 +25,13 @@ export class FxVariable extends foreElementMixin(HTMLElement) {
|
|
|
25
25
|
refresh() {
|
|
26
26
|
const inscope = getInScopeContext(this, this.valueQuery);
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const values = evaluateXPath(this.valueQuery, inscope, this, this.precedingVariables);
|
|
29
|
+
if (values.length) {
|
|
30
|
+
[this.value] = values;
|
|
31
|
+
} else {
|
|
32
|
+
// There is no value: set to null so it's interpreted as empty-sequence later on
|
|
33
|
+
this.value = null;
|
|
34
|
+
}
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
setInScopeVariables(inScopeVariables) {
|
package/src/getInScopeContext.js
CHANGED
|
@@ -62,13 +62,23 @@ export default function getInScopeContext(node, ref) {
|
|
|
62
62
|
// console.log('getInScopeContext parent', parentElement);
|
|
63
63
|
|
|
64
64
|
if(parentElement.nodeName === 'FX-FORE'){
|
|
65
|
-
|
|
65
|
+
const context = parentElement.getModel().getDefaultInstance()?.getDefaultContext();
|
|
66
|
+
if (!context) {
|
|
67
|
+
// Edge-case, we are in an inner fore. Use the outer fore's default context
|
|
68
|
+
return getInScopeContext(parentElement.parentNode, ref);
|
|
69
|
+
}
|
|
70
|
+
return context;
|
|
66
71
|
}
|
|
67
72
|
const parentBind = XPathUtil.getClosest('[ref]', parentElement.parentNode);
|
|
68
73
|
if (parentBind && (parentBind.nodeName === 'FX-GROUP' || parentBind.nodeName === 'FX-CONTROL')) {
|
|
69
74
|
return parentBind.nodeset;
|
|
70
75
|
}
|
|
71
76
|
|
|
77
|
+
const parentActionWithIterateExpr = parentElement.matches('[iterate]') ? parentElement : XPathUtil.getClosest('[iterate]', parentElement.parentNode);
|
|
78
|
+
if (parentActionWithIterateExpr && parentActionWithIterateExpr.currentContext) {
|
|
79
|
+
return parentActionWithIterateExpr.currentContext;
|
|
80
|
+
}
|
|
81
|
+
|
|
72
82
|
const repeatItem = XPathUtil.getClosest('fx-repeatitem', parentElement);
|
|
73
83
|
if (repeatItem) {
|
|
74
84
|
if (node.nodeName === 'context') {
|
package/src/json-util.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const jsonToXml = (json) => {
|
|
2
|
+
const convert = (obj) => {
|
|
3
|
+
let xml = '';
|
|
4
|
+
for (const key in obj) {
|
|
5
|
+
if (obj.hasOwnProperty(key)) {
|
|
6
|
+
xml += `<${key}`;
|
|
7
|
+
if (typeof obj[key] === 'object') {
|
|
8
|
+
if (Array.isArray(obj[key])) {
|
|
9
|
+
xml += ' type="array">';
|
|
10
|
+
obj[key].forEach((item) => {
|
|
11
|
+
xml += `<_>${convert(item)}</_>`;
|
|
12
|
+
});
|
|
13
|
+
} else {
|
|
14
|
+
xml += ' type="object">';
|
|
15
|
+
xml += convert(obj[key]);
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
xml += ` type="${typeof obj[key]}">${obj[key]}</${key}>`;
|
|
19
|
+
}
|
|
20
|
+
xml += `</${key}>`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return xml;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return `<json>${convert(json)}</json>`;
|
|
27
|
+
};
|
package/src/relevance.js
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
|
+
import {Fore} from "./fore.js";
|
|
2
|
+
|
|
1
3
|
export class Relevance {
|
|
4
|
+
|
|
5
|
+
static handleRelevance(boundElement){
|
|
6
|
+
const modelItem = boundElement.getModelItem();
|
|
7
|
+
|
|
8
|
+
if (modelItem && modelItem.relevant) {
|
|
9
|
+
boundElement.removeAttribute('nonrelevant');
|
|
10
|
+
boundElement.setAttribute('relevant','');
|
|
11
|
+
Fore.dispatch(this,'relevant',{});
|
|
12
|
+
|
|
13
|
+
} else {
|
|
14
|
+
boundElement.removeAttribute('relevant');
|
|
15
|
+
boundElement.setAttribute('nonrelevant','');
|
|
16
|
+
Fore.dispatch(this,'nonrelevant',{});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
2
20
|
static selectRelevant(element, type) {
|
|
3
21
|
// console.log('selectRelevant', type);
|
|
4
22
|
switch (type) {
|
|
@@ -5,6 +5,7 @@ import { Fore } from '../fore.js';
|
|
|
5
5
|
import { XPathUtil } from '../xpath-util.js';
|
|
6
6
|
import getInScopeContext from '../getInScopeContext.js';
|
|
7
7
|
import { evaluateXPathToFirstNode} from '../xpath-evaluation.js';
|
|
8
|
+
import {Relevance} from "../relevance.js";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* `AbstractControl` -
|
|
@@ -172,6 +173,7 @@ export default class AbstractControl extends foreElementMixin(HTMLElement) {
|
|
|
172
173
|
this.handleValid();
|
|
173
174
|
}
|
|
174
175
|
this.handleRelevant();
|
|
176
|
+
// Relevance.handleRelevance(this);
|
|
175
177
|
// todo: handleType()
|
|
176
178
|
}
|
|
177
179
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { foreElementMixin } from '../ForeElementMixin.js';
|
|
2
|
+
import { withDraggability } from '../withDraggability.js';
|
|
3
|
+
|
|
4
|
+
class FxDroptarget extends withDraggability(foreElementMixin(HTMLElement)) {
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
if (!customElements.get('fx-droptarget')) {
|
|
8
|
+
window.customElements.define('fx-droptarget', FxDroptarget);
|
|
9
|
+
}
|
|
@@ -3,6 +3,7 @@ import { evaluateXPath } from '../xpath-evaluation.js';
|
|
|
3
3
|
import getInScopeContext from '../getInScopeContext.js';
|
|
4
4
|
import { XPathUtil } from '../xpath-util.js';
|
|
5
5
|
import {foreElementMixin} from "../ForeElementMixin.js";
|
|
6
|
+
import {withDraggability} from "../withDraggability.js";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* `fx-repeat`
|
|
@@ -19,7 +20,7 @@ import {foreElementMixin} from "../ForeElementMixin.js";
|
|
|
19
20
|
*
|
|
20
21
|
* todo: it should be seriously be considered to extend FxContainer instead but needs refactoring first.
|
|
21
22
|
*/
|
|
22
|
-
export class FxRepeatAttributes extends foreElementMixin(HTMLElement) {
|
|
23
|
+
export class FxRepeatAttributes extends withDraggability(foreElementMixin(HTMLElement), false) {
|
|
23
24
|
static get properties() {
|
|
24
25
|
return {
|
|
25
26
|
...super.properties,
|
|
@@ -51,6 +52,7 @@ export class FxRepeatAttributes extends foreElementMixin(HTMLElement) {
|
|
|
51
52
|
super();
|
|
52
53
|
this.ref = '';
|
|
53
54
|
this.dataTemplate = [];
|
|
55
|
+
this.isDraggable=null;
|
|
54
56
|
this.focusOnCreate = '';
|
|
55
57
|
this.initDone = false;
|
|
56
58
|
this.repeatIndex = 1;
|
|
@@ -87,7 +89,7 @@ export class FxRepeatAttributes extends foreElementMixin(HTMLElement) {
|
|
|
87
89
|
}
|
|
88
90
|
|
|
89
91
|
get index() {
|
|
90
|
-
|
|
92
|
+
return parseInt(this.getAttribute('index'), 10);
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
set index(idx) {
|