@tager/admin-banners 0.2.1 → 0.3.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/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 +3205 -892
- package/dist/index.umd.js +3218 -903
- 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 +19 -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 -9
- 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 +33 -88
- 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
package/dist/index.umd.js
CHANGED
|
@@ -1,181 +1,174 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '
|
|
4
|
-
(global = global || self, factory(global.
|
|
5
|
-
}(this, (function (exports,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tager/admin-services'), require('@vue/composition-api'), require('@tager/admin-ui'), require('path-to-regexp')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@tager/admin-services', '@vue/composition-api', '@tager/admin-ui', 'path-to-regexp'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TagerAdminBanners = {}, global.adminServices, global.compositionApi, global.adminUi, global.pathToRegexp));
|
|
5
|
+
}(this, (function (exports, adminServices, compositionApi, adminUi, pathToRegexp) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const EN = {
|
|
8
|
+
home: 'Home',
|
|
9
|
+
zone: 'Banner zone',
|
|
10
|
+
zones: 'Banner zones',
|
|
11
|
+
banners: 'Banners',
|
|
12
|
+
bannerForm: 'Banner Form',
|
|
13
|
+
createBanner: 'Create Banner',
|
|
14
|
+
updateBanner: 'Update Banner',
|
|
15
|
+
link: 'Link',
|
|
16
|
+
image: 'Image',
|
|
17
|
+
openNewTab: 'Open new tab',
|
|
18
|
+
period: 'Period',
|
|
19
|
+
from: 'From',
|
|
20
|
+
to: 'To',
|
|
21
|
+
disabled: 'Disabled',
|
|
22
|
+
comment: 'Comment',
|
|
23
|
+
status: 'Status',
|
|
24
|
+
bannerZoneIsDeleted: 'Banner zone is deleted',
|
|
25
|
+
newTab: 'New Tab',
|
|
26
|
+
yes: 'Yes',
|
|
27
|
+
no: 'No',
|
|
28
|
+
edit: 'Edit',
|
|
29
|
+
remove: 'Remove',
|
|
30
|
+
actions: 'actions',
|
|
31
|
+
date: 'Date',
|
|
32
|
+
success: 'Success',
|
|
33
|
+
error: 'Error',
|
|
34
|
+
statuses: {
|
|
35
|
+
waiting: 'Waiting',
|
|
36
|
+
archived: 'Archived',
|
|
37
|
+
active: 'Active',
|
|
38
|
+
disabled: 'Disabled',
|
|
39
|
+
},
|
|
40
|
+
bannerWasSuccessfullyCreated: 'Banner was successfully created',
|
|
41
|
+
bannerWasSuccessfullyUpdated: 'Banner was successfully updated',
|
|
42
|
+
bannerCreationWasFailed: 'Banner creation was failed',
|
|
43
|
+
bannerUpdateWasFailed: 'Banner update was failed',
|
|
44
|
+
};
|
|
8
45
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
46
|
+
const RU = {
|
|
47
|
+
home: 'Главная',
|
|
48
|
+
zone: 'Баннерная зона',
|
|
49
|
+
zones: 'Баннерные зоны',
|
|
50
|
+
banners: 'Баннеры',
|
|
51
|
+
bannerForm: 'Форма баннера',
|
|
52
|
+
createBanner: 'Добавить баннер',
|
|
53
|
+
updateBanner: 'Редактировать баннер',
|
|
54
|
+
link: 'Ссылка',
|
|
55
|
+
image: 'Картинка',
|
|
56
|
+
openNewTab: 'Открывать в новой вкладке',
|
|
57
|
+
period: 'Срок действия',
|
|
58
|
+
from: 'От',
|
|
59
|
+
to: 'До',
|
|
60
|
+
disabled: 'Выключен',
|
|
61
|
+
comment: 'Комментарий',
|
|
62
|
+
status: 'Статус',
|
|
63
|
+
bannerZoneIsDeleted: 'Баннерная зона удалена',
|
|
64
|
+
newTab: 'Новая вкладка',
|
|
65
|
+
yes: 'Да',
|
|
66
|
+
no: 'Нет',
|
|
67
|
+
edit: 'Редактировать',
|
|
68
|
+
remove: 'Удалить',
|
|
69
|
+
actions: 'Действия',
|
|
70
|
+
date: 'Дата',
|
|
71
|
+
success: 'Успех',
|
|
72
|
+
error: 'Ошибка',
|
|
73
|
+
statuses: {
|
|
74
|
+
waiting: 'В ожидании',
|
|
75
|
+
archived: 'Архивный',
|
|
76
|
+
active: 'Активный',
|
|
77
|
+
disabled: 'Отключен',
|
|
78
|
+
},
|
|
79
|
+
bannerWasSuccessfullyCreated: 'Баннер успешно создан',
|
|
80
|
+
bannerWasSuccessfullyUpdated: 'Баннер успешно обновлен',
|
|
81
|
+
bannerCreationWasFailed: 'Не удалось создать баннер',
|
|
82
|
+
bannerUpdateWasFailed: 'Не удалось обновить баннер',
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/** Zones **/
|
|
86
|
+
function getZones(params) {
|
|
87
|
+
return adminServices.request.get({ path: '/admin/adv/zones', params });
|
|
27
88
|
}
|
|
28
|
-
/** Banners
|
|
29
|
-
function
|
|
30
|
-
return adminServices.request.get({ path:
|
|
89
|
+
/** Banners **/
|
|
90
|
+
function getBanners(params) {
|
|
91
|
+
return adminServices.request.get({ path: '/admin/adv', params });
|
|
31
92
|
}
|
|
32
|
-
function
|
|
33
|
-
return adminServices.request.get({ path: `/admin/
|
|
93
|
+
function getBanner(bannerId) {
|
|
94
|
+
return adminServices.request.get({ path: `/admin/adv/${bannerId}` });
|
|
34
95
|
}
|
|
35
|
-
function
|
|
36
|
-
return adminServices.request.post({
|
|
37
|
-
path: `/admin/market-boards/${areaId}/items`,
|
|
38
|
-
body: payload,
|
|
39
|
-
});
|
|
96
|
+
function createBanner(payload) {
|
|
97
|
+
return adminServices.request.post({ path: '/admin/adv', body: payload });
|
|
40
98
|
}
|
|
41
|
-
function
|
|
99
|
+
function updateBanner(bannerId, payload) {
|
|
42
100
|
return adminServices.request.put({
|
|
43
|
-
path: `/admin/
|
|
101
|
+
path: `/admin/adv/${bannerId}`,
|
|
44
102
|
body: payload,
|
|
45
103
|
});
|
|
46
104
|
}
|
|
47
|
-
function
|
|
48
|
-
return adminServices.request.delete({ path: `/admin/
|
|
49
|
-
}
|
|
50
|
-
function moveBannerItem(bannerItemId, direction) {
|
|
51
|
-
return adminServices.request.post({
|
|
52
|
-
path: `/admin/market-boards/items/${bannerItemId}/${direction}`,
|
|
53
|
-
});
|
|
105
|
+
function deleteBanner(bannerId) {
|
|
106
|
+
return adminServices.request.delete({ path: `/admin/banners/${bannerId}` });
|
|
54
107
|
}
|
|
55
108
|
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
ITEM_FORM: '/banners/:areaAlias/items/:itemId',
|
|
109
|
+
const BANNERS_ROUTE_PATHS = {
|
|
110
|
+
ZONE_LIST: '/banners/zones',
|
|
111
|
+
BANNER_LIST: '/banners',
|
|
112
|
+
BANNER_FORM: '/banners/:bannerId',
|
|
61
113
|
};
|
|
62
|
-
function
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
function getBannerAreaFormUrl(params) {
|
|
66
|
-
return pathToRegexp.compile(BANNER_ROUTE_PATHS.AREA_FORM)({
|
|
67
|
-
areaId: params.areaId,
|
|
68
|
-
});
|
|
114
|
+
function getBannersZoneListUrl() {
|
|
115
|
+
return BANNERS_ROUTE_PATHS.ZONE_LIST;
|
|
69
116
|
}
|
|
70
|
-
function
|
|
71
|
-
return
|
|
72
|
-
areaAlias: params.areaAlias,
|
|
73
|
-
});
|
|
117
|
+
function getBannersBannerListUrl() {
|
|
118
|
+
return BANNERS_ROUTE_PATHS.BANNER_LIST;
|
|
74
119
|
}
|
|
75
|
-
function
|
|
76
|
-
return pathToRegexp.compile(
|
|
77
|
-
areaAlias: params.areaAlias,
|
|
78
|
-
itemId: params.itemId,
|
|
79
|
-
});
|
|
120
|
+
function getBannersBannerFormUrl(params) {
|
|
121
|
+
return pathToRegexp.compile(BANNERS_ROUTE_PATHS.BANNER_FORM)(params);
|
|
80
122
|
}
|
|
81
123
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
{ id: 2, name: 'Alias', field: 'alias' },
|
|
91
|
-
{ id: 3, name: 'Label', field: 'label' },
|
|
92
|
-
{ id: 4, name: 'Scenario', field: 'scenario' },
|
|
93
|
-
{
|
|
94
|
-
id: 6,
|
|
95
|
-
name: 'Banner Items',
|
|
96
|
-
field: 'linkToBannerItems',
|
|
97
|
-
style: { whiteSpace: 'nowrap', width: '120px', textAlign: 'center' },
|
|
98
|
-
headStyle: { whiteSpace: 'nowrap', width: '120px', textAlign: 'center' },
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
id: 8,
|
|
102
|
-
name: 'Actions',
|
|
103
|
-
field: 'actions',
|
|
104
|
-
style: { whiteSpace: 'nowrap', width: '110px', textAlign: 'center' },
|
|
105
|
-
headStyle: { whiteSpace: 'nowrap', width: '110px', textAlign: 'center' },
|
|
106
|
-
},
|
|
107
|
-
];
|
|
108
|
-
var script = Vue.extend({
|
|
109
|
-
name: 'BannerAreaList',
|
|
110
|
-
data() {
|
|
111
|
-
return {
|
|
112
|
-
columnDefs: COLUMN_DEFS,
|
|
113
|
-
rowData: [],
|
|
114
|
-
deletingBannerAreaIdList: [],
|
|
115
|
-
isRowDataLoading: false,
|
|
116
|
-
errorMessage: null,
|
|
117
|
-
};
|
|
118
|
-
},
|
|
119
|
-
mounted() {
|
|
120
|
-
this.refreshBannerAreaList();
|
|
121
|
-
},
|
|
122
|
-
methods: {
|
|
123
|
-
getBannerAreaUrl(areaId) {
|
|
124
|
-
return getBannerAreaFormUrl({ areaId });
|
|
125
|
-
},
|
|
126
|
-
refreshBannerAreaList() {
|
|
127
|
-
this.isRowDataLoading = true;
|
|
128
|
-
return getBannerAreaList()
|
|
129
|
-
.then((response) => {
|
|
130
|
-
this.rowData = response.data;
|
|
131
|
-
this.errorMessage = null;
|
|
132
|
-
})
|
|
133
|
-
.catch((error) => {
|
|
134
|
-
console.error(error);
|
|
135
|
-
this.rowData = [];
|
|
136
|
-
this.errorMessage = adminServices.getMessageFromError(error);
|
|
137
|
-
})
|
|
138
|
-
.finally(() => {
|
|
139
|
-
this.isRowDataLoading = false;
|
|
140
|
-
});
|
|
124
|
+
function getColumnDefs(t) {
|
|
125
|
+
return [
|
|
126
|
+
{
|
|
127
|
+
id: 0,
|
|
128
|
+
name: 'ID',
|
|
129
|
+
field: 'id',
|
|
130
|
+
style: { width: '50px', textAlign: 'center' },
|
|
131
|
+
headStyle: { width: '50px', textAlign: 'center' },
|
|
141
132
|
},
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
deleteBannerArea(bannerArea.id)
|
|
148
|
-
.then((response) => {
|
|
149
|
-
if (response.success) {
|
|
150
|
-
this.refreshBannerAreaList().then(() => {
|
|
151
|
-
this.deletingBannerAreaIdList.filter((id) => id !== bannerArea.id);
|
|
152
|
-
});
|
|
153
|
-
this.$toast({
|
|
154
|
-
variant: 'success',
|
|
155
|
-
title: 'Success',
|
|
156
|
-
body: 'Banner area was successfully removed',
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
this.$toast({
|
|
161
|
-
variant: 'danger',
|
|
162
|
-
title: 'Error',
|
|
163
|
-
body: 'Banner area deletion was failed',
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
})
|
|
167
|
-
.catch((error) => {
|
|
168
|
-
console.error(error);
|
|
169
|
-
this.$toast({
|
|
170
|
-
variant: 'danger',
|
|
171
|
-
title: 'Error',
|
|
172
|
-
body: 'Banner area deletion was failed',
|
|
173
|
-
});
|
|
174
|
-
});
|
|
133
|
+
{
|
|
134
|
+
id: 1,
|
|
135
|
+
name: t('banners:name'),
|
|
136
|
+
field: 'name',
|
|
137
|
+
type: 'name',
|
|
175
138
|
},
|
|
176
|
-
|
|
177
|
-
|
|
139
|
+
{
|
|
140
|
+
id: 2,
|
|
141
|
+
name: t('banners:banners'),
|
|
142
|
+
field: 'bannersCount',
|
|
143
|
+
style: { whiteSpace: 'nowrap', width: '130px' },
|
|
178
144
|
},
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
function getLinkToBannersByZone(zoneId) {
|
|
148
|
+
return `${getBannersBannerListUrl()}?filter[zone]=${zoneId}`;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
var script = compositionApi.defineComponent({
|
|
152
|
+
name: 'ZoneList',
|
|
153
|
+
setup(props, context) {
|
|
154
|
+
const { fetchEntityList: fetchZones, isLoading: isZonesLoading, rowData, errorMessage, handleChange, } = adminUi.useDataTable({
|
|
155
|
+
fetchEntityList: getZones,
|
|
156
|
+
initialValue: [],
|
|
157
|
+
context,
|
|
158
|
+
resourceName: 'Banner Zones',
|
|
159
|
+
});
|
|
160
|
+
compositionApi.onMounted(() => {
|
|
161
|
+
fetchZones();
|
|
162
|
+
});
|
|
163
|
+
const columnDefs = compositionApi.computed(() => getColumnDefs(context.root.$t));
|
|
164
|
+
return {
|
|
165
|
+
columnDefs,
|
|
166
|
+
isRowDataLoading: isZonesLoading,
|
|
167
|
+
rowData,
|
|
168
|
+
errorMessage,
|
|
169
|
+
handleChange,
|
|
170
|
+
getLinkToBannersByZone,
|
|
171
|
+
};
|
|
179
172
|
},
|
|
180
173
|
});
|
|
181
174
|
|
|
@@ -254,59 +247,6 @@
|
|
|
254
247
|
return script;
|
|
255
248
|
}
|
|
256
249
|
|
|
257
|
-
const isOldIE = typeof navigator !== 'undefined' &&
|
|
258
|
-
/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
|
|
259
|
-
function createInjector(context) {
|
|
260
|
-
return (id, style) => addStyle(id, style);
|
|
261
|
-
}
|
|
262
|
-
let HEAD;
|
|
263
|
-
const styles = {};
|
|
264
|
-
function addStyle(id, css) {
|
|
265
|
-
const group = isOldIE ? css.media || 'default' : id;
|
|
266
|
-
const style = styles[group] || (styles[group] = { ids: new Set(), styles: [] });
|
|
267
|
-
if (!style.ids.has(id)) {
|
|
268
|
-
style.ids.add(id);
|
|
269
|
-
let code = css.source;
|
|
270
|
-
if (css.map) {
|
|
271
|
-
// https://developer.chrome.com/devtools/docs/javascript-debugging
|
|
272
|
-
// this makes source maps inside style tags work properly in Chrome
|
|
273
|
-
code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
|
|
274
|
-
// http://stackoverflow.com/a/26603875
|
|
275
|
-
code +=
|
|
276
|
-
'\n/*# sourceMappingURL=data:application/json;base64,' +
|
|
277
|
-
btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) +
|
|
278
|
-
' */';
|
|
279
|
-
}
|
|
280
|
-
if (!style.element) {
|
|
281
|
-
style.element = document.createElement('style');
|
|
282
|
-
style.element.type = 'text/css';
|
|
283
|
-
if (css.media)
|
|
284
|
-
style.element.setAttribute('media', css.media);
|
|
285
|
-
if (HEAD === undefined) {
|
|
286
|
-
HEAD = document.head || document.getElementsByTagName('head')[0];
|
|
287
|
-
}
|
|
288
|
-
HEAD.appendChild(style.element);
|
|
289
|
-
}
|
|
290
|
-
if ('styleSheet' in style.element) {
|
|
291
|
-
style.styles.push(code);
|
|
292
|
-
style.element.styleSheet.cssText = style.styles
|
|
293
|
-
.filter(Boolean)
|
|
294
|
-
.join('\n');
|
|
295
|
-
}
|
|
296
|
-
else {
|
|
297
|
-
const index = style.ids.size - 1;
|
|
298
|
-
const textNode = document.createTextNode(code);
|
|
299
|
-
const nodes = style.element.childNodes;
|
|
300
|
-
if (nodes[index])
|
|
301
|
-
style.element.removeChild(nodes[index]);
|
|
302
|
-
if (nodes.length)
|
|
303
|
-
style.element.insertBefore(textNode, nodes[index]);
|
|
304
|
-
else
|
|
305
|
-
style.element.appendChild(textNode);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
250
|
/* script */
|
|
311
251
|
const __vue_script__ = script;
|
|
312
252
|
|
|
@@ -316,82 +256,45 @@
|
|
|
316
256
|
var _h = _vm.$createElement;
|
|
317
257
|
var _c = _vm._self._c || _h;
|
|
318
258
|
return _c("page", {
|
|
319
|
-
attrs: {
|
|
320
|
-
title: "Banner Areas",
|
|
321
|
-
"header-buttons": [
|
|
322
|
-
{ text: "New banner area", href: _vm.getBannerAreaUrl("create") },
|
|
323
|
-
],
|
|
324
|
-
},
|
|
259
|
+
attrs: { title: _vm.$t("banners:zones") },
|
|
325
260
|
scopedSlots: _vm._u([
|
|
326
261
|
{
|
|
327
262
|
key: "content",
|
|
328
263
|
fn: function () {
|
|
329
264
|
return [
|
|
330
|
-
_c("
|
|
265
|
+
_c("data-table", {
|
|
331
266
|
attrs: {
|
|
332
267
|
"column-defs": _vm.columnDefs,
|
|
333
268
|
"row-data": _vm.rowData,
|
|
334
269
|
loading: _vm.isRowDataLoading,
|
|
335
270
|
"error-message": _vm.errorMessage,
|
|
271
|
+
"data-table": "banners-zones",
|
|
272
|
+
"use-search": false,
|
|
273
|
+
"use-pagination": false,
|
|
336
274
|
},
|
|
275
|
+
on: { change: _vm.handleChange },
|
|
337
276
|
scopedSlots: _vm._u([
|
|
338
277
|
{
|
|
339
|
-
key: "cell(
|
|
278
|
+
key: "cell(banners-count)",
|
|
340
279
|
fn: function (ref) {
|
|
341
280
|
var row = ref.row;
|
|
342
281
|
return [
|
|
343
282
|
_c(
|
|
344
|
-
"
|
|
283
|
+
"count-button",
|
|
345
284
|
{
|
|
346
285
|
attrs: {
|
|
347
|
-
href: _vm.
|
|
286
|
+
href: _vm.getLinkToBannersByZone(row.id),
|
|
348
287
|
variant: "outline-secondary",
|
|
288
|
+
count: row.bannersCount,
|
|
349
289
|
},
|
|
350
290
|
},
|
|
351
|
-
[
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
fn: function (ref) {
|
|
359
|
-
var row = ref.row;
|
|
360
|
-
return [
|
|
361
|
-
_c(
|
|
362
|
-
"base-button",
|
|
363
|
-
{
|
|
364
|
-
attrs: {
|
|
365
|
-
variant: "icon",
|
|
366
|
-
title: "Edit",
|
|
367
|
-
disabled: _vm.deletingBannerAreaIdList.includes(
|
|
368
|
-
row.id
|
|
369
|
-
),
|
|
370
|
-
href: _vm.getBannerAreaUrl(row.id),
|
|
371
|
-
},
|
|
372
|
-
},
|
|
373
|
-
[_c("svg-icon", { attrs: { name: "edit" } })],
|
|
374
|
-
1
|
|
375
|
-
),
|
|
376
|
-
_vm._v(" "),
|
|
377
|
-
_c(
|
|
378
|
-
"base-button",
|
|
379
|
-
{
|
|
380
|
-
attrs: {
|
|
381
|
-
variant: "icon",
|
|
382
|
-
title: "Remove",
|
|
383
|
-
disabled: _vm.deletingBannerAreaIdList.includes(
|
|
384
|
-
row.id
|
|
385
|
-
),
|
|
386
|
-
},
|
|
387
|
-
on: {
|
|
388
|
-
click: function ($event) {
|
|
389
|
-
return _vm.handleBannerAreaDelete(row)
|
|
390
|
-
},
|
|
391
|
-
},
|
|
392
|
-
},
|
|
393
|
-
[_c("svg-icon", { attrs: { name: "delete" } })],
|
|
394
|
-
1
|
|
291
|
+
[
|
|
292
|
+
_vm._v(
|
|
293
|
+
"\n " +
|
|
294
|
+
_vm._s(_vm.$t("banners:banners")) +
|
|
295
|
+
"\n "
|
|
296
|
+
),
|
|
297
|
+
]
|
|
395
298
|
),
|
|
396
299
|
]
|
|
397
300
|
},
|
|
@@ -409,17 +312,15 @@
|
|
|
409
312
|
__vue_render__._withStripped = true;
|
|
410
313
|
|
|
411
314
|
/* style */
|
|
412
|
-
const __vue_inject_styles__ =
|
|
413
|
-
if (!inject) return
|
|
414
|
-
inject("data-v-60c3bc88_0", { source: ".actions-cell button[data-v-60c3bc88]:not(:last-child) {\n margin-right: 0.5rem;\n}\n\n/*# sourceMappingURL=BannerAreaList.vue.map */", map: {"version":3,"sources":["D:\\Work\\tager-admin-banners\\src\\views\\BannerAreaList.vue","BannerAreaList.vue"],"names":[],"mappings":"AA2KA;EACA,oBAAA;AC1KA;;AAEA,6CAA6C","file":"BannerAreaList.vue","sourcesContent":["<template>\n <page\n title=\"Banner Areas\"\n :header-buttons=\"[\n { text: 'New banner area', href: getBannerAreaUrl('create') },\n ]\"\n >\n <template v-slot:content>\n <base-table\n :column-defs=\"columnDefs\"\n :row-data=\"rowData\"\n :loading=\"isRowDataLoading\"\n :error-message=\"errorMessage\"\n >\n <template v-slot:cell(link-to-banner-items)=\"{ row }\">\n <base-button\n :href=\"getLinkToBannerItems(row.alias)\"\n variant=\"outline-secondary\"\n >\n Banner Items\n </base-button>\n </template>\n\n <template v-slot:cell(actions)=\"{ row }\">\n <base-button\n variant=\"icon\"\n title=\"Edit\"\n :disabled=\"deletingBannerAreaIdList.includes(row.id)\"\n :href=\"getBannerAreaUrl(row.id)\"\n >\n <svg-icon name=\"edit\"></svg-icon>\n </base-button>\n <base-button\n variant=\"icon\"\n title=\"Remove\"\n :disabled=\"deletingBannerAreaIdList.includes(row.id)\"\n @click=\"handleBannerAreaDelete(row)\"\n >\n <svg-icon name=\"delete\"></svg-icon>\n </base-button>\n </template>\n </base-table>\n </template>\n </page>\n</template>\n\n<script lang=\"ts\">\nimport Vue from 'vue';\nimport { ColumnDefinition } from '@tager/admin-ui';\nimport { getMessageFromError, Nullable } from '@tager/admin-services';\n\nimport { BannerArea } from '../typings/model';\nimport { deleteBannerArea, getBannerAreaList } from '../services/requests';\nimport { getBannerAreaFormUrl, getBannerItemListUrl } from '../constants/paths';\n\nconst COLUMN_DEFS: Array<ColumnDefinition<BannerArea>> = [\n {\n id: 1,\n name: 'ID',\n field: 'id',\n style: { width: '50px', textAlign: 'center' },\n headStyle: { width: '50px', textAlign: 'center' },\n },\n { id: 2, name: 'Alias', field: 'alias' },\n { id: 3, name: 'Label', field: 'label' },\n { id: 4, name: 'Scenario', field: 'scenario' },\n {\n id: 6,\n name: 'Banner Items',\n field: 'linkToBannerItems',\n style: { whiteSpace: 'nowrap', width: '120px', textAlign: 'center' },\n headStyle: { whiteSpace: 'nowrap', width: '120px', textAlign: 'center' },\n },\n {\n id: 8,\n name: 'Actions',\n field: 'actions',\n style: { whiteSpace: 'nowrap', width: '110px', textAlign: 'center' },\n headStyle: { whiteSpace: 'nowrap', width: '110px', textAlign: 'center' },\n },\n];\n\nexport default Vue.extend({\n name: 'BannerAreaList',\n data(): {\n columnDefs: Array<ColumnDefinition<BannerArea>>;\n rowData: Array<BannerArea>;\n deletingBannerAreaIdList: Array<number>;\n isRowDataLoading: boolean;\n errorMessage: Nullable<string>;\n } {\n return {\n columnDefs: COLUMN_DEFS,\n rowData: [],\n deletingBannerAreaIdList: [],\n isRowDataLoading: false,\n errorMessage: null,\n };\n },\n mounted(): void {\n this.refreshBannerAreaList();\n },\n methods: {\n getBannerAreaUrl(areaId: number | string): string {\n return getBannerAreaFormUrl({ areaId });\n },\n refreshBannerAreaList(): Promise<void> {\n this.isRowDataLoading = true;\n\n return getBannerAreaList()\n .then((response) => {\n this.rowData = response.data;\n this.errorMessage = null;\n })\n .catch((error) => {\n console.error(error);\n this.rowData = [];\n this.errorMessage = getMessageFromError(error);\n })\n .finally(() => {\n this.isRowDataLoading = false;\n });\n },\n handleBannerAreaDelete(bannerArea: BannerArea) {\n const shouldDeleteBannerArea = confirm(\n `Are you sure you want to delete banner area \"${bannerArea.label}\"`\n );\n\n if (!shouldDeleteBannerArea) return;\n\n this.deletingBannerAreaIdList.push(bannerArea.id);\n\n deleteBannerArea(bannerArea.id)\n .then((response) => {\n if (response.success) {\n this.refreshBannerAreaList().then(() => {\n this.deletingBannerAreaIdList.filter(\n (id) => id !== bannerArea.id\n );\n });\n this.$toast({\n variant: 'success',\n title: 'Success',\n body: 'Banner area was successfully removed',\n });\n } else {\n this.$toast({\n variant: 'danger',\n title: 'Error',\n body: 'Banner area deletion was failed',\n });\n }\n })\n .catch((error) => {\n console.error(error);\n this.$toast({\n variant: 'danger',\n title: 'Error',\n body: 'Banner area deletion was failed',\n });\n });\n },\n getLinkToBannerItems(areaAlias: string) {\n return getBannerItemListUrl({ areaAlias });\n },\n },\n});\n</script>\n\n<style scoped lang=\"scss\">\n.actions-cell {\n button:not(:last-child) {\n margin-right: 0.5rem;\n }\n}\n</style>\n",".actions-cell button:not(:last-child) {\n margin-right: 0.5rem;\n}\n\n/*# sourceMappingURL=BannerAreaList.vue.map */"]}, media: undefined });
|
|
415
|
-
|
|
416
|
-
};
|
|
315
|
+
const __vue_inject_styles__ = undefined;
|
|
417
316
|
/* scoped */
|
|
418
|
-
const __vue_scope_id__ =
|
|
317
|
+
const __vue_scope_id__ = undefined;
|
|
419
318
|
/* module identifier */
|
|
420
319
|
const __vue_module_identifier__ = undefined;
|
|
421
320
|
/* functional template */
|
|
422
321
|
const __vue_is_functional_template__ = false;
|
|
322
|
+
/* style inject */
|
|
323
|
+
|
|
423
324
|
/* style inject SSR */
|
|
424
325
|
|
|
425
326
|
/* style inject shadow dom */
|
|
@@ -434,368 +335,2691 @@
|
|
|
434
335
|
__vue_is_functional_template__,
|
|
435
336
|
__vue_module_identifier__,
|
|
436
337
|
false,
|
|
437
|
-
|
|
338
|
+
undefined,
|
|
438
339
|
undefined,
|
|
439
340
|
undefined
|
|
440
341
|
);
|
|
441
342
|
|
|
442
|
-
|
|
443
|
-
alias: '',
|
|
444
|
-
label: '',
|
|
445
|
-
scenario: '',
|
|
446
|
-
};
|
|
447
|
-
var script$1 = Vue.extend({
|
|
448
|
-
name: 'BannerAreaForm',
|
|
449
|
-
data() {
|
|
450
|
-
return {
|
|
451
|
-
values: Object.assign({}, initialValues),
|
|
452
|
-
errors: {},
|
|
453
|
-
isContentLoading: false,
|
|
454
|
-
};
|
|
455
|
-
},
|
|
456
|
-
computed: {
|
|
457
|
-
areaId() {
|
|
458
|
-
return this.$route.params.areaId;
|
|
459
|
-
},
|
|
460
|
-
isCreation() {
|
|
461
|
-
return this.areaId === 'create';
|
|
462
|
-
},
|
|
463
|
-
},
|
|
464
|
-
watch: {
|
|
465
|
-
areaId() {
|
|
466
|
-
this.updateValues();
|
|
467
|
-
},
|
|
468
|
-
},
|
|
469
|
-
mounted() {
|
|
470
|
-
this.updateValues();
|
|
471
|
-
},
|
|
472
|
-
methods: {
|
|
473
|
-
convertReviewToInitialValues(bannerArea) {
|
|
474
|
-
return {
|
|
475
|
-
alias: bannerArea.alias,
|
|
476
|
-
label: bannerArea.label,
|
|
477
|
-
scenario: bannerArea.scenario,
|
|
478
|
-
};
|
|
479
|
-
},
|
|
480
|
-
updateValues() {
|
|
481
|
-
if (this.isCreation) {
|
|
482
|
-
this.values = Object.assign({}, initialValues);
|
|
483
|
-
}
|
|
484
|
-
else {
|
|
485
|
-
this.isContentLoading = true;
|
|
486
|
-
getBannerAreaById(this.areaId)
|
|
487
|
-
.then((response) => {
|
|
488
|
-
this.values = this.convertReviewToInitialValues(response.data);
|
|
489
|
-
})
|
|
490
|
-
.catch(console.error)
|
|
491
|
-
.finally(() => {
|
|
492
|
-
this.isContentLoading = false;
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
},
|
|
496
|
-
submitForm() {
|
|
497
|
-
const body = {
|
|
498
|
-
label: this.values.label,
|
|
499
|
-
alias: this.values.alias,
|
|
500
|
-
scenario: this.values.scenario,
|
|
501
|
-
};
|
|
502
|
-
const requestPromise = this.isCreation
|
|
503
|
-
? createBannerArea(body)
|
|
504
|
-
: updateBannerArea(this.areaId, body);
|
|
505
|
-
requestPromise
|
|
506
|
-
.then(() => {
|
|
507
|
-
this.errors = {};
|
|
508
|
-
this.$router.push(getBannerAreaListUrl());
|
|
509
|
-
this.$toast({
|
|
510
|
-
variant: 'success',
|
|
511
|
-
title: 'Success',
|
|
512
|
-
body: `Banner Area was successfully ${this.isCreation ? 'created' : 'updated'}`,
|
|
513
|
-
});
|
|
514
|
-
})
|
|
515
|
-
.catch((error) => {
|
|
516
|
-
console.error(error);
|
|
517
|
-
this.errors = adminServices.convertRequestErrorToMap(error);
|
|
518
|
-
this.$toast({
|
|
519
|
-
variant: 'danger',
|
|
520
|
-
title: 'Error',
|
|
521
|
-
body: `Blog bannerArea ${this.isCreation ? 'creation' : 'update'} was failed`,
|
|
522
|
-
});
|
|
523
|
-
});
|
|
524
|
-
},
|
|
525
|
-
getAreaListUrl: getBannerAreaListUrl,
|
|
526
|
-
},
|
|
527
|
-
});
|
|
343
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
528
344
|
|
|
529
|
-
|
|
530
|
-
|
|
345
|
+
function createCommonjsModule(fn, basedir, module) {
|
|
346
|
+
return module = {
|
|
347
|
+
path: basedir,
|
|
348
|
+
exports: {},
|
|
349
|
+
require: function (path, base) {
|
|
350
|
+
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
|
|
351
|
+
}
|
|
352
|
+
}, fn(module, module.exports), module.exports;
|
|
353
|
+
}
|
|
531
354
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
var _h = _vm.$createElement;
|
|
536
|
-
var _c = _vm._self._c || _h;
|
|
537
|
-
return _c("page", {
|
|
538
|
-
attrs: {
|
|
539
|
-
title: _vm.isCreation ? "Create Banner Area" : "Update Banner Area",
|
|
540
|
-
"is-content-loading": _vm.isContentLoading,
|
|
541
|
-
footer: { onSubmit: _vm.submitForm, backHref: _vm.getAreaListUrl() },
|
|
542
|
-
},
|
|
543
|
-
scopedSlots: _vm._u([
|
|
544
|
-
{
|
|
545
|
-
key: "content",
|
|
546
|
-
fn: function () {
|
|
547
|
-
return [
|
|
548
|
-
_c(
|
|
549
|
-
"form",
|
|
550
|
-
{
|
|
551
|
-
attrs: { novalidate: "" },
|
|
552
|
-
on: {
|
|
553
|
-
submit: function ($event) {
|
|
554
|
-
$event.preventDefault();
|
|
555
|
-
return _vm.submitForm($event)
|
|
556
|
-
},
|
|
557
|
-
},
|
|
558
|
-
},
|
|
559
|
-
[
|
|
560
|
-
_c("form-field", {
|
|
561
|
-
attrs: {
|
|
562
|
-
name: "alias",
|
|
563
|
-
label: "Alias",
|
|
564
|
-
error: _vm.errors.alias,
|
|
565
|
-
},
|
|
566
|
-
model: {
|
|
567
|
-
value: _vm.values.alias,
|
|
568
|
-
callback: function ($$v) {
|
|
569
|
-
_vm.$set(_vm.values, "alias", $$v);
|
|
570
|
-
},
|
|
571
|
-
expression: "values.alias",
|
|
572
|
-
},
|
|
573
|
-
}),
|
|
574
|
-
_vm._v(" "),
|
|
575
|
-
_c("form-field", {
|
|
576
|
-
attrs: {
|
|
577
|
-
name: "label",
|
|
578
|
-
label: "Label",
|
|
579
|
-
error: _vm.errors.label,
|
|
580
|
-
},
|
|
581
|
-
model: {
|
|
582
|
-
value: _vm.values.label,
|
|
583
|
-
callback: function ($$v) {
|
|
584
|
-
_vm.$set(_vm.values, "label", $$v);
|
|
585
|
-
},
|
|
586
|
-
expression: "values.label",
|
|
587
|
-
},
|
|
588
|
-
}),
|
|
589
|
-
_vm._v(" "),
|
|
590
|
-
_c("form-field", {
|
|
591
|
-
attrs: {
|
|
592
|
-
name: "scenario",
|
|
593
|
-
label: "Scenario",
|
|
594
|
-
error: _vm.errors.scenario,
|
|
595
|
-
},
|
|
596
|
-
model: {
|
|
597
|
-
value: _vm.values.scenario,
|
|
598
|
-
callback: function ($$v) {
|
|
599
|
-
_vm.$set(_vm.values, "scenario", $$v);
|
|
600
|
-
},
|
|
601
|
-
expression: "values.scenario",
|
|
602
|
-
},
|
|
603
|
-
}),
|
|
604
|
-
],
|
|
605
|
-
1
|
|
606
|
-
),
|
|
607
|
-
]
|
|
608
|
-
},
|
|
609
|
-
proxy: true,
|
|
610
|
-
},
|
|
611
|
-
]),
|
|
612
|
-
})
|
|
613
|
-
};
|
|
614
|
-
var __vue_staticRenderFns__$1 = [];
|
|
615
|
-
__vue_render__$1._withStripped = true;
|
|
355
|
+
function commonjsRequire () {
|
|
356
|
+
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
|
|
357
|
+
}
|
|
616
358
|
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
359
|
+
var lodash_isequal = createCommonjsModule(function (module, exports) {
|
|
360
|
+
/**
|
|
361
|
+
* Lodash (Custom Build) <https://lodash.com/>
|
|
362
|
+
* Build: `lodash modularize exports="npm" -o ./`
|
|
363
|
+
* Copyright JS Foundation and other contributors <https://js.foundation/>
|
|
364
|
+
* Released under MIT license <https://lodash.com/license>
|
|
365
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
366
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
367
|
+
*/
|
|
621
368
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
const __vue_scope_id__$1 = "data-v-78a20f0f";
|
|
625
|
-
/* module identifier */
|
|
626
|
-
const __vue_module_identifier__$1 = undefined;
|
|
627
|
-
/* functional template */
|
|
628
|
-
const __vue_is_functional_template__$1 = false;
|
|
629
|
-
/* style inject SSR */
|
|
630
|
-
|
|
631
|
-
/* style inject shadow dom */
|
|
632
|
-
|
|
369
|
+
/** Used as the size to enable large array optimizations. */
|
|
370
|
+
var LARGE_ARRAY_SIZE = 200;
|
|
633
371
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
{ render: __vue_render__$1, staticRenderFns: __vue_staticRenderFns__$1 },
|
|
637
|
-
__vue_inject_styles__$1,
|
|
638
|
-
__vue_script__$1,
|
|
639
|
-
__vue_scope_id__$1,
|
|
640
|
-
__vue_is_functional_template__$1,
|
|
641
|
-
__vue_module_identifier__$1,
|
|
642
|
-
false,
|
|
643
|
-
createInjector,
|
|
644
|
-
undefined,
|
|
645
|
-
undefined
|
|
646
|
-
);
|
|
372
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
373
|
+
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
|
647
374
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
var
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
375
|
+
/** Used to compose bitmasks for value comparisons. */
|
|
376
|
+
var COMPARE_PARTIAL_FLAG = 1,
|
|
377
|
+
COMPARE_UNORDERED_FLAG = 2;
|
|
378
|
+
|
|
379
|
+
/** Used as references for various `Number` constants. */
|
|
380
|
+
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
381
|
+
|
|
382
|
+
/** `Object#toString` result references. */
|
|
383
|
+
var argsTag = '[object Arguments]',
|
|
384
|
+
arrayTag = '[object Array]',
|
|
385
|
+
asyncTag = '[object AsyncFunction]',
|
|
386
|
+
boolTag = '[object Boolean]',
|
|
387
|
+
dateTag = '[object Date]',
|
|
388
|
+
errorTag = '[object Error]',
|
|
389
|
+
funcTag = '[object Function]',
|
|
390
|
+
genTag = '[object GeneratorFunction]',
|
|
391
|
+
mapTag = '[object Map]',
|
|
392
|
+
numberTag = '[object Number]',
|
|
393
|
+
nullTag = '[object Null]',
|
|
394
|
+
objectTag = '[object Object]',
|
|
395
|
+
promiseTag = '[object Promise]',
|
|
396
|
+
proxyTag = '[object Proxy]',
|
|
397
|
+
regexpTag = '[object RegExp]',
|
|
398
|
+
setTag = '[object Set]',
|
|
399
|
+
stringTag = '[object String]',
|
|
400
|
+
symbolTag = '[object Symbol]',
|
|
401
|
+
undefinedTag = '[object Undefined]',
|
|
402
|
+
weakMapTag = '[object WeakMap]';
|
|
403
|
+
|
|
404
|
+
var arrayBufferTag = '[object ArrayBuffer]',
|
|
405
|
+
dataViewTag = '[object DataView]',
|
|
406
|
+
float32Tag = '[object Float32Array]',
|
|
407
|
+
float64Tag = '[object Float64Array]',
|
|
408
|
+
int8Tag = '[object Int8Array]',
|
|
409
|
+
int16Tag = '[object Int16Array]',
|
|
410
|
+
int32Tag = '[object Int32Array]',
|
|
411
|
+
uint8Tag = '[object Uint8Array]',
|
|
412
|
+
uint8ClampedTag = '[object Uint8ClampedArray]',
|
|
413
|
+
uint16Tag = '[object Uint16Array]',
|
|
414
|
+
uint32Tag = '[object Uint32Array]';
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Used to match `RegExp`
|
|
418
|
+
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|
419
|
+
*/
|
|
420
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
421
|
+
|
|
422
|
+
/** Used to detect host constructors (Safari). */
|
|
423
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
424
|
+
|
|
425
|
+
/** Used to detect unsigned integer values. */
|
|
426
|
+
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|
427
|
+
|
|
428
|
+
/** Used to identify `toStringTag` values of typed arrays. */
|
|
429
|
+
var typedArrayTags = {};
|
|
430
|
+
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
|
|
431
|
+
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
|
|
432
|
+
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
|
|
433
|
+
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
|
|
434
|
+
typedArrayTags[uint32Tag] = true;
|
|
435
|
+
typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
|
|
436
|
+
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
|
|
437
|
+
typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
|
|
438
|
+
typedArrayTags[errorTag] = typedArrayTags[funcTag] =
|
|
439
|
+
typedArrayTags[mapTag] = typedArrayTags[numberTag] =
|
|
440
|
+
typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
|
|
441
|
+
typedArrayTags[setTag] = typedArrayTags[stringTag] =
|
|
442
|
+
typedArrayTags[weakMapTag] = false;
|
|
443
|
+
|
|
444
|
+
/** Detect free variable `global` from Node.js. */
|
|
445
|
+
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
446
|
+
|
|
447
|
+
/** Detect free variable `self`. */
|
|
448
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
449
|
+
|
|
450
|
+
/** Used as a reference to the global object. */
|
|
451
|
+
var root = freeGlobal || freeSelf || Function('return this')();
|
|
452
|
+
|
|
453
|
+
/** Detect free variable `exports`. */
|
|
454
|
+
var freeExports = exports && !exports.nodeType && exports;
|
|
455
|
+
|
|
456
|
+
/** Detect free variable `module`. */
|
|
457
|
+
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
|
458
|
+
|
|
459
|
+
/** Detect the popular CommonJS extension `module.exports`. */
|
|
460
|
+
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
461
|
+
|
|
462
|
+
/** Detect free variable `process` from Node.js. */
|
|
463
|
+
var freeProcess = moduleExports && freeGlobal.process;
|
|
464
|
+
|
|
465
|
+
/** Used to access faster Node.js helpers. */
|
|
466
|
+
var nodeUtil = (function() {
|
|
467
|
+
try {
|
|
468
|
+
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
|
469
|
+
} catch (e) {}
|
|
470
|
+
}());
|
|
471
|
+
|
|
472
|
+
/* Node.js helper references. */
|
|
473
|
+
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* A specialized version of `_.filter` for arrays without support for
|
|
477
|
+
* iteratee shorthands.
|
|
478
|
+
*
|
|
479
|
+
* @private
|
|
480
|
+
* @param {Array} [array] The array to iterate over.
|
|
481
|
+
* @param {Function} predicate The function invoked per iteration.
|
|
482
|
+
* @returns {Array} Returns the new filtered array.
|
|
483
|
+
*/
|
|
484
|
+
function arrayFilter(array, predicate) {
|
|
485
|
+
var index = -1,
|
|
486
|
+
length = array == null ? 0 : array.length,
|
|
487
|
+
resIndex = 0,
|
|
488
|
+
result = [];
|
|
489
|
+
|
|
490
|
+
while (++index < length) {
|
|
491
|
+
var value = array[index];
|
|
492
|
+
if (predicate(value, index, array)) {
|
|
493
|
+
result[resIndex++] = value;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
return result;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Appends the elements of `values` to `array`.
|
|
501
|
+
*
|
|
502
|
+
* @private
|
|
503
|
+
* @param {Array} array The array to modify.
|
|
504
|
+
* @param {Array} values The values to append.
|
|
505
|
+
* @returns {Array} Returns `array`.
|
|
506
|
+
*/
|
|
507
|
+
function arrayPush(array, values) {
|
|
508
|
+
var index = -1,
|
|
509
|
+
length = values.length,
|
|
510
|
+
offset = array.length;
|
|
511
|
+
|
|
512
|
+
while (++index < length) {
|
|
513
|
+
array[offset + index] = values[index];
|
|
514
|
+
}
|
|
515
|
+
return array;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* A specialized version of `_.some` for arrays without support for iteratee
|
|
520
|
+
* shorthands.
|
|
521
|
+
*
|
|
522
|
+
* @private
|
|
523
|
+
* @param {Array} [array] The array to iterate over.
|
|
524
|
+
* @param {Function} predicate The function invoked per iteration.
|
|
525
|
+
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
|
526
|
+
* else `false`.
|
|
527
|
+
*/
|
|
528
|
+
function arraySome(array, predicate) {
|
|
529
|
+
var index = -1,
|
|
530
|
+
length = array == null ? 0 : array.length;
|
|
531
|
+
|
|
532
|
+
while (++index < length) {
|
|
533
|
+
if (predicate(array[index], index, array)) {
|
|
534
|
+
return true;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* The base implementation of `_.times` without support for iteratee shorthands
|
|
542
|
+
* or max array length checks.
|
|
543
|
+
*
|
|
544
|
+
* @private
|
|
545
|
+
* @param {number} n The number of times to invoke `iteratee`.
|
|
546
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
547
|
+
* @returns {Array} Returns the array of results.
|
|
548
|
+
*/
|
|
549
|
+
function baseTimes(n, iteratee) {
|
|
550
|
+
var index = -1,
|
|
551
|
+
result = Array(n);
|
|
552
|
+
|
|
553
|
+
while (++index < n) {
|
|
554
|
+
result[index] = iteratee(index);
|
|
555
|
+
}
|
|
556
|
+
return result;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* The base implementation of `_.unary` without support for storing metadata.
|
|
561
|
+
*
|
|
562
|
+
* @private
|
|
563
|
+
* @param {Function} func The function to cap arguments for.
|
|
564
|
+
* @returns {Function} Returns the new capped function.
|
|
565
|
+
*/
|
|
566
|
+
function baseUnary(func) {
|
|
567
|
+
return function(value) {
|
|
568
|
+
return func(value);
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Checks if a `cache` value for `key` exists.
|
|
574
|
+
*
|
|
575
|
+
* @private
|
|
576
|
+
* @param {Object} cache The cache to query.
|
|
577
|
+
* @param {string} key The key of the entry to check.
|
|
578
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
579
|
+
*/
|
|
580
|
+
function cacheHas(cache, key) {
|
|
581
|
+
return cache.has(key);
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Gets the value at `key` of `object`.
|
|
586
|
+
*
|
|
587
|
+
* @private
|
|
588
|
+
* @param {Object} [object] The object to query.
|
|
589
|
+
* @param {string} key The key of the property to get.
|
|
590
|
+
* @returns {*} Returns the property value.
|
|
591
|
+
*/
|
|
592
|
+
function getValue(object, key) {
|
|
593
|
+
return object == null ? undefined : object[key];
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Converts `map` to its key-value pairs.
|
|
598
|
+
*
|
|
599
|
+
* @private
|
|
600
|
+
* @param {Object} map The map to convert.
|
|
601
|
+
* @returns {Array} Returns the key-value pairs.
|
|
602
|
+
*/
|
|
603
|
+
function mapToArray(map) {
|
|
604
|
+
var index = -1,
|
|
605
|
+
result = Array(map.size);
|
|
606
|
+
|
|
607
|
+
map.forEach(function(value, key) {
|
|
608
|
+
result[++index] = [key, value];
|
|
609
|
+
});
|
|
610
|
+
return result;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Creates a unary function that invokes `func` with its argument transformed.
|
|
615
|
+
*
|
|
616
|
+
* @private
|
|
617
|
+
* @param {Function} func The function to wrap.
|
|
618
|
+
* @param {Function} transform The argument transform.
|
|
619
|
+
* @returns {Function} Returns the new function.
|
|
620
|
+
*/
|
|
621
|
+
function overArg(func, transform) {
|
|
622
|
+
return function(arg) {
|
|
623
|
+
return func(transform(arg));
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Converts `set` to an array of its values.
|
|
629
|
+
*
|
|
630
|
+
* @private
|
|
631
|
+
* @param {Object} set The set to convert.
|
|
632
|
+
* @returns {Array} Returns the values.
|
|
633
|
+
*/
|
|
634
|
+
function setToArray(set) {
|
|
635
|
+
var index = -1,
|
|
636
|
+
result = Array(set.size);
|
|
637
|
+
|
|
638
|
+
set.forEach(function(value) {
|
|
639
|
+
result[++index] = value;
|
|
640
|
+
});
|
|
641
|
+
return result;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/** Used for built-in method references. */
|
|
645
|
+
var arrayProto = Array.prototype,
|
|
646
|
+
funcProto = Function.prototype,
|
|
647
|
+
objectProto = Object.prototype;
|
|
648
|
+
|
|
649
|
+
/** Used to detect overreaching core-js shims. */
|
|
650
|
+
var coreJsData = root['__core-js_shared__'];
|
|
651
|
+
|
|
652
|
+
/** Used to resolve the decompiled source of functions. */
|
|
653
|
+
var funcToString = funcProto.toString;
|
|
654
|
+
|
|
655
|
+
/** Used to check objects for own properties. */
|
|
656
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
657
|
+
|
|
658
|
+
/** Used to detect methods masquerading as native. */
|
|
659
|
+
var maskSrcKey = (function() {
|
|
660
|
+
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
|
661
|
+
return uid ? ('Symbol(src)_1.' + uid) : '';
|
|
662
|
+
}());
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* Used to resolve the
|
|
666
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
667
|
+
* of values.
|
|
668
|
+
*/
|
|
669
|
+
var nativeObjectToString = objectProto.toString;
|
|
670
|
+
|
|
671
|
+
/** Used to detect if a method is native. */
|
|
672
|
+
var reIsNative = RegExp('^' +
|
|
673
|
+
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
|
|
674
|
+
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
|
675
|
+
);
|
|
676
|
+
|
|
677
|
+
/** Built-in value references. */
|
|
678
|
+
var Buffer = moduleExports ? root.Buffer : undefined,
|
|
679
|
+
Symbol = root.Symbol,
|
|
680
|
+
Uint8Array = root.Uint8Array,
|
|
681
|
+
propertyIsEnumerable = objectProto.propertyIsEnumerable,
|
|
682
|
+
splice = arrayProto.splice,
|
|
683
|
+
symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
|
684
|
+
|
|
685
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
686
|
+
var nativeGetSymbols = Object.getOwnPropertySymbols,
|
|
687
|
+
nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
|
|
688
|
+
nativeKeys = overArg(Object.keys, Object);
|
|
689
|
+
|
|
690
|
+
/* Built-in method references that are verified to be native. */
|
|
691
|
+
var DataView = getNative(root, 'DataView'),
|
|
692
|
+
Map = getNative(root, 'Map'),
|
|
693
|
+
Promise = getNative(root, 'Promise'),
|
|
694
|
+
Set = getNative(root, 'Set'),
|
|
695
|
+
WeakMap = getNative(root, 'WeakMap'),
|
|
696
|
+
nativeCreate = getNative(Object, 'create');
|
|
697
|
+
|
|
698
|
+
/** Used to detect maps, sets, and weakmaps. */
|
|
699
|
+
var dataViewCtorString = toSource(DataView),
|
|
700
|
+
mapCtorString = toSource(Map),
|
|
701
|
+
promiseCtorString = toSource(Promise),
|
|
702
|
+
setCtorString = toSource(Set),
|
|
703
|
+
weakMapCtorString = toSource(WeakMap);
|
|
704
|
+
|
|
705
|
+
/** Used to convert symbols to primitives and strings. */
|
|
706
|
+
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
|
707
|
+
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Creates a hash object.
|
|
711
|
+
*
|
|
712
|
+
* @private
|
|
713
|
+
* @constructor
|
|
714
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
715
|
+
*/
|
|
716
|
+
function Hash(entries) {
|
|
717
|
+
var index = -1,
|
|
718
|
+
length = entries == null ? 0 : entries.length;
|
|
719
|
+
|
|
720
|
+
this.clear();
|
|
721
|
+
while (++index < length) {
|
|
722
|
+
var entry = entries[index];
|
|
723
|
+
this.set(entry[0], entry[1]);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Removes all key-value entries from the hash.
|
|
729
|
+
*
|
|
730
|
+
* @private
|
|
731
|
+
* @name clear
|
|
732
|
+
* @memberOf Hash
|
|
733
|
+
*/
|
|
734
|
+
function hashClear() {
|
|
735
|
+
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
|
736
|
+
this.size = 0;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Removes `key` and its value from the hash.
|
|
741
|
+
*
|
|
742
|
+
* @private
|
|
743
|
+
* @name delete
|
|
744
|
+
* @memberOf Hash
|
|
745
|
+
* @param {Object} hash The hash to modify.
|
|
746
|
+
* @param {string} key The key of the value to remove.
|
|
747
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
748
|
+
*/
|
|
749
|
+
function hashDelete(key) {
|
|
750
|
+
var result = this.has(key) && delete this.__data__[key];
|
|
751
|
+
this.size -= result ? 1 : 0;
|
|
752
|
+
return result;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Gets the hash value for `key`.
|
|
757
|
+
*
|
|
758
|
+
* @private
|
|
759
|
+
* @name get
|
|
760
|
+
* @memberOf Hash
|
|
761
|
+
* @param {string} key The key of the value to get.
|
|
762
|
+
* @returns {*} Returns the entry value.
|
|
763
|
+
*/
|
|
764
|
+
function hashGet(key) {
|
|
765
|
+
var data = this.__data__;
|
|
766
|
+
if (nativeCreate) {
|
|
767
|
+
var result = data[key];
|
|
768
|
+
return result === HASH_UNDEFINED ? undefined : result;
|
|
769
|
+
}
|
|
770
|
+
return hasOwnProperty.call(data, key) ? data[key] : undefined;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Checks if a hash value for `key` exists.
|
|
775
|
+
*
|
|
776
|
+
* @private
|
|
777
|
+
* @name has
|
|
778
|
+
* @memberOf Hash
|
|
779
|
+
* @param {string} key The key of the entry to check.
|
|
780
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
781
|
+
*/
|
|
782
|
+
function hashHas(key) {
|
|
783
|
+
var data = this.__data__;
|
|
784
|
+
return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* Sets the hash `key` to `value`.
|
|
789
|
+
*
|
|
790
|
+
* @private
|
|
791
|
+
* @name set
|
|
792
|
+
* @memberOf Hash
|
|
793
|
+
* @param {string} key The key of the value to set.
|
|
794
|
+
* @param {*} value The value to set.
|
|
795
|
+
* @returns {Object} Returns the hash instance.
|
|
796
|
+
*/
|
|
797
|
+
function hashSet(key, value) {
|
|
798
|
+
var data = this.__data__;
|
|
799
|
+
this.size += this.has(key) ? 0 : 1;
|
|
800
|
+
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
|
|
801
|
+
return this;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
// Add methods to `Hash`.
|
|
805
|
+
Hash.prototype.clear = hashClear;
|
|
806
|
+
Hash.prototype['delete'] = hashDelete;
|
|
807
|
+
Hash.prototype.get = hashGet;
|
|
808
|
+
Hash.prototype.has = hashHas;
|
|
809
|
+
Hash.prototype.set = hashSet;
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* Creates an list cache object.
|
|
813
|
+
*
|
|
814
|
+
* @private
|
|
815
|
+
* @constructor
|
|
816
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
817
|
+
*/
|
|
818
|
+
function ListCache(entries) {
|
|
819
|
+
var index = -1,
|
|
820
|
+
length = entries == null ? 0 : entries.length;
|
|
821
|
+
|
|
822
|
+
this.clear();
|
|
823
|
+
while (++index < length) {
|
|
824
|
+
var entry = entries[index];
|
|
825
|
+
this.set(entry[0], entry[1]);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Removes all key-value entries from the list cache.
|
|
831
|
+
*
|
|
832
|
+
* @private
|
|
833
|
+
* @name clear
|
|
834
|
+
* @memberOf ListCache
|
|
835
|
+
*/
|
|
836
|
+
function listCacheClear() {
|
|
837
|
+
this.__data__ = [];
|
|
838
|
+
this.size = 0;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* Removes `key` and its value from the list cache.
|
|
843
|
+
*
|
|
844
|
+
* @private
|
|
845
|
+
* @name delete
|
|
846
|
+
* @memberOf ListCache
|
|
847
|
+
* @param {string} key The key of the value to remove.
|
|
848
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
849
|
+
*/
|
|
850
|
+
function listCacheDelete(key) {
|
|
851
|
+
var data = this.__data__,
|
|
852
|
+
index = assocIndexOf(data, key);
|
|
853
|
+
|
|
854
|
+
if (index < 0) {
|
|
855
|
+
return false;
|
|
856
|
+
}
|
|
857
|
+
var lastIndex = data.length - 1;
|
|
858
|
+
if (index == lastIndex) {
|
|
859
|
+
data.pop();
|
|
860
|
+
} else {
|
|
861
|
+
splice.call(data, index, 1);
|
|
862
|
+
}
|
|
863
|
+
--this.size;
|
|
864
|
+
return true;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* Gets the list cache value for `key`.
|
|
869
|
+
*
|
|
870
|
+
* @private
|
|
871
|
+
* @name get
|
|
872
|
+
* @memberOf ListCache
|
|
873
|
+
* @param {string} key The key of the value to get.
|
|
874
|
+
* @returns {*} Returns the entry value.
|
|
875
|
+
*/
|
|
876
|
+
function listCacheGet(key) {
|
|
877
|
+
var data = this.__data__,
|
|
878
|
+
index = assocIndexOf(data, key);
|
|
879
|
+
|
|
880
|
+
return index < 0 ? undefined : data[index][1];
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* Checks if a list cache value for `key` exists.
|
|
885
|
+
*
|
|
886
|
+
* @private
|
|
887
|
+
* @name has
|
|
888
|
+
* @memberOf ListCache
|
|
889
|
+
* @param {string} key The key of the entry to check.
|
|
890
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
891
|
+
*/
|
|
892
|
+
function listCacheHas(key) {
|
|
893
|
+
return assocIndexOf(this.__data__, key) > -1;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* Sets the list cache `key` to `value`.
|
|
898
|
+
*
|
|
899
|
+
* @private
|
|
900
|
+
* @name set
|
|
901
|
+
* @memberOf ListCache
|
|
902
|
+
* @param {string} key The key of the value to set.
|
|
903
|
+
* @param {*} value The value to set.
|
|
904
|
+
* @returns {Object} Returns the list cache instance.
|
|
905
|
+
*/
|
|
906
|
+
function listCacheSet(key, value) {
|
|
907
|
+
var data = this.__data__,
|
|
908
|
+
index = assocIndexOf(data, key);
|
|
909
|
+
|
|
910
|
+
if (index < 0) {
|
|
911
|
+
++this.size;
|
|
912
|
+
data.push([key, value]);
|
|
913
|
+
} else {
|
|
914
|
+
data[index][1] = value;
|
|
915
|
+
}
|
|
916
|
+
return this;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
// Add methods to `ListCache`.
|
|
920
|
+
ListCache.prototype.clear = listCacheClear;
|
|
921
|
+
ListCache.prototype['delete'] = listCacheDelete;
|
|
922
|
+
ListCache.prototype.get = listCacheGet;
|
|
923
|
+
ListCache.prototype.has = listCacheHas;
|
|
924
|
+
ListCache.prototype.set = listCacheSet;
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
* Creates a map cache object to store key-value pairs.
|
|
928
|
+
*
|
|
929
|
+
* @private
|
|
930
|
+
* @constructor
|
|
931
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
932
|
+
*/
|
|
933
|
+
function MapCache(entries) {
|
|
934
|
+
var index = -1,
|
|
935
|
+
length = entries == null ? 0 : entries.length;
|
|
936
|
+
|
|
937
|
+
this.clear();
|
|
938
|
+
while (++index < length) {
|
|
939
|
+
var entry = entries[index];
|
|
940
|
+
this.set(entry[0], entry[1]);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* Removes all key-value entries from the map.
|
|
946
|
+
*
|
|
947
|
+
* @private
|
|
948
|
+
* @name clear
|
|
949
|
+
* @memberOf MapCache
|
|
950
|
+
*/
|
|
951
|
+
function mapCacheClear() {
|
|
952
|
+
this.size = 0;
|
|
953
|
+
this.__data__ = {
|
|
954
|
+
'hash': new Hash,
|
|
955
|
+
'map': new (Map || ListCache),
|
|
956
|
+
'string': new Hash
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* Removes `key` and its value from the map.
|
|
962
|
+
*
|
|
963
|
+
* @private
|
|
964
|
+
* @name delete
|
|
965
|
+
* @memberOf MapCache
|
|
966
|
+
* @param {string} key The key of the value to remove.
|
|
967
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
968
|
+
*/
|
|
969
|
+
function mapCacheDelete(key) {
|
|
970
|
+
var result = getMapData(this, key)['delete'](key);
|
|
971
|
+
this.size -= result ? 1 : 0;
|
|
972
|
+
return result;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* Gets the map value for `key`.
|
|
977
|
+
*
|
|
978
|
+
* @private
|
|
979
|
+
* @name get
|
|
980
|
+
* @memberOf MapCache
|
|
981
|
+
* @param {string} key The key of the value to get.
|
|
982
|
+
* @returns {*} Returns the entry value.
|
|
983
|
+
*/
|
|
984
|
+
function mapCacheGet(key) {
|
|
985
|
+
return getMapData(this, key).get(key);
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* Checks if a map value for `key` exists.
|
|
990
|
+
*
|
|
991
|
+
* @private
|
|
992
|
+
* @name has
|
|
993
|
+
* @memberOf MapCache
|
|
994
|
+
* @param {string} key The key of the entry to check.
|
|
995
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
996
|
+
*/
|
|
997
|
+
function mapCacheHas(key) {
|
|
998
|
+
return getMapData(this, key).has(key);
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
/**
|
|
1002
|
+
* Sets the map `key` to `value`.
|
|
1003
|
+
*
|
|
1004
|
+
* @private
|
|
1005
|
+
* @name set
|
|
1006
|
+
* @memberOf MapCache
|
|
1007
|
+
* @param {string} key The key of the value to set.
|
|
1008
|
+
* @param {*} value The value to set.
|
|
1009
|
+
* @returns {Object} Returns the map cache instance.
|
|
1010
|
+
*/
|
|
1011
|
+
function mapCacheSet(key, value) {
|
|
1012
|
+
var data = getMapData(this, key),
|
|
1013
|
+
size = data.size;
|
|
1014
|
+
|
|
1015
|
+
data.set(key, value);
|
|
1016
|
+
this.size += data.size == size ? 0 : 1;
|
|
1017
|
+
return this;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
// Add methods to `MapCache`.
|
|
1021
|
+
MapCache.prototype.clear = mapCacheClear;
|
|
1022
|
+
MapCache.prototype['delete'] = mapCacheDelete;
|
|
1023
|
+
MapCache.prototype.get = mapCacheGet;
|
|
1024
|
+
MapCache.prototype.has = mapCacheHas;
|
|
1025
|
+
MapCache.prototype.set = mapCacheSet;
|
|
1026
|
+
|
|
1027
|
+
/**
|
|
1028
|
+
*
|
|
1029
|
+
* Creates an array cache object to store unique values.
|
|
1030
|
+
*
|
|
1031
|
+
* @private
|
|
1032
|
+
* @constructor
|
|
1033
|
+
* @param {Array} [values] The values to cache.
|
|
1034
|
+
*/
|
|
1035
|
+
function SetCache(values) {
|
|
1036
|
+
var index = -1,
|
|
1037
|
+
length = values == null ? 0 : values.length;
|
|
1038
|
+
|
|
1039
|
+
this.__data__ = new MapCache;
|
|
1040
|
+
while (++index < length) {
|
|
1041
|
+
this.add(values[index]);
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* Adds `value` to the array cache.
|
|
1047
|
+
*
|
|
1048
|
+
* @private
|
|
1049
|
+
* @name add
|
|
1050
|
+
* @memberOf SetCache
|
|
1051
|
+
* @alias push
|
|
1052
|
+
* @param {*} value The value to cache.
|
|
1053
|
+
* @returns {Object} Returns the cache instance.
|
|
1054
|
+
*/
|
|
1055
|
+
function setCacheAdd(value) {
|
|
1056
|
+
this.__data__.set(value, HASH_UNDEFINED);
|
|
1057
|
+
return this;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* Checks if `value` is in the array cache.
|
|
1062
|
+
*
|
|
1063
|
+
* @private
|
|
1064
|
+
* @name has
|
|
1065
|
+
* @memberOf SetCache
|
|
1066
|
+
* @param {*} value The value to search for.
|
|
1067
|
+
* @returns {number} Returns `true` if `value` is found, else `false`.
|
|
1068
|
+
*/
|
|
1069
|
+
function setCacheHas(value) {
|
|
1070
|
+
return this.__data__.has(value);
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
// Add methods to `SetCache`.
|
|
1074
|
+
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
|
|
1075
|
+
SetCache.prototype.has = setCacheHas;
|
|
1076
|
+
|
|
1077
|
+
/**
|
|
1078
|
+
* Creates a stack cache object to store key-value pairs.
|
|
1079
|
+
*
|
|
1080
|
+
* @private
|
|
1081
|
+
* @constructor
|
|
1082
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
1083
|
+
*/
|
|
1084
|
+
function Stack(entries) {
|
|
1085
|
+
var data = this.__data__ = new ListCache(entries);
|
|
1086
|
+
this.size = data.size;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
/**
|
|
1090
|
+
* Removes all key-value entries from the stack.
|
|
1091
|
+
*
|
|
1092
|
+
* @private
|
|
1093
|
+
* @name clear
|
|
1094
|
+
* @memberOf Stack
|
|
1095
|
+
*/
|
|
1096
|
+
function stackClear() {
|
|
1097
|
+
this.__data__ = new ListCache;
|
|
1098
|
+
this.size = 0;
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
/**
|
|
1102
|
+
* Removes `key` and its value from the stack.
|
|
1103
|
+
*
|
|
1104
|
+
* @private
|
|
1105
|
+
* @name delete
|
|
1106
|
+
* @memberOf Stack
|
|
1107
|
+
* @param {string} key The key of the value to remove.
|
|
1108
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
1109
|
+
*/
|
|
1110
|
+
function stackDelete(key) {
|
|
1111
|
+
var data = this.__data__,
|
|
1112
|
+
result = data['delete'](key);
|
|
1113
|
+
|
|
1114
|
+
this.size = data.size;
|
|
1115
|
+
return result;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
/**
|
|
1119
|
+
* Gets the stack value for `key`.
|
|
1120
|
+
*
|
|
1121
|
+
* @private
|
|
1122
|
+
* @name get
|
|
1123
|
+
* @memberOf Stack
|
|
1124
|
+
* @param {string} key The key of the value to get.
|
|
1125
|
+
* @returns {*} Returns the entry value.
|
|
1126
|
+
*/
|
|
1127
|
+
function stackGet(key) {
|
|
1128
|
+
return this.__data__.get(key);
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* Checks if a stack value for `key` exists.
|
|
1133
|
+
*
|
|
1134
|
+
* @private
|
|
1135
|
+
* @name has
|
|
1136
|
+
* @memberOf Stack
|
|
1137
|
+
* @param {string} key The key of the entry to check.
|
|
1138
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
1139
|
+
*/
|
|
1140
|
+
function stackHas(key) {
|
|
1141
|
+
return this.__data__.has(key);
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
/**
|
|
1145
|
+
* Sets the stack `key` to `value`.
|
|
1146
|
+
*
|
|
1147
|
+
* @private
|
|
1148
|
+
* @name set
|
|
1149
|
+
* @memberOf Stack
|
|
1150
|
+
* @param {string} key The key of the value to set.
|
|
1151
|
+
* @param {*} value The value to set.
|
|
1152
|
+
* @returns {Object} Returns the stack cache instance.
|
|
1153
|
+
*/
|
|
1154
|
+
function stackSet(key, value) {
|
|
1155
|
+
var data = this.__data__;
|
|
1156
|
+
if (data instanceof ListCache) {
|
|
1157
|
+
var pairs = data.__data__;
|
|
1158
|
+
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
|
1159
|
+
pairs.push([key, value]);
|
|
1160
|
+
this.size = ++data.size;
|
|
1161
|
+
return this;
|
|
1162
|
+
}
|
|
1163
|
+
data = this.__data__ = new MapCache(pairs);
|
|
1164
|
+
}
|
|
1165
|
+
data.set(key, value);
|
|
1166
|
+
this.size = data.size;
|
|
1167
|
+
return this;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
// Add methods to `Stack`.
|
|
1171
|
+
Stack.prototype.clear = stackClear;
|
|
1172
|
+
Stack.prototype['delete'] = stackDelete;
|
|
1173
|
+
Stack.prototype.get = stackGet;
|
|
1174
|
+
Stack.prototype.has = stackHas;
|
|
1175
|
+
Stack.prototype.set = stackSet;
|
|
1176
|
+
|
|
1177
|
+
/**
|
|
1178
|
+
* Creates an array of the enumerable property names of the array-like `value`.
|
|
1179
|
+
*
|
|
1180
|
+
* @private
|
|
1181
|
+
* @param {*} value The value to query.
|
|
1182
|
+
* @param {boolean} inherited Specify returning inherited property names.
|
|
1183
|
+
* @returns {Array} Returns the array of property names.
|
|
1184
|
+
*/
|
|
1185
|
+
function arrayLikeKeys(value, inherited) {
|
|
1186
|
+
var isArr = isArray(value),
|
|
1187
|
+
isArg = !isArr && isArguments(value),
|
|
1188
|
+
isBuff = !isArr && !isArg && isBuffer(value),
|
|
1189
|
+
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
|
|
1190
|
+
skipIndexes = isArr || isArg || isBuff || isType,
|
|
1191
|
+
result = skipIndexes ? baseTimes(value.length, String) : [],
|
|
1192
|
+
length = result.length;
|
|
1193
|
+
|
|
1194
|
+
for (var key in value) {
|
|
1195
|
+
if ((inherited || hasOwnProperty.call(value, key)) &&
|
|
1196
|
+
!(skipIndexes && (
|
|
1197
|
+
// Safari 9 has enumerable `arguments.length` in strict mode.
|
|
1198
|
+
key == 'length' ||
|
|
1199
|
+
// Node.js 0.10 has enumerable non-index properties on buffers.
|
|
1200
|
+
(isBuff && (key == 'offset' || key == 'parent')) ||
|
|
1201
|
+
// PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
1202
|
+
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
|
|
1203
|
+
// Skip index properties.
|
|
1204
|
+
isIndex(key, length)
|
|
1205
|
+
))) {
|
|
1206
|
+
result.push(key);
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
return result;
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/**
|
|
1213
|
+
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
|
1214
|
+
*
|
|
1215
|
+
* @private
|
|
1216
|
+
* @param {Array} array The array to inspect.
|
|
1217
|
+
* @param {*} key The key to search for.
|
|
1218
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
1219
|
+
*/
|
|
1220
|
+
function assocIndexOf(array, key) {
|
|
1221
|
+
var length = array.length;
|
|
1222
|
+
while (length--) {
|
|
1223
|
+
if (eq(array[length][0], key)) {
|
|
1224
|
+
return length;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
return -1;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
/**
|
|
1231
|
+
* The base implementation of `getAllKeys` and `getAllKeysIn` which uses
|
|
1232
|
+
* `keysFunc` and `symbolsFunc` to get the enumerable property names and
|
|
1233
|
+
* symbols of `object`.
|
|
1234
|
+
*
|
|
1235
|
+
* @private
|
|
1236
|
+
* @param {Object} object The object to query.
|
|
1237
|
+
* @param {Function} keysFunc The function to get the keys of `object`.
|
|
1238
|
+
* @param {Function} symbolsFunc The function to get the symbols of `object`.
|
|
1239
|
+
* @returns {Array} Returns the array of property names and symbols.
|
|
1240
|
+
*/
|
|
1241
|
+
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
|
|
1242
|
+
var result = keysFunc(object);
|
|
1243
|
+
return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
/**
|
|
1247
|
+
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
1248
|
+
*
|
|
1249
|
+
* @private
|
|
1250
|
+
* @param {*} value The value to query.
|
|
1251
|
+
* @returns {string} Returns the `toStringTag`.
|
|
1252
|
+
*/
|
|
1253
|
+
function baseGetTag(value) {
|
|
1254
|
+
if (value == null) {
|
|
1255
|
+
return value === undefined ? undefinedTag : nullTag;
|
|
1256
|
+
}
|
|
1257
|
+
return (symToStringTag && symToStringTag in Object(value))
|
|
1258
|
+
? getRawTag(value)
|
|
1259
|
+
: objectToString(value);
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
/**
|
|
1263
|
+
* The base implementation of `_.isArguments`.
|
|
1264
|
+
*
|
|
1265
|
+
* @private
|
|
1266
|
+
* @param {*} value The value to check.
|
|
1267
|
+
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
1268
|
+
*/
|
|
1269
|
+
function baseIsArguments(value) {
|
|
1270
|
+
return isObjectLike(value) && baseGetTag(value) == argsTag;
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
/**
|
|
1274
|
+
* The base implementation of `_.isEqual` which supports partial comparisons
|
|
1275
|
+
* and tracks traversed objects.
|
|
1276
|
+
*
|
|
1277
|
+
* @private
|
|
1278
|
+
* @param {*} value The value to compare.
|
|
1279
|
+
* @param {*} other The other value to compare.
|
|
1280
|
+
* @param {boolean} bitmask The bitmask flags.
|
|
1281
|
+
* 1 - Unordered comparison
|
|
1282
|
+
* 2 - Partial comparison
|
|
1283
|
+
* @param {Function} [customizer] The function to customize comparisons.
|
|
1284
|
+
* @param {Object} [stack] Tracks traversed `value` and `other` objects.
|
|
1285
|
+
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
1286
|
+
*/
|
|
1287
|
+
function baseIsEqual(value, other, bitmask, customizer, stack) {
|
|
1288
|
+
if (value === other) {
|
|
1289
|
+
return true;
|
|
1290
|
+
}
|
|
1291
|
+
if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
|
|
1292
|
+
return value !== value && other !== other;
|
|
1293
|
+
}
|
|
1294
|
+
return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
/**
|
|
1298
|
+
* A specialized version of `baseIsEqual` for arrays and objects which performs
|
|
1299
|
+
* deep comparisons and tracks traversed objects enabling objects with circular
|
|
1300
|
+
* references to be compared.
|
|
1301
|
+
*
|
|
1302
|
+
* @private
|
|
1303
|
+
* @param {Object} object The object to compare.
|
|
1304
|
+
* @param {Object} other The other object to compare.
|
|
1305
|
+
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
1306
|
+
* @param {Function} customizer The function to customize comparisons.
|
|
1307
|
+
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
1308
|
+
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
|
|
1309
|
+
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
1310
|
+
*/
|
|
1311
|
+
function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
|
1312
|
+
var objIsArr = isArray(object),
|
|
1313
|
+
othIsArr = isArray(other),
|
|
1314
|
+
objTag = objIsArr ? arrayTag : getTag(object),
|
|
1315
|
+
othTag = othIsArr ? arrayTag : getTag(other);
|
|
1316
|
+
|
|
1317
|
+
objTag = objTag == argsTag ? objectTag : objTag;
|
|
1318
|
+
othTag = othTag == argsTag ? objectTag : othTag;
|
|
1319
|
+
|
|
1320
|
+
var objIsObj = objTag == objectTag,
|
|
1321
|
+
othIsObj = othTag == objectTag,
|
|
1322
|
+
isSameTag = objTag == othTag;
|
|
1323
|
+
|
|
1324
|
+
if (isSameTag && isBuffer(object)) {
|
|
1325
|
+
if (!isBuffer(other)) {
|
|
1326
|
+
return false;
|
|
1327
|
+
}
|
|
1328
|
+
objIsArr = true;
|
|
1329
|
+
objIsObj = false;
|
|
1330
|
+
}
|
|
1331
|
+
if (isSameTag && !objIsObj) {
|
|
1332
|
+
stack || (stack = new Stack);
|
|
1333
|
+
return (objIsArr || isTypedArray(object))
|
|
1334
|
+
? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
|
|
1335
|
+
: equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
|
|
1336
|
+
}
|
|
1337
|
+
if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
|
|
1338
|
+
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
|
1339
|
+
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
|
1340
|
+
|
|
1341
|
+
if (objIsWrapped || othIsWrapped) {
|
|
1342
|
+
var objUnwrapped = objIsWrapped ? object.value() : object,
|
|
1343
|
+
othUnwrapped = othIsWrapped ? other.value() : other;
|
|
1344
|
+
|
|
1345
|
+
stack || (stack = new Stack);
|
|
1346
|
+
return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
if (!isSameTag) {
|
|
1350
|
+
return false;
|
|
1351
|
+
}
|
|
1352
|
+
stack || (stack = new Stack);
|
|
1353
|
+
return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
/**
|
|
1357
|
+
* The base implementation of `_.isNative` without bad shim checks.
|
|
1358
|
+
*
|
|
1359
|
+
* @private
|
|
1360
|
+
* @param {*} value The value to check.
|
|
1361
|
+
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
1362
|
+
* else `false`.
|
|
1363
|
+
*/
|
|
1364
|
+
function baseIsNative(value) {
|
|
1365
|
+
if (!isObject(value) || isMasked(value)) {
|
|
1366
|
+
return false;
|
|
1367
|
+
}
|
|
1368
|
+
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
1369
|
+
return pattern.test(toSource(value));
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
/**
|
|
1373
|
+
* The base implementation of `_.isTypedArray` without Node.js optimizations.
|
|
1374
|
+
*
|
|
1375
|
+
* @private
|
|
1376
|
+
* @param {*} value The value to check.
|
|
1377
|
+
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
1378
|
+
*/
|
|
1379
|
+
function baseIsTypedArray(value) {
|
|
1380
|
+
return isObjectLike(value) &&
|
|
1381
|
+
isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
/**
|
|
1385
|
+
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
|
|
1386
|
+
*
|
|
1387
|
+
* @private
|
|
1388
|
+
* @param {Object} object The object to query.
|
|
1389
|
+
* @returns {Array} Returns the array of property names.
|
|
1390
|
+
*/
|
|
1391
|
+
function baseKeys(object) {
|
|
1392
|
+
if (!isPrototype(object)) {
|
|
1393
|
+
return nativeKeys(object);
|
|
1394
|
+
}
|
|
1395
|
+
var result = [];
|
|
1396
|
+
for (var key in Object(object)) {
|
|
1397
|
+
if (hasOwnProperty.call(object, key) && key != 'constructor') {
|
|
1398
|
+
result.push(key);
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
return result;
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
/**
|
|
1405
|
+
* A specialized version of `baseIsEqualDeep` for arrays with support for
|
|
1406
|
+
* partial deep comparisons.
|
|
1407
|
+
*
|
|
1408
|
+
* @private
|
|
1409
|
+
* @param {Array} array The array to compare.
|
|
1410
|
+
* @param {Array} other The other array to compare.
|
|
1411
|
+
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
1412
|
+
* @param {Function} customizer The function to customize comparisons.
|
|
1413
|
+
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
1414
|
+
* @param {Object} stack Tracks traversed `array` and `other` objects.
|
|
1415
|
+
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
|
1416
|
+
*/
|
|
1417
|
+
function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
|
|
1418
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
|
|
1419
|
+
arrLength = array.length,
|
|
1420
|
+
othLength = other.length;
|
|
1421
|
+
|
|
1422
|
+
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
|
1423
|
+
return false;
|
|
1424
|
+
}
|
|
1425
|
+
// Assume cyclic values are equal.
|
|
1426
|
+
var stacked = stack.get(array);
|
|
1427
|
+
if (stacked && stack.get(other)) {
|
|
1428
|
+
return stacked == other;
|
|
1429
|
+
}
|
|
1430
|
+
var index = -1,
|
|
1431
|
+
result = true,
|
|
1432
|
+
seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
|
|
1433
|
+
|
|
1434
|
+
stack.set(array, other);
|
|
1435
|
+
stack.set(other, array);
|
|
1436
|
+
|
|
1437
|
+
// Ignore non-index properties.
|
|
1438
|
+
while (++index < arrLength) {
|
|
1439
|
+
var arrValue = array[index],
|
|
1440
|
+
othValue = other[index];
|
|
1441
|
+
|
|
1442
|
+
if (customizer) {
|
|
1443
|
+
var compared = isPartial
|
|
1444
|
+
? customizer(othValue, arrValue, index, other, array, stack)
|
|
1445
|
+
: customizer(arrValue, othValue, index, array, other, stack);
|
|
1446
|
+
}
|
|
1447
|
+
if (compared !== undefined) {
|
|
1448
|
+
if (compared) {
|
|
1449
|
+
continue;
|
|
1450
|
+
}
|
|
1451
|
+
result = false;
|
|
1452
|
+
break;
|
|
1453
|
+
}
|
|
1454
|
+
// Recursively compare arrays (susceptible to call stack limits).
|
|
1455
|
+
if (seen) {
|
|
1456
|
+
if (!arraySome(other, function(othValue, othIndex) {
|
|
1457
|
+
if (!cacheHas(seen, othIndex) &&
|
|
1458
|
+
(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
|
|
1459
|
+
return seen.push(othIndex);
|
|
1460
|
+
}
|
|
1461
|
+
})) {
|
|
1462
|
+
result = false;
|
|
1463
|
+
break;
|
|
1464
|
+
}
|
|
1465
|
+
} else if (!(
|
|
1466
|
+
arrValue === othValue ||
|
|
1467
|
+
equalFunc(arrValue, othValue, bitmask, customizer, stack)
|
|
1468
|
+
)) {
|
|
1469
|
+
result = false;
|
|
1470
|
+
break;
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
stack['delete'](array);
|
|
1474
|
+
stack['delete'](other);
|
|
1475
|
+
return result;
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
/**
|
|
1479
|
+
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
|
1480
|
+
* the same `toStringTag`.
|
|
1481
|
+
*
|
|
1482
|
+
* **Note:** This function only supports comparing values with tags of
|
|
1483
|
+
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
|
|
1484
|
+
*
|
|
1485
|
+
* @private
|
|
1486
|
+
* @param {Object} object The object to compare.
|
|
1487
|
+
* @param {Object} other The other object to compare.
|
|
1488
|
+
* @param {string} tag The `toStringTag` of the objects to compare.
|
|
1489
|
+
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
1490
|
+
* @param {Function} customizer The function to customize comparisons.
|
|
1491
|
+
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
1492
|
+
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
|
1493
|
+
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
1494
|
+
*/
|
|
1495
|
+
function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
|
1496
|
+
switch (tag) {
|
|
1497
|
+
case dataViewTag:
|
|
1498
|
+
if ((object.byteLength != other.byteLength) ||
|
|
1499
|
+
(object.byteOffset != other.byteOffset)) {
|
|
1500
|
+
return false;
|
|
1501
|
+
}
|
|
1502
|
+
object = object.buffer;
|
|
1503
|
+
other = other.buffer;
|
|
1504
|
+
|
|
1505
|
+
case arrayBufferTag:
|
|
1506
|
+
if ((object.byteLength != other.byteLength) ||
|
|
1507
|
+
!equalFunc(new Uint8Array(object), new Uint8Array(other))) {
|
|
1508
|
+
return false;
|
|
1509
|
+
}
|
|
1510
|
+
return true;
|
|
1511
|
+
|
|
1512
|
+
case boolTag:
|
|
1513
|
+
case dateTag:
|
|
1514
|
+
case numberTag:
|
|
1515
|
+
// Coerce booleans to `1` or `0` and dates to milliseconds.
|
|
1516
|
+
// Invalid dates are coerced to `NaN`.
|
|
1517
|
+
return eq(+object, +other);
|
|
1518
|
+
|
|
1519
|
+
case errorTag:
|
|
1520
|
+
return object.name == other.name && object.message == other.message;
|
|
1521
|
+
|
|
1522
|
+
case regexpTag:
|
|
1523
|
+
case stringTag:
|
|
1524
|
+
// Coerce regexes to strings and treat strings, primitives and objects,
|
|
1525
|
+
// as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
|
|
1526
|
+
// for more details.
|
|
1527
|
+
return object == (other + '');
|
|
1528
|
+
|
|
1529
|
+
case mapTag:
|
|
1530
|
+
var convert = mapToArray;
|
|
1531
|
+
|
|
1532
|
+
case setTag:
|
|
1533
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
|
|
1534
|
+
convert || (convert = setToArray);
|
|
1535
|
+
|
|
1536
|
+
if (object.size != other.size && !isPartial) {
|
|
1537
|
+
return false;
|
|
1538
|
+
}
|
|
1539
|
+
// Assume cyclic values are equal.
|
|
1540
|
+
var stacked = stack.get(object);
|
|
1541
|
+
if (stacked) {
|
|
1542
|
+
return stacked == other;
|
|
1543
|
+
}
|
|
1544
|
+
bitmask |= COMPARE_UNORDERED_FLAG;
|
|
1545
|
+
|
|
1546
|
+
// Recursively compare objects (susceptible to call stack limits).
|
|
1547
|
+
stack.set(object, other);
|
|
1548
|
+
var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
|
|
1549
|
+
stack['delete'](object);
|
|
1550
|
+
return result;
|
|
1551
|
+
|
|
1552
|
+
case symbolTag:
|
|
1553
|
+
if (symbolValueOf) {
|
|
1554
|
+
return symbolValueOf.call(object) == symbolValueOf.call(other);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
return false;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
/**
|
|
1561
|
+
* A specialized version of `baseIsEqualDeep` for objects with support for
|
|
1562
|
+
* partial deep comparisons.
|
|
1563
|
+
*
|
|
1564
|
+
* @private
|
|
1565
|
+
* @param {Object} object The object to compare.
|
|
1566
|
+
* @param {Object} other The other object to compare.
|
|
1567
|
+
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
1568
|
+
* @param {Function} customizer The function to customize comparisons.
|
|
1569
|
+
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
1570
|
+
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
|
1571
|
+
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
1572
|
+
*/
|
|
1573
|
+
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
|
1574
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
|
|
1575
|
+
objProps = getAllKeys(object),
|
|
1576
|
+
objLength = objProps.length,
|
|
1577
|
+
othProps = getAllKeys(other),
|
|
1578
|
+
othLength = othProps.length;
|
|
1579
|
+
|
|
1580
|
+
if (objLength != othLength && !isPartial) {
|
|
1581
|
+
return false;
|
|
1582
|
+
}
|
|
1583
|
+
var index = objLength;
|
|
1584
|
+
while (index--) {
|
|
1585
|
+
var key = objProps[index];
|
|
1586
|
+
if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
|
|
1587
|
+
return false;
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
// Assume cyclic values are equal.
|
|
1591
|
+
var stacked = stack.get(object);
|
|
1592
|
+
if (stacked && stack.get(other)) {
|
|
1593
|
+
return stacked == other;
|
|
1594
|
+
}
|
|
1595
|
+
var result = true;
|
|
1596
|
+
stack.set(object, other);
|
|
1597
|
+
stack.set(other, object);
|
|
1598
|
+
|
|
1599
|
+
var skipCtor = isPartial;
|
|
1600
|
+
while (++index < objLength) {
|
|
1601
|
+
key = objProps[index];
|
|
1602
|
+
var objValue = object[key],
|
|
1603
|
+
othValue = other[key];
|
|
1604
|
+
|
|
1605
|
+
if (customizer) {
|
|
1606
|
+
var compared = isPartial
|
|
1607
|
+
? customizer(othValue, objValue, key, other, object, stack)
|
|
1608
|
+
: customizer(objValue, othValue, key, object, other, stack);
|
|
1609
|
+
}
|
|
1610
|
+
// Recursively compare objects (susceptible to call stack limits).
|
|
1611
|
+
if (!(compared === undefined
|
|
1612
|
+
? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
|
|
1613
|
+
: compared
|
|
1614
|
+
)) {
|
|
1615
|
+
result = false;
|
|
1616
|
+
break;
|
|
1617
|
+
}
|
|
1618
|
+
skipCtor || (skipCtor = key == 'constructor');
|
|
1619
|
+
}
|
|
1620
|
+
if (result && !skipCtor) {
|
|
1621
|
+
var objCtor = object.constructor,
|
|
1622
|
+
othCtor = other.constructor;
|
|
1623
|
+
|
|
1624
|
+
// Non `Object` object instances with different constructors are not equal.
|
|
1625
|
+
if (objCtor != othCtor &&
|
|
1626
|
+
('constructor' in object && 'constructor' in other) &&
|
|
1627
|
+
!(typeof objCtor == 'function' && objCtor instanceof objCtor &&
|
|
1628
|
+
typeof othCtor == 'function' && othCtor instanceof othCtor)) {
|
|
1629
|
+
result = false;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
stack['delete'](object);
|
|
1633
|
+
stack['delete'](other);
|
|
1634
|
+
return result;
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
/**
|
|
1638
|
+
* Creates an array of own enumerable property names and symbols of `object`.
|
|
1639
|
+
*
|
|
1640
|
+
* @private
|
|
1641
|
+
* @param {Object} object The object to query.
|
|
1642
|
+
* @returns {Array} Returns the array of property names and symbols.
|
|
1643
|
+
*/
|
|
1644
|
+
function getAllKeys(object) {
|
|
1645
|
+
return baseGetAllKeys(object, keys, getSymbols);
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
/**
|
|
1649
|
+
* Gets the data for `map`.
|
|
1650
|
+
*
|
|
1651
|
+
* @private
|
|
1652
|
+
* @param {Object} map The map to query.
|
|
1653
|
+
* @param {string} key The reference key.
|
|
1654
|
+
* @returns {*} Returns the map data.
|
|
1655
|
+
*/
|
|
1656
|
+
function getMapData(map, key) {
|
|
1657
|
+
var data = map.__data__;
|
|
1658
|
+
return isKeyable(key)
|
|
1659
|
+
? data[typeof key == 'string' ? 'string' : 'hash']
|
|
1660
|
+
: data.map;
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
/**
|
|
1664
|
+
* Gets the native function at `key` of `object`.
|
|
1665
|
+
*
|
|
1666
|
+
* @private
|
|
1667
|
+
* @param {Object} object The object to query.
|
|
1668
|
+
* @param {string} key The key of the method to get.
|
|
1669
|
+
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
1670
|
+
*/
|
|
1671
|
+
function getNative(object, key) {
|
|
1672
|
+
var value = getValue(object, key);
|
|
1673
|
+
return baseIsNative(value) ? value : undefined;
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
/**
|
|
1677
|
+
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
1678
|
+
*
|
|
1679
|
+
* @private
|
|
1680
|
+
* @param {*} value The value to query.
|
|
1681
|
+
* @returns {string} Returns the raw `toStringTag`.
|
|
1682
|
+
*/
|
|
1683
|
+
function getRawTag(value) {
|
|
1684
|
+
var isOwn = hasOwnProperty.call(value, symToStringTag),
|
|
1685
|
+
tag = value[symToStringTag];
|
|
1686
|
+
|
|
1687
|
+
try {
|
|
1688
|
+
value[symToStringTag] = undefined;
|
|
1689
|
+
var unmasked = true;
|
|
1690
|
+
} catch (e) {}
|
|
1691
|
+
|
|
1692
|
+
var result = nativeObjectToString.call(value);
|
|
1693
|
+
if (unmasked) {
|
|
1694
|
+
if (isOwn) {
|
|
1695
|
+
value[symToStringTag] = tag;
|
|
1696
|
+
} else {
|
|
1697
|
+
delete value[symToStringTag];
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
return result;
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
/**
|
|
1704
|
+
* Creates an array of the own enumerable symbols of `object`.
|
|
1705
|
+
*
|
|
1706
|
+
* @private
|
|
1707
|
+
* @param {Object} object The object to query.
|
|
1708
|
+
* @returns {Array} Returns the array of symbols.
|
|
1709
|
+
*/
|
|
1710
|
+
var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
|
|
1711
|
+
if (object == null) {
|
|
1712
|
+
return [];
|
|
1713
|
+
}
|
|
1714
|
+
object = Object(object);
|
|
1715
|
+
return arrayFilter(nativeGetSymbols(object), function(symbol) {
|
|
1716
|
+
return propertyIsEnumerable.call(object, symbol);
|
|
1717
|
+
});
|
|
1718
|
+
};
|
|
1719
|
+
|
|
1720
|
+
/**
|
|
1721
|
+
* Gets the `toStringTag` of `value`.
|
|
1722
|
+
*
|
|
1723
|
+
* @private
|
|
1724
|
+
* @param {*} value The value to query.
|
|
1725
|
+
* @returns {string} Returns the `toStringTag`.
|
|
1726
|
+
*/
|
|
1727
|
+
var getTag = baseGetTag;
|
|
1728
|
+
|
|
1729
|
+
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
|
|
1730
|
+
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
|
|
1731
|
+
(Map && getTag(new Map) != mapTag) ||
|
|
1732
|
+
(Promise && getTag(Promise.resolve()) != promiseTag) ||
|
|
1733
|
+
(Set && getTag(new Set) != setTag) ||
|
|
1734
|
+
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
|
|
1735
|
+
getTag = function(value) {
|
|
1736
|
+
var result = baseGetTag(value),
|
|
1737
|
+
Ctor = result == objectTag ? value.constructor : undefined,
|
|
1738
|
+
ctorString = Ctor ? toSource(Ctor) : '';
|
|
1739
|
+
|
|
1740
|
+
if (ctorString) {
|
|
1741
|
+
switch (ctorString) {
|
|
1742
|
+
case dataViewCtorString: return dataViewTag;
|
|
1743
|
+
case mapCtorString: return mapTag;
|
|
1744
|
+
case promiseCtorString: return promiseTag;
|
|
1745
|
+
case setCtorString: return setTag;
|
|
1746
|
+
case weakMapCtorString: return weakMapTag;
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
return result;
|
|
1750
|
+
};
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
/**
|
|
1754
|
+
* Checks if `value` is a valid array-like index.
|
|
1755
|
+
*
|
|
1756
|
+
* @private
|
|
1757
|
+
* @param {*} value The value to check.
|
|
1758
|
+
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
|
|
1759
|
+
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
|
1760
|
+
*/
|
|
1761
|
+
function isIndex(value, length) {
|
|
1762
|
+
length = length == null ? MAX_SAFE_INTEGER : length;
|
|
1763
|
+
return !!length &&
|
|
1764
|
+
(typeof value == 'number' || reIsUint.test(value)) &&
|
|
1765
|
+
(value > -1 && value % 1 == 0 && value < length);
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
/**
|
|
1769
|
+
* Checks if `value` is suitable for use as unique object key.
|
|
1770
|
+
*
|
|
1771
|
+
* @private
|
|
1772
|
+
* @param {*} value The value to check.
|
|
1773
|
+
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
|
1774
|
+
*/
|
|
1775
|
+
function isKeyable(value) {
|
|
1776
|
+
var type = typeof value;
|
|
1777
|
+
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
|
1778
|
+
? (value !== '__proto__')
|
|
1779
|
+
: (value === null);
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
/**
|
|
1783
|
+
* Checks if `func` has its source masked.
|
|
1784
|
+
*
|
|
1785
|
+
* @private
|
|
1786
|
+
* @param {Function} func The function to check.
|
|
1787
|
+
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|
1788
|
+
*/
|
|
1789
|
+
function isMasked(func) {
|
|
1790
|
+
return !!maskSrcKey && (maskSrcKey in func);
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
/**
|
|
1794
|
+
* Checks if `value` is likely a prototype object.
|
|
1795
|
+
*
|
|
1796
|
+
* @private
|
|
1797
|
+
* @param {*} value The value to check.
|
|
1798
|
+
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
|
|
1799
|
+
*/
|
|
1800
|
+
function isPrototype(value) {
|
|
1801
|
+
var Ctor = value && value.constructor,
|
|
1802
|
+
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
|
|
1803
|
+
|
|
1804
|
+
return value === proto;
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
/**
|
|
1808
|
+
* Converts `value` to a string using `Object.prototype.toString`.
|
|
1809
|
+
*
|
|
1810
|
+
* @private
|
|
1811
|
+
* @param {*} value The value to convert.
|
|
1812
|
+
* @returns {string} Returns the converted string.
|
|
1813
|
+
*/
|
|
1814
|
+
function objectToString(value) {
|
|
1815
|
+
return nativeObjectToString.call(value);
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
/**
|
|
1819
|
+
* Converts `func` to its source code.
|
|
1820
|
+
*
|
|
1821
|
+
* @private
|
|
1822
|
+
* @param {Function} func The function to convert.
|
|
1823
|
+
* @returns {string} Returns the source code.
|
|
1824
|
+
*/
|
|
1825
|
+
function toSource(func) {
|
|
1826
|
+
if (func != null) {
|
|
1827
|
+
try {
|
|
1828
|
+
return funcToString.call(func);
|
|
1829
|
+
} catch (e) {}
|
|
1830
|
+
try {
|
|
1831
|
+
return (func + '');
|
|
1832
|
+
} catch (e) {}
|
|
1833
|
+
}
|
|
1834
|
+
return '';
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
/**
|
|
1838
|
+
* Performs a
|
|
1839
|
+
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
1840
|
+
* comparison between two values to determine if they are equivalent.
|
|
1841
|
+
*
|
|
1842
|
+
* @static
|
|
1843
|
+
* @memberOf _
|
|
1844
|
+
* @since 4.0.0
|
|
1845
|
+
* @category Lang
|
|
1846
|
+
* @param {*} value The value to compare.
|
|
1847
|
+
* @param {*} other The other value to compare.
|
|
1848
|
+
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
1849
|
+
* @example
|
|
1850
|
+
*
|
|
1851
|
+
* var object = { 'a': 1 };
|
|
1852
|
+
* var other = { 'a': 1 };
|
|
1853
|
+
*
|
|
1854
|
+
* _.eq(object, object);
|
|
1855
|
+
* // => true
|
|
1856
|
+
*
|
|
1857
|
+
* _.eq(object, other);
|
|
1858
|
+
* // => false
|
|
1859
|
+
*
|
|
1860
|
+
* _.eq('a', 'a');
|
|
1861
|
+
* // => true
|
|
1862
|
+
*
|
|
1863
|
+
* _.eq('a', Object('a'));
|
|
1864
|
+
* // => false
|
|
1865
|
+
*
|
|
1866
|
+
* _.eq(NaN, NaN);
|
|
1867
|
+
* // => true
|
|
1868
|
+
*/
|
|
1869
|
+
function eq(value, other) {
|
|
1870
|
+
return value === other || (value !== value && other !== other);
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
/**
|
|
1874
|
+
* Checks if `value` is likely an `arguments` object.
|
|
1875
|
+
*
|
|
1876
|
+
* @static
|
|
1877
|
+
* @memberOf _
|
|
1878
|
+
* @since 0.1.0
|
|
1879
|
+
* @category Lang
|
|
1880
|
+
* @param {*} value The value to check.
|
|
1881
|
+
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
1882
|
+
* else `false`.
|
|
1883
|
+
* @example
|
|
1884
|
+
*
|
|
1885
|
+
* _.isArguments(function() { return arguments; }());
|
|
1886
|
+
* // => true
|
|
1887
|
+
*
|
|
1888
|
+
* _.isArguments([1, 2, 3]);
|
|
1889
|
+
* // => false
|
|
1890
|
+
*/
|
|
1891
|
+
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
|
|
1892
|
+
return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
|
|
1893
|
+
!propertyIsEnumerable.call(value, 'callee');
|
|
1894
|
+
};
|
|
1895
|
+
|
|
1896
|
+
/**
|
|
1897
|
+
* Checks if `value` is classified as an `Array` object.
|
|
1898
|
+
*
|
|
1899
|
+
* @static
|
|
1900
|
+
* @memberOf _
|
|
1901
|
+
* @since 0.1.0
|
|
1902
|
+
* @category Lang
|
|
1903
|
+
* @param {*} value The value to check.
|
|
1904
|
+
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
1905
|
+
* @example
|
|
1906
|
+
*
|
|
1907
|
+
* _.isArray([1, 2, 3]);
|
|
1908
|
+
* // => true
|
|
1909
|
+
*
|
|
1910
|
+
* _.isArray(document.body.children);
|
|
1911
|
+
* // => false
|
|
1912
|
+
*
|
|
1913
|
+
* _.isArray('abc');
|
|
1914
|
+
* // => false
|
|
1915
|
+
*
|
|
1916
|
+
* _.isArray(_.noop);
|
|
1917
|
+
* // => false
|
|
1918
|
+
*/
|
|
1919
|
+
var isArray = Array.isArray;
|
|
1920
|
+
|
|
1921
|
+
/**
|
|
1922
|
+
* Checks if `value` is array-like. A value is considered array-like if it's
|
|
1923
|
+
* not a function and has a `value.length` that's an integer greater than or
|
|
1924
|
+
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
|
1925
|
+
*
|
|
1926
|
+
* @static
|
|
1927
|
+
* @memberOf _
|
|
1928
|
+
* @since 4.0.0
|
|
1929
|
+
* @category Lang
|
|
1930
|
+
* @param {*} value The value to check.
|
|
1931
|
+
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
|
1932
|
+
* @example
|
|
1933
|
+
*
|
|
1934
|
+
* _.isArrayLike([1, 2, 3]);
|
|
1935
|
+
* // => true
|
|
1936
|
+
*
|
|
1937
|
+
* _.isArrayLike(document.body.children);
|
|
1938
|
+
* // => true
|
|
1939
|
+
*
|
|
1940
|
+
* _.isArrayLike('abc');
|
|
1941
|
+
* // => true
|
|
1942
|
+
*
|
|
1943
|
+
* _.isArrayLike(_.noop);
|
|
1944
|
+
* // => false
|
|
1945
|
+
*/
|
|
1946
|
+
function isArrayLike(value) {
|
|
1947
|
+
return value != null && isLength(value.length) && !isFunction(value);
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
/**
|
|
1951
|
+
* Checks if `value` is a buffer.
|
|
1952
|
+
*
|
|
1953
|
+
* @static
|
|
1954
|
+
* @memberOf _
|
|
1955
|
+
* @since 4.3.0
|
|
1956
|
+
* @category Lang
|
|
1957
|
+
* @param {*} value The value to check.
|
|
1958
|
+
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
|
1959
|
+
* @example
|
|
1960
|
+
*
|
|
1961
|
+
* _.isBuffer(new Buffer(2));
|
|
1962
|
+
* // => true
|
|
1963
|
+
*
|
|
1964
|
+
* _.isBuffer(new Uint8Array(2));
|
|
1965
|
+
* // => false
|
|
1966
|
+
*/
|
|
1967
|
+
var isBuffer = nativeIsBuffer || stubFalse;
|
|
1968
|
+
|
|
1969
|
+
/**
|
|
1970
|
+
* Performs a deep comparison between two values to determine if they are
|
|
1971
|
+
* equivalent.
|
|
1972
|
+
*
|
|
1973
|
+
* **Note:** This method supports comparing arrays, array buffers, booleans,
|
|
1974
|
+
* date objects, error objects, maps, numbers, `Object` objects, regexes,
|
|
1975
|
+
* sets, strings, symbols, and typed arrays. `Object` objects are compared
|
|
1976
|
+
* by their own, not inherited, enumerable properties. Functions and DOM
|
|
1977
|
+
* nodes are compared by strict equality, i.e. `===`.
|
|
1978
|
+
*
|
|
1979
|
+
* @static
|
|
1980
|
+
* @memberOf _
|
|
1981
|
+
* @since 0.1.0
|
|
1982
|
+
* @category Lang
|
|
1983
|
+
* @param {*} value The value to compare.
|
|
1984
|
+
* @param {*} other The other value to compare.
|
|
1985
|
+
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
1986
|
+
* @example
|
|
1987
|
+
*
|
|
1988
|
+
* var object = { 'a': 1 };
|
|
1989
|
+
* var other = { 'a': 1 };
|
|
1990
|
+
*
|
|
1991
|
+
* _.isEqual(object, other);
|
|
1992
|
+
* // => true
|
|
1993
|
+
*
|
|
1994
|
+
* object === other;
|
|
1995
|
+
* // => false
|
|
1996
|
+
*/
|
|
1997
|
+
function isEqual(value, other) {
|
|
1998
|
+
return baseIsEqual(value, other);
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
/**
|
|
2002
|
+
* Checks if `value` is classified as a `Function` object.
|
|
2003
|
+
*
|
|
2004
|
+
* @static
|
|
2005
|
+
* @memberOf _
|
|
2006
|
+
* @since 0.1.0
|
|
2007
|
+
* @category Lang
|
|
2008
|
+
* @param {*} value The value to check.
|
|
2009
|
+
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
2010
|
+
* @example
|
|
2011
|
+
*
|
|
2012
|
+
* _.isFunction(_);
|
|
2013
|
+
* // => true
|
|
2014
|
+
*
|
|
2015
|
+
* _.isFunction(/abc/);
|
|
2016
|
+
* // => false
|
|
2017
|
+
*/
|
|
2018
|
+
function isFunction(value) {
|
|
2019
|
+
if (!isObject(value)) {
|
|
2020
|
+
return false;
|
|
2021
|
+
}
|
|
2022
|
+
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
2023
|
+
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
|
2024
|
+
var tag = baseGetTag(value);
|
|
2025
|
+
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
/**
|
|
2029
|
+
* Checks if `value` is a valid array-like length.
|
|
2030
|
+
*
|
|
2031
|
+
* **Note:** This method is loosely based on
|
|
2032
|
+
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|
2033
|
+
*
|
|
2034
|
+
* @static
|
|
2035
|
+
* @memberOf _
|
|
2036
|
+
* @since 4.0.0
|
|
2037
|
+
* @category Lang
|
|
2038
|
+
* @param {*} value The value to check.
|
|
2039
|
+
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|
2040
|
+
* @example
|
|
2041
|
+
*
|
|
2042
|
+
* _.isLength(3);
|
|
2043
|
+
* // => true
|
|
2044
|
+
*
|
|
2045
|
+
* _.isLength(Number.MIN_VALUE);
|
|
2046
|
+
* // => false
|
|
2047
|
+
*
|
|
2048
|
+
* _.isLength(Infinity);
|
|
2049
|
+
* // => false
|
|
2050
|
+
*
|
|
2051
|
+
* _.isLength('3');
|
|
2052
|
+
* // => false
|
|
2053
|
+
*/
|
|
2054
|
+
function isLength(value) {
|
|
2055
|
+
return typeof value == 'number' &&
|
|
2056
|
+
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
/**
|
|
2060
|
+
* Checks if `value` is the
|
|
2061
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
2062
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
2063
|
+
*
|
|
2064
|
+
* @static
|
|
2065
|
+
* @memberOf _
|
|
2066
|
+
* @since 0.1.0
|
|
2067
|
+
* @category Lang
|
|
2068
|
+
* @param {*} value The value to check.
|
|
2069
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
2070
|
+
* @example
|
|
2071
|
+
*
|
|
2072
|
+
* _.isObject({});
|
|
2073
|
+
* // => true
|
|
2074
|
+
*
|
|
2075
|
+
* _.isObject([1, 2, 3]);
|
|
2076
|
+
* // => true
|
|
2077
|
+
*
|
|
2078
|
+
* _.isObject(_.noop);
|
|
2079
|
+
* // => true
|
|
2080
|
+
*
|
|
2081
|
+
* _.isObject(null);
|
|
2082
|
+
* // => false
|
|
2083
|
+
*/
|
|
2084
|
+
function isObject(value) {
|
|
2085
|
+
var type = typeof value;
|
|
2086
|
+
return value != null && (type == 'object' || type == 'function');
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
/**
|
|
2090
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
2091
|
+
* and has a `typeof` result of "object".
|
|
2092
|
+
*
|
|
2093
|
+
* @static
|
|
2094
|
+
* @memberOf _
|
|
2095
|
+
* @since 4.0.0
|
|
2096
|
+
* @category Lang
|
|
2097
|
+
* @param {*} value The value to check.
|
|
2098
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
2099
|
+
* @example
|
|
2100
|
+
*
|
|
2101
|
+
* _.isObjectLike({});
|
|
2102
|
+
* // => true
|
|
2103
|
+
*
|
|
2104
|
+
* _.isObjectLike([1, 2, 3]);
|
|
2105
|
+
* // => true
|
|
2106
|
+
*
|
|
2107
|
+
* _.isObjectLike(_.noop);
|
|
2108
|
+
* // => false
|
|
2109
|
+
*
|
|
2110
|
+
* _.isObjectLike(null);
|
|
2111
|
+
* // => false
|
|
2112
|
+
*/
|
|
2113
|
+
function isObjectLike(value) {
|
|
2114
|
+
return value != null && typeof value == 'object';
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
/**
|
|
2118
|
+
* Checks if `value` is classified as a typed array.
|
|
2119
|
+
*
|
|
2120
|
+
* @static
|
|
2121
|
+
* @memberOf _
|
|
2122
|
+
* @since 3.0.0
|
|
2123
|
+
* @category Lang
|
|
2124
|
+
* @param {*} value The value to check.
|
|
2125
|
+
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
2126
|
+
* @example
|
|
2127
|
+
*
|
|
2128
|
+
* _.isTypedArray(new Uint8Array);
|
|
2129
|
+
* // => true
|
|
2130
|
+
*
|
|
2131
|
+
* _.isTypedArray([]);
|
|
2132
|
+
* // => false
|
|
2133
|
+
*/
|
|
2134
|
+
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
|
|
2135
|
+
|
|
2136
|
+
/**
|
|
2137
|
+
* Creates an array of the own enumerable property names of `object`.
|
|
2138
|
+
*
|
|
2139
|
+
* **Note:** Non-object values are coerced to objects. See the
|
|
2140
|
+
* [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
|
2141
|
+
* for more details.
|
|
2142
|
+
*
|
|
2143
|
+
* @static
|
|
2144
|
+
* @since 0.1.0
|
|
2145
|
+
* @memberOf _
|
|
2146
|
+
* @category Object
|
|
2147
|
+
* @param {Object} object The object to query.
|
|
2148
|
+
* @returns {Array} Returns the array of property names.
|
|
2149
|
+
* @example
|
|
2150
|
+
*
|
|
2151
|
+
* function Foo() {
|
|
2152
|
+
* this.a = 1;
|
|
2153
|
+
* this.b = 2;
|
|
2154
|
+
* }
|
|
2155
|
+
*
|
|
2156
|
+
* Foo.prototype.c = 3;
|
|
2157
|
+
*
|
|
2158
|
+
* _.keys(new Foo);
|
|
2159
|
+
* // => ['a', 'b'] (iteration order is not guaranteed)
|
|
2160
|
+
*
|
|
2161
|
+
* _.keys('hi');
|
|
2162
|
+
* // => ['0', '1']
|
|
2163
|
+
*/
|
|
2164
|
+
function keys(object) {
|
|
2165
|
+
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
/**
|
|
2169
|
+
* This method returns a new empty array.
|
|
2170
|
+
*
|
|
2171
|
+
* @static
|
|
2172
|
+
* @memberOf _
|
|
2173
|
+
* @since 4.13.0
|
|
2174
|
+
* @category Util
|
|
2175
|
+
* @returns {Array} Returns the new empty array.
|
|
2176
|
+
* @example
|
|
2177
|
+
*
|
|
2178
|
+
* var arrays = _.times(2, _.stubArray);
|
|
2179
|
+
*
|
|
2180
|
+
* console.log(arrays);
|
|
2181
|
+
* // => [[], []]
|
|
2182
|
+
*
|
|
2183
|
+
* console.log(arrays[0] === arrays[1]);
|
|
2184
|
+
* // => false
|
|
2185
|
+
*/
|
|
2186
|
+
function stubArray() {
|
|
2187
|
+
return [];
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2190
|
+
/**
|
|
2191
|
+
* This method returns `false`.
|
|
2192
|
+
*
|
|
2193
|
+
* @static
|
|
2194
|
+
* @memberOf _
|
|
2195
|
+
* @since 4.13.0
|
|
2196
|
+
* @category Util
|
|
2197
|
+
* @returns {boolean} Returns `false`.
|
|
2198
|
+
* @example
|
|
2199
|
+
*
|
|
2200
|
+
* _.times(2, _.stubFalse);
|
|
2201
|
+
* // => [false, false]
|
|
2202
|
+
*/
|
|
2203
|
+
function stubFalse() {
|
|
2204
|
+
return false;
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
module.exports = isEqual;
|
|
2208
|
+
});
|
|
2209
|
+
|
|
2210
|
+
/**
|
|
2211
|
+
* lodash (Custom Build) <https://lodash.com/>
|
|
2212
|
+
* Build: `lodash modularize exports="npm" -o ./`
|
|
2213
|
+
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
|
2214
|
+
* Released under MIT license <https://lodash.com/license>
|
|
2215
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
2216
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
2217
|
+
*/
|
|
2218
|
+
|
|
2219
|
+
/** Used as references for various `Number` constants. */
|
|
2220
|
+
var INFINITY = 1 / 0,
|
|
2221
|
+
MAX_SAFE_INTEGER = 9007199254740991;
|
|
2222
|
+
|
|
2223
|
+
/** `Object#toString` result references. */
|
|
2224
|
+
var argsTag = '[object Arguments]',
|
|
2225
|
+
funcTag = '[object Function]',
|
|
2226
|
+
genTag = '[object GeneratorFunction]',
|
|
2227
|
+
symbolTag = '[object Symbol]';
|
|
2228
|
+
|
|
2229
|
+
/** Detect free variable `global` from Node.js. */
|
|
2230
|
+
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
2231
|
+
|
|
2232
|
+
/** Detect free variable `self`. */
|
|
2233
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
2234
|
+
|
|
2235
|
+
/** Used as a reference to the global object. */
|
|
2236
|
+
var root = freeGlobal || freeSelf || Function('return this')();
|
|
2237
|
+
|
|
2238
|
+
/**
|
|
2239
|
+
* A faster alternative to `Function#apply`, this function invokes `func`
|
|
2240
|
+
* with the `this` binding of `thisArg` and the arguments of `args`.
|
|
2241
|
+
*
|
|
2242
|
+
* @private
|
|
2243
|
+
* @param {Function} func The function to invoke.
|
|
2244
|
+
* @param {*} thisArg The `this` binding of `func`.
|
|
2245
|
+
* @param {Array} args The arguments to invoke `func` with.
|
|
2246
|
+
* @returns {*} Returns the result of `func`.
|
|
2247
|
+
*/
|
|
2248
|
+
function apply(func, thisArg, args) {
|
|
2249
|
+
switch (args.length) {
|
|
2250
|
+
case 0: return func.call(thisArg);
|
|
2251
|
+
case 1: return func.call(thisArg, args[0]);
|
|
2252
|
+
case 2: return func.call(thisArg, args[0], args[1]);
|
|
2253
|
+
case 3: return func.call(thisArg, args[0], args[1], args[2]);
|
|
2254
|
+
}
|
|
2255
|
+
return func.apply(thisArg, args);
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
/**
|
|
2259
|
+
* A specialized version of `_.map` for arrays without support for iteratee
|
|
2260
|
+
* shorthands.
|
|
2261
|
+
*
|
|
2262
|
+
* @private
|
|
2263
|
+
* @param {Array} [array] The array to iterate over.
|
|
2264
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
2265
|
+
* @returns {Array} Returns the new mapped array.
|
|
2266
|
+
*/
|
|
2267
|
+
function arrayMap(array, iteratee) {
|
|
2268
|
+
var index = -1,
|
|
2269
|
+
length = array ? array.length : 0,
|
|
2270
|
+
result = Array(length);
|
|
2271
|
+
|
|
2272
|
+
while (++index < length) {
|
|
2273
|
+
result[index] = iteratee(array[index], index, array);
|
|
2274
|
+
}
|
|
2275
|
+
return result;
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2278
|
+
/**
|
|
2279
|
+
* Appends the elements of `values` to `array`.
|
|
2280
|
+
*
|
|
2281
|
+
* @private
|
|
2282
|
+
* @param {Array} array The array to modify.
|
|
2283
|
+
* @param {Array} values The values to append.
|
|
2284
|
+
* @returns {Array} Returns `array`.
|
|
2285
|
+
*/
|
|
2286
|
+
function arrayPush(array, values) {
|
|
2287
|
+
var index = -1,
|
|
2288
|
+
length = values.length,
|
|
2289
|
+
offset = array.length;
|
|
2290
|
+
|
|
2291
|
+
while (++index < length) {
|
|
2292
|
+
array[offset + index] = values[index];
|
|
2293
|
+
}
|
|
2294
|
+
return array;
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
/** Used for built-in method references. */
|
|
2298
|
+
var objectProto = Object.prototype;
|
|
2299
|
+
|
|
2300
|
+
/** Used to check objects for own properties. */
|
|
2301
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
2302
|
+
|
|
2303
|
+
/**
|
|
2304
|
+
* Used to resolve the
|
|
2305
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
2306
|
+
* of values.
|
|
2307
|
+
*/
|
|
2308
|
+
var objectToString = objectProto.toString;
|
|
2309
|
+
|
|
2310
|
+
/** Built-in value references. */
|
|
2311
|
+
var Symbol = root.Symbol,
|
|
2312
|
+
propertyIsEnumerable = objectProto.propertyIsEnumerable,
|
|
2313
|
+
spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
|
|
2314
|
+
|
|
2315
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
2316
|
+
var nativeMax = Math.max;
|
|
2317
|
+
|
|
2318
|
+
/**
|
|
2319
|
+
* The base implementation of `_.flatten` with support for restricting flattening.
|
|
2320
|
+
*
|
|
2321
|
+
* @private
|
|
2322
|
+
* @param {Array} array The array to flatten.
|
|
2323
|
+
* @param {number} depth The maximum recursion depth.
|
|
2324
|
+
* @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
|
|
2325
|
+
* @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
|
|
2326
|
+
* @param {Array} [result=[]] The initial result value.
|
|
2327
|
+
* @returns {Array} Returns the new flattened array.
|
|
2328
|
+
*/
|
|
2329
|
+
function baseFlatten(array, depth, predicate, isStrict, result) {
|
|
2330
|
+
var index = -1,
|
|
2331
|
+
length = array.length;
|
|
2332
|
+
|
|
2333
|
+
predicate || (predicate = isFlattenable);
|
|
2334
|
+
result || (result = []);
|
|
2335
|
+
|
|
2336
|
+
while (++index < length) {
|
|
2337
|
+
var value = array[index];
|
|
2338
|
+
if (depth > 0 && predicate(value)) {
|
|
2339
|
+
if (depth > 1) {
|
|
2340
|
+
// Recursively flatten arrays (susceptible to call stack limits).
|
|
2341
|
+
baseFlatten(value, depth - 1, predicate, isStrict, result);
|
|
2342
|
+
} else {
|
|
2343
|
+
arrayPush(result, value);
|
|
2344
|
+
}
|
|
2345
|
+
} else if (!isStrict) {
|
|
2346
|
+
result[result.length] = value;
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
return result;
|
|
2350
|
+
}
|
|
2351
|
+
|
|
2352
|
+
/**
|
|
2353
|
+
* The base implementation of `_.pick` without support for individual
|
|
2354
|
+
* property identifiers.
|
|
2355
|
+
*
|
|
2356
|
+
* @private
|
|
2357
|
+
* @param {Object} object The source object.
|
|
2358
|
+
* @param {string[]} props The property identifiers to pick.
|
|
2359
|
+
* @returns {Object} Returns the new object.
|
|
2360
|
+
*/
|
|
2361
|
+
function basePick(object, props) {
|
|
2362
|
+
object = Object(object);
|
|
2363
|
+
return basePickBy(object, props, function(value, key) {
|
|
2364
|
+
return key in object;
|
|
2365
|
+
});
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
/**
|
|
2369
|
+
* The base implementation of `_.pickBy` without support for iteratee shorthands.
|
|
2370
|
+
*
|
|
2371
|
+
* @private
|
|
2372
|
+
* @param {Object} object The source object.
|
|
2373
|
+
* @param {string[]} props The property identifiers to pick from.
|
|
2374
|
+
* @param {Function} predicate The function invoked per property.
|
|
2375
|
+
* @returns {Object} Returns the new object.
|
|
2376
|
+
*/
|
|
2377
|
+
function basePickBy(object, props, predicate) {
|
|
2378
|
+
var index = -1,
|
|
2379
|
+
length = props.length,
|
|
2380
|
+
result = {};
|
|
2381
|
+
|
|
2382
|
+
while (++index < length) {
|
|
2383
|
+
var key = props[index],
|
|
2384
|
+
value = object[key];
|
|
2385
|
+
|
|
2386
|
+
if (predicate(value, key)) {
|
|
2387
|
+
result[key] = value;
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
return result;
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
/**
|
|
2394
|
+
* The base implementation of `_.rest` which doesn't validate or coerce arguments.
|
|
2395
|
+
*
|
|
2396
|
+
* @private
|
|
2397
|
+
* @param {Function} func The function to apply a rest parameter to.
|
|
2398
|
+
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
|
2399
|
+
* @returns {Function} Returns the new function.
|
|
2400
|
+
*/
|
|
2401
|
+
function baseRest(func, start) {
|
|
2402
|
+
start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
|
|
2403
|
+
return function() {
|
|
2404
|
+
var args = arguments,
|
|
2405
|
+
index = -1,
|
|
2406
|
+
length = nativeMax(args.length - start, 0),
|
|
2407
|
+
array = Array(length);
|
|
2408
|
+
|
|
2409
|
+
while (++index < length) {
|
|
2410
|
+
array[index] = args[start + index];
|
|
2411
|
+
}
|
|
2412
|
+
index = -1;
|
|
2413
|
+
var otherArgs = Array(start + 1);
|
|
2414
|
+
while (++index < start) {
|
|
2415
|
+
otherArgs[index] = args[index];
|
|
2416
|
+
}
|
|
2417
|
+
otherArgs[start] = array;
|
|
2418
|
+
return apply(func, this, otherArgs);
|
|
2419
|
+
};
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
/**
|
|
2423
|
+
* Checks if `value` is a flattenable `arguments` object or array.
|
|
2424
|
+
*
|
|
2425
|
+
* @private
|
|
2426
|
+
* @param {*} value The value to check.
|
|
2427
|
+
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
|
|
2428
|
+
*/
|
|
2429
|
+
function isFlattenable(value) {
|
|
2430
|
+
return isArray(value) || isArguments(value) ||
|
|
2431
|
+
!!(spreadableSymbol && value && value[spreadableSymbol]);
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2434
|
+
/**
|
|
2435
|
+
* Converts `value` to a string key if it's not a string or symbol.
|
|
2436
|
+
*
|
|
2437
|
+
* @private
|
|
2438
|
+
* @param {*} value The value to inspect.
|
|
2439
|
+
* @returns {string|symbol} Returns the key.
|
|
2440
|
+
*/
|
|
2441
|
+
function toKey(value) {
|
|
2442
|
+
if (typeof value == 'string' || isSymbol(value)) {
|
|
2443
|
+
return value;
|
|
2444
|
+
}
|
|
2445
|
+
var result = (value + '');
|
|
2446
|
+
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
/**
|
|
2450
|
+
* Checks if `value` is likely an `arguments` object.
|
|
2451
|
+
*
|
|
2452
|
+
* @static
|
|
2453
|
+
* @memberOf _
|
|
2454
|
+
* @since 0.1.0
|
|
2455
|
+
* @category Lang
|
|
2456
|
+
* @param {*} value The value to check.
|
|
2457
|
+
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
2458
|
+
* else `false`.
|
|
2459
|
+
* @example
|
|
2460
|
+
*
|
|
2461
|
+
* _.isArguments(function() { return arguments; }());
|
|
2462
|
+
* // => true
|
|
2463
|
+
*
|
|
2464
|
+
* _.isArguments([1, 2, 3]);
|
|
2465
|
+
* // => false
|
|
2466
|
+
*/
|
|
2467
|
+
function isArguments(value) {
|
|
2468
|
+
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
|
|
2469
|
+
return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
|
|
2470
|
+
(!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
/**
|
|
2474
|
+
* Checks if `value` is classified as an `Array` object.
|
|
2475
|
+
*
|
|
2476
|
+
* @static
|
|
2477
|
+
* @memberOf _
|
|
2478
|
+
* @since 0.1.0
|
|
2479
|
+
* @category Lang
|
|
2480
|
+
* @param {*} value The value to check.
|
|
2481
|
+
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
2482
|
+
* @example
|
|
2483
|
+
*
|
|
2484
|
+
* _.isArray([1, 2, 3]);
|
|
2485
|
+
* // => true
|
|
2486
|
+
*
|
|
2487
|
+
* _.isArray(document.body.children);
|
|
2488
|
+
* // => false
|
|
2489
|
+
*
|
|
2490
|
+
* _.isArray('abc');
|
|
2491
|
+
* // => false
|
|
2492
|
+
*
|
|
2493
|
+
* _.isArray(_.noop);
|
|
2494
|
+
* // => false
|
|
2495
|
+
*/
|
|
2496
|
+
var isArray = Array.isArray;
|
|
2497
|
+
|
|
2498
|
+
/**
|
|
2499
|
+
* Checks if `value` is array-like. A value is considered array-like if it's
|
|
2500
|
+
* not a function and has a `value.length` that's an integer greater than or
|
|
2501
|
+
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
|
2502
|
+
*
|
|
2503
|
+
* @static
|
|
2504
|
+
* @memberOf _
|
|
2505
|
+
* @since 4.0.0
|
|
2506
|
+
* @category Lang
|
|
2507
|
+
* @param {*} value The value to check.
|
|
2508
|
+
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
|
2509
|
+
* @example
|
|
2510
|
+
*
|
|
2511
|
+
* _.isArrayLike([1, 2, 3]);
|
|
2512
|
+
* // => true
|
|
2513
|
+
*
|
|
2514
|
+
* _.isArrayLike(document.body.children);
|
|
2515
|
+
* // => true
|
|
2516
|
+
*
|
|
2517
|
+
* _.isArrayLike('abc');
|
|
2518
|
+
* // => true
|
|
2519
|
+
*
|
|
2520
|
+
* _.isArrayLike(_.noop);
|
|
2521
|
+
* // => false
|
|
2522
|
+
*/
|
|
2523
|
+
function isArrayLike(value) {
|
|
2524
|
+
return value != null && isLength(value.length) && !isFunction(value);
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
/**
|
|
2528
|
+
* This method is like `_.isArrayLike` except that it also checks if `value`
|
|
2529
|
+
* is an object.
|
|
2530
|
+
*
|
|
2531
|
+
* @static
|
|
2532
|
+
* @memberOf _
|
|
2533
|
+
* @since 4.0.0
|
|
2534
|
+
* @category Lang
|
|
2535
|
+
* @param {*} value The value to check.
|
|
2536
|
+
* @returns {boolean} Returns `true` if `value` is an array-like object,
|
|
2537
|
+
* else `false`.
|
|
2538
|
+
* @example
|
|
2539
|
+
*
|
|
2540
|
+
* _.isArrayLikeObject([1, 2, 3]);
|
|
2541
|
+
* // => true
|
|
2542
|
+
*
|
|
2543
|
+
* _.isArrayLikeObject(document.body.children);
|
|
2544
|
+
* // => true
|
|
2545
|
+
*
|
|
2546
|
+
* _.isArrayLikeObject('abc');
|
|
2547
|
+
* // => false
|
|
2548
|
+
*
|
|
2549
|
+
* _.isArrayLikeObject(_.noop);
|
|
2550
|
+
* // => false
|
|
2551
|
+
*/
|
|
2552
|
+
function isArrayLikeObject(value) {
|
|
2553
|
+
return isObjectLike(value) && isArrayLike(value);
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2556
|
+
/**
|
|
2557
|
+
* Checks if `value` is classified as a `Function` object.
|
|
2558
|
+
*
|
|
2559
|
+
* @static
|
|
2560
|
+
* @memberOf _
|
|
2561
|
+
* @since 0.1.0
|
|
2562
|
+
* @category Lang
|
|
2563
|
+
* @param {*} value The value to check.
|
|
2564
|
+
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
2565
|
+
* @example
|
|
2566
|
+
*
|
|
2567
|
+
* _.isFunction(_);
|
|
2568
|
+
* // => true
|
|
2569
|
+
*
|
|
2570
|
+
* _.isFunction(/abc/);
|
|
2571
|
+
* // => false
|
|
2572
|
+
*/
|
|
2573
|
+
function isFunction(value) {
|
|
2574
|
+
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
2575
|
+
// in Safari 8-9 which returns 'object' for typed array and other constructors.
|
|
2576
|
+
var tag = isObject(value) ? objectToString.call(value) : '';
|
|
2577
|
+
return tag == funcTag || tag == genTag;
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2580
|
+
/**
|
|
2581
|
+
* Checks if `value` is a valid array-like length.
|
|
2582
|
+
*
|
|
2583
|
+
* **Note:** This method is loosely based on
|
|
2584
|
+
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|
2585
|
+
*
|
|
2586
|
+
* @static
|
|
2587
|
+
* @memberOf _
|
|
2588
|
+
* @since 4.0.0
|
|
2589
|
+
* @category Lang
|
|
2590
|
+
* @param {*} value The value to check.
|
|
2591
|
+
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|
2592
|
+
* @example
|
|
2593
|
+
*
|
|
2594
|
+
* _.isLength(3);
|
|
2595
|
+
* // => true
|
|
2596
|
+
*
|
|
2597
|
+
* _.isLength(Number.MIN_VALUE);
|
|
2598
|
+
* // => false
|
|
2599
|
+
*
|
|
2600
|
+
* _.isLength(Infinity);
|
|
2601
|
+
* // => false
|
|
2602
|
+
*
|
|
2603
|
+
* _.isLength('3');
|
|
2604
|
+
* // => false
|
|
2605
|
+
*/
|
|
2606
|
+
function isLength(value) {
|
|
2607
|
+
return typeof value == 'number' &&
|
|
2608
|
+
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
2609
|
+
}
|
|
2610
|
+
|
|
2611
|
+
/**
|
|
2612
|
+
* Checks if `value` is the
|
|
2613
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
2614
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
2615
|
+
*
|
|
2616
|
+
* @static
|
|
2617
|
+
* @memberOf _
|
|
2618
|
+
* @since 0.1.0
|
|
2619
|
+
* @category Lang
|
|
2620
|
+
* @param {*} value The value to check.
|
|
2621
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
2622
|
+
* @example
|
|
2623
|
+
*
|
|
2624
|
+
* _.isObject({});
|
|
2625
|
+
* // => true
|
|
2626
|
+
*
|
|
2627
|
+
* _.isObject([1, 2, 3]);
|
|
2628
|
+
* // => true
|
|
2629
|
+
*
|
|
2630
|
+
* _.isObject(_.noop);
|
|
2631
|
+
* // => true
|
|
2632
|
+
*
|
|
2633
|
+
* _.isObject(null);
|
|
2634
|
+
* // => false
|
|
2635
|
+
*/
|
|
2636
|
+
function isObject(value) {
|
|
2637
|
+
var type = typeof value;
|
|
2638
|
+
return !!value && (type == 'object' || type == 'function');
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
/**
|
|
2642
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
2643
|
+
* and has a `typeof` result of "object".
|
|
2644
|
+
*
|
|
2645
|
+
* @static
|
|
2646
|
+
* @memberOf _
|
|
2647
|
+
* @since 4.0.0
|
|
2648
|
+
* @category Lang
|
|
2649
|
+
* @param {*} value The value to check.
|
|
2650
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
2651
|
+
* @example
|
|
2652
|
+
*
|
|
2653
|
+
* _.isObjectLike({});
|
|
2654
|
+
* // => true
|
|
2655
|
+
*
|
|
2656
|
+
* _.isObjectLike([1, 2, 3]);
|
|
2657
|
+
* // => true
|
|
2658
|
+
*
|
|
2659
|
+
* _.isObjectLike(_.noop);
|
|
2660
|
+
* // => false
|
|
2661
|
+
*
|
|
2662
|
+
* _.isObjectLike(null);
|
|
2663
|
+
* // => false
|
|
2664
|
+
*/
|
|
2665
|
+
function isObjectLike(value) {
|
|
2666
|
+
return !!value && typeof value == 'object';
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2669
|
+
/**
|
|
2670
|
+
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
2671
|
+
*
|
|
2672
|
+
* @static
|
|
2673
|
+
* @memberOf _
|
|
2674
|
+
* @since 4.0.0
|
|
2675
|
+
* @category Lang
|
|
2676
|
+
* @param {*} value The value to check.
|
|
2677
|
+
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
2678
|
+
* @example
|
|
2679
|
+
*
|
|
2680
|
+
* _.isSymbol(Symbol.iterator);
|
|
2681
|
+
* // => true
|
|
2682
|
+
*
|
|
2683
|
+
* _.isSymbol('abc');
|
|
2684
|
+
* // => false
|
|
2685
|
+
*/
|
|
2686
|
+
function isSymbol(value) {
|
|
2687
|
+
return typeof value == 'symbol' ||
|
|
2688
|
+
(isObjectLike(value) && objectToString.call(value) == symbolTag);
|
|
2689
|
+
}
|
|
2690
|
+
|
|
2691
|
+
/**
|
|
2692
|
+
* Creates an object composed of the picked `object` properties.
|
|
2693
|
+
*
|
|
2694
|
+
* @static
|
|
2695
|
+
* @since 0.1.0
|
|
2696
|
+
* @memberOf _
|
|
2697
|
+
* @category Object
|
|
2698
|
+
* @param {Object} object The source object.
|
|
2699
|
+
* @param {...(string|string[])} [props] The property identifiers to pick.
|
|
2700
|
+
* @returns {Object} Returns the new object.
|
|
2701
|
+
* @example
|
|
2702
|
+
*
|
|
2703
|
+
* var object = { 'a': 1, 'b': '2', 'c': 3 };
|
|
2704
|
+
*
|
|
2705
|
+
* _.pick(object, ['a', 'c']);
|
|
2706
|
+
* // => { 'a': 1, 'c': 3 }
|
|
2707
|
+
*/
|
|
2708
|
+
var pick = baseRest(function(object, props) {
|
|
2709
|
+
return object == null ? {} : basePick(object, arrayMap(baseFlatten(props, 1), toKey));
|
|
2710
|
+
});
|
|
2711
|
+
|
|
2712
|
+
var lodash_pick = pick;
|
|
2713
|
+
|
|
2714
|
+
function useFetchZones(params) {
|
|
2715
|
+
const [fetchZones, resource] = adminServices.useResource({
|
|
2716
|
+
fetchResource: getZones,
|
|
2717
|
+
initialValue: [],
|
|
2718
|
+
context: params.context,
|
|
2719
|
+
resourceName: 'Banner zones',
|
|
2720
|
+
});
|
|
2721
|
+
compositionApi.onMounted(() => {
|
|
2722
|
+
fetchZones();
|
|
2723
|
+
});
|
|
2724
|
+
return resource;
|
|
2725
|
+
}
|
|
2726
|
+
|
|
2727
|
+
var Status;
|
|
2728
|
+
(function (Status) {
|
|
2729
|
+
Status["Waiting"] = "WAITING";
|
|
2730
|
+
Status["Archived"] = "ARCHIVED";
|
|
2731
|
+
Status["Active"] = "ACTIVE";
|
|
2732
|
+
Status["Disabled"] = "DISABLED";
|
|
2733
|
+
})(Status || (Status = {}));
|
|
2734
|
+
|
|
2735
|
+
function getStatus(type, t) {
|
|
2736
|
+
switch (type) {
|
|
2737
|
+
case Status.Waiting:
|
|
2738
|
+
return t('banners:statuses.waiting');
|
|
2739
|
+
case Status.Archived:
|
|
2740
|
+
return t('banners:statuses.archived');
|
|
2741
|
+
case Status.Active:
|
|
2742
|
+
return t('banners:statuses.active');
|
|
2743
|
+
case Status.Disabled:
|
|
2744
|
+
return t('banners:statuses.disabled');
|
|
2745
|
+
default:
|
|
2746
|
+
return '';
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
function getColumnDefs$1(t) {
|
|
2750
|
+
return [
|
|
2751
|
+
{
|
|
2752
|
+
id: 0,
|
|
2753
|
+
name: '#',
|
|
2754
|
+
field: 'id',
|
|
2755
|
+
style: { width: '50px', textAlign: 'center' },
|
|
2756
|
+
headStyle: { width: '50px', textAlign: 'center' },
|
|
693
2757
|
},
|
|
694
|
-
|
|
695
|
-
|
|
2758
|
+
{
|
|
2759
|
+
id: 1,
|
|
2760
|
+
name: t('banners:zone'),
|
|
2761
|
+
field: 'bannerZone',
|
|
2762
|
+
format: ({ row }) => row.bannerZone ? row.bannerZone : t('banners:bannerZoneIsDeleted'),
|
|
696
2763
|
},
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
2764
|
+
{
|
|
2765
|
+
id: 2,
|
|
2766
|
+
name: t('banners:status'),
|
|
2767
|
+
field: 'status',
|
|
2768
|
+
format: ({ row }) => getStatus(row.status, t),
|
|
2769
|
+
style: { width: '120px' },
|
|
2770
|
+
headStyle: { width: '120px' },
|
|
701
2771
|
},
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
refreshBannerItemList() {
|
|
708
|
-
this.isRowDataLoading = true;
|
|
709
|
-
return getBannerAreaByAlias(this.areaAlias)
|
|
710
|
-
.then((response) => {
|
|
711
|
-
this.bannerArea = response.data;
|
|
712
|
-
return getBannerItemList(this.bannerArea.id);
|
|
713
|
-
})
|
|
714
|
-
.then((response) => {
|
|
715
|
-
this.rowData = response.data;
|
|
716
|
-
this.errorMessage = null;
|
|
717
|
-
})
|
|
718
|
-
.catch((error) => {
|
|
719
|
-
console.error(error);
|
|
720
|
-
this.rowData = [];
|
|
721
|
-
this.errorMessage = adminServices.getMessageFromError(error);
|
|
722
|
-
})
|
|
723
|
-
.finally(() => {
|
|
724
|
-
this.isRowDataLoading = false;
|
|
725
|
-
});
|
|
2772
|
+
{
|
|
2773
|
+
id: 3,
|
|
2774
|
+
name: t('banners:period'),
|
|
2775
|
+
field: 'dateStart',
|
|
2776
|
+
format: ({ row }) => `${row.dateStart ? `${t('banners:from')} ${row.dateStart}` : ''} ${row.dateEnd ? `${t('banners:to')} ${row.dateEnd}` : ''}`,
|
|
726
2777
|
},
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
return this.refreshBannerItemList();
|
|
733
|
-
}
|
|
734
|
-
})
|
|
735
|
-
.catch(console.error)
|
|
736
|
-
.finally(() => {
|
|
737
|
-
this.isBannerItemMoving = false;
|
|
738
|
-
});
|
|
2778
|
+
{
|
|
2779
|
+
id: 4,
|
|
2780
|
+
name: t('banners:image'),
|
|
2781
|
+
field: 'image',
|
|
2782
|
+
type: 'image',
|
|
739
2783
|
},
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
variant: 'danger',
|
|
759
|
-
title: 'Error',
|
|
760
|
-
body: 'Banner Item deletion was failed',
|
|
761
|
-
});
|
|
762
|
-
}
|
|
763
|
-
})
|
|
764
|
-
.catch((error) => {
|
|
765
|
-
console.error(error);
|
|
766
|
-
this.$toast({
|
|
767
|
-
variant: 'danger',
|
|
768
|
-
title: 'Error',
|
|
769
|
-
body: 'Banner Item deletion was failed',
|
|
770
|
-
});
|
|
2784
|
+
{
|
|
2785
|
+
id: 5,
|
|
2786
|
+
name: t('banners:link'),
|
|
2787
|
+
field: 'link',
|
|
2788
|
+
type: 'name',
|
|
2789
|
+
format: ({ row }) => {
|
|
2790
|
+
var _a, _b;
|
|
2791
|
+
return ({
|
|
2792
|
+
adminLink: {
|
|
2793
|
+
url: (_a = row.link) !== null && _a !== void 0 ? _a : '',
|
|
2794
|
+
text: (_b = row.link) !== null && _b !== void 0 ? _b : '',
|
|
2795
|
+
},
|
|
2796
|
+
paramList: [
|
|
2797
|
+
{
|
|
2798
|
+
name: t('banners:newTab'),
|
|
2799
|
+
value: row.openNewTab ? t('banners:yes') : t('banners:no'),
|
|
2800
|
+
},
|
|
2801
|
+
],
|
|
771
2802
|
});
|
|
772
|
-
}
|
|
2803
|
+
},
|
|
773
2804
|
},
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
2805
|
+
{
|
|
2806
|
+
id: 6,
|
|
2807
|
+
name: t('banners:comment'),
|
|
2808
|
+
field: 'comment',
|
|
2809
|
+
},
|
|
2810
|
+
{
|
|
2811
|
+
id: 7,
|
|
2812
|
+
name: t('banners:actions'),
|
|
2813
|
+
field: 'actions',
|
|
2814
|
+
style: { whiteSpace: 'nowrap', width: '100px' },
|
|
2815
|
+
headStyle: { whiteSpace: 'nowrap', width: '100px' },
|
|
780
2816
|
},
|
|
2817
|
+
];
|
|
2818
|
+
}
|
|
2819
|
+
|
|
2820
|
+
var FilterTypes;
|
|
2821
|
+
(function (FilterTypes) {
|
|
2822
|
+
FilterTypes["Zone"] = "zone";
|
|
2823
|
+
FilterTypes["Date"] = "date";
|
|
2824
|
+
FilterTypes["Status"] = "status";
|
|
2825
|
+
})(FilterTypes || (FilterTypes = {}));
|
|
2826
|
+
function useAdvancedSearch({ context, t, zoneList }) {
|
|
2827
|
+
/** Zone **/
|
|
2828
|
+
const zonesOptionList = compositionApi.computed(() => zoneList.value.map(({ id, name }) => ({
|
|
2829
|
+
value: id,
|
|
2830
|
+
label: name,
|
|
2831
|
+
})));
|
|
2832
|
+
const initialZoneFilter = compositionApi.computed(() => {
|
|
2833
|
+
const queryValue = adminUi.getFilterParamAsStringArray(context.root.$route.query, FilterTypes.Zone);
|
|
2834
|
+
return zonesOptionList.value.filter(({ value }) => queryValue.some((selected) => selected === value));
|
|
2835
|
+
});
|
|
2836
|
+
const zoneFilter = compositionApi.ref(initialZoneFilter.value);
|
|
2837
|
+
compositionApi.watch(initialZoneFilter, () => {
|
|
2838
|
+
zoneFilter.value = initialZoneFilter.value;
|
|
2839
|
+
});
|
|
2840
|
+
/** Date **/
|
|
2841
|
+
const initialDateFilter = compositionApi.computed(() => { var _a; return (_a = adminUi.getFilterParamAsString(context.root.$route.query, FilterTypes.Date)) !== null && _a !== void 0 ? _a : ''; });
|
|
2842
|
+
const dateFilter = compositionApi.ref(initialDateFilter.value);
|
|
2843
|
+
compositionApi.watch(initialDateFilter, () => {
|
|
2844
|
+
dateFilter.value = initialDateFilter.value;
|
|
2845
|
+
});
|
|
2846
|
+
/** Status **/
|
|
2847
|
+
const statusesOptionList = compositionApi.computed(() => Object.entries(Status).map(([_, value]) => ({
|
|
2848
|
+
value: value,
|
|
2849
|
+
label: getStatus(value, t),
|
|
2850
|
+
})));
|
|
2851
|
+
const initialStatusFilter = compositionApi.computed(() => {
|
|
2852
|
+
const queryValue = adminUi.getFilterParamAsStringArray(context.root.$route.query, FilterTypes.Status);
|
|
2853
|
+
return statusesOptionList.value.filter(({ value }) => queryValue.some((selected) => selected === value));
|
|
2854
|
+
});
|
|
2855
|
+
const statusFilter = compositionApi.ref(initialStatusFilter.value);
|
|
2856
|
+
compositionApi.watch(initialStatusFilter, () => {
|
|
2857
|
+
statusFilter.value = initialStatusFilter.value;
|
|
2858
|
+
});
|
|
2859
|
+
/** Params **/
|
|
2860
|
+
const filterParams = compositionApi.computed(() => adminUi.getFilterParams({
|
|
2861
|
+
[FilterTypes.Zone]: zoneFilter.value.map(({ value }) => value),
|
|
2862
|
+
[FilterTypes.Date]: dateFilter.value,
|
|
2863
|
+
[FilterTypes.Status]: statusFilter.value.map(({ value }) => value),
|
|
2864
|
+
}));
|
|
2865
|
+
/** Tag removal handler **/
|
|
2866
|
+
const tagRemovalHandler = (event) => {
|
|
2867
|
+
if (event.name === FilterTypes.Zone) {
|
|
2868
|
+
zoneFilter.value = zoneFilter.value.filter(({ value }) => value !== event.value);
|
|
2869
|
+
}
|
|
2870
|
+
if (event.name === FilterTypes.Date) {
|
|
2871
|
+
dateFilter.value = '';
|
|
2872
|
+
}
|
|
2873
|
+
if (event.name === FilterTypes.Status) {
|
|
2874
|
+
statusFilter.value = statusFilter.value.filter(({ value }) => value !== event.value);
|
|
2875
|
+
}
|
|
2876
|
+
};
|
|
2877
|
+
/** Tags **/
|
|
2878
|
+
const tags = compositionApi.computed(() => []);
|
|
2879
|
+
return {
|
|
2880
|
+
zoneFilter,
|
|
2881
|
+
zonesOptionList,
|
|
2882
|
+
dateFilter,
|
|
2883
|
+
statusFilter,
|
|
2884
|
+
statusesOptionList,
|
|
2885
|
+
filterParams,
|
|
2886
|
+
tags,
|
|
2887
|
+
tagRemovalHandler,
|
|
2888
|
+
};
|
|
2889
|
+
}
|
|
2890
|
+
|
|
2891
|
+
var script$1 = compositionApi.defineComponent({
|
|
2892
|
+
name: 'BannerList',
|
|
2893
|
+
setup(props, context) {
|
|
2894
|
+
const { t } = adminUi.useTranslation(context);
|
|
2895
|
+
const { loading: isZonesLoading, data: zoneList } = useFetchZones({
|
|
2896
|
+
context,
|
|
2897
|
+
});
|
|
2898
|
+
const { zoneFilter, zonesOptionList, dateFilter, statusFilter, statusesOptionList, filterParams, tags, tagRemovalHandler, } = useAdvancedSearch({
|
|
2899
|
+
context,
|
|
2900
|
+
t,
|
|
2901
|
+
zoneList,
|
|
2902
|
+
});
|
|
2903
|
+
const { fetchEntityList: fetchBanners, isLoading: isBannersLoading, rowData, errorMessage, handleChange, searchQuery, pageNumber, pageCount, pageSize, } = adminUi.useDataTable({
|
|
2904
|
+
fetchEntityList: (params) => getBanners(Object.assign({ query: params.searchQuery, pageNumber: params.pageNumber, pageSize: params.pageSize }, filterParams.value)),
|
|
2905
|
+
initialValue: [],
|
|
2906
|
+
context,
|
|
2907
|
+
resourceName: 'Banners',
|
|
2908
|
+
});
|
|
2909
|
+
compositionApi.watch(filterParams, () => {
|
|
2910
|
+
if (isZonesLoading.value) {
|
|
2911
|
+
return;
|
|
2912
|
+
}
|
|
2913
|
+
const newQuery = Object.assign(Object.assign({}, lodash_pick(context.root.$route.query, ['query', 'pageNumber'])), filterParams.value);
|
|
2914
|
+
if (!lodash_isequal(context.root.$route.query, newQuery)) {
|
|
2915
|
+
context.root.$router.replace({ query: newQuery });
|
|
2916
|
+
fetchBanners();
|
|
2917
|
+
}
|
|
2918
|
+
});
|
|
2919
|
+
const { isDeleting, handleResourceDelete } = adminServices.useResourceDelete({
|
|
2920
|
+
deleteResource: deleteBanner,
|
|
2921
|
+
resourceName: 'Banner',
|
|
2922
|
+
onSuccess: fetchBanners,
|
|
2923
|
+
context,
|
|
2924
|
+
});
|
|
2925
|
+
const isBusy = (bannerId) => {
|
|
2926
|
+
return isDeleting(bannerId) || isBannersLoading.value;
|
|
2927
|
+
};
|
|
2928
|
+
const columnDefs = compositionApi.computed(() => getColumnDefs$1(context.root.$t));
|
|
2929
|
+
const isRowDataLoading = compositionApi.computed(() => isBannersLoading.value || isZonesLoading.value);
|
|
2930
|
+
return {
|
|
2931
|
+
columnDefs,
|
|
2932
|
+
isRowDataLoading,
|
|
2933
|
+
rowData,
|
|
2934
|
+
errorMessage,
|
|
2935
|
+
handleChange,
|
|
2936
|
+
getBannersBannerFormUrl,
|
|
2937
|
+
searchQuery,
|
|
2938
|
+
pageNumber,
|
|
2939
|
+
pageCount,
|
|
2940
|
+
pageSize,
|
|
2941
|
+
isBusy,
|
|
2942
|
+
handleResourceDelete,
|
|
2943
|
+
// Advanced search
|
|
2944
|
+
zoneFilter,
|
|
2945
|
+
zonesOptionList,
|
|
2946
|
+
dateFilter,
|
|
2947
|
+
statusFilter,
|
|
2948
|
+
statusesOptionList,
|
|
2949
|
+
tags,
|
|
2950
|
+
tagRemovalHandler,
|
|
2951
|
+
};
|
|
781
2952
|
},
|
|
782
2953
|
});
|
|
783
2954
|
|
|
2955
|
+
const isOldIE = typeof navigator !== 'undefined' &&
|
|
2956
|
+
/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
|
|
2957
|
+
function createInjector(context) {
|
|
2958
|
+
return (id, style) => addStyle(id, style);
|
|
2959
|
+
}
|
|
2960
|
+
let HEAD;
|
|
2961
|
+
const styles = {};
|
|
2962
|
+
function addStyle(id, css) {
|
|
2963
|
+
const group = isOldIE ? css.media || 'default' : id;
|
|
2964
|
+
const style = styles[group] || (styles[group] = { ids: new Set(), styles: [] });
|
|
2965
|
+
if (!style.ids.has(id)) {
|
|
2966
|
+
style.ids.add(id);
|
|
2967
|
+
let code = css.source;
|
|
2968
|
+
if (css.map) {
|
|
2969
|
+
// https://developer.chrome.com/devtools/docs/javascript-debugging
|
|
2970
|
+
// this makes source maps inside style tags work properly in Chrome
|
|
2971
|
+
code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
|
|
2972
|
+
// http://stackoverflow.com/a/26603875
|
|
2973
|
+
code +=
|
|
2974
|
+
'\n/*# sourceMappingURL=data:application/json;base64,' +
|
|
2975
|
+
btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) +
|
|
2976
|
+
' */';
|
|
2977
|
+
}
|
|
2978
|
+
if (!style.element) {
|
|
2979
|
+
style.element = document.createElement('style');
|
|
2980
|
+
style.element.type = 'text/css';
|
|
2981
|
+
if (css.media)
|
|
2982
|
+
style.element.setAttribute('media', css.media);
|
|
2983
|
+
if (HEAD === undefined) {
|
|
2984
|
+
HEAD = document.head || document.getElementsByTagName('head')[0];
|
|
2985
|
+
}
|
|
2986
|
+
HEAD.appendChild(style.element);
|
|
2987
|
+
}
|
|
2988
|
+
if ('styleSheet' in style.element) {
|
|
2989
|
+
style.styles.push(code);
|
|
2990
|
+
style.element.styleSheet.cssText = style.styles
|
|
2991
|
+
.filter(Boolean)
|
|
2992
|
+
.join('\n');
|
|
2993
|
+
}
|
|
2994
|
+
else {
|
|
2995
|
+
const index = style.ids.size - 1;
|
|
2996
|
+
const textNode = document.createTextNode(code);
|
|
2997
|
+
const nodes = style.element.childNodes;
|
|
2998
|
+
if (nodes[index])
|
|
2999
|
+
style.element.removeChild(nodes[index]);
|
|
3000
|
+
if (nodes.length)
|
|
3001
|
+
style.element.insertBefore(textNode, nodes[index]);
|
|
3002
|
+
else
|
|
3003
|
+
style.element.appendChild(textNode);
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
|
|
784
3008
|
/* script */
|
|
785
|
-
const __vue_script__$
|
|
3009
|
+
const __vue_script__$1 = script$1;
|
|
786
3010
|
|
|
787
3011
|
/* template */
|
|
788
|
-
var __vue_render__$
|
|
3012
|
+
var __vue_render__$1 = function () {
|
|
789
3013
|
var _vm = this;
|
|
790
3014
|
var _h = _vm.$createElement;
|
|
791
3015
|
var _c = _vm._self._c || _h;
|
|
792
3016
|
return _c("page", {
|
|
793
3017
|
attrs: {
|
|
794
|
-
title: _vm
|
|
3018
|
+
title: _vm.$t("banners:banners"),
|
|
795
3019
|
"header-buttons": [
|
|
796
3020
|
{
|
|
797
|
-
text: "
|
|
798
|
-
href: _vm.
|
|
3021
|
+
text: _vm.$t("banners:createBanner"),
|
|
3022
|
+
href: _vm.getBannersBannerFormUrl({ bannerId: "create" }),
|
|
799
3023
|
},
|
|
800
3024
|
],
|
|
801
3025
|
},
|
|
@@ -804,72 +3028,116 @@
|
|
|
804
3028
|
key: "content",
|
|
805
3029
|
fn: function () {
|
|
806
3030
|
return [
|
|
807
|
-
_c("
|
|
3031
|
+
_c("data-table", {
|
|
808
3032
|
attrs: {
|
|
809
3033
|
"column-defs": _vm.columnDefs,
|
|
810
3034
|
"row-data": _vm.rowData,
|
|
811
3035
|
loading: _vm.isRowDataLoading,
|
|
812
3036
|
"error-message": _vm.errorMessage,
|
|
813
|
-
|
|
3037
|
+
"data-table": "banners",
|
|
3038
|
+
"use-search": true,
|
|
3039
|
+
"use-pagination": true,
|
|
3040
|
+
"search-query": _vm.searchQuery,
|
|
3041
|
+
pagination: {
|
|
3042
|
+
pageNumber: _vm.pageNumber,
|
|
3043
|
+
pageCount: _vm.pageCount,
|
|
3044
|
+
pageSize: _vm.pageSize,
|
|
3045
|
+
disabled: _vm.isRowDataLoading,
|
|
3046
|
+
},
|
|
814
3047
|
},
|
|
3048
|
+
on: { change: _vm.handleChange },
|
|
815
3049
|
scopedSlots: _vm._u([
|
|
816
3050
|
{
|
|
817
|
-
key: "
|
|
818
|
-
fn: function (
|
|
819
|
-
var row = ref.row;
|
|
820
|
-
var rowIndex = ref.rowIndex;
|
|
3051
|
+
key: "filters",
|
|
3052
|
+
fn: function () {
|
|
821
3053
|
return [
|
|
822
3054
|
_c(
|
|
823
|
-
"
|
|
824
|
-
{
|
|
825
|
-
attrs: {
|
|
826
|
-
variant: "icon",
|
|
827
|
-
title: "Edit",
|
|
828
|
-
disabled: _vm.deletingBannerItemIdList.includes(
|
|
829
|
-
row.id
|
|
830
|
-
),
|
|
831
|
-
href: _vm.getLinkToBannerItemForm(row.id),
|
|
832
|
-
},
|
|
833
|
-
},
|
|
834
|
-
[_c("svg-icon", { attrs: { name: "edit" } })],
|
|
835
|
-
1
|
|
836
|
-
),
|
|
837
|
-
_vm._v(" "),
|
|
838
|
-
_c(
|
|
839
|
-
"base-button",
|
|
3055
|
+
"advanced-search",
|
|
840
3056
|
{
|
|
841
|
-
attrs: {
|
|
842
|
-
|
|
843
|
-
title: "Move up",
|
|
844
|
-
disabled: rowIndex === 0 || _vm.isBannerItemMoving,
|
|
845
|
-
},
|
|
846
|
-
on: {
|
|
847
|
-
click: function ($event) {
|
|
848
|
-
return _vm.moveBannerItem(row.id, "up")
|
|
849
|
-
},
|
|
850
|
-
},
|
|
3057
|
+
attrs: { tags: _vm.tags },
|
|
3058
|
+
on: { "click:tag": _vm.tagRemovalHandler },
|
|
851
3059
|
},
|
|
852
|
-
[
|
|
853
|
-
|
|
3060
|
+
[
|
|
3061
|
+
_c(
|
|
3062
|
+
"div",
|
|
3063
|
+
{ staticClass: "filters" },
|
|
3064
|
+
[
|
|
3065
|
+
_c("form-field-multi-select", {
|
|
3066
|
+
staticClass: "filter",
|
|
3067
|
+
attrs: {
|
|
3068
|
+
options: _vm.zonesOptionList,
|
|
3069
|
+
name: "zoneFilter",
|
|
3070
|
+
searchable: true,
|
|
3071
|
+
label: _vm.$t("banners:zone"),
|
|
3072
|
+
},
|
|
3073
|
+
model: {
|
|
3074
|
+
value: _vm.zoneFilter,
|
|
3075
|
+
callback: function ($$v) {
|
|
3076
|
+
_vm.zoneFilter = $$v;
|
|
3077
|
+
},
|
|
3078
|
+
expression: "zoneFilter",
|
|
3079
|
+
},
|
|
3080
|
+
}),
|
|
3081
|
+
_vm._v(" "),
|
|
3082
|
+
_c("form-field", {
|
|
3083
|
+
staticClass: "filter",
|
|
3084
|
+
attrs: {
|
|
3085
|
+
label: _vm.$t("banners:date"),
|
|
3086
|
+
name: "dateFilter",
|
|
3087
|
+
type: "date",
|
|
3088
|
+
},
|
|
3089
|
+
model: {
|
|
3090
|
+
value: _vm.dateFilter,
|
|
3091
|
+
callback: function ($$v) {
|
|
3092
|
+
_vm.dateFilter = $$v;
|
|
3093
|
+
},
|
|
3094
|
+
expression: "dateFilter",
|
|
3095
|
+
},
|
|
3096
|
+
}),
|
|
3097
|
+
_vm._v(" "),
|
|
3098
|
+
_c("form-field-multi-select", {
|
|
3099
|
+
staticClass: "filter",
|
|
3100
|
+
attrs: {
|
|
3101
|
+
options: _vm.statusesOptionList,
|
|
3102
|
+
name: "statusFilter",
|
|
3103
|
+
searchable: true,
|
|
3104
|
+
label: _vm.$t("banners:status"),
|
|
3105
|
+
},
|
|
3106
|
+
model: {
|
|
3107
|
+
value: _vm.statusFilter,
|
|
3108
|
+
callback: function ($$v) {
|
|
3109
|
+
_vm.statusFilter = $$v;
|
|
3110
|
+
},
|
|
3111
|
+
expression: "statusFilter",
|
|
3112
|
+
},
|
|
3113
|
+
}),
|
|
3114
|
+
],
|
|
3115
|
+
1
|
|
3116
|
+
),
|
|
3117
|
+
]
|
|
854
3118
|
),
|
|
855
|
-
|
|
3119
|
+
]
|
|
3120
|
+
},
|
|
3121
|
+
proxy: true,
|
|
3122
|
+
},
|
|
3123
|
+
{
|
|
3124
|
+
key: "cell(actions)",
|
|
3125
|
+
fn: function (ref) {
|
|
3126
|
+
var row = ref.row;
|
|
3127
|
+
return [
|
|
856
3128
|
_c(
|
|
857
3129
|
"base-button",
|
|
858
3130
|
{
|
|
859
3131
|
attrs: {
|
|
860
3132
|
variant: "icon",
|
|
861
|
-
title: "
|
|
862
|
-
disabled:
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
on: {
|
|
867
|
-
click: function ($event) {
|
|
868
|
-
return _vm.moveBannerItem(row.id, "down")
|
|
869
|
-
},
|
|
3133
|
+
title: _vm.$t("banners:edit"),
|
|
3134
|
+
disabled: _vm.isBusy(row.id),
|
|
3135
|
+
href: _vm.getBannersBannerFormUrl({
|
|
3136
|
+
bannerId: row.id,
|
|
3137
|
+
}),
|
|
870
3138
|
},
|
|
871
3139
|
},
|
|
872
|
-
[_c("svg-icon", { attrs: { name: "
|
|
3140
|
+
[_c("svg-icon", { attrs: { name: "edit" } })],
|
|
873
3141
|
1
|
|
874
3142
|
),
|
|
875
3143
|
_vm._v(" "),
|
|
@@ -878,14 +3146,12 @@
|
|
|
878
3146
|
{
|
|
879
3147
|
attrs: {
|
|
880
3148
|
variant: "icon",
|
|
881
|
-
title: "
|
|
882
|
-
disabled: _vm.
|
|
883
|
-
row.id
|
|
884
|
-
),
|
|
3149
|
+
title: _vm.$t("banners:remove"),
|
|
3150
|
+
disabled: _vm.isBusy(row.id),
|
|
885
3151
|
},
|
|
886
3152
|
on: {
|
|
887
3153
|
click: function ($event) {
|
|
888
|
-
return _vm.
|
|
3154
|
+
return _vm.handleResourceDelete(row.id)
|
|
889
3155
|
},
|
|
890
3156
|
},
|
|
891
3157
|
},
|
|
@@ -904,169 +3170,175 @@
|
|
|
904
3170
|
]),
|
|
905
3171
|
})
|
|
906
3172
|
};
|
|
907
|
-
var __vue_staticRenderFns__$
|
|
908
|
-
__vue_render__$
|
|
3173
|
+
var __vue_staticRenderFns__$1 = [];
|
|
3174
|
+
__vue_render__$1._withStripped = true;
|
|
909
3175
|
|
|
910
3176
|
/* style */
|
|
911
|
-
const __vue_inject_styles__$
|
|
3177
|
+
const __vue_inject_styles__$1 = function (inject) {
|
|
912
3178
|
if (!inject) return
|
|
913
|
-
inject("data-v-
|
|
3179
|
+
inject("data-v-92c7e846_0", { source: ".filters {\n display: flex;\n margin: 0 -10px;\n}\n.filters:not(:first-child) {\n margin-top: 10px;\n}\n.filters .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n}\n\n/*# sourceMappingURL=BannerList.vue.map */", map: {"version":3,"sources":["/home/runner/work/tager-admin-banners/tager-admin-banners/src/views/Banners/BannerList/BannerList.vue","BannerList.vue"],"names":[],"mappings":"AA0NA;EACA,aAAA;EACA,eAAA;ACzNA;AD2NA;EACA,gBAAA;ACzNA;AD4NA;EACA,oBAAA;EACA,UAAA;EACA,SAAA;AC1NA;;AAEA,yCAAyC","file":"BannerList.vue","sourcesContent":["<template>\n <page\n :title=\"$t('banners:banners')\"\n :header-buttons=\"[\n {\n text: $t('banners:createBanner'),\n href: getBannersBannerFormUrl({ bannerId: 'create' }),\n },\n ]\"\n >\n <template v-slot:content>\n <data-table\n :column-defs=\"columnDefs\"\n :row-data=\"rowData\"\n :loading=\"isRowDataLoading\"\n :error-message=\"errorMessage\"\n data-table=\"banners\"\n :use-search=\"true\"\n :use-pagination=\"true\"\n :search-query=\"searchQuery\"\n :pagination=\"{\n pageNumber,\n pageCount,\n pageSize,\n disabled: isRowDataLoading,\n }\"\n @change=\"handleChange\"\n >\n <template v-slot:filters>\n <advanced-search :tags=\"tags\" @click:tag=\"tagRemovalHandler\">\n <div class=\"filters\">\n <form-field-multi-select\n v-model=\"zoneFilter\"\n :options=\"zonesOptionList\"\n name=\"zoneFilter\"\n :searchable=\"true\"\n :label=\"$t('banners:zone')\"\n class=\"filter\"\n />\n\n <form-field\n v-model=\"dateFilter\"\n :label=\"$t('banners:date')\"\n name=\"dateFilter\"\n type=\"date\"\n class=\"filter\"\n />\n\n <form-field-multi-select\n v-model=\"statusFilter\"\n :options=\"statusesOptionList\"\n name=\"statusFilter\"\n :searchable=\"true\"\n :label=\"$t('banners:status')\"\n class=\"filter\"\n />\n </div>\n </advanced-search>\n </template>\n\n <template v-slot:cell(actions)=\"{ row }\">\n <base-button\n variant=\"icon\"\n :title=\"$t('banners:edit')\"\n :disabled=\"isBusy(row.id)\"\n :href=\"getBannersBannerFormUrl({ bannerId: row.id })\"\n >\n <svg-icon name=\"edit\" />\n </base-button>\n\n <base-button\n variant=\"icon\"\n :title=\"$t('banners:remove')\"\n :disabled=\"isBusy(row.id)\"\n @click=\"handleResourceDelete(row.id)\"\n >\n <svg-icon name=\"delete\" />\n </base-button>\n </template>\n </data-table>\n </template>\n </page>\n</template>\n\n<script lang=\"ts\">\nimport {\n computed,\n defineComponent,\n SetupContext,\n watch,\n} from '@vue/composition-api';\nimport isEqual from 'lodash.isequal';\nimport pick from 'lodash.pick';\n\nimport {\n ColumnDefinition,\n useDataTable,\n useTranslation,\n} from '@tager/admin-ui';\nimport { useResourceDelete } from '@tager/admin-services';\n\nimport { deleteBanner, getBanners } from '../../../services/requests';\nimport { Banner } from '../../../typings/banners';\nimport { getBannersBannerFormUrl } from '../../../constants/paths';\nimport { useFetchZones } from '../../../hooks';\n\nimport { getColumnDefs } from './BannerList.helpers';\nimport { useAdvancedSearch } from './hooks';\n\nexport default defineComponent({\n name: 'BannerList',\n setup(props, context: SetupContext) {\n const { t } = useTranslation(context);\n const { loading: isZonesLoading, data: zoneList } = useFetchZones({\n context,\n });\n\n const {\n zoneFilter,\n zonesOptionList,\n dateFilter,\n statusFilter,\n statusesOptionList,\n filterParams,\n tags,\n tagRemovalHandler,\n } = useAdvancedSearch({\n context,\n t,\n zoneList,\n });\n\n const {\n fetchEntityList: fetchBanners,\n isLoading: isBannersLoading,\n rowData,\n errorMessage,\n handleChange,\n searchQuery,\n pageNumber,\n pageCount,\n pageSize,\n } = useDataTable<Banner>({\n fetchEntityList: (params) =>\n getBanners({\n query: params.searchQuery,\n pageNumber: params.pageNumber,\n pageSize: params.pageSize,\n ...filterParams.value,\n }),\n initialValue: [],\n context,\n resourceName: 'Banners',\n });\n\n watch(filterParams, () => {\n if (isZonesLoading.value) {\n return;\n }\n\n const newQuery = {\n ...pick(context.root.$route.query, ['query', 'pageNumber']),\n ...filterParams.value,\n };\n\n if (!isEqual(context.root.$route.query, newQuery)) {\n context.root.$router.replace({ query: newQuery });\n fetchBanners();\n }\n });\n\n const { isDeleting, handleResourceDelete } = useResourceDelete({\n deleteResource: deleteBanner,\n resourceName: 'Banner',\n onSuccess: fetchBanners,\n context,\n });\n\n const isBusy = (bannerId: number): boolean => {\n return isDeleting(bannerId) || isBannersLoading.value;\n };\n\n const columnDefs = computed<ColumnDefinition<Banner>[]>(() =>\n getColumnDefs(context.root.$t)\n );\n\n const isRowDataLoading = computed<boolean>(\n () => isBannersLoading.value || isZonesLoading.value\n );\n\n return {\n columnDefs,\n isRowDataLoading,\n rowData,\n errorMessage,\n handleChange,\n getBannersBannerFormUrl,\n searchQuery,\n pageNumber,\n pageCount,\n pageSize,\n isBusy,\n handleResourceDelete,\n\n // Advanced search\n zoneFilter,\n zonesOptionList,\n dateFilter,\n statusFilter,\n statusesOptionList,\n tags,\n tagRemovalHandler,\n };\n },\n});\n</script>\n\n<style lang=\"scss\">\n.filters {\n display: flex;\n margin: 0 -10px;\n\n &:not(:first-child) {\n margin-top: 10px;\n }\n\n .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n }\n}\n</style>\n",".filters {\n display: flex;\n margin: 0 -10px;\n}\n.filters:not(:first-child) {\n margin-top: 10px;\n}\n.filters .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n}\n\n/*# sourceMappingURL=BannerList.vue.map */"]}, media: undefined });
|
|
914
3180
|
|
|
915
3181
|
};
|
|
916
3182
|
/* scoped */
|
|
917
|
-
const __vue_scope_id__$
|
|
3183
|
+
const __vue_scope_id__$1 = undefined;
|
|
918
3184
|
/* module identifier */
|
|
919
|
-
const __vue_module_identifier__$
|
|
3185
|
+
const __vue_module_identifier__$1 = undefined;
|
|
920
3186
|
/* functional template */
|
|
921
|
-
const __vue_is_functional_template__$
|
|
3187
|
+
const __vue_is_functional_template__$1 = false;
|
|
922
3188
|
/* style inject SSR */
|
|
923
3189
|
|
|
924
3190
|
/* style inject shadow dom */
|
|
925
3191
|
|
|
926
3192
|
|
|
927
3193
|
|
|
928
|
-
const __vue_component__$
|
|
929
|
-
{ render: __vue_render__$
|
|
930
|
-
__vue_inject_styles__$
|
|
931
|
-
__vue_script__$
|
|
932
|
-
__vue_scope_id__$
|
|
933
|
-
__vue_is_functional_template__$
|
|
934
|
-
__vue_module_identifier__$
|
|
3194
|
+
const __vue_component__$1 = /*#__PURE__*/normalizeComponent(
|
|
3195
|
+
{ render: __vue_render__$1, staticRenderFns: __vue_staticRenderFns__$1 },
|
|
3196
|
+
__vue_inject_styles__$1,
|
|
3197
|
+
__vue_script__$1,
|
|
3198
|
+
__vue_scope_id__$1,
|
|
3199
|
+
__vue_is_functional_template__$1,
|
|
3200
|
+
__vue_module_identifier__$1,
|
|
935
3201
|
false,
|
|
936
3202
|
createInjector,
|
|
937
3203
|
undefined,
|
|
938
3204
|
undefined
|
|
939
3205
|
);
|
|
940
3206
|
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
},
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
title: bannerItem.title,
|
|
1014
|
-
text: bannerItem.text,
|
|
1015
|
-
buttonLink: (_a = bannerItem.buttonLink) !== null && _a !== void 0 ? _a : '',
|
|
1016
|
-
buttonLabel: bannerItem.buttonLabel,
|
|
1017
|
-
buttonIsNewTab: bannerItem.buttonIsNewTab,
|
|
1018
|
-
image: bannerItem.image,
|
|
1019
|
-
};
|
|
1020
|
-
},
|
|
1021
|
-
submitForm() {
|
|
1022
|
-
var _a, _b, _c, _d;
|
|
1023
|
-
const creationBody = {
|
|
1024
|
-
title: this.values.title,
|
|
1025
|
-
text: this.values.text,
|
|
1026
|
-
buttonLink: this.values.buttonLink.trim() || null,
|
|
1027
|
-
buttonLabel: this.values.buttonLabel,
|
|
1028
|
-
buttonIsNewTab: this.values.buttonIsNewTab,
|
|
1029
|
-
image: (_b = (_a = this.values.image) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null,
|
|
1030
|
-
};
|
|
1031
|
-
const requestPromise = this.isCreation
|
|
1032
|
-
? createBannerItem((_d = (_c = this.bannerArea) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : 'unknown', creationBody)
|
|
1033
|
-
: updateBannerItem(this.itemId, creationBody);
|
|
3207
|
+
function useFetchBanner({ context, bannerId, isCreation, }) {
|
|
3208
|
+
const [fetchBanner, resource] = adminServices.useResource({
|
|
3209
|
+
fetchResource: () => getBanner(bannerId.value),
|
|
3210
|
+
initialValue: null,
|
|
3211
|
+
context,
|
|
3212
|
+
resourceName: 'Banner',
|
|
3213
|
+
});
|
|
3214
|
+
compositionApi.onMounted(() => {
|
|
3215
|
+
if (isCreation.value) {
|
|
3216
|
+
return;
|
|
3217
|
+
}
|
|
3218
|
+
fetchBanner();
|
|
3219
|
+
});
|
|
3220
|
+
compositionApi.watch(bannerId, () => {
|
|
3221
|
+
if (isCreation.value) {
|
|
3222
|
+
return;
|
|
3223
|
+
}
|
|
3224
|
+
fetchBanner();
|
|
3225
|
+
});
|
|
3226
|
+
return resource;
|
|
3227
|
+
}
|
|
3228
|
+
|
|
3229
|
+
function convertBannerToFormValues(banner, zonesOptionList) {
|
|
3230
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3231
|
+
const foundZone = zonesOptionList.find(({ value }) => value === (banner === null || banner === void 0 ? void 0 : banner.bannerZone));
|
|
3232
|
+
return {
|
|
3233
|
+
link: (_a = banner === null || banner === void 0 ? void 0 : banner.link) !== null && _a !== void 0 ? _a : '',
|
|
3234
|
+
image: (banner === null || banner === void 0 ? void 0 : banner.image) ? { id: adminServices.createId(), file: banner.image } : null,
|
|
3235
|
+
bannerZone: foundZone !== null && foundZone !== void 0 ? foundZone : null,
|
|
3236
|
+
openNewTab: (_b = banner === null || banner === void 0 ? void 0 : banner.openNewTab) !== null && _b !== void 0 ? _b : false,
|
|
3237
|
+
dateStart: (_c = banner === null || banner === void 0 ? void 0 : banner.dateStart) !== null && _c !== void 0 ? _c : '',
|
|
3238
|
+
dateEnd: (_d = banner === null || banner === void 0 ? void 0 : banner.dateEnd) !== null && _d !== void 0 ? _d : '',
|
|
3239
|
+
disabled: (_e = banner === null || banner === void 0 ? void 0 : banner.disabled) !== null && _e !== void 0 ? _e : false,
|
|
3240
|
+
comment: (_f = banner === null || banner === void 0 ? void 0 : banner.comment) !== null && _f !== void 0 ? _f : '',
|
|
3241
|
+
};
|
|
3242
|
+
}
|
|
3243
|
+
function convertBannerFormValuesToPayload(values) {
|
|
3244
|
+
var _a, _b, _c, _d;
|
|
3245
|
+
return Object.assign(Object.assign({}, values), { image: (_b = (_a = values.image) === null || _a === void 0 ? void 0 : _a.file.id) !== null && _b !== void 0 ? _b : null, bannerZone: (_d = (_c = values.bannerZone) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : '' });
|
|
3246
|
+
}
|
|
3247
|
+
|
|
3248
|
+
var script$2 = compositionApi.defineComponent({
|
|
3249
|
+
name: 'BannerForm',
|
|
3250
|
+
components: { FormFooter: adminUi.FormFooter },
|
|
3251
|
+
setup(props, context) {
|
|
3252
|
+
const bannerId = compositionApi.computed(() => context.root.$route.params.bannerId);
|
|
3253
|
+
const isCreation = compositionApi.computed(() => bannerId.value === 'create');
|
|
3254
|
+
/** Zones **/
|
|
3255
|
+
const { data: zones, loading: isZonesLoading } = useFetchZones({ context });
|
|
3256
|
+
const zonesOptionList = compositionApi.computed(() => zones.value.map((zone) => ({
|
|
3257
|
+
value: zone.id,
|
|
3258
|
+
label: zone.name,
|
|
3259
|
+
})));
|
|
3260
|
+
/** Banner **/
|
|
3261
|
+
const { data: banner, loading: isBannerLoading } = useFetchBanner({
|
|
3262
|
+
context,
|
|
3263
|
+
bannerId,
|
|
3264
|
+
isCreation,
|
|
3265
|
+
});
|
|
3266
|
+
/** Form State **/
|
|
3267
|
+
const isSubmitting = compositionApi.ref(false);
|
|
3268
|
+
const values = compositionApi.ref(convertBannerToFormValues(banner.value, zonesOptionList.value));
|
|
3269
|
+
const errors = compositionApi.ref({});
|
|
3270
|
+
compositionApi.watch([banner, zones], () => {
|
|
3271
|
+
values.value = convertBannerToFormValues(banner.value, zonesOptionList.value);
|
|
3272
|
+
});
|
|
3273
|
+
const submitForm = (event) => {
|
|
3274
|
+
isSubmitting.value = true;
|
|
3275
|
+
const body = convertBannerFormValuesToPayload(values.value);
|
|
3276
|
+
const requestPromise = isCreation.value
|
|
3277
|
+
? createBanner(body)
|
|
3278
|
+
: updateBanner(bannerId.value, body);
|
|
1034
3279
|
requestPromise
|
|
1035
|
-
.then(() => {
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
3280
|
+
.then(({ data }) => {
|
|
3281
|
+
errors.value = {};
|
|
3282
|
+
if (event.type === 'create') {
|
|
3283
|
+
context.root.$router.push(getBannersBannerFormUrl({ bannerId: String(data.id) }));
|
|
3284
|
+
}
|
|
3285
|
+
if (event.type === 'create_exit' || event.type === 'save_exit') {
|
|
3286
|
+
context.root.$router.push(getBannersBannerListUrl());
|
|
3287
|
+
}
|
|
3288
|
+
if (event.type === 'create_create-another') {
|
|
3289
|
+
values.value = convertBannerToFormValues(null, zonesOptionList.value);
|
|
3290
|
+
}
|
|
3291
|
+
context.root.$toast({
|
|
1039
3292
|
variant: 'success',
|
|
1040
|
-
title: '
|
|
1041
|
-
body:
|
|
3293
|
+
title: context.root.$t('banners:success'),
|
|
3294
|
+
body: isCreation.value
|
|
3295
|
+
? context.root.$t('banners:bannerWasSuccessfullyCreated')
|
|
3296
|
+
: context.root.$t('banners:bannerWasSuccessfullyUpdated'),
|
|
1042
3297
|
});
|
|
1043
3298
|
})
|
|
1044
3299
|
.catch((error) => {
|
|
1045
3300
|
console.error(error);
|
|
1046
|
-
|
|
1047
|
-
|
|
3301
|
+
errors.value = adminServices.convertRequestErrorToMap(error);
|
|
3302
|
+
context.root.$toast({
|
|
1048
3303
|
variant: 'danger',
|
|
1049
|
-
title: '
|
|
1050
|
-
body:
|
|
3304
|
+
title: context.root.$t('banners:error'),
|
|
3305
|
+
body: isCreation.value
|
|
3306
|
+
? context.root.$t('banners:bannerCreationWasFailed')
|
|
3307
|
+
: context.root.$t('banners:bannerUpdateWasFailed'),
|
|
1051
3308
|
});
|
|
3309
|
+
})
|
|
3310
|
+
.finally(() => {
|
|
3311
|
+
isSubmitting.value = false;
|
|
1052
3312
|
});
|
|
1053
|
-
}
|
|
3313
|
+
};
|
|
3314
|
+
const isContentLoading = compositionApi.computed(() => isBannerLoading.value || isZonesLoading.value);
|
|
3315
|
+
return {
|
|
3316
|
+
isCreation,
|
|
3317
|
+
isContentLoading,
|
|
3318
|
+
isSubmitting,
|
|
3319
|
+
values,
|
|
3320
|
+
errors,
|
|
3321
|
+
submitForm,
|
|
3322
|
+
bannerListUrl: getBannersBannerListUrl(),
|
|
3323
|
+
zonesOptionList,
|
|
3324
|
+
};
|
|
1054
3325
|
},
|
|
1055
3326
|
});
|
|
1056
3327
|
|
|
1057
3328
|
/* script */
|
|
1058
|
-
const __vue_script__$
|
|
3329
|
+
const __vue_script__$2 = script$2;
|
|
1059
3330
|
|
|
1060
3331
|
/* template */
|
|
1061
|
-
var __vue_render__$
|
|
3332
|
+
var __vue_render__$2 = function () {
|
|
1062
3333
|
var _vm = this;
|
|
1063
3334
|
var _h = _vm.$createElement;
|
|
1064
3335
|
var _c = _vm._self._c || _h;
|
|
1065
3336
|
return _c("page", {
|
|
1066
3337
|
attrs: {
|
|
1067
|
-
title: _vm.isCreation
|
|
3338
|
+
title: _vm.isCreation
|
|
3339
|
+
? _vm.$t("banners:createBanner")
|
|
3340
|
+
: _vm.$t("banners:updateBanner"),
|
|
1068
3341
|
"is-content-loading": _vm.isContentLoading,
|
|
1069
|
-
footer: { onSubmit: _vm.submitForm, backHref: _vm.bannerItemListUrl },
|
|
1070
3342
|
},
|
|
1071
3343
|
scopedSlots: _vm._u([
|
|
1072
3344
|
{
|
|
@@ -1080,46 +3352,33 @@
|
|
|
1080
3352
|
on: {
|
|
1081
3353
|
submit: function ($event) {
|
|
1082
3354
|
$event.preventDefault();
|
|
3355
|
+
return _vm.submitForm($event)
|
|
1083
3356
|
},
|
|
1084
3357
|
},
|
|
1085
3358
|
},
|
|
1086
3359
|
[
|
|
1087
|
-
_c("form-field", {
|
|
1088
|
-
attrs: {
|
|
1089
|
-
name: "title",
|
|
1090
|
-
label: "Title",
|
|
1091
|
-
error: _vm.errors.title,
|
|
1092
|
-
type: "textarea",
|
|
1093
|
-
},
|
|
1094
|
-
model: {
|
|
1095
|
-
value: _vm.values.title,
|
|
1096
|
-
callback: function ($$v) {
|
|
1097
|
-
_vm.$set(_vm.values, "title", $$v);
|
|
1098
|
-
},
|
|
1099
|
-
expression: "values.title",
|
|
1100
|
-
},
|
|
1101
|
-
}),
|
|
1102
|
-
_vm._v(" "),
|
|
1103
|
-
_c("form-field-rich-text-input", {
|
|
3360
|
+
_c("form-field-select", {
|
|
1104
3361
|
attrs: {
|
|
1105
|
-
name: "
|
|
1106
|
-
label: "
|
|
1107
|
-
|
|
3362
|
+
name: "bannerZone",
|
|
3363
|
+
label: _vm.$t("banners:zone"),
|
|
3364
|
+
options: _vm.zonesOptionList,
|
|
3365
|
+
error: _vm.errors.bannerZone,
|
|
1108
3366
|
},
|
|
1109
3367
|
model: {
|
|
1110
|
-
value: _vm.values.
|
|
3368
|
+
value: _vm.values.bannerZone,
|
|
1111
3369
|
callback: function ($$v) {
|
|
1112
|
-
_vm.$set(_vm.values, "
|
|
3370
|
+
_vm.$set(_vm.values, "bannerZone", $$v);
|
|
1113
3371
|
},
|
|
1114
|
-
expression: "values.
|
|
3372
|
+
expression: "values.bannerZone",
|
|
1115
3373
|
},
|
|
1116
3374
|
}),
|
|
1117
3375
|
_vm._v(" "),
|
|
1118
3376
|
_c("form-field-file-input", {
|
|
1119
3377
|
attrs: {
|
|
1120
|
-
label: "Image",
|
|
1121
3378
|
name: "image",
|
|
1122
3379
|
"file-type": "image",
|
|
3380
|
+
label: _vm.$t("banners:image"),
|
|
3381
|
+
error: _vm.errors.file,
|
|
1123
3382
|
},
|
|
1124
3383
|
model: {
|
|
1125
3384
|
value: _vm.values.image,
|
|
@@ -1132,46 +3391,103 @@
|
|
|
1132
3391
|
_vm._v(" "),
|
|
1133
3392
|
_c("form-field", {
|
|
1134
3393
|
attrs: {
|
|
1135
|
-
name: "
|
|
1136
|
-
label: "
|
|
1137
|
-
error: _vm.errors.
|
|
3394
|
+
name: "link",
|
|
3395
|
+
label: _vm.$t("banners:link"),
|
|
3396
|
+
error: _vm.errors.name,
|
|
1138
3397
|
},
|
|
1139
3398
|
model: {
|
|
1140
|
-
value: _vm.values.
|
|
3399
|
+
value: _vm.values.link,
|
|
1141
3400
|
callback: function ($$v) {
|
|
1142
|
-
_vm.$set(_vm.values, "
|
|
3401
|
+
_vm.$set(_vm.values, "link", $$v);
|
|
1143
3402
|
},
|
|
1144
|
-
expression: "values.
|
|
3403
|
+
expression: "values.link",
|
|
1145
3404
|
},
|
|
1146
3405
|
}),
|
|
1147
3406
|
_vm._v(" "),
|
|
1148
|
-
_c("form-field", {
|
|
3407
|
+
_c("form-field-checkbox", {
|
|
1149
3408
|
attrs: {
|
|
1150
|
-
name: "
|
|
1151
|
-
label: "
|
|
1152
|
-
error: _vm.errors.
|
|
3409
|
+
name: "openNewTab",
|
|
3410
|
+
label: _vm.$t("banners:openNewTab"),
|
|
3411
|
+
error: _vm.errors.openNewTab,
|
|
1153
3412
|
},
|
|
1154
3413
|
model: {
|
|
1155
|
-
value: _vm.values.
|
|
3414
|
+
value: _vm.values.openNewTab,
|
|
1156
3415
|
callback: function ($$v) {
|
|
1157
|
-
_vm.$set(_vm.values, "
|
|
3416
|
+
_vm.$set(_vm.values, "openNewTab", $$v);
|
|
1158
3417
|
},
|
|
1159
|
-
expression: "values.
|
|
3418
|
+
expression: "values.openNewTab",
|
|
1160
3419
|
},
|
|
1161
3420
|
}),
|
|
1162
3421
|
_vm._v(" "),
|
|
3422
|
+
_c("input-label", [_vm._v(_vm._s(_vm.$t("banners:period")))]),
|
|
3423
|
+
_vm._v(" "),
|
|
3424
|
+
_c(
|
|
3425
|
+
"div",
|
|
3426
|
+
{ staticClass: "date" },
|
|
3427
|
+
[
|
|
3428
|
+
_c("form-field", {
|
|
3429
|
+
attrs: {
|
|
3430
|
+
label: _vm.$t("banners:from"),
|
|
3431
|
+
name: "dateStart",
|
|
3432
|
+
type: "date",
|
|
3433
|
+
max: _vm.values.dateEnd,
|
|
3434
|
+
},
|
|
3435
|
+
model: {
|
|
3436
|
+
value: _vm.values.dateStart,
|
|
3437
|
+
callback: function ($$v) {
|
|
3438
|
+
_vm.$set(_vm.values, "dateStart", $$v);
|
|
3439
|
+
},
|
|
3440
|
+
expression: "values.dateStart",
|
|
3441
|
+
},
|
|
3442
|
+
}),
|
|
3443
|
+
_vm._v(" "),
|
|
3444
|
+
_c("form-field", {
|
|
3445
|
+
attrs: {
|
|
3446
|
+
label: _vm.$t("banners:to"),
|
|
3447
|
+
name: "dateEnd",
|
|
3448
|
+
type: "date",
|
|
3449
|
+
min: _vm.values.dateStart,
|
|
3450
|
+
},
|
|
3451
|
+
model: {
|
|
3452
|
+
value: _vm.values.dateEnd,
|
|
3453
|
+
callback: function ($$v) {
|
|
3454
|
+
_vm.$set(_vm.values, "dateEnd", $$v);
|
|
3455
|
+
},
|
|
3456
|
+
expression: "values.dateEnd",
|
|
3457
|
+
},
|
|
3458
|
+
}),
|
|
3459
|
+
],
|
|
3460
|
+
1
|
|
3461
|
+
),
|
|
3462
|
+
_vm._v(" "),
|
|
1163
3463
|
_c("form-field-checkbox", {
|
|
1164
3464
|
attrs: {
|
|
1165
|
-
name: "
|
|
1166
|
-
label: "
|
|
1167
|
-
error: _vm.errors.
|
|
3465
|
+
name: "disabled",
|
|
3466
|
+
label: _vm.$t("banners:disabled"),
|
|
3467
|
+
error: _vm.errors.disabled,
|
|
3468
|
+
},
|
|
3469
|
+
model: {
|
|
3470
|
+
value: _vm.values.disabled,
|
|
3471
|
+
callback: function ($$v) {
|
|
3472
|
+
_vm.$set(_vm.values, "disabled", $$v);
|
|
3473
|
+
},
|
|
3474
|
+
expression: "values.disabled",
|
|
3475
|
+
},
|
|
3476
|
+
}),
|
|
3477
|
+
_vm._v(" "),
|
|
3478
|
+
_c("form-field", {
|
|
3479
|
+
attrs: {
|
|
3480
|
+
name: "comment",
|
|
3481
|
+
type: "textarea",
|
|
3482
|
+
label: _vm.$t("banners:comment"),
|
|
3483
|
+
error: _vm.errors.comment,
|
|
1168
3484
|
},
|
|
1169
3485
|
model: {
|
|
1170
|
-
value: _vm.values.
|
|
3486
|
+
value: _vm.values.comment,
|
|
1171
3487
|
callback: function ($$v) {
|
|
1172
|
-
_vm.$set(_vm.values, "
|
|
3488
|
+
_vm.$set(_vm.values, "comment", $$v);
|
|
1173
3489
|
},
|
|
1174
|
-
expression: "values.
|
|
3490
|
+
expression: "values.comment",
|
|
1175
3491
|
},
|
|
1176
3492
|
}),
|
|
1177
3493
|
],
|
|
@@ -1181,129 +3497,128 @@
|
|
|
1181
3497
|
},
|
|
1182
3498
|
proxy: true,
|
|
1183
3499
|
},
|
|
3500
|
+
{
|
|
3501
|
+
key: "footer",
|
|
3502
|
+
fn: function () {
|
|
3503
|
+
return [
|
|
3504
|
+
_c("FormFooter", {
|
|
3505
|
+
attrs: {
|
|
3506
|
+
"back-href": _vm.bannerListUrl,
|
|
3507
|
+
"on-submit": _vm.submitForm,
|
|
3508
|
+
"is-submitting": _vm.isSubmitting,
|
|
3509
|
+
"is-creation": _vm.isCreation,
|
|
3510
|
+
"can-create-another": _vm.isCreation,
|
|
3511
|
+
},
|
|
3512
|
+
}),
|
|
3513
|
+
]
|
|
3514
|
+
},
|
|
3515
|
+
proxy: true,
|
|
3516
|
+
},
|
|
1184
3517
|
]),
|
|
1185
3518
|
})
|
|
1186
3519
|
};
|
|
1187
|
-
var __vue_staticRenderFns__$
|
|
1188
|
-
__vue_render__$
|
|
3520
|
+
var __vue_staticRenderFns__$2 = [];
|
|
3521
|
+
__vue_render__$2._withStripped = true;
|
|
1189
3522
|
|
|
1190
3523
|
/* style */
|
|
1191
|
-
const __vue_inject_styles__$
|
|
3524
|
+
const __vue_inject_styles__$2 = function (inject) {
|
|
1192
3525
|
if (!inject) return
|
|
1193
|
-
inject("data-v-
|
|
3526
|
+
inject("data-v-60ad1218_0", { source: ".date {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n column-gap: 10px;\n}\n\n/*# sourceMappingURL=BannerForm.vue.map */", map: {"version":3,"sources":["/home/runner/work/tager-admin-banners/tager-admin-banners/src/views/Banners/BannerForm/BannerForm.vue","BannerForm.vue"],"names":[],"mappings":"AAsOA;EACA,aAAA;EACA,qCAAA;EACA,gBAAA;ACrOA;;AAEA,yCAAyC","file":"BannerForm.vue","sourcesContent":["<template>\n <page\n :title=\"\n isCreation ? $t('banners:createBanner') : $t('banners:updateBanner')\n \"\n :is-content-loading=\"isContentLoading\"\n >\n <template v-slot:content>\n <form novalidate @submit.prevent=\"submitForm\">\n <form-field-select\n v-model=\"values.bannerZone\"\n name=\"bannerZone\"\n :label=\"$t('banners:zone')\"\n :options=\"zonesOptionList\"\n :error=\"errors.bannerZone\"\n />\n\n <form-field-file-input\n v-model=\"values.image\"\n name=\"image\"\n file-type=\"image\"\n :label=\"$t('banners:image')\"\n :error=\"errors.file\"\n />\n\n <form-field\n v-model=\"values.link\"\n name=\"link\"\n :label=\"$t('banners:link')\"\n :error=\"errors.name\"\n />\n\n <form-field-checkbox\n v-model=\"values.openNewTab\"\n name=\"openNewTab\"\n :label=\"$t('banners:openNewTab')\"\n :error=\"errors.openNewTab\"\n />\n\n <input-label>{{ $t('banners:period') }}</input-label>\n\n <div class=\"date\">\n <form-field\n v-model=\"values.dateStart\"\n :label=\"$t('banners:from')\"\n name=\"dateStart\"\n type=\"date\"\n :max=\"values.dateEnd\"\n />\n\n <form-field\n v-model=\"values.dateEnd\"\n :label=\"$t('banners:to')\"\n name=\"dateEnd\"\n type=\"date\"\n :min=\"values.dateStart\"\n />\n </div>\n\n <form-field-checkbox\n v-model=\"values.disabled\"\n name=\"disabled\"\n :label=\"$t('banners:disabled')\"\n :error=\"errors.disabled\"\n />\n\n <form-field\n v-model=\"values.comment\"\n name=\"comment\"\n type=\"textarea\"\n :label=\"$t('banners:comment')\"\n :error=\"errors.comment\"\n />\n </form>\n </template>\n\n <template v-slot:footer>\n <FormFooter\n :back-href=\"bannerListUrl\"\n :on-submit=\"submitForm\"\n :is-submitting=\"isSubmitting\"\n :is-creation=\"isCreation\"\n :can-create-another=\"isCreation\"\n />\n </template>\n </page>\n</template>\n\n<script lang=\"ts\">\nimport {\n computed,\n defineComponent,\n ref,\n SetupContext,\n watch,\n} from '@vue/composition-api';\n\nimport { FormFooter, OptionType, TagerFormSubmitEvent } from '@tager/admin-ui';\nimport { convertRequestErrorToMap } from '@tager/admin-services';\n\nimport { useFetchZones } from '../../../hooks';\nimport { BannerFormValues } from '../../../typings/banners';\nimport { useFetchBanner } from '../../../hooks/useFetchBanner';\nimport {\n getBannersBannerFormUrl,\n getBannersBannerListUrl,\n} from '../../../constants/paths';\nimport { createBanner, updateBanner } from '../../../services/requests';\n\nimport {\n convertBannerFormValuesToPayload,\n convertBannerToFormValues,\n} from './BannerForm.helpers';\n\nexport default defineComponent({\n name: 'BannerForm',\n components: { FormFooter },\n setup(props, context: SetupContext) {\n const bannerId = computed<string>(\n () => context.root.$route.params.bannerId\n );\n const isCreation = computed<boolean>(() => bannerId.value === 'create');\n\n /** Zones **/\n\n const { data: zones, loading: isZonesLoading } = useFetchZones({ context });\n\n const zonesOptionList = computed<OptionType[]>(() =>\n zones.value.map<OptionType>((zone) => ({\n value: zone.id,\n label: zone.name,\n }))\n );\n\n /** Banner **/\n\n const { data: banner, loading: isBannerLoading } = useFetchBanner({\n context,\n bannerId,\n isCreation,\n });\n\n /** Form State **/\n\n const isSubmitting = ref<boolean>(false);\n const values = ref<BannerFormValues>(\n convertBannerToFormValues(banner.value, zonesOptionList.value)\n );\n const errors = ref<Record<string, string>>({});\n\n watch([banner, zones], () => {\n values.value = convertBannerToFormValues(\n banner.value,\n zonesOptionList.value\n );\n });\n\n const submitForm = (event: TagerFormSubmitEvent) => {\n isSubmitting.value = true;\n\n const body = convertBannerFormValuesToPayload(values.value);\n\n const requestPromise = isCreation.value\n ? createBanner(body)\n : updateBanner(bannerId.value, body);\n\n requestPromise\n .then(({ data }) => {\n errors.value = {};\n\n if (event.type === 'create') {\n context.root.$router.push(\n getBannersBannerFormUrl({ bannerId: String(data.id) })\n );\n }\n\n if (event.type === 'create_exit' || event.type === 'save_exit') {\n context.root.$router.push(getBannersBannerListUrl());\n }\n\n if (event.type === 'create_create-another') {\n values.value = convertBannerToFormValues(\n null,\n zonesOptionList.value\n );\n }\n\n context.root.$toast({\n variant: 'success',\n title: context.root.$t('banners:success'),\n body: isCreation.value\n ? context.root.$t('banners:bannerWasSuccessfullyCreated')\n : context.root.$t('banners:bannerWasSuccessfullyUpdated'),\n });\n })\n .catch((error) => {\n console.error(error);\n errors.value = convertRequestErrorToMap(error);\n context.root.$toast({\n variant: 'danger',\n title: context.root.$t('banners:error'),\n body: isCreation.value\n ? context.root.$t('banners:bannerCreationWasFailed')\n : context.root.$t('banners:bannerUpdateWasFailed'),\n });\n })\n .finally(() => {\n isSubmitting.value = false;\n });\n };\n\n const isContentLoading = computed<boolean>(\n () => isBannerLoading.value || isZonesLoading.value\n );\n\n return {\n isCreation,\n isContentLoading,\n isSubmitting,\n values,\n errors,\n submitForm,\n bannerListUrl: getBannersBannerListUrl(),\n zonesOptionList,\n };\n },\n});\n</script>\n\n<style lang=\"scss\">\n.date {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n column-gap: 10px;\n}\n</style>\n",".date {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n column-gap: 10px;\n}\n\n/*# sourceMappingURL=BannerForm.vue.map */"]}, media: undefined });
|
|
1194
3527
|
|
|
1195
3528
|
};
|
|
1196
3529
|
/* scoped */
|
|
1197
|
-
const __vue_scope_id__$
|
|
3530
|
+
const __vue_scope_id__$2 = undefined;
|
|
1198
3531
|
/* module identifier */
|
|
1199
|
-
const __vue_module_identifier__$
|
|
3532
|
+
const __vue_module_identifier__$2 = undefined;
|
|
1200
3533
|
/* functional template */
|
|
1201
|
-
const __vue_is_functional_template__$
|
|
3534
|
+
const __vue_is_functional_template__$2 = false;
|
|
1202
3535
|
/* style inject SSR */
|
|
1203
3536
|
|
|
1204
3537
|
/* style inject shadow dom */
|
|
1205
3538
|
|
|
1206
3539
|
|
|
1207
3540
|
|
|
1208
|
-
const __vue_component__$
|
|
1209
|
-
{ render: __vue_render__$
|
|
1210
|
-
__vue_inject_styles__$
|
|
1211
|
-
__vue_script__$
|
|
1212
|
-
__vue_scope_id__$
|
|
1213
|
-
__vue_is_functional_template__$
|
|
1214
|
-
__vue_module_identifier__$
|
|
3541
|
+
const __vue_component__$2 = /*#__PURE__*/normalizeComponent(
|
|
3542
|
+
{ render: __vue_render__$2, staticRenderFns: __vue_staticRenderFns__$2 },
|
|
3543
|
+
__vue_inject_styles__$2,
|
|
3544
|
+
__vue_script__$2,
|
|
3545
|
+
__vue_scope_id__$2,
|
|
3546
|
+
__vue_is_functional_template__$2,
|
|
3547
|
+
__vue_module_identifier__$2,
|
|
1215
3548
|
false,
|
|
1216
3549
|
createInjector,
|
|
1217
3550
|
undefined,
|
|
1218
3551
|
undefined
|
|
1219
3552
|
);
|
|
1220
3553
|
|
|
1221
|
-
const
|
|
1222
|
-
|
|
1223
|
-
path: BANNER_ROUTE_PATHS.AREA_LIST,
|
|
3554
|
+
const BANNERS_ZONE_LIST_ROUTE = {
|
|
3555
|
+
path: BANNERS_ROUTE_PATHS.ZONE_LIST,
|
|
1224
3556
|
component: __vue_component__,
|
|
1225
|
-
name: '
|
|
3557
|
+
name: 'Zones',
|
|
1226
3558
|
meta: {
|
|
1227
|
-
getBreadcrumbs: (route) =>
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
{ url: route.path, text: (_a = route.name) !== null && _a !== void 0 ? _a : '' },
|
|
1232
|
-
];
|
|
1233
|
-
},
|
|
3559
|
+
getBreadcrumbs: (route, t) => [
|
|
3560
|
+
{ url: '/', text: t('banners:home') },
|
|
3561
|
+
{ url: BANNERS_ROUTE_PATHS.ZONE_LIST, text: t('banners:zones') },
|
|
3562
|
+
],
|
|
1234
3563
|
},
|
|
1235
3564
|
};
|
|
1236
|
-
const
|
|
1237
|
-
path:
|
|
3565
|
+
const BANNERS_BANNER_LIST_ROUTE = {
|
|
3566
|
+
path: BANNERS_ROUTE_PATHS.BANNER_LIST,
|
|
1238
3567
|
component: __vue_component__$1,
|
|
1239
|
-
name: '
|
|
3568
|
+
name: 'Banners',
|
|
1240
3569
|
meta: {
|
|
1241
|
-
getBreadcrumbs: (route) =>
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
{
|
|
1246
|
-
url: BANNER_ROUTE_PATHS.AREA_LIST,
|
|
1247
|
-
text: (_a = BANNER_AREA_LIST_ROUTE.name) !== null && _a !== void 0 ? _a : '',
|
|
1248
|
-
},
|
|
1249
|
-
{ url: route.path, text: (_b = route.name) !== null && _b !== void 0 ? _b : '' },
|
|
1250
|
-
];
|
|
1251
|
-
},
|
|
3570
|
+
getBreadcrumbs: (route, t) => [
|
|
3571
|
+
{ url: '/', text: t('banners:home') },
|
|
3572
|
+
{ url: BANNERS_ROUTE_PATHS.BANNER_LIST, text: t('banners:banners') },
|
|
3573
|
+
],
|
|
1252
3574
|
},
|
|
1253
3575
|
};
|
|
1254
|
-
const
|
|
1255
|
-
path:
|
|
3576
|
+
const BANNERS_BANNER_FORM_ROUTE = {
|
|
3577
|
+
path: BANNERS_ROUTE_PATHS.BANNER_FORM,
|
|
1256
3578
|
component: __vue_component__$2,
|
|
1257
|
-
name: 'Banner
|
|
3579
|
+
name: 'Banner Form',
|
|
1258
3580
|
meta: {
|
|
1259
|
-
getBreadcrumbs: (route) =>
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
];
|
|
1265
|
-
},
|
|
1266
|
-
},
|
|
1267
|
-
};
|
|
1268
|
-
const BANNER_ITEM_FORM_ROUTE = {
|
|
1269
|
-
path: BANNER_ROUTE_PATHS.ITEM_FORM,
|
|
1270
|
-
component: __vue_component__$3,
|
|
1271
|
-
name: 'Banner Item Form',
|
|
1272
|
-
meta: {
|
|
1273
|
-
getBreadcrumbs: (route) => {
|
|
1274
|
-
var _a, _b;
|
|
1275
|
-
return [
|
|
1276
|
-
HOME_BREADCRUMB,
|
|
1277
|
-
{
|
|
1278
|
-
url: getBannerItemListUrl({ areaAlias: route.params.areaAlias }),
|
|
1279
|
-
text: (_a = BANNER_ITEM_LIST_ROUTE.name) !== null && _a !== void 0 ? _a : '',
|
|
1280
|
-
},
|
|
1281
|
-
{ url: route.path, text: (_b = route.name) !== null && _b !== void 0 ? _b : '' },
|
|
1282
|
-
];
|
|
1283
|
-
},
|
|
3581
|
+
getBreadcrumbs: (route, t) => [
|
|
3582
|
+
{ url: '/', text: t('banners:home') },
|
|
3583
|
+
{ url: BANNERS_ROUTE_PATHS.BANNER_LIST, text: t('banners:banners') },
|
|
3584
|
+
{ url: route.path, text: t('banners:bannerForm') },
|
|
3585
|
+
],
|
|
1284
3586
|
},
|
|
1285
3587
|
};
|
|
1286
3588
|
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
3589
|
+
function getBannersMenuItem(params) {
|
|
3590
|
+
return {
|
|
3591
|
+
id: 'banners',
|
|
3592
|
+
text: params.t('banners:banners'),
|
|
3593
|
+
icon: 'viewList',
|
|
3594
|
+
children: [
|
|
3595
|
+
{ text: params.t('banners:zones'), url: getBannersZoneListUrl() },
|
|
3596
|
+
{ text: params.t('banners:banners'), url: getBannersBannerListUrl() },
|
|
3597
|
+
{
|
|
3598
|
+
text: params.t('banners:createBanner'),
|
|
3599
|
+
url: getBannersBannerFormUrl({ bannerId: 'create' }),
|
|
3600
|
+
},
|
|
3601
|
+
],
|
|
3602
|
+
};
|
|
3603
|
+
}
|
|
3604
|
+
|
|
3605
|
+
adminServices.i18n.addTranslations('en', 'blog', EN);
|
|
3606
|
+
adminServices.i18n.addTranslations('ru', 'blog', RU);
|
|
1296
3607
|
|
|
1297
|
-
exports.
|
|
1298
|
-
exports.
|
|
1299
|
-
exports.
|
|
1300
|
-
exports.
|
|
1301
|
-
exports.
|
|
1302
|
-
exports.
|
|
1303
|
-
exports.
|
|
1304
|
-
exports.
|
|
1305
|
-
exports.
|
|
1306
|
-
exports.
|
|
3608
|
+
exports.BANNERS_BANNER_FORM_ROUTE = BANNERS_BANNER_FORM_ROUTE;
|
|
3609
|
+
exports.BANNERS_BANNER_LIST_ROUTE = BANNERS_BANNER_LIST_ROUTE;
|
|
3610
|
+
exports.BANNERS_ROUTE_PATHS = BANNERS_ROUTE_PATHS;
|
|
3611
|
+
exports.BANNERS_ZONE_LIST_ROUTE = BANNERS_ZONE_LIST_ROUTE;
|
|
3612
|
+
exports.createBanner = createBanner;
|
|
3613
|
+
exports.deleteBanner = deleteBanner;
|
|
3614
|
+
exports.getBanner = getBanner;
|
|
3615
|
+
exports.getBanners = getBanners;
|
|
3616
|
+
exports.getBannersBannerFormUrl = getBannersBannerFormUrl;
|
|
3617
|
+
exports.getBannersBannerListUrl = getBannersBannerListUrl;
|
|
3618
|
+
exports.getBannersMenuItem = getBannersMenuItem;
|
|
3619
|
+
exports.getBannersZoneListUrl = getBannersZoneListUrl;
|
|
3620
|
+
exports.getZones = getZones;
|
|
3621
|
+
exports.updateBanner = updateBanner;
|
|
1307
3622
|
|
|
1308
3623
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1309
3624
|
|