quasar-ui-danx 0.4.19 → 0.4.21
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/danx.es.js +2335 -2283
- package/dist/danx.es.js.map +1 -1
- package/dist/danx.umd.js +46 -46
- package/dist/danx.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/ActionTable/Form/Fields/TextField.vue +6 -2
- package/src/helpers/FlashMessages.ts +15 -1
- package/src/helpers/formats.ts +6 -0
- package/src/helpers/objectStore.ts +29 -0
- package/src/types/config.d.ts +1 -0
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
<template>
|
2
|
-
<div>
|
2
|
+
<div class="dx-text-field">
|
3
3
|
<FieldLabel
|
4
4
|
v-if="!prependLabel"
|
5
5
|
:label="label"
|
@@ -33,7 +33,7 @@
|
|
33
33
|
@update:model-value="$emit('update:model-value', $event)"
|
34
34
|
>
|
35
35
|
<template
|
36
|
-
v-if="prependLabel"
|
36
|
+
v-if="prependLabel || $slots.prepend"
|
37
37
|
#prepend
|
38
38
|
>
|
39
39
|
<FieldLabel
|
@@ -43,6 +43,10 @@
|
|
43
43
|
:required-label="requiredLabel"
|
44
44
|
:class="labelClass"
|
45
45
|
/>
|
46
|
+
<slot name="prepend" />
|
47
|
+
</template>
|
48
|
+
<template #append>
|
49
|
+
<slot name="append" />
|
46
50
|
</template>
|
47
51
|
</QInput>
|
48
52
|
<MaxLengthCounter
|
@@ -10,6 +10,10 @@ export class FlashMessages {
|
|
10
10
|
type: String,
|
11
11
|
default: ""
|
12
12
|
},
|
13
|
+
infoMsg: {
|
14
|
+
type: String,
|
15
|
+
default: ""
|
16
|
+
},
|
13
17
|
errorMsg: {
|
14
18
|
type: String,
|
15
19
|
default: ""
|
@@ -20,11 +24,12 @@ export class FlashMessages {
|
|
20
24
|
}
|
21
25
|
};
|
22
26
|
|
23
|
-
static enable(msgProps: { successMsg?: string, errorMsg?: string, warningMsg?: string }) {
|
27
|
+
static enable(msgProps: { successMsg?: string, infoMsg?: string, errorMsg?: string, warningMsg?: string }) {
|
24
28
|
FlashMessages.success(msgProps.successMsg);
|
25
29
|
FlashMessages.error(msgProps.errorMsg);
|
26
30
|
FlashMessages.warning(msgProps.warningMsg);
|
27
31
|
watch(() => msgProps.successMsg, msg => FlashMessages.success(msg));
|
32
|
+
watch(() => msgProps.infoMsg, msg => FlashMessages.info(msg));
|
28
33
|
watch(() => msgProps.errorMsg, msg => FlashMessages.error(msg));
|
29
34
|
watch(() => msgProps.warningMsg, msg => FlashMessages.warning(msg));
|
30
35
|
}
|
@@ -61,6 +66,15 @@ export class FlashMessages {
|
|
61
66
|
});
|
62
67
|
}
|
63
68
|
|
69
|
+
static info(message?: string, options: QNotifyCreateOptions = {}) {
|
70
|
+
FlashMessages.send(message, {
|
71
|
+
classes: "bg-sky-300 !text-sky-900",
|
72
|
+
icon: "info",
|
73
|
+
...options,
|
74
|
+
...danxOptions.value.flashMessages?.info
|
75
|
+
});
|
76
|
+
}
|
77
|
+
|
64
78
|
static error(message?: string, options: QNotifyCreateOptions = {}) {
|
65
79
|
FlashMessages.send(message, {
|
66
80
|
classes: "bg-red-300 !text-red-900",
|
package/src/helpers/formats.ts
CHANGED
@@ -144,6 +144,9 @@ export function fElapsedTime(start: string, end?: string) {
|
|
144
144
|
* Formats an amount into USD currency format
|
145
145
|
*/
|
146
146
|
export function fCurrency(amount: number, options?: object) {
|
147
|
+
if (amount === null || amount === undefined || isNaN(amount)) {
|
148
|
+
return "$-";
|
149
|
+
}
|
147
150
|
return new Intl.NumberFormat("en-US", {
|
148
151
|
style: "currency",
|
149
152
|
currency: "USD",
|
@@ -179,6 +182,9 @@ export function fShortCurrency(value: string | number, options?: { round: boolea
|
|
179
182
|
* Formats a number into a shorthand human-readable format (ie: 1.2M or 5K)
|
180
183
|
*/
|
181
184
|
export function fShortNumber(value: string | number, options?: { round: boolean }) {
|
185
|
+
if (value === "" || value === null || value === undefined) {
|
186
|
+
return "-";
|
187
|
+
}
|
182
188
|
const shorts = [
|
183
189
|
{ pow: 3, unit: "K" },
|
184
190
|
{ pow: 6, unit: "M" },
|
@@ -1,9 +1,19 @@
|
|
1
1
|
import { uid } from "quasar";
|
2
2
|
import { ShallowReactive, shallowReactive } from "vue";
|
3
3
|
import { TypedObject } from "../types";
|
4
|
+
import { FlashMessages } from "./FlashMessages";
|
4
5
|
|
5
6
|
const store = new Map<string, any>();
|
6
7
|
|
8
|
+
export function storeObjects<T extends TypedObject>(newObjects: T[]) {
|
9
|
+
for (const index in newObjects) {
|
10
|
+
if (newObjects[index] && typeof newObjects[index] === "object") {
|
11
|
+
newObjects[index] = storeObject(newObjects[index]);
|
12
|
+
}
|
13
|
+
}
|
14
|
+
return newObjects;
|
15
|
+
}
|
16
|
+
|
7
17
|
/**
|
8
18
|
* Store an object in the object store via type + id
|
9
19
|
* Returns the stored object that should be used instead of the passed object as the returned object is shared across the system
|
@@ -56,3 +66,22 @@ export function storeObject<T extends TypedObject>(newObject: T): ShallowReactiv
|
|
56
66
|
store.set(objectKey, reactiveObject);
|
57
67
|
return reactiveObject;
|
58
68
|
}
|
69
|
+
|
70
|
+
export async function autoRefreshObject<T extends TypedObject>(object: T, condition: (object: T) => boolean, callback: (object: T) => Promise<T>, interval = 3000) {
|
71
|
+
if (!object?.id || !object?.__type) {
|
72
|
+
throw new Error("Invalid stored object. Cannot auto-refresh");
|
73
|
+
}
|
74
|
+
|
75
|
+
if (condition(object)) {
|
76
|
+
console.log("condition true", object);
|
77
|
+
const refreshedObject = await callback(object);
|
78
|
+
|
79
|
+
if (!refreshedObject.id) {
|
80
|
+
return FlashMessages.error(`Failed to refresh ${object.__type} (${object.id}) status: ` + object.name);
|
81
|
+
}
|
82
|
+
|
83
|
+
storeObject(refreshedObject);
|
84
|
+
}
|
85
|
+
|
86
|
+
setTimeout(() => autoRefreshObject(object, condition, callback), interval);
|
87
|
+
}
|
package/src/types/config.d.ts
CHANGED