@jinntec/fore 2.1.1 → 2.3.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 +2 -2
- 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 +4 -2
- package/package.json +10 -38
- package/resources/fore.css +263 -262
- package/resources/vars.css +8 -0
- package/src/DependencyNotifyingDomFacade.js +1 -0
- package/src/ForeElementMixin.js +243 -228
- package/src/actions/abstract-action.js +407 -398
- package/src/actions/fx-action.js +6 -6
- package/src/actions/fx-append.js +1 -1
- package/src/actions/fx-call.js +63 -62
- package/src/actions/fx-confirm.js +11 -11
- package/src/actions/fx-construct-done.js +4 -4
- package/src/actions/fx-copy.js +36 -36
- package/src/actions/fx-delete.js +77 -79
- package/src/actions/fx-dispatch.js +14 -14
- package/src/actions/fx-hide.js +15 -15
- package/src/actions/fx-insert.js +9 -12
- package/src/actions/fx-insertchild.js +88 -0
- package/src/actions/fx-load.js +188 -185
- package/src/actions/fx-message.js +18 -19
- package/src/actions/fx-refresh.js +10 -10
- package/src/actions/fx-reload.js +16 -14
- package/src/actions/fx-replace.js +0 -1
- package/src/actions/fx-reset.js +31 -31
- package/src/actions/fx-send.js +59 -52
- package/src/actions/fx-setattribute.js +48 -49
- package/src/actions/fx-setfocus.js +54 -58
- package/src/actions/fx-setvalue.js +85 -81
- package/src/actions/fx-show.js +11 -11
- package/src/actions/fx-toggle.js +2 -2
- package/src/actions/fx-toggleboolean.js +38 -39
- package/src/actions/fx-unmodified.js +27 -0
- package/src/actions/fx-update.js +6 -6
- package/src/dep_graph.js +1 -1
- package/src/drawdown.js +23 -30
- package/src/events.js +19 -19
- package/src/fore.js +143 -125
- package/src/functions/common-function.js +24 -25
- package/src/functions/fx-function.js +6 -99
- package/src/functions/fx-functionlib.js +56 -0
- package/src/functions/registerFunction.js +112 -0
- package/src/fx-bind.js +19 -24
- package/src/fx-connection.js +226 -0
- package/src/fx-fore.js +844 -815
- package/src/fx-header.js +4 -4
- package/src/fx-instance.js +25 -29
- package/src/fx-model.js +405 -380
- package/src/fx-submission.js +399 -397
- package/src/fx-var.js +13 -12
- package/src/getInScopeContext.js +102 -89
- package/src/json-util.js +24 -24
- package/src/lab/fore-component.js +48 -52
- package/src/lab/instance-inspector.js +13 -16
- package/src/modelitem.js +48 -10
- package/src/relevance.js +12 -16
- package/src/tools/adi.js +858 -812
- package/src/tools/fx-action-log.js +377 -295
- package/src/tools/fx-devtools.js +210 -210
- package/src/tools/fx-dom-inspector.js +123 -122
- package/src/tools/fx-json-instance.js +262 -253
- package/src/tools/fx-log-item.js +6 -11
- package/src/tools/fx-log-settings.js +358 -301
- package/src/tools/fx-minimap.js +186 -177
- package/src/tools/helpers.js +1 -1
- package/src/ui/abstract-control.js +73 -53
- package/src/ui/fx-case.js +59 -7
- package/src/ui/fx-container.js +13 -14
- package/src/ui/fx-control.js +572 -538
- package/src/ui/fx-dialog.js +3 -3
- package/src/ui/fx-droptarget.js +3 -4
- package/src/ui/fx-group.js +4 -2
- package/src/ui/fx-hint.js +3 -0
- package/src/ui/fx-inspector.js +5 -5
- package/src/ui/fx-items.js +11 -11
- package/src/ui/fx-output.js +10 -12
- package/src/ui/fx-repeat-attributes.js +23 -27
- package/src/ui/fx-repeat.js +347 -344
- package/src/ui/fx-repeatitem.js +75 -68
- package/src/ui/fx-switch.js +39 -14
- package/src/ui/fx-trigger.js +4 -4
- package/src/withDraggability.js +193 -191
- package/src/xpath-evaluation.js +969 -958
- package/src/xpath-util.js +161 -134
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { AbstractAction } from './abstract-action.js';
|
|
2
|
+
import getInScopeContext from '../getInScopeContext.js';
|
|
3
|
+
import {
|
|
4
|
+
evaluateXPathToNodes,
|
|
5
|
+
evaluateXPathToFirstNode,
|
|
6
|
+
evaluateXPathToNumber,
|
|
7
|
+
} from '../xpath-evaluation.js';
|
|
8
|
+
import { XPathUtil } from '../xpath-util';
|
|
9
|
+
import { Fore } from '../fore.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* `fx-insert`
|
|
13
|
+
* inserts nodes into data instances
|
|
14
|
+
*
|
|
15
|
+
* <fx-insertChild parent="instance('i-stopwatches')/stopwatches"
|
|
16
|
+
* child="watch"
|
|
17
|
+
* template="instance('vars')/templates/watch"
|
|
18
|
+
* at="1"
|
|
19
|
+
* position="before"></fx-insertChild>
|
|
20
|
+
* @customElement
|
|
21
|
+
*/
|
|
22
|
+
export class FxInsertchild extends AbstractAction {
|
|
23
|
+
static get properties() {
|
|
24
|
+
return {
|
|
25
|
+
...super.properties,
|
|
26
|
+
at: {
|
|
27
|
+
type: Number,
|
|
28
|
+
},
|
|
29
|
+
child: {
|
|
30
|
+
type: String,
|
|
31
|
+
},
|
|
32
|
+
parent: {
|
|
33
|
+
type: String,
|
|
34
|
+
},
|
|
35
|
+
origin: {
|
|
36
|
+
type: Object,
|
|
37
|
+
},
|
|
38
|
+
keepValues: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
constructor() {
|
|
45
|
+
super();
|
|
46
|
+
this.attachShadow({ mode: 'open' });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
connectedCallback() {
|
|
50
|
+
if (super.connectedCallback) {
|
|
51
|
+
super.connectedCallback();
|
|
52
|
+
}
|
|
53
|
+
this.at = Number(this.hasAttribute('at') ? this.getAttribute('at') : 1); // default: size of nodeset, determined later
|
|
54
|
+
this.child = this.getAttribute('child');
|
|
55
|
+
this.parent = this.getAttribute('parent');
|
|
56
|
+
this.position = this.hasAttribute('position') ? this.getAttribute('position') : 'after';
|
|
57
|
+
this.origin = this.hasAttribute('origin') ? this.getAttribute('origin') : null; // last item of context seq
|
|
58
|
+
this.keepValues = !!this.hasAttribute('keep-values');
|
|
59
|
+
|
|
60
|
+
const style = `
|
|
61
|
+
:host{
|
|
62
|
+
display:none;
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
this.shadowRoot.innerHTML = `
|
|
66
|
+
<style>
|
|
67
|
+
${style}
|
|
68
|
+
</style>
|
|
69
|
+
<fx-insert context="${this.parent}"
|
|
70
|
+
ref="${this.ref}"
|
|
71
|
+
origin="${this.origin}"
|
|
72
|
+
at="${this.at}"
|
|
73
|
+
position="${this.position}"></fx-insert>
|
|
74
|
+
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async perform() {
|
|
79
|
+
super.perform();
|
|
80
|
+
const insert = this.shadowRoot.querySelector('fx-insert');
|
|
81
|
+
await insert.perform();
|
|
82
|
+
this.needsUpdate = true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!customElements.get('fx-insertChild')) {
|
|
87
|
+
window.customElements.define('fx-insertchild', FxInsertchild);
|
|
88
|
+
}
|
package/src/actions/fx-load.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {AbstractAction} from './abstract-action.js';
|
|
2
|
-
import {evaluateXPathToString, resolveId} from
|
|
1
|
+
import { AbstractAction } from './abstract-action.js';
|
|
2
|
+
import { evaluateXPathToString, resolveId } from '../xpath-evaluation.js';
|
|
3
3
|
import getInScopeContext from '../getInScopeContext.js';
|
|
4
|
-
import {XPathUtil} from
|
|
5
|
-
import {Fore} from
|
|
4
|
+
import { XPathUtil } from '../xpath-util.js';
|
|
5
|
+
import { Fore } from '../fore.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* `fx-load`
|
|
@@ -11,214 +11,217 @@ import {Fore} from "../fore.js";
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
class FxLoad extends AbstractAction {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
connectedCallback()
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const style = `
|
|
14
|
+
static get properties() {
|
|
15
|
+
return {
|
|
16
|
+
...super.properties,
|
|
17
|
+
attachTo: {
|
|
18
|
+
type: String,
|
|
19
|
+
},
|
|
20
|
+
url: {
|
|
21
|
+
type: String,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
28
|
+
this.attachShadow({ mode: 'open' });
|
|
29
|
+
this.url = '';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
connectedCallback() {
|
|
33
|
+
super.connectedCallback();
|
|
34
|
+
this.attachTo = this.hasAttribute('attach-to') ? this.getAttribute('attach-to') : '_self';
|
|
35
|
+
|
|
36
|
+
// Add a 'doneEvent' to block the action chain untill the event fired on the element we're
|
|
37
|
+
// loading something into.
|
|
38
|
+
this.awaitEvent = this.hasAttribute('await') ? this.getAttribute('await') : '';
|
|
39
|
+
this.url = this.hasAttribute('url') ? this.getAttribute('url') : '';
|
|
40
|
+
const style = `
|
|
42
41
|
:host{
|
|
43
42
|
display:none;
|
|
44
43
|
}
|
|
45
44
|
`;
|
|
46
|
-
|
|
45
|
+
this.shadowRoot.innerHTML = `
|
|
47
46
|
<style>
|
|
48
47
|
${style}
|
|
49
48
|
</style>
|
|
50
49
|
${this.renderHTML()}`;
|
|
51
|
-
|
|
50
|
+
}
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
disconnectedCallback() {
|
|
53
|
+
// super.disconnectedCallback();
|
|
54
|
+
this.targetElement.removeEventListener(this.event, e => this.execute(e));
|
|
55
|
+
}
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
// eslint-disable-next-line class-methods-use-this
|
|
58
|
+
renderHTML() {
|
|
59
|
+
return `
|
|
61
60
|
<slot></slot>
|
|
62
61
|
`;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
if (this.awaitEvent) {
|
|
83
|
-
let resolveEvent;
|
|
84
|
-
const waitForEvent = new Promise((resolve) => {
|
|
85
|
-
resolveEvent = resolve;
|
|
86
|
-
});
|
|
87
|
-
const eventListener = () => {
|
|
88
|
-
resolveEvent();
|
|
89
|
-
resolved.removeEventListener(this.awaitEvent, eventListener);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
resolved.appendChild(content);
|
|
93
|
-
resolved.addEventListener(this.awaitEvent, eventListener);
|
|
94
|
-
|
|
95
|
-
await waitForEvent;
|
|
96
|
-
|
|
97
|
-
this.needsUpdate = true;
|
|
98
|
-
|
|
99
|
-
Fore.dispatch(this, 'loaded', {attachPoint:this.attachTo, content});
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
resolved.appendChild(content);
|
|
104
|
-
|
|
105
|
-
this.needsUpdate = true;
|
|
106
|
-
}
|
|
107
|
-
Fore.dispatch(this, 'loaded', {});
|
|
108
|
-
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async perform() {
|
|
65
|
+
await super.perform();
|
|
66
|
+
|
|
67
|
+
// this.getOwnerForm().evaluateTemplateExpression(this.urlContent, this);
|
|
68
|
+
|
|
69
|
+
const template = this.querySelector('template');
|
|
70
|
+
if (template) {
|
|
71
|
+
const clone = template.content.cloneNode(true);
|
|
72
|
+
const content = document.importNode(clone, true);
|
|
73
|
+
// this._attachToElement(content);
|
|
74
|
+
if (this.attachTo.startsWith('#')) {
|
|
75
|
+
const targetId = this.attachTo.substring(1);
|
|
76
|
+
const resolved = resolveId(targetId, this);
|
|
77
|
+
// remove all children
|
|
78
|
+
while (resolved.firstChild) {
|
|
79
|
+
resolved.removeChild(resolved.firstChild);
|
|
109
80
|
}
|
|
81
|
+
if (this.awaitEvent) {
|
|
82
|
+
let resolveEvent;
|
|
83
|
+
const waitForEvent = new Promise(resolve => {
|
|
84
|
+
resolveEvent = resolve;
|
|
85
|
+
});
|
|
86
|
+
const eventListener = () => {
|
|
87
|
+
resolveEvent();
|
|
88
|
+
resolved.removeEventListener(this.awaitEvent, eventListener);
|
|
89
|
+
};
|
|
110
90
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
this.dispatchEvent(
|
|
115
|
-
new CustomEvent('error', {
|
|
116
|
-
composed: false,
|
|
117
|
-
bubbles: true,
|
|
118
|
-
cancelable:true,
|
|
119
|
-
detail: {
|
|
120
|
-
origin:this,
|
|
121
|
-
message: `neither template element nor Url was specified.`,
|
|
122
|
-
level:'Error'},
|
|
123
|
-
}),
|
|
124
|
-
);
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const resolvedUrl = this.evaluateAttributeTemplateExpression(this.url,this);
|
|
128
|
-
if (this.attachTo === '_blank') {
|
|
129
|
-
window.open(this.url);
|
|
130
|
-
}
|
|
91
|
+
resolved.appendChild(content);
|
|
92
|
+
resolved.addEventListener(this.awaitEvent, eventListener);
|
|
131
93
|
|
|
132
|
-
|
|
133
|
-
window.location.href = this.url;
|
|
134
|
-
}
|
|
94
|
+
await waitForEvent;
|
|
135
95
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
credentials: 'same-origin',
|
|
141
|
-
headers: {
|
|
142
|
-
'Content-Type': "text/html",
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
const data = await response.text();
|
|
146
|
-
// console.log('data loaded: ', data);
|
|
147
|
-
// const data = Fore.loadHtml(resolvedUrl);
|
|
148
|
-
|
|
149
|
-
// todo: if data contain '<template' element as first child instanciate and insert it
|
|
150
|
-
if (!this.attachTo) {
|
|
151
|
-
this.innerHtml = data;
|
|
152
|
-
}
|
|
153
|
-
this._attachToElement(data);
|
|
154
|
-
Fore.dispatch(this, 'loaded', {url: this.url})
|
|
155
|
-
} catch (error) {
|
|
156
|
-
throw new Error(`failed loading data ${error}`);
|
|
96
|
+
this.needsUpdate = true;
|
|
97
|
+
|
|
98
|
+
Fore.dispatch(this, 'loaded', { attachPoint: this.attachTo, content });
|
|
99
|
+
return;
|
|
157
100
|
}
|
|
101
|
+
|
|
102
|
+
resolved.appendChild(content);
|
|
103
|
+
|
|
104
|
+
this.needsUpdate = true;
|
|
105
|
+
}
|
|
106
|
+
Fore.dispatch(this, 'loaded', {});
|
|
107
|
+
return;
|
|
158
108
|
}
|
|
159
109
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
110
|
+
if (!this.url) {
|
|
111
|
+
// for authoring errors we log errors directly to DOM
|
|
112
|
+
|
|
113
|
+
this.dispatchEvent(
|
|
114
|
+
new CustomEvent('error', {
|
|
115
|
+
composed: false,
|
|
116
|
+
bubbles: true,
|
|
117
|
+
cancelable: true,
|
|
118
|
+
detail: {
|
|
119
|
+
origin: this,
|
|
120
|
+
message: 'neither template element nor Url was specified.',
|
|
121
|
+
level: 'Error',
|
|
122
|
+
},
|
|
123
|
+
}),
|
|
124
|
+
);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const resolvedUrl = this.evaluateAttributeTemplateExpression(this.url, this);
|
|
128
|
+
if (this.attachTo === '_blank') {
|
|
129
|
+
window.open(this.url);
|
|
130
|
+
}
|
|
171
131
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
132
|
+
if (this.attachTo === '_self') {
|
|
133
|
+
window.location.href = this.url;
|
|
134
|
+
}
|
|
175
135
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
136
|
+
try {
|
|
137
|
+
const response = await fetch(resolvedUrl, {
|
|
138
|
+
method: 'GET',
|
|
139
|
+
mode: 'cors',
|
|
140
|
+
credentials: 'same-origin',
|
|
141
|
+
headers: {
|
|
142
|
+
'Content-Type': 'text/html',
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
const data = await response.text();
|
|
146
|
+
// console.log('data loaded: ', data);
|
|
147
|
+
// const data = Fore.loadHtml(resolvedUrl);
|
|
148
|
+
|
|
149
|
+
// todo: if data contain '<template' element as first child instanciate and insert it
|
|
150
|
+
if (!this.attachTo) {
|
|
151
|
+
this.innerHtml = data;
|
|
152
|
+
}
|
|
153
|
+
this._attachToElement(data);
|
|
154
|
+
Fore.dispatch(this, 'loaded', { url: this.url });
|
|
155
|
+
} catch (error) {
|
|
156
|
+
throw new Error(`failed loading data ${error}`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
_attachToElement(content) {
|
|
161
|
+
let effectiveContent;
|
|
162
|
+
if (content.nodeType) {
|
|
163
|
+
effectiveContent = content;
|
|
164
|
+
} else {
|
|
165
|
+
try {
|
|
166
|
+
effectiveContent = new DOMParser().parseFromString(content, 'text/html').firstElementChild;
|
|
167
|
+
} catch (e) {
|
|
168
|
+
Fore.dispatch(this, 'error', { message: 'parsing of content as HTML failed' });
|
|
169
|
+
}
|
|
188
170
|
}
|
|
189
171
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
172
|
+
if (!(this.attachTo.startsWith('_') || this.attachTo.startsWith('#'))) {
|
|
173
|
+
Fore.dispatch(this, 'error', {
|
|
174
|
+
message: 'valid values for "attach-to" start with "_" or "#"',
|
|
175
|
+
});
|
|
176
|
+
}
|
|
195
177
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
return match;
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
return replaced;
|
|
178
|
+
if (this.attachTo.startsWith('#')) {
|
|
179
|
+
const targetId = this.attachTo.substring(1);
|
|
180
|
+
const resolved = resolveId(targetId, this);
|
|
181
|
+
resolved.innerHTML = '';
|
|
182
|
+
// resolved.innerHTML = effectiveContent;
|
|
183
|
+
if (effectiveContent.querySelector('fx-fore')) {
|
|
184
|
+
resolved.append(effectiveContent.querySelector('fx-fore').cloneNode(true));
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const body = effectiveContent.querySelector('body').cloneNode(true);
|
|
188
|
+
resolved.appendChild(body.firstElementChild);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
_evaluateUrlExpression() {
|
|
193
|
+
const url = this.getAttribute('url');
|
|
194
|
+
if (!url) {
|
|
195
|
+
throw new Error('url not specified');
|
|
218
196
|
}
|
|
219
197
|
|
|
198
|
+
const replaced = url.replace(/{[^}]*}/g, match => {
|
|
199
|
+
if (match === '{}') return match;
|
|
200
|
+
const naked = match.substring(1, match.length - 1);
|
|
201
|
+
const inscope = getInScopeContext(this, naked);
|
|
202
|
+
if (!inscope) {
|
|
203
|
+
console.warn('no inscope context for ', this);
|
|
204
|
+
return match;
|
|
205
|
+
}
|
|
206
|
+
// Templates are special: they use the namespace configuration from the place where they are
|
|
207
|
+
// being defined
|
|
208
|
+
const instanceId = XPathUtil.getInstanceId(naked);
|
|
209
|
+
|
|
210
|
+
// If there is an instance referred
|
|
211
|
+
const inst = instanceId
|
|
212
|
+
? this.getModel().getInstance(instanceId)
|
|
213
|
+
: this.getModel().getDefaultInstance();
|
|
214
|
+
try {
|
|
215
|
+
return evaluateXPathToString(naked, inscope, this, null, inst);
|
|
216
|
+
} catch (error) {
|
|
217
|
+
console.warn('ignoring unparseable url', error);
|
|
218
|
+
return match;
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
return replaced;
|
|
222
|
+
}
|
|
220
223
|
}
|
|
221
224
|
|
|
222
225
|
if (!customElements.get('fx-load')) {
|
|
223
|
-
|
|
226
|
+
window.customElements.define('fx-load', FxLoad);
|
|
224
227
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractAction } from './abstract-action.js';
|
|
2
|
-
import {evaluateXPathToString} from
|
|
3
|
-
import {Fore} from
|
|
2
|
+
import { evaluateXPathToString } from '../xpath-evaluation.js';
|
|
3
|
+
import { Fore } from '../fore.js';
|
|
4
4
|
import getInScopeContext from '../getInScopeContext.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -16,18 +16,18 @@ class FxMessage extends AbstractAction {
|
|
|
16
16
|
this.attachShadow({ mode: 'open' });
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
static get properties() {
|
|
20
|
+
return {
|
|
21
|
+
...AbstractAction.properties,
|
|
22
|
+
modelItem: undefined,
|
|
23
|
+
messageTextContent: {
|
|
24
|
+
type: String,
|
|
25
|
+
get value() {
|
|
26
|
+
return 'here!';
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
31
|
|
|
32
32
|
connectedCallback() {
|
|
33
33
|
super.connectedCallback();
|
|
@@ -35,7 +35,7 @@ class FxMessage extends AbstractAction {
|
|
|
35
35
|
this.level = this.hasAttribute('level') ? this.getAttribute('level') : 'ephemeral';
|
|
36
36
|
this.message = '';
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
this.messageTextContent = this.textContent;
|
|
39
39
|
const style = `
|
|
40
40
|
:host{
|
|
41
41
|
display:none;
|
|
@@ -49,7 +49,7 @@ class FxMessage extends AbstractAction {
|
|
|
49
49
|
`;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
/*
|
|
52
|
+
/*
|
|
53
53
|
disconnectedCallback() {
|
|
54
54
|
// super.disconnectedCallback();
|
|
55
55
|
this.targetElement.removeEventListener(this.event, e => this.execute(e));
|
|
@@ -68,7 +68,7 @@ class FxMessage extends AbstractAction {
|
|
|
68
68
|
if (this.hasAttribute('value')) {
|
|
69
69
|
this.message = this._getValue();
|
|
70
70
|
} else {
|
|
71
|
-
|
|
71
|
+
this.getOwnerForm().evaluateTemplateExpression(this.messageTextContent, this.firstChild);
|
|
72
72
|
this.message = this.textContent;
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -76,7 +76,7 @@ class FxMessage extends AbstractAction {
|
|
|
76
76
|
new CustomEvent('message', {
|
|
77
77
|
composed: false,
|
|
78
78
|
bubbles: true,
|
|
79
|
-
detail: { level: this.level, message:this.message },
|
|
79
|
+
detail: { level: this.level, message: this.message },
|
|
80
80
|
}),
|
|
81
81
|
);
|
|
82
82
|
}
|
|
@@ -97,7 +97,6 @@ class FxMessage extends AbstractAction {
|
|
|
97
97
|
}
|
|
98
98
|
return null;
|
|
99
99
|
}
|
|
100
|
-
|
|
101
100
|
}
|
|
102
101
|
|
|
103
102
|
if (!customElements.get('fx-message')) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AbstractAction } from './abstract-action.js';
|
|
2
2
|
import { Fore } from '../fore.js';
|
|
3
|
-
import {resolveId} from
|
|
4
|
-
import {XPathUtil} from
|
|
3
|
+
import { resolveId } from '../xpath-evaluation.js';
|
|
4
|
+
import { XPathUtil } from '../xpath-util.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* `fx-refresh`
|
|
@@ -12,12 +12,12 @@ import {XPathUtil} from "../xpath-util.js";
|
|
|
12
12
|
class FxRefresh extends AbstractAction {
|
|
13
13
|
async perform() {
|
|
14
14
|
this.dispatchEvent(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
new CustomEvent('execute-action', {
|
|
16
|
+
composed: true,
|
|
17
|
+
bubbles: true,
|
|
18
|
+
cancelable: true,
|
|
19
|
+
detail: { action: this, event: this.event },
|
|
20
|
+
}),
|
|
21
21
|
);
|
|
22
22
|
|
|
23
23
|
if (this.hasAttribute('self')) {
|
|
@@ -28,12 +28,12 @@ class FxRefresh extends AbstractAction {
|
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
if(this.hasAttribute('force')){
|
|
31
|
+
if (this.hasAttribute('force')) {
|
|
32
32
|
console.log(`### <<<<< refresh() force ${this} >>>>>`);
|
|
33
33
|
this.getOwnerForm().forceRefresh();
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
-
if(this.hasAttribute('control')){
|
|
36
|
+
if (this.hasAttribute('control')) {
|
|
37
37
|
const targetId = this.getAttribute('control');
|
|
38
38
|
console.log(`### <<<<< refresh() control '${targetId}' >>>>>`);
|
|
39
39
|
const ctrl = resolveId(targetId, this);
|
package/src/actions/fx-reload.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractAction } from './abstract-action.js';
|
|
2
|
-
import {Fore} from
|
|
2
|
+
import { Fore } from '../fore.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* `fx-reload`
|
|
@@ -10,24 +10,27 @@ import {Fore} from "../fore.js";
|
|
|
10
10
|
* @demo demo/project.html
|
|
11
11
|
*/
|
|
12
12
|
export class FxReload extends AbstractAction {
|
|
13
|
-
|
|
14
13
|
connectedCallback() {
|
|
15
|
-
if(super.connectedCallback){
|
|
16
|
-
|
|
14
|
+
if (super.connectedCallback) {
|
|
15
|
+
super.connectedCallback();
|
|
17
16
|
}
|
|
18
|
-
this.addEventListener(
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
this.addEventListener(
|
|
18
|
+
'reload',
|
|
19
|
+
() => {
|
|
20
|
+
window.location.reload();
|
|
21
|
+
},
|
|
22
|
+
{ once: true },
|
|
23
|
+
);
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
async perform() {
|
|
24
27
|
this.dispatchEvent(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
new CustomEvent('execute-action', {
|
|
29
|
+
composed: true,
|
|
30
|
+
bubbles: true,
|
|
31
|
+
cancelable: true,
|
|
32
|
+
detail: { action: this, event: this.event },
|
|
33
|
+
}),
|
|
31
34
|
);
|
|
32
35
|
|
|
33
36
|
Fore.dispatch(this, 'reload', {});
|
|
@@ -37,4 +40,3 @@ export class FxReload extends AbstractAction {
|
|
|
37
40
|
if (!customElements.get('fx-reload')) {
|
|
38
41
|
window.customElements.define('fx-reload', FxReload);
|
|
39
42
|
}
|
|
40
|
-
|