not-bulma 1.0.93 → 1.0.95
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/package.json +1 -1
- package/src/elements/common.js +1 -0
- package/src/elements/form/ui.select.svelte +20 -8
- package/src/frame/common.js +7 -0
- package/src/frame/crud/actions/generic/action.js +19 -1
- package/src/frame/crud/actions/generic/create.js +3 -2
- package/src/frame/crud/actions/generic/update.js +3 -2
package/package.json
CHANGED
package/src/elements/common.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
import { LOCALE } from "../../locale";
|
|
3
3
|
import ErrorsList from "../various/ui.errors.list.svelte";
|
|
4
4
|
import UICommon from "../common.js";
|
|
5
|
-
|
|
6
|
-
const CLEAR_MACRO = "__CLEAR__";
|
|
5
|
+
import notCommon from "../../frame/common";
|
|
7
6
|
|
|
8
7
|
import { createEventDispatcher } from "svelte";
|
|
9
8
|
let dispatch = createEventDispatcher();
|
|
@@ -55,19 +54,31 @@
|
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
56
|
|
|
57
|
+
let lastChange;
|
|
58
|
+
|
|
58
59
|
function onBlur(ev) {
|
|
59
60
|
let data = {
|
|
60
61
|
field: fieldname,
|
|
61
62
|
value: ev.currentTarget.value,
|
|
62
63
|
};
|
|
64
|
+
if (lastChange === data.value) {
|
|
65
|
+
return true;
|
|
66
|
+
} else {
|
|
67
|
+
if (
|
|
68
|
+
Array.isArray(data.value) &&
|
|
69
|
+
notCommon.compareTwoArrays(lastChange, data.value)
|
|
70
|
+
) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
63
74
|
if (multiple) {
|
|
64
75
|
value = Array.from(ev.target.selectedOptions).map((el) => el.value);
|
|
65
|
-
if (value.indexOf(CLEAR_MACRO) > -1) {
|
|
76
|
+
if (value.indexOf(UICommon.CLEAR_MACRO) > -1) {
|
|
66
77
|
value = [];
|
|
67
78
|
}
|
|
68
79
|
data.value = value;
|
|
69
80
|
} else {
|
|
70
|
-
if (data.value === CLEAR_MACRO) {
|
|
81
|
+
if (data.value === UICommon.CLEAR_MACRO) {
|
|
71
82
|
value = "";
|
|
72
83
|
}
|
|
73
84
|
}
|
|
@@ -83,16 +94,17 @@
|
|
|
83
94
|
};
|
|
84
95
|
if (multiple) {
|
|
85
96
|
value = Array.from(ev.target.selectedOptions).map((el) => el.value);
|
|
86
|
-
if (value.indexOf(CLEAR_MACRO) > -1) {
|
|
97
|
+
if (value.indexOf(UICommon.CLEAR_MACRO) > -1) {
|
|
87
98
|
value = [];
|
|
88
99
|
}
|
|
89
100
|
data.value = value;
|
|
90
101
|
} else {
|
|
91
|
-
if (data.value === CLEAR_MACRO) {
|
|
102
|
+
if (data.value === UICommon.CLEAR_MACRO) {
|
|
92
103
|
value = "";
|
|
93
104
|
}
|
|
94
105
|
}
|
|
95
106
|
inputStarted = true;
|
|
107
|
+
lastChange = data.value;
|
|
96
108
|
dispatch("change", data);
|
|
97
109
|
return true;
|
|
98
110
|
}
|
|
@@ -117,11 +129,11 @@
|
|
|
117
129
|
>
|
|
118
130
|
{#if placeholder.length > 0}
|
|
119
131
|
{#if value}
|
|
120
|
-
<option value={CLEAR_MACRO}
|
|
132
|
+
<option value={UICommon.CLEAR_MACRO}
|
|
121
133
|
>{$LOCALE[placeholder]}</option
|
|
122
134
|
>
|
|
123
135
|
{:else}
|
|
124
|
-
<option value={CLEAR_MACRO} selected="selected"
|
|
136
|
+
<option value={UICommon.CLEAR_MACRO} selected="selected"
|
|
125
137
|
>{$LOCALE[placeholder]}</option
|
|
126
138
|
>
|
|
127
139
|
{/if}
|
package/src/frame/common.js
CHANGED
|
@@ -220,6 +220,13 @@ class notCommon {
|
|
|
220
220
|
return JSON.parse(JSON.stringify(partObj));
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
static compareTwoArrays(a, b) {
|
|
224
|
+
return (
|
|
225
|
+
a.length === b.length &&
|
|
226
|
+
a.every((element, index) => element === b[index])
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
223
230
|
/**
|
|
224
231
|
* Test argument type to be 'function'
|
|
225
232
|
* @param {any} func possible function
|
|
@@ -207,13 +207,31 @@ class CRUDGenericAction {
|
|
|
207
207
|
*/
|
|
208
208
|
static bindUIEvents(controller, params, response) {
|
|
209
209
|
if (notCommon.isFunc(controller.goBack)) {
|
|
210
|
-
this.
|
|
210
|
+
this.bindUIEvent(
|
|
211
|
+
controller,
|
|
211
212
|
"reject",
|
|
212
213
|
controller.goBack.bind(controller)
|
|
213
214
|
);
|
|
214
215
|
}
|
|
215
216
|
}
|
|
216
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Bind event handler named event to UI. Checks different binder notation $on/on
|
|
220
|
+
* @param {object} controller instance of controller
|
|
221
|
+
* @param {string} event event name
|
|
222
|
+
* @param {function} callback callback function on event
|
|
223
|
+
* @returns
|
|
224
|
+
*/
|
|
225
|
+
static bindUIEvent(controller, event, callback) {
|
|
226
|
+
const ui = this.getUI(controller);
|
|
227
|
+
if (ui.$on) {
|
|
228
|
+
return ui.$on(event, callback);
|
|
229
|
+
}
|
|
230
|
+
if (ui.on) {
|
|
231
|
+
return ui.on(event, callback);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
217
235
|
/**
|
|
218
236
|
* true, if UI of this action already exists,
|
|
219
237
|
* false, if UI of this action wasn't existed and other UIs were destoryed
|
|
@@ -69,13 +69,14 @@ class CRUDGenericActionCreate extends CRUDGenericAction {
|
|
|
69
69
|
*/
|
|
70
70
|
static bindUIEvents(controller, params, response) {
|
|
71
71
|
if (notCommon.isFunc(controller.goBack)) {
|
|
72
|
-
this.
|
|
72
|
+
this.bindUIEvent(
|
|
73
|
+
controller,
|
|
73
74
|
"reject",
|
|
74
75
|
controller.goBack.bind(controller)
|
|
75
76
|
);
|
|
76
77
|
}
|
|
77
78
|
if (notCommon.isFunc(controller.onActionSubmit)) {
|
|
78
|
-
this.
|
|
79
|
+
this.bindUIEvent(controller, "submit", async (ev) => {
|
|
79
80
|
const success = await controller.onActionSubmit(this.ACTION, {
|
|
80
81
|
...this.loadDataQuery(controller, params),
|
|
81
82
|
...ev,
|
|
@@ -79,13 +79,14 @@ class CRUDGenericActionUpdate extends CRUDGenericAction {
|
|
|
79
79
|
*/
|
|
80
80
|
static bindUIEvents(controller, params, response) {
|
|
81
81
|
if (notCommon.isFunc(controller.goBack)) {
|
|
82
|
-
this.
|
|
82
|
+
this.bindUIEvent(
|
|
83
|
+
controller,
|
|
83
84
|
"reject",
|
|
84
85
|
controller.goBack.bind(controller)
|
|
85
86
|
);
|
|
86
87
|
}
|
|
87
88
|
if (notCommon.isFunc(controller.onActionSubmit)) {
|
|
88
|
-
this.
|
|
89
|
+
this.bindUIEvent(controller, "submit", async (ev) => {
|
|
89
90
|
const success = await controller.onActionSubmit(this.ACTION, {
|
|
90
91
|
...this.loadDataQuery(controller, params),
|
|
91
92
|
...ev,
|