quasar-ui-danx 0.4.21 → 0.4.23
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/danx.es.js +1493 -1446
- package/dist/danx.es.js.map +1 -1
- package/dist/danx.umd.js +16 -16
- package/dist/danx.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ActionTable/Form/Fields/BooleanField.vue +25 -23
- package/src/components/ActionTable/Form/Fields/IntegerField.vue +9 -13
- package/src/components/ActionTable/Form/Fields/LabelValueBlock.vue +25 -10
- package/src/components/ActionTable/Form/Fields/NumberField.vue +1 -8
- package/src/components/ActionTable/listControls.ts +16 -6
- package/src/helpers/formats.ts +7 -1
- package/src/helpers/objectStore.ts +0 -1
- package/src/helpers/routes.ts +3 -2
- package/src/types/fields.d.ts +8 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
<template>
|
2
2
|
<QToggle
|
3
|
-
:data-testid="'boolean-field-' +
|
3
|
+
:data-testid="'boolean-field-' + (name || label)"
|
4
4
|
:model-value="modelValue || (toggleIndeterminate ? modelValue : false)"
|
5
5
|
:disable="disable || readonly"
|
6
6
|
:toggle-indeterminate="toggleIndeterminate"
|
@@ -8,37 +8,39 @@
|
|
8
8
|
@update:model-value="$emit('update:model-value', $event)"
|
9
9
|
>
|
10
10
|
<FieldLabel
|
11
|
-
:
|
11
|
+
:label="label || name"
|
12
|
+
:name="name"
|
12
13
|
:show-name="showName"
|
13
14
|
:class="labelClass"
|
14
15
|
/>
|
15
16
|
</QToggle>
|
16
17
|
</template>
|
17
18
|
|
18
|
-
<script setup>
|
19
|
+
<script setup lang="ts">
|
19
20
|
import FieldLabel from "./FieldLabel";
|
20
21
|
|
21
22
|
defineEmits(["update:model-value"]);
|
22
23
|
defineProps({
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
24
|
+
label: {
|
25
|
+
type: String,
|
26
|
+
default: null
|
27
|
+
},
|
28
|
+
name: {
|
29
|
+
type: String,
|
30
|
+
default: null
|
31
|
+
},
|
32
|
+
required: Boolean,
|
33
|
+
modelValue: {
|
34
|
+
type: Boolean,
|
35
|
+
default: undefined
|
36
|
+
},
|
37
|
+
labelClass: {
|
38
|
+
type: String,
|
39
|
+
default: "text-sm"
|
40
|
+
},
|
41
|
+
showName: Boolean,
|
42
|
+
toggleIndeterminate: Boolean,
|
43
|
+
disable: Boolean,
|
44
|
+
readonly: Boolean
|
43
45
|
});
|
44
46
|
</script>
|
@@ -1,26 +1,22 @@
|
|
1
1
|
<template>
|
2
2
|
<NumberField
|
3
|
-
|
3
|
+
v-bind="$props"
|
4
4
|
:precision="0"
|
5
5
|
:model-value="modelValue"
|
6
|
-
:show-name="showName"
|
7
6
|
@update:model-value="$emit('update:model-value', $event)"
|
8
7
|
/>
|
9
8
|
</template>
|
10
9
|
|
11
|
-
<script setup>
|
10
|
+
<script setup lang="ts">
|
11
|
+
import { NumberFieldProps } from "../../../../types";
|
12
12
|
import NumberField from "./NumberField";
|
13
13
|
|
14
14
|
defineEmits(["update:model-value"]);
|
15
|
-
defineProps({
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
type: Object,
|
22
|
-
required: true
|
23
|
-
},
|
24
|
-
showName: Boolean
|
15
|
+
withDefaults(defineProps<NumberFieldProps>(), {
|
16
|
+
modelValue: "",
|
17
|
+
label: undefined,
|
18
|
+
delay: 1000,
|
19
|
+
min: undefined,
|
20
|
+
max: undefined
|
25
21
|
});
|
26
22
|
</script>
|
@@ -1,17 +1,30 @@
|
|
1
1
|
<template>
|
2
2
|
<div>
|
3
3
|
<div class="text-xs font-bold">
|
4
|
-
|
4
|
+
<slot name="label">
|
5
|
+
{{ label }}
|
6
|
+
</slot>
|
5
7
|
</div>
|
6
8
|
<div :class="valueClass">
|
7
|
-
<
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
<template v-if="url">
|
10
|
+
<a
|
11
|
+
v-if="!isLargeContent"
|
12
|
+
target="_blank"
|
13
|
+
:href="url"
|
14
|
+
>
|
15
|
+
<slot>{{ formattedValue }}</slot>
|
16
|
+
</a>
|
17
|
+
<template v-else>
|
18
|
+
<slot>{{ formattedValue }}</slot>
|
19
|
+
<a
|
20
|
+
target="_blank"
|
21
|
+
:href="url"
|
22
|
+
class="inline-block ml-2"
|
23
|
+
>
|
24
|
+
<LinkIcon class="w-4" />
|
25
|
+
</a>
|
26
|
+
</template>
|
27
|
+
</template>
|
15
28
|
<template v-else>
|
16
29
|
<slot>{{ formattedValue }}</slot>
|
17
30
|
</template>
|
@@ -19,12 +32,13 @@
|
|
19
32
|
</div>
|
20
33
|
</template>
|
21
34
|
<script setup lang="ts">
|
35
|
+
import { FaSolidLink as LinkIcon } from "danx-icon";
|
22
36
|
import { computed } from "vue";
|
23
37
|
import { fBoolean, fNumber } from "../../../../helpers";
|
24
38
|
|
25
39
|
export interface LabelValueBlockProps {
|
26
40
|
label: string;
|
27
|
-
value
|
41
|
+
value?: string | number | boolean;
|
28
42
|
url?: string;
|
29
43
|
dense?: boolean;
|
30
44
|
nowrap?: boolean;
|
@@ -36,6 +50,7 @@ const props = withDefaults(defineProps<LabelValueBlockProps>(), {
|
|
36
50
|
});
|
37
51
|
|
38
52
|
const valueClass = computed(() => ({ "mt-2": !props.dense, "mt-1": props.dense, "text-no-wrap": props.nowrap }));
|
53
|
+
const isLargeContent = computed(() => typeof props.value === "string" && props.value.length > 30);
|
39
54
|
const formattedValue = computed(() => {
|
40
55
|
switch (typeof props.value) {
|
41
56
|
case "boolean":
|
@@ -11,18 +11,11 @@
|
|
11
11
|
import { useDebounceFn } from "@vueuse/core";
|
12
12
|
import { nextTick, ref, watch } from "vue";
|
13
13
|
import { fNumber } from "../../../../helpers";
|
14
|
-
import { AnyObject,
|
14
|
+
import { AnyObject, NumberFieldProps } from "../../../../types";
|
15
15
|
import TextField from "./TextField";
|
16
16
|
|
17
17
|
const emit = defineEmits(["update:model-value", "update"]);
|
18
18
|
|
19
|
-
export interface NumberFieldProps extends TextFieldProps {
|
20
|
-
precision?: number;
|
21
|
-
delay?: number;
|
22
|
-
currency?: boolean;
|
23
|
-
min?: number;
|
24
|
-
max?: number;
|
25
|
-
}
|
26
19
|
|
27
20
|
const props = withDefaults(defineProps<NumberFieldProps>(), {
|
28
21
|
modelValue: "",
|
@@ -364,7 +364,7 @@ export function useListControls(name: string, options: ListControlsOptions): Act
|
|
364
364
|
|
365
365
|
const latestNextIndex = latestCallOnly("getNextItem", async () => {
|
366
366
|
if (!pagedItems.value?.data) return -1;
|
367
|
-
|
367
|
+
|
368
368
|
// Load the previous page if the offset is before index 0
|
369
369
|
if (nextIndex < 0) {
|
370
370
|
if (pagination.value.page > 1) {
|
@@ -439,11 +439,21 @@ export function useListControls(name: string, options: ListControlsOptions): Act
|
|
439
439
|
*/
|
440
440
|
function updateRouteParams(params: AnyObject) {
|
441
441
|
const vueRouter = getVueRouter();
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
442
|
+
let { name: routeName } = vueRouter.currentRoute.value;
|
443
|
+
routeName = Array.isArray(routeName) ? routeName[0] : routeName;
|
444
|
+
|
445
|
+
if (!routeName) {
|
446
|
+
console.error("No route name found for list controls", name);
|
447
|
+
return;
|
448
|
+
}
|
449
|
+
|
450
|
+
const newRoutePath = vueRouter.resolve({ name: routeName, params }).href;
|
451
|
+
const currentRoutePath = vueRouter.currentRoute.value.fullPath;
|
452
|
+
|
453
|
+
// Only update the route if the route is different (or the currentRoutePath is a child of the newRoutePath)
|
454
|
+
if (currentRoutePath !== newRoutePath && !currentRoutePath.startsWith(newRoutePath)) {
|
455
|
+
vueRouter.push({ name: routeName, params });
|
456
|
+
}
|
447
457
|
}
|
448
458
|
|
449
459
|
function setPanelFromRoute(params: RouteParams, meta: AnyObject) {
|
package/src/helpers/formats.ts
CHANGED
@@ -234,7 +234,13 @@ export function fShortSize(value: string | number) {
|
|
234
234
|
return Math.round(n / div) + " " + power.unit;
|
235
235
|
}
|
236
236
|
|
237
|
-
export function fBoolean(value?: boolean) {
|
237
|
+
export function fBoolean(value?: boolean | string | any) {
|
238
|
+
switch (value) {
|
239
|
+
case "Yes":
|
240
|
+
case "No":
|
241
|
+
return value;
|
242
|
+
}
|
243
|
+
|
238
244
|
return (value === undefined || value === null) ? "-" : (value ? "Yes" : "No");
|
239
245
|
}
|
240
246
|
|
package/src/helpers/routes.ts
CHANGED
@@ -3,7 +3,7 @@ import { ListControlsRoutes } from "../types";
|
|
3
3
|
import { downloadFile } from "./downloadPdf";
|
4
4
|
import { request } from "./request";
|
5
5
|
|
6
|
-
export function useActionRoutes(baseUrl: string): ListControlsRoutes {
|
6
|
+
export function useActionRoutes(baseUrl: string, extend?: object): ListControlsRoutes {
|
7
7
|
return {
|
8
8
|
list(pager?) {
|
9
9
|
return request.post(`${baseUrl}/list`, pager);
|
@@ -33,6 +33,7 @@ export function useActionRoutes(baseUrl: string): ListControlsRoutes {
|
|
33
33
|
},
|
34
34
|
export(filter, name) {
|
35
35
|
return downloadFile(`${baseUrl}/export`, name || "export.csv", { filter });
|
36
|
-
}
|
36
|
+
},
|
37
|
+
...extend
|
37
38
|
};
|
38
39
|
}
|
package/src/types/fields.d.ts
CHANGED
@@ -19,3 +19,11 @@ export interface TextFieldProps {
|
|
19
19
|
readonly?: boolean;
|
20
20
|
debounce?: string | number;
|
21
21
|
}
|
22
|
+
|
23
|
+
export interface NumberFieldProps extends TextFieldProps {
|
24
|
+
precision?: number;
|
25
|
+
delay?: number;
|
26
|
+
currency?: boolean;
|
27
|
+
min?: number;
|
28
|
+
max?: number;
|
29
|
+
}
|