@ramathibodi/nuxt-commons 0.1.46 → 0.1.47
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/module.json +1 -1
- package/dist/runtime/components/ExportCSV.vue +3 -0
- package/dist/runtime/components/FileBtn.vue +4 -1
- package/dist/runtime/components/ImportCSV.vue +3 -0
- package/dist/runtime/composables/graphqlOperation.js +6 -4
- package/dist/runtime/composables/menu.js +2 -2
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -9,12 +9,14 @@ interface ExportButtonProps extends /* @vue-ignore */ InstanceType<typeof VBtn['
|
|
|
9
9
|
sheetName?: string
|
|
10
10
|
modelValue?: object[]
|
|
11
11
|
stringFields?: Array<string>
|
|
12
|
+
tooltip?: string | Record<string,any> | undefined
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
const props = withDefaults(defineProps<ExportButtonProps>(), {
|
|
15
16
|
fileName: 'download',
|
|
16
17
|
sheetName: 'Sheet1',
|
|
17
18
|
stringFields: ()=>[],
|
|
19
|
+
tooltip: ()=>({text: 'Export', location: 'bottom'}),
|
|
18
20
|
})
|
|
19
21
|
|
|
20
22
|
const alert = useAlert()
|
|
@@ -84,6 +86,7 @@ function flattenObject(obj: any, parentKey = '', separator = '.') {
|
|
|
84
86
|
:disabled="loading"
|
|
85
87
|
text="Export CSV"
|
|
86
88
|
@click="exportFile"
|
|
89
|
+
v-tooltip="props.tooltip"
|
|
87
90
|
>
|
|
88
91
|
<template
|
|
89
92
|
v-for="(_, name, index) in ($slots as {})"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {ref
|
|
2
|
+
import {ref} from 'vue'
|
|
3
3
|
import {VBtn} from 'vuetify/components/VBtn'
|
|
4
4
|
|
|
5
5
|
interface Props extends /* @vue-ignore */ InstanceType<typeof VBtn['$props']> {
|
|
@@ -7,11 +7,13 @@ interface Props extends /* @vue-ignore */ InstanceType<typeof VBtn['$props']> {
|
|
|
7
7
|
multiple?: boolean
|
|
8
8
|
iconOnly?: boolean
|
|
9
9
|
modelValue?: File | File[] | undefined
|
|
10
|
+
tooltip?: string | Record<string,any> | undefined
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
const props = withDefaults(defineProps<Props>(), {
|
|
13
14
|
multiple: false,
|
|
14
15
|
accept: '*',
|
|
16
|
+
tooltip: 'Upload File',
|
|
15
17
|
})
|
|
16
18
|
|
|
17
19
|
const emit = defineEmits<{
|
|
@@ -41,6 +43,7 @@ defineExpose({ reset })
|
|
|
41
43
|
<v-btn
|
|
42
44
|
v-bind="$attrs"
|
|
43
45
|
@click="openFileInput"
|
|
46
|
+
v-tooltip="tooltip"
|
|
44
47
|
>
|
|
45
48
|
<template
|
|
46
49
|
v-for="(_, name, index) in ($slots as {})"
|
|
@@ -6,10 +6,12 @@ import { VBtn } from 'vuetify/components/VBtn'
|
|
|
6
6
|
|
|
7
7
|
interface ImportButtonProps extends /* @vue-ignore */ InstanceType<typeof VBtn['$props']> {
|
|
8
8
|
stringFields?: Array<string>
|
|
9
|
+
tooltip?: string | Record<string,any> | undefined
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
const props = withDefaults(defineProps<ImportButtonProps>(), {
|
|
12
13
|
stringFields: ()=>[],
|
|
14
|
+
tooltip: ()=>({text: 'Import', location: 'bottom'}),
|
|
13
15
|
})
|
|
14
16
|
|
|
15
17
|
const alert = useAlert()
|
|
@@ -120,6 +122,7 @@ const parseIfJson = (value: any) => {
|
|
|
120
122
|
accept=".csv, .xlsx"
|
|
121
123
|
:multiple="false"
|
|
122
124
|
@update:model-value="uploadedFile"
|
|
125
|
+
:tooltip="props.tooltip"
|
|
123
126
|
>
|
|
124
127
|
<template
|
|
125
128
|
v-for="(_, name, index) in ($slots as {})"
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cloneDeep } from "lodash-es";
|
|
1
2
|
import { classAttributes, isClassConstructor } from "../utils/object.js";
|
|
2
3
|
import { useGraphQl } from "./graphql.js";
|
|
3
4
|
import { graphqlInputType, graphqlOperation, graphqlType, scalarType } from "#imports";
|
|
@@ -36,8 +37,9 @@ export function buildFields(operationFields, fields, depth = 0) {
|
|
|
36
37
|
}
|
|
37
38
|
export function buildVariables(outputVariables, inputVariables, reject, isRoot = true) {
|
|
38
39
|
if (!outputVariables) return void 0;
|
|
40
|
+
let localOutputVariables = cloneDeep(outputVariables);
|
|
39
41
|
if (inputVariables) {
|
|
40
|
-
|
|
42
|
+
localOutputVariables.map((variable) => {
|
|
41
43
|
if (variable.type && !scalarType.includes(variable.type)) {
|
|
42
44
|
if (variable.list) {
|
|
43
45
|
if (inputVariables[variable.name] && Array.isArray(inputVariables[variable.name])) {
|
|
@@ -58,7 +60,7 @@ export function buildVariables(outputVariables, inputVariables, reject, isRoot =
|
|
|
58
60
|
return variable;
|
|
59
61
|
});
|
|
60
62
|
}
|
|
61
|
-
|
|
63
|
+
localOutputVariables.forEach((variable) => {
|
|
62
64
|
if (variable.required && variable.value === void 0) {
|
|
63
65
|
console.warn("Required variable " + variable.name + " is not found, operation abort");
|
|
64
66
|
if (reject) {
|
|
@@ -67,10 +69,10 @@ export function buildVariables(outputVariables, inputVariables, reject, isRoot =
|
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
});
|
|
70
|
-
const usedVariables =
|
|
72
|
+
const usedVariables = localOutputVariables.map((variable) => variable.name);
|
|
71
73
|
const droppedVariable = Object.keys(inputVariables || {}).filter((key) => !usedVariables.includes(key));
|
|
72
74
|
if (droppedVariable.length > 0) console.debug("There is data not appeared in schema and dropped before operation.", droppedVariable);
|
|
73
|
-
return
|
|
75
|
+
return localOutputVariables.reduce((acc, item) => {
|
|
74
76
|
acc[item.name] = isRoot ? item : item.value;
|
|
75
77
|
return acc;
|
|
76
78
|
}, {});
|
|
@@ -20,7 +20,7 @@ export function routeToMenuItem(route) {
|
|
|
20
20
|
};
|
|
21
21
|
if (route.children) {
|
|
22
22
|
const menuItems = new Array();
|
|
23
|
-
for (const children of route.children.sort((a, b) => (a.
|
|
23
|
+
for (const children of route.children.sort((a, b) => (a.name?.toString() ?? "").localeCompare(b.name?.toString() ?? ""))) {
|
|
24
24
|
const childMenuItem = routeToMenuItem(children);
|
|
25
25
|
if (childMenuItem) menuItems.push(childMenuItem);
|
|
26
26
|
menuItem.menuItems = menuItems;
|
|
@@ -31,7 +31,7 @@ export function routeToMenuItem(route) {
|
|
|
31
31
|
}
|
|
32
32
|
export function createMenu() {
|
|
33
33
|
const menuAll = ref([]);
|
|
34
|
-
const routes = useRouter().getRoutes().sort((a, b) => (a.
|
|
34
|
+
const routes = useRouter().getRoutes().sort((a, b) => (a.name?.toString() ?? "").localeCompare(b.name?.toString() ?? ""));
|
|
35
35
|
for (const route of routes) {
|
|
36
36
|
const paths = route.path.split("/");
|
|
37
37
|
if (paths.length == 2) {
|