@tager/admin-banners 0.2.0 → 0.3.2
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/menu.d.ts +4 -1
- package/dist/constants/paths.d.ts +8 -15
- package/dist/constants/routes.d.ts +3 -4
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useFetchBanner.d.ts +8 -0
- package/dist/hooks/useFetchBanners.d.ts +6 -0
- package/dist/hooks/useFetchZones.d.ts +6 -0
- package/dist/index.esm.js +3202 -875
- package/dist/index.umd.js +3216 -886
- package/dist/locales/en.d.ts +39 -0
- package/dist/locales/ru.d.ts +3 -0
- package/dist/{index.d.ts → main.d.ts} +1 -0
- package/dist/router/index.d.ts +4 -0
- package/dist/services/requests.d.ts +22 -35
- package/dist/typings/banners.d.ts +40 -0
- package/dist/typings/common.d.ts +1 -0
- package/dist/typings/model.d.ts +103 -15
- package/dist/typings/zones.d.ts +5 -0
- package/dist/utils/common.d.ts +2 -0
- package/dist/views/Banners/BannerForm/BannerForm.helpers.d.ts +5 -0
- package/dist/views/Banners/BannerForm/BannerForm.vue.d.ts +81 -0
- package/dist/views/Banners/BannerForm/index.d.ts +1 -0
- package/dist/views/Banners/BannerList/BannerList.helpers.d.ts +5 -0
- package/dist/views/Banners/BannerList/BannerList.vue.d.ts +55 -0
- package/dist/views/Banners/BannerList/hooks/index.d.ts +1 -0
- package/dist/views/Banners/BannerList/hooks/useAdvancedSearch.d.ts +21 -0
- package/dist/views/Banners/BannerList/index.d.ts +1 -0
- package/dist/views/Zones/ZoneList/ZoneList.helpers.d.ts +5 -0
- package/dist/views/Zones/ZoneList/ZoneList.vue.d.ts +28 -0
- package/dist/views/Zones/ZoneList/index.d.ts +1 -0
- package/package.json +32 -23
- package/src/config/config.json +1 -1
- package/src/constants/menu.ts +24 -10
- package/src/constants/paths.ts +10 -27
- package/src/constants/routes.ts +27 -49
- package/src/dev.ts +22 -34
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useFetchBanner.ts +41 -0
- package/src/hooks/useFetchBanners.ts +23 -0
- package/src/hooks/useFetchZones.ts +23 -0
- package/src/locales/en.ts +43 -0
- package/src/locales/ru.ts +45 -0
- package/src/main.ts +12 -0
- package/src/router/index.ts +38 -0
- package/src/services/requests.ts +35 -86
- package/src/typings/banners.ts +44 -0
- package/src/typings/common.ts +1 -0
- package/src/typings/model.ts +119 -16
- package/src/typings/shims-vue.d.ts +1 -0
- package/src/typings/translate.d.ts +10 -0
- package/src/typings/zones.ts +5 -0
- package/src/utils/common.ts +13 -0
- package/src/views/App.vue +7 -7
- package/src/views/Banners/BannerForm/BannerForm.helpers.ts +38 -0
- package/src/views/Banners/BannerForm/BannerForm.vue +236 -0
- package/src/views/Banners/BannerForm/index.ts +1 -0
- package/src/views/Banners/BannerList/BannerList.helpers.ts +93 -0
- package/src/views/Banners/BannerList/BannerList.vue +233 -0
- package/src/views/Banners/BannerList/hooks/index.ts +1 -0
- package/src/views/Banners/BannerList/hooks/useAdvancedSearch.ts +152 -0
- package/src/views/Banners/BannerList/index.ts +1 -0
- package/src/views/Home.vue +37 -0
- package/src/views/Zones/ZoneList/ZoneList.helpers.ts +34 -0
- package/src/views/Zones/ZoneList/ZoneList.vue +75 -0
- package/src/views/Zones/ZoneList/index.ts +1 -0
- package/dist/views/BannerAreaForm.vue.d.ts +0 -22
- package/dist/views/BannerAreaList.vue.d.ts +0 -17
- package/dist/views/BannerItemForm.vue.d.ts +0 -27
- package/dist/views/BannerItemList.vue.d.ts +0 -22
- package/src/index.ts +0 -3
- package/src/locales/en.js +0 -3
- package/src/locales/ru.js +0 -3
- package/src/views/BannerAreaForm.vue +0 -173
- package/src/views/BannerAreaList.vue +0 -176
- package/src/views/BannerItemForm.vue +0 -231
- package/src/views/BannerItemList.vue +0 -221
- package/typings/index.d.ts +0 -15
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<page
|
|
3
|
+
:title="$t('banners:banners')"
|
|
4
|
+
:header-buttons="[
|
|
5
|
+
{
|
|
6
|
+
text: $t('banners:createBanner'),
|
|
7
|
+
href: getBannersBannerFormUrl({ bannerId: 'create' }),
|
|
8
|
+
},
|
|
9
|
+
]"
|
|
10
|
+
>
|
|
11
|
+
<template v-slot:content>
|
|
12
|
+
<data-table
|
|
13
|
+
:column-defs="columnDefs"
|
|
14
|
+
:row-data="rowData"
|
|
15
|
+
:loading="isRowDataLoading"
|
|
16
|
+
:error-message="errorMessage"
|
|
17
|
+
data-table="banners"
|
|
18
|
+
:use-search="true"
|
|
19
|
+
:use-pagination="true"
|
|
20
|
+
:search-query="searchQuery"
|
|
21
|
+
:pagination="{
|
|
22
|
+
pageNumber,
|
|
23
|
+
pageCount,
|
|
24
|
+
pageSize,
|
|
25
|
+
disabled: isRowDataLoading,
|
|
26
|
+
}"
|
|
27
|
+
@change="handleChange"
|
|
28
|
+
>
|
|
29
|
+
<template v-slot:filters>
|
|
30
|
+
<advanced-search :tags="tags" @click:tag="tagRemovalHandler">
|
|
31
|
+
<div class="filters">
|
|
32
|
+
<form-field-multi-select
|
|
33
|
+
v-model="zoneFilter"
|
|
34
|
+
:options="zonesOptionList"
|
|
35
|
+
name="zoneFilter"
|
|
36
|
+
:searchable="true"
|
|
37
|
+
:label="$t('banners:zone')"
|
|
38
|
+
class="filter"
|
|
39
|
+
/>
|
|
40
|
+
|
|
41
|
+
<form-field
|
|
42
|
+
v-model="dateFilter"
|
|
43
|
+
:label="$t('banners:date')"
|
|
44
|
+
name="dateFilter"
|
|
45
|
+
type="date"
|
|
46
|
+
class="filter"
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
<form-field-multi-select
|
|
50
|
+
v-model="statusFilter"
|
|
51
|
+
:options="statusesOptionList"
|
|
52
|
+
name="statusFilter"
|
|
53
|
+
:searchable="true"
|
|
54
|
+
:label="$t('banners:status')"
|
|
55
|
+
class="filter"
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
</advanced-search>
|
|
59
|
+
</template>
|
|
60
|
+
|
|
61
|
+
<template v-slot:cell(actions)="{ row }">
|
|
62
|
+
<base-button
|
|
63
|
+
variant="icon"
|
|
64
|
+
:title="$t('banners:edit')"
|
|
65
|
+
:disabled="isBusy(row.id)"
|
|
66
|
+
:href="getBannersBannerFormUrl({ bannerId: row.id })"
|
|
67
|
+
>
|
|
68
|
+
<svg-icon name="edit" />
|
|
69
|
+
</base-button>
|
|
70
|
+
|
|
71
|
+
<base-button
|
|
72
|
+
variant="icon"
|
|
73
|
+
:title="$t('banners:remove')"
|
|
74
|
+
:disabled="isBusy(row.id)"
|
|
75
|
+
@click="handleResourceDelete(row.id)"
|
|
76
|
+
>
|
|
77
|
+
<svg-icon name="delete" />
|
|
78
|
+
</base-button>
|
|
79
|
+
</template>
|
|
80
|
+
</data-table>
|
|
81
|
+
</template>
|
|
82
|
+
</page>
|
|
83
|
+
</template>
|
|
84
|
+
|
|
85
|
+
<script lang="ts">
|
|
86
|
+
import {
|
|
87
|
+
computed,
|
|
88
|
+
defineComponent,
|
|
89
|
+
SetupContext,
|
|
90
|
+
watch,
|
|
91
|
+
} from '@vue/composition-api';
|
|
92
|
+
import isEqual from 'lodash.isequal';
|
|
93
|
+
import pick from 'lodash.pick';
|
|
94
|
+
|
|
95
|
+
import {
|
|
96
|
+
ColumnDefinition,
|
|
97
|
+
useDataTable,
|
|
98
|
+
useTranslation,
|
|
99
|
+
} from '@tager/admin-ui';
|
|
100
|
+
import { useResourceDelete } from '@tager/admin-services';
|
|
101
|
+
|
|
102
|
+
import { deleteBanner, getBanners } from '../../../services/requests';
|
|
103
|
+
import { Banner } from '../../../typings/banners';
|
|
104
|
+
import { getBannersBannerFormUrl } from '../../../constants/paths';
|
|
105
|
+
import { useFetchZones } from '../../../hooks';
|
|
106
|
+
|
|
107
|
+
import { getColumnDefs } from './BannerList.helpers';
|
|
108
|
+
import { useAdvancedSearch } from './hooks';
|
|
109
|
+
|
|
110
|
+
export default defineComponent({
|
|
111
|
+
name: 'BannerList',
|
|
112
|
+
setup(props, context: SetupContext) {
|
|
113
|
+
const { t } = useTranslation(context);
|
|
114
|
+
const { loading: isZonesLoading, data: zoneList } = useFetchZones({
|
|
115
|
+
context,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const {
|
|
119
|
+
zoneFilter,
|
|
120
|
+
zonesOptionList,
|
|
121
|
+
dateFilter,
|
|
122
|
+
statusFilter,
|
|
123
|
+
statusesOptionList,
|
|
124
|
+
filterParams,
|
|
125
|
+
tags,
|
|
126
|
+
tagRemovalHandler,
|
|
127
|
+
} = useAdvancedSearch({
|
|
128
|
+
context,
|
|
129
|
+
t,
|
|
130
|
+
zoneList,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const {
|
|
134
|
+
fetchEntityList: fetchBanners,
|
|
135
|
+
isLoading: isBannersLoading,
|
|
136
|
+
rowData,
|
|
137
|
+
errorMessage,
|
|
138
|
+
handleChange,
|
|
139
|
+
searchQuery,
|
|
140
|
+
pageNumber,
|
|
141
|
+
pageCount,
|
|
142
|
+
pageSize,
|
|
143
|
+
} = useDataTable<Banner>({
|
|
144
|
+
fetchEntityList: (params) =>
|
|
145
|
+
getBanners({
|
|
146
|
+
query: params.searchQuery,
|
|
147
|
+
pageNumber: params.pageNumber,
|
|
148
|
+
pageSize: params.pageSize,
|
|
149
|
+
...filterParams.value,
|
|
150
|
+
}),
|
|
151
|
+
initialValue: [],
|
|
152
|
+
context,
|
|
153
|
+
resourceName: 'Banners',
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
watch(filterParams, () => {
|
|
157
|
+
if (isZonesLoading.value) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const newQuery = {
|
|
162
|
+
...pick(context.root.$route.query, ['query', 'pageNumber']),
|
|
163
|
+
...filterParams.value,
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
if (!isEqual(context.root.$route.query, newQuery)) {
|
|
167
|
+
context.root.$router.replace({ query: newQuery });
|
|
168
|
+
fetchBanners();
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const { isDeleting, handleResourceDelete } = useResourceDelete({
|
|
173
|
+
deleteResource: deleteBanner,
|
|
174
|
+
resourceName: 'Banner',
|
|
175
|
+
onSuccess: fetchBanners,
|
|
176
|
+
context,
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
const isBusy = (bannerId: number): boolean => {
|
|
180
|
+
return isDeleting(bannerId) || isBannersLoading.value;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const columnDefs = computed<ColumnDefinition<Banner>[]>(() =>
|
|
184
|
+
getColumnDefs(context.root.$t)
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
const isRowDataLoading = computed<boolean>(
|
|
188
|
+
() => isBannersLoading.value || isZonesLoading.value
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
return {
|
|
192
|
+
columnDefs,
|
|
193
|
+
isRowDataLoading,
|
|
194
|
+
rowData,
|
|
195
|
+
errorMessage,
|
|
196
|
+
handleChange,
|
|
197
|
+
getBannersBannerFormUrl,
|
|
198
|
+
searchQuery,
|
|
199
|
+
pageNumber,
|
|
200
|
+
pageCount,
|
|
201
|
+
pageSize,
|
|
202
|
+
isBusy,
|
|
203
|
+
handleResourceDelete,
|
|
204
|
+
|
|
205
|
+
// Advanced search
|
|
206
|
+
zoneFilter,
|
|
207
|
+
zonesOptionList,
|
|
208
|
+
dateFilter,
|
|
209
|
+
statusFilter,
|
|
210
|
+
statusesOptionList,
|
|
211
|
+
tags,
|
|
212
|
+
tagRemovalHandler,
|
|
213
|
+
};
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
</script>
|
|
217
|
+
|
|
218
|
+
<style lang="scss">
|
|
219
|
+
.filters {
|
|
220
|
+
display: flex;
|
|
221
|
+
margin: 0 -10px;
|
|
222
|
+
|
|
223
|
+
&:not(:first-child) {
|
|
224
|
+
margin-top: 10px;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.filter {
|
|
228
|
+
padding: 10px 10px 0;
|
|
229
|
+
width: 50%;
|
|
230
|
+
margin: 0;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useAdvancedSearch } from './useAdvancedSearch';
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
ComputedRef,
|
|
4
|
+
ref,
|
|
5
|
+
Ref,
|
|
6
|
+
SetupContext,
|
|
7
|
+
watch,
|
|
8
|
+
} from '@vue/composition-api';
|
|
9
|
+
import { TFunction } from 'i18next';
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
FilterTagType,
|
|
13
|
+
getFilterParamAsString,
|
|
14
|
+
getFilterParamAsStringArray,
|
|
15
|
+
getFilterParams,
|
|
16
|
+
OptionType,
|
|
17
|
+
} from '@tager/admin-ui';
|
|
18
|
+
|
|
19
|
+
import { Zone } from '../../../../typings/zones';
|
|
20
|
+
import { Status } from '../../../../typings/banners';
|
|
21
|
+
import { getStatus } from '../BannerList.helpers';
|
|
22
|
+
|
|
23
|
+
interface Params {
|
|
24
|
+
context: SetupContext;
|
|
25
|
+
t: TFunction;
|
|
26
|
+
zoneList: ComputedRef<Zone[]>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface State {
|
|
30
|
+
zoneFilter: Ref<OptionType[]>;
|
|
31
|
+
zonesOptionList: ComputedRef<OptionType[]>;
|
|
32
|
+
dateFilter: Ref<string>;
|
|
33
|
+
statusFilter: Ref<OptionType[]>;
|
|
34
|
+
statusesOptionList: ComputedRef<OptionType[]>;
|
|
35
|
+
filterParams: ComputedRef<Record<string, string | string[]>>;
|
|
36
|
+
tags: ComputedRef<FilterTagType[]>;
|
|
37
|
+
tagRemovalHandler(event: FilterTagType): void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
enum FilterTypes {
|
|
41
|
+
Zone = 'zone',
|
|
42
|
+
Date = 'date',
|
|
43
|
+
Status = 'status',
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function useAdvancedSearch({ context, t, zoneList }: Params): State {
|
|
47
|
+
/** Zone **/
|
|
48
|
+
|
|
49
|
+
const zonesOptionList = computed<OptionType[]>(() =>
|
|
50
|
+
zoneList.value.map(({ id, name }) => ({
|
|
51
|
+
value: id,
|
|
52
|
+
label: name,
|
|
53
|
+
}))
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const initialZoneFilter = computed<OptionType[]>(() => {
|
|
57
|
+
const queryValue = getFilterParamAsStringArray(
|
|
58
|
+
context.root.$route.query,
|
|
59
|
+
FilterTypes.Zone
|
|
60
|
+
);
|
|
61
|
+
return zonesOptionList.value.filter(({ value }) =>
|
|
62
|
+
queryValue.some((selected) => selected === value)
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const zoneFilter = ref<OptionType[]>(initialZoneFilter.value);
|
|
67
|
+
|
|
68
|
+
watch(initialZoneFilter, () => {
|
|
69
|
+
zoneFilter.value = initialZoneFilter.value;
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
/** Date **/
|
|
73
|
+
|
|
74
|
+
const initialDateFilter = computed<string>(
|
|
75
|
+
() =>
|
|
76
|
+
getFilterParamAsString(context.root.$route.query, FilterTypes.Date) ?? ''
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const dateFilter = ref<string>(initialDateFilter.value);
|
|
80
|
+
|
|
81
|
+
watch(initialDateFilter, () => {
|
|
82
|
+
dateFilter.value = initialDateFilter.value;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
/** Status **/
|
|
86
|
+
|
|
87
|
+
const statusesOptionList = computed<OptionType[]>(() =>
|
|
88
|
+
Object.entries(Status).map(([_, value]) => ({
|
|
89
|
+
value: value,
|
|
90
|
+
label: getStatus(value, t),
|
|
91
|
+
}))
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const initialStatusFilter = computed<OptionType[]>(() => {
|
|
95
|
+
const queryValue = getFilterParamAsStringArray(
|
|
96
|
+
context.root.$route.query,
|
|
97
|
+
FilterTypes.Status
|
|
98
|
+
);
|
|
99
|
+
return statusesOptionList.value.filter(({ value }) =>
|
|
100
|
+
queryValue.some((selected) => selected === value)
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const statusFilter = ref<OptionType[]>(initialStatusFilter.value);
|
|
105
|
+
|
|
106
|
+
watch(initialStatusFilter, () => {
|
|
107
|
+
statusFilter.value = initialStatusFilter.value;
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
/** Params **/
|
|
111
|
+
|
|
112
|
+
const filterParams = computed(() =>
|
|
113
|
+
getFilterParams({
|
|
114
|
+
[FilterTypes.Zone]: zoneFilter.value.map(({ value }) => value),
|
|
115
|
+
[FilterTypes.Date]: dateFilter.value,
|
|
116
|
+
[FilterTypes.Status]: statusFilter.value.map(({ value }) => value),
|
|
117
|
+
})
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
/** Tag removal handler **/
|
|
121
|
+
|
|
122
|
+
const tagRemovalHandler = (event: FilterTagType): void => {
|
|
123
|
+
if (event.name === FilterTypes.Zone) {
|
|
124
|
+
zoneFilter.value = zoneFilter.value.filter(
|
|
125
|
+
({ value }) => value !== event.value
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
if (event.name === FilterTypes.Date) {
|
|
129
|
+
dateFilter.value = '';
|
|
130
|
+
}
|
|
131
|
+
if (event.name === FilterTypes.Status) {
|
|
132
|
+
statusFilter.value = statusFilter.value.filter(
|
|
133
|
+
({ value }) => value !== event.value
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/** Tags **/
|
|
139
|
+
|
|
140
|
+
const tags = computed<FilterTagType[]>(() => []);
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
zoneFilter,
|
|
144
|
+
zonesOptionList,
|
|
145
|
+
dateFilter,
|
|
146
|
+
statusFilter,
|
|
147
|
+
statusesOptionList,
|
|
148
|
+
filterParams,
|
|
149
|
+
tags,
|
|
150
|
+
tagRemovalHandler,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './BannerList.vue';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<navigation-grid :nav-items="navItemList" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { defineComponent, ref } from '@vue/composition-api';
|
|
7
|
+
|
|
8
|
+
import { NavigationGridItem } from '@tager/admin-ui';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
getBannersZoneListUrl,
|
|
12
|
+
getBannersBannerListUrl,
|
|
13
|
+
} from '../constants/paths';
|
|
14
|
+
|
|
15
|
+
export default defineComponent({
|
|
16
|
+
name: 'Home',
|
|
17
|
+
setup(props, context) {
|
|
18
|
+
const navItemList = ref<NavigationGridItem[]>([
|
|
19
|
+
{
|
|
20
|
+
name: context.root.$t('banners:banners'),
|
|
21
|
+
linkList: [
|
|
22
|
+
{
|
|
23
|
+
url: getBannersZoneListUrl(),
|
|
24
|
+
text: context.root.$t('banners:zones'),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
url: getBannersBannerListUrl(),
|
|
28
|
+
text: context.root.$t('banners:banners'),
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
]);
|
|
33
|
+
|
|
34
|
+
return { navItemList };
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
</script>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TFunction } from 'i18next';
|
|
2
|
+
|
|
3
|
+
import { ColumnDefinition } from '@tager/admin-ui';
|
|
4
|
+
|
|
5
|
+
import { Zone } from '../../../typings/zones';
|
|
6
|
+
import { getBannersBannerListUrl } from '../../../constants/paths';
|
|
7
|
+
|
|
8
|
+
export function getColumnDefs(t: TFunction): ColumnDefinition<Zone>[] {
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
id: 0,
|
|
12
|
+
name: 'ID',
|
|
13
|
+
field: 'id',
|
|
14
|
+
style: { width: '50px', textAlign: 'center' },
|
|
15
|
+
headStyle: { width: '50px', textAlign: 'center' },
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: 1,
|
|
19
|
+
name: t('banners:name'),
|
|
20
|
+
field: 'name',
|
|
21
|
+
type: 'name',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: 2,
|
|
25
|
+
name: t('banners:banners'),
|
|
26
|
+
field: 'bannersCount',
|
|
27
|
+
style: { whiteSpace: 'nowrap', width: '130px' },
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getLinkToBannersByZone(zoneId: number): string {
|
|
33
|
+
return `${getBannersBannerListUrl()}?filter[zone]=${zoneId}`;
|
|
34
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<page :title="$t('banners:zones')">
|
|
3
|
+
<template v-slot:content>
|
|
4
|
+
<data-table
|
|
5
|
+
:column-defs="columnDefs"
|
|
6
|
+
:row-data="rowData"
|
|
7
|
+
:loading="isRowDataLoading"
|
|
8
|
+
:error-message="errorMessage"
|
|
9
|
+
data-table="banners-zones"
|
|
10
|
+
:use-search="false"
|
|
11
|
+
:use-pagination="false"
|
|
12
|
+
@change="handleChange"
|
|
13
|
+
>
|
|
14
|
+
<template v-slot:cell(banners-count)="{ row }">
|
|
15
|
+
<count-button
|
|
16
|
+
:href="getLinkToBannersByZone(row.id)"
|
|
17
|
+
variant="outline-secondary"
|
|
18
|
+
:count="row.bannersCount"
|
|
19
|
+
>
|
|
20
|
+
{{ $t('banners:banners') }}
|
|
21
|
+
</count-button>
|
|
22
|
+
</template>
|
|
23
|
+
</data-table>
|
|
24
|
+
</template>
|
|
25
|
+
</page>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script lang="ts">
|
|
29
|
+
import {
|
|
30
|
+
computed,
|
|
31
|
+
defineComponent,
|
|
32
|
+
onMounted,
|
|
33
|
+
SetupContext,
|
|
34
|
+
} from '@vue/composition-api';
|
|
35
|
+
|
|
36
|
+
import { useDataTable } from '@tager/admin-ui';
|
|
37
|
+
|
|
38
|
+
import { Zone } from '../../../typings/zones';
|
|
39
|
+
import { getZones } from '../../../services/requests';
|
|
40
|
+
|
|
41
|
+
import { getColumnDefs, getLinkToBannersByZone } from './ZoneList.helpers';
|
|
42
|
+
|
|
43
|
+
export default defineComponent({
|
|
44
|
+
name: 'ZoneList',
|
|
45
|
+
setup(props, context: SetupContext) {
|
|
46
|
+
const {
|
|
47
|
+
fetchEntityList: fetchZones,
|
|
48
|
+
isLoading: isZonesLoading,
|
|
49
|
+
rowData,
|
|
50
|
+
errorMessage,
|
|
51
|
+
handleChange,
|
|
52
|
+
} = useDataTable<Zone>({
|
|
53
|
+
fetchEntityList: getZones,
|
|
54
|
+
initialValue: [],
|
|
55
|
+
context,
|
|
56
|
+
resourceName: 'Banner Zones',
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
onMounted(() => {
|
|
60
|
+
fetchZones();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const columnDefs = computed(() => getColumnDefs(context.root.$t));
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
columnDefs,
|
|
67
|
+
isRowDataLoading: isZonesLoading,
|
|
68
|
+
rowData,
|
|
69
|
+
errorMessage,
|
|
70
|
+
handleChange,
|
|
71
|
+
getLinkToBannersByZone,
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ZoneList.vue';
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import Vue from 'vue';
|
|
2
|
-
import { BannerArea } from '../typings/model';
|
|
3
|
-
import { getBannerAreaListUrl } from '../constants/paths';
|
|
4
|
-
declare type FormValues = {
|
|
5
|
-
alias: string;
|
|
6
|
-
label: string;
|
|
7
|
-
scenario: string;
|
|
8
|
-
};
|
|
9
|
-
declare const _default: import("vue/types/vue").ExtendedVue<Vue, {
|
|
10
|
-
values: FormValues;
|
|
11
|
-
errors: Record<string, string>;
|
|
12
|
-
isContentLoading: boolean;
|
|
13
|
-
}, {
|
|
14
|
-
convertReviewToInitialValues(bannerArea: BannerArea): FormValues;
|
|
15
|
-
updateValues(): void;
|
|
16
|
-
submitForm(): void;
|
|
17
|
-
getAreaListUrl: typeof getBannerAreaListUrl;
|
|
18
|
-
}, {
|
|
19
|
-
areaId: string;
|
|
20
|
-
isCreation: boolean;
|
|
21
|
-
}, Record<never, any>>;
|
|
22
|
-
export default _default;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import Vue from 'vue';
|
|
2
|
-
import { ColumnDefinition } from '@tager/admin-ui';
|
|
3
|
-
import { Nullable } from '@tager/admin-services';
|
|
4
|
-
import { BannerArea } from '../typings/model';
|
|
5
|
-
declare const _default: import("vue/types/vue").ExtendedVue<Vue, {
|
|
6
|
-
columnDefs: Array<ColumnDefinition<BannerArea>>;
|
|
7
|
-
rowData: Array<BannerArea>;
|
|
8
|
-
deletingBannerAreaIdList: Array<number>;
|
|
9
|
-
isRowDataLoading: boolean;
|
|
10
|
-
errorMessage: Nullable<string>;
|
|
11
|
-
}, {
|
|
12
|
-
getBannerAreaUrl(areaId: number | string): string;
|
|
13
|
-
refreshBannerAreaList(): Promise<void>;
|
|
14
|
-
handleBannerAreaDelete(bannerArea: BannerArea): void;
|
|
15
|
-
getLinkToBannerItems(areaAlias: string): string;
|
|
16
|
-
}, unknown, Record<never, any>>;
|
|
17
|
-
export default _default;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import Vue from 'vue';
|
|
2
|
-
import { FileType, Nullable } from '@tager/admin-services';
|
|
3
|
-
import { BannerArea, BannerItem } from '../typings/model';
|
|
4
|
-
declare type FormValues = {
|
|
5
|
-
title: string;
|
|
6
|
-
text: string;
|
|
7
|
-
buttonLink: string;
|
|
8
|
-
buttonLabel: string;
|
|
9
|
-
buttonIsNewTab: boolean;
|
|
10
|
-
image: Nullable<FileType>;
|
|
11
|
-
};
|
|
12
|
-
declare const _default: import("vue/types/vue").ExtendedVue<Vue, {
|
|
13
|
-
values: FormValues;
|
|
14
|
-
errors: Record<string, string>;
|
|
15
|
-
isContentLoading: boolean;
|
|
16
|
-
bannerArea: Nullable<BannerArea>;
|
|
17
|
-
}, {
|
|
18
|
-
updateValues(): void;
|
|
19
|
-
convertReviewToInitialValues(bannerItem: BannerItem): FormValues;
|
|
20
|
-
submitForm(): void;
|
|
21
|
-
}, {
|
|
22
|
-
itemId: string;
|
|
23
|
-
areaAlias: string;
|
|
24
|
-
isCreation: boolean;
|
|
25
|
-
bannerItemListUrl: string;
|
|
26
|
-
}, Record<never, any>>;
|
|
27
|
-
export default _default;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import Vue from 'vue';
|
|
2
|
-
import { ColumnDefinition } from '@tager/admin-ui';
|
|
3
|
-
import { Nullable } from '@tager/admin-services';
|
|
4
|
-
import { BannerArea, BannerItem } from '../typings/model';
|
|
5
|
-
declare const _default: import("vue/types/vue").ExtendedVue<Vue, {
|
|
6
|
-
columnDefs: Array<ColumnDefinition<BannerItem>>;
|
|
7
|
-
rowData: Array<BannerItem>;
|
|
8
|
-
deletingBannerItemIdList: Array<number>;
|
|
9
|
-
isBannerItemMoving: boolean;
|
|
10
|
-
isRowDataLoading: boolean;
|
|
11
|
-
errorMessage: Nullable<string>;
|
|
12
|
-
bannerArea: Nullable<BannerArea>;
|
|
13
|
-
}, {
|
|
14
|
-
refreshBannerItemList(): Promise<void>;
|
|
15
|
-
moveBannerItem(bannerItemId: number, direction: 'up' | 'down'): void;
|
|
16
|
-
handleBannerItemDelete(bannerItem: BannerItem): void;
|
|
17
|
-
getLinkToBannerItemForm(bannerItemId: number | string): string;
|
|
18
|
-
}, {
|
|
19
|
-
areaAlias: string;
|
|
20
|
-
pageTitle: string;
|
|
21
|
-
}, Record<never, any>>;
|
|
22
|
-
export default _default;
|
package/src/index.ts
DELETED
package/src/locales/en.js
DELETED
package/src/locales/ru.js
DELETED