@tager/admin-banners 0.3.5 → 1.0.0
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/constants/paths.d.ts +5 -10
- package/dist/constants/routes.d.ts +4 -4
- package/dist/dev/App.vue.d.ts +5 -0
- package/dist/dev/config.d.ts +2 -0
- package/dist/dev/env.d.ts +1 -0
- package/dist/dev/main.d.ts +3 -0
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/useFetchBanner.d.ts +7 -8
- package/dist/hooks/useFetchBanners.d.ts +3 -6
- package/dist/hooks/useFetchZoneFields.d.ts +7 -0
- package/dist/hooks/useFetchZones.d.ts +3 -6
- package/dist/index.mjs +993 -0
- package/dist/locales/apply.d.ts +1 -0
- package/dist/locales/en.d.ts +41 -40
- package/dist/locales/ru.d.ts +2 -3
- package/dist/main.d.ts +3 -4
- package/dist/services/requests.d.ts +25 -24
- package/dist/style.css +1 -0
- package/dist/typings/banners.d.ts +47 -40
- package/dist/typings/common.d.ts +1 -1
- package/dist/typings/model.d.ts +104 -104
- package/dist/typings/zones.d.ts +9 -5
- package/dist/utils/common.d.ts +2 -2
- package/dist/utils/paths.d.ts +5 -0
- package/dist/views/Banners/BannerForm/BannerForm.helpers.d.ts +5 -5
- package/dist/views/Banners/BannerForm/BannerForm.vue.d.ts +2694 -81
- package/dist/views/Banners/BannerForm/index.d.ts +1 -1
- package/dist/views/Banners/BannerList/BannerList.helpers.d.ts +6 -6
- package/dist/views/Banners/BannerList/BannerList.vue.d.ts +25 -55
- package/dist/views/Banners/BannerList/hooks/index.d.ts +1 -1
- package/dist/views/Banners/BannerList/hooks/useAdvancedSearch.d.ts +23 -21
- package/dist/views/Banners/BannerList/index.d.ts +1 -1
- package/dist/views/Zones/ZoneList/ZoneList.helpers.d.ts +5 -5
- package/dist/views/Zones/ZoneList/ZoneList.vue.d.ts +11 -28
- package/dist/views/Zones/ZoneList/index.d.ts +1 -1
- package/package.json +51 -49
- package/src/constants/paths.ts +1 -15
- package/src/constants/routes.ts +7 -7
- package/src/dev/App.vue +46 -0
- package/src/dev/config.ts +23 -0
- package/src/dev/env.ts +17 -0
- package/src/dev/main.ts +47 -0
- package/src/hooks/useFetchBanner.ts +3 -6
- package/src/hooks/useFetchBanners.ts +2 -5
- package/src/hooks/useFetchZoneFields.ts +39 -0
- package/src/hooks/useFetchZones.ts +2 -5
- package/src/locales/apply.ts +9 -0
- package/src/locales/en.ts +2 -1
- package/src/locales/ru.ts +40 -41
- package/src/main.ts +3 -8
- package/src/services/requests.ts +7 -1
- package/src/typings/banners.ts +14 -2
- package/src/typings/zones.ts +6 -0
- package/src/utils/paths.ts +15 -0
- package/src/views/Banners/BannerForm/BannerForm.helpers.ts +10 -0
- package/src/views/Banners/BannerForm/BannerForm.vue +168 -83
- package/src/views/Banners/BannerList/BannerList.helpers.ts +11 -4
- package/src/views/Banners/BannerList/BannerList.vue +60 -47
- package/src/views/Banners/BannerList/hooks/useAdvancedSearch.ts +14 -14
- package/src/views/Zones/ZoneList/ZoneList.helpers.ts +1 -1
- package/src/views/Zones/ZoneList/ZoneList.vue +18 -19
- package/CHANGELOG.md +0 -13
- package/dist/constants/menu.d.ts +0 -5
- package/dist/dev.d.ts +0 -1
- package/dist/index.esm.js +0 -3621
- package/dist/index.umd.js +0 -3640
- package/dist/router/index.d.ts +0 -4
- package/src/constants/menu.ts +0 -26
- package/src/dev.ts +0 -34
- package/src/router/index.ts +0 -38
- package/src/typings/sfc.d.ts +0 -12
- package/src/typings/shims-tsx.d.ts +0 -13
- package/src/typings/shims-vue.d.ts +0 -11
- package/src/views/App.vue +0 -22
- package/src/views/Home.vue +0 -37
|
@@ -1,102 +1,132 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<Page
|
|
3
3
|
:title="
|
|
4
|
-
isCreation
|
|
4
|
+
isCreation
|
|
5
|
+
? $i18n.t('banners:createBanner')
|
|
6
|
+
: $i18n.t('banners:updateBanner')
|
|
5
7
|
"
|
|
6
8
|
:is-content-loading="isContentLoading"
|
|
7
9
|
>
|
|
8
|
-
<template
|
|
10
|
+
<template #content>
|
|
9
11
|
<form novalidate @submit.prevent="submitForm">
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<form-field-file-input
|
|
19
|
-
v-model="values.image"
|
|
20
|
-
name="image"
|
|
21
|
-
file-type="image"
|
|
22
|
-
:label="$t('banners:image')"
|
|
23
|
-
:error="errors.file"
|
|
24
|
-
/>
|
|
25
|
-
|
|
26
|
-
<form-field
|
|
27
|
-
v-model="values.link"
|
|
28
|
-
name="link"
|
|
29
|
-
:label="$t('banners:link')"
|
|
30
|
-
:error="errors.name"
|
|
31
|
-
/>
|
|
12
|
+
<div class="zone">
|
|
13
|
+
<FormFieldSelect
|
|
14
|
+
v-model:value="values.bannerZone"
|
|
15
|
+
name="bannerZone"
|
|
16
|
+
:label="$i18n.t('banners:zone')"
|
|
17
|
+
:options="zonesOptionList"
|
|
18
|
+
:error="errors.bannerZone"
|
|
19
|
+
/>
|
|
32
20
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
21
|
+
<FormField
|
|
22
|
+
v-model:value="values.priority"
|
|
23
|
+
name="priority"
|
|
24
|
+
:label="$i18n.t('banners:priority')"
|
|
25
|
+
:error="errors.priority"
|
|
26
|
+
/>
|
|
27
|
+
</div>
|
|
39
28
|
|
|
40
|
-
<
|
|
29
|
+
<InputLabel>{{ $i18n.t('banners:period') }}</InputLabel>
|
|
41
30
|
|
|
42
31
|
<div class="date">
|
|
43
|
-
<
|
|
44
|
-
v-model="values.dateStart"
|
|
45
|
-
:label="$t('banners:from')"
|
|
32
|
+
<FormField
|
|
33
|
+
v-model:value="values.dateStart"
|
|
34
|
+
:label="$i18n.t('banners:from')"
|
|
46
35
|
name="dateStart"
|
|
47
36
|
type="date"
|
|
48
37
|
:max="values.dateEnd"
|
|
49
38
|
/>
|
|
50
39
|
|
|
51
|
-
<
|
|
52
|
-
v-model="values.dateEnd"
|
|
53
|
-
:label="$t('banners:to')"
|
|
40
|
+
<FormField
|
|
41
|
+
v-model:value="values.dateEnd"
|
|
42
|
+
:label="$i18n.t('banners:to')"
|
|
54
43
|
name="dateEnd"
|
|
55
44
|
type="date"
|
|
56
45
|
:min="values.dateStart"
|
|
57
46
|
/>
|
|
58
47
|
</div>
|
|
59
48
|
|
|
60
|
-
<
|
|
61
|
-
v-model="values.disabled"
|
|
49
|
+
<FormFieldCheckbox
|
|
50
|
+
v-model:checked="values.disabled"
|
|
62
51
|
name="disabled"
|
|
63
|
-
:label="$t('banners:disabled')"
|
|
52
|
+
:label="$i18n.t('banners:disabled')"
|
|
64
53
|
:error="errors.disabled"
|
|
65
54
|
/>
|
|
66
55
|
|
|
67
|
-
<
|
|
68
|
-
|
|
56
|
+
<div class="link">
|
|
57
|
+
<FormField
|
|
58
|
+
v-model:value="values.link"
|
|
59
|
+
name="link"
|
|
60
|
+
:label="$i18n.t('banners:link')"
|
|
61
|
+
:error="errors.name"
|
|
62
|
+
/>
|
|
63
|
+
|
|
64
|
+
<FormFieldCheckbox
|
|
65
|
+
v-model:checked="values.openNewTab"
|
|
66
|
+
name="openNewTab"
|
|
67
|
+
:label="$i18n.t('banners:openNewTab')"
|
|
68
|
+
:error="errors.openNewTab"
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<FormFieldFileInput
|
|
73
|
+
v-model:value="values.image"
|
|
74
|
+
name="image"
|
|
75
|
+
file-type="image"
|
|
76
|
+
:label="$i18n.t('banners:image')"
|
|
77
|
+
:error="errors.file"
|
|
78
|
+
/>
|
|
79
|
+
|
|
80
|
+
<DynamicField
|
|
81
|
+
v-for="field of values.fields"
|
|
82
|
+
:key="field.name"
|
|
83
|
+
:field="field"
|
|
84
|
+
/>
|
|
85
|
+
|
|
86
|
+
<FormField
|
|
87
|
+
v-model:value="values.comment"
|
|
69
88
|
name="comment"
|
|
70
89
|
type="textarea"
|
|
71
|
-
:label="$t('banners:comment')"
|
|
90
|
+
:label="$i18n.t('banners:comment')"
|
|
72
91
|
:error="errors.comment"
|
|
73
92
|
/>
|
|
74
93
|
</form>
|
|
75
94
|
</template>
|
|
76
95
|
|
|
77
|
-
<template
|
|
96
|
+
<template #footer>
|
|
78
97
|
<FormFooter
|
|
79
98
|
:back-href="bannerListUrl"
|
|
80
|
-
:on-submit="submitForm"
|
|
81
99
|
:is-submitting="isSubmitting"
|
|
82
100
|
:is-creation="isCreation"
|
|
83
101
|
:can-create-another="isCreation"
|
|
102
|
+
@submit="submitForm"
|
|
84
103
|
/>
|
|
85
104
|
</template>
|
|
86
|
-
</
|
|
105
|
+
</Page>
|
|
87
106
|
</template>
|
|
88
107
|
|
|
89
108
|
<script lang="ts">
|
|
90
|
-
import {
|
|
91
|
-
|
|
92
|
-
defineComponent,
|
|
93
|
-
ref,
|
|
94
|
-
SetupContext,
|
|
95
|
-
watch,
|
|
96
|
-
} from '@vue/composition-api';
|
|
109
|
+
import { computed, defineComponent, ref, SetupContext, watch } from 'vue';
|
|
110
|
+
import { useRoute, useRouter } from 'vue-router';
|
|
97
111
|
|
|
98
|
-
import {
|
|
99
|
-
|
|
112
|
+
import {
|
|
113
|
+
FormField,
|
|
114
|
+
FormFieldCheckbox,
|
|
115
|
+
FormFieldFileInput,
|
|
116
|
+
FormFieldSelect,
|
|
117
|
+
FormFooter,
|
|
118
|
+
InputLabel,
|
|
119
|
+
OptionType,
|
|
120
|
+
TagerFormSubmitEvent,
|
|
121
|
+
} from '@tager/admin-ui';
|
|
122
|
+
import { DynamicField, universalFieldUtils } from '@tager/admin-dynamic-field';
|
|
123
|
+
import {
|
|
124
|
+
convertRequestErrorToMap,
|
|
125
|
+
navigateBack,
|
|
126
|
+
useI18n,
|
|
127
|
+
useToast,
|
|
128
|
+
} from '@tager/admin-services';
|
|
129
|
+
import { Page } from '@tager/admin-layout';
|
|
100
130
|
|
|
101
131
|
import { useFetchZones } from '../../../hooks';
|
|
102
132
|
import { BannerFormValues } from '../../../typings/banners';
|
|
@@ -104,8 +134,9 @@ import { useFetchBanner } from '../../../hooks/useFetchBanner';
|
|
|
104
134
|
import {
|
|
105
135
|
getBannersBannerFormUrl,
|
|
106
136
|
getBannersBannerListUrl,
|
|
107
|
-
} from '../../../
|
|
137
|
+
} from '../../../utils/paths';
|
|
108
138
|
import { createBanner, updateBanner } from '../../../services/requests';
|
|
139
|
+
import { useFetchZoneFields } from '../../../hooks/useFetchZoneFields';
|
|
109
140
|
|
|
110
141
|
import {
|
|
111
142
|
convertBannerFormValuesToPayload,
|
|
@@ -114,16 +145,28 @@ import {
|
|
|
114
145
|
|
|
115
146
|
export default defineComponent({
|
|
116
147
|
name: 'BannerForm',
|
|
117
|
-
components: {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
148
|
+
components: {
|
|
149
|
+
FormFieldFileInput,
|
|
150
|
+
FormFieldCheckbox,
|
|
151
|
+
InputLabel,
|
|
152
|
+
FormField,
|
|
153
|
+
FormFieldSelect,
|
|
154
|
+
Page,
|
|
155
|
+
FormFooter,
|
|
156
|
+
DynamicField,
|
|
157
|
+
},
|
|
158
|
+
setup() {
|
|
159
|
+
const route = useRoute();
|
|
160
|
+
const router = useRouter();
|
|
161
|
+
const toast = useToast();
|
|
162
|
+
const { t } = useI18n();
|
|
163
|
+
|
|
164
|
+
const bannerId = computed<string>(() => route.params.bannerId as string);
|
|
122
165
|
const isCreation = computed<boolean>(() => bannerId.value === 'create');
|
|
123
166
|
|
|
124
167
|
/** Zones **/
|
|
125
168
|
|
|
126
|
-
const { data: zones, loading: isZonesLoading } = useFetchZones(
|
|
169
|
+
const { data: zones, loading: isZonesLoading } = useFetchZones();
|
|
127
170
|
|
|
128
171
|
const zonesOptionList = computed<OptionType[]>(() =>
|
|
129
172
|
zones.value.map<OptionType>((zone) => ({
|
|
@@ -135,7 +178,6 @@ export default defineComponent({
|
|
|
135
178
|
/** Banner **/
|
|
136
179
|
|
|
137
180
|
const { data: banner, loading: isBannerLoading } = useFetchBanner({
|
|
138
|
-
context,
|
|
139
181
|
bannerId,
|
|
140
182
|
isCreation,
|
|
141
183
|
});
|
|
@@ -155,6 +197,21 @@ export default defineComponent({
|
|
|
155
197
|
);
|
|
156
198
|
});
|
|
157
199
|
|
|
200
|
+
/** Zone Fields **/
|
|
201
|
+
|
|
202
|
+
const { loading: isZoneFieldsLoading, data: zoneFields } =
|
|
203
|
+
useFetchZoneFields({ values });
|
|
204
|
+
|
|
205
|
+
watch(zoneFields, () => {
|
|
206
|
+
values.value.fields = (zoneFields.value?.fields ?? []).map(
|
|
207
|
+
(fieldConfig, index) =>
|
|
208
|
+
universalFieldUtils.createFormField(
|
|
209
|
+
fieldConfig,
|
|
210
|
+
banner.value ? banner.value.fields[index].value ?? null : null
|
|
211
|
+
)
|
|
212
|
+
);
|
|
213
|
+
});
|
|
214
|
+
|
|
158
215
|
const submitForm = (event: TagerFormSubmitEvent) => {
|
|
159
216
|
isSubmitting.value = true;
|
|
160
217
|
|
|
@@ -169,39 +226,36 @@ export default defineComponent({
|
|
|
169
226
|
errors.value = {};
|
|
170
227
|
|
|
171
228
|
if (event.type === 'create') {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (event.type === 'create_create-another') {
|
|
229
|
+
router.push(getBannersBannerFormUrl({ bannerId: String(data.id) }));
|
|
230
|
+
} else if (
|
|
231
|
+
event.type === 'create_exit' ||
|
|
232
|
+
event.type === 'save_exit'
|
|
233
|
+
) {
|
|
234
|
+
navigateBack(router, getBannersBannerListUrl());
|
|
235
|
+
} else if (event.type === 'create_create-another') {
|
|
182
236
|
values.value = convertBannerToFormValues(
|
|
183
237
|
null,
|
|
184
238
|
zonesOptionList.value
|
|
185
239
|
);
|
|
186
240
|
}
|
|
187
241
|
|
|
188
|
-
|
|
242
|
+
toast.show({
|
|
189
243
|
variant: 'success',
|
|
190
|
-
title:
|
|
244
|
+
title: t('banners:success'),
|
|
191
245
|
body: isCreation.value
|
|
192
|
-
?
|
|
193
|
-
:
|
|
246
|
+
? t('banners:bannerWasSuccessfullyCreated')
|
|
247
|
+
: t('banners:bannerWasSuccessfullyUpdated'),
|
|
194
248
|
});
|
|
195
249
|
})
|
|
196
250
|
.catch((error) => {
|
|
197
251
|
console.error(error);
|
|
198
252
|
errors.value = convertRequestErrorToMap(error);
|
|
199
|
-
|
|
253
|
+
toast.show({
|
|
200
254
|
variant: 'danger',
|
|
201
|
-
title:
|
|
255
|
+
title: t('banners:error'),
|
|
202
256
|
body: isCreation.value
|
|
203
|
-
?
|
|
204
|
-
:
|
|
257
|
+
? t('banners:bannerCreationWasFailed')
|
|
258
|
+
: t('banners:bannerUpdateWasFailed'),
|
|
205
259
|
});
|
|
206
260
|
})
|
|
207
261
|
.finally(() => {
|
|
@@ -210,7 +264,10 @@ export default defineComponent({
|
|
|
210
264
|
};
|
|
211
265
|
|
|
212
266
|
const isContentLoading = computed<boolean>(
|
|
213
|
-
() =>
|
|
267
|
+
() =>
|
|
268
|
+
isBannerLoading.value ||
|
|
269
|
+
isZonesLoading.value ||
|
|
270
|
+
isZoneFieldsLoading.value
|
|
214
271
|
);
|
|
215
272
|
|
|
216
273
|
return {
|
|
@@ -233,4 +290,32 @@ export default defineComponent({
|
|
|
233
290
|
grid-template-columns: repeat(2, 1fr);
|
|
234
291
|
column-gap: 10px;
|
|
235
292
|
}
|
|
293
|
+
|
|
294
|
+
.zone {
|
|
295
|
+
display: flex;
|
|
296
|
+
|
|
297
|
+
> *:first-child {
|
|
298
|
+
flex: 1 1 1px;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
> *:last-child {
|
|
302
|
+
flex-basis: 30%;
|
|
303
|
+
margin-left: 20px;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.link {
|
|
308
|
+
display: flex;
|
|
309
|
+
align-items: flex-end;
|
|
310
|
+
|
|
311
|
+
> *:first-child {
|
|
312
|
+
flex: 1 1 1px;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
> *:last-child {
|
|
316
|
+
flex-basis: 30%;
|
|
317
|
+
margin-left: 20px;
|
|
318
|
+
padding-bottom: 8px;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
236
321
|
</style>
|
|
@@ -57,6 +57,13 @@ export function getColumnDefs(
|
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
id: 3,
|
|
60
|
+
name: t('banners:priority'),
|
|
61
|
+
field: 'priority',
|
|
62
|
+
style: { width: '100px', textAlign: 'center' },
|
|
63
|
+
headStyle: { width: '100px', textAlign: 'center' },
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 4,
|
|
60
67
|
name: t('banners:period'),
|
|
61
68
|
field: 'dateStart',
|
|
62
69
|
format: ({ row }) =>
|
|
@@ -65,13 +72,13 @@ export function getColumnDefs(
|
|
|
65
72
|
}`,
|
|
66
73
|
},
|
|
67
74
|
{
|
|
68
|
-
id:
|
|
75
|
+
id: 5,
|
|
69
76
|
name: t('banners:image'),
|
|
70
77
|
field: 'image',
|
|
71
78
|
type: 'image',
|
|
72
79
|
},
|
|
73
80
|
{
|
|
74
|
-
id:
|
|
81
|
+
id: 6,
|
|
75
82
|
name: t('banners:link'),
|
|
76
83
|
field: 'link',
|
|
77
84
|
type: 'name',
|
|
@@ -92,12 +99,12 @@ export function getColumnDefs(
|
|
|
92
99
|
},
|
|
93
100
|
},
|
|
94
101
|
{
|
|
95
|
-
id:
|
|
102
|
+
id: 7,
|
|
96
103
|
name: t('banners:comment'),
|
|
97
104
|
field: 'comment',
|
|
98
105
|
},
|
|
99
106
|
{
|
|
100
|
-
id:
|
|
107
|
+
id: 8,
|
|
101
108
|
name: t('banners:actions'),
|
|
102
109
|
field: 'actions',
|
|
103
110
|
style: { whiteSpace: 'nowrap', width: '100px' },
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
:title="$t('banners:banners')"
|
|
2
|
+
<Page
|
|
3
|
+
:title="$i18n.t('banners:banners')"
|
|
4
4
|
:header-buttons="[
|
|
5
5
|
{
|
|
6
|
-
text: $t('banners:createBanner'),
|
|
6
|
+
text: $i18n.t('banners:createBanner'),
|
|
7
7
|
href: getBannersBannerFormUrl({ bannerId: 'create' }),
|
|
8
8
|
},
|
|
9
9
|
]"
|
|
10
10
|
>
|
|
11
|
-
<template
|
|
12
|
-
<
|
|
11
|
+
<template #content>
|
|
12
|
+
<DataTable
|
|
13
13
|
:column-defs="columnDefs"
|
|
14
14
|
:row-data="rowData"
|
|
15
15
|
:loading="isRowDataLoading"
|
|
@@ -26,82 +26,85 @@
|
|
|
26
26
|
}"
|
|
27
27
|
@change="handleChange"
|
|
28
28
|
>
|
|
29
|
-
<template
|
|
30
|
-
<
|
|
29
|
+
<template #filters>
|
|
30
|
+
<AdvancedSearch :tags="tags" @click:tag="tagRemovalHandler">
|
|
31
31
|
<div class="filters">
|
|
32
|
-
<
|
|
33
|
-
v-model="zoneFilter"
|
|
32
|
+
<FormFieldMultiSelect
|
|
33
|
+
v-model:selected-options="zoneFilter"
|
|
34
34
|
:options="zonesOptionList"
|
|
35
35
|
name="zoneFilter"
|
|
36
36
|
:searchable="true"
|
|
37
|
-
:label="$t('banners:zone')"
|
|
37
|
+
:label="$i18n.t('banners:zone')"
|
|
38
38
|
class="filter"
|
|
39
39
|
/>
|
|
40
40
|
|
|
41
|
-
<
|
|
42
|
-
v-model="dateFilter"
|
|
43
|
-
:label="$t('banners:date')"
|
|
41
|
+
<FormField
|
|
42
|
+
v-model:value="dateFilter"
|
|
43
|
+
:label="$i18n.t('banners:date')"
|
|
44
44
|
name="dateFilter"
|
|
45
45
|
type="date"
|
|
46
46
|
class="filter"
|
|
47
47
|
/>
|
|
48
48
|
|
|
49
|
-
<
|
|
50
|
-
v-model="statusFilter"
|
|
49
|
+
<FormFieldMultiSelect
|
|
50
|
+
v-model:selected-options="statusFilter"
|
|
51
51
|
:options="statusesOptionList"
|
|
52
52
|
name="statusFilter"
|
|
53
53
|
:searchable="true"
|
|
54
|
-
:label="$t('banners:status')"
|
|
54
|
+
:label="$i18n.t('banners:status')"
|
|
55
55
|
class="filter"
|
|
56
56
|
/>
|
|
57
57
|
</div>
|
|
58
|
-
</
|
|
58
|
+
</AdvancedSearch>
|
|
59
59
|
</template>
|
|
60
60
|
|
|
61
|
-
<template
|
|
62
|
-
<
|
|
61
|
+
<template #cell(actions)="{ row }">
|
|
62
|
+
<BaseButton
|
|
63
63
|
variant="icon"
|
|
64
|
-
:title="$t('banners:edit')"
|
|
64
|
+
:title="$i18n.t('banners:edit')"
|
|
65
65
|
:disabled="isBusy(row.id)"
|
|
66
66
|
:href="getBannersBannerFormUrl({ bannerId: row.id })"
|
|
67
67
|
>
|
|
68
|
-
<
|
|
69
|
-
</
|
|
68
|
+
<EditIcon />
|
|
69
|
+
</BaseButton>
|
|
70
70
|
|
|
71
|
-
<
|
|
71
|
+
<BaseButton
|
|
72
72
|
variant="icon"
|
|
73
|
-
:title="$t('banners:remove')"
|
|
73
|
+
:title="$i18n.t('banners:remove')"
|
|
74
74
|
:disabled="isBusy(row.id)"
|
|
75
75
|
@click="handleResourceDelete(row.id)"
|
|
76
76
|
>
|
|
77
|
-
<
|
|
78
|
-
</
|
|
77
|
+
<DeleteIcon />
|
|
78
|
+
</BaseButton>
|
|
79
79
|
</template>
|
|
80
|
-
</
|
|
80
|
+
</DataTable>
|
|
81
81
|
</template>
|
|
82
|
-
</
|
|
82
|
+
</Page>
|
|
83
83
|
</template>
|
|
84
84
|
|
|
85
85
|
<script lang="ts">
|
|
86
|
-
import {
|
|
87
|
-
computed,
|
|
88
|
-
defineComponent,
|
|
89
|
-
SetupContext,
|
|
90
|
-
watch,
|
|
91
|
-
} from '@vue/composition-api';
|
|
86
|
+
import { computed, defineComponent, SetupContext, watch } from 'vue';
|
|
92
87
|
import isEqual from 'lodash.isequal';
|
|
93
88
|
import pick from 'lodash.pick';
|
|
89
|
+
import { useRoute, useRouter } from 'vue-router';
|
|
94
90
|
|
|
95
91
|
import {
|
|
96
92
|
ColumnDefinition,
|
|
97
93
|
useDataTable,
|
|
98
|
-
|
|
94
|
+
DataTable,
|
|
95
|
+
AdvancedSearch,
|
|
96
|
+
FormFieldMultiSelect,
|
|
97
|
+
FormField,
|
|
98
|
+
BaseButton,
|
|
99
|
+
EditIcon,
|
|
100
|
+
DeleteIcon,
|
|
99
101
|
} from '@tager/admin-ui';
|
|
100
|
-
import { useResourceDelete } from '@tager/admin-services';
|
|
102
|
+
import { useI18n, useResourceDelete } from '@tager/admin-services';
|
|
103
|
+
import { Page } from '@tager/admin-layout';
|
|
101
104
|
|
|
102
105
|
import { deleteBanner, getBanners } from '../../../services/requests';
|
|
103
106
|
import { Banner } from '../../../typings/banners';
|
|
104
|
-
import { getBannersBannerFormUrl } from '../../../
|
|
107
|
+
import { getBannersBannerFormUrl } from '../../../utils/paths';
|
|
105
108
|
import { useFetchZones } from '../../../hooks';
|
|
106
109
|
|
|
107
110
|
import { getColumnDefs } from './BannerList.helpers';
|
|
@@ -109,11 +112,22 @@ import { useAdvancedSearch } from './hooks';
|
|
|
109
112
|
|
|
110
113
|
export default defineComponent({
|
|
111
114
|
name: 'BannerList',
|
|
115
|
+
components: {
|
|
116
|
+
DeleteIcon,
|
|
117
|
+
EditIcon,
|
|
118
|
+
BaseButton,
|
|
119
|
+
FormField,
|
|
120
|
+
FormFieldMultiSelect,
|
|
121
|
+
AdvancedSearch,
|
|
122
|
+
Page,
|
|
123
|
+
DataTable,
|
|
124
|
+
},
|
|
112
125
|
setup(props, context: SetupContext) {
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
126
|
+
const route = useRoute();
|
|
127
|
+
const router = useRouter();
|
|
128
|
+
const { t } = useI18n();
|
|
129
|
+
|
|
130
|
+
const { loading: isZonesLoading, data: zoneList } = useFetchZones();
|
|
117
131
|
|
|
118
132
|
const {
|
|
119
133
|
zoneFilter,
|
|
@@ -128,6 +142,7 @@ export default defineComponent({
|
|
|
128
142
|
context,
|
|
129
143
|
t,
|
|
130
144
|
zoneList,
|
|
145
|
+
route,
|
|
131
146
|
});
|
|
132
147
|
|
|
133
148
|
const {
|
|
@@ -149,7 +164,6 @@ export default defineComponent({
|
|
|
149
164
|
...filterParams.value,
|
|
150
165
|
}),
|
|
151
166
|
initialValue: [],
|
|
152
|
-
context,
|
|
153
167
|
resourceName: 'Banners',
|
|
154
168
|
});
|
|
155
169
|
|
|
@@ -159,12 +173,12 @@ export default defineComponent({
|
|
|
159
173
|
}
|
|
160
174
|
|
|
161
175
|
const newQuery = {
|
|
162
|
-
...pick(
|
|
176
|
+
...pick(route.query, ['query', 'pageNumber']),
|
|
163
177
|
...filterParams.value,
|
|
164
178
|
};
|
|
165
179
|
|
|
166
|
-
if (!isEqual(
|
|
167
|
-
|
|
180
|
+
if (!isEqual(route.query, newQuery)) {
|
|
181
|
+
router.replace({ query: newQuery });
|
|
168
182
|
fetchBanners();
|
|
169
183
|
}
|
|
170
184
|
});
|
|
@@ -173,7 +187,6 @@ export default defineComponent({
|
|
|
173
187
|
deleteResource: deleteBanner,
|
|
174
188
|
resourceName: 'Banner',
|
|
175
189
|
onSuccess: fetchBanners,
|
|
176
|
-
context,
|
|
177
190
|
});
|
|
178
191
|
|
|
179
192
|
const isBusy = (bannerId: number): boolean => {
|
|
@@ -181,7 +194,7 @@ export default defineComponent({
|
|
|
181
194
|
};
|
|
182
195
|
|
|
183
196
|
const columnDefs = computed<ColumnDefinition<Banner>[]>(() =>
|
|
184
|
-
getColumnDefs(zoneList.value,
|
|
197
|
+
getColumnDefs(zoneList.value, t)
|
|
185
198
|
);
|
|
186
199
|
|
|
187
200
|
const isRowDataLoading = computed<boolean>(
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
computed,
|
|
3
|
-
ComputedRef,
|
|
4
|
-
ref,
|
|
5
|
-
Ref,
|
|
6
|
-
SetupContext,
|
|
7
|
-
watch,
|
|
8
|
-
} from '@vue/composition-api';
|
|
1
|
+
import { computed, ComputedRef, ref, Ref, SetupContext, watch } from 'vue';
|
|
9
2
|
import { TFunction } from 'i18next';
|
|
3
|
+
import { RouteLocationNormalizedLoaded } from 'vue-router';
|
|
10
4
|
|
|
11
5
|
import {
|
|
12
6
|
FilterTagType,
|
|
@@ -23,7 +17,8 @@ import { getStatus } from '../BannerList.helpers';
|
|
|
23
17
|
interface Params {
|
|
24
18
|
context: SetupContext;
|
|
25
19
|
t: TFunction;
|
|
26
|
-
zoneList:
|
|
20
|
+
zoneList: Ref<Zone[]>;
|
|
21
|
+
route: RouteLocationNormalizedLoaded;
|
|
27
22
|
}
|
|
28
23
|
|
|
29
24
|
interface State {
|
|
@@ -34,6 +29,7 @@ interface State {
|
|
|
34
29
|
statusesOptionList: ComputedRef<OptionType[]>;
|
|
35
30
|
filterParams: ComputedRef<Record<string, string | string[]>>;
|
|
36
31
|
tags: ComputedRef<FilterTagType[]>;
|
|
32
|
+
|
|
37
33
|
tagRemovalHandler(event: FilterTagType): void;
|
|
38
34
|
}
|
|
39
35
|
|
|
@@ -43,7 +39,12 @@ enum FilterTypes {
|
|
|
43
39
|
Status = 'status',
|
|
44
40
|
}
|
|
45
41
|
|
|
46
|
-
export function useAdvancedSearch({
|
|
42
|
+
export function useAdvancedSearch({
|
|
43
|
+
context,
|
|
44
|
+
t,
|
|
45
|
+
zoneList,
|
|
46
|
+
route,
|
|
47
|
+
}: Params): State {
|
|
47
48
|
/** Zone **/
|
|
48
49
|
|
|
49
50
|
const zonesOptionList = computed<OptionType[]>(() =>
|
|
@@ -55,7 +56,7 @@ export function useAdvancedSearch({ context, t, zoneList }: Params): State {
|
|
|
55
56
|
|
|
56
57
|
const initialZoneFilter = computed<OptionType[]>(() => {
|
|
57
58
|
const queryValue = getFilterParamAsStringArray(
|
|
58
|
-
|
|
59
|
+
route.query,
|
|
59
60
|
FilterTypes.Zone
|
|
60
61
|
);
|
|
61
62
|
return zonesOptionList.value.filter(({ value }) =>
|
|
@@ -72,8 +73,7 @@ export function useAdvancedSearch({ context, t, zoneList }: Params): State {
|
|
|
72
73
|
/** Date **/
|
|
73
74
|
|
|
74
75
|
const initialDateFilter = computed<string>(
|
|
75
|
-
() =>
|
|
76
|
-
getFilterParamAsString(context.root.$route.query, FilterTypes.Date) ?? ''
|
|
76
|
+
() => getFilterParamAsString(route.query, FilterTypes.Date) ?? ''
|
|
77
77
|
);
|
|
78
78
|
|
|
79
79
|
const dateFilter = ref<string>(initialDateFilter.value);
|
|
@@ -93,7 +93,7 @@ export function useAdvancedSearch({ context, t, zoneList }: Params): State {
|
|
|
93
93
|
|
|
94
94
|
const initialStatusFilter = computed<OptionType[]>(() => {
|
|
95
95
|
const queryValue = getFilterParamAsStringArray(
|
|
96
|
-
|
|
96
|
+
route.query,
|
|
97
97
|
FilterTypes.Status
|
|
98
98
|
);
|
|
99
99
|
return statusesOptionList.value.filter(({ value }) =>
|