@tager/admin-banners 0.3.7 → 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 -8
- 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 -41
- package/dist/locales/ru.d.ts +2 -3
- package/dist/main.d.ts +3 -4
- package/dist/services/requests.d.ts +25 -25
- package/dist/style.css +1 -0
- package/dist/typings/banners.d.ts +47 -47
- package/dist/typings/common.d.ts +1 -1
- package/dist/typings/model.d.ts +104 -104
- package/dist/typings/zones.d.ts +9 -9
- 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 -9251
- 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 +1 -10
- package/src/hooks/useFetchZones.ts +2 -5
- package/src/locales/apply.ts +9 -0
- package/src/locales/en.ts +1 -1
- package/src/locales/ru.ts +40 -42
- package/src/main.ts +3 -8
- package/src/utils/paths.ts +15 -0
- package/src/views/Banners/BannerForm/BannerForm.vue +97 -80
- 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 -3709
- package/dist/index.umd.js +0 -3728
- 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
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,993 @@
|
|
|
1
|
+
import { i18n, request, useI18n, useResource, useResourceDelete, createId, useToast, navigateBack, convertRequestErrorToMap } from "@tager/admin-services";
|
|
2
|
+
import { defineComponent, onMounted, computed, resolveComponent, openBlock, createBlock, withCtx, createVNode, createTextVNode, toDisplayString, ref, watch, createElementVNode, withModifiers, createElementBlock, Fragment, renderList } from "vue";
|
|
3
|
+
import { CountButton, DataTable, useDataTable, getFilterParamAsStringArray, getFilterParamAsString, getFilterParams, DeleteIcon, EditIcon, BaseButton, FormField, FormFieldMultiSelect, AdvancedSearch, FormFieldFileInput, FormFieldCheckbox, InputLabel, FormFieldSelect, FormFooter } from "@tager/admin-ui";
|
|
4
|
+
import { Page } from "@tager/admin-layout";
|
|
5
|
+
import { universalFieldUtils, DynamicField } from "@tager/admin-dynamic-field";
|
|
6
|
+
import "i18next";
|
|
7
|
+
import { compile } from "path-to-regexp";
|
|
8
|
+
import isEqual from "lodash.isequal";
|
|
9
|
+
import pick from "lodash.pick";
|
|
10
|
+
import { useRoute, useRouter } from "vue-router";
|
|
11
|
+
const EN = {
|
|
12
|
+
home: "Home",
|
|
13
|
+
zone: "Banner zone",
|
|
14
|
+
zones: "Banner zones",
|
|
15
|
+
banners: "Banners",
|
|
16
|
+
bannerForm: "Banner Form",
|
|
17
|
+
createBanner: "Create Banner",
|
|
18
|
+
updateBanner: "Update Banner",
|
|
19
|
+
link: "Link",
|
|
20
|
+
image: "Image",
|
|
21
|
+
openNewTab: "Open new tab",
|
|
22
|
+
period: "Period",
|
|
23
|
+
from: "From",
|
|
24
|
+
to: "To",
|
|
25
|
+
disabled: "Disabled",
|
|
26
|
+
comment: "Comment",
|
|
27
|
+
status: "Status",
|
|
28
|
+
bannerZoneIsDeleted: "Banner zone is deleted",
|
|
29
|
+
newTab: "New Tab",
|
|
30
|
+
yes: "Yes",
|
|
31
|
+
no: "No",
|
|
32
|
+
edit: "Edit",
|
|
33
|
+
remove: "Remove",
|
|
34
|
+
actions: "actions",
|
|
35
|
+
date: "Date",
|
|
36
|
+
name: "Name",
|
|
37
|
+
priority: "Priority",
|
|
38
|
+
success: "Success",
|
|
39
|
+
error: "Error",
|
|
40
|
+
statuses: {
|
|
41
|
+
waiting: "Waiting",
|
|
42
|
+
archived: "Archived",
|
|
43
|
+
active: "Active",
|
|
44
|
+
disabled: "Disabled"
|
|
45
|
+
},
|
|
46
|
+
bannerWasSuccessfullyCreated: "Banner was successfully created",
|
|
47
|
+
bannerWasSuccessfullyUpdated: "Banner was successfully updated",
|
|
48
|
+
bannerCreationWasFailed: "Banner creation was failed",
|
|
49
|
+
bannerUpdateWasFailed: "Banner update was failed"
|
|
50
|
+
};
|
|
51
|
+
const RU = {
|
|
52
|
+
home: "\u0413\u043B\u0430\u0432\u043D\u0430\u044F",
|
|
53
|
+
zone: "\u0411\u0430\u043D\u043D\u0435\u0440\u043D\u0430\u044F \u0437\u043E\u043D\u0430",
|
|
54
|
+
zones: "\u0411\u0430\u043D\u043D\u0435\u0440\u043D\u044B\u0435 \u0437\u043E\u043D\u044B",
|
|
55
|
+
banners: "\u0411\u0430\u043D\u043D\u0435\u0440\u044B",
|
|
56
|
+
bannerForm: "\u0424\u043E\u0440\u043C\u0430 \u0431\u0430\u043D\u043D\u0435\u0440\u0430",
|
|
57
|
+
createBanner: "\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0431\u0430\u043D\u043D\u0435\u0440",
|
|
58
|
+
updateBanner: "\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0431\u0430\u043D\u043D\u0435\u0440",
|
|
59
|
+
link: "\u0421\u0441\u044B\u043B\u043A\u0430",
|
|
60
|
+
image: "\u041A\u0430\u0440\u0442\u0438\u043D\u043A\u0430",
|
|
61
|
+
openNewTab: "\u041E\u0442\u043A\u0440\u044B\u0432\u0430\u0442\u044C \u0432 \u043D\u043E\u0432\u043E\u0439 \u0432\u043A\u043B\u0430\u0434\u043A\u0435",
|
|
62
|
+
period: "\u0421\u0440\u043E\u043A \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044F",
|
|
63
|
+
from: "\u041E\u0442",
|
|
64
|
+
to: "\u0414\u043E",
|
|
65
|
+
disabled: "\u0412\u044B\u043A\u043B\u044E\u0447\u0435\u043D",
|
|
66
|
+
comment: "\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439",
|
|
67
|
+
status: "\u0421\u0442\u0430\u0442\u0443\u0441",
|
|
68
|
+
bannerZoneIsDeleted: "\u0411\u0430\u043D\u043D\u0435\u0440\u043D\u0430\u044F \u0437\u043E\u043D\u0430 \u0443\u0434\u0430\u043B\u0435\u043D\u0430",
|
|
69
|
+
newTab: "\u041D\u043E\u0432\u0430\u044F \u0432\u043A\u043B\u0430\u0434\u043A\u0430",
|
|
70
|
+
yes: "\u0414\u0430",
|
|
71
|
+
no: "\u041D\u0435\u0442",
|
|
72
|
+
edit: "\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C",
|
|
73
|
+
remove: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C",
|
|
74
|
+
actions: "\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044F",
|
|
75
|
+
date: "\u0414\u0430\u0442\u0430",
|
|
76
|
+
name: "\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435",
|
|
77
|
+
priority: "\u041F\u0440\u0438\u043E\u0440\u0438\u0442\u0435\u0442",
|
|
78
|
+
success: "\u0423\u0441\u043F\u0435\u0445",
|
|
79
|
+
error: "\u041E\u0448\u0438\u0431\u043A\u0430",
|
|
80
|
+
statuses: {
|
|
81
|
+
waiting: "\u0412 \u043E\u0436\u0438\u0434\u0430\u043D\u0438\u0438",
|
|
82
|
+
archived: "\u0410\u0440\u0445\u0438\u0432\u043D\u044B\u0439",
|
|
83
|
+
active: "\u0410\u043A\u0442\u0438\u0432\u043D\u044B\u0439",
|
|
84
|
+
disabled: "\u041E\u0442\u043A\u043B\u044E\u0447\u0435\u043D"
|
|
85
|
+
},
|
|
86
|
+
bannerWasSuccessfullyCreated: "\u0411\u0430\u043D\u043D\u0435\u0440 \u0443\u0441\u043F\u0435\u0448\u043D\u043E \u0441\u043E\u0437\u0434\u0430\u043D",
|
|
87
|
+
bannerWasSuccessfullyUpdated: "\u0411\u0430\u043D\u043D\u0435\u0440 \u0443\u0441\u043F\u0435\u0448\u043D\u043E \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D",
|
|
88
|
+
bannerCreationWasFailed: "\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0441\u043E\u0437\u0434\u0430\u0442\u044C \u0431\u0430\u043D\u043D\u0435\u0440",
|
|
89
|
+
bannerUpdateWasFailed: "\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0431\u043D\u043E\u0432\u0438\u0442\u044C \u0431\u0430\u043D\u043D\u0435\u0440"
|
|
90
|
+
};
|
|
91
|
+
function applyTranslations() {
|
|
92
|
+
i18n.addTranslations("en", "banners", EN);
|
|
93
|
+
i18n.addTranslations("ru", "banners", RU);
|
|
94
|
+
}
|
|
95
|
+
var Status = /* @__PURE__ */ ((Status2) => {
|
|
96
|
+
Status2["Waiting"] = "WAITING";
|
|
97
|
+
Status2["Archived"] = "ARCHIVED";
|
|
98
|
+
Status2["Active"] = "ACTIVE";
|
|
99
|
+
Status2["Disabled"] = "DISABLED";
|
|
100
|
+
return Status2;
|
|
101
|
+
})(Status || {});
|
|
102
|
+
function getZones(params) {
|
|
103
|
+
return request.get({ path: "/admin/adv/zones", params });
|
|
104
|
+
}
|
|
105
|
+
function getZoneFields(zoneId) {
|
|
106
|
+
return request.get({ path: `/admin/adv/zones/${zoneId}` });
|
|
107
|
+
}
|
|
108
|
+
function getBanners(params) {
|
|
109
|
+
return request.get({ path: "/admin/adv", params });
|
|
110
|
+
}
|
|
111
|
+
function getBanner(bannerId) {
|
|
112
|
+
return request.get({ path: `/admin/adv/${bannerId}` });
|
|
113
|
+
}
|
|
114
|
+
function createBanner(payload) {
|
|
115
|
+
return request.post({ path: "/admin/adv", body: payload });
|
|
116
|
+
}
|
|
117
|
+
function updateBanner(bannerId, payload) {
|
|
118
|
+
return request.put({
|
|
119
|
+
path: `/admin/adv/${bannerId}`,
|
|
120
|
+
body: payload
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function deleteBanner(bannerId) {
|
|
124
|
+
return request.delete({ path: `/admin/adv/${bannerId}` });
|
|
125
|
+
}
|
|
126
|
+
function getBannerCount() {
|
|
127
|
+
return request.get({ path: "/admin/adv/count" });
|
|
128
|
+
}
|
|
129
|
+
const BANNERS_ROUTE_PATHS = {
|
|
130
|
+
ZONE_LIST: "/banners/zones",
|
|
131
|
+
BANNER_LIST: "/banners",
|
|
132
|
+
BANNER_FORM: "/banners/:bannerId"
|
|
133
|
+
};
|
|
134
|
+
function getBannersZoneListUrl() {
|
|
135
|
+
return BANNERS_ROUTE_PATHS.ZONE_LIST;
|
|
136
|
+
}
|
|
137
|
+
function getBannersBannerListUrl() {
|
|
138
|
+
return BANNERS_ROUTE_PATHS.BANNER_LIST;
|
|
139
|
+
}
|
|
140
|
+
function getBannersBannerFormUrl(params) {
|
|
141
|
+
return compile(BANNERS_ROUTE_PATHS.BANNER_FORM)(params);
|
|
142
|
+
}
|
|
143
|
+
function getColumnDefs$1(t) {
|
|
144
|
+
return [
|
|
145
|
+
{
|
|
146
|
+
id: 0,
|
|
147
|
+
name: "ID",
|
|
148
|
+
field: "id",
|
|
149
|
+
style: { width: "50px", textAlign: "center" },
|
|
150
|
+
headStyle: { width: "50px", textAlign: "center" }
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
id: 1,
|
|
154
|
+
name: t("banners:name"),
|
|
155
|
+
field: "name",
|
|
156
|
+
type: "name"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
id: 2,
|
|
160
|
+
name: t("banners:banners"),
|
|
161
|
+
field: "bannersCount",
|
|
162
|
+
style: { whiteSpace: "nowrap", width: "130px" }
|
|
163
|
+
}
|
|
164
|
+
];
|
|
165
|
+
}
|
|
166
|
+
function getLinkToBannersByZone(zoneId) {
|
|
167
|
+
return `${getBannersBannerListUrl()}?filter[zone]=${zoneId}`;
|
|
168
|
+
}
|
|
169
|
+
var _export_sfc = (sfc, props) => {
|
|
170
|
+
const target = sfc.__vccOpts || sfc;
|
|
171
|
+
for (const [key, val] of props) {
|
|
172
|
+
target[key] = val;
|
|
173
|
+
}
|
|
174
|
+
return target;
|
|
175
|
+
};
|
|
176
|
+
const _sfc_main$2 = defineComponent({
|
|
177
|
+
name: "ZoneList",
|
|
178
|
+
components: { CountButton, Page, DataTable },
|
|
179
|
+
setup() {
|
|
180
|
+
const i18n2 = useI18n();
|
|
181
|
+
const {
|
|
182
|
+
fetchEntityList: fetchZones,
|
|
183
|
+
isLoading: isZonesLoading,
|
|
184
|
+
rowData,
|
|
185
|
+
errorMessage,
|
|
186
|
+
handleChange
|
|
187
|
+
} = useDataTable({
|
|
188
|
+
fetchEntityList: getZones,
|
|
189
|
+
initialValue: [],
|
|
190
|
+
resourceName: "Banner Zones"
|
|
191
|
+
});
|
|
192
|
+
onMounted(() => {
|
|
193
|
+
fetchZones();
|
|
194
|
+
});
|
|
195
|
+
const columnDefs = computed(() => getColumnDefs$1(i18n2.t));
|
|
196
|
+
return {
|
|
197
|
+
columnDefs,
|
|
198
|
+
isRowDataLoading: isZonesLoading,
|
|
199
|
+
rowData,
|
|
200
|
+
errorMessage,
|
|
201
|
+
handleChange,
|
|
202
|
+
getLinkToBannersByZone
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
207
|
+
const _component_CountButton = resolveComponent("CountButton");
|
|
208
|
+
const _component_DataTable = resolveComponent("DataTable");
|
|
209
|
+
const _component_Page = resolveComponent("Page");
|
|
210
|
+
return openBlock(), createBlock(_component_Page, {
|
|
211
|
+
title: _ctx.$i18n.t("banners:zones")
|
|
212
|
+
}, {
|
|
213
|
+
content: withCtx(() => [
|
|
214
|
+
createVNode(_component_DataTable, {
|
|
215
|
+
"column-defs": _ctx.columnDefs,
|
|
216
|
+
"row-data": _ctx.rowData,
|
|
217
|
+
loading: _ctx.isRowDataLoading,
|
|
218
|
+
"error-message": _ctx.errorMessage,
|
|
219
|
+
"data-table": "banners-zones",
|
|
220
|
+
"use-search": false,
|
|
221
|
+
"use-pagination": false,
|
|
222
|
+
onChange: _ctx.handleChange
|
|
223
|
+
}, {
|
|
224
|
+
"cell(banners-count)": withCtx(({ row }) => [
|
|
225
|
+
createVNode(_component_CountButton, {
|
|
226
|
+
href: _ctx.getLinkToBannersByZone(row.id),
|
|
227
|
+
variant: "outline-secondary",
|
|
228
|
+
count: row.bannersCount
|
|
229
|
+
}, {
|
|
230
|
+
default: withCtx(() => [
|
|
231
|
+
createTextVNode(toDisplayString(_ctx.$i18n.t("banners:banners")), 1)
|
|
232
|
+
]),
|
|
233
|
+
_: 2
|
|
234
|
+
}, 1032, ["href", "count"])
|
|
235
|
+
]),
|
|
236
|
+
_: 1
|
|
237
|
+
}, 8, ["column-defs", "row-data", "loading", "error-message", "onChange"])
|
|
238
|
+
]),
|
|
239
|
+
_: 1
|
|
240
|
+
}, 8, ["title"]);
|
|
241
|
+
}
|
|
242
|
+
var ZoneList = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
|
|
243
|
+
function useFetchZones() {
|
|
244
|
+
const [fetchZones, resource] = useResource({
|
|
245
|
+
fetchResource: getZones,
|
|
246
|
+
initialValue: [],
|
|
247
|
+
resourceName: "Banner zones"
|
|
248
|
+
});
|
|
249
|
+
onMounted(() => {
|
|
250
|
+
fetchZones();
|
|
251
|
+
});
|
|
252
|
+
return resource;
|
|
253
|
+
}
|
|
254
|
+
function getStatus(type, t) {
|
|
255
|
+
switch (type) {
|
|
256
|
+
case Status.Waiting:
|
|
257
|
+
return t("banners:statuses.waiting");
|
|
258
|
+
case Status.Archived:
|
|
259
|
+
return t("banners:statuses.archived");
|
|
260
|
+
case Status.Active:
|
|
261
|
+
return t("banners:statuses.active");
|
|
262
|
+
case Status.Disabled:
|
|
263
|
+
return t("banners:statuses.disabled");
|
|
264
|
+
default:
|
|
265
|
+
return "";
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function getColumnDefs(zoneList, t) {
|
|
269
|
+
return [
|
|
270
|
+
{
|
|
271
|
+
id: 0,
|
|
272
|
+
name: "#",
|
|
273
|
+
field: "id",
|
|
274
|
+
format: ({ rowIndex }) => String(rowIndex + 1),
|
|
275
|
+
style: { width: "50px", textAlign: "center" },
|
|
276
|
+
headStyle: { width: "50px", textAlign: "center" }
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
id: 1,
|
|
280
|
+
name: t("banners:zone"),
|
|
281
|
+
field: "bannerZone",
|
|
282
|
+
format: ({ row }) => {
|
|
283
|
+
const foundBannerZone = zoneList.find(
|
|
284
|
+
(zone) => zone.id === row.bannerZone
|
|
285
|
+
);
|
|
286
|
+
return foundBannerZone ? foundBannerZone.name : t("banners:bannerZoneIsDeleted");
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
id: 2,
|
|
291
|
+
name: t("banners:status"),
|
|
292
|
+
field: "status",
|
|
293
|
+
format: ({ row }) => getStatus(row.status, t),
|
|
294
|
+
style: { width: "120px" },
|
|
295
|
+
headStyle: { width: "120px" }
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
id: 3,
|
|
299
|
+
name: t("banners:priority"),
|
|
300
|
+
field: "priority",
|
|
301
|
+
style: { width: "100px", textAlign: "center" },
|
|
302
|
+
headStyle: { width: "100px", textAlign: "center" }
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
id: 4,
|
|
306
|
+
name: t("banners:period"),
|
|
307
|
+
field: "dateStart",
|
|
308
|
+
format: ({ row }) => `${row.dateStart ? `${t("banners:from")} ${row.dateStart}` : ""} ${row.dateEnd ? `${t("banners:to")} ${row.dateEnd}` : ""}`
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
id: 5,
|
|
312
|
+
name: t("banners:image"),
|
|
313
|
+
field: "image",
|
|
314
|
+
type: "image"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
id: 6,
|
|
318
|
+
name: t("banners:link"),
|
|
319
|
+
field: "link",
|
|
320
|
+
type: "name",
|
|
321
|
+
format: ({ row }) => {
|
|
322
|
+
var _a, _b;
|
|
323
|
+
return {
|
|
324
|
+
adminLink: {
|
|
325
|
+
url: (_a = row.link) != null ? _a : "",
|
|
326
|
+
text: (_b = row.link) != null ? _b : ""
|
|
327
|
+
},
|
|
328
|
+
paramList: [
|
|
329
|
+
{
|
|
330
|
+
name: t("banners:newTab"),
|
|
331
|
+
value: row.openNewTab ? t("banners:yes") : t("banners:no")
|
|
332
|
+
}
|
|
333
|
+
]
|
|
334
|
+
};
|
|
335
|
+
},
|
|
336
|
+
options: {
|
|
337
|
+
shouldOpenNewTab: true
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
id: 7,
|
|
342
|
+
name: t("banners:comment"),
|
|
343
|
+
field: "comment"
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
id: 8,
|
|
347
|
+
name: t("banners:actions"),
|
|
348
|
+
field: "actions",
|
|
349
|
+
style: { whiteSpace: "nowrap", width: "100px" },
|
|
350
|
+
headStyle: { whiteSpace: "nowrap", width: "100px" }
|
|
351
|
+
}
|
|
352
|
+
];
|
|
353
|
+
}
|
|
354
|
+
function useAdvancedSearch({
|
|
355
|
+
context,
|
|
356
|
+
t,
|
|
357
|
+
zoneList,
|
|
358
|
+
route
|
|
359
|
+
}) {
|
|
360
|
+
const zonesOptionList = computed(
|
|
361
|
+
() => zoneList.value.map(({ id, name }) => ({
|
|
362
|
+
value: id,
|
|
363
|
+
label: name
|
|
364
|
+
}))
|
|
365
|
+
);
|
|
366
|
+
const initialZoneFilter = computed(() => {
|
|
367
|
+
const queryValue = getFilterParamAsStringArray(
|
|
368
|
+
route.query,
|
|
369
|
+
"zone"
|
|
370
|
+
);
|
|
371
|
+
return zonesOptionList.value.filter(
|
|
372
|
+
({ value }) => queryValue.some((selected) => selected === value)
|
|
373
|
+
);
|
|
374
|
+
});
|
|
375
|
+
const zoneFilter = ref(initialZoneFilter.value);
|
|
376
|
+
watch(initialZoneFilter, () => {
|
|
377
|
+
zoneFilter.value = initialZoneFilter.value;
|
|
378
|
+
});
|
|
379
|
+
const initialDateFilter = computed(
|
|
380
|
+
() => {
|
|
381
|
+
var _a;
|
|
382
|
+
return (_a = getFilterParamAsString(route.query, "date")) != null ? _a : "";
|
|
383
|
+
}
|
|
384
|
+
);
|
|
385
|
+
const dateFilter = ref(initialDateFilter.value);
|
|
386
|
+
watch(initialDateFilter, () => {
|
|
387
|
+
dateFilter.value = initialDateFilter.value;
|
|
388
|
+
});
|
|
389
|
+
const statusesOptionList = computed(
|
|
390
|
+
() => Object.entries(Status).map(([_, value]) => ({
|
|
391
|
+
value,
|
|
392
|
+
label: getStatus(value, t)
|
|
393
|
+
}))
|
|
394
|
+
);
|
|
395
|
+
const initialStatusFilter = computed(() => {
|
|
396
|
+
const queryValue = getFilterParamAsStringArray(
|
|
397
|
+
route.query,
|
|
398
|
+
"status"
|
|
399
|
+
);
|
|
400
|
+
return statusesOptionList.value.filter(
|
|
401
|
+
({ value }) => queryValue.some((selected) => selected === value)
|
|
402
|
+
);
|
|
403
|
+
});
|
|
404
|
+
const statusFilter = ref(initialStatusFilter.value);
|
|
405
|
+
watch(initialStatusFilter, () => {
|
|
406
|
+
statusFilter.value = initialStatusFilter.value;
|
|
407
|
+
});
|
|
408
|
+
const filterParams = computed(
|
|
409
|
+
() => getFilterParams({
|
|
410
|
+
["zone"]: zoneFilter.value.map(({ value }) => value),
|
|
411
|
+
["date"]: dateFilter.value || [],
|
|
412
|
+
["status"]: statusFilter.value.map(({ value }) => value)
|
|
413
|
+
})
|
|
414
|
+
);
|
|
415
|
+
const tagRemovalHandler = (event) => {
|
|
416
|
+
if (event.name === "zone") {
|
|
417
|
+
zoneFilter.value = zoneFilter.value.filter(
|
|
418
|
+
({ value }) => value !== event.value
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
if (event.name === "date") {
|
|
422
|
+
dateFilter.value = "";
|
|
423
|
+
}
|
|
424
|
+
if (event.name === "status") {
|
|
425
|
+
statusFilter.value = statusFilter.value.filter(
|
|
426
|
+
({ value }) => value !== event.value
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
const tags = computed(() => []);
|
|
431
|
+
return {
|
|
432
|
+
zoneFilter,
|
|
433
|
+
zonesOptionList,
|
|
434
|
+
dateFilter,
|
|
435
|
+
statusFilter,
|
|
436
|
+
statusesOptionList,
|
|
437
|
+
filterParams,
|
|
438
|
+
tags,
|
|
439
|
+
tagRemovalHandler
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
var BannerList_vue_vue_type_style_index_0_lang = "";
|
|
443
|
+
const _sfc_main$1 = defineComponent({
|
|
444
|
+
name: "BannerList",
|
|
445
|
+
components: {
|
|
446
|
+
DeleteIcon,
|
|
447
|
+
EditIcon,
|
|
448
|
+
BaseButton,
|
|
449
|
+
FormField,
|
|
450
|
+
FormFieldMultiSelect,
|
|
451
|
+
AdvancedSearch,
|
|
452
|
+
Page,
|
|
453
|
+
DataTable
|
|
454
|
+
},
|
|
455
|
+
setup(props, context) {
|
|
456
|
+
const route = useRoute();
|
|
457
|
+
const router = useRouter();
|
|
458
|
+
const { t } = useI18n();
|
|
459
|
+
const { loading: isZonesLoading, data: zoneList } = useFetchZones();
|
|
460
|
+
const {
|
|
461
|
+
zoneFilter,
|
|
462
|
+
zonesOptionList,
|
|
463
|
+
dateFilter,
|
|
464
|
+
statusFilter,
|
|
465
|
+
statusesOptionList,
|
|
466
|
+
filterParams,
|
|
467
|
+
tags,
|
|
468
|
+
tagRemovalHandler
|
|
469
|
+
} = useAdvancedSearch({
|
|
470
|
+
context,
|
|
471
|
+
t,
|
|
472
|
+
zoneList,
|
|
473
|
+
route
|
|
474
|
+
});
|
|
475
|
+
const {
|
|
476
|
+
fetchEntityList: fetchBanners,
|
|
477
|
+
isLoading: isBannersLoading,
|
|
478
|
+
rowData,
|
|
479
|
+
errorMessage,
|
|
480
|
+
handleChange,
|
|
481
|
+
searchQuery,
|
|
482
|
+
pageNumber,
|
|
483
|
+
pageCount,
|
|
484
|
+
pageSize
|
|
485
|
+
} = useDataTable({
|
|
486
|
+
fetchEntityList: (params) => getBanners({
|
|
487
|
+
query: params.searchQuery,
|
|
488
|
+
pageNumber: params.pageNumber,
|
|
489
|
+
pageSize: params.pageSize,
|
|
490
|
+
...filterParams.value
|
|
491
|
+
}),
|
|
492
|
+
initialValue: [],
|
|
493
|
+
resourceName: "Banners"
|
|
494
|
+
});
|
|
495
|
+
watch(filterParams, () => {
|
|
496
|
+
if (isZonesLoading.value) {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
const newQuery = {
|
|
500
|
+
...pick(route.query, ["query", "pageNumber"]),
|
|
501
|
+
...filterParams.value
|
|
502
|
+
};
|
|
503
|
+
if (!isEqual(route.query, newQuery)) {
|
|
504
|
+
router.replace({ query: newQuery });
|
|
505
|
+
fetchBanners();
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
const { isDeleting, handleResourceDelete } = useResourceDelete({
|
|
509
|
+
deleteResource: deleteBanner,
|
|
510
|
+
resourceName: "Banner",
|
|
511
|
+
onSuccess: fetchBanners
|
|
512
|
+
});
|
|
513
|
+
const isBusy = (bannerId) => {
|
|
514
|
+
return isDeleting(bannerId) || isBannersLoading.value;
|
|
515
|
+
};
|
|
516
|
+
const columnDefs = computed(
|
|
517
|
+
() => getColumnDefs(zoneList.value, t)
|
|
518
|
+
);
|
|
519
|
+
const isRowDataLoading = computed(
|
|
520
|
+
() => isBannersLoading.value || isZonesLoading.value
|
|
521
|
+
);
|
|
522
|
+
return {
|
|
523
|
+
columnDefs,
|
|
524
|
+
isRowDataLoading,
|
|
525
|
+
rowData,
|
|
526
|
+
errorMessage,
|
|
527
|
+
handleChange,
|
|
528
|
+
getBannersBannerFormUrl,
|
|
529
|
+
searchQuery,
|
|
530
|
+
pageNumber,
|
|
531
|
+
pageCount,
|
|
532
|
+
pageSize,
|
|
533
|
+
isBusy,
|
|
534
|
+
handleResourceDelete,
|
|
535
|
+
zoneFilter,
|
|
536
|
+
zonesOptionList,
|
|
537
|
+
dateFilter,
|
|
538
|
+
statusFilter,
|
|
539
|
+
statusesOptionList,
|
|
540
|
+
tags,
|
|
541
|
+
tagRemovalHandler
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
const _hoisted_1$1 = { class: "filters" };
|
|
546
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
547
|
+
const _component_FormFieldMultiSelect = resolveComponent("FormFieldMultiSelect");
|
|
548
|
+
const _component_FormField = resolveComponent("FormField");
|
|
549
|
+
const _component_AdvancedSearch = resolveComponent("AdvancedSearch");
|
|
550
|
+
const _component_EditIcon = resolveComponent("EditIcon");
|
|
551
|
+
const _component_BaseButton = resolveComponent("BaseButton");
|
|
552
|
+
const _component_DeleteIcon = resolveComponent("DeleteIcon");
|
|
553
|
+
const _component_DataTable = resolveComponent("DataTable");
|
|
554
|
+
const _component_Page = resolveComponent("Page");
|
|
555
|
+
return openBlock(), createBlock(_component_Page, {
|
|
556
|
+
title: _ctx.$i18n.t("banners:banners"),
|
|
557
|
+
"header-buttons": [
|
|
558
|
+
{
|
|
559
|
+
text: _ctx.$i18n.t("banners:createBanner"),
|
|
560
|
+
href: _ctx.getBannersBannerFormUrl({ bannerId: "create" })
|
|
561
|
+
}
|
|
562
|
+
]
|
|
563
|
+
}, {
|
|
564
|
+
content: withCtx(() => [
|
|
565
|
+
createVNode(_component_DataTable, {
|
|
566
|
+
"column-defs": _ctx.columnDefs,
|
|
567
|
+
"row-data": _ctx.rowData,
|
|
568
|
+
loading: _ctx.isRowDataLoading,
|
|
569
|
+
"error-message": _ctx.errorMessage,
|
|
570
|
+
"data-table": "banners",
|
|
571
|
+
"use-search": true,
|
|
572
|
+
"use-pagination": true,
|
|
573
|
+
"search-query": _ctx.searchQuery,
|
|
574
|
+
pagination: {
|
|
575
|
+
pageNumber: _ctx.pageNumber,
|
|
576
|
+
pageCount: _ctx.pageCount,
|
|
577
|
+
pageSize: _ctx.pageSize,
|
|
578
|
+
disabled: _ctx.isRowDataLoading
|
|
579
|
+
},
|
|
580
|
+
onChange: _ctx.handleChange
|
|
581
|
+
}, {
|
|
582
|
+
filters: withCtx(() => [
|
|
583
|
+
createVNode(_component_AdvancedSearch, {
|
|
584
|
+
tags: _ctx.tags,
|
|
585
|
+
"onClick:tag": _ctx.tagRemovalHandler
|
|
586
|
+
}, {
|
|
587
|
+
default: withCtx(() => [
|
|
588
|
+
createElementVNode("div", _hoisted_1$1, [
|
|
589
|
+
createVNode(_component_FormFieldMultiSelect, {
|
|
590
|
+
"selected-options": _ctx.zoneFilter,
|
|
591
|
+
"onUpdate:selected-options": _cache[0] || (_cache[0] = ($event) => _ctx.zoneFilter = $event),
|
|
592
|
+
options: _ctx.zonesOptionList,
|
|
593
|
+
name: "zoneFilter",
|
|
594
|
+
searchable: true,
|
|
595
|
+
label: _ctx.$i18n.t("banners:zone"),
|
|
596
|
+
class: "filter"
|
|
597
|
+
}, null, 8, ["selected-options", "options", "label"]),
|
|
598
|
+
createVNode(_component_FormField, {
|
|
599
|
+
value: _ctx.dateFilter,
|
|
600
|
+
"onUpdate:value": _cache[1] || (_cache[1] = ($event) => _ctx.dateFilter = $event),
|
|
601
|
+
label: _ctx.$i18n.t("banners:date"),
|
|
602
|
+
name: "dateFilter",
|
|
603
|
+
type: "date",
|
|
604
|
+
class: "filter"
|
|
605
|
+
}, null, 8, ["value", "label"]),
|
|
606
|
+
createVNode(_component_FormFieldMultiSelect, {
|
|
607
|
+
"selected-options": _ctx.statusFilter,
|
|
608
|
+
"onUpdate:selected-options": _cache[2] || (_cache[2] = ($event) => _ctx.statusFilter = $event),
|
|
609
|
+
options: _ctx.statusesOptionList,
|
|
610
|
+
name: "statusFilter",
|
|
611
|
+
searchable: true,
|
|
612
|
+
label: _ctx.$i18n.t("banners:status"),
|
|
613
|
+
class: "filter"
|
|
614
|
+
}, null, 8, ["selected-options", "options", "label"])
|
|
615
|
+
])
|
|
616
|
+
]),
|
|
617
|
+
_: 1
|
|
618
|
+
}, 8, ["tags", "onClick:tag"])
|
|
619
|
+
]),
|
|
620
|
+
"cell(actions)": withCtx(({ row }) => [
|
|
621
|
+
createVNode(_component_BaseButton, {
|
|
622
|
+
variant: "icon",
|
|
623
|
+
title: _ctx.$i18n.t("banners:edit"),
|
|
624
|
+
disabled: _ctx.isBusy(row.id),
|
|
625
|
+
href: _ctx.getBannersBannerFormUrl({ bannerId: row.id })
|
|
626
|
+
}, {
|
|
627
|
+
default: withCtx(() => [
|
|
628
|
+
createVNode(_component_EditIcon)
|
|
629
|
+
]),
|
|
630
|
+
_: 2
|
|
631
|
+
}, 1032, ["title", "disabled", "href"]),
|
|
632
|
+
createVNode(_component_BaseButton, {
|
|
633
|
+
variant: "icon",
|
|
634
|
+
title: _ctx.$i18n.t("banners:remove"),
|
|
635
|
+
disabled: _ctx.isBusy(row.id),
|
|
636
|
+
onClick: ($event) => _ctx.handleResourceDelete(row.id)
|
|
637
|
+
}, {
|
|
638
|
+
default: withCtx(() => [
|
|
639
|
+
createVNode(_component_DeleteIcon)
|
|
640
|
+
]),
|
|
641
|
+
_: 2
|
|
642
|
+
}, 1032, ["title", "disabled", "onClick"])
|
|
643
|
+
]),
|
|
644
|
+
_: 1
|
|
645
|
+
}, 8, ["column-defs", "row-data", "loading", "error-message", "search-query", "pagination", "onChange"])
|
|
646
|
+
]),
|
|
647
|
+
_: 1
|
|
648
|
+
}, 8, ["title", "header-buttons"]);
|
|
649
|
+
}
|
|
650
|
+
var BannerList = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
651
|
+
function useFetchBanner({
|
|
652
|
+
bannerId,
|
|
653
|
+
isCreation
|
|
654
|
+
}) {
|
|
655
|
+
const [fetchBanner, resource] = useResource({
|
|
656
|
+
fetchResource: () => getBanner(bannerId.value),
|
|
657
|
+
initialValue: null,
|
|
658
|
+
resourceName: "Banner"
|
|
659
|
+
});
|
|
660
|
+
onMounted(() => {
|
|
661
|
+
if (isCreation.value || !bannerId.value) {
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
fetchBanner();
|
|
665
|
+
});
|
|
666
|
+
watch(bannerId, () => {
|
|
667
|
+
if (isCreation.value || !bannerId.value) {
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
fetchBanner();
|
|
671
|
+
});
|
|
672
|
+
return resource;
|
|
673
|
+
}
|
|
674
|
+
function useFetchZoneFields({
|
|
675
|
+
values
|
|
676
|
+
}) {
|
|
677
|
+
const zoneId = computed(() => {
|
|
678
|
+
var _a, _b;
|
|
679
|
+
return (_b = (_a = values.value.bannerZone) == null ? void 0 : _a.value) != null ? _b : "";
|
|
680
|
+
});
|
|
681
|
+
const [fetchZoneFields, resource] = useResource({
|
|
682
|
+
fetchResource: () => getZoneFields(zoneId.value),
|
|
683
|
+
initialValue: null,
|
|
684
|
+
resourceName: "Zone Fields"
|
|
685
|
+
});
|
|
686
|
+
onMounted(() => {
|
|
687
|
+
if (!zoneId.value) {
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
fetchZoneFields();
|
|
691
|
+
});
|
|
692
|
+
watch(zoneId, () => {
|
|
693
|
+
if (!zoneId.value) {
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
fetchZoneFields();
|
|
697
|
+
});
|
|
698
|
+
return resource;
|
|
699
|
+
}
|
|
700
|
+
function convertBannerToFormValues(banner, zonesOptionList) {
|
|
701
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
702
|
+
const foundZone = zonesOptionList.find(
|
|
703
|
+
({ value }) => value === (banner == null ? void 0 : banner.bannerZone)
|
|
704
|
+
);
|
|
705
|
+
return {
|
|
706
|
+
priority: String((_a = banner == null ? void 0 : banner.priority) != null ? _a : 1),
|
|
707
|
+
link: (_b = banner == null ? void 0 : banner.link) != null ? _b : "",
|
|
708
|
+
image: (banner == null ? void 0 : banner.image) ? { id: createId(), file: banner.image } : null,
|
|
709
|
+
bannerZone: foundZone != null ? foundZone : null,
|
|
710
|
+
openNewTab: (_c = banner == null ? void 0 : banner.openNewTab) != null ? _c : false,
|
|
711
|
+
dateStart: (_d = banner == null ? void 0 : banner.dateStart) != null ? _d : "",
|
|
712
|
+
dateEnd: (_e = banner == null ? void 0 : banner.dateEnd) != null ? _e : "",
|
|
713
|
+
disabled: (_f = banner == null ? void 0 : banner.disabled) != null ? _f : false,
|
|
714
|
+
comment: (_g = banner == null ? void 0 : banner.comment) != null ? _g : "",
|
|
715
|
+
fields: []
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
function convertBannerFormValuesToPayload(values) {
|
|
719
|
+
var _a, _b, _c, _d;
|
|
720
|
+
return {
|
|
721
|
+
...values,
|
|
722
|
+
priority: values.priority ? Number(values.priority) : 1,
|
|
723
|
+
dateStart: values.dateStart ? values.dateStart : null,
|
|
724
|
+
dateEnd: values.dateEnd ? values.dateEnd : null,
|
|
725
|
+
image: (_b = (_a = values.image) == null ? void 0 : _a.file.id) != null ? _b : null,
|
|
726
|
+
bannerZone: (_d = (_c = values.bannerZone) == null ? void 0 : _c.value) != null ? _d : "",
|
|
727
|
+
fields: values.fields.map((field) => ({
|
|
728
|
+
name: field.config.name,
|
|
729
|
+
value: universalFieldUtils.getOutgoingValue(field)
|
|
730
|
+
}))
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
var BannerForm_vue_vue_type_style_index_0_lang = "";
|
|
734
|
+
const _sfc_main = defineComponent({
|
|
735
|
+
name: "BannerForm",
|
|
736
|
+
components: {
|
|
737
|
+
FormFieldFileInput,
|
|
738
|
+
FormFieldCheckbox,
|
|
739
|
+
InputLabel,
|
|
740
|
+
FormField,
|
|
741
|
+
FormFieldSelect,
|
|
742
|
+
Page,
|
|
743
|
+
FormFooter,
|
|
744
|
+
DynamicField
|
|
745
|
+
},
|
|
746
|
+
setup() {
|
|
747
|
+
const route = useRoute();
|
|
748
|
+
const router = useRouter();
|
|
749
|
+
const toast = useToast();
|
|
750
|
+
const { t } = useI18n();
|
|
751
|
+
const bannerId = computed(() => route.params.bannerId);
|
|
752
|
+
const isCreation = computed(() => bannerId.value === "create");
|
|
753
|
+
const { data: zones, loading: isZonesLoading } = useFetchZones();
|
|
754
|
+
const zonesOptionList = computed(
|
|
755
|
+
() => zones.value.map((zone) => ({
|
|
756
|
+
value: zone.id,
|
|
757
|
+
label: zone.name
|
|
758
|
+
}))
|
|
759
|
+
);
|
|
760
|
+
const { data: banner, loading: isBannerLoading } = useFetchBanner({
|
|
761
|
+
bannerId,
|
|
762
|
+
isCreation
|
|
763
|
+
});
|
|
764
|
+
const isSubmitting = ref(false);
|
|
765
|
+
const values = ref(
|
|
766
|
+
convertBannerToFormValues(banner.value, zonesOptionList.value)
|
|
767
|
+
);
|
|
768
|
+
const errors = ref({});
|
|
769
|
+
watch([banner, zones], () => {
|
|
770
|
+
values.value = convertBannerToFormValues(
|
|
771
|
+
banner.value,
|
|
772
|
+
zonesOptionList.value
|
|
773
|
+
);
|
|
774
|
+
});
|
|
775
|
+
const { loading: isZoneFieldsLoading, data: zoneFields } = useFetchZoneFields({ values });
|
|
776
|
+
watch(zoneFields, () => {
|
|
777
|
+
var _a, _b;
|
|
778
|
+
values.value.fields = ((_b = (_a = zoneFields.value) == null ? void 0 : _a.fields) != null ? _b : []).map(
|
|
779
|
+
(fieldConfig, index) => {
|
|
780
|
+
var _a2;
|
|
781
|
+
return universalFieldUtils.createFormField(
|
|
782
|
+
fieldConfig,
|
|
783
|
+
banner.value ? (_a2 = banner.value.fields[index].value) != null ? _a2 : null : null
|
|
784
|
+
);
|
|
785
|
+
}
|
|
786
|
+
);
|
|
787
|
+
});
|
|
788
|
+
const submitForm = (event) => {
|
|
789
|
+
isSubmitting.value = true;
|
|
790
|
+
const body = convertBannerFormValuesToPayload(values.value);
|
|
791
|
+
const requestPromise = isCreation.value ? createBanner(body) : updateBanner(bannerId.value, body);
|
|
792
|
+
requestPromise.then(({ data }) => {
|
|
793
|
+
errors.value = {};
|
|
794
|
+
if (event.type === "create") {
|
|
795
|
+
router.push(getBannersBannerFormUrl({ bannerId: String(data.id) }));
|
|
796
|
+
} else if (event.type === "create_exit" || event.type === "save_exit") {
|
|
797
|
+
navigateBack(router, getBannersBannerListUrl());
|
|
798
|
+
} else if (event.type === "create_create-another") {
|
|
799
|
+
values.value = convertBannerToFormValues(
|
|
800
|
+
null,
|
|
801
|
+
zonesOptionList.value
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
toast.show({
|
|
805
|
+
variant: "success",
|
|
806
|
+
title: t("banners:success"),
|
|
807
|
+
body: isCreation.value ? t("banners:bannerWasSuccessfullyCreated") : t("banners:bannerWasSuccessfullyUpdated")
|
|
808
|
+
});
|
|
809
|
+
}).catch((error) => {
|
|
810
|
+
console.error(error);
|
|
811
|
+
errors.value = convertRequestErrorToMap(error);
|
|
812
|
+
toast.show({
|
|
813
|
+
variant: "danger",
|
|
814
|
+
title: t("banners:error"),
|
|
815
|
+
body: isCreation.value ? t("banners:bannerCreationWasFailed") : t("banners:bannerUpdateWasFailed")
|
|
816
|
+
});
|
|
817
|
+
}).finally(() => {
|
|
818
|
+
isSubmitting.value = false;
|
|
819
|
+
});
|
|
820
|
+
};
|
|
821
|
+
const isContentLoading = computed(
|
|
822
|
+
() => isBannerLoading.value || isZonesLoading.value || isZoneFieldsLoading.value
|
|
823
|
+
);
|
|
824
|
+
return {
|
|
825
|
+
isCreation,
|
|
826
|
+
isContentLoading,
|
|
827
|
+
isSubmitting,
|
|
828
|
+
values,
|
|
829
|
+
errors,
|
|
830
|
+
submitForm,
|
|
831
|
+
bannerListUrl: getBannersBannerListUrl(),
|
|
832
|
+
zonesOptionList
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
});
|
|
836
|
+
const _hoisted_1 = { class: "zone" };
|
|
837
|
+
const _hoisted_2 = { class: "date" };
|
|
838
|
+
const _hoisted_3 = { class: "link" };
|
|
839
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
840
|
+
const _component_FormFieldSelect = resolveComponent("FormFieldSelect");
|
|
841
|
+
const _component_FormField = resolveComponent("FormField");
|
|
842
|
+
const _component_InputLabel = resolveComponent("InputLabel");
|
|
843
|
+
const _component_FormFieldCheckbox = resolveComponent("FormFieldCheckbox");
|
|
844
|
+
const _component_FormFieldFileInput = resolveComponent("FormFieldFileInput");
|
|
845
|
+
const _component_DynamicField = resolveComponent("DynamicField");
|
|
846
|
+
const _component_FormFooter = resolveComponent("FormFooter");
|
|
847
|
+
const _component_Page = resolveComponent("Page");
|
|
848
|
+
return openBlock(), createBlock(_component_Page, {
|
|
849
|
+
title: _ctx.isCreation ? _ctx.$i18n.t("banners:createBanner") : _ctx.$i18n.t("banners:updateBanner"),
|
|
850
|
+
"is-content-loading": _ctx.isContentLoading
|
|
851
|
+
}, {
|
|
852
|
+
content: withCtx(() => [
|
|
853
|
+
createElementVNode("form", {
|
|
854
|
+
novalidate: "",
|
|
855
|
+
onSubmit: _cache[9] || (_cache[9] = withModifiers((...args) => _ctx.submitForm && _ctx.submitForm(...args), ["prevent"]))
|
|
856
|
+
}, [
|
|
857
|
+
createElementVNode("div", _hoisted_1, [
|
|
858
|
+
createVNode(_component_FormFieldSelect, {
|
|
859
|
+
value: _ctx.values.bannerZone,
|
|
860
|
+
"onUpdate:value": _cache[0] || (_cache[0] = ($event) => _ctx.values.bannerZone = $event),
|
|
861
|
+
name: "bannerZone",
|
|
862
|
+
label: _ctx.$i18n.t("banners:zone"),
|
|
863
|
+
options: _ctx.zonesOptionList,
|
|
864
|
+
error: _ctx.errors.bannerZone
|
|
865
|
+
}, null, 8, ["value", "label", "options", "error"]),
|
|
866
|
+
createVNode(_component_FormField, {
|
|
867
|
+
value: _ctx.values.priority,
|
|
868
|
+
"onUpdate:value": _cache[1] || (_cache[1] = ($event) => _ctx.values.priority = $event),
|
|
869
|
+
name: "priority",
|
|
870
|
+
label: _ctx.$i18n.t("banners:priority"),
|
|
871
|
+
error: _ctx.errors.priority
|
|
872
|
+
}, null, 8, ["value", "label", "error"])
|
|
873
|
+
]),
|
|
874
|
+
createVNode(_component_InputLabel, null, {
|
|
875
|
+
default: withCtx(() => [
|
|
876
|
+
createTextVNode(toDisplayString(_ctx.$i18n.t("banners:period")), 1)
|
|
877
|
+
]),
|
|
878
|
+
_: 1
|
|
879
|
+
}),
|
|
880
|
+
createElementVNode("div", _hoisted_2, [
|
|
881
|
+
createVNode(_component_FormField, {
|
|
882
|
+
value: _ctx.values.dateStart,
|
|
883
|
+
"onUpdate:value": _cache[2] || (_cache[2] = ($event) => _ctx.values.dateStart = $event),
|
|
884
|
+
label: _ctx.$i18n.t("banners:from"),
|
|
885
|
+
name: "dateStart",
|
|
886
|
+
type: "date",
|
|
887
|
+
max: _ctx.values.dateEnd
|
|
888
|
+
}, null, 8, ["value", "label", "max"]),
|
|
889
|
+
createVNode(_component_FormField, {
|
|
890
|
+
value: _ctx.values.dateEnd,
|
|
891
|
+
"onUpdate:value": _cache[3] || (_cache[3] = ($event) => _ctx.values.dateEnd = $event),
|
|
892
|
+
label: _ctx.$i18n.t("banners:to"),
|
|
893
|
+
name: "dateEnd",
|
|
894
|
+
type: "date",
|
|
895
|
+
min: _ctx.values.dateStart
|
|
896
|
+
}, null, 8, ["value", "label", "min"])
|
|
897
|
+
]),
|
|
898
|
+
createVNode(_component_FormFieldCheckbox, {
|
|
899
|
+
checked: _ctx.values.disabled,
|
|
900
|
+
"onUpdate:checked": _cache[4] || (_cache[4] = ($event) => _ctx.values.disabled = $event),
|
|
901
|
+
name: "disabled",
|
|
902
|
+
label: _ctx.$i18n.t("banners:disabled"),
|
|
903
|
+
error: _ctx.errors.disabled
|
|
904
|
+
}, null, 8, ["checked", "label", "error"]),
|
|
905
|
+
createElementVNode("div", _hoisted_3, [
|
|
906
|
+
createVNode(_component_FormField, {
|
|
907
|
+
value: _ctx.values.link,
|
|
908
|
+
"onUpdate:value": _cache[5] || (_cache[5] = ($event) => _ctx.values.link = $event),
|
|
909
|
+
name: "link",
|
|
910
|
+
label: _ctx.$i18n.t("banners:link"),
|
|
911
|
+
error: _ctx.errors.name
|
|
912
|
+
}, null, 8, ["value", "label", "error"]),
|
|
913
|
+
createVNode(_component_FormFieldCheckbox, {
|
|
914
|
+
checked: _ctx.values.openNewTab,
|
|
915
|
+
"onUpdate:checked": _cache[6] || (_cache[6] = ($event) => _ctx.values.openNewTab = $event),
|
|
916
|
+
name: "openNewTab",
|
|
917
|
+
label: _ctx.$i18n.t("banners:openNewTab"),
|
|
918
|
+
error: _ctx.errors.openNewTab
|
|
919
|
+
}, null, 8, ["checked", "label", "error"])
|
|
920
|
+
]),
|
|
921
|
+
createVNode(_component_FormFieldFileInput, {
|
|
922
|
+
value: _ctx.values.image,
|
|
923
|
+
"onUpdate:value": _cache[7] || (_cache[7] = ($event) => _ctx.values.image = $event),
|
|
924
|
+
name: "image",
|
|
925
|
+
"file-type": "image",
|
|
926
|
+
label: _ctx.$i18n.t("banners:image"),
|
|
927
|
+
error: _ctx.errors.file
|
|
928
|
+
}, null, 8, ["value", "label", "error"]),
|
|
929
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.values.fields, (field) => {
|
|
930
|
+
return openBlock(), createBlock(_component_DynamicField, {
|
|
931
|
+
key: field.name,
|
|
932
|
+
field
|
|
933
|
+
}, null, 8, ["field"]);
|
|
934
|
+
}), 128)),
|
|
935
|
+
createVNode(_component_FormField, {
|
|
936
|
+
value: _ctx.values.comment,
|
|
937
|
+
"onUpdate:value": _cache[8] || (_cache[8] = ($event) => _ctx.values.comment = $event),
|
|
938
|
+
name: "comment",
|
|
939
|
+
type: "textarea",
|
|
940
|
+
label: _ctx.$i18n.t("banners:comment"),
|
|
941
|
+
error: _ctx.errors.comment
|
|
942
|
+
}, null, 8, ["value", "label", "error"])
|
|
943
|
+
], 32)
|
|
944
|
+
]),
|
|
945
|
+
footer: withCtx(() => [
|
|
946
|
+
createVNode(_component_FormFooter, {
|
|
947
|
+
"back-href": _ctx.bannerListUrl,
|
|
948
|
+
"is-submitting": _ctx.isSubmitting,
|
|
949
|
+
"is-creation": _ctx.isCreation,
|
|
950
|
+
"can-create-another": _ctx.isCreation,
|
|
951
|
+
onSubmit: _ctx.submitForm
|
|
952
|
+
}, null, 8, ["back-href", "is-submitting", "is-creation", "can-create-another", "onSubmit"])
|
|
953
|
+
]),
|
|
954
|
+
_: 1
|
|
955
|
+
}, 8, ["title", "is-content-loading"]);
|
|
956
|
+
}
|
|
957
|
+
var BannerForm = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
958
|
+
const BANNERS_ZONE_LIST_ROUTE = {
|
|
959
|
+
path: BANNERS_ROUTE_PATHS.ZONE_LIST,
|
|
960
|
+
component: ZoneList,
|
|
961
|
+
name: "Zones",
|
|
962
|
+
meta: {
|
|
963
|
+
getBreadcrumbs: (route, { t }) => [
|
|
964
|
+
{ url: "/", text: t("banners:home") },
|
|
965
|
+
{ url: BANNERS_ROUTE_PATHS.ZONE_LIST, text: t("banners:zones") }
|
|
966
|
+
]
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
const BANNERS_BANNER_LIST_ROUTE = {
|
|
970
|
+
path: BANNERS_ROUTE_PATHS.BANNER_LIST,
|
|
971
|
+
component: BannerList,
|
|
972
|
+
name: "Banners",
|
|
973
|
+
meta: {
|
|
974
|
+
getBreadcrumbs: (route, { t }) => [
|
|
975
|
+
{ url: "/", text: t("banners:home") },
|
|
976
|
+
{ url: BANNERS_ROUTE_PATHS.BANNER_LIST, text: t("banners:banners") }
|
|
977
|
+
]
|
|
978
|
+
}
|
|
979
|
+
};
|
|
980
|
+
const BANNERS_BANNER_FORM_ROUTE = {
|
|
981
|
+
path: BANNERS_ROUTE_PATHS.BANNER_FORM,
|
|
982
|
+
component: BannerForm,
|
|
983
|
+
name: "Banner Form",
|
|
984
|
+
meta: {
|
|
985
|
+
getBreadcrumbs: (route, { t }) => [
|
|
986
|
+
{ url: "/", text: t("banners:home") },
|
|
987
|
+
{ url: BANNERS_ROUTE_PATHS.BANNER_LIST, text: t("banners:banners") },
|
|
988
|
+
{ url: route.path, text: t("banners:bannerForm") }
|
|
989
|
+
]
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
applyTranslations();
|
|
993
|
+
export { BANNERS_BANNER_FORM_ROUTE, BANNERS_BANNER_LIST_ROUTE, BANNERS_ZONE_LIST_ROUTE, createBanner, deleteBanner, getBanner, getBannerCount, getBanners, getBannersBannerFormUrl, getBannersBannerListUrl, getBannersZoneListUrl, getZoneFields, getZones, updateBanner };
|