@ramathibodi/nuxt-commons 0.1.51 → 0.1.53
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/document/TemplateBuilder.vue +0 -1
- package/dist/runtime/components/form/ActionPad.vue +8 -4
- package/dist/runtime/components/form/EditPad.vue +9 -5
- package/dist/runtime/components/form/Table.vue +3 -2
- package/dist/runtime/components/model/Pad.vue +4 -6
- package/dist/runtime/components/model/Table.vue +4 -0
- package/dist/runtime/composables/userPermission.d.ts +1 -1
- package/dist/runtime/plugins/permission.js +4 -4
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
import {computed, defineExpose, ref, watchEffect} from 'vue'
|
|
3
3
|
import {cloneDeep, isEqual} from 'lodash-es'
|
|
4
4
|
import type {FormDialogCallback} from '../../types/formDialog'
|
|
5
|
+
import FormPadComponent from './Pad.vue'
|
|
5
6
|
|
|
6
|
-
interface Props {
|
|
7
|
+
interface Props extends /* @vue-ignore */ InstanceType<typeof FormPadComponent['$props']> {
|
|
7
8
|
title?: string
|
|
8
9
|
initialData?: object
|
|
9
10
|
saveCaption?: string
|
|
10
11
|
cancelCaption?: string
|
|
11
12
|
readonly?: boolean
|
|
12
13
|
showTitle?: boolean
|
|
14
|
+
skipValidation?:boolean
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -17,6 +19,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
17
19
|
cancelCaption: 'ยกเลิก',
|
|
18
20
|
readonly: false,
|
|
19
21
|
showTitle: false,
|
|
22
|
+
skipValidation:false
|
|
20
23
|
})
|
|
21
24
|
|
|
22
25
|
const isSaving = ref<boolean>(false)
|
|
@@ -27,7 +30,7 @@ const formDataOriginalValue = ref<object>()
|
|
|
27
30
|
const emit = defineEmits(['create', 'update'])
|
|
28
31
|
|
|
29
32
|
function save() {
|
|
30
|
-
if (formPadRef.value
|
|
33
|
+
if (props.skipValidation || formPadRef.value?.isValid) {
|
|
31
34
|
isSaving.value = true
|
|
32
35
|
emit((isCreating.value) ? 'create' : 'update', cloneDeep(formData.value), callback)
|
|
33
36
|
}
|
|
@@ -39,7 +42,7 @@ function cancel() {
|
|
|
39
42
|
|
|
40
43
|
function reset() {
|
|
41
44
|
formDataOriginalValue.value = undefined
|
|
42
|
-
formPadRef.value
|
|
45
|
+
formPadRef.value?.reset()
|
|
43
46
|
loadFormData()
|
|
44
47
|
}
|
|
45
48
|
|
|
@@ -82,7 +85,7 @@ function setOriginalData(originalData?: object) {
|
|
|
82
85
|
formDataOriginalValue.value = originalData
|
|
83
86
|
}
|
|
84
87
|
|
|
85
|
-
defineExpose({setOriginalData,operation})
|
|
88
|
+
defineExpose({setOriginalData,operation,formPad: formPadRef})
|
|
86
89
|
</script>
|
|
87
90
|
|
|
88
91
|
<template>
|
|
@@ -102,6 +105,7 @@ defineExpose({setOriginalData,operation})
|
|
|
102
105
|
v-model="formData"
|
|
103
106
|
:readonly="readonly"
|
|
104
107
|
isolated
|
|
108
|
+
v-bind="$attrs"
|
|
105
109
|
>
|
|
106
110
|
<template #default="slotData">
|
|
107
111
|
<slot
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {computed, ref, watchEffect} from 'vue'
|
|
2
|
+
import {computed, defineExpose, ref, watchEffect} from 'vue'
|
|
3
3
|
import {cloneDeep, isEqual} from 'lodash-es'
|
|
4
4
|
import type {FormDialogCallback} from '../../types/formDialog'
|
|
5
|
+
import FormPadComponent from './Pad.vue'
|
|
5
6
|
|
|
6
|
-
interface Props {
|
|
7
|
+
interface Props extends /* @vue-ignore */ InstanceType<typeof FormPadComponent['$props']> {
|
|
7
8
|
title?: string
|
|
8
9
|
initialData?: object
|
|
9
10
|
formData?: object
|
|
@@ -11,6 +12,7 @@ interface Props {
|
|
|
11
12
|
cancelCaption?: string
|
|
12
13
|
readonly?: boolean
|
|
13
14
|
showTitle?: boolean
|
|
15
|
+
skipValidation?:boolean
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -18,6 +20,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
18
20
|
cancelCaption: 'ยกเลิก',
|
|
19
21
|
readonly: false,
|
|
20
22
|
showTitle: false,
|
|
23
|
+
skipValidation:false
|
|
21
24
|
})
|
|
22
25
|
|
|
23
26
|
const isSaving = ref<boolean>(false)
|
|
@@ -28,7 +31,7 @@ const formDataOriginalValue = ref<object>()
|
|
|
28
31
|
const emit = defineEmits(['create', 'update'])
|
|
29
32
|
|
|
30
33
|
function save() {
|
|
31
|
-
if (formPadRef.value
|
|
34
|
+
if (props.skipValidation || formPadRef.value?.isValid) {
|
|
32
35
|
isSaving.value = true
|
|
33
36
|
emit((isCreating.value) ? 'create' : 'update', cloneDeep(formData.value), callback)
|
|
34
37
|
}
|
|
@@ -40,7 +43,7 @@ function cancel() {
|
|
|
40
43
|
|
|
41
44
|
function reset() {
|
|
42
45
|
formDataOriginalValue.value = undefined
|
|
43
|
-
formPadRef.value
|
|
46
|
+
formPadRef.value?.reset()
|
|
44
47
|
loadFormData()
|
|
45
48
|
}
|
|
46
49
|
|
|
@@ -83,7 +86,7 @@ const operation = ref({ isDataChange, isCreating, isSaving, save, cancel })
|
|
|
83
86
|
|
|
84
87
|
watchEffect(loadFormData)
|
|
85
88
|
|
|
86
|
-
defineExpose({operation})
|
|
89
|
+
defineExpose({operation,formPad:formPadRef})
|
|
87
90
|
</script>
|
|
88
91
|
|
|
89
92
|
<template>
|
|
@@ -103,6 +106,7 @@ defineExpose({operation})
|
|
|
103
106
|
v-model="formData"
|
|
104
107
|
:readonly="readonly"
|
|
105
108
|
isolated
|
|
109
|
+
v-bind="$attrs"
|
|
106
110
|
>
|
|
107
111
|
<template #default="slotData">
|
|
108
112
|
<slot
|
|
@@ -43,8 +43,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
43
43
|
stringFields: ()=>[],
|
|
44
44
|
})
|
|
45
45
|
|
|
46
|
-
const emit = defineEmits(['update:modelValue'])
|
|
47
|
-
|
|
46
|
+
const emit = defineEmits(['update:modelValue','open:dialog','close:dialog'])
|
|
48
47
|
const attrs = useAttrs()
|
|
49
48
|
const plainAttrs = computed(() => {
|
|
50
49
|
return omit(attrs, ['modelValue', 'onUpdate:modelValue'])
|
|
@@ -175,6 +174,7 @@ function openDialog(item?: object) {
|
|
|
175
174
|
currentItem.value = item
|
|
176
175
|
nextTick(() => {
|
|
177
176
|
isDialogOpen.value = true
|
|
177
|
+
emit('open:dialog',item)
|
|
178
178
|
})
|
|
179
179
|
}
|
|
180
180
|
}
|
|
@@ -325,6 +325,7 @@ defineExpose({
|
|
|
325
325
|
:form-data="currentItem"
|
|
326
326
|
@create="createItem"
|
|
327
327
|
@update="updateItem"
|
|
328
|
+
@afterLeave="emit('close:dialog')"
|
|
328
329
|
:saveAndStay="saveAndStay"
|
|
329
330
|
v-if="!props.inputPadOnly"
|
|
330
331
|
>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { computed, useTemplateRef } from 'vue'
|
|
2
|
+
import { computed, useTemplateRef, defineExpose } from 'vue'
|
|
3
3
|
import { type GraphqlModelItemProps, useGraphqlModelItem } from '../../composables/graphqlModelItem'
|
|
4
4
|
import EditPad from '../form/EditPad.vue'
|
|
5
5
|
|
|
@@ -11,8 +11,6 @@ interface Props extends /* @vue-ignore */ InstanceType<typeof EditPad['$props']>
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const props = withDefaults(defineProps<Props & GraphqlModelItemProps>(), {
|
|
14
|
-
saveCaption: 'บันทึก',
|
|
15
|
-
cancelCaption: 'ยกเลิก',
|
|
16
14
|
fields: () => ['*'],
|
|
17
15
|
})
|
|
18
16
|
|
|
@@ -29,12 +27,12 @@ const operation : any = computed(()=>{
|
|
|
29
27
|
return Object.assign({},editPad.value?.operation,{canSave,reload,item})
|
|
30
28
|
})
|
|
31
29
|
|
|
32
|
-
defineExpose({ operation })
|
|
30
|
+
defineExpose({ operation, formPad: editPad.value?.formPad })
|
|
33
31
|
</script>
|
|
34
32
|
|
|
35
33
|
<template>
|
|
36
|
-
<FormEditPad :form-data="item" ref="editPadRef" @create="createItem" @update="updateItem">
|
|
37
|
-
<template #titleToolbar
|
|
34
|
+
<FormEditPad v-bind="$attrs" :form-data="item" ref="editPadRef" @create="createItem" @update="updateItem">
|
|
35
|
+
<template #titleToolbar>
|
|
38
36
|
<slot name="titleToolbar" :operation="operation">
|
|
39
37
|
<VToolbarTitle>
|
|
40
38
|
<slot name="title" :operation="operation">
|
|
@@ -46,6 +46,7 @@ const props = withDefaults(defineProps<Props & GraphqlModelProps>(), {
|
|
|
46
46
|
onlyOwnerEdit: false,
|
|
47
47
|
})
|
|
48
48
|
|
|
49
|
+
const emit = defineEmits(['open:dialog','close:dialog'])
|
|
49
50
|
const attrs = useAttrs()
|
|
50
51
|
const plainAttrs = computed(() => {
|
|
51
52
|
const returnAttrs = clone(attrs)
|
|
@@ -75,6 +76,7 @@ function openDialog(item?: object) {
|
|
|
75
76
|
currentItem.value = item
|
|
76
77
|
nextTick(() => {
|
|
77
78
|
isDialogOpen.value = true
|
|
79
|
+
emit('open:dialog' , item)
|
|
78
80
|
})
|
|
79
81
|
}
|
|
80
82
|
|
|
@@ -83,6 +85,7 @@ function openDialogReadonly(item?: object) {
|
|
|
83
85
|
currentItem.value = item
|
|
84
86
|
nextTick(() => {
|
|
85
87
|
isDialogOpen.value = true
|
|
88
|
+
emit('open:dialog' , item)
|
|
86
89
|
})
|
|
87
90
|
}
|
|
88
91
|
|
|
@@ -289,6 +292,7 @@ defineExpose({ reload,operation })
|
|
|
289
292
|
:form-data="currentItem"
|
|
290
293
|
@create="createItem"
|
|
291
294
|
@update="updateItem"
|
|
295
|
+
@afterLeave="emit('close:dialog')"
|
|
292
296
|
:saveAndStay="saveAndStay"
|
|
293
297
|
:readonly="isDialogReadonly"
|
|
294
298
|
>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useUserPermission: () =>
|
|
1
|
+
export declare const useUserPermission: () => import("../types/permission").PermissionPlugin;
|
|
@@ -11,18 +11,18 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
11
11
|
const arr = normalize(input);
|
|
12
12
|
return arr.length === 0 || arr.every((v) => v.trim() === "");
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
const check = (permissionIds) => {
|
|
15
15
|
if (isBlank(permissionIds)) return true;
|
|
16
16
|
const auth = useAuthentication();
|
|
17
17
|
const perms = normalize(permissionIds);
|
|
18
18
|
return perms.some((id) => auth?.hasPermission(id));
|
|
19
|
-
}
|
|
20
|
-
|
|
19
|
+
};
|
|
20
|
+
const checkAll = (permissionIds) => {
|
|
21
21
|
if (isBlank(permissionIds)) return true;
|
|
22
22
|
const auth = useAuthentication();
|
|
23
23
|
const perms = normalize(permissionIds);
|
|
24
24
|
return perms.every((id) => auth?.hasPermission(id));
|
|
25
|
-
}
|
|
25
|
+
};
|
|
26
26
|
nuxtApp.vueApp.directive("permission", (el, binding, vnode) => {
|
|
27
27
|
if (!check(binding.value)) {
|
|
28
28
|
vnode?.um?.forEach?.((um) => um());
|