@jinntec/fore 1.2.0 → 1.4.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 +8 -8
- package/dist/fore-dev.js.map +1 -1
- package/dist/fore.js +7 -7
- package/dist/fore.js.map +1 -1
- package/index.js +1 -0
- package/package.json +2 -2
- package/resources/fore.css +100 -72
- package/src/ForeElementMixin.js +4 -0
- package/src/actions/abstract-action.js +102 -18
- package/src/actions/fx-action.js +9 -10
- package/src/actions/fx-append.js +1 -1
- package/src/actions/fx-confirm.js +3 -3
- package/src/actions/fx-copy.js +68 -0
- package/src/actions/fx-delete.js +53 -62
- package/src/actions/fx-dispatch.js +1 -1
- package/src/actions/fx-hide.js +4 -2
- package/src/actions/fx-insert.js +1 -1
- package/src/actions/fx-message.js +26 -2
- package/src/actions/fx-refresh.js +2 -2
- package/src/actions/fx-reload.js +30 -0
- package/src/actions/fx-replace.js +1 -1
- package/src/actions/fx-return.js +1 -1
- package/src/actions/fx-send.js +13 -3
- package/src/actions/fx-setfocus.js +33 -6
- package/src/actions/fx-setvalue.js +5 -5
- package/src/actions/fx-show.js +2 -1
- package/src/actions/fx-toggle.js +6 -1
- package/src/actions/fx-update.js +1 -1
- package/src/events.js +24 -0
- package/src/fore.js +128 -17
- package/src/fx-bind.js +6 -1
- package/src/fx-fore.js +93 -41
- package/src/fx-instance.js +95 -70
- package/src/fx-model.js +430 -441
- package/src/fx-submission.js +423 -405
- package/src/getInScopeContext.js +88 -82
- package/src/modelitem.js +5 -3
- package/src/relevance.js +1 -1
- package/src/ui/abstract-control.js +108 -22
- package/src/ui/fx-alert.js +0 -1
- package/src/ui/fx-container.js +22 -26
- package/src/ui/fx-control.js +84 -34
- package/src/ui/fx-group.js +5 -0
- package/src/ui/fx-inspector.js +5 -0
- package/src/ui/fx-output.js +14 -14
- package/src/ui/fx-repeat.js +2 -2
- package/src/ui/fx-repeatitem.js +5 -3
- package/src/ui/fx-switch.js +20 -8
- package/src/ui/fx-trigger.js +26 -19
- package/src/xpath-evaluation.js +49 -26
- package/src/xpath-util.js +26 -28
package/src/actions/fx-delete.js
CHANGED
|
@@ -1,83 +1,74 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {AbstractAction} from './abstract-action.js';
|
|
2
|
+
import {Fore} from '../fore.js';
|
|
3
|
+
import {evaluateXPathToNodes} from "../xpath-evaluation.js";
|
|
4
|
+
import {XPathUtil} from "../xpath-util";
|
|
5
|
+
import getInScopeContext from '../getInScopeContext.js';
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* `fx-delete`
|
|
6
|
-
*
|
|
9
|
+
* deletes nodes from instance data.
|
|
7
10
|
*
|
|
11
|
+
* @fires deleted event
|
|
8
12
|
* @customElement
|
|
9
13
|
* @demo demo/todo.html
|
|
10
14
|
*/
|
|
11
15
|
class FxDelete extends AbstractAction {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* deletes a
|
|
19
|
-
*/
|
|
20
|
-
perform() {
|
|
21
|
-
super.perform();
|
|
22
|
-
console.log('##### fx-delete executing...');
|
|
23
|
-
|
|
24
|
-
// this.ref = this.getAttribute('ref');
|
|
25
|
-
// const inscope = this.getInScopeContext();
|
|
26
|
-
// this.nodeset = fx.evaluateXPathToNodes(this.ref, inscope, null, {});
|
|
27
|
-
|
|
28
|
-
console.log('delete nodeset ', this.nodeset);
|
|
29
|
-
|
|
30
|
-
// ### if there's no repeat the delete action is inside of a repeat template
|
|
31
|
-
if (this.repeatId === '') {
|
|
32
|
-
// find the index to delete
|
|
33
|
-
const rItem = Fore.getClosest('fx-repeatitem', this.parentNode);
|
|
34
|
-
const idx = Array.from(rItem.parentNode.children).indexOf(rItem) + 1;
|
|
35
|
-
// console.log('>>> idx to delete ', idx);
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
}
|
|
36
19
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
20
|
+
/**
|
|
21
|
+
* deletes nodes from instance data.
|
|
22
|
+
*
|
|
23
|
+
* Will NOT perform delete if nodeset is pointing to document node, document fragment, root node or being readonly.
|
|
24
|
+
*/
|
|
25
|
+
async perform() {
|
|
26
|
+
console.log('##### fx-delete executing...');
|
|
27
|
+
const inscopeContext = getInScopeContext(this.getAttributeNode('ref') || this, this.ref);
|
|
28
|
+
this.nodeset = evaluateXPathToNodes(this.ref, inscopeContext, this);
|
|
40
29
|
|
|
41
|
-
|
|
42
|
-
let nodeToDelete;
|
|
43
|
-
if (Array.isArray(this.nodeset)) {
|
|
44
|
-
nodeToDelete = this.nodeset[idx - 1];
|
|
45
|
-
} else {
|
|
46
|
-
nodeToDelete = this.nodeset;
|
|
47
|
-
}
|
|
48
|
-
const p = nodeToDelete.parentNode;
|
|
49
|
-
p.removeChild(nodeToDelete);
|
|
30
|
+
console.log('delete nodeset ', this.nodeset);
|
|
50
31
|
|
|
51
|
-
|
|
52
|
-
|
|
32
|
+
const nodesToDelete = this.nodeset;
|
|
33
|
+
let parent;
|
|
34
|
+
if (Array.isArray(nodesToDelete)) {
|
|
35
|
+
if(nodesToDelete.length === 0) return;
|
|
36
|
+
parent = nodesToDelete[0].parentNode;
|
|
37
|
+
nodesToDelete.forEach(item => {
|
|
38
|
+
this._deleteNode(parent, item);
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
parent = nodesToDelete.parentNode;
|
|
42
|
+
this._deleteNode(parent, nodesToDelete);
|
|
43
|
+
}
|
|
53
44
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
} else if (idx > repeatSize) {
|
|
59
|
-
repeat.setIndex(repeatSize);
|
|
60
|
-
} else {
|
|
61
|
-
repeat.setIndex(idx);
|
|
62
|
-
}
|
|
45
|
+
const instanceId = XPathUtil.resolveInstance(this);
|
|
46
|
+
const instance = this.getModel().getInstance(instanceId);
|
|
47
|
+
Fore.dispatch(instance, 'deleted', {deletedNodes:nodesToDelete});
|
|
48
|
+
this.needsUpdate = true;
|
|
63
49
|
}
|
|
64
50
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
51
|
+
_deleteNode(parent, node) {
|
|
52
|
+
if (parent.nodeType === Node.DOCUMENT_NODE) return;
|
|
53
|
+
if (node.nodeType === Node.DOCUMENT_NODE) return;
|
|
54
|
+
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) return;
|
|
55
|
+
if (node.parentNode === null) return;
|
|
69
56
|
|
|
70
|
-
|
|
57
|
+
const mi = this.getModelItem();
|
|
58
|
+
if (mi.readonly) return;
|
|
71
59
|
|
|
72
|
-
|
|
73
|
-
|
|
60
|
+
parent.removeChild(node);
|
|
61
|
+
}
|
|
74
62
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
63
|
+
/**
|
|
64
|
+
* overwriting as we need to perform additional rebuild()
|
|
65
|
+
*/
|
|
66
|
+
actionPerformed() {
|
|
67
|
+
this.getModel().rebuild();
|
|
68
|
+
super.actionPerformed();
|
|
69
|
+
}
|
|
79
70
|
}
|
|
80
71
|
|
|
81
72
|
if (!customElements.get('fx-delete')) {
|
|
82
|
-
|
|
73
|
+
window.customElements.define('fx-delete', FxDelete);
|
|
83
74
|
}
|
package/src/actions/fx-hide.js
CHANGED
|
@@ -17,8 +17,10 @@ export class FxHide extends AbstractAction {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
perform() {
|
|
21
|
-
resolveId(this.dialog, this)
|
|
20
|
+
async perform() {
|
|
21
|
+
const dialog = resolveId(this.dialog, this);
|
|
22
|
+
dialog.hide();
|
|
23
|
+
Fore.dispatch(dialog,'dialog-hidden',{})
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
|
package/src/actions/fx-insert.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { AbstractAction } from './abstract-action.js';
|
|
2
|
+
import {evaluateXPathToString} from "../xpath-evaluation";
|
|
3
|
+
import {Fore} from "../fore";
|
|
4
|
+
import getInScopeContext from '../getInScopeContext.js';
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* `fx-message`
|
|
@@ -17,6 +20,8 @@ class FxMessage extends AbstractAction {
|
|
|
17
20
|
super.connectedCallback();
|
|
18
21
|
this.event = this.hasAttribute('event') ? this.getAttribute('event') : '';
|
|
19
22
|
this.level = this.hasAttribute('level') ? this.getAttribute('level') : 'ephemeral';
|
|
23
|
+
|
|
24
|
+
this.messageTextContent = this.textContent;
|
|
20
25
|
const style = `
|
|
21
26
|
:host{
|
|
22
27
|
display:none;
|
|
@@ -42,12 +47,13 @@ class FxMessage extends AbstractAction {
|
|
|
42
47
|
`;
|
|
43
48
|
}
|
|
44
49
|
|
|
45
|
-
perform() {
|
|
50
|
+
async perform() {
|
|
46
51
|
super.perform();
|
|
47
52
|
let message;
|
|
48
53
|
if (this.hasAttribute('value')) {
|
|
49
|
-
message = this.
|
|
54
|
+
message = this._getValue();
|
|
50
55
|
} else {
|
|
56
|
+
this.getOwnerForm().evaluateTemplateExpression(this.messageTextContent, this.firstChild);
|
|
51
57
|
message = this.textContent;
|
|
52
58
|
}
|
|
53
59
|
|
|
@@ -59,6 +65,24 @@ class FxMessage extends AbstractAction {
|
|
|
59
65
|
}),
|
|
60
66
|
);
|
|
61
67
|
}
|
|
68
|
+
|
|
69
|
+
_getValue() {
|
|
70
|
+
if (this.hasAttribute('value')) {
|
|
71
|
+
const valAttr = this.getAttribute('value');
|
|
72
|
+
try {
|
|
73
|
+
const inscopeContext = getInScopeContext(this, valAttr);
|
|
74
|
+
return evaluateXPathToString(valAttr, inscopeContext, this);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error(error);
|
|
77
|
+
Fore.dispatch(this, 'error', { message: error });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (this.textContent) {
|
|
81
|
+
return this.textContent;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
62
86
|
}
|
|
63
87
|
|
|
64
88
|
if (!customElements.get('fx-message')) {
|
|
@@ -9,7 +9,7 @@ import {resolveId} from "../xpath-evaluation.js";
|
|
|
9
9
|
*
|
|
10
10
|
*/
|
|
11
11
|
class FxRefresh extends AbstractAction {
|
|
12
|
-
perform() {
|
|
12
|
+
async perform() {
|
|
13
13
|
if (this.hasAttribute('self')) {
|
|
14
14
|
const control = Fore.getClosest('fx-control', this);
|
|
15
15
|
if (control) {
|
|
@@ -24,7 +24,7 @@ class FxRefresh extends AbstractAction {
|
|
|
24
24
|
if(this.hasAttribute('control')){
|
|
25
25
|
const targetId = this.getAttribute('control');
|
|
26
26
|
const ctrl = resolveId(targetId, this);
|
|
27
|
-
if (Fore.isUiElement(ctrl.nodeName) && typeof ctrl.refresh === 'function') {
|
|
27
|
+
if (ctrl && Fore.isUiElement(ctrl.nodeName) && typeof ctrl.refresh === 'function') {
|
|
28
28
|
ctrl.refresh();
|
|
29
29
|
}
|
|
30
30
|
return;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Fore } from '../fore.js';
|
|
2
|
+
import { AbstractAction } from './abstract-action.js';
|
|
3
|
+
import { resolveId } from '../xpath-evaluation.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `fx-reload`
|
|
7
|
+
* reloads browser window when receiving 'reload' event
|
|
8
|
+
*
|
|
9
|
+
* @event reload dispatched when action executes. Usually calls its own handler but might get cancelled by other handler.
|
|
10
|
+
* @customElement
|
|
11
|
+
* @demo demo/project.html
|
|
12
|
+
*/
|
|
13
|
+
export class FxReload extends AbstractAction {
|
|
14
|
+
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
super.connectedCallback();
|
|
17
|
+
this.addEventListener('reload', event => {
|
|
18
|
+
window.location.reload();
|
|
19
|
+
},{once:true});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async perform() {
|
|
23
|
+
Fore.dispatch(this, 'reload', {});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!customElements.get('fx-reload')) {
|
|
28
|
+
window.customElements.define('fx-reload', FxReload);
|
|
29
|
+
}
|
|
30
|
+
|
|
@@ -32,7 +32,7 @@ export default class FxReplace extends AbstractAction {
|
|
|
32
32
|
this.with = this.getAttribute('with');
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
perform() {
|
|
35
|
+
async perform() {
|
|
36
36
|
super.perform();
|
|
37
37
|
console.log('replace action');
|
|
38
38
|
// console.log('replace action variables', this.inScopeVariables);
|
package/src/actions/fx-return.js
CHANGED
|
@@ -20,7 +20,7 @@ export class FxReturn extends AbstractAction {
|
|
|
20
20
|
// const nonrelevant = this.hasAttribute('nonrelevant') ? this.getAttribute('nonrelevant') : null;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
perform() {
|
|
23
|
+
async perform() {
|
|
24
24
|
super.perform();
|
|
25
25
|
console.log('performing return with nodes', this.nodeset);
|
|
26
26
|
|
package/src/actions/fx-send.js
CHANGED
|
@@ -5,6 +5,7 @@ import { AbstractAction } from './abstract-action.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* `fx-send` - finds and activates a `fx-submission` element.
|
|
7
7
|
*
|
|
8
|
+
* extension idea: allow params to be passed as with dispatch action which can be used to set properties on submission attributes
|
|
8
9
|
*
|
|
9
10
|
* @customElement
|
|
10
11
|
*/
|
|
@@ -21,13 +22,16 @@ class FxSend extends AbstractAction {
|
|
|
21
22
|
this.submission = this.getAttribute('submission');
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
perform() {
|
|
25
|
+
async perform() {
|
|
25
26
|
super.perform();
|
|
26
27
|
|
|
27
28
|
console.log('submitting ', this.submission);
|
|
28
|
-
console.log('submitting model', this.getModel());
|
|
29
|
+
// console.log('submitting model', this.getModel());
|
|
29
30
|
|
|
30
31
|
// if not exists signal error
|
|
32
|
+
// todo: instead of relying on model just use pure dom to find submission as the context could be broken due to a delete action
|
|
33
|
+
// const fore = this.closest('fx-fore');
|
|
34
|
+
// const submission = fore.querySelector(`#${this.submission}`);
|
|
31
35
|
const submission = this.getModel().querySelector(`#${this.submission}`);
|
|
32
36
|
if (submission === null) {
|
|
33
37
|
this.dispatchEvent(
|
|
@@ -40,7 +44,13 @@ class FxSend extends AbstractAction {
|
|
|
40
44
|
throw new Error(`submission with id: ${this.submission} not found`);
|
|
41
45
|
}
|
|
42
46
|
console.log('submission', submission);
|
|
43
|
-
|
|
47
|
+
await submission.submit();
|
|
48
|
+
/*
|
|
49
|
+
if(submission.replace === 'instance'){
|
|
50
|
+
this.getModel().updateModel();
|
|
51
|
+
this.getOwnerForm().refresh();
|
|
52
|
+
}
|
|
53
|
+
*/
|
|
44
54
|
// if not of type fx-submission signal error
|
|
45
55
|
}
|
|
46
56
|
}
|
|
@@ -3,7 +3,7 @@ import {resolveId} from "../xpath-evaluation";
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* `fx-setfocus`
|
|
6
|
-
* Set the focus to a target control.
|
|
6
|
+
* Set the focus to a target control optionally selecting eventual value in case a `select` attribute is given.
|
|
7
7
|
*
|
|
8
8
|
* @customElement
|
|
9
9
|
*/
|
|
@@ -13,25 +13,52 @@ export class FxSetfocus extends AbstractAction {
|
|
|
13
13
|
this.control = this.hasAttribute('control') ? this.getAttribute('control') : null;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
perform() {
|
|
16
|
+
async perform() {
|
|
17
17
|
console.log('setting focus', this.control);
|
|
18
18
|
// super.perform();
|
|
19
|
-
|
|
20
|
-
// const targetElement = resolveId(this.control, this);
|
|
21
19
|
const selector = '#'+this.control;
|
|
22
|
-
|
|
20
|
+
|
|
21
|
+
let targetElement = this.getOwnerForm().querySelector(selector);;
|
|
22
|
+
|
|
23
|
+
// ### focus action is itself hosted within a repeat
|
|
24
|
+
const parentIItem = this.closest('fx-repeatitem');
|
|
25
|
+
if(parentIItem){
|
|
26
|
+
console.log('parentRepeat',parentIItem);
|
|
27
|
+
targetElement = parentIItem.querySelector(selector);
|
|
28
|
+
this._focus(targetElement);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ### the target element is hosted within a repeat
|
|
23
33
|
const repeatitem = targetElement.closest('fx-repeatitem, .fx-repeatitem');
|
|
24
34
|
if(repeatitem){
|
|
25
35
|
// targetElement is repeated
|
|
26
36
|
// get the active repeatitem (only for fx-repeat for now - todo: support repeat attributes
|
|
27
37
|
const repeat = repeatitem.parentNode;
|
|
28
38
|
targetElement = repeat.querySelector('[repeat-index] ' + selector);
|
|
39
|
+
}
|
|
29
40
|
|
|
41
|
+
this._focus(targetElement);
|
|
42
|
+
if(this.hasAttribute('select')){
|
|
43
|
+
this._select(targetElement);
|
|
30
44
|
}
|
|
31
|
-
targetElement.getWidget().focus();
|
|
32
45
|
}
|
|
46
|
+
|
|
47
|
+
_focus(targetElement){
|
|
48
|
+
if(targetElement){
|
|
49
|
+
targetElement.getWidget().focus();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
_select(targetElement){
|
|
54
|
+
if(targetElement){
|
|
55
|
+
targetElement.getWidget().select();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
33
59
|
}
|
|
34
60
|
|
|
61
|
+
|
|
35
62
|
if (!customElements.get('fx-setfocus')) {
|
|
36
63
|
window.customElements.define('fx-setfocus', FxSetfocus);
|
|
37
64
|
}
|
|
@@ -40,7 +40,7 @@ export default class FxSetvalue extends AbstractAction {
|
|
|
40
40
|
this.valueAttr = this.getAttribute('value');
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
perform() {
|
|
43
|
+
async perform() {
|
|
44
44
|
super.perform();
|
|
45
45
|
let {value} = this;
|
|
46
46
|
if (this.valueAttr !== null) {
|
|
@@ -52,16 +52,17 @@ export default class FxSetvalue extends AbstractAction {
|
|
|
52
52
|
}
|
|
53
53
|
console.log('value', value);
|
|
54
54
|
if (value.nodeType === Node.ATTRIBUTE_NODE) {
|
|
55
|
-
console.log('value', value.nodeValue);
|
|
55
|
+
// console.log('value', value.nodeValue);
|
|
56
56
|
value = value.nodeValue;
|
|
57
57
|
}
|
|
58
58
|
const mi = this.getModelItem();
|
|
59
59
|
this.setValue(mi, value);
|
|
60
|
+
// todo: check this again - logically needsUpate should be set but makes tests fail
|
|
61
|
+
// this.needsUpdate = true;
|
|
62
|
+
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
setValue(modelItem, newVal) {
|
|
63
|
-
console.log('setvalue[1] ', modelItem, newVal);
|
|
64
|
-
|
|
65
66
|
const item = modelItem;
|
|
66
67
|
if (!item) return;
|
|
67
68
|
|
|
@@ -69,7 +70,6 @@ export default class FxSetvalue extends AbstractAction {
|
|
|
69
70
|
item.value = newVal;
|
|
70
71
|
this.getModel().changed.push(modelItem);
|
|
71
72
|
this.needsUpdate = true;
|
|
72
|
-
console.log('setvalue[2] ', item, newVal);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
}
|
package/src/actions/fx-show.js
CHANGED
|
@@ -17,12 +17,13 @@ export class FxShow extends FxAction {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
perform() {
|
|
20
|
+
async perform() {
|
|
21
21
|
const targetDlg = resolveId(this.dialog,this);
|
|
22
22
|
if(!targetDlg){
|
|
23
23
|
console.error('target dialog with given id does not exist',this.dialog);
|
|
24
24
|
}
|
|
25
25
|
targetDlg.open();
|
|
26
|
+
Fore.dispatch(targetDlg,'dialog-shown',{});
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
|
package/src/actions/fx-toggle.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AbstractAction } from './abstract-action.js';
|
|
2
|
+
import {Fore} from "../fore";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* `fx-toggle`
|
|
@@ -18,12 +19,16 @@ class FxToggle extends AbstractAction {
|
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
perform() {
|
|
22
|
+
async perform() {
|
|
22
23
|
super.perform();
|
|
23
24
|
console.log('### fx-toggle.execute ');
|
|
24
25
|
if (this.case) {
|
|
25
26
|
const ownerForm = this.getOwnerForm();
|
|
26
27
|
const caseElement = ownerForm.querySelector(`#${this.case}`);
|
|
28
|
+
if(!caseElement){
|
|
29
|
+
Fore.dispatch(this, 'error', { message: `fx-case id not found: ${this.case}` });
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
27
32
|
const fxSwitch = caseElement.parentNode;
|
|
28
33
|
fxSwitch.toggle(caseElement);
|
|
29
34
|
}
|
package/src/actions/fx-update.js
CHANGED
package/src/events.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function leadingDebounce(caller, func, timeout = 300){
|
|
2
|
+
console.log('debouncing', func);
|
|
3
|
+
let timer;
|
|
4
|
+
return (...args) => {
|
|
5
|
+
if (!timer) {
|
|
6
|
+
func.apply(caller, args);
|
|
7
|
+
}
|
|
8
|
+
clearTimeout(timer);
|
|
9
|
+
timer = setTimeout(() => {
|
|
10
|
+
timer = undefined;
|
|
11
|
+
return null;
|
|
12
|
+
}, timeout);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function debounce(caller, func, timeout = 300) {
|
|
17
|
+
let timer;
|
|
18
|
+
return (...args) => {
|
|
19
|
+
clearTimeout(timer);
|
|
20
|
+
timer = setTimeout(() => {
|
|
21
|
+
func.apply(caller, args);
|
|
22
|
+
}, timeout);
|
|
23
|
+
};
|
|
24
|
+
}
|