@vc-shell/create-vc-app 1.1.0-alpha.9 → 1.1.1
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/CHANGELOG.md +26 -0
- package/dist/index.js +1 -1
- package/dist/templates/base/_package.json +12 -13
- package/dist/templates/base/src/main.ts +7 -3
- package/dist/templates/base/src/pages/App.vue +1 -1
- package/dist/templates/base/src/styles/custom.scss +116 -2
- package/dist/templates/base/src/styles/index.scss +3 -4
- package/dist/templates/base/tsconfig.json +16 -16
- package/dist/templates/base/vite.config.mts +5 -5
- package/dist/templates/modules/classic-module/pages/list.vue +162 -162
- package/dist/templates/modules/dynamic-module/pages/list.ts +35 -35
- package/dist/templates/sample/classic-module/pages/details.vue +257 -257
- package/dist/templates/sample/classic-module/pages/list.vue +4 -5
- package/dist/templates/sample/dynamic-module/pages/details.ts +100 -100
- package/dist/templates/sample/dynamic-module/pages/list.ts +80 -81
- package/dist/templates/sample/overrides/main.ts +0 -3
- package/package.json +5 -5
- package/dist/templates/base/src/styles/base.scss +0 -38
- package/dist/templates/base/src/styles/colors.scss +0 -10
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { DynamicGridSchema } from "@vc-shell/framework";
|
|
2
|
-
|
|
3
|
-
export const grid: DynamicGridSchema = {
|
|
4
|
-
settings: {
|
|
5
|
-
url: "/{{ModuleName}}",
|
|
6
|
-
id: "{{ModuleNamePascalCase}}List",
|
|
7
|
-
titleTemplate: "{{ModuleNameSentenceCase}} list",
|
|
8
|
-
localizationPrefix: "{{ModuleNameUppercaseSnakeCase}}",
|
|
9
|
-
isWorkspace: true,
|
|
10
|
-
composable: "use{{ModuleNamePascalCase}}List",
|
|
11
|
-
component: "DynamicBladeList",
|
|
12
|
-
toolbar: [
|
|
13
|
-
{
|
|
14
|
-
id: "refresh",
|
|
15
|
-
icon: "
|
|
16
|
-
title: "Refresh",
|
|
17
|
-
method: "refresh",
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
menuItem: {
|
|
21
|
-
title: "{{ModuleNameUppercaseSnakeCase}}.MENU.TITLE",
|
|
22
|
-
icon: "
|
|
23
|
-
priority: 1,
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
content: [
|
|
27
|
-
{
|
|
28
|
-
id: "itemsGrid",
|
|
29
|
-
component: "vc-table",
|
|
30
|
-
columns: [
|
|
31
|
-
// You can add columns here
|
|
32
|
-
],
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
};
|
|
1
|
+
import { DynamicGridSchema } from "@vc-shell/framework";
|
|
2
|
+
|
|
3
|
+
export const grid: DynamicGridSchema = {
|
|
4
|
+
settings: {
|
|
5
|
+
url: "/{{ModuleName}}",
|
|
6
|
+
id: "{{ModuleNamePascalCase}}List",
|
|
7
|
+
titleTemplate: "{{ModuleNameSentenceCase}} list",
|
|
8
|
+
localizationPrefix: "{{ModuleNameUppercaseSnakeCase}}",
|
|
9
|
+
isWorkspace: true,
|
|
10
|
+
composable: "use{{ModuleNamePascalCase}}List",
|
|
11
|
+
component: "DynamicBladeList",
|
|
12
|
+
toolbar: [
|
|
13
|
+
{
|
|
14
|
+
id: "refresh",
|
|
15
|
+
icon: "material-refresh",
|
|
16
|
+
title: "Refresh",
|
|
17
|
+
method: "refresh",
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
menuItem: {
|
|
21
|
+
title: "{{ModuleNameUppercaseSnakeCase}}.MENU.TITLE",
|
|
22
|
+
icon: "lucide-file",
|
|
23
|
+
priority: 1,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
content: [
|
|
27
|
+
{
|
|
28
|
+
id: "itemsGrid",
|
|
29
|
+
component: "vc-table",
|
|
30
|
+
columns: [
|
|
31
|
+
// You can add columns here
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
};
|
|
@@ -1,257 +1,257 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<VcBlade
|
|
3
|
-
v-loading="loading"
|
|
4
|
-
:title="title"
|
|
5
|
-
:expanded="expanded"
|
|
6
|
-
:closable="closable"
|
|
7
|
-
width="70%"
|
|
8
|
-
:toolbar-items="bladeToolbar"
|
|
9
|
-
@close="$emit('close:blade')"
|
|
10
|
-
@expand="$emit('expand:blade')"
|
|
11
|
-
@collapse="$emit('collapse:blade')"
|
|
12
|
-
>
|
|
13
|
-
<VcContainer class="tw-p-2">
|
|
14
|
-
<VcForm>
|
|
15
|
-
<Field
|
|
16
|
-
v-slot="{ errorMessage, handleChange, errors }"
|
|
17
|
-
name="name"
|
|
18
|
-
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.NAME')"
|
|
19
|
-
rules="required"
|
|
20
|
-
:model-value="item.name"
|
|
21
|
-
>
|
|
22
|
-
<VcInput
|
|
23
|
-
v-model="item.name"
|
|
24
|
-
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.NAME')"
|
|
25
|
-
required
|
|
26
|
-
:error="!!errors.length"
|
|
27
|
-
:error-message="errorMessage"
|
|
28
|
-
class="tw-mb-4"
|
|
29
|
-
@update:model-value="handleChange"
|
|
30
|
-
></VcInput>
|
|
31
|
-
</Field>
|
|
32
|
-
<VcCard
|
|
33
|
-
header="Content"
|
|
34
|
-
class="tw-mb-4"
|
|
35
|
-
>
|
|
36
|
-
<div class="tw-p-4">
|
|
37
|
-
<Field
|
|
38
|
-
v-slot="{ errorMessage, handleChange, errors }"
|
|
39
|
-
name="guid"
|
|
40
|
-
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.GUID')"
|
|
41
|
-
:rules="{
|
|
42
|
-
required: true,
|
|
43
|
-
regex: /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/,
|
|
44
|
-
}"
|
|
45
|
-
:model-value="item.guid"
|
|
46
|
-
>
|
|
47
|
-
<VcInput
|
|
48
|
-
v-model="item.guid"
|
|
49
|
-
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.GUID')"
|
|
50
|
-
required
|
|
51
|
-
:error="!!errors.length"
|
|
52
|
-
:error-message="errorMessage"
|
|
53
|
-
class="tw-mb-4"
|
|
54
|
-
@update:model-value="handleChange"
|
|
55
|
-
></VcInput>
|
|
56
|
-
</Field>
|
|
57
|
-
<Field
|
|
58
|
-
v-slot="{ errorMessage, handleChange, errors }"
|
|
59
|
-
name="description"
|
|
60
|
-
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.DESCRIPTION')"
|
|
61
|
-
:rules="{
|
|
62
|
-
required: true,
|
|
63
|
-
}"
|
|
64
|
-
:model-value="item.description"
|
|
65
|
-
>
|
|
66
|
-
<VcTextarea
|
|
67
|
-
v-model="item.description"
|
|
68
|
-
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.DESCRIPTION')"
|
|
69
|
-
required
|
|
70
|
-
:error="!!errors.length"
|
|
71
|
-
:error-message="errorMessage"
|
|
72
|
-
@update:model-value="handleChange"
|
|
73
|
-
></VcTextarea>
|
|
74
|
-
</Field>
|
|
75
|
-
</div>
|
|
76
|
-
</VcCard>
|
|
77
|
-
<VcCard
|
|
78
|
-
v-if="item.currency"
|
|
79
|
-
header="Prices"
|
|
80
|
-
>
|
|
81
|
-
<VcRow class="tw-p-4 tw-gap-4">
|
|
82
|
-
<VcCol :size="2">
|
|
83
|
-
<Field
|
|
84
|
-
v-slot="{ errorMessage, handleChange, errors }"
|
|
85
|
-
name="price"
|
|
86
|
-
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.PRICE')"
|
|
87
|
-
:rules="{
|
|
88
|
-
required: true,
|
|
89
|
-
}"
|
|
90
|
-
:model-value="item.price"
|
|
91
|
-
>
|
|
92
|
-
<VcInputCurrency
|
|
93
|
-
v-model="item.price"
|
|
94
|
-
v-model:option="item.currency"
|
|
95
|
-
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.PRICE')"
|
|
96
|
-
required
|
|
97
|
-
option-value="value"
|
|
98
|
-
option-label="label"
|
|
99
|
-
:error="!!errors.length"
|
|
100
|
-
:error-message="errorMessage"
|
|
101
|
-
:options="currencyOptions"
|
|
102
|
-
@update:model-value="handleChange"
|
|
103
|
-
></VcInputCurrency>
|
|
104
|
-
</Field>
|
|
105
|
-
</VcCol>
|
|
106
|
-
<VcCol :size="2">
|
|
107
|
-
<Field
|
|
108
|
-
v-slot="{ errorMessage, handleChange, errors }"
|
|
109
|
-
name="salePrice"
|
|
110
|
-
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.SALE_PRICE')"
|
|
111
|
-
:rules="{
|
|
112
|
-
required: true,
|
|
113
|
-
}"
|
|
114
|
-
:model-value="item.salePrice"
|
|
115
|
-
>
|
|
116
|
-
<VcInputCurrency
|
|
117
|
-
v-model="item.salePrice"
|
|
118
|
-
v-model:option="item.currency"
|
|
119
|
-
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.SALE_PRICE')"
|
|
120
|
-
required
|
|
121
|
-
option-value="value"
|
|
122
|
-
option-label="label"
|
|
123
|
-
:error="!!errors.length"
|
|
124
|
-
:error-message="errorMessage"
|
|
125
|
-
:options="currencyOptions"
|
|
126
|
-
@update:model-value="handleChange"
|
|
127
|
-
></VcInputCurrency>
|
|
128
|
-
</Field>
|
|
129
|
-
</VcCol>
|
|
130
|
-
</VcRow>
|
|
131
|
-
</VcCard>
|
|
132
|
-
</VcForm>
|
|
133
|
-
</VcContainer>
|
|
134
|
-
</VcBlade>
|
|
135
|
-
</template>
|
|
136
|
-
|
|
137
|
-
<script lang="ts" setup>
|
|
138
|
-
import { IBladeToolbar, IParentCallArgs, useBeforeUnload, useBladeNavigation, usePopup } from "@vc-shell/framework";
|
|
139
|
-
import { useDetails } from "./../composables";
|
|
140
|
-
import { computed, onMounted, ref, unref, watch } from "vue";
|
|
141
|
-
import { Field, useForm, useIsFormDirty, useIsFormValid } from "vee-validate";
|
|
142
|
-
import { useI18n } from "vue-i18n";
|
|
143
|
-
import * as _ from "lodash-es";
|
|
144
|
-
import { MockedItem } from "../sample-data";
|
|
145
|
-
|
|
146
|
-
export interface Props {
|
|
147
|
-
expanded?: boolean;
|
|
148
|
-
closable?: boolean;
|
|
149
|
-
param?: string;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export interface Emits {
|
|
153
|
-
(event: "parent:call", args: IParentCallArgs): void;
|
|
154
|
-
(event: "collapse:blade"): void;
|
|
155
|
-
(event: "expand:blade"): void;
|
|
156
|
-
(event: "close:blade"): void;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
defineOptions({
|
|
160
|
-
url: "/sample-details",
|
|
161
|
-
name: "SampleDetails",
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
165
|
-
expanded: true,
|
|
166
|
-
closable: true,
|
|
167
|
-
param: undefined,
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
const emit = defineEmits<Emits>();
|
|
171
|
-
|
|
172
|
-
const { loading, getItem, saveItem, removeItem, item, currencyOptions } = useDetails();
|
|
173
|
-
const { showConfirmation } = usePopup();
|
|
174
|
-
const { onBeforeClose } = useBladeNavigation();
|
|
175
|
-
const { t } = useI18n({ useScope: "global" });
|
|
176
|
-
useForm({
|
|
177
|
-
validateOnMount: false,
|
|
178
|
-
});
|
|
179
|
-
useBeforeUnload(computed(() => !isDisabled.value && modified.value));
|
|
180
|
-
|
|
181
|
-
const modified = ref(false);
|
|
182
|
-
const isFormValid = useIsFormValid();
|
|
183
|
-
const isDirty = useIsFormDirty();
|
|
184
|
-
const isDisabled = computed(() => {
|
|
185
|
-
return !isDirty.value || !isFormValid.value;
|
|
186
|
-
});
|
|
187
|
-
let itemCopy: MockedItem;
|
|
188
|
-
const title = computed(() => {
|
|
189
|
-
return props.param
|
|
190
|
-
? item.value?.name
|
|
191
|
-
? item.value?.name + t("SAMPLE_APP.PAGES.DETAILS.TITLE.DETAILS")
|
|
192
|
-
: t("SAMPLE_APP.PAGES.DETAILS.TITLE.LOADING")
|
|
193
|
-
: "Test App" + t("SAMPLE_APP.PAGES.DETAILS.TITLE.DETAILS");
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
watch(
|
|
197
|
-
() => item.value,
|
|
198
|
-
(state) => {
|
|
199
|
-
if (itemCopy) {
|
|
200
|
-
modified.value = !_.isEqual(itemCopy, state);
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
{ deep: true },
|
|
204
|
-
);
|
|
205
|
-
|
|
206
|
-
const bladeToolbar = ref<IBladeToolbar[]>([
|
|
207
|
-
{
|
|
208
|
-
id: "save",
|
|
209
|
-
icon: "
|
|
210
|
-
title: "Save",
|
|
211
|
-
async clickHandler() {
|
|
212
|
-
await saveItem(item.value);
|
|
213
|
-
itemCopy = _.cloneDeep(item.value);
|
|
214
|
-
modified.value = false;
|
|
215
|
-
emit("parent:call", {
|
|
216
|
-
method: "reload",
|
|
217
|
-
});
|
|
218
|
-
emit("close:blade");
|
|
219
|
-
},
|
|
220
|
-
disabled: computed(() => !(modified.value && !isDisabled.value)),
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
id: "delete",
|
|
224
|
-
icon: "
|
|
225
|
-
title: "Delete",
|
|
226
|
-
async clickHandler() {
|
|
227
|
-
if (await showConfirmation(computed(() => t(`SAMPLE_APP.PAGES.ALERTS.DELETE`)))) {
|
|
228
|
-
if (props.param) {
|
|
229
|
-
await removeItem({ id: props.param });
|
|
230
|
-
emit("parent:call", {
|
|
231
|
-
method: "reload",
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
emit("close:blade");
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
]);
|
|
240
|
-
|
|
241
|
-
onMounted(async () => {
|
|
242
|
-
if (props.param) {
|
|
243
|
-
await getItem({ id: props.param });
|
|
244
|
-
itemCopy = _.cloneDeep(item.value);
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
onBeforeClose(async () => {
|
|
249
|
-
if (!isDisabled.value && modified.value) {
|
|
250
|
-
return await showConfirmation(unref(computed(() => t("SAMPLE_APP.PAGES.ALERTS.CLOSE_CONFIRMATION"))));
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
defineExpose({
|
|
255
|
-
title,
|
|
256
|
-
});
|
|
257
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<VcBlade
|
|
3
|
+
v-loading="loading"
|
|
4
|
+
:title="title"
|
|
5
|
+
:expanded="expanded"
|
|
6
|
+
:closable="closable"
|
|
7
|
+
width="70%"
|
|
8
|
+
:toolbar-items="bladeToolbar"
|
|
9
|
+
@close="$emit('close:blade')"
|
|
10
|
+
@expand="$emit('expand:blade')"
|
|
11
|
+
@collapse="$emit('collapse:blade')"
|
|
12
|
+
>
|
|
13
|
+
<VcContainer class="tw-p-2">
|
|
14
|
+
<VcForm>
|
|
15
|
+
<Field
|
|
16
|
+
v-slot="{ errorMessage, handleChange, errors }"
|
|
17
|
+
name="name"
|
|
18
|
+
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.NAME')"
|
|
19
|
+
rules="required"
|
|
20
|
+
:model-value="item.name"
|
|
21
|
+
>
|
|
22
|
+
<VcInput
|
|
23
|
+
v-model="item.name"
|
|
24
|
+
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.NAME')"
|
|
25
|
+
required
|
|
26
|
+
:error="!!errors.length"
|
|
27
|
+
:error-message="errorMessage"
|
|
28
|
+
class="tw-mb-4"
|
|
29
|
+
@update:model-value="handleChange"
|
|
30
|
+
></VcInput>
|
|
31
|
+
</Field>
|
|
32
|
+
<VcCard
|
|
33
|
+
header="Content"
|
|
34
|
+
class="tw-mb-4"
|
|
35
|
+
>
|
|
36
|
+
<div class="tw-p-4">
|
|
37
|
+
<Field
|
|
38
|
+
v-slot="{ errorMessage, handleChange, errors }"
|
|
39
|
+
name="guid"
|
|
40
|
+
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.GUID')"
|
|
41
|
+
:rules="{
|
|
42
|
+
required: true,
|
|
43
|
+
regex: /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/,
|
|
44
|
+
}"
|
|
45
|
+
:model-value="item.guid"
|
|
46
|
+
>
|
|
47
|
+
<VcInput
|
|
48
|
+
v-model="item.guid"
|
|
49
|
+
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.GUID')"
|
|
50
|
+
required
|
|
51
|
+
:error="!!errors.length"
|
|
52
|
+
:error-message="errorMessage"
|
|
53
|
+
class="tw-mb-4"
|
|
54
|
+
@update:model-value="handleChange"
|
|
55
|
+
></VcInput>
|
|
56
|
+
</Field>
|
|
57
|
+
<Field
|
|
58
|
+
v-slot="{ errorMessage, handleChange, errors }"
|
|
59
|
+
name="description"
|
|
60
|
+
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.DESCRIPTION')"
|
|
61
|
+
:rules="{
|
|
62
|
+
required: true,
|
|
63
|
+
}"
|
|
64
|
+
:model-value="item.description"
|
|
65
|
+
>
|
|
66
|
+
<VcTextarea
|
|
67
|
+
v-model="item.description"
|
|
68
|
+
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.DESCRIPTION')"
|
|
69
|
+
required
|
|
70
|
+
:error="!!errors.length"
|
|
71
|
+
:error-message="errorMessage"
|
|
72
|
+
@update:model-value="handleChange"
|
|
73
|
+
></VcTextarea>
|
|
74
|
+
</Field>
|
|
75
|
+
</div>
|
|
76
|
+
</VcCard>
|
|
77
|
+
<VcCard
|
|
78
|
+
v-if="item.currency"
|
|
79
|
+
header="Prices"
|
|
80
|
+
>
|
|
81
|
+
<VcRow class="tw-p-4 tw-gap-4">
|
|
82
|
+
<VcCol :size="2">
|
|
83
|
+
<Field
|
|
84
|
+
v-slot="{ errorMessage, handleChange, errors }"
|
|
85
|
+
name="price"
|
|
86
|
+
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.PRICE')"
|
|
87
|
+
:rules="{
|
|
88
|
+
required: true,
|
|
89
|
+
}"
|
|
90
|
+
:model-value="item.price"
|
|
91
|
+
>
|
|
92
|
+
<VcInputCurrency
|
|
93
|
+
v-model="item.price"
|
|
94
|
+
v-model:option="item.currency"
|
|
95
|
+
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.PRICE')"
|
|
96
|
+
required
|
|
97
|
+
option-value="value"
|
|
98
|
+
option-label="label"
|
|
99
|
+
:error="!!errors.length"
|
|
100
|
+
:error-message="errorMessage"
|
|
101
|
+
:options="currencyOptions"
|
|
102
|
+
@update:model-value="handleChange"
|
|
103
|
+
></VcInputCurrency>
|
|
104
|
+
</Field>
|
|
105
|
+
</VcCol>
|
|
106
|
+
<VcCol :size="2">
|
|
107
|
+
<Field
|
|
108
|
+
v-slot="{ errorMessage, handleChange, errors }"
|
|
109
|
+
name="salePrice"
|
|
110
|
+
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.SALE_PRICE')"
|
|
111
|
+
:rules="{
|
|
112
|
+
required: true,
|
|
113
|
+
}"
|
|
114
|
+
:model-value="item.salePrice"
|
|
115
|
+
>
|
|
116
|
+
<VcInputCurrency
|
|
117
|
+
v-model="item.salePrice"
|
|
118
|
+
v-model:option="item.currency"
|
|
119
|
+
:label="$t('SAMPLE_APP.PAGES.DETAILS.FIELDS.SALE_PRICE')"
|
|
120
|
+
required
|
|
121
|
+
option-value="value"
|
|
122
|
+
option-label="label"
|
|
123
|
+
:error="!!errors.length"
|
|
124
|
+
:error-message="errorMessage"
|
|
125
|
+
:options="currencyOptions"
|
|
126
|
+
@update:model-value="handleChange"
|
|
127
|
+
></VcInputCurrency>
|
|
128
|
+
</Field>
|
|
129
|
+
</VcCol>
|
|
130
|
+
</VcRow>
|
|
131
|
+
</VcCard>
|
|
132
|
+
</VcForm>
|
|
133
|
+
</VcContainer>
|
|
134
|
+
</VcBlade>
|
|
135
|
+
</template>
|
|
136
|
+
|
|
137
|
+
<script lang="ts" setup>
|
|
138
|
+
import { IBladeToolbar, IParentCallArgs, useBeforeUnload, useBladeNavigation, usePopup } from "@vc-shell/framework";
|
|
139
|
+
import { useDetails } from "./../composables";
|
|
140
|
+
import { computed, onMounted, ref, unref, watch } from "vue";
|
|
141
|
+
import { Field, useForm, useIsFormDirty, useIsFormValid } from "vee-validate";
|
|
142
|
+
import { useI18n } from "vue-i18n";
|
|
143
|
+
import * as _ from "lodash-es";
|
|
144
|
+
import { MockedItem } from "../sample-data";
|
|
145
|
+
|
|
146
|
+
export interface Props {
|
|
147
|
+
expanded?: boolean;
|
|
148
|
+
closable?: boolean;
|
|
149
|
+
param?: string;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface Emits {
|
|
153
|
+
(event: "parent:call", args: IParentCallArgs): void;
|
|
154
|
+
(event: "collapse:blade"): void;
|
|
155
|
+
(event: "expand:blade"): void;
|
|
156
|
+
(event: "close:blade"): void;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
defineOptions({
|
|
160
|
+
url: "/sample-details",
|
|
161
|
+
name: "SampleDetails",
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
165
|
+
expanded: true,
|
|
166
|
+
closable: true,
|
|
167
|
+
param: undefined,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
const emit = defineEmits<Emits>();
|
|
171
|
+
|
|
172
|
+
const { loading, getItem, saveItem, removeItem, item, currencyOptions } = useDetails();
|
|
173
|
+
const { showConfirmation } = usePopup();
|
|
174
|
+
const { onBeforeClose } = useBladeNavigation();
|
|
175
|
+
const { t } = useI18n({ useScope: "global" });
|
|
176
|
+
useForm({
|
|
177
|
+
validateOnMount: false,
|
|
178
|
+
});
|
|
179
|
+
useBeforeUnload(computed(() => !isDisabled.value && modified.value));
|
|
180
|
+
|
|
181
|
+
const modified = ref(false);
|
|
182
|
+
const isFormValid = useIsFormValid();
|
|
183
|
+
const isDirty = useIsFormDirty();
|
|
184
|
+
const isDisabled = computed(() => {
|
|
185
|
+
return !isDirty.value || !isFormValid.value;
|
|
186
|
+
});
|
|
187
|
+
let itemCopy: MockedItem;
|
|
188
|
+
const title = computed(() => {
|
|
189
|
+
return props.param
|
|
190
|
+
? item.value?.name
|
|
191
|
+
? item.value?.name + t("SAMPLE_APP.PAGES.DETAILS.TITLE.DETAILS")
|
|
192
|
+
: t("SAMPLE_APP.PAGES.DETAILS.TITLE.LOADING")
|
|
193
|
+
: "Test App" + t("SAMPLE_APP.PAGES.DETAILS.TITLE.DETAILS");
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
watch(
|
|
197
|
+
() => item.value,
|
|
198
|
+
(state) => {
|
|
199
|
+
if (itemCopy) {
|
|
200
|
+
modified.value = !_.isEqual(itemCopy, state);
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
{ deep: true },
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
const bladeToolbar = ref<IBladeToolbar[]>([
|
|
207
|
+
{
|
|
208
|
+
id: "save",
|
|
209
|
+
icon: "material-save",
|
|
210
|
+
title: "Save",
|
|
211
|
+
async clickHandler() {
|
|
212
|
+
await saveItem(item.value);
|
|
213
|
+
itemCopy = _.cloneDeep(item.value);
|
|
214
|
+
modified.value = false;
|
|
215
|
+
emit("parent:call", {
|
|
216
|
+
method: "reload",
|
|
217
|
+
});
|
|
218
|
+
emit("close:blade");
|
|
219
|
+
},
|
|
220
|
+
disabled: computed(() => !(modified.value && !isDisabled.value)),
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
id: "delete",
|
|
224
|
+
icon: "material-delete",
|
|
225
|
+
title: "Delete",
|
|
226
|
+
async clickHandler() {
|
|
227
|
+
if (await showConfirmation(computed(() => t(`SAMPLE_APP.PAGES.ALERTS.DELETE`)))) {
|
|
228
|
+
if (props.param) {
|
|
229
|
+
await removeItem({ id: props.param });
|
|
230
|
+
emit("parent:call", {
|
|
231
|
+
method: "reload",
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
emit("close:blade");
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
]);
|
|
240
|
+
|
|
241
|
+
onMounted(async () => {
|
|
242
|
+
if (props.param) {
|
|
243
|
+
await getItem({ id: props.param });
|
|
244
|
+
itemCopy = _.cloneDeep(item.value);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
onBeforeClose(async () => {
|
|
249
|
+
if (!isDisabled.value && modified.value) {
|
|
250
|
+
return await showConfirmation(unref(computed(() => t("SAMPLE_APP.PAGES.ALERTS.CLOSE_CONFIRMATION"))));
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
defineExpose({
|
|
255
|
+
title,
|
|
256
|
+
});
|
|
257
|
+
</script>
|
|
@@ -73,7 +73,7 @@ defineOptions({
|
|
|
73
73
|
isWorkspace: true,
|
|
74
74
|
menuItem: {
|
|
75
75
|
title: "SAMPLE_APP.MENU.TITLE",
|
|
76
|
-
icon: "
|
|
76
|
+
icon: "lucide-file",
|
|
77
77
|
priority: 1,
|
|
78
78
|
},
|
|
79
79
|
});
|
|
@@ -112,14 +112,14 @@ const bladeToolbar = ref<IBladeToolbar[]>([
|
|
|
112
112
|
{
|
|
113
113
|
id: "refresh",
|
|
114
114
|
title: computed(() => t("SAMPLE_APP.PAGES.LIST.TOOLBAR.REFRESH")),
|
|
115
|
-
icon: "
|
|
115
|
+
icon: "material-refresh",
|
|
116
116
|
async clickHandler() {
|
|
117
117
|
await reload();
|
|
118
118
|
},
|
|
119
119
|
},
|
|
120
120
|
{
|
|
121
121
|
id: "remove",
|
|
122
|
-
icon: "
|
|
122
|
+
icon: "material-delete",
|
|
123
123
|
title: computed(() => t("SAMPLE_APP.PAGES.LIST.TOOLBAR.REMOVE")),
|
|
124
124
|
async clickHandler() {
|
|
125
125
|
await remove(selectedIds.value);
|
|
@@ -216,10 +216,9 @@ const onSelectionChanged = (items: MockedItem[]) => {
|
|
|
216
216
|
const actionBuilder = (): IActionBuilderResult[] => {
|
|
217
217
|
const result: IActionBuilderResult[] = [];
|
|
218
218
|
result.push({
|
|
219
|
-
icon: "
|
|
219
|
+
icon: "material-delete",
|
|
220
220
|
title: computed(() => t("SAMPLE_APP.PAGES.LIST.TABLE.ACTIONS.DELETE")),
|
|
221
221
|
type: "danger",
|
|
222
|
-
position: "left",
|
|
223
222
|
clickHandler(item: MockedItem) {
|
|
224
223
|
if (item.id) {
|
|
225
224
|
if (!selectedIds.value.includes(item.id)) {
|