@jinntec/fore 3.3.1 → 4.0.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 +98 -70
- package/dist/fore-dev.js +5593 -6832
- package/dist/fore.js +5602 -4887
- package/index.js +5 -10
- package/package.json +7 -7
- package/resources/fore.css +33 -0
- package/src/DependencyNotifyingDomFacade.js +90 -21
- package/src/DependentXPathQueries.js +15 -2
- package/src/ForeElementMixin.js +110 -16
- package/src/UndoManager.js +267 -0
- package/src/actions/abstract-action.js +71 -30
- package/src/actions/fx-action.js +5 -0
- package/src/actions/fx-append.js +3 -3
- package/src/actions/fx-commit-history.js +26 -0
- package/src/actions/fx-hide.js +1 -1
- package/src/actions/fx-insert.js +25 -22
- package/src/actions/fx-load.js +5 -5
- package/src/actions/fx-redo.js +58 -0
- package/src/actions/fx-refresh.js +2 -2
- package/src/actions/fx-reload.js +1 -1
- package/src/actions/fx-replace.js +1 -1
- package/src/actions/fx-send.js +27 -5
- package/src/actions/fx-setattribute.js +11 -7
- package/src/actions/fx-undo.js +58 -0
- package/src/createNodes.js +314 -0
- package/src/fore.js +53 -18
- package/src/functions/fx-functionlib.js +10 -10
- package/src/fx-bind.js +30 -18
- package/src/fx-fore.js +222 -200
- package/src/fx-instance.js +18 -1
- package/src/fx-model.js +236 -69
- package/src/fx-submission.js +37 -29
- package/src/fx-var.js +49 -13
- package/src/getInScopeContext.js +1 -1
- package/src/json/JSONDomFacade.js +1 -1
- package/src/json/JSONLens.js +2 -2
- package/src/ui/UIElement.js +18 -8
- package/src/ui/abstract-control.js +45 -3
- package/src/ui/fx-alert.js +4 -0
- package/src/ui/fx-case.js +1 -1
- package/src/ui/fx-container.js +3 -0
- package/src/ui/fx-control-menu.js +79 -11
- package/src/ui/fx-control.js +130 -41
- package/src/ui/fx-dialog.js +5 -0
- package/src/ui/fx-items.js +6 -6
- package/src/ui/fx-output.js +37 -1
- package/src/ui/fx-repeat.js +1065 -103
- package/src/ui/fx-repeatitem.js +4 -1
- package/src/ui/fx-switch.js +116 -3
- package/src/ui/fx-trigger.js +9 -4
- package/src/ui/fx-upload.js +10 -4
- package/src/ui/repeat-base.js +20 -12
- package/src/withDraggability.js +10 -1
- package/src/xpath-evaluation.js +30 -18
- package/src/xpath-path.js +122 -0
- package/src/xpath-util.js +11 -126
- package/src/actions/StringTpl.js +0 -17
- package/src/extract-predicate-deps.js +0 -57
- package/src/extractPredicateDependencies.js +0 -36
- package/src/json/lensFromNode.js +0 -5
- package/src/json-util.js +0 -27
- package/src/tools/adi.js +0 -1111
- package/src/tools/deprecation.md +0 -1
- package/src/tools/fx-action-log.js +0 -745
- package/src/tools/fx-devtools.js +0 -444
- package/src/tools/fx-dom-inspector.js +0 -610
- package/src/tools/fx-json-instance.js +0 -444
- package/src/tools/fx-log-item.js +0 -128
- package/src/tools/fx-log-settings.js +0 -533
- package/src/tools/fx-minimap.js +0 -203
- package/src/tools/helpers.js +0 -132
- package/src/ui/TemplateExpression.js +0 -12
- package/src/ui/fx-dom-inspector.js +0 -1255
|
@@ -1,745 +0,0 @@
|
|
|
1
|
-
import { XPathUtil } from '../xpath-util.js';
|
|
2
|
-
import './fx-log-item.js';
|
|
3
|
-
import { FxLogSettings } from './fx-log-settings.js';
|
|
4
|
-
import { getDocPath, getPath } from '../xpath-path.js';
|
|
5
|
-
|
|
6
|
-
export class FxActionLog extends HTMLElement {
|
|
7
|
-
constructor() {
|
|
8
|
-
super();
|
|
9
|
-
this.attachShadow({ mode: 'open' });
|
|
10
|
-
this.listenTo = [];
|
|
11
|
-
this.listeners = [];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
connectedCallback() {
|
|
15
|
-
const style = `
|
|
16
|
-
:host {
|
|
17
|
-
display:block;
|
|
18
|
-
position:relative;
|
|
19
|
-
width:100%;
|
|
20
|
-
border:thin solid #efefef;
|
|
21
|
-
background:transparent;
|
|
22
|
-
font-family: Verdana, Sans;
|
|
23
|
-
margin:0;
|
|
24
|
-
padding:0.25rem;
|
|
25
|
-
}
|
|
26
|
-
a,a:link,a:visited{
|
|
27
|
-
color:black;
|
|
28
|
-
}
|
|
29
|
-
a{
|
|
30
|
-
position:relative;
|
|
31
|
-
}
|
|
32
|
-
a[alt]:hover::after {
|
|
33
|
-
content:attr(alt);
|
|
34
|
-
position:absolute;
|
|
35
|
-
left:0;
|
|
36
|
-
bottom:-0.5em;
|
|
37
|
-
border:thin solid;
|
|
38
|
-
padding:0.5em;
|
|
39
|
-
background:white;
|
|
40
|
-
z-index:1;
|
|
41
|
-
min-width:5em;
|
|
42
|
-
border:thin solid;
|
|
43
|
-
max-width:90%;
|
|
44
|
-
}
|
|
45
|
-
.details{
|
|
46
|
-
padding:0.25em 0;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.key{
|
|
50
|
-
width:20%;
|
|
51
|
-
display:inline-block;
|
|
52
|
-
min-width:5rem;
|
|
53
|
-
border-bottom:1px solid #ddd;
|
|
54
|
-
background:#efefef;
|
|
55
|
-
vertical-align:top;
|
|
56
|
-
}
|
|
57
|
-
.value{
|
|
58
|
-
display:inline-block;
|
|
59
|
-
width:60%;
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.buttons{
|
|
64
|
-
position:absolute;
|
|
65
|
-
top:0;
|
|
66
|
-
right:0;
|
|
67
|
-
}
|
|
68
|
-
.buttons button{
|
|
69
|
-
padding:0;
|
|
70
|
-
}
|
|
71
|
-
button{
|
|
72
|
-
float:right;
|
|
73
|
-
}
|
|
74
|
-
button{
|
|
75
|
-
border:none;
|
|
76
|
-
background:transparent;
|
|
77
|
-
width:2.25rem;
|
|
78
|
-
height:2.25rem;
|
|
79
|
-
cursor:pointer;
|
|
80
|
-
}
|
|
81
|
-
button#reset{
|
|
82
|
-
padding:0;
|
|
83
|
-
height:1rem;
|
|
84
|
-
}
|
|
85
|
-
.info{
|
|
86
|
-
padding:0 0.5em;
|
|
87
|
-
margin:0.1rem 0;
|
|
88
|
-
background:white;
|
|
89
|
-
position:relative;
|
|
90
|
-
display:grid;
|
|
91
|
-
grid-template-areas: "left right"
|
|
92
|
-
"bottom .";
|
|
93
|
-
grid-template-columns: 75% 25%;
|
|
94
|
-
}
|
|
95
|
-
.info a{
|
|
96
|
-
grid-area:right;
|
|
97
|
-
justify-self:end;
|
|
98
|
-
}
|
|
99
|
-
.details > section{
|
|
100
|
-
display:flex;
|
|
101
|
-
flex-wrap:wrap;
|
|
102
|
-
padding:0.5em 0;
|
|
103
|
-
}
|
|
104
|
-
fx-log-item{
|
|
105
|
-
}
|
|
106
|
-
header{
|
|
107
|
-
padding:0.5rem;
|
|
108
|
-
margin:0;
|
|
109
|
-
border-bottom:2px solid #ddd;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.info:hover{
|
|
113
|
-
outline:3px solid lightblue;
|
|
114
|
-
transition:height 0.4s;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
ol{
|
|
118
|
-
background: #efefef;
|
|
119
|
-
padding: 0.5em 0 0 2em;
|
|
120
|
-
border-left:3px solid red;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.event-name{
|
|
124
|
-
display:inline-block;
|
|
125
|
-
}
|
|
126
|
-
#log{
|
|
127
|
-
margin-bottom:10em;
|
|
128
|
-
margin-right:2em;
|
|
129
|
-
}
|
|
130
|
-
.log-row{
|
|
131
|
-
margin:0;
|
|
132
|
-
padding:0;
|
|
133
|
-
position:relative;
|
|
134
|
-
font-size:0.8em;
|
|
135
|
-
border-left:4px solid transparent;
|
|
136
|
-
padding-left:5px;
|
|
137
|
-
width:calc(100% - 2em);
|
|
138
|
-
margin-bottom:0.25em;
|
|
139
|
-
}
|
|
140
|
-
.log-row summary{
|
|
141
|
-
display:flex;
|
|
142
|
-
flex-wrap:wrap;
|
|
143
|
-
padding:0.5em 0;
|
|
144
|
-
cursor:pointer;
|
|
145
|
-
}
|
|
146
|
-
.log-row summary > span {
|
|
147
|
-
width:calc(90% div 3);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.log-name{
|
|
151
|
-
position:relative;
|
|
152
|
-
}
|
|
153
|
-
.short-info{
|
|
154
|
-
flex:3;
|
|
155
|
-
overflow:hidden;
|
|
156
|
-
white-space:nowrap;
|
|
157
|
-
text-overflow:ellipsis;
|
|
158
|
-
}
|
|
159
|
-
.log-row.no-detail summary{
|
|
160
|
-
position:relative;
|
|
161
|
-
}
|
|
162
|
-
.log-row.no-detail summary{
|
|
163
|
-
list-style:none;
|
|
164
|
-
padding-left:1rem;
|
|
165
|
-
}
|
|
166
|
-
.log-row.no-detail summary::-webkit-details-marker {
|
|
167
|
-
display: none;
|
|
168
|
-
}
|
|
169
|
-
.log-row.nested{
|
|
170
|
-
margin-left:1em;
|
|
171
|
-
}
|
|
172
|
-
.nested .event-name{
|
|
173
|
-
display:none;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
.setvalue .value{
|
|
177
|
-
background:lightyellow;
|
|
178
|
-
}
|
|
179
|
-
summary{
|
|
180
|
-
padding:1em;
|
|
181
|
-
border-bottom:2px solid #ddd;
|
|
182
|
-
}
|
|
183
|
-
.outer-details{
|
|
184
|
-
height:100%;
|
|
185
|
-
overflow:auto;
|
|
186
|
-
margin-top:2rem;
|
|
187
|
-
background:rgba(250, 250, 250, 0.9);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
.outer-details > header{
|
|
191
|
-
position:absolute;
|
|
192
|
-
top:-1px;
|
|
193
|
-
width:calc(100% - 2rem);
|
|
194
|
-
border-bottom:2px solid #ddd;
|
|
195
|
-
font-size:1rem;
|
|
196
|
-
height:1rem;
|
|
197
|
-
}
|
|
198
|
-
.outer-details > summary{
|
|
199
|
-
font-size:1em;
|
|
200
|
-
}
|
|
201
|
-
ul{
|
|
202
|
-
list-style:none;
|
|
203
|
-
padding:0;
|
|
204
|
-
margin:0.1em 0;
|
|
205
|
-
border-left:3px solid steelblue;
|
|
206
|
-
padding:0.1em 0;
|
|
207
|
-
}
|
|
208
|
-
ul .log-row{
|
|
209
|
-
padding-left:3px;
|
|
210
|
-
width:calc(100% - 1em);
|
|
211
|
-
}
|
|
212
|
-
`;
|
|
213
|
-
|
|
214
|
-
if (localStorage.getItem('fx-action-log-filters')) {
|
|
215
|
-
this.listenTo = JSON.parse(localStorage.getItem('fx-action-log-filters'));
|
|
216
|
-
} else {
|
|
217
|
-
this.listenTo = FxLogSettings.defaultSettings();
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (localStorage.getItem('fx-log-settings')) {
|
|
221
|
-
this.listenTo = JSON.parse(localStorage.getItem('fx-log-settings'));
|
|
222
|
-
} else {
|
|
223
|
-
this.listenTo = FxLogSettings.defaultSettings();
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const html = `
|
|
227
|
-
<section open class="outer-details">
|
|
228
|
-
<header>Log
|
|
229
|
-
<span class="buttons">
|
|
230
|
-
<button id="del"" title="empty log - Ctrl+d">
|
|
231
|
-
<svg viewBox="0 0 24 24" style="width:24px;height:24px;" preserveAspectRatio="xMidYMid meet" focusable="true"><g><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zm2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12zM15.5 4l-1-1h-5l-1 1H5v2h14V4z"></path></g></svg></a>
|
|
232
|
-
</button>
|
|
233
|
-
</span>
|
|
234
|
-
</header>
|
|
235
|
-
<div id="log"></div>
|
|
236
|
-
</section>
|
|
237
|
-
`;
|
|
238
|
-
|
|
239
|
-
this.shadowRoot.innerHTML = `
|
|
240
|
-
<style>
|
|
241
|
-
${style}
|
|
242
|
-
</style>
|
|
243
|
-
${html}
|
|
244
|
-
`;
|
|
245
|
-
|
|
246
|
-
const fore = window.document.querySelector('fx-fore');
|
|
247
|
-
if (!fore) {
|
|
248
|
-
console.error('fx-fore element not found in this page.');
|
|
249
|
-
}
|
|
250
|
-
const log = this.shadowRoot.querySelector('#log');
|
|
251
|
-
// fore.classList.add('action-log');
|
|
252
|
-
|
|
253
|
-
this.listenTo.forEach(eventName => {
|
|
254
|
-
if (eventName.show) {
|
|
255
|
-
document.addEventListener(eventName.name, e => {
|
|
256
|
-
this._log(e, log);
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
// const boxes = this.shadowRoot.querySelector('.boxes');
|
|
262
|
-
|
|
263
|
-
/*
|
|
264
|
-
build the list of checkboxes for the filtering settings
|
|
265
|
-
*/
|
|
266
|
-
/*
|
|
267
|
-
this.listenTo.forEach(item => {
|
|
268
|
-
const wrapper = document.createElement('span');
|
|
269
|
-
boxes.append(wrapper);
|
|
270
|
-
|
|
271
|
-
const lbl = document.createElement('label');
|
|
272
|
-
lbl.setAttribute('title', item.description);
|
|
273
|
-
lbl.setAttribute('for', item.name);
|
|
274
|
-
lbl.innerText = item.name;
|
|
275
|
-
|
|
276
|
-
const cbx = document.createElement('input');
|
|
277
|
-
cbx.setAttribute('type', 'checkbox');
|
|
278
|
-
cbx.setAttribute('name', item.name);
|
|
279
|
-
cbx.setAttribute('id', item.name);
|
|
280
|
-
if (item.show) {
|
|
281
|
-
cbx.setAttribute('checked', '');
|
|
282
|
-
}
|
|
283
|
-
wrapper.append(cbx);
|
|
284
|
-
wrapper.append(lbl);
|
|
285
|
-
|
|
286
|
-
cbx.addEventListener('click', e => {
|
|
287
|
-
console.log('filter box ticked', e);
|
|
288
|
-
if (!e.target.checked) {
|
|
289
|
-
// remove event listener
|
|
290
|
-
const fore = document.querySelector('fx-fore');
|
|
291
|
-
fore.removeEventListener(item.name, this._log);
|
|
292
|
-
// e.preventDefault();
|
|
293
|
-
// e.stopPropagation();
|
|
294
|
-
}
|
|
295
|
-
const t = this.listenTo.find(evt => evt.name === item.name);
|
|
296
|
-
e.target.checked ? t.show = true : t.show = false;
|
|
297
|
-
// console.log('filter', this.listenTo);
|
|
298
|
-
localStorage.setItem('fx-action-log-filters', JSON.stringify(this.listenTo));
|
|
299
|
-
})
|
|
300
|
-
// boxes.appendChild(lbl);
|
|
301
|
-
});
|
|
302
|
-
*/
|
|
303
|
-
|
|
304
|
-
document.addEventListener(
|
|
305
|
-
'outermost-action-start',
|
|
306
|
-
e => {
|
|
307
|
-
this.outermost = true;
|
|
308
|
-
},
|
|
309
|
-
{ capture: true },
|
|
310
|
-
);
|
|
311
|
-
document.addEventListener(
|
|
312
|
-
'outermost-action-end',
|
|
313
|
-
e => {
|
|
314
|
-
this.outermost = false;
|
|
315
|
-
this.outermostAppender = null;
|
|
316
|
-
},
|
|
317
|
-
{ capture: true },
|
|
318
|
-
);
|
|
319
|
-
|
|
320
|
-
// buttons
|
|
321
|
-
const del = this.shadowRoot.querySelector('#del');
|
|
322
|
-
del.addEventListener('click', e => {
|
|
323
|
-
this.shadowRoot.querySelector('#log').innerHTML = '';
|
|
324
|
-
});
|
|
325
|
-
document.addEventListener('keydown', event => {
|
|
326
|
-
if (event.ctrlKey && event.key === 'd') {
|
|
327
|
-
this.shadowRoot.querySelector('#log').innerHTML = '';
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
_defaultSettings() {
|
|
333
|
-
this.listenTo = [
|
|
334
|
-
{
|
|
335
|
-
name: 'action-performed',
|
|
336
|
-
show: false,
|
|
337
|
-
description: 'fires after an action has been performed',
|
|
338
|
-
},
|
|
339
|
-
{ name: 'click', show: false, description: '' },
|
|
340
|
-
{
|
|
341
|
-
name: 'deleted',
|
|
342
|
-
show: false,
|
|
343
|
-
description: 'fires after a delete action has been executed',
|
|
344
|
-
},
|
|
345
|
-
{ name: 'deselect', show: false, description: 'fires when fx-case is deselected' },
|
|
346
|
-
{ name: 'dialog-hidden', show: false, description: 'fires after fx-dialog has been hidden' },
|
|
347
|
-
{ name: 'dialog-shown', show: false, description: 'fired when a dialog has been shown' },
|
|
348
|
-
{ name: 'error', show: false, description: 'fires after an error occurred' },
|
|
349
|
-
{ name: 'execute-action', show: true, description: 'fires when an action executes' },
|
|
350
|
-
{ name: 'init', show: false, description: 'fires when a control initializes' },
|
|
351
|
-
{ name: 'index-changed', show: false, description: 'fires when the repeat index changes' },
|
|
352
|
-
{ name: 'insert', show: false, description: 'fires when an fx-insert is executed' },
|
|
353
|
-
{
|
|
354
|
-
name: 'instance-loaded',
|
|
355
|
-
show: false,
|
|
356
|
-
description: 'fires after an fx-instance has been loaded',
|
|
357
|
-
},
|
|
358
|
-
{ name: 'invalid', show: false, description: 'fires after a control became invalid' },
|
|
359
|
-
{ name: 'item-changed', show: false, description: 'fires when a repeat item was changed' },
|
|
360
|
-
{ name: 'item-created', show: false, description: 'fires when a repeat item was created' },
|
|
361
|
-
{ name: 'loaded', show: false, description: 'fires after a fx-load has loaded' },
|
|
362
|
-
{ name: 'model-construct', show: false, description: 'fires when a model gets constructed' },
|
|
363
|
-
{
|
|
364
|
-
name: 'model-construct-done',
|
|
365
|
-
show: false,
|
|
366
|
-
description: 'fires after model initialization',
|
|
367
|
-
},
|
|
368
|
-
{
|
|
369
|
-
name: 'nonrelevant',
|
|
370
|
-
show: false,
|
|
371
|
-
description: 'fires after an fx-control became nonrelevant',
|
|
372
|
-
},
|
|
373
|
-
{ name: 'optional', show: false, description: 'fires after an fx-control became optional' },
|
|
374
|
-
{
|
|
375
|
-
name: 'outermost-action-end',
|
|
376
|
-
show: false,
|
|
377
|
-
description: 'fires when an outermost action block is finished',
|
|
378
|
-
},
|
|
379
|
-
{
|
|
380
|
-
name: 'outermost-action-start',
|
|
381
|
-
show: false,
|
|
382
|
-
description: 'fires when an outermost action block is started',
|
|
383
|
-
},
|
|
384
|
-
{
|
|
385
|
-
name: 'path-mutated',
|
|
386
|
-
show: false,
|
|
387
|
-
description: 'fires when a path in a repeat has been mutated',
|
|
388
|
-
},
|
|
389
|
-
{ name: 'readonly', show: false, description: 'fires after an fx-control became readonly' },
|
|
390
|
-
{ name: 'readwrite', show: false, description: 'fires after an fx-control became readwrite' },
|
|
391
|
-
{
|
|
392
|
-
name: 'ready',
|
|
393
|
-
show: false,
|
|
394
|
-
description: 'fires after a fx-fore page has been completely initialized',
|
|
395
|
-
},
|
|
396
|
-
{ name: 'rebuild-done', show: false, description: 'fires after a rebuild has taken place' },
|
|
397
|
-
{
|
|
398
|
-
name: 'recalculate-done',
|
|
399
|
-
show: false,
|
|
400
|
-
description: 'fires after a recalculate has taken place',
|
|
401
|
-
},
|
|
402
|
-
{ name: 'refresh-done', show: false, description: 'fires after a refresh has been done' },
|
|
403
|
-
{
|
|
404
|
-
name: 'relevant',
|
|
405
|
-
show: false,
|
|
406
|
-
description: 'fires after a fx-control has become relevant',
|
|
407
|
-
},
|
|
408
|
-
{ name: 'reload', show: false, description: 'fires when a fx-reload action executes' },
|
|
409
|
-
{
|
|
410
|
-
name: 'required',
|
|
411
|
-
show: false,
|
|
412
|
-
description: 'fires after an fx-control has become required',
|
|
413
|
-
},
|
|
414
|
-
{
|
|
415
|
-
name: 'return',
|
|
416
|
-
show: false,
|
|
417
|
-
description: 'fired by embedded Fore controls to return their bound value',
|
|
418
|
-
},
|
|
419
|
-
{ name: 'select', show: false, description: 'fires when an fx-case has been selected' },
|
|
420
|
-
{ name: 'submit', show: false, description: 'fires before a submission takes place' },
|
|
421
|
-
{
|
|
422
|
-
name: 'submit-done',
|
|
423
|
-
show: false,
|
|
424
|
-
description: 'fires after a submission has successfully been executed',
|
|
425
|
-
},
|
|
426
|
-
{
|
|
427
|
-
name: 'submit-error',
|
|
428
|
-
show: false,
|
|
429
|
-
description: 'fires when a submission returned an error',
|
|
430
|
-
},
|
|
431
|
-
{ name: 'valid', show: false, description: 'fires after a fx-control has become valid' },
|
|
432
|
-
{
|
|
433
|
-
name: 'value-changed',
|
|
434
|
-
show: false,
|
|
435
|
-
description: 'fires after a fx-control has changed its value',
|
|
436
|
-
},
|
|
437
|
-
];
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
_log(e, log) {
|
|
441
|
-
const elementName = e.target.nodeName;
|
|
442
|
-
if (elementName === 'FX-ACTION-LOG') return;
|
|
443
|
-
// e.preventDefault();
|
|
444
|
-
// e.stopPropagation();
|
|
445
|
-
|
|
446
|
-
const row = document.createElement('div');
|
|
447
|
-
row.classList.add('log-row');
|
|
448
|
-
const logRow = this._logDetails(e);
|
|
449
|
-
if (
|
|
450
|
-
e.detail &&
|
|
451
|
-
Object.keys(e.detail).length === 0 &&
|
|
452
|
-
Object.getPrototypeOf(e.detail) === Object.prototype
|
|
453
|
-
) {
|
|
454
|
-
row.classList.add('no-detail');
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
row.innerHTML = logRow;
|
|
458
|
-
if (this.outermost) {
|
|
459
|
-
/*
|
|
460
|
-
outermost-action-start and outermost-action-end are use as marker events only to start/end a list.
|
|
461
|
-
They don't have aditional information to log.
|
|
462
|
-
*/
|
|
463
|
-
if (e.type === 'outermost-action-start') return; // we don't want this event to actualy log something
|
|
464
|
-
if (!this.outermostAppender) {
|
|
465
|
-
this.outermostAppender = document.createElement('ul');
|
|
466
|
-
log.append(this.outermostAppender);
|
|
467
|
-
}
|
|
468
|
-
const li = document.createElement('li');
|
|
469
|
-
// li.innerHTML = logRow;
|
|
470
|
-
li.append(row);
|
|
471
|
-
this.outermostAppender.append(li);
|
|
472
|
-
} else {
|
|
473
|
-
log.append(row);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
if (this.parentPath && elementName !== 'FX-ACTION') {
|
|
477
|
-
row.classList.add('nested');
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
const targetElement = e.target;
|
|
481
|
-
row.addEventListener('click', ev => {
|
|
482
|
-
// console.log('clicked inspect item', targetElement);
|
|
483
|
-
// console.log('clicked inspect item', ev.target.getAttribute('xpath'));
|
|
484
|
-
|
|
485
|
-
this._highlight(targetElement);
|
|
486
|
-
});
|
|
487
|
-
|
|
488
|
-
const logRowTarget = row.querySelector('.event-target');
|
|
489
|
-
if (!logRowTarget) return;
|
|
490
|
-
|
|
491
|
-
logRowTarget.addEventListener('click', e => {
|
|
492
|
-
const alreadyLogged = document.querySelectorAll('.fx-action-log-debug');
|
|
493
|
-
alreadyLogged.forEach(logged => {
|
|
494
|
-
logged.classList.remove('fx-action-log-debug');
|
|
495
|
-
});
|
|
496
|
-
|
|
497
|
-
targetElement.dispatchEvent(
|
|
498
|
-
new CustomEvent('log-action', {
|
|
499
|
-
composed: false,
|
|
500
|
-
bubbles: true,
|
|
501
|
-
cancelable: true,
|
|
502
|
-
detail: { target: targetElement },
|
|
503
|
-
}),
|
|
504
|
-
);
|
|
505
|
-
|
|
506
|
-
targetElement.classList.add('fx-action-log-debug');
|
|
507
|
-
targetElement.setAttribute('data-name', targetElement.nodeName);
|
|
508
|
-
this._highlight(targetElement);
|
|
509
|
-
});
|
|
510
|
-
// log.append(logElements);
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
/**
|
|
514
|
-
* logs all configured events.
|
|
515
|
-
* Special treatment is given to action-execute event to log out all actions that
|
|
516
|
-
* are triggered.
|
|
517
|
-
*
|
|
518
|
-
* @param e the event to log
|
|
519
|
-
* @returns {string}
|
|
520
|
-
* @private
|
|
521
|
-
*/
|
|
522
|
-
_logDetails(e) {
|
|
523
|
-
const eventType = e.type;
|
|
524
|
-
const path = getDocPath(e.target);
|
|
525
|
-
// console.log('>>>> _logDetails', path);
|
|
526
|
-
const cut = path.substring(path.indexOf('/fx-fore'), path.length);
|
|
527
|
-
const xpath = `/${cut}`;
|
|
528
|
-
const short = cut.replaceAll('fx-', '');
|
|
529
|
-
|
|
530
|
-
if (this.parentPath && !xpath.startsWith(this.parentPath)) {
|
|
531
|
-
this.parentPath = null;
|
|
532
|
-
}
|
|
533
|
-
switch (eventType) {
|
|
534
|
-
case 'deleted':
|
|
535
|
-
const { deletedNodes } = e.detail;
|
|
536
|
-
const s = new XMLSerializer();
|
|
537
|
-
let serialized = '';
|
|
538
|
-
deletedNodes.forEach(node => {
|
|
539
|
-
serialized += s.serializeToString(node);
|
|
540
|
-
});
|
|
541
|
-
|
|
542
|
-
return `
|
|
543
|
-
<fx-log-item event-name="${eventType}"
|
|
544
|
-
xpath="${xpath}"
|
|
545
|
-
short-info="${e.detail.ref}"
|
|
546
|
-
short-name="${e.target.nodeName.toLowerCase()}">
|
|
547
|
-
<section class="details">
|
|
548
|
-
<header>Details</header>
|
|
549
|
-
<section>
|
|
550
|
-
<span class="key">Deleted Nodes</span>
|
|
551
|
-
<textarea class="value" rows="5">${serialized.trim()}</textarea>
|
|
552
|
-
</section>
|
|
553
|
-
</section>
|
|
554
|
-
</fx-log-item>
|
|
555
|
-
`;
|
|
556
|
-
break;
|
|
557
|
-
case 'outermost-action-start':
|
|
558
|
-
return 'start';
|
|
559
|
-
break;
|
|
560
|
-
case 'outermost-action-end':
|
|
561
|
-
return '';
|
|
562
|
-
break;
|
|
563
|
-
case 'execute-action':
|
|
564
|
-
// ##### here actions will be handled
|
|
565
|
-
const actionElement = e.detail.action;
|
|
566
|
-
return this._renderAction(actionElement, xpath, short, e);
|
|
567
|
-
break;
|
|
568
|
-
default:
|
|
569
|
-
return `
|
|
570
|
-
<fx-log-item event-name="${eventType}"
|
|
571
|
-
xpath="${xpath}"
|
|
572
|
-
short-name="${e.target.nodeName.toLowerCase()}">
|
|
573
|
-
|
|
574
|
-
<section class="details">
|
|
575
|
-
${this._listEventDetails(e)}
|
|
576
|
-
</section>
|
|
577
|
-
</fx-log-item>
|
|
578
|
-
`;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
// }
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
_renderAction(actionElement, xpath, short, e) {
|
|
585
|
-
const stripped = actionElement.nodeName.split('-')[1];
|
|
586
|
-
let eventName;
|
|
587
|
-
switch (actionElement.nodeName) {
|
|
588
|
-
case 'FX-ACTION':
|
|
589
|
-
this.parentPath = xpath;
|
|
590
|
-
eventName = e.target.currentEvent
|
|
591
|
-
? e.target.currentEvent.type
|
|
592
|
-
: e.detail.event
|
|
593
|
-
? e.detail.event
|
|
594
|
-
: '';
|
|
595
|
-
|
|
596
|
-
return `
|
|
597
|
-
<fx-log-item event-name="${eventName}"
|
|
598
|
-
xpath="${xpath}"
|
|
599
|
-
short-name="ACTION"
|
|
600
|
-
data-path="${e.detail.path}"
|
|
601
|
-
class="action">
|
|
602
|
-
<section class="details">
|
|
603
|
-
<header>Attributes</header>
|
|
604
|
-
<section>
|
|
605
|
-
${Array.from(actionElement.attributes)
|
|
606
|
-
.map(
|
|
607
|
-
item => `
|
|
608
|
-
<span class="key">${item.nodeName}</span>
|
|
609
|
-
<span class="value">${item.nodeValue}</span>
|
|
610
|
-
`,
|
|
611
|
-
)
|
|
612
|
-
.join('')}
|
|
613
|
-
</section>
|
|
614
|
-
</section>
|
|
615
|
-
</fx-log-item>
|
|
616
|
-
`;
|
|
617
|
-
// break;
|
|
618
|
-
case 'FX-MESSAGE':
|
|
619
|
-
const message = e.detail.action.messageTextContent;
|
|
620
|
-
return `
|
|
621
|
-
<fx-log-item event-name="${e.detail.event}"
|
|
622
|
-
xpath="${xpath}"
|
|
623
|
-
short-name="MESSAGE"
|
|
624
|
-
short-info="${message}" class="action">
|
|
625
|
-
<section class="details">
|
|
626
|
-
<span>${message}</span>
|
|
627
|
-
</section>
|
|
628
|
-
</fx-log-item>
|
|
629
|
-
`;
|
|
630
|
-
// break;
|
|
631
|
-
case 'FX-SEND':
|
|
632
|
-
const submission = document.querySelector(`#${e.detail.action.getAttribute('submission')}`);
|
|
633
|
-
const event = e.detail.event ? e.detail.event : '';
|
|
634
|
-
return `
|
|
635
|
-
<fx-log-item short-name="SEND"
|
|
636
|
-
short-info="${submission.getAttribute('id')}"
|
|
637
|
-
event-name="${event}"
|
|
638
|
-
xpath="${xpath}" class="action"
|
|
639
|
-
data-path="${e.detail.path}" >
|
|
640
|
-
<section class="details">
|
|
641
|
-
<header>Submission</header>
|
|
642
|
-
<section class="attributes">
|
|
643
|
-
${Array.from(submission.attributes)
|
|
644
|
-
.map(
|
|
645
|
-
item => `
|
|
646
|
-
<span class="key">${item.nodeName}</span>
|
|
647
|
-
<span class="value">${item.nodeValue}</span>
|
|
648
|
-
`,
|
|
649
|
-
)
|
|
650
|
-
.join('')}
|
|
651
|
-
</section>
|
|
652
|
-
</section>
|
|
653
|
-
</fx-log-item>
|
|
654
|
-
`;
|
|
655
|
-
// break;
|
|
656
|
-
case 'FX-SETVALUE':
|
|
657
|
-
const instanceId = XPathUtil.getInstanceId(xpath, actionElement);
|
|
658
|
-
const instPath = getPath(e.target.nodeset, instanceId);
|
|
659
|
-
const listensOn =
|
|
660
|
-
e.target.nodeName === 'FX-CONTROL'
|
|
661
|
-
? e.target.updateEvent
|
|
662
|
-
: e.detail.event
|
|
663
|
-
? e.detail.event
|
|
664
|
-
: '';
|
|
665
|
-
return `
|
|
666
|
-
<fx-log-item short-name="SETVALUE"
|
|
667
|
-
short-info="${instPath}"
|
|
668
|
-
event-name="${listensOn}"
|
|
669
|
-
xpath="${xpath}"
|
|
670
|
-
data-path="${e.detail.path}" class="action">
|
|
671
|
-
<section class="details">
|
|
672
|
-
<span class="key">value</span>
|
|
673
|
-
<span class="value">${e.detail.value}</span>
|
|
674
|
-
</section>
|
|
675
|
-
</fx-log-item>
|
|
676
|
-
`;
|
|
677
|
-
// break;
|
|
678
|
-
default:
|
|
679
|
-
eventName = e.target.currentEvent
|
|
680
|
-
? e.target.currentEvent.type
|
|
681
|
-
: e.detail.event
|
|
682
|
-
? e.detail.event
|
|
683
|
-
: '';
|
|
684
|
-
return `
|
|
685
|
-
<fx-log-item event-name="${eventName}"
|
|
686
|
-
short-name="${e.target.nodeName}"
|
|
687
|
-
xpath="${xpath}"
|
|
688
|
-
data-path="${e.detail.path}"
|
|
689
|
-
class="action">
|
|
690
|
-
<section class="details">
|
|
691
|
-
</section>
|
|
692
|
-
</fx-log-item>
|
|
693
|
-
`;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
_listEventDetails(e) {
|
|
698
|
-
if (
|
|
699
|
-
e.detail &&
|
|
700
|
-
Object.keys(e.detail).length === 0 &&
|
|
701
|
-
Object.getPrototypeOf(e.detail) === Object.prototype
|
|
702
|
-
) {
|
|
703
|
-
return '';
|
|
704
|
-
}
|
|
705
|
-
return `${Object.keys(e.detail).map(item => `<span>${item}</span>`)}`;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
_listAttributes(e) {
|
|
709
|
-
// console.log('_listAttributes', e)
|
|
710
|
-
return '';
|
|
711
|
-
// return `${e.detail.model.id}`;
|
|
712
|
-
/*
|
|
713
|
-
if(e.detail &&
|
|
714
|
-
Object.keys(e.detail).length === 0 &&
|
|
715
|
-
Object.getPrototypeOf(e.detail) === Object.prototype){
|
|
716
|
-
return ``;
|
|
717
|
-
}else{
|
|
718
|
-
return `${e.detail.map((item) => `<span>${item}</span>`)}`;
|
|
719
|
-
}
|
|
720
|
-
*/
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
_highlight(element) {
|
|
724
|
-
const defaultBG = element.style.backgroundColor;
|
|
725
|
-
const defaultTransition = element.style.transition;
|
|
726
|
-
|
|
727
|
-
element.style.transition = 'background 1s';
|
|
728
|
-
element.style.backgroundColor = '#FFA500';
|
|
729
|
-
|
|
730
|
-
setTimeout(() => {
|
|
731
|
-
element.style.backgroundColor = defaultBG;
|
|
732
|
-
setTimeout(() => {
|
|
733
|
-
element.style.transition = defaultTransition;
|
|
734
|
-
}, 400);
|
|
735
|
-
}, 400);
|
|
736
|
-
|
|
737
|
-
window.document.dispatchEvent(
|
|
738
|
-
new CustomEvent('log-active-element', { detail: { target: element } }),
|
|
739
|
-
);
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
if (!customElements.get('fx-action-log')) {
|
|
744
|
-
customElements.define('fx-action-log', FxActionLog);
|
|
745
|
-
}
|