@tager/admin-blog 0.3.21 → 0.3.25
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/index.esm.js +3452 -612
- package/dist/index.umd.js +3454 -619
- package/package.json +13 -7
- package/src/constants/menu.ts +0 -2
- package/src/constants/paths.ts +0 -5
- package/src/constants/routes.ts +5 -18
- package/src/constants/scopes.ts +11 -0
- package/src/dev.ts +11 -44
- package/src/hooks/index.ts +6 -0
- package/src/hooks/useBlogCategoryList.ts +3 -5
- package/src/hooks/useBlogPostList.ts +2 -4
- package/src/hooks/useModuleConfig.ts +4 -8
- package/src/hooks/useStore.ts +8 -0
- package/src/hooks/useUserPermission.ts +16 -0
- package/src/hooks/useUserProfile.ts +13 -0
- package/src/locales/en.ts +17 -5
- package/src/locales/ru.ts +17 -4
- package/src/router/index.ts +39 -0
- package/src/services/requests.ts +33 -43
- package/src/store/index.ts +21 -0
- package/src/store/user.ts +109 -0
- package/src/typings/common.ts +1 -0
- package/src/typings/model.ts +62 -38
- package/src/utils/common.ts +23 -0
- package/src/views/App.vue +10 -4
- package/src/views/{BlogCategoryForm/BlogCategoryForm.helpers.ts → Categories/CategoryForm/CategoryForm.helpers.ts} +22 -7
- package/src/views/{BlogCategoryForm/BlogCategoryForm.vue → Categories/CategoryForm/CategoryForm.vue} +140 -63
- package/src/views/Categories/CategoryForm/index.ts +1 -0
- package/src/views/Categories/CategoryList/CategoryList.helpers.ts +91 -0
- package/src/views/Categories/CategoryList/CategoryList.vue +269 -0
- package/src/views/Categories/CategoryList/hooks/index.ts +1 -0
- package/src/views/Categories/CategoryList/hooks/useAdvancedSearch.ts +95 -0
- package/src/views/Categories/CategoryList/index.ts +1 -0
- package/src/views/Home.vue +2 -9
- package/src/views/Posts/PostForm/PostForm.helpers.ts +150 -0
- package/src/views/Posts/PostForm/PostForm.vue +550 -0
- package/src/views/{BlogPostForm → Posts/PostForm}/components/TabList/TabList.types.ts +0 -0
- package/src/views/{BlogPostForm → Posts/PostForm}/components/TabList/TabList.vue +1 -1
- package/src/views/{BlogPostForm → Posts/PostForm}/components/TabList/index.ts +0 -0
- package/src/views/Posts/PostForm/index.ts +1 -0
- package/src/views/{BlogPostList/BlogPostList.helpers.ts → Posts/PostList/PostList.helpers.ts} +10 -18
- package/src/views/Posts/PostList/PostList.vue +361 -0
- package/src/views/Posts/PostList/hooks/index.ts +1 -0
- package/src/views/Posts/PostList/hooks/useAdvancedSearch.ts +250 -0
- package/src/views/Posts/PostList/index.ts +1 -0
- package/dist/constants/menu.d.ts +0 -5
- package/dist/constants/paths.d.ts +0 -16
- package/dist/constants/routes.d.ts +0 -6
- package/dist/dev.d.ts +0 -3
- package/dist/hooks/useBlogCategoryList.d.ts +0 -7
- package/dist/hooks/useBlogPostList.d.ts +0 -7
- package/dist/hooks/useModuleConfig.d.ts +0 -7
- package/dist/locales/en.d.ts +0 -63
- package/dist/locales/ru.d.ts +0 -3
- package/dist/main.d.ts +0 -4
- package/dist/services/requests.d.ts +0 -68
- package/dist/typings/model.d.ts +0 -74
- package/dist/views/BlogCategoryForm/BlogCategoryForm.helpers.d.ts +0 -16
- package/dist/views/BlogCategoryForm/BlogCategoryForm.vue.d.ts +0 -86
- package/dist/views/BlogCategoryForm/index.d.ts +0 -1
- package/dist/views/BlogCategoryList/BlogCategoryList.helpers.d.ts +0 -6
- package/dist/views/BlogCategoryList/BlogCategoryList.vue.d.ts +0 -3
- package/dist/views/BlogCategoryList/index.d.ts +0 -1
- package/dist/views/BlogPostForm/BlogPostForm.helpers.d.ts +0 -27
- package/dist/views/BlogPostForm/BlogPostForm.vue.d.ts +0 -9320
- package/dist/views/BlogPostForm/components/TabList/TabList.types.d.ts +0 -5
- package/dist/views/BlogPostForm/components/TabList/index.d.ts +0 -2
- package/dist/views/BlogPostForm/index.d.ts +0 -1
- package/dist/views/BlogPostList/BlogPostList.helpers.d.ts +0 -6
- package/dist/views/BlogPostList/BlogPostList.vue.d.ts +0 -45
- package/dist/views/BlogPostList/index.d.ts +0 -1
- package/dist/views/BlogSettings/BlogSettings.helpers.d.ts +0 -6
- package/dist/views/BlogSettings/BlogSettings.vue.d.ts +0 -9132
- package/dist/views/BlogSettings/index.d.ts +0 -1
- package/src/views/BlogCategoryForm/index.ts +0 -1
- package/src/views/BlogCategoryList/BlogCategoryList.helpers.ts +0 -82
- package/src/views/BlogCategoryList/BlogCategoryList.vue +0 -196
- package/src/views/BlogCategoryList/index.ts +0 -1
- package/src/views/BlogPostForm/BlogPostForm.helpers.ts +0 -152
- package/src/views/BlogPostForm/BlogPostForm.vue +0 -534
- package/src/views/BlogPostForm/index.ts +0 -1
- package/src/views/BlogPostList/BlogPostList.vue +0 -174
- package/src/views/BlogPostList/index.ts +0 -1
- package/src/views/BlogSettings/BlogSettings.helpers.ts +0 -25
- package/src/views/BlogSettings/BlogSettings.vue +0 -110
- package/src/views/BlogSettings/index.ts +0 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
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'), require('@tager/admin-dynamic-field')
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@tager/admin-services', '@vue/composition-api', '@tager/admin-ui', 'path-to-regexp', '@tager/admin-dynamic-field'
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TagerAdminBlog = {}, global.adminServices, global.compositionApi, global.adminUi, global.pathToRegexp, global.adminDynamicField
|
|
5
|
-
}(this, (function (exports, adminServices, compositionApi, adminUi, pathToRegexp, adminDynamicField
|
|
6
|
-
|
|
7
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
-
|
|
9
|
-
var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);
|
|
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'), require('@tager/admin-dynamic-field')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@tager/admin-services', '@vue/composition-api', '@tager/admin-ui', 'path-to-regexp', '@tager/admin-dynamic-field'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TagerAdminBlog = {}, global.adminServices, global.compositionApi, global.adminUi, global.pathToRegexp, global.adminDynamicField));
|
|
5
|
+
}(this, (function (exports, adminServices, compositionApi, adminUi, pathToRegexp, adminDynamicField) { 'use strict';
|
|
10
6
|
|
|
11
7
|
const EN = {
|
|
12
8
|
yes: 'Yes',
|
|
@@ -16,17 +12,13 @@
|
|
|
16
12
|
categories: 'Categories',
|
|
17
13
|
createPost: 'Create post',
|
|
18
14
|
createCategory: 'Create category',
|
|
19
|
-
settings: 'Settings',
|
|
20
15
|
home: 'Home',
|
|
21
16
|
allPosts: 'All posts',
|
|
22
17
|
postForm: 'Post Form',
|
|
23
18
|
allCategories: 'All categories',
|
|
24
19
|
categoryForm: 'Category Form',
|
|
25
|
-
blogSettings: 'Blog settings',
|
|
26
20
|
success: 'Success',
|
|
27
|
-
blogSettingsHaveBeenSuccessfullyUpdated: 'Blog settings have been successfully updated',
|
|
28
21
|
error: 'Error',
|
|
29
|
-
blogSettingsUpdateHasBeenFailed: 'Blog settings update has been failed',
|
|
30
22
|
newPost: 'New Post',
|
|
31
23
|
edit: 'Edit',
|
|
32
24
|
remove: 'Remove',
|
|
@@ -34,7 +26,14 @@
|
|
|
34
26
|
name: 'Name',
|
|
35
27
|
image: 'Image',
|
|
36
28
|
language: 'Language',
|
|
29
|
+
languages: 'Languages',
|
|
37
30
|
date: 'Date',
|
|
31
|
+
dateOfPublication: 'Date of publication',
|
|
32
|
+
from: 'from',
|
|
33
|
+
to: 'to',
|
|
34
|
+
From: 'From',
|
|
35
|
+
To: 'To',
|
|
36
|
+
category: 'Category',
|
|
38
37
|
actions: 'Actions',
|
|
39
38
|
updatePost: 'Update post',
|
|
40
39
|
title: 'Title',
|
|
@@ -69,6 +68,14 @@
|
|
|
69
68
|
blogCategoryWasSuccessfullyUpdated: 'Blog category was successfully updated',
|
|
70
69
|
blogCategoryCreationWasFailed: 'Blog category creation was failed',
|
|
71
70
|
blogCategoryUpdateWasFailed: 'Blog category update was failed',
|
|
71
|
+
clone: 'Clone',
|
|
72
|
+
cloneConfirm: 'Are you sure you want to clone the page?',
|
|
73
|
+
cloneSuccess: 'Page have copied successfully',
|
|
74
|
+
cloneFailure: 'Page copy failure',
|
|
75
|
+
tabs: {
|
|
76
|
+
common: 'Common',
|
|
77
|
+
seo: 'SEO',
|
|
78
|
+
},
|
|
72
79
|
};
|
|
73
80
|
|
|
74
81
|
const RU = {
|
|
@@ -79,17 +86,13 @@
|
|
|
79
86
|
categories: 'Категории',
|
|
80
87
|
createPost: 'Создать пост',
|
|
81
88
|
createCategory: 'Создать категорию',
|
|
82
|
-
settings: 'Настройки',
|
|
83
89
|
home: 'Главная',
|
|
84
90
|
allPosts: 'Все посты',
|
|
85
91
|
postForm: 'Форма поста',
|
|
86
92
|
allCategories: 'Все категории',
|
|
87
93
|
categoryForm: 'Форма категории',
|
|
88
|
-
blogSettings: 'Настройки блога',
|
|
89
94
|
success: 'Успех',
|
|
90
|
-
blogSettingsHaveBeenSuccessfullyUpdated: 'Настройки блога успешно обновлены',
|
|
91
95
|
error: 'Ошибка',
|
|
92
|
-
blogSettingsUpdateHasBeenFailed: 'Не удалось обновить настройки блога',
|
|
93
96
|
newPost: 'Новый пост',
|
|
94
97
|
edit: 'Редактировать',
|
|
95
98
|
remove: 'Удалить',
|
|
@@ -97,7 +100,14 @@
|
|
|
97
100
|
name: 'Имя',
|
|
98
101
|
image: 'Изображение',
|
|
99
102
|
language: 'Язык',
|
|
103
|
+
languages: 'Языки',
|
|
100
104
|
date: 'Дата',
|
|
105
|
+
dateOfPublication: 'Дата публикации',
|
|
106
|
+
from: 'от',
|
|
107
|
+
to: 'до',
|
|
108
|
+
From: 'От',
|
|
109
|
+
To: 'До',
|
|
110
|
+
category: 'Категория',
|
|
101
111
|
actions: 'Действия',
|
|
102
112
|
updatePost: 'Обновить пост',
|
|
103
113
|
title: 'Заголовок',
|
|
@@ -132,8 +142,2390 @@
|
|
|
132
142
|
blogCategoryWasSuccessfullyUpdated: 'Категория блога успешно обновлена',
|
|
133
143
|
blogCategoryCreationWasFailed: 'Не удалось создать категорию блога',
|
|
134
144
|
blogCategoryUpdateWasFailed: 'Не удалось обновить категорию блога',
|
|
145
|
+
clone: 'Клонировать',
|
|
146
|
+
cloneConfirm: 'Вы уверены, что хотите создать копию страницы?',
|
|
147
|
+
cloneSuccess: 'Копия страницы успешно создана',
|
|
148
|
+
cloneFailure: 'Ошибка копирования страницы',
|
|
149
|
+
tabs: {
|
|
150
|
+
common: 'Общие',
|
|
151
|
+
seo: 'SEO',
|
|
152
|
+
},
|
|
135
153
|
};
|
|
136
154
|
|
|
155
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
156
|
+
|
|
157
|
+
function createCommonjsModule(fn, basedir, module) {
|
|
158
|
+
return module = {
|
|
159
|
+
path: basedir,
|
|
160
|
+
exports: {},
|
|
161
|
+
require: function (path, base) {
|
|
162
|
+
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
|
|
163
|
+
}
|
|
164
|
+
}, fn(module, module.exports), module.exports;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function commonjsRequire () {
|
|
168
|
+
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
var lodash_isequal = createCommonjsModule(function (module, exports) {
|
|
172
|
+
/**
|
|
173
|
+
* Lodash (Custom Build) <https://lodash.com/>
|
|
174
|
+
* Build: `lodash modularize exports="npm" -o ./`
|
|
175
|
+
* Copyright JS Foundation and other contributors <https://js.foundation/>
|
|
176
|
+
* Released under MIT license <https://lodash.com/license>
|
|
177
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
178
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
/** Used as the size to enable large array optimizations. */
|
|
182
|
+
var LARGE_ARRAY_SIZE = 200;
|
|
183
|
+
|
|
184
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
185
|
+
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
|
186
|
+
|
|
187
|
+
/** Used to compose bitmasks for value comparisons. */
|
|
188
|
+
var COMPARE_PARTIAL_FLAG = 1,
|
|
189
|
+
COMPARE_UNORDERED_FLAG = 2;
|
|
190
|
+
|
|
191
|
+
/** Used as references for various `Number` constants. */
|
|
192
|
+
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
193
|
+
|
|
194
|
+
/** `Object#toString` result references. */
|
|
195
|
+
var argsTag = '[object Arguments]',
|
|
196
|
+
arrayTag = '[object Array]',
|
|
197
|
+
asyncTag = '[object AsyncFunction]',
|
|
198
|
+
boolTag = '[object Boolean]',
|
|
199
|
+
dateTag = '[object Date]',
|
|
200
|
+
errorTag = '[object Error]',
|
|
201
|
+
funcTag = '[object Function]',
|
|
202
|
+
genTag = '[object GeneratorFunction]',
|
|
203
|
+
mapTag = '[object Map]',
|
|
204
|
+
numberTag = '[object Number]',
|
|
205
|
+
nullTag = '[object Null]',
|
|
206
|
+
objectTag = '[object Object]',
|
|
207
|
+
promiseTag = '[object Promise]',
|
|
208
|
+
proxyTag = '[object Proxy]',
|
|
209
|
+
regexpTag = '[object RegExp]',
|
|
210
|
+
setTag = '[object Set]',
|
|
211
|
+
stringTag = '[object String]',
|
|
212
|
+
symbolTag = '[object Symbol]',
|
|
213
|
+
undefinedTag = '[object Undefined]',
|
|
214
|
+
weakMapTag = '[object WeakMap]';
|
|
215
|
+
|
|
216
|
+
var arrayBufferTag = '[object ArrayBuffer]',
|
|
217
|
+
dataViewTag = '[object DataView]',
|
|
218
|
+
float32Tag = '[object Float32Array]',
|
|
219
|
+
float64Tag = '[object Float64Array]',
|
|
220
|
+
int8Tag = '[object Int8Array]',
|
|
221
|
+
int16Tag = '[object Int16Array]',
|
|
222
|
+
int32Tag = '[object Int32Array]',
|
|
223
|
+
uint8Tag = '[object Uint8Array]',
|
|
224
|
+
uint8ClampedTag = '[object Uint8ClampedArray]',
|
|
225
|
+
uint16Tag = '[object Uint16Array]',
|
|
226
|
+
uint32Tag = '[object Uint32Array]';
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Used to match `RegExp`
|
|
230
|
+
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|
231
|
+
*/
|
|
232
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
233
|
+
|
|
234
|
+
/** Used to detect host constructors (Safari). */
|
|
235
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
236
|
+
|
|
237
|
+
/** Used to detect unsigned integer values. */
|
|
238
|
+
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|
239
|
+
|
|
240
|
+
/** Used to identify `toStringTag` values of typed arrays. */
|
|
241
|
+
var typedArrayTags = {};
|
|
242
|
+
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
|
|
243
|
+
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
|
|
244
|
+
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
|
|
245
|
+
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
|
|
246
|
+
typedArrayTags[uint32Tag] = true;
|
|
247
|
+
typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
|
|
248
|
+
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
|
|
249
|
+
typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
|
|
250
|
+
typedArrayTags[errorTag] = typedArrayTags[funcTag] =
|
|
251
|
+
typedArrayTags[mapTag] = typedArrayTags[numberTag] =
|
|
252
|
+
typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
|
|
253
|
+
typedArrayTags[setTag] = typedArrayTags[stringTag] =
|
|
254
|
+
typedArrayTags[weakMapTag] = false;
|
|
255
|
+
|
|
256
|
+
/** Detect free variable `global` from Node.js. */
|
|
257
|
+
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
258
|
+
|
|
259
|
+
/** Detect free variable `self`. */
|
|
260
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
261
|
+
|
|
262
|
+
/** Used as a reference to the global object. */
|
|
263
|
+
var root = freeGlobal || freeSelf || Function('return this')();
|
|
264
|
+
|
|
265
|
+
/** Detect free variable `exports`. */
|
|
266
|
+
var freeExports = exports && !exports.nodeType && exports;
|
|
267
|
+
|
|
268
|
+
/** Detect free variable `module`. */
|
|
269
|
+
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
|
270
|
+
|
|
271
|
+
/** Detect the popular CommonJS extension `module.exports`. */
|
|
272
|
+
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
273
|
+
|
|
274
|
+
/** Detect free variable `process` from Node.js. */
|
|
275
|
+
var freeProcess = moduleExports && freeGlobal.process;
|
|
276
|
+
|
|
277
|
+
/** Used to access faster Node.js helpers. */
|
|
278
|
+
var nodeUtil = (function() {
|
|
279
|
+
try {
|
|
280
|
+
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
|
281
|
+
} catch (e) {}
|
|
282
|
+
}());
|
|
283
|
+
|
|
284
|
+
/* Node.js helper references. */
|
|
285
|
+
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* A specialized version of `_.filter` for arrays without support for
|
|
289
|
+
* iteratee shorthands.
|
|
290
|
+
*
|
|
291
|
+
* @private
|
|
292
|
+
* @param {Array} [array] The array to iterate over.
|
|
293
|
+
* @param {Function} predicate The function invoked per iteration.
|
|
294
|
+
* @returns {Array} Returns the new filtered array.
|
|
295
|
+
*/
|
|
296
|
+
function arrayFilter(array, predicate) {
|
|
297
|
+
var index = -1,
|
|
298
|
+
length = array == null ? 0 : array.length,
|
|
299
|
+
resIndex = 0,
|
|
300
|
+
result = [];
|
|
301
|
+
|
|
302
|
+
while (++index < length) {
|
|
303
|
+
var value = array[index];
|
|
304
|
+
if (predicate(value, index, array)) {
|
|
305
|
+
result[resIndex++] = value;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return result;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Appends the elements of `values` to `array`.
|
|
313
|
+
*
|
|
314
|
+
* @private
|
|
315
|
+
* @param {Array} array The array to modify.
|
|
316
|
+
* @param {Array} values The values to append.
|
|
317
|
+
* @returns {Array} Returns `array`.
|
|
318
|
+
*/
|
|
319
|
+
function arrayPush(array, values) {
|
|
320
|
+
var index = -1,
|
|
321
|
+
length = values.length,
|
|
322
|
+
offset = array.length;
|
|
323
|
+
|
|
324
|
+
while (++index < length) {
|
|
325
|
+
array[offset + index] = values[index];
|
|
326
|
+
}
|
|
327
|
+
return array;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* A specialized version of `_.some` for arrays without support for iteratee
|
|
332
|
+
* shorthands.
|
|
333
|
+
*
|
|
334
|
+
* @private
|
|
335
|
+
* @param {Array} [array] The array to iterate over.
|
|
336
|
+
* @param {Function} predicate The function invoked per iteration.
|
|
337
|
+
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
|
338
|
+
* else `false`.
|
|
339
|
+
*/
|
|
340
|
+
function arraySome(array, predicate) {
|
|
341
|
+
var index = -1,
|
|
342
|
+
length = array == null ? 0 : array.length;
|
|
343
|
+
|
|
344
|
+
while (++index < length) {
|
|
345
|
+
if (predicate(array[index], index, array)) {
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* The base implementation of `_.times` without support for iteratee shorthands
|
|
354
|
+
* or max array length checks.
|
|
355
|
+
*
|
|
356
|
+
* @private
|
|
357
|
+
* @param {number} n The number of times to invoke `iteratee`.
|
|
358
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
359
|
+
* @returns {Array} Returns the array of results.
|
|
360
|
+
*/
|
|
361
|
+
function baseTimes(n, iteratee) {
|
|
362
|
+
var index = -1,
|
|
363
|
+
result = Array(n);
|
|
364
|
+
|
|
365
|
+
while (++index < n) {
|
|
366
|
+
result[index] = iteratee(index);
|
|
367
|
+
}
|
|
368
|
+
return result;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* The base implementation of `_.unary` without support for storing metadata.
|
|
373
|
+
*
|
|
374
|
+
* @private
|
|
375
|
+
* @param {Function} func The function to cap arguments for.
|
|
376
|
+
* @returns {Function} Returns the new capped function.
|
|
377
|
+
*/
|
|
378
|
+
function baseUnary(func) {
|
|
379
|
+
return function(value) {
|
|
380
|
+
return func(value);
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Checks if a `cache` value for `key` exists.
|
|
386
|
+
*
|
|
387
|
+
* @private
|
|
388
|
+
* @param {Object} cache The cache to query.
|
|
389
|
+
* @param {string} key The key of the entry to check.
|
|
390
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
391
|
+
*/
|
|
392
|
+
function cacheHas(cache, key) {
|
|
393
|
+
return cache.has(key);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Gets the value at `key` of `object`.
|
|
398
|
+
*
|
|
399
|
+
* @private
|
|
400
|
+
* @param {Object} [object] The object to query.
|
|
401
|
+
* @param {string} key The key of the property to get.
|
|
402
|
+
* @returns {*} Returns the property value.
|
|
403
|
+
*/
|
|
404
|
+
function getValue(object, key) {
|
|
405
|
+
return object == null ? undefined : object[key];
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Converts `map` to its key-value pairs.
|
|
410
|
+
*
|
|
411
|
+
* @private
|
|
412
|
+
* @param {Object} map The map to convert.
|
|
413
|
+
* @returns {Array} Returns the key-value pairs.
|
|
414
|
+
*/
|
|
415
|
+
function mapToArray(map) {
|
|
416
|
+
var index = -1,
|
|
417
|
+
result = Array(map.size);
|
|
418
|
+
|
|
419
|
+
map.forEach(function(value, key) {
|
|
420
|
+
result[++index] = [key, value];
|
|
421
|
+
});
|
|
422
|
+
return result;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Creates a unary function that invokes `func` with its argument transformed.
|
|
427
|
+
*
|
|
428
|
+
* @private
|
|
429
|
+
* @param {Function} func The function to wrap.
|
|
430
|
+
* @param {Function} transform The argument transform.
|
|
431
|
+
* @returns {Function} Returns the new function.
|
|
432
|
+
*/
|
|
433
|
+
function overArg(func, transform) {
|
|
434
|
+
return function(arg) {
|
|
435
|
+
return func(transform(arg));
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Converts `set` to an array of its values.
|
|
441
|
+
*
|
|
442
|
+
* @private
|
|
443
|
+
* @param {Object} set The set to convert.
|
|
444
|
+
* @returns {Array} Returns the values.
|
|
445
|
+
*/
|
|
446
|
+
function setToArray(set) {
|
|
447
|
+
var index = -1,
|
|
448
|
+
result = Array(set.size);
|
|
449
|
+
|
|
450
|
+
set.forEach(function(value) {
|
|
451
|
+
result[++index] = value;
|
|
452
|
+
});
|
|
453
|
+
return result;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/** Used for built-in method references. */
|
|
457
|
+
var arrayProto = Array.prototype,
|
|
458
|
+
funcProto = Function.prototype,
|
|
459
|
+
objectProto = Object.prototype;
|
|
460
|
+
|
|
461
|
+
/** Used to detect overreaching core-js shims. */
|
|
462
|
+
var coreJsData = root['__core-js_shared__'];
|
|
463
|
+
|
|
464
|
+
/** Used to resolve the decompiled source of functions. */
|
|
465
|
+
var funcToString = funcProto.toString;
|
|
466
|
+
|
|
467
|
+
/** Used to check objects for own properties. */
|
|
468
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
469
|
+
|
|
470
|
+
/** Used to detect methods masquerading as native. */
|
|
471
|
+
var maskSrcKey = (function() {
|
|
472
|
+
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
|
473
|
+
return uid ? ('Symbol(src)_1.' + uid) : '';
|
|
474
|
+
}());
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Used to resolve the
|
|
478
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
479
|
+
* of values.
|
|
480
|
+
*/
|
|
481
|
+
var nativeObjectToString = objectProto.toString;
|
|
482
|
+
|
|
483
|
+
/** Used to detect if a method is native. */
|
|
484
|
+
var reIsNative = RegExp('^' +
|
|
485
|
+
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
|
|
486
|
+
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
|
487
|
+
);
|
|
488
|
+
|
|
489
|
+
/** Built-in value references. */
|
|
490
|
+
var Buffer = moduleExports ? root.Buffer : undefined,
|
|
491
|
+
Symbol = root.Symbol,
|
|
492
|
+
Uint8Array = root.Uint8Array,
|
|
493
|
+
propertyIsEnumerable = objectProto.propertyIsEnumerable,
|
|
494
|
+
splice = arrayProto.splice,
|
|
495
|
+
symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
|
496
|
+
|
|
497
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
498
|
+
var nativeGetSymbols = Object.getOwnPropertySymbols,
|
|
499
|
+
nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
|
|
500
|
+
nativeKeys = overArg(Object.keys, Object);
|
|
501
|
+
|
|
502
|
+
/* Built-in method references that are verified to be native. */
|
|
503
|
+
var DataView = getNative(root, 'DataView'),
|
|
504
|
+
Map = getNative(root, 'Map'),
|
|
505
|
+
Promise = getNative(root, 'Promise'),
|
|
506
|
+
Set = getNative(root, 'Set'),
|
|
507
|
+
WeakMap = getNative(root, 'WeakMap'),
|
|
508
|
+
nativeCreate = getNative(Object, 'create');
|
|
509
|
+
|
|
510
|
+
/** Used to detect maps, sets, and weakmaps. */
|
|
511
|
+
var dataViewCtorString = toSource(DataView),
|
|
512
|
+
mapCtorString = toSource(Map),
|
|
513
|
+
promiseCtorString = toSource(Promise),
|
|
514
|
+
setCtorString = toSource(Set),
|
|
515
|
+
weakMapCtorString = toSource(WeakMap);
|
|
516
|
+
|
|
517
|
+
/** Used to convert symbols to primitives and strings. */
|
|
518
|
+
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
|
519
|
+
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Creates a hash object.
|
|
523
|
+
*
|
|
524
|
+
* @private
|
|
525
|
+
* @constructor
|
|
526
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
527
|
+
*/
|
|
528
|
+
function Hash(entries) {
|
|
529
|
+
var index = -1,
|
|
530
|
+
length = entries == null ? 0 : entries.length;
|
|
531
|
+
|
|
532
|
+
this.clear();
|
|
533
|
+
while (++index < length) {
|
|
534
|
+
var entry = entries[index];
|
|
535
|
+
this.set(entry[0], entry[1]);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Removes all key-value entries from the hash.
|
|
541
|
+
*
|
|
542
|
+
* @private
|
|
543
|
+
* @name clear
|
|
544
|
+
* @memberOf Hash
|
|
545
|
+
*/
|
|
546
|
+
function hashClear() {
|
|
547
|
+
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
|
548
|
+
this.size = 0;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Removes `key` and its value from the hash.
|
|
553
|
+
*
|
|
554
|
+
* @private
|
|
555
|
+
* @name delete
|
|
556
|
+
* @memberOf Hash
|
|
557
|
+
* @param {Object} hash The hash to modify.
|
|
558
|
+
* @param {string} key The key of the value to remove.
|
|
559
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
560
|
+
*/
|
|
561
|
+
function hashDelete(key) {
|
|
562
|
+
var result = this.has(key) && delete this.__data__[key];
|
|
563
|
+
this.size -= result ? 1 : 0;
|
|
564
|
+
return result;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Gets the hash value for `key`.
|
|
569
|
+
*
|
|
570
|
+
* @private
|
|
571
|
+
* @name get
|
|
572
|
+
* @memberOf Hash
|
|
573
|
+
* @param {string} key The key of the value to get.
|
|
574
|
+
* @returns {*} Returns the entry value.
|
|
575
|
+
*/
|
|
576
|
+
function hashGet(key) {
|
|
577
|
+
var data = this.__data__;
|
|
578
|
+
if (nativeCreate) {
|
|
579
|
+
var result = data[key];
|
|
580
|
+
return result === HASH_UNDEFINED ? undefined : result;
|
|
581
|
+
}
|
|
582
|
+
return hasOwnProperty.call(data, key) ? data[key] : undefined;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Checks if a hash value for `key` exists.
|
|
587
|
+
*
|
|
588
|
+
* @private
|
|
589
|
+
* @name has
|
|
590
|
+
* @memberOf Hash
|
|
591
|
+
* @param {string} key The key of the entry to check.
|
|
592
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
593
|
+
*/
|
|
594
|
+
function hashHas(key) {
|
|
595
|
+
var data = this.__data__;
|
|
596
|
+
return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Sets the hash `key` to `value`.
|
|
601
|
+
*
|
|
602
|
+
* @private
|
|
603
|
+
* @name set
|
|
604
|
+
* @memberOf Hash
|
|
605
|
+
* @param {string} key The key of the value to set.
|
|
606
|
+
* @param {*} value The value to set.
|
|
607
|
+
* @returns {Object} Returns the hash instance.
|
|
608
|
+
*/
|
|
609
|
+
function hashSet(key, value) {
|
|
610
|
+
var data = this.__data__;
|
|
611
|
+
this.size += this.has(key) ? 0 : 1;
|
|
612
|
+
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
|
|
613
|
+
return this;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
// Add methods to `Hash`.
|
|
617
|
+
Hash.prototype.clear = hashClear;
|
|
618
|
+
Hash.prototype['delete'] = hashDelete;
|
|
619
|
+
Hash.prototype.get = hashGet;
|
|
620
|
+
Hash.prototype.has = hashHas;
|
|
621
|
+
Hash.prototype.set = hashSet;
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Creates an list cache object.
|
|
625
|
+
*
|
|
626
|
+
* @private
|
|
627
|
+
* @constructor
|
|
628
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
629
|
+
*/
|
|
630
|
+
function ListCache(entries) {
|
|
631
|
+
var index = -1,
|
|
632
|
+
length = entries == null ? 0 : entries.length;
|
|
633
|
+
|
|
634
|
+
this.clear();
|
|
635
|
+
while (++index < length) {
|
|
636
|
+
var entry = entries[index];
|
|
637
|
+
this.set(entry[0], entry[1]);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Removes all key-value entries from the list cache.
|
|
643
|
+
*
|
|
644
|
+
* @private
|
|
645
|
+
* @name clear
|
|
646
|
+
* @memberOf ListCache
|
|
647
|
+
*/
|
|
648
|
+
function listCacheClear() {
|
|
649
|
+
this.__data__ = [];
|
|
650
|
+
this.size = 0;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Removes `key` and its value from the list cache.
|
|
655
|
+
*
|
|
656
|
+
* @private
|
|
657
|
+
* @name delete
|
|
658
|
+
* @memberOf ListCache
|
|
659
|
+
* @param {string} key The key of the value to remove.
|
|
660
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
661
|
+
*/
|
|
662
|
+
function listCacheDelete(key) {
|
|
663
|
+
var data = this.__data__,
|
|
664
|
+
index = assocIndexOf(data, key);
|
|
665
|
+
|
|
666
|
+
if (index < 0) {
|
|
667
|
+
return false;
|
|
668
|
+
}
|
|
669
|
+
var lastIndex = data.length - 1;
|
|
670
|
+
if (index == lastIndex) {
|
|
671
|
+
data.pop();
|
|
672
|
+
} else {
|
|
673
|
+
splice.call(data, index, 1);
|
|
674
|
+
}
|
|
675
|
+
--this.size;
|
|
676
|
+
return true;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Gets the list cache value for `key`.
|
|
681
|
+
*
|
|
682
|
+
* @private
|
|
683
|
+
* @name get
|
|
684
|
+
* @memberOf ListCache
|
|
685
|
+
* @param {string} key The key of the value to get.
|
|
686
|
+
* @returns {*} Returns the entry value.
|
|
687
|
+
*/
|
|
688
|
+
function listCacheGet(key) {
|
|
689
|
+
var data = this.__data__,
|
|
690
|
+
index = assocIndexOf(data, key);
|
|
691
|
+
|
|
692
|
+
return index < 0 ? undefined : data[index][1];
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* Checks if a list cache value for `key` exists.
|
|
697
|
+
*
|
|
698
|
+
* @private
|
|
699
|
+
* @name has
|
|
700
|
+
* @memberOf ListCache
|
|
701
|
+
* @param {string} key The key of the entry to check.
|
|
702
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
703
|
+
*/
|
|
704
|
+
function listCacheHas(key) {
|
|
705
|
+
return assocIndexOf(this.__data__, key) > -1;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Sets the list cache `key` to `value`.
|
|
710
|
+
*
|
|
711
|
+
* @private
|
|
712
|
+
* @name set
|
|
713
|
+
* @memberOf ListCache
|
|
714
|
+
* @param {string} key The key of the value to set.
|
|
715
|
+
* @param {*} value The value to set.
|
|
716
|
+
* @returns {Object} Returns the list cache instance.
|
|
717
|
+
*/
|
|
718
|
+
function listCacheSet(key, value) {
|
|
719
|
+
var data = this.__data__,
|
|
720
|
+
index = assocIndexOf(data, key);
|
|
721
|
+
|
|
722
|
+
if (index < 0) {
|
|
723
|
+
++this.size;
|
|
724
|
+
data.push([key, value]);
|
|
725
|
+
} else {
|
|
726
|
+
data[index][1] = value;
|
|
727
|
+
}
|
|
728
|
+
return this;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
// Add methods to `ListCache`.
|
|
732
|
+
ListCache.prototype.clear = listCacheClear;
|
|
733
|
+
ListCache.prototype['delete'] = listCacheDelete;
|
|
734
|
+
ListCache.prototype.get = listCacheGet;
|
|
735
|
+
ListCache.prototype.has = listCacheHas;
|
|
736
|
+
ListCache.prototype.set = listCacheSet;
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Creates a map cache object to store key-value pairs.
|
|
740
|
+
*
|
|
741
|
+
* @private
|
|
742
|
+
* @constructor
|
|
743
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
744
|
+
*/
|
|
745
|
+
function MapCache(entries) {
|
|
746
|
+
var index = -1,
|
|
747
|
+
length = entries == null ? 0 : entries.length;
|
|
748
|
+
|
|
749
|
+
this.clear();
|
|
750
|
+
while (++index < length) {
|
|
751
|
+
var entry = entries[index];
|
|
752
|
+
this.set(entry[0], entry[1]);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* Removes all key-value entries from the map.
|
|
758
|
+
*
|
|
759
|
+
* @private
|
|
760
|
+
* @name clear
|
|
761
|
+
* @memberOf MapCache
|
|
762
|
+
*/
|
|
763
|
+
function mapCacheClear() {
|
|
764
|
+
this.size = 0;
|
|
765
|
+
this.__data__ = {
|
|
766
|
+
'hash': new Hash,
|
|
767
|
+
'map': new (Map || ListCache),
|
|
768
|
+
'string': new Hash
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* Removes `key` and its value from the map.
|
|
774
|
+
*
|
|
775
|
+
* @private
|
|
776
|
+
* @name delete
|
|
777
|
+
* @memberOf MapCache
|
|
778
|
+
* @param {string} key The key of the value to remove.
|
|
779
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
780
|
+
*/
|
|
781
|
+
function mapCacheDelete(key) {
|
|
782
|
+
var result = getMapData(this, key)['delete'](key);
|
|
783
|
+
this.size -= result ? 1 : 0;
|
|
784
|
+
return result;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* Gets the map value for `key`.
|
|
789
|
+
*
|
|
790
|
+
* @private
|
|
791
|
+
* @name get
|
|
792
|
+
* @memberOf MapCache
|
|
793
|
+
* @param {string} key The key of the value to get.
|
|
794
|
+
* @returns {*} Returns the entry value.
|
|
795
|
+
*/
|
|
796
|
+
function mapCacheGet(key) {
|
|
797
|
+
return getMapData(this, key).get(key);
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* Checks if a map value for `key` exists.
|
|
802
|
+
*
|
|
803
|
+
* @private
|
|
804
|
+
* @name has
|
|
805
|
+
* @memberOf MapCache
|
|
806
|
+
* @param {string} key The key of the entry to check.
|
|
807
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
808
|
+
*/
|
|
809
|
+
function mapCacheHas(key) {
|
|
810
|
+
return getMapData(this, key).has(key);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* Sets the map `key` to `value`.
|
|
815
|
+
*
|
|
816
|
+
* @private
|
|
817
|
+
* @name set
|
|
818
|
+
* @memberOf MapCache
|
|
819
|
+
* @param {string} key The key of the value to set.
|
|
820
|
+
* @param {*} value The value to set.
|
|
821
|
+
* @returns {Object} Returns the map cache instance.
|
|
822
|
+
*/
|
|
823
|
+
function mapCacheSet(key, value) {
|
|
824
|
+
var data = getMapData(this, key),
|
|
825
|
+
size = data.size;
|
|
826
|
+
|
|
827
|
+
data.set(key, value);
|
|
828
|
+
this.size += data.size == size ? 0 : 1;
|
|
829
|
+
return this;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
// Add methods to `MapCache`.
|
|
833
|
+
MapCache.prototype.clear = mapCacheClear;
|
|
834
|
+
MapCache.prototype['delete'] = mapCacheDelete;
|
|
835
|
+
MapCache.prototype.get = mapCacheGet;
|
|
836
|
+
MapCache.prototype.has = mapCacheHas;
|
|
837
|
+
MapCache.prototype.set = mapCacheSet;
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
*
|
|
841
|
+
* Creates an array cache object to store unique values.
|
|
842
|
+
*
|
|
843
|
+
* @private
|
|
844
|
+
* @constructor
|
|
845
|
+
* @param {Array} [values] The values to cache.
|
|
846
|
+
*/
|
|
847
|
+
function SetCache(values) {
|
|
848
|
+
var index = -1,
|
|
849
|
+
length = values == null ? 0 : values.length;
|
|
850
|
+
|
|
851
|
+
this.__data__ = new MapCache;
|
|
852
|
+
while (++index < length) {
|
|
853
|
+
this.add(values[index]);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* Adds `value` to the array cache.
|
|
859
|
+
*
|
|
860
|
+
* @private
|
|
861
|
+
* @name add
|
|
862
|
+
* @memberOf SetCache
|
|
863
|
+
* @alias push
|
|
864
|
+
* @param {*} value The value to cache.
|
|
865
|
+
* @returns {Object} Returns the cache instance.
|
|
866
|
+
*/
|
|
867
|
+
function setCacheAdd(value) {
|
|
868
|
+
this.__data__.set(value, HASH_UNDEFINED);
|
|
869
|
+
return this;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* Checks if `value` is in the array cache.
|
|
874
|
+
*
|
|
875
|
+
* @private
|
|
876
|
+
* @name has
|
|
877
|
+
* @memberOf SetCache
|
|
878
|
+
* @param {*} value The value to search for.
|
|
879
|
+
* @returns {number} Returns `true` if `value` is found, else `false`.
|
|
880
|
+
*/
|
|
881
|
+
function setCacheHas(value) {
|
|
882
|
+
return this.__data__.has(value);
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
// Add methods to `SetCache`.
|
|
886
|
+
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
|
|
887
|
+
SetCache.prototype.has = setCacheHas;
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* Creates a stack cache object to store key-value pairs.
|
|
891
|
+
*
|
|
892
|
+
* @private
|
|
893
|
+
* @constructor
|
|
894
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
895
|
+
*/
|
|
896
|
+
function Stack(entries) {
|
|
897
|
+
var data = this.__data__ = new ListCache(entries);
|
|
898
|
+
this.size = data.size;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* Removes all key-value entries from the stack.
|
|
903
|
+
*
|
|
904
|
+
* @private
|
|
905
|
+
* @name clear
|
|
906
|
+
* @memberOf Stack
|
|
907
|
+
*/
|
|
908
|
+
function stackClear() {
|
|
909
|
+
this.__data__ = new ListCache;
|
|
910
|
+
this.size = 0;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* Removes `key` and its value from the stack.
|
|
915
|
+
*
|
|
916
|
+
* @private
|
|
917
|
+
* @name delete
|
|
918
|
+
* @memberOf Stack
|
|
919
|
+
* @param {string} key The key of the value to remove.
|
|
920
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
921
|
+
*/
|
|
922
|
+
function stackDelete(key) {
|
|
923
|
+
var data = this.__data__,
|
|
924
|
+
result = data['delete'](key);
|
|
925
|
+
|
|
926
|
+
this.size = data.size;
|
|
927
|
+
return result;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
/**
|
|
931
|
+
* Gets the stack value for `key`.
|
|
932
|
+
*
|
|
933
|
+
* @private
|
|
934
|
+
* @name get
|
|
935
|
+
* @memberOf Stack
|
|
936
|
+
* @param {string} key The key of the value to get.
|
|
937
|
+
* @returns {*} Returns the entry value.
|
|
938
|
+
*/
|
|
939
|
+
function stackGet(key) {
|
|
940
|
+
return this.__data__.get(key);
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
/**
|
|
944
|
+
* Checks if a stack value for `key` exists.
|
|
945
|
+
*
|
|
946
|
+
* @private
|
|
947
|
+
* @name has
|
|
948
|
+
* @memberOf Stack
|
|
949
|
+
* @param {string} key The key of the entry to check.
|
|
950
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
951
|
+
*/
|
|
952
|
+
function stackHas(key) {
|
|
953
|
+
return this.__data__.has(key);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* Sets the stack `key` to `value`.
|
|
958
|
+
*
|
|
959
|
+
* @private
|
|
960
|
+
* @name set
|
|
961
|
+
* @memberOf Stack
|
|
962
|
+
* @param {string} key The key of the value to set.
|
|
963
|
+
* @param {*} value The value to set.
|
|
964
|
+
* @returns {Object} Returns the stack cache instance.
|
|
965
|
+
*/
|
|
966
|
+
function stackSet(key, value) {
|
|
967
|
+
var data = this.__data__;
|
|
968
|
+
if (data instanceof ListCache) {
|
|
969
|
+
var pairs = data.__data__;
|
|
970
|
+
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
|
971
|
+
pairs.push([key, value]);
|
|
972
|
+
this.size = ++data.size;
|
|
973
|
+
return this;
|
|
974
|
+
}
|
|
975
|
+
data = this.__data__ = new MapCache(pairs);
|
|
976
|
+
}
|
|
977
|
+
data.set(key, value);
|
|
978
|
+
this.size = data.size;
|
|
979
|
+
return this;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
// Add methods to `Stack`.
|
|
983
|
+
Stack.prototype.clear = stackClear;
|
|
984
|
+
Stack.prototype['delete'] = stackDelete;
|
|
985
|
+
Stack.prototype.get = stackGet;
|
|
986
|
+
Stack.prototype.has = stackHas;
|
|
987
|
+
Stack.prototype.set = stackSet;
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* Creates an array of the enumerable property names of the array-like `value`.
|
|
991
|
+
*
|
|
992
|
+
* @private
|
|
993
|
+
* @param {*} value The value to query.
|
|
994
|
+
* @param {boolean} inherited Specify returning inherited property names.
|
|
995
|
+
* @returns {Array} Returns the array of property names.
|
|
996
|
+
*/
|
|
997
|
+
function arrayLikeKeys(value, inherited) {
|
|
998
|
+
var isArr = isArray(value),
|
|
999
|
+
isArg = !isArr && isArguments(value),
|
|
1000
|
+
isBuff = !isArr && !isArg && isBuffer(value),
|
|
1001
|
+
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
|
|
1002
|
+
skipIndexes = isArr || isArg || isBuff || isType,
|
|
1003
|
+
result = skipIndexes ? baseTimes(value.length, String) : [],
|
|
1004
|
+
length = result.length;
|
|
1005
|
+
|
|
1006
|
+
for (var key in value) {
|
|
1007
|
+
if ((inherited || hasOwnProperty.call(value, key)) &&
|
|
1008
|
+
!(skipIndexes && (
|
|
1009
|
+
// Safari 9 has enumerable `arguments.length` in strict mode.
|
|
1010
|
+
key == 'length' ||
|
|
1011
|
+
// Node.js 0.10 has enumerable non-index properties on buffers.
|
|
1012
|
+
(isBuff && (key == 'offset' || key == 'parent')) ||
|
|
1013
|
+
// PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
1014
|
+
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
|
|
1015
|
+
// Skip index properties.
|
|
1016
|
+
isIndex(key, length)
|
|
1017
|
+
))) {
|
|
1018
|
+
result.push(key);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
return result;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
/**
|
|
1025
|
+
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
|
1026
|
+
*
|
|
1027
|
+
* @private
|
|
1028
|
+
* @param {Array} array The array to inspect.
|
|
1029
|
+
* @param {*} key The key to search for.
|
|
1030
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
1031
|
+
*/
|
|
1032
|
+
function assocIndexOf(array, key) {
|
|
1033
|
+
var length = array.length;
|
|
1034
|
+
while (length--) {
|
|
1035
|
+
if (eq(array[length][0], key)) {
|
|
1036
|
+
return length;
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
return -1;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
/**
|
|
1043
|
+
* The base implementation of `getAllKeys` and `getAllKeysIn` which uses
|
|
1044
|
+
* `keysFunc` and `symbolsFunc` to get the enumerable property names and
|
|
1045
|
+
* symbols of `object`.
|
|
1046
|
+
*
|
|
1047
|
+
* @private
|
|
1048
|
+
* @param {Object} object The object to query.
|
|
1049
|
+
* @param {Function} keysFunc The function to get the keys of `object`.
|
|
1050
|
+
* @param {Function} symbolsFunc The function to get the symbols of `object`.
|
|
1051
|
+
* @returns {Array} Returns the array of property names and symbols.
|
|
1052
|
+
*/
|
|
1053
|
+
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
|
|
1054
|
+
var result = keysFunc(object);
|
|
1055
|
+
return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
1060
|
+
*
|
|
1061
|
+
* @private
|
|
1062
|
+
* @param {*} value The value to query.
|
|
1063
|
+
* @returns {string} Returns the `toStringTag`.
|
|
1064
|
+
*/
|
|
1065
|
+
function baseGetTag(value) {
|
|
1066
|
+
if (value == null) {
|
|
1067
|
+
return value === undefined ? undefinedTag : nullTag;
|
|
1068
|
+
}
|
|
1069
|
+
return (symToStringTag && symToStringTag in Object(value))
|
|
1070
|
+
? getRawTag(value)
|
|
1071
|
+
: objectToString(value);
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* The base implementation of `_.isArguments`.
|
|
1076
|
+
*
|
|
1077
|
+
* @private
|
|
1078
|
+
* @param {*} value The value to check.
|
|
1079
|
+
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
1080
|
+
*/
|
|
1081
|
+
function baseIsArguments(value) {
|
|
1082
|
+
return isObjectLike(value) && baseGetTag(value) == argsTag;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* The base implementation of `_.isEqual` which supports partial comparisons
|
|
1087
|
+
* and tracks traversed objects.
|
|
1088
|
+
*
|
|
1089
|
+
* @private
|
|
1090
|
+
* @param {*} value The value to compare.
|
|
1091
|
+
* @param {*} other The other value to compare.
|
|
1092
|
+
* @param {boolean} bitmask The bitmask flags.
|
|
1093
|
+
* 1 - Unordered comparison
|
|
1094
|
+
* 2 - Partial comparison
|
|
1095
|
+
* @param {Function} [customizer] The function to customize comparisons.
|
|
1096
|
+
* @param {Object} [stack] Tracks traversed `value` and `other` objects.
|
|
1097
|
+
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
1098
|
+
*/
|
|
1099
|
+
function baseIsEqual(value, other, bitmask, customizer, stack) {
|
|
1100
|
+
if (value === other) {
|
|
1101
|
+
return true;
|
|
1102
|
+
}
|
|
1103
|
+
if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
|
|
1104
|
+
return value !== value && other !== other;
|
|
1105
|
+
}
|
|
1106
|
+
return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* A specialized version of `baseIsEqual` for arrays and objects which performs
|
|
1111
|
+
* deep comparisons and tracks traversed objects enabling objects with circular
|
|
1112
|
+
* references to be compared.
|
|
1113
|
+
*
|
|
1114
|
+
* @private
|
|
1115
|
+
* @param {Object} object The object to compare.
|
|
1116
|
+
* @param {Object} other The other object to compare.
|
|
1117
|
+
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
1118
|
+
* @param {Function} customizer The function to customize comparisons.
|
|
1119
|
+
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
1120
|
+
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
|
|
1121
|
+
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
1122
|
+
*/
|
|
1123
|
+
function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
|
1124
|
+
var objIsArr = isArray(object),
|
|
1125
|
+
othIsArr = isArray(other),
|
|
1126
|
+
objTag = objIsArr ? arrayTag : getTag(object),
|
|
1127
|
+
othTag = othIsArr ? arrayTag : getTag(other);
|
|
1128
|
+
|
|
1129
|
+
objTag = objTag == argsTag ? objectTag : objTag;
|
|
1130
|
+
othTag = othTag == argsTag ? objectTag : othTag;
|
|
1131
|
+
|
|
1132
|
+
var objIsObj = objTag == objectTag,
|
|
1133
|
+
othIsObj = othTag == objectTag,
|
|
1134
|
+
isSameTag = objTag == othTag;
|
|
1135
|
+
|
|
1136
|
+
if (isSameTag && isBuffer(object)) {
|
|
1137
|
+
if (!isBuffer(other)) {
|
|
1138
|
+
return false;
|
|
1139
|
+
}
|
|
1140
|
+
objIsArr = true;
|
|
1141
|
+
objIsObj = false;
|
|
1142
|
+
}
|
|
1143
|
+
if (isSameTag && !objIsObj) {
|
|
1144
|
+
stack || (stack = new Stack);
|
|
1145
|
+
return (objIsArr || isTypedArray(object))
|
|
1146
|
+
? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
|
|
1147
|
+
: equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
|
|
1148
|
+
}
|
|
1149
|
+
if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
|
|
1150
|
+
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
|
1151
|
+
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
|
1152
|
+
|
|
1153
|
+
if (objIsWrapped || othIsWrapped) {
|
|
1154
|
+
var objUnwrapped = objIsWrapped ? object.value() : object,
|
|
1155
|
+
othUnwrapped = othIsWrapped ? other.value() : other;
|
|
1156
|
+
|
|
1157
|
+
stack || (stack = new Stack);
|
|
1158
|
+
return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
if (!isSameTag) {
|
|
1162
|
+
return false;
|
|
1163
|
+
}
|
|
1164
|
+
stack || (stack = new Stack);
|
|
1165
|
+
return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* The base implementation of `_.isNative` without bad shim checks.
|
|
1170
|
+
*
|
|
1171
|
+
* @private
|
|
1172
|
+
* @param {*} value The value to check.
|
|
1173
|
+
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
1174
|
+
* else `false`.
|
|
1175
|
+
*/
|
|
1176
|
+
function baseIsNative(value) {
|
|
1177
|
+
if (!isObject(value) || isMasked(value)) {
|
|
1178
|
+
return false;
|
|
1179
|
+
}
|
|
1180
|
+
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
1181
|
+
return pattern.test(toSource(value));
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
/**
|
|
1185
|
+
* The base implementation of `_.isTypedArray` without Node.js optimizations.
|
|
1186
|
+
*
|
|
1187
|
+
* @private
|
|
1188
|
+
* @param {*} value The value to check.
|
|
1189
|
+
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
1190
|
+
*/
|
|
1191
|
+
function baseIsTypedArray(value) {
|
|
1192
|
+
return isObjectLike(value) &&
|
|
1193
|
+
isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
/**
|
|
1197
|
+
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
|
|
1198
|
+
*
|
|
1199
|
+
* @private
|
|
1200
|
+
* @param {Object} object The object to query.
|
|
1201
|
+
* @returns {Array} Returns the array of property names.
|
|
1202
|
+
*/
|
|
1203
|
+
function baseKeys(object) {
|
|
1204
|
+
if (!isPrototype(object)) {
|
|
1205
|
+
return nativeKeys(object);
|
|
1206
|
+
}
|
|
1207
|
+
var result = [];
|
|
1208
|
+
for (var key in Object(object)) {
|
|
1209
|
+
if (hasOwnProperty.call(object, key) && key != 'constructor') {
|
|
1210
|
+
result.push(key);
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
return result;
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
/**
|
|
1217
|
+
* A specialized version of `baseIsEqualDeep` for arrays with support for
|
|
1218
|
+
* partial deep comparisons.
|
|
1219
|
+
*
|
|
1220
|
+
* @private
|
|
1221
|
+
* @param {Array} array The array to compare.
|
|
1222
|
+
* @param {Array} other The other array to compare.
|
|
1223
|
+
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
1224
|
+
* @param {Function} customizer The function to customize comparisons.
|
|
1225
|
+
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
1226
|
+
* @param {Object} stack Tracks traversed `array` and `other` objects.
|
|
1227
|
+
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
|
1228
|
+
*/
|
|
1229
|
+
function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
|
|
1230
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
|
|
1231
|
+
arrLength = array.length,
|
|
1232
|
+
othLength = other.length;
|
|
1233
|
+
|
|
1234
|
+
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
|
1235
|
+
return false;
|
|
1236
|
+
}
|
|
1237
|
+
// Assume cyclic values are equal.
|
|
1238
|
+
var stacked = stack.get(array);
|
|
1239
|
+
if (stacked && stack.get(other)) {
|
|
1240
|
+
return stacked == other;
|
|
1241
|
+
}
|
|
1242
|
+
var index = -1,
|
|
1243
|
+
result = true,
|
|
1244
|
+
seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
|
|
1245
|
+
|
|
1246
|
+
stack.set(array, other);
|
|
1247
|
+
stack.set(other, array);
|
|
1248
|
+
|
|
1249
|
+
// Ignore non-index properties.
|
|
1250
|
+
while (++index < arrLength) {
|
|
1251
|
+
var arrValue = array[index],
|
|
1252
|
+
othValue = other[index];
|
|
1253
|
+
|
|
1254
|
+
if (customizer) {
|
|
1255
|
+
var compared = isPartial
|
|
1256
|
+
? customizer(othValue, arrValue, index, other, array, stack)
|
|
1257
|
+
: customizer(arrValue, othValue, index, array, other, stack);
|
|
1258
|
+
}
|
|
1259
|
+
if (compared !== undefined) {
|
|
1260
|
+
if (compared) {
|
|
1261
|
+
continue;
|
|
1262
|
+
}
|
|
1263
|
+
result = false;
|
|
1264
|
+
break;
|
|
1265
|
+
}
|
|
1266
|
+
// Recursively compare arrays (susceptible to call stack limits).
|
|
1267
|
+
if (seen) {
|
|
1268
|
+
if (!arraySome(other, function(othValue, othIndex) {
|
|
1269
|
+
if (!cacheHas(seen, othIndex) &&
|
|
1270
|
+
(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
|
|
1271
|
+
return seen.push(othIndex);
|
|
1272
|
+
}
|
|
1273
|
+
})) {
|
|
1274
|
+
result = false;
|
|
1275
|
+
break;
|
|
1276
|
+
}
|
|
1277
|
+
} else if (!(
|
|
1278
|
+
arrValue === othValue ||
|
|
1279
|
+
equalFunc(arrValue, othValue, bitmask, customizer, stack)
|
|
1280
|
+
)) {
|
|
1281
|
+
result = false;
|
|
1282
|
+
break;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
stack['delete'](array);
|
|
1286
|
+
stack['delete'](other);
|
|
1287
|
+
return result;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
/**
|
|
1291
|
+
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
|
1292
|
+
* the same `toStringTag`.
|
|
1293
|
+
*
|
|
1294
|
+
* **Note:** This function only supports comparing values with tags of
|
|
1295
|
+
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
|
|
1296
|
+
*
|
|
1297
|
+
* @private
|
|
1298
|
+
* @param {Object} object The object to compare.
|
|
1299
|
+
* @param {Object} other The other object to compare.
|
|
1300
|
+
* @param {string} tag The `toStringTag` of the objects to compare.
|
|
1301
|
+
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
1302
|
+
* @param {Function} customizer The function to customize comparisons.
|
|
1303
|
+
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
1304
|
+
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
|
1305
|
+
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
1306
|
+
*/
|
|
1307
|
+
function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
|
1308
|
+
switch (tag) {
|
|
1309
|
+
case dataViewTag:
|
|
1310
|
+
if ((object.byteLength != other.byteLength) ||
|
|
1311
|
+
(object.byteOffset != other.byteOffset)) {
|
|
1312
|
+
return false;
|
|
1313
|
+
}
|
|
1314
|
+
object = object.buffer;
|
|
1315
|
+
other = other.buffer;
|
|
1316
|
+
|
|
1317
|
+
case arrayBufferTag:
|
|
1318
|
+
if ((object.byteLength != other.byteLength) ||
|
|
1319
|
+
!equalFunc(new Uint8Array(object), new Uint8Array(other))) {
|
|
1320
|
+
return false;
|
|
1321
|
+
}
|
|
1322
|
+
return true;
|
|
1323
|
+
|
|
1324
|
+
case boolTag:
|
|
1325
|
+
case dateTag:
|
|
1326
|
+
case numberTag:
|
|
1327
|
+
// Coerce booleans to `1` or `0` and dates to milliseconds.
|
|
1328
|
+
// Invalid dates are coerced to `NaN`.
|
|
1329
|
+
return eq(+object, +other);
|
|
1330
|
+
|
|
1331
|
+
case errorTag:
|
|
1332
|
+
return object.name == other.name && object.message == other.message;
|
|
1333
|
+
|
|
1334
|
+
case regexpTag:
|
|
1335
|
+
case stringTag:
|
|
1336
|
+
// Coerce regexes to strings and treat strings, primitives and objects,
|
|
1337
|
+
// as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
|
|
1338
|
+
// for more details.
|
|
1339
|
+
return object == (other + '');
|
|
1340
|
+
|
|
1341
|
+
case mapTag:
|
|
1342
|
+
var convert = mapToArray;
|
|
1343
|
+
|
|
1344
|
+
case setTag:
|
|
1345
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
|
|
1346
|
+
convert || (convert = setToArray);
|
|
1347
|
+
|
|
1348
|
+
if (object.size != other.size && !isPartial) {
|
|
1349
|
+
return false;
|
|
1350
|
+
}
|
|
1351
|
+
// Assume cyclic values are equal.
|
|
1352
|
+
var stacked = stack.get(object);
|
|
1353
|
+
if (stacked) {
|
|
1354
|
+
return stacked == other;
|
|
1355
|
+
}
|
|
1356
|
+
bitmask |= COMPARE_UNORDERED_FLAG;
|
|
1357
|
+
|
|
1358
|
+
// Recursively compare objects (susceptible to call stack limits).
|
|
1359
|
+
stack.set(object, other);
|
|
1360
|
+
var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
|
|
1361
|
+
stack['delete'](object);
|
|
1362
|
+
return result;
|
|
1363
|
+
|
|
1364
|
+
case symbolTag:
|
|
1365
|
+
if (symbolValueOf) {
|
|
1366
|
+
return symbolValueOf.call(object) == symbolValueOf.call(other);
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
return false;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
/**
|
|
1373
|
+
* A specialized version of `baseIsEqualDeep` for objects with support for
|
|
1374
|
+
* partial deep comparisons.
|
|
1375
|
+
*
|
|
1376
|
+
* @private
|
|
1377
|
+
* @param {Object} object The object to compare.
|
|
1378
|
+
* @param {Object} other The other object to compare.
|
|
1379
|
+
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
1380
|
+
* @param {Function} customizer The function to customize comparisons.
|
|
1381
|
+
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
1382
|
+
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
|
1383
|
+
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
1384
|
+
*/
|
|
1385
|
+
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
|
1386
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
|
|
1387
|
+
objProps = getAllKeys(object),
|
|
1388
|
+
objLength = objProps.length,
|
|
1389
|
+
othProps = getAllKeys(other),
|
|
1390
|
+
othLength = othProps.length;
|
|
1391
|
+
|
|
1392
|
+
if (objLength != othLength && !isPartial) {
|
|
1393
|
+
return false;
|
|
1394
|
+
}
|
|
1395
|
+
var index = objLength;
|
|
1396
|
+
while (index--) {
|
|
1397
|
+
var key = objProps[index];
|
|
1398
|
+
if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
|
|
1399
|
+
return false;
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
// Assume cyclic values are equal.
|
|
1403
|
+
var stacked = stack.get(object);
|
|
1404
|
+
if (stacked && stack.get(other)) {
|
|
1405
|
+
return stacked == other;
|
|
1406
|
+
}
|
|
1407
|
+
var result = true;
|
|
1408
|
+
stack.set(object, other);
|
|
1409
|
+
stack.set(other, object);
|
|
1410
|
+
|
|
1411
|
+
var skipCtor = isPartial;
|
|
1412
|
+
while (++index < objLength) {
|
|
1413
|
+
key = objProps[index];
|
|
1414
|
+
var objValue = object[key],
|
|
1415
|
+
othValue = other[key];
|
|
1416
|
+
|
|
1417
|
+
if (customizer) {
|
|
1418
|
+
var compared = isPartial
|
|
1419
|
+
? customizer(othValue, objValue, key, other, object, stack)
|
|
1420
|
+
: customizer(objValue, othValue, key, object, other, stack);
|
|
1421
|
+
}
|
|
1422
|
+
// Recursively compare objects (susceptible to call stack limits).
|
|
1423
|
+
if (!(compared === undefined
|
|
1424
|
+
? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
|
|
1425
|
+
: compared
|
|
1426
|
+
)) {
|
|
1427
|
+
result = false;
|
|
1428
|
+
break;
|
|
1429
|
+
}
|
|
1430
|
+
skipCtor || (skipCtor = key == 'constructor');
|
|
1431
|
+
}
|
|
1432
|
+
if (result && !skipCtor) {
|
|
1433
|
+
var objCtor = object.constructor,
|
|
1434
|
+
othCtor = other.constructor;
|
|
1435
|
+
|
|
1436
|
+
// Non `Object` object instances with different constructors are not equal.
|
|
1437
|
+
if (objCtor != othCtor &&
|
|
1438
|
+
('constructor' in object && 'constructor' in other) &&
|
|
1439
|
+
!(typeof objCtor == 'function' && objCtor instanceof objCtor &&
|
|
1440
|
+
typeof othCtor == 'function' && othCtor instanceof othCtor)) {
|
|
1441
|
+
result = false;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
stack['delete'](object);
|
|
1445
|
+
stack['delete'](other);
|
|
1446
|
+
return result;
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
/**
|
|
1450
|
+
* Creates an array of own enumerable property names and symbols of `object`.
|
|
1451
|
+
*
|
|
1452
|
+
* @private
|
|
1453
|
+
* @param {Object} object The object to query.
|
|
1454
|
+
* @returns {Array} Returns the array of property names and symbols.
|
|
1455
|
+
*/
|
|
1456
|
+
function getAllKeys(object) {
|
|
1457
|
+
return baseGetAllKeys(object, keys, getSymbols);
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
/**
|
|
1461
|
+
* Gets the data for `map`.
|
|
1462
|
+
*
|
|
1463
|
+
* @private
|
|
1464
|
+
* @param {Object} map The map to query.
|
|
1465
|
+
* @param {string} key The reference key.
|
|
1466
|
+
* @returns {*} Returns the map data.
|
|
1467
|
+
*/
|
|
1468
|
+
function getMapData(map, key) {
|
|
1469
|
+
var data = map.__data__;
|
|
1470
|
+
return isKeyable(key)
|
|
1471
|
+
? data[typeof key == 'string' ? 'string' : 'hash']
|
|
1472
|
+
: data.map;
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
/**
|
|
1476
|
+
* Gets the native function at `key` of `object`.
|
|
1477
|
+
*
|
|
1478
|
+
* @private
|
|
1479
|
+
* @param {Object} object The object to query.
|
|
1480
|
+
* @param {string} key The key of the method to get.
|
|
1481
|
+
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
1482
|
+
*/
|
|
1483
|
+
function getNative(object, key) {
|
|
1484
|
+
var value = getValue(object, key);
|
|
1485
|
+
return baseIsNative(value) ? value : undefined;
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
/**
|
|
1489
|
+
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
1490
|
+
*
|
|
1491
|
+
* @private
|
|
1492
|
+
* @param {*} value The value to query.
|
|
1493
|
+
* @returns {string} Returns the raw `toStringTag`.
|
|
1494
|
+
*/
|
|
1495
|
+
function getRawTag(value) {
|
|
1496
|
+
var isOwn = hasOwnProperty.call(value, symToStringTag),
|
|
1497
|
+
tag = value[symToStringTag];
|
|
1498
|
+
|
|
1499
|
+
try {
|
|
1500
|
+
value[symToStringTag] = undefined;
|
|
1501
|
+
var unmasked = true;
|
|
1502
|
+
} catch (e) {}
|
|
1503
|
+
|
|
1504
|
+
var result = nativeObjectToString.call(value);
|
|
1505
|
+
if (unmasked) {
|
|
1506
|
+
if (isOwn) {
|
|
1507
|
+
value[symToStringTag] = tag;
|
|
1508
|
+
} else {
|
|
1509
|
+
delete value[symToStringTag];
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
return result;
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
/**
|
|
1516
|
+
* Creates an array of the own enumerable symbols of `object`.
|
|
1517
|
+
*
|
|
1518
|
+
* @private
|
|
1519
|
+
* @param {Object} object The object to query.
|
|
1520
|
+
* @returns {Array} Returns the array of symbols.
|
|
1521
|
+
*/
|
|
1522
|
+
var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
|
|
1523
|
+
if (object == null) {
|
|
1524
|
+
return [];
|
|
1525
|
+
}
|
|
1526
|
+
object = Object(object);
|
|
1527
|
+
return arrayFilter(nativeGetSymbols(object), function(symbol) {
|
|
1528
|
+
return propertyIsEnumerable.call(object, symbol);
|
|
1529
|
+
});
|
|
1530
|
+
};
|
|
1531
|
+
|
|
1532
|
+
/**
|
|
1533
|
+
* Gets the `toStringTag` of `value`.
|
|
1534
|
+
*
|
|
1535
|
+
* @private
|
|
1536
|
+
* @param {*} value The value to query.
|
|
1537
|
+
* @returns {string} Returns the `toStringTag`.
|
|
1538
|
+
*/
|
|
1539
|
+
var getTag = baseGetTag;
|
|
1540
|
+
|
|
1541
|
+
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
|
|
1542
|
+
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
|
|
1543
|
+
(Map && getTag(new Map) != mapTag) ||
|
|
1544
|
+
(Promise && getTag(Promise.resolve()) != promiseTag) ||
|
|
1545
|
+
(Set && getTag(new Set) != setTag) ||
|
|
1546
|
+
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
|
|
1547
|
+
getTag = function(value) {
|
|
1548
|
+
var result = baseGetTag(value),
|
|
1549
|
+
Ctor = result == objectTag ? value.constructor : undefined,
|
|
1550
|
+
ctorString = Ctor ? toSource(Ctor) : '';
|
|
1551
|
+
|
|
1552
|
+
if (ctorString) {
|
|
1553
|
+
switch (ctorString) {
|
|
1554
|
+
case dataViewCtorString: return dataViewTag;
|
|
1555
|
+
case mapCtorString: return mapTag;
|
|
1556
|
+
case promiseCtorString: return promiseTag;
|
|
1557
|
+
case setCtorString: return setTag;
|
|
1558
|
+
case weakMapCtorString: return weakMapTag;
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
return result;
|
|
1562
|
+
};
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
/**
|
|
1566
|
+
* Checks if `value` is a valid array-like index.
|
|
1567
|
+
*
|
|
1568
|
+
* @private
|
|
1569
|
+
* @param {*} value The value to check.
|
|
1570
|
+
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
|
|
1571
|
+
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
|
1572
|
+
*/
|
|
1573
|
+
function isIndex(value, length) {
|
|
1574
|
+
length = length == null ? MAX_SAFE_INTEGER : length;
|
|
1575
|
+
return !!length &&
|
|
1576
|
+
(typeof value == 'number' || reIsUint.test(value)) &&
|
|
1577
|
+
(value > -1 && value % 1 == 0 && value < length);
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
/**
|
|
1581
|
+
* Checks if `value` is suitable for use as unique object key.
|
|
1582
|
+
*
|
|
1583
|
+
* @private
|
|
1584
|
+
* @param {*} value The value to check.
|
|
1585
|
+
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
|
1586
|
+
*/
|
|
1587
|
+
function isKeyable(value) {
|
|
1588
|
+
var type = typeof value;
|
|
1589
|
+
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
|
1590
|
+
? (value !== '__proto__')
|
|
1591
|
+
: (value === null);
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
/**
|
|
1595
|
+
* Checks if `func` has its source masked.
|
|
1596
|
+
*
|
|
1597
|
+
* @private
|
|
1598
|
+
* @param {Function} func The function to check.
|
|
1599
|
+
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|
1600
|
+
*/
|
|
1601
|
+
function isMasked(func) {
|
|
1602
|
+
return !!maskSrcKey && (maskSrcKey in func);
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
/**
|
|
1606
|
+
* Checks if `value` is likely a prototype object.
|
|
1607
|
+
*
|
|
1608
|
+
* @private
|
|
1609
|
+
* @param {*} value The value to check.
|
|
1610
|
+
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
|
|
1611
|
+
*/
|
|
1612
|
+
function isPrototype(value) {
|
|
1613
|
+
var Ctor = value && value.constructor,
|
|
1614
|
+
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
|
|
1615
|
+
|
|
1616
|
+
return value === proto;
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
/**
|
|
1620
|
+
* Converts `value` to a string using `Object.prototype.toString`.
|
|
1621
|
+
*
|
|
1622
|
+
* @private
|
|
1623
|
+
* @param {*} value The value to convert.
|
|
1624
|
+
* @returns {string} Returns the converted string.
|
|
1625
|
+
*/
|
|
1626
|
+
function objectToString(value) {
|
|
1627
|
+
return nativeObjectToString.call(value);
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
/**
|
|
1631
|
+
* Converts `func` to its source code.
|
|
1632
|
+
*
|
|
1633
|
+
* @private
|
|
1634
|
+
* @param {Function} func The function to convert.
|
|
1635
|
+
* @returns {string} Returns the source code.
|
|
1636
|
+
*/
|
|
1637
|
+
function toSource(func) {
|
|
1638
|
+
if (func != null) {
|
|
1639
|
+
try {
|
|
1640
|
+
return funcToString.call(func);
|
|
1641
|
+
} catch (e) {}
|
|
1642
|
+
try {
|
|
1643
|
+
return (func + '');
|
|
1644
|
+
} catch (e) {}
|
|
1645
|
+
}
|
|
1646
|
+
return '';
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
/**
|
|
1650
|
+
* Performs a
|
|
1651
|
+
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
1652
|
+
* comparison between two values to determine if they are equivalent.
|
|
1653
|
+
*
|
|
1654
|
+
* @static
|
|
1655
|
+
* @memberOf _
|
|
1656
|
+
* @since 4.0.0
|
|
1657
|
+
* @category Lang
|
|
1658
|
+
* @param {*} value The value to compare.
|
|
1659
|
+
* @param {*} other The other value to compare.
|
|
1660
|
+
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
1661
|
+
* @example
|
|
1662
|
+
*
|
|
1663
|
+
* var object = { 'a': 1 };
|
|
1664
|
+
* var other = { 'a': 1 };
|
|
1665
|
+
*
|
|
1666
|
+
* _.eq(object, object);
|
|
1667
|
+
* // => true
|
|
1668
|
+
*
|
|
1669
|
+
* _.eq(object, other);
|
|
1670
|
+
* // => false
|
|
1671
|
+
*
|
|
1672
|
+
* _.eq('a', 'a');
|
|
1673
|
+
* // => true
|
|
1674
|
+
*
|
|
1675
|
+
* _.eq('a', Object('a'));
|
|
1676
|
+
* // => false
|
|
1677
|
+
*
|
|
1678
|
+
* _.eq(NaN, NaN);
|
|
1679
|
+
* // => true
|
|
1680
|
+
*/
|
|
1681
|
+
function eq(value, other) {
|
|
1682
|
+
return value === other || (value !== value && other !== other);
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
/**
|
|
1686
|
+
* Checks if `value` is likely an `arguments` object.
|
|
1687
|
+
*
|
|
1688
|
+
* @static
|
|
1689
|
+
* @memberOf _
|
|
1690
|
+
* @since 0.1.0
|
|
1691
|
+
* @category Lang
|
|
1692
|
+
* @param {*} value The value to check.
|
|
1693
|
+
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
1694
|
+
* else `false`.
|
|
1695
|
+
* @example
|
|
1696
|
+
*
|
|
1697
|
+
* _.isArguments(function() { return arguments; }());
|
|
1698
|
+
* // => true
|
|
1699
|
+
*
|
|
1700
|
+
* _.isArguments([1, 2, 3]);
|
|
1701
|
+
* // => false
|
|
1702
|
+
*/
|
|
1703
|
+
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
|
|
1704
|
+
return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
|
|
1705
|
+
!propertyIsEnumerable.call(value, 'callee');
|
|
1706
|
+
};
|
|
1707
|
+
|
|
1708
|
+
/**
|
|
1709
|
+
* Checks if `value` is classified as an `Array` object.
|
|
1710
|
+
*
|
|
1711
|
+
* @static
|
|
1712
|
+
* @memberOf _
|
|
1713
|
+
* @since 0.1.0
|
|
1714
|
+
* @category Lang
|
|
1715
|
+
* @param {*} value The value to check.
|
|
1716
|
+
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
1717
|
+
* @example
|
|
1718
|
+
*
|
|
1719
|
+
* _.isArray([1, 2, 3]);
|
|
1720
|
+
* // => true
|
|
1721
|
+
*
|
|
1722
|
+
* _.isArray(document.body.children);
|
|
1723
|
+
* // => false
|
|
1724
|
+
*
|
|
1725
|
+
* _.isArray('abc');
|
|
1726
|
+
* // => false
|
|
1727
|
+
*
|
|
1728
|
+
* _.isArray(_.noop);
|
|
1729
|
+
* // => false
|
|
1730
|
+
*/
|
|
1731
|
+
var isArray = Array.isArray;
|
|
1732
|
+
|
|
1733
|
+
/**
|
|
1734
|
+
* Checks if `value` is array-like. A value is considered array-like if it's
|
|
1735
|
+
* not a function and has a `value.length` that's an integer greater than or
|
|
1736
|
+
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
|
1737
|
+
*
|
|
1738
|
+
* @static
|
|
1739
|
+
* @memberOf _
|
|
1740
|
+
* @since 4.0.0
|
|
1741
|
+
* @category Lang
|
|
1742
|
+
* @param {*} value The value to check.
|
|
1743
|
+
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
|
1744
|
+
* @example
|
|
1745
|
+
*
|
|
1746
|
+
* _.isArrayLike([1, 2, 3]);
|
|
1747
|
+
* // => true
|
|
1748
|
+
*
|
|
1749
|
+
* _.isArrayLike(document.body.children);
|
|
1750
|
+
* // => true
|
|
1751
|
+
*
|
|
1752
|
+
* _.isArrayLike('abc');
|
|
1753
|
+
* // => true
|
|
1754
|
+
*
|
|
1755
|
+
* _.isArrayLike(_.noop);
|
|
1756
|
+
* // => false
|
|
1757
|
+
*/
|
|
1758
|
+
function isArrayLike(value) {
|
|
1759
|
+
return value != null && isLength(value.length) && !isFunction(value);
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
/**
|
|
1763
|
+
* Checks if `value` is a buffer.
|
|
1764
|
+
*
|
|
1765
|
+
* @static
|
|
1766
|
+
* @memberOf _
|
|
1767
|
+
* @since 4.3.0
|
|
1768
|
+
* @category Lang
|
|
1769
|
+
* @param {*} value The value to check.
|
|
1770
|
+
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
|
1771
|
+
* @example
|
|
1772
|
+
*
|
|
1773
|
+
* _.isBuffer(new Buffer(2));
|
|
1774
|
+
* // => true
|
|
1775
|
+
*
|
|
1776
|
+
* _.isBuffer(new Uint8Array(2));
|
|
1777
|
+
* // => false
|
|
1778
|
+
*/
|
|
1779
|
+
var isBuffer = nativeIsBuffer || stubFalse;
|
|
1780
|
+
|
|
1781
|
+
/**
|
|
1782
|
+
* Performs a deep comparison between two values to determine if they are
|
|
1783
|
+
* equivalent.
|
|
1784
|
+
*
|
|
1785
|
+
* **Note:** This method supports comparing arrays, array buffers, booleans,
|
|
1786
|
+
* date objects, error objects, maps, numbers, `Object` objects, regexes,
|
|
1787
|
+
* sets, strings, symbols, and typed arrays. `Object` objects are compared
|
|
1788
|
+
* by their own, not inherited, enumerable properties. Functions and DOM
|
|
1789
|
+
* nodes are compared by strict equality, i.e. `===`.
|
|
1790
|
+
*
|
|
1791
|
+
* @static
|
|
1792
|
+
* @memberOf _
|
|
1793
|
+
* @since 0.1.0
|
|
1794
|
+
* @category Lang
|
|
1795
|
+
* @param {*} value The value to compare.
|
|
1796
|
+
* @param {*} other The other value to compare.
|
|
1797
|
+
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
1798
|
+
* @example
|
|
1799
|
+
*
|
|
1800
|
+
* var object = { 'a': 1 };
|
|
1801
|
+
* var other = { 'a': 1 };
|
|
1802
|
+
*
|
|
1803
|
+
* _.isEqual(object, other);
|
|
1804
|
+
* // => true
|
|
1805
|
+
*
|
|
1806
|
+
* object === other;
|
|
1807
|
+
* // => false
|
|
1808
|
+
*/
|
|
1809
|
+
function isEqual(value, other) {
|
|
1810
|
+
return baseIsEqual(value, other);
|
|
1811
|
+
}
|
|
1812
|
+
|
|
1813
|
+
/**
|
|
1814
|
+
* Checks if `value` is classified as a `Function` object.
|
|
1815
|
+
*
|
|
1816
|
+
* @static
|
|
1817
|
+
* @memberOf _
|
|
1818
|
+
* @since 0.1.0
|
|
1819
|
+
* @category Lang
|
|
1820
|
+
* @param {*} value The value to check.
|
|
1821
|
+
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
1822
|
+
* @example
|
|
1823
|
+
*
|
|
1824
|
+
* _.isFunction(_);
|
|
1825
|
+
* // => true
|
|
1826
|
+
*
|
|
1827
|
+
* _.isFunction(/abc/);
|
|
1828
|
+
* // => false
|
|
1829
|
+
*/
|
|
1830
|
+
function isFunction(value) {
|
|
1831
|
+
if (!isObject(value)) {
|
|
1832
|
+
return false;
|
|
1833
|
+
}
|
|
1834
|
+
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
1835
|
+
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
|
1836
|
+
var tag = baseGetTag(value);
|
|
1837
|
+
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
/**
|
|
1841
|
+
* Checks if `value` is a valid array-like length.
|
|
1842
|
+
*
|
|
1843
|
+
* **Note:** This method is loosely based on
|
|
1844
|
+
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|
1845
|
+
*
|
|
1846
|
+
* @static
|
|
1847
|
+
* @memberOf _
|
|
1848
|
+
* @since 4.0.0
|
|
1849
|
+
* @category Lang
|
|
1850
|
+
* @param {*} value The value to check.
|
|
1851
|
+
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|
1852
|
+
* @example
|
|
1853
|
+
*
|
|
1854
|
+
* _.isLength(3);
|
|
1855
|
+
* // => true
|
|
1856
|
+
*
|
|
1857
|
+
* _.isLength(Number.MIN_VALUE);
|
|
1858
|
+
* // => false
|
|
1859
|
+
*
|
|
1860
|
+
* _.isLength(Infinity);
|
|
1861
|
+
* // => false
|
|
1862
|
+
*
|
|
1863
|
+
* _.isLength('3');
|
|
1864
|
+
* // => false
|
|
1865
|
+
*/
|
|
1866
|
+
function isLength(value) {
|
|
1867
|
+
return typeof value == 'number' &&
|
|
1868
|
+
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
/**
|
|
1872
|
+
* Checks if `value` is the
|
|
1873
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
1874
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
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 object, else `false`.
|
|
1882
|
+
* @example
|
|
1883
|
+
*
|
|
1884
|
+
* _.isObject({});
|
|
1885
|
+
* // => true
|
|
1886
|
+
*
|
|
1887
|
+
* _.isObject([1, 2, 3]);
|
|
1888
|
+
* // => true
|
|
1889
|
+
*
|
|
1890
|
+
* _.isObject(_.noop);
|
|
1891
|
+
* // => true
|
|
1892
|
+
*
|
|
1893
|
+
* _.isObject(null);
|
|
1894
|
+
* // => false
|
|
1895
|
+
*/
|
|
1896
|
+
function isObject(value) {
|
|
1897
|
+
var type = typeof value;
|
|
1898
|
+
return value != null && (type == 'object' || type == 'function');
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
/**
|
|
1902
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
1903
|
+
* and has a `typeof` result of "object".
|
|
1904
|
+
*
|
|
1905
|
+
* @static
|
|
1906
|
+
* @memberOf _
|
|
1907
|
+
* @since 4.0.0
|
|
1908
|
+
* @category Lang
|
|
1909
|
+
* @param {*} value The value to check.
|
|
1910
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
1911
|
+
* @example
|
|
1912
|
+
*
|
|
1913
|
+
* _.isObjectLike({});
|
|
1914
|
+
* // => true
|
|
1915
|
+
*
|
|
1916
|
+
* _.isObjectLike([1, 2, 3]);
|
|
1917
|
+
* // => true
|
|
1918
|
+
*
|
|
1919
|
+
* _.isObjectLike(_.noop);
|
|
1920
|
+
* // => false
|
|
1921
|
+
*
|
|
1922
|
+
* _.isObjectLike(null);
|
|
1923
|
+
* // => false
|
|
1924
|
+
*/
|
|
1925
|
+
function isObjectLike(value) {
|
|
1926
|
+
return value != null && typeof value == 'object';
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
/**
|
|
1930
|
+
* Checks if `value` is classified as a typed array.
|
|
1931
|
+
*
|
|
1932
|
+
* @static
|
|
1933
|
+
* @memberOf _
|
|
1934
|
+
* @since 3.0.0
|
|
1935
|
+
* @category Lang
|
|
1936
|
+
* @param {*} value The value to check.
|
|
1937
|
+
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
1938
|
+
* @example
|
|
1939
|
+
*
|
|
1940
|
+
* _.isTypedArray(new Uint8Array);
|
|
1941
|
+
* // => true
|
|
1942
|
+
*
|
|
1943
|
+
* _.isTypedArray([]);
|
|
1944
|
+
* // => false
|
|
1945
|
+
*/
|
|
1946
|
+
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
|
|
1947
|
+
|
|
1948
|
+
/**
|
|
1949
|
+
* Creates an array of the own enumerable property names of `object`.
|
|
1950
|
+
*
|
|
1951
|
+
* **Note:** Non-object values are coerced to objects. See the
|
|
1952
|
+
* [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
|
1953
|
+
* for more details.
|
|
1954
|
+
*
|
|
1955
|
+
* @static
|
|
1956
|
+
* @since 0.1.0
|
|
1957
|
+
* @memberOf _
|
|
1958
|
+
* @category Object
|
|
1959
|
+
* @param {Object} object The object to query.
|
|
1960
|
+
* @returns {Array} Returns the array of property names.
|
|
1961
|
+
* @example
|
|
1962
|
+
*
|
|
1963
|
+
* function Foo() {
|
|
1964
|
+
* this.a = 1;
|
|
1965
|
+
* this.b = 2;
|
|
1966
|
+
* }
|
|
1967
|
+
*
|
|
1968
|
+
* Foo.prototype.c = 3;
|
|
1969
|
+
*
|
|
1970
|
+
* _.keys(new Foo);
|
|
1971
|
+
* // => ['a', 'b'] (iteration order is not guaranteed)
|
|
1972
|
+
*
|
|
1973
|
+
* _.keys('hi');
|
|
1974
|
+
* // => ['0', '1']
|
|
1975
|
+
*/
|
|
1976
|
+
function keys(object) {
|
|
1977
|
+
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
/**
|
|
1981
|
+
* This method returns a new empty array.
|
|
1982
|
+
*
|
|
1983
|
+
* @static
|
|
1984
|
+
* @memberOf _
|
|
1985
|
+
* @since 4.13.0
|
|
1986
|
+
* @category Util
|
|
1987
|
+
* @returns {Array} Returns the new empty array.
|
|
1988
|
+
* @example
|
|
1989
|
+
*
|
|
1990
|
+
* var arrays = _.times(2, _.stubArray);
|
|
1991
|
+
*
|
|
1992
|
+
* console.log(arrays);
|
|
1993
|
+
* // => [[], []]
|
|
1994
|
+
*
|
|
1995
|
+
* console.log(arrays[0] === arrays[1]);
|
|
1996
|
+
* // => false
|
|
1997
|
+
*/
|
|
1998
|
+
function stubArray() {
|
|
1999
|
+
return [];
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
/**
|
|
2003
|
+
* This method returns `false`.
|
|
2004
|
+
*
|
|
2005
|
+
* @static
|
|
2006
|
+
* @memberOf _
|
|
2007
|
+
* @since 4.13.0
|
|
2008
|
+
* @category Util
|
|
2009
|
+
* @returns {boolean} Returns `false`.
|
|
2010
|
+
* @example
|
|
2011
|
+
*
|
|
2012
|
+
* _.times(2, _.stubFalse);
|
|
2013
|
+
* // => [false, false]
|
|
2014
|
+
*/
|
|
2015
|
+
function stubFalse() {
|
|
2016
|
+
return false;
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
module.exports = isEqual;
|
|
2020
|
+
});
|
|
2021
|
+
|
|
2022
|
+
/**
|
|
2023
|
+
* lodash (Custom Build) <https://lodash.com/>
|
|
2024
|
+
* Build: `lodash modularize exports="npm" -o ./`
|
|
2025
|
+
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
|
2026
|
+
* Released under MIT license <https://lodash.com/license>
|
|
2027
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
2028
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
2029
|
+
*/
|
|
2030
|
+
|
|
2031
|
+
/** Used as references for various `Number` constants. */
|
|
2032
|
+
var INFINITY = 1 / 0,
|
|
2033
|
+
MAX_SAFE_INTEGER = 9007199254740991;
|
|
2034
|
+
|
|
2035
|
+
/** `Object#toString` result references. */
|
|
2036
|
+
var argsTag = '[object Arguments]',
|
|
2037
|
+
funcTag = '[object Function]',
|
|
2038
|
+
genTag = '[object GeneratorFunction]',
|
|
2039
|
+
symbolTag = '[object Symbol]';
|
|
2040
|
+
|
|
2041
|
+
/** Detect free variable `global` from Node.js. */
|
|
2042
|
+
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
2043
|
+
|
|
2044
|
+
/** Detect free variable `self`. */
|
|
2045
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
2046
|
+
|
|
2047
|
+
/** Used as a reference to the global object. */
|
|
2048
|
+
var root = freeGlobal || freeSelf || Function('return this')();
|
|
2049
|
+
|
|
2050
|
+
/**
|
|
2051
|
+
* A faster alternative to `Function#apply`, this function invokes `func`
|
|
2052
|
+
* with the `this` binding of `thisArg` and the arguments of `args`.
|
|
2053
|
+
*
|
|
2054
|
+
* @private
|
|
2055
|
+
* @param {Function} func The function to invoke.
|
|
2056
|
+
* @param {*} thisArg The `this` binding of `func`.
|
|
2057
|
+
* @param {Array} args The arguments to invoke `func` with.
|
|
2058
|
+
* @returns {*} Returns the result of `func`.
|
|
2059
|
+
*/
|
|
2060
|
+
function apply(func, thisArg, args) {
|
|
2061
|
+
switch (args.length) {
|
|
2062
|
+
case 0: return func.call(thisArg);
|
|
2063
|
+
case 1: return func.call(thisArg, args[0]);
|
|
2064
|
+
case 2: return func.call(thisArg, args[0], args[1]);
|
|
2065
|
+
case 3: return func.call(thisArg, args[0], args[1], args[2]);
|
|
2066
|
+
}
|
|
2067
|
+
return func.apply(thisArg, args);
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
/**
|
|
2071
|
+
* A specialized version of `_.map` for arrays without support for iteratee
|
|
2072
|
+
* shorthands.
|
|
2073
|
+
*
|
|
2074
|
+
* @private
|
|
2075
|
+
* @param {Array} [array] The array to iterate over.
|
|
2076
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
2077
|
+
* @returns {Array} Returns the new mapped array.
|
|
2078
|
+
*/
|
|
2079
|
+
function arrayMap(array, iteratee) {
|
|
2080
|
+
var index = -1,
|
|
2081
|
+
length = array ? array.length : 0,
|
|
2082
|
+
result = Array(length);
|
|
2083
|
+
|
|
2084
|
+
while (++index < length) {
|
|
2085
|
+
result[index] = iteratee(array[index], index, array);
|
|
2086
|
+
}
|
|
2087
|
+
return result;
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
/**
|
|
2091
|
+
* Appends the elements of `values` to `array`.
|
|
2092
|
+
*
|
|
2093
|
+
* @private
|
|
2094
|
+
* @param {Array} array The array to modify.
|
|
2095
|
+
* @param {Array} values The values to append.
|
|
2096
|
+
* @returns {Array} Returns `array`.
|
|
2097
|
+
*/
|
|
2098
|
+
function arrayPush(array, values) {
|
|
2099
|
+
var index = -1,
|
|
2100
|
+
length = values.length,
|
|
2101
|
+
offset = array.length;
|
|
2102
|
+
|
|
2103
|
+
while (++index < length) {
|
|
2104
|
+
array[offset + index] = values[index];
|
|
2105
|
+
}
|
|
2106
|
+
return array;
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
/** Used for built-in method references. */
|
|
2110
|
+
var objectProto = Object.prototype;
|
|
2111
|
+
|
|
2112
|
+
/** Used to check objects for own properties. */
|
|
2113
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
2114
|
+
|
|
2115
|
+
/**
|
|
2116
|
+
* Used to resolve the
|
|
2117
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
2118
|
+
* of values.
|
|
2119
|
+
*/
|
|
2120
|
+
var objectToString = objectProto.toString;
|
|
2121
|
+
|
|
2122
|
+
/** Built-in value references. */
|
|
2123
|
+
var Symbol = root.Symbol,
|
|
2124
|
+
propertyIsEnumerable = objectProto.propertyIsEnumerable,
|
|
2125
|
+
spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
|
|
2126
|
+
|
|
2127
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
2128
|
+
var nativeMax = Math.max;
|
|
2129
|
+
|
|
2130
|
+
/**
|
|
2131
|
+
* The base implementation of `_.flatten` with support for restricting flattening.
|
|
2132
|
+
*
|
|
2133
|
+
* @private
|
|
2134
|
+
* @param {Array} array The array to flatten.
|
|
2135
|
+
* @param {number} depth The maximum recursion depth.
|
|
2136
|
+
* @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
|
|
2137
|
+
* @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
|
|
2138
|
+
* @param {Array} [result=[]] The initial result value.
|
|
2139
|
+
* @returns {Array} Returns the new flattened array.
|
|
2140
|
+
*/
|
|
2141
|
+
function baseFlatten(array, depth, predicate, isStrict, result) {
|
|
2142
|
+
var index = -1,
|
|
2143
|
+
length = array.length;
|
|
2144
|
+
|
|
2145
|
+
predicate || (predicate = isFlattenable);
|
|
2146
|
+
result || (result = []);
|
|
2147
|
+
|
|
2148
|
+
while (++index < length) {
|
|
2149
|
+
var value = array[index];
|
|
2150
|
+
if (depth > 0 && predicate(value)) {
|
|
2151
|
+
if (depth > 1) {
|
|
2152
|
+
// Recursively flatten arrays (susceptible to call stack limits).
|
|
2153
|
+
baseFlatten(value, depth - 1, predicate, isStrict, result);
|
|
2154
|
+
} else {
|
|
2155
|
+
arrayPush(result, value);
|
|
2156
|
+
}
|
|
2157
|
+
} else if (!isStrict) {
|
|
2158
|
+
result[result.length] = value;
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
return result;
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2164
|
+
/**
|
|
2165
|
+
* The base implementation of `_.pick` without support for individual
|
|
2166
|
+
* property identifiers.
|
|
2167
|
+
*
|
|
2168
|
+
* @private
|
|
2169
|
+
* @param {Object} object The source object.
|
|
2170
|
+
* @param {string[]} props The property identifiers to pick.
|
|
2171
|
+
* @returns {Object} Returns the new object.
|
|
2172
|
+
*/
|
|
2173
|
+
function basePick(object, props) {
|
|
2174
|
+
object = Object(object);
|
|
2175
|
+
return basePickBy(object, props, function(value, key) {
|
|
2176
|
+
return key in object;
|
|
2177
|
+
});
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
/**
|
|
2181
|
+
* The base implementation of `_.pickBy` without support for iteratee shorthands.
|
|
2182
|
+
*
|
|
2183
|
+
* @private
|
|
2184
|
+
* @param {Object} object The source object.
|
|
2185
|
+
* @param {string[]} props The property identifiers to pick from.
|
|
2186
|
+
* @param {Function} predicate The function invoked per property.
|
|
2187
|
+
* @returns {Object} Returns the new object.
|
|
2188
|
+
*/
|
|
2189
|
+
function basePickBy(object, props, predicate) {
|
|
2190
|
+
var index = -1,
|
|
2191
|
+
length = props.length,
|
|
2192
|
+
result = {};
|
|
2193
|
+
|
|
2194
|
+
while (++index < length) {
|
|
2195
|
+
var key = props[index],
|
|
2196
|
+
value = object[key];
|
|
2197
|
+
|
|
2198
|
+
if (predicate(value, key)) {
|
|
2199
|
+
result[key] = value;
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
return result;
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
/**
|
|
2206
|
+
* The base implementation of `_.rest` which doesn't validate or coerce arguments.
|
|
2207
|
+
*
|
|
2208
|
+
* @private
|
|
2209
|
+
* @param {Function} func The function to apply a rest parameter to.
|
|
2210
|
+
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
|
2211
|
+
* @returns {Function} Returns the new function.
|
|
2212
|
+
*/
|
|
2213
|
+
function baseRest(func, start) {
|
|
2214
|
+
start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
|
|
2215
|
+
return function() {
|
|
2216
|
+
var args = arguments,
|
|
2217
|
+
index = -1,
|
|
2218
|
+
length = nativeMax(args.length - start, 0),
|
|
2219
|
+
array = Array(length);
|
|
2220
|
+
|
|
2221
|
+
while (++index < length) {
|
|
2222
|
+
array[index] = args[start + index];
|
|
2223
|
+
}
|
|
2224
|
+
index = -1;
|
|
2225
|
+
var otherArgs = Array(start + 1);
|
|
2226
|
+
while (++index < start) {
|
|
2227
|
+
otherArgs[index] = args[index];
|
|
2228
|
+
}
|
|
2229
|
+
otherArgs[start] = array;
|
|
2230
|
+
return apply(func, this, otherArgs);
|
|
2231
|
+
};
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
/**
|
|
2235
|
+
* Checks if `value` is a flattenable `arguments` object or array.
|
|
2236
|
+
*
|
|
2237
|
+
* @private
|
|
2238
|
+
* @param {*} value The value to check.
|
|
2239
|
+
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
|
|
2240
|
+
*/
|
|
2241
|
+
function isFlattenable(value) {
|
|
2242
|
+
return isArray(value) || isArguments(value) ||
|
|
2243
|
+
!!(spreadableSymbol && value && value[spreadableSymbol]);
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2246
|
+
/**
|
|
2247
|
+
* Converts `value` to a string key if it's not a string or symbol.
|
|
2248
|
+
*
|
|
2249
|
+
* @private
|
|
2250
|
+
* @param {*} value The value to inspect.
|
|
2251
|
+
* @returns {string|symbol} Returns the key.
|
|
2252
|
+
*/
|
|
2253
|
+
function toKey(value) {
|
|
2254
|
+
if (typeof value == 'string' || isSymbol(value)) {
|
|
2255
|
+
return value;
|
|
2256
|
+
}
|
|
2257
|
+
var result = (value + '');
|
|
2258
|
+
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
|
2259
|
+
}
|
|
2260
|
+
|
|
2261
|
+
/**
|
|
2262
|
+
* Checks if `value` is likely an `arguments` object.
|
|
2263
|
+
*
|
|
2264
|
+
* @static
|
|
2265
|
+
* @memberOf _
|
|
2266
|
+
* @since 0.1.0
|
|
2267
|
+
* @category Lang
|
|
2268
|
+
* @param {*} value The value to check.
|
|
2269
|
+
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
2270
|
+
* else `false`.
|
|
2271
|
+
* @example
|
|
2272
|
+
*
|
|
2273
|
+
* _.isArguments(function() { return arguments; }());
|
|
2274
|
+
* // => true
|
|
2275
|
+
*
|
|
2276
|
+
* _.isArguments([1, 2, 3]);
|
|
2277
|
+
* // => false
|
|
2278
|
+
*/
|
|
2279
|
+
function isArguments(value) {
|
|
2280
|
+
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
|
|
2281
|
+
return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
|
|
2282
|
+
(!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
|
|
2283
|
+
}
|
|
2284
|
+
|
|
2285
|
+
/**
|
|
2286
|
+
* Checks if `value` is classified as an `Array` object.
|
|
2287
|
+
*
|
|
2288
|
+
* @static
|
|
2289
|
+
* @memberOf _
|
|
2290
|
+
* @since 0.1.0
|
|
2291
|
+
* @category Lang
|
|
2292
|
+
* @param {*} value The value to check.
|
|
2293
|
+
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
2294
|
+
* @example
|
|
2295
|
+
*
|
|
2296
|
+
* _.isArray([1, 2, 3]);
|
|
2297
|
+
* // => true
|
|
2298
|
+
*
|
|
2299
|
+
* _.isArray(document.body.children);
|
|
2300
|
+
* // => false
|
|
2301
|
+
*
|
|
2302
|
+
* _.isArray('abc');
|
|
2303
|
+
* // => false
|
|
2304
|
+
*
|
|
2305
|
+
* _.isArray(_.noop);
|
|
2306
|
+
* // => false
|
|
2307
|
+
*/
|
|
2308
|
+
var isArray = Array.isArray;
|
|
2309
|
+
|
|
2310
|
+
/**
|
|
2311
|
+
* Checks if `value` is array-like. A value is considered array-like if it's
|
|
2312
|
+
* not a function and has a `value.length` that's an integer greater than or
|
|
2313
|
+
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
|
2314
|
+
*
|
|
2315
|
+
* @static
|
|
2316
|
+
* @memberOf _
|
|
2317
|
+
* @since 4.0.0
|
|
2318
|
+
* @category Lang
|
|
2319
|
+
* @param {*} value The value to check.
|
|
2320
|
+
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
|
2321
|
+
* @example
|
|
2322
|
+
*
|
|
2323
|
+
* _.isArrayLike([1, 2, 3]);
|
|
2324
|
+
* // => true
|
|
2325
|
+
*
|
|
2326
|
+
* _.isArrayLike(document.body.children);
|
|
2327
|
+
* // => true
|
|
2328
|
+
*
|
|
2329
|
+
* _.isArrayLike('abc');
|
|
2330
|
+
* // => true
|
|
2331
|
+
*
|
|
2332
|
+
* _.isArrayLike(_.noop);
|
|
2333
|
+
* // => false
|
|
2334
|
+
*/
|
|
2335
|
+
function isArrayLike(value) {
|
|
2336
|
+
return value != null && isLength(value.length) && !isFunction(value);
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
/**
|
|
2340
|
+
* This method is like `_.isArrayLike` except that it also checks if `value`
|
|
2341
|
+
* is an object.
|
|
2342
|
+
*
|
|
2343
|
+
* @static
|
|
2344
|
+
* @memberOf _
|
|
2345
|
+
* @since 4.0.0
|
|
2346
|
+
* @category Lang
|
|
2347
|
+
* @param {*} value The value to check.
|
|
2348
|
+
* @returns {boolean} Returns `true` if `value` is an array-like object,
|
|
2349
|
+
* else `false`.
|
|
2350
|
+
* @example
|
|
2351
|
+
*
|
|
2352
|
+
* _.isArrayLikeObject([1, 2, 3]);
|
|
2353
|
+
* // => true
|
|
2354
|
+
*
|
|
2355
|
+
* _.isArrayLikeObject(document.body.children);
|
|
2356
|
+
* // => true
|
|
2357
|
+
*
|
|
2358
|
+
* _.isArrayLikeObject('abc');
|
|
2359
|
+
* // => false
|
|
2360
|
+
*
|
|
2361
|
+
* _.isArrayLikeObject(_.noop);
|
|
2362
|
+
* // => false
|
|
2363
|
+
*/
|
|
2364
|
+
function isArrayLikeObject(value) {
|
|
2365
|
+
return isObjectLike(value) && isArrayLike(value);
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
/**
|
|
2369
|
+
* Checks if `value` is classified as a `Function` object.
|
|
2370
|
+
*
|
|
2371
|
+
* @static
|
|
2372
|
+
* @memberOf _
|
|
2373
|
+
* @since 0.1.0
|
|
2374
|
+
* @category Lang
|
|
2375
|
+
* @param {*} value The value to check.
|
|
2376
|
+
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
2377
|
+
* @example
|
|
2378
|
+
*
|
|
2379
|
+
* _.isFunction(_);
|
|
2380
|
+
* // => true
|
|
2381
|
+
*
|
|
2382
|
+
* _.isFunction(/abc/);
|
|
2383
|
+
* // => false
|
|
2384
|
+
*/
|
|
2385
|
+
function isFunction(value) {
|
|
2386
|
+
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
2387
|
+
// in Safari 8-9 which returns 'object' for typed array and other constructors.
|
|
2388
|
+
var tag = isObject(value) ? objectToString.call(value) : '';
|
|
2389
|
+
return tag == funcTag || tag == genTag;
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
/**
|
|
2393
|
+
* Checks if `value` is a valid array-like length.
|
|
2394
|
+
*
|
|
2395
|
+
* **Note:** This method is loosely based on
|
|
2396
|
+
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|
2397
|
+
*
|
|
2398
|
+
* @static
|
|
2399
|
+
* @memberOf _
|
|
2400
|
+
* @since 4.0.0
|
|
2401
|
+
* @category Lang
|
|
2402
|
+
* @param {*} value The value to check.
|
|
2403
|
+
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|
2404
|
+
* @example
|
|
2405
|
+
*
|
|
2406
|
+
* _.isLength(3);
|
|
2407
|
+
* // => true
|
|
2408
|
+
*
|
|
2409
|
+
* _.isLength(Number.MIN_VALUE);
|
|
2410
|
+
* // => false
|
|
2411
|
+
*
|
|
2412
|
+
* _.isLength(Infinity);
|
|
2413
|
+
* // => false
|
|
2414
|
+
*
|
|
2415
|
+
* _.isLength('3');
|
|
2416
|
+
* // => false
|
|
2417
|
+
*/
|
|
2418
|
+
function isLength(value) {
|
|
2419
|
+
return typeof value == 'number' &&
|
|
2420
|
+
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
/**
|
|
2424
|
+
* Checks if `value` is the
|
|
2425
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
2426
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
2427
|
+
*
|
|
2428
|
+
* @static
|
|
2429
|
+
* @memberOf _
|
|
2430
|
+
* @since 0.1.0
|
|
2431
|
+
* @category Lang
|
|
2432
|
+
* @param {*} value The value to check.
|
|
2433
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
2434
|
+
* @example
|
|
2435
|
+
*
|
|
2436
|
+
* _.isObject({});
|
|
2437
|
+
* // => true
|
|
2438
|
+
*
|
|
2439
|
+
* _.isObject([1, 2, 3]);
|
|
2440
|
+
* // => true
|
|
2441
|
+
*
|
|
2442
|
+
* _.isObject(_.noop);
|
|
2443
|
+
* // => true
|
|
2444
|
+
*
|
|
2445
|
+
* _.isObject(null);
|
|
2446
|
+
* // => false
|
|
2447
|
+
*/
|
|
2448
|
+
function isObject(value) {
|
|
2449
|
+
var type = typeof value;
|
|
2450
|
+
return !!value && (type == 'object' || type == 'function');
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
/**
|
|
2454
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
2455
|
+
* and has a `typeof` result of "object".
|
|
2456
|
+
*
|
|
2457
|
+
* @static
|
|
2458
|
+
* @memberOf _
|
|
2459
|
+
* @since 4.0.0
|
|
2460
|
+
* @category Lang
|
|
2461
|
+
* @param {*} value The value to check.
|
|
2462
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
2463
|
+
* @example
|
|
2464
|
+
*
|
|
2465
|
+
* _.isObjectLike({});
|
|
2466
|
+
* // => true
|
|
2467
|
+
*
|
|
2468
|
+
* _.isObjectLike([1, 2, 3]);
|
|
2469
|
+
* // => true
|
|
2470
|
+
*
|
|
2471
|
+
* _.isObjectLike(_.noop);
|
|
2472
|
+
* // => false
|
|
2473
|
+
*
|
|
2474
|
+
* _.isObjectLike(null);
|
|
2475
|
+
* // => false
|
|
2476
|
+
*/
|
|
2477
|
+
function isObjectLike(value) {
|
|
2478
|
+
return !!value && typeof value == 'object';
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2481
|
+
/**
|
|
2482
|
+
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
2483
|
+
*
|
|
2484
|
+
* @static
|
|
2485
|
+
* @memberOf _
|
|
2486
|
+
* @since 4.0.0
|
|
2487
|
+
* @category Lang
|
|
2488
|
+
* @param {*} value The value to check.
|
|
2489
|
+
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
2490
|
+
* @example
|
|
2491
|
+
*
|
|
2492
|
+
* _.isSymbol(Symbol.iterator);
|
|
2493
|
+
* // => true
|
|
2494
|
+
*
|
|
2495
|
+
* _.isSymbol('abc');
|
|
2496
|
+
* // => false
|
|
2497
|
+
*/
|
|
2498
|
+
function isSymbol(value) {
|
|
2499
|
+
return typeof value == 'symbol' ||
|
|
2500
|
+
(isObjectLike(value) && objectToString.call(value) == symbolTag);
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2503
|
+
/**
|
|
2504
|
+
* Creates an object composed of the picked `object` properties.
|
|
2505
|
+
*
|
|
2506
|
+
* @static
|
|
2507
|
+
* @since 0.1.0
|
|
2508
|
+
* @memberOf _
|
|
2509
|
+
* @category Object
|
|
2510
|
+
* @param {Object} object The source object.
|
|
2511
|
+
* @param {...(string|string[])} [props] The property identifiers to pick.
|
|
2512
|
+
* @returns {Object} Returns the new object.
|
|
2513
|
+
* @example
|
|
2514
|
+
*
|
|
2515
|
+
* var object = { 'a': 1, 'b': '2', 'c': 3 };
|
|
2516
|
+
*
|
|
2517
|
+
* _.pick(object, ['a', 'c']);
|
|
2518
|
+
* // => { 'a': 1, 'c': 3 }
|
|
2519
|
+
*/
|
|
2520
|
+
var pick = baseRest(function(object, props) {
|
|
2521
|
+
return object == null ? {} : basePick(object, arrayMap(baseFlatten(props, 1), toKey));
|
|
2522
|
+
});
|
|
2523
|
+
|
|
2524
|
+
var lodash_pick = pick;
|
|
2525
|
+
|
|
2526
|
+
function getUserProfile() {
|
|
2527
|
+
return adminServices.request.get({ path: '/admin/self' });
|
|
2528
|
+
}
|
|
137
2529
|
/** Blog Posts */
|
|
138
2530
|
function getBlogPostList(params) {
|
|
139
2531
|
return adminServices.request.get({ path: '/admin/blog/posts', params });
|
|
@@ -144,6 +2536,9 @@
|
|
|
144
2536
|
function getBlogPost(postId) {
|
|
145
2537
|
return adminServices.request.get({ path: `/admin/blog/posts/${postId}` });
|
|
146
2538
|
}
|
|
2539
|
+
function clonePost(postId) {
|
|
2540
|
+
return adminServices.request.post({ path: `/admin/blog/posts/${postId}/clone` });
|
|
2541
|
+
}
|
|
147
2542
|
function createBlogPost(payload) {
|
|
148
2543
|
return adminServices.request.post({ path: '/admin/blog/posts', body: payload });
|
|
149
2544
|
}
|
|
@@ -154,8 +2549,8 @@
|
|
|
154
2549
|
return adminServices.request.delete({ path: `/admin/blog/posts/${postId}` });
|
|
155
2550
|
}
|
|
156
2551
|
/** Blog Categories */
|
|
157
|
-
function getBlogCategoryList() {
|
|
158
|
-
return adminServices.request.get({ path: '/admin/blog/categories' });
|
|
2552
|
+
function getBlogCategoryList(params) {
|
|
2553
|
+
return adminServices.request.get({ path: '/admin/blog/categories', params });
|
|
159
2554
|
}
|
|
160
2555
|
function getBlogCategory(categoryId) {
|
|
161
2556
|
return adminServices.request.get({ path: `/admin/blog/categories/${categoryId}` });
|
|
@@ -183,17 +2578,6 @@
|
|
|
183
2578
|
return adminServices.request.get({
|
|
184
2579
|
path: `/admin/blog/module-info`,
|
|
185
2580
|
});
|
|
186
|
-
}
|
|
187
|
-
function getBlogSettingList() {
|
|
188
|
-
return adminServices.request.get({
|
|
189
|
-
path: `/admin/blog/settings`,
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
function updateBlogSettingList(payload) {
|
|
193
|
-
return adminServices.request.post({
|
|
194
|
-
path: `/admin/blog/settings`,
|
|
195
|
-
body: payload,
|
|
196
|
-
});
|
|
197
2581
|
}
|
|
198
2582
|
|
|
199
2583
|
const BLOG_ROUTE_PATHS = {
|
|
@@ -201,7 +2585,6 @@
|
|
|
201
2585
|
POST_FORM: '/blog/posts/:postId',
|
|
202
2586
|
CATEGORY_LIST: '/blog/categories',
|
|
203
2587
|
CATEGORY_FORM: '/blog/categories/:categoryId',
|
|
204
|
-
SETTINGS: '/blog/settings',
|
|
205
2588
|
};
|
|
206
2589
|
function getBlogPostListUrl() {
|
|
207
2590
|
return BLOG_ROUTE_PATHS.POST_LIST;
|
|
@@ -216,46 +2599,170 @@
|
|
|
216
2599
|
return pathToRegexp.compile(BLOG_ROUTE_PATHS.CATEGORY_FORM)({
|
|
217
2600
|
categoryId: params.categoryId,
|
|
218
2601
|
});
|
|
219
|
-
}
|
|
220
|
-
function getBlogSettingsUrl() {
|
|
221
|
-
return BLOG_ROUTE_PATHS.SETTINGS;
|
|
222
2602
|
}
|
|
223
2603
|
|
|
224
|
-
function useModuleConfig(params) {
|
|
225
|
-
const [fetchModuleConfig, resource] = adminServices.useResource({
|
|
226
|
-
fetchResource: getBlogModuleConfig,
|
|
227
|
-
initialValue: null,
|
|
228
|
-
context: params.context,
|
|
229
|
-
resourceName: 'Module configuration',
|
|
230
|
-
});
|
|
231
|
-
compositionApi.onMounted(() => {
|
|
232
|
-
fetchModuleConfig();
|
|
233
|
-
});
|
|
234
|
-
return resource;
|
|
2604
|
+
function useModuleConfig(params) {
|
|
2605
|
+
const [fetchModuleConfig, resource] = adminServices.useResource({
|
|
2606
|
+
fetchResource: getBlogModuleConfig,
|
|
2607
|
+
initialValue: null,
|
|
2608
|
+
context: params.context,
|
|
2609
|
+
resourceName: 'Module configuration',
|
|
2610
|
+
});
|
|
2611
|
+
compositionApi.onMounted(() => {
|
|
2612
|
+
fetchModuleConfig();
|
|
2613
|
+
});
|
|
2614
|
+
return resource;
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
function useBlogPostList(params) {
|
|
2618
|
+
const [fetchBlogPostList, resource] = adminServices.useResource({
|
|
2619
|
+
fetchResource: () => getBlogPostList({ pageNumber: 1, pageSize: 99999 }),
|
|
2620
|
+
initialValue: [],
|
|
2621
|
+
context: params.context,
|
|
2622
|
+
resourceName: 'Blog post list',
|
|
2623
|
+
});
|
|
2624
|
+
compositionApi.onMounted(() => {
|
|
2625
|
+
fetchBlogPostList();
|
|
2626
|
+
});
|
|
2627
|
+
return resource;
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2630
|
+
function useBlogCategoryList(params) {
|
|
2631
|
+
const [fetchBlogCategoryList, resource] = adminServices.useResource({
|
|
2632
|
+
fetchResource: getBlogCategoryList,
|
|
2633
|
+
initialValue: [],
|
|
2634
|
+
context: params.context,
|
|
2635
|
+
resourceName: 'Blog category list',
|
|
2636
|
+
});
|
|
2637
|
+
compositionApi.onMounted(() => {
|
|
2638
|
+
fetchBlogCategoryList();
|
|
2639
|
+
});
|
|
2640
|
+
return resource;
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2643
|
+
function useStore(context) {
|
|
2644
|
+
return context.root.$store;
|
|
2645
|
+
}
|
|
2646
|
+
|
|
2647
|
+
const Scope = {
|
|
2648
|
+
All: '*',
|
|
2649
|
+
OrdersCreate: 'orders.create',
|
|
2650
|
+
OrdersView: 'orders.view',
|
|
2651
|
+
OrdersDelete: 'orders.delete',
|
|
2652
|
+
RbacViewRoles: 'rbac.view-roles',
|
|
2653
|
+
RbacEditRoles: 'rbac.edit-roles',
|
|
2654
|
+
AdministratorsView: 'administrators.view',
|
|
2655
|
+
AdministratorsEdit: 'administrators.edit',
|
|
2656
|
+
AdministratorsDelete: 'administrators.delete',
|
|
2657
|
+
};
|
|
2658
|
+
|
|
2659
|
+
const USER_MODULE_NAMESPACE = 'user';
|
|
2660
|
+
const USER_MUTATION_TYPES = {
|
|
2661
|
+
PROFILE_REQUEST_STARTED: 'profileRequestStarted',
|
|
2662
|
+
PROFILE_REQUEST_FULFILLED: 'profileRequestFulfilled',
|
|
2663
|
+
PROFILE_REQUEST_REJECTED: 'profileRequestRejected',
|
|
2664
|
+
};
|
|
2665
|
+
const USER_ACTION_TYPES = {
|
|
2666
|
+
FETCH_USER_PROFILE: 'fetchUserProfile',
|
|
2667
|
+
};
|
|
2668
|
+
const userGetters = {
|
|
2669
|
+
userProfile(state) {
|
|
2670
|
+
return state.profile;
|
|
2671
|
+
},
|
|
2672
|
+
userScopes(state) {
|
|
2673
|
+
const roles = state.profile ? state.profile.roles : [];
|
|
2674
|
+
const scopes = [];
|
|
2675
|
+
roles.forEach((role) => {
|
|
2676
|
+
scopes.push(...role.scopes);
|
|
2677
|
+
});
|
|
2678
|
+
return scopes;
|
|
2679
|
+
},
|
|
2680
|
+
userHasPermission: (state, getters) => (scope) => {
|
|
2681
|
+
const scopes = getters.userScopes;
|
|
2682
|
+
if (scopes.includes(Scope.All))
|
|
2683
|
+
return true;
|
|
2684
|
+
return scopes.includes(scope);
|
|
2685
|
+
},
|
|
2686
|
+
};
|
|
2687
|
+
const userModule = {
|
|
2688
|
+
namespaced: true,
|
|
2689
|
+
state: {
|
|
2690
|
+
profile: null,
|
|
2691
|
+
status: adminServices.FETCH_STATUSES.IDLE,
|
|
2692
|
+
},
|
|
2693
|
+
mutations: {
|
|
2694
|
+
[USER_MUTATION_TYPES.PROFILE_REQUEST_STARTED](state) {
|
|
2695
|
+
if (state.status === adminServices.FETCH_STATUSES.IDLE) {
|
|
2696
|
+
state.status = adminServices.FETCH_STATUSES.LOADING;
|
|
2697
|
+
}
|
|
2698
|
+
},
|
|
2699
|
+
[USER_MUTATION_TYPES.PROFILE_REQUEST_FULFILLED](state, user) {
|
|
2700
|
+
if (state.status === adminServices.FETCH_STATUSES.LOADING) {
|
|
2701
|
+
state.status = adminServices.FETCH_STATUSES.SUCCESS;
|
|
2702
|
+
state.profile = user;
|
|
2703
|
+
}
|
|
2704
|
+
},
|
|
2705
|
+
[USER_MUTATION_TYPES.PROFILE_REQUEST_REJECTED](state) {
|
|
2706
|
+
if (state.status === adminServices.FETCH_STATUSES.LOADING) {
|
|
2707
|
+
state.status = adminServices.FETCH_STATUSES.FAILURE;
|
|
2708
|
+
state.profile = null;
|
|
2709
|
+
}
|
|
2710
|
+
},
|
|
2711
|
+
},
|
|
2712
|
+
actions: {
|
|
2713
|
+
[USER_ACTION_TYPES.FETCH_USER_PROFILE](store) {
|
|
2714
|
+
if (store.state.status !== adminServices.FETCH_STATUSES.IDLE)
|
|
2715
|
+
return;
|
|
2716
|
+
store.commit(USER_MUTATION_TYPES.PROFILE_REQUEST_STARTED);
|
|
2717
|
+
getUserProfile()
|
|
2718
|
+
.then((response) => {
|
|
2719
|
+
store.commit(USER_MUTATION_TYPES.PROFILE_REQUEST_FULFILLED, response.data);
|
|
2720
|
+
})
|
|
2721
|
+
.catch((error) => {
|
|
2722
|
+
console.error(error);
|
|
2723
|
+
store.commit(USER_MUTATION_TYPES.PROFILE_REQUEST_REJECTED);
|
|
2724
|
+
});
|
|
2725
|
+
},
|
|
2726
|
+
},
|
|
2727
|
+
getters: userGetters,
|
|
2728
|
+
};
|
|
2729
|
+
|
|
2730
|
+
function namespace(namespace, name) {
|
|
2731
|
+
return `${namespace}/${name}`;
|
|
2732
|
+
}
|
|
2733
|
+
function userNamespace(name) {
|
|
2734
|
+
return namespace(USER_MODULE_NAMESPACE, name);
|
|
2735
|
+
}
|
|
2736
|
+
function generateNumberArray(length) {
|
|
2737
|
+
return Array.from({ length }, (_, index) => index);
|
|
2738
|
+
}
|
|
2739
|
+
function getNameWithDepth(name, depth) {
|
|
2740
|
+
return (generateNumberArray(depth)
|
|
2741
|
+
.map(() => '—')
|
|
2742
|
+
.join(' ') +
|
|
2743
|
+
' ' +
|
|
2744
|
+
name);
|
|
235
2745
|
}
|
|
236
2746
|
|
|
237
|
-
function
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
context: params.context,
|
|
242
|
-
resourceName: 'Blog category list',
|
|
243
|
-
});
|
|
244
|
-
compositionApi.onMounted(() => {
|
|
245
|
-
fetchBlogCategoryList();
|
|
2747
|
+
function useUserPermission(context, scope) {
|
|
2748
|
+
const store = useStore(context);
|
|
2749
|
+
return compositionApi.computed(() => {
|
|
2750
|
+
return store.getters[userNamespace('userHasPermission')](scope);
|
|
246
2751
|
});
|
|
247
|
-
return resource;
|
|
248
2752
|
}
|
|
249
2753
|
|
|
250
2754
|
function convertPostList(postList, selectedCategory, languages) {
|
|
251
2755
|
return postList
|
|
252
2756
|
.filter((post) => selectedCategory
|
|
253
|
-
? post.categories.some((
|
|
2757
|
+
? post.categories.some(({ id }) => id === selectedCategory.id)
|
|
254
2758
|
: true)
|
|
255
2759
|
.map((post) => {
|
|
256
2760
|
if (languages.length > 0) {
|
|
257
|
-
const foundLanguage = languages.find((
|
|
258
|
-
return
|
|
2761
|
+
const foundLanguage = languages.find(({ id }) => id === post.language);
|
|
2762
|
+
return {
|
|
2763
|
+
...post,
|
|
2764
|
+
language: foundLanguage ? foundLanguage.name : post.language,
|
|
2765
|
+
};
|
|
259
2766
|
}
|
|
260
2767
|
return post;
|
|
261
2768
|
});
|
|
@@ -320,53 +2827,217 @@
|
|
|
320
2827
|
return COLUMN_DEFS.filter(adminServices.notEmpty);
|
|
321
2828
|
}
|
|
322
2829
|
|
|
2830
|
+
var FilterTypes;
|
|
2831
|
+
(function (FilterTypes) {
|
|
2832
|
+
FilterTypes["CATEGORY"] = "category";
|
|
2833
|
+
FilterTypes["LANGUAGE"] = "language";
|
|
2834
|
+
FilterTypes["FROM_DATE"] = "from-date";
|
|
2835
|
+
FilterTypes["TO_DATE"] = "to-date";
|
|
2836
|
+
})(FilterTypes || (FilterTypes = {}));
|
|
2837
|
+
const dateFormat = (date) => date.split('-').reverse().join('.');
|
|
2838
|
+
function useAdvancedSearch({ context, categoryList, languageList, }) {
|
|
2839
|
+
/** Category **/
|
|
2840
|
+
const categoryOptionList = compositionApi.computed(() => categoryList.value.map(({ id, name, depth }) => ({
|
|
2841
|
+
value: String(id),
|
|
2842
|
+
label: getNameWithDepth(name, depth),
|
|
2843
|
+
})));
|
|
2844
|
+
const initialCategoryFilter = compositionApi.computed(() => {
|
|
2845
|
+
const queryValue = adminUi.getFilterParamAsStringArray(context.root.$route.query, FilterTypes.CATEGORY);
|
|
2846
|
+
return categoryOptionList.value.filter(({ value }) => queryValue.some((selected) => selected === value));
|
|
2847
|
+
});
|
|
2848
|
+
const categoryFilter = compositionApi.ref(initialCategoryFilter.value);
|
|
2849
|
+
compositionApi.watch(initialCategoryFilter, () => {
|
|
2850
|
+
categoryFilter.value = initialCategoryFilter.value;
|
|
2851
|
+
});
|
|
2852
|
+
/** Language **/
|
|
2853
|
+
const languageOptionList = compositionApi.computed(() => languageList.value.map(({ id, name }) => ({ value: id, label: name })));
|
|
2854
|
+
const initialLanguageFilter = compositionApi.computed(() => {
|
|
2855
|
+
const queryValue = adminUi.getFilterParamAsStringArray(context.root.$route.query, FilterTypes.LANGUAGE);
|
|
2856
|
+
return languageOptionList.value.filter(({ value }) => queryValue.some((selected) => selected === value));
|
|
2857
|
+
});
|
|
2858
|
+
const languageFilter = compositionApi.ref(initialLanguageFilter.value);
|
|
2859
|
+
compositionApi.watch(initialLanguageFilter, () => {
|
|
2860
|
+
languageFilter.value = initialLanguageFilter.value;
|
|
2861
|
+
});
|
|
2862
|
+
/** From date **/
|
|
2863
|
+
const initialFromDateFilter = compositionApi.computed(() => adminUi.getFilterParamAsString(context.root.$route.query, FilterTypes.FROM_DATE) ?? '');
|
|
2864
|
+
const fromDateFilter = compositionApi.ref(initialFromDateFilter.value);
|
|
2865
|
+
compositionApi.watch(initialFromDateFilter, () => {
|
|
2866
|
+
fromDateFilter.value = initialFromDateFilter.value;
|
|
2867
|
+
});
|
|
2868
|
+
/** To date **/
|
|
2869
|
+
const initialToDateFilter = compositionApi.computed(() => adminUi.getFilterParamAsString(context.root.$route.query, FilterTypes.TO_DATE) ??
|
|
2870
|
+
'');
|
|
2871
|
+
const toDateFilter = compositionApi.ref(initialToDateFilter.value);
|
|
2872
|
+
compositionApi.watch(initialToDateFilter, () => {
|
|
2873
|
+
toDateFilter.value = initialToDateFilter.value;
|
|
2874
|
+
});
|
|
2875
|
+
/** Date **/
|
|
2876
|
+
const date = compositionApi.computed(() => {
|
|
2877
|
+
if (!fromDateFilter.value && !toDateFilter.value) {
|
|
2878
|
+
return null;
|
|
2879
|
+
}
|
|
2880
|
+
let label = '';
|
|
2881
|
+
if (fromDateFilter.value && toDateFilter.value) {
|
|
2882
|
+
label = `${dateFormat(fromDateFilter.value)} - ${dateFormat(toDateFilter.value)}`;
|
|
2883
|
+
}
|
|
2884
|
+
if (fromDateFilter.value && !toDateFilter.value) {
|
|
2885
|
+
label = `${context.root.$t('blog:from')} ${dateFormat(fromDateFilter.value)}`;
|
|
2886
|
+
}
|
|
2887
|
+
if (!fromDateFilter.value && toDateFilter.value) {
|
|
2888
|
+
label = `${context.root.$t('blog:to')} ${dateFormat(toDateFilter.value)}`;
|
|
2889
|
+
}
|
|
2890
|
+
return {
|
|
2891
|
+
value: '',
|
|
2892
|
+
label,
|
|
2893
|
+
name: FilterTypes.FROM_DATE,
|
|
2894
|
+
title: context.root.$t('blog:dateOfPublication'),
|
|
2895
|
+
};
|
|
2896
|
+
});
|
|
2897
|
+
/** Params **/
|
|
2898
|
+
const filterParams = compositionApi.computed(() => {
|
|
2899
|
+
const filters = {
|
|
2900
|
+
[FilterTypes.CATEGORY]: categoryFilter.value.map(({ value }) => value),
|
|
2901
|
+
[FilterTypes.LANGUAGE]: languageFilter.value.map(({ value }) => value),
|
|
2902
|
+
};
|
|
2903
|
+
if (fromDateFilter.value) {
|
|
2904
|
+
filters[FilterTypes.FROM_DATE] = fromDateFilter.value;
|
|
2905
|
+
}
|
|
2906
|
+
if (toDateFilter.value) {
|
|
2907
|
+
filters[FilterTypes.TO_DATE] = toDateFilter.value;
|
|
2908
|
+
}
|
|
2909
|
+
return adminUi.getFilterParams(filters);
|
|
2910
|
+
});
|
|
2911
|
+
/** Tag removal handler **/
|
|
2912
|
+
function tagRemovalHandler(event) {
|
|
2913
|
+
if (event.name === FilterTypes.CATEGORY) {
|
|
2914
|
+
categoryFilter.value = categoryFilter.value.filter(({ value }) => value !== event.value);
|
|
2915
|
+
}
|
|
2916
|
+
if (event.name === FilterTypes.LANGUAGE) {
|
|
2917
|
+
languageFilter.value = languageFilter.value.filter(({ value }) => value !== event.value);
|
|
2918
|
+
}
|
|
2919
|
+
if (event.name === FilterTypes.FROM_DATE) {
|
|
2920
|
+
fromDateFilter.value = '';
|
|
2921
|
+
toDateFilter.value = '';
|
|
2922
|
+
}
|
|
2923
|
+
}
|
|
2924
|
+
/** Tags **/
|
|
2925
|
+
const tags = compositionApi.computed(() => [
|
|
2926
|
+
...categoryFilter.value.map(({ value, label }) => ({
|
|
2927
|
+
value,
|
|
2928
|
+
label,
|
|
2929
|
+
name: FilterTypes.CATEGORY,
|
|
2930
|
+
title: context.root.$t('blog:category'),
|
|
2931
|
+
})),
|
|
2932
|
+
...languageFilter.value.map(({ value, label }) => ({
|
|
2933
|
+
value,
|
|
2934
|
+
label,
|
|
2935
|
+
name: FilterTypes.LANGUAGE,
|
|
2936
|
+
title: context.root.$t('blog:language'),
|
|
2937
|
+
})),
|
|
2938
|
+
date.value,
|
|
2939
|
+
].filter(adminServices.isNotNullish));
|
|
2940
|
+
/** Helpers **/
|
|
2941
|
+
const selectedCategoryOptionList = compositionApi.computed(() => {
|
|
2942
|
+
if (languageFilter.value.length === 0) {
|
|
2943
|
+
return categoryOptionList.value;
|
|
2944
|
+
}
|
|
2945
|
+
const selectedList = categoryList.value.filter(({ language }) => languageFilter.value.some(({ value }) => value === language));
|
|
2946
|
+
return selectedList.map(({ id, name, depth }) => ({
|
|
2947
|
+
value: String(id),
|
|
2948
|
+
label: getNameWithDepth(name, depth),
|
|
2949
|
+
}));
|
|
2950
|
+
});
|
|
2951
|
+
return {
|
|
2952
|
+
categoryFilter,
|
|
2953
|
+
categoryOptionList: selectedCategoryOptionList,
|
|
2954
|
+
languageFilter,
|
|
2955
|
+
languageOptionList,
|
|
2956
|
+
fromDateFilter,
|
|
2957
|
+
toDateFilter,
|
|
2958
|
+
tagRemovalHandler,
|
|
2959
|
+
tags: tags,
|
|
2960
|
+
filterParams,
|
|
2961
|
+
};
|
|
2962
|
+
}
|
|
2963
|
+
|
|
323
2964
|
var script = compositionApi.defineComponent({
|
|
324
2965
|
name: 'BlogPostList',
|
|
325
2966
|
setup(props, context) {
|
|
2967
|
+
const { t } = adminUi.useTranslation(context);
|
|
2968
|
+
const canViewAdministrators = useUserPermission(context, Scope.AdministratorsView);
|
|
326
2969
|
const categoryId = compositionApi.computed(() => {
|
|
327
|
-
var _a;
|
|
328
2970
|
return Array.isArray(context.root.$route.query.category)
|
|
329
|
-
?
|
|
2971
|
+
? context.root.$route.query.category[0] ?? ''
|
|
2972
|
+
: context.root.$route.query.category;
|
|
330
2973
|
});
|
|
331
2974
|
/** Fetch module config */
|
|
332
2975
|
const { data: moduleConfig, loading: isModuleConfigLoading, } = useModuleConfig({ context });
|
|
2976
|
+
const languageList = compositionApi.computed(() => moduleConfig.value?.languages ?? []);
|
|
333
2977
|
/** Fetch category list */
|
|
334
2978
|
const { data: categoryList, loading: isCategoryListLoading, } = useBlogCategoryList({ context });
|
|
335
|
-
const selectedCategory = compositionApi.computed(() =>
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
? (_a = categoryList.value.find((category) => String(category.id) === String(categoryId.value))) !== null && _a !== void 0 ? _a : null : null;
|
|
339
|
-
});
|
|
2979
|
+
const selectedCategory = compositionApi.computed(() => categoryId.value
|
|
2980
|
+
? categoryList.value.find(({ id }) => String(id) === String(categoryId.value)) ?? null
|
|
2981
|
+
: null);
|
|
340
2982
|
const pageTitle = compositionApi.computed(() => {
|
|
341
2983
|
return selectedCategory.value
|
|
342
2984
|
? `${context.root.$t('blog:postsByCategory')} "${selectedCategory.value.name}"`
|
|
343
2985
|
: context.root.$t('blog:posts');
|
|
344
2986
|
});
|
|
2987
|
+
/** Advanced search **/
|
|
2988
|
+
const { categoryFilter, categoryOptionList, languageFilter, languageOptionList, fromDateFilter, toDateFilter, filterParams, tags, tagRemovalHandler, } = useAdvancedSearch({
|
|
2989
|
+
context,
|
|
2990
|
+
categoryList,
|
|
2991
|
+
languageList,
|
|
2992
|
+
});
|
|
2993
|
+
const isLangSpecific = compositionApi.computed(() => languageOptionList.value.length > 1);
|
|
345
2994
|
/** Fetch Post list */
|
|
346
2995
|
const { fetchEntityList: fetchPostList, isLoading: isPostLoading, rowData: postList, errorMessage, searchQuery, handleChange, pageNumber, pageCount, pageSize, } = adminUi.useDataTable({
|
|
347
2996
|
fetchEntityList: (params) => getBlogPostList({
|
|
348
2997
|
query: params.searchQuery,
|
|
349
2998
|
pageNumber: params.pageNumber,
|
|
350
2999
|
pageSize: params.pageSize,
|
|
3000
|
+
...filterParams.value,
|
|
351
3001
|
}),
|
|
352
3002
|
initialValue: [],
|
|
353
3003
|
context,
|
|
354
3004
|
resourceName: 'Blog post list',
|
|
355
3005
|
pageSize: 100,
|
|
356
3006
|
});
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
3007
|
+
compositionApi.watch(filterParams, () => {
|
|
3008
|
+
if (isModuleConfigLoading.value || isCategoryListLoading.value) {
|
|
3009
|
+
return;
|
|
3010
|
+
}
|
|
3011
|
+
const newQuery = {
|
|
3012
|
+
...lodash_pick(context.root.$route.query, ['query', 'pageNumber']),
|
|
3013
|
+
...filterParams.value,
|
|
3014
|
+
};
|
|
3015
|
+
if (!lodash_isequal(context.root.$route.query, newQuery)) {
|
|
3016
|
+
context.root.$router.replace({ query: newQuery });
|
|
3017
|
+
fetchPostList();
|
|
3018
|
+
}
|
|
360
3019
|
});
|
|
361
|
-
const
|
|
3020
|
+
const displayedPostList = compositionApi.computed(() => convertPostList(postList.value, selectedCategory.value, moduleConfig.value?.languages ?? []));
|
|
3021
|
+
const isRowDataLoading = compositionApi.computed(() => isCategoryListLoading.value ||
|
|
3022
|
+
isPostLoading.value ||
|
|
3023
|
+
isModuleConfigLoading.value);
|
|
3024
|
+
const { isDeleting, handleResourceDelete } = adminServices.useResourceDelete({
|
|
362
3025
|
deleteResource: deleteBlogPost,
|
|
363
3026
|
resourceName: 'Post',
|
|
364
3027
|
onSuccess: fetchPostList,
|
|
365
3028
|
context,
|
|
366
3029
|
});
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
|
|
3030
|
+
const { isCloning, handleResourceClone } = adminServices.useResourceClone({
|
|
3031
|
+
cloneResource: clonePost,
|
|
3032
|
+
confirmMessage: t('blog:cloneConfirm'),
|
|
3033
|
+
successMessage: t('blog:cloneSuccess'),
|
|
3034
|
+
failureMessage: t('blog:cloneFailure'),
|
|
3035
|
+
onSuccessRedirectTo: (data) => `/posts/${data.id}`,
|
|
3036
|
+
context,
|
|
3037
|
+
});
|
|
3038
|
+
function isBusy(postId) {
|
|
3039
|
+
return isDeleting(postId) || isCloning(postId) || isRowDataLoading.value;
|
|
3040
|
+
}
|
|
370
3041
|
const columnDefs = compositionApi.computed(() => getPostTableColumnDefs(moduleConfig.value, context.root.$t));
|
|
371
3042
|
return {
|
|
372
3043
|
columnDefs,
|
|
@@ -383,6 +3054,21 @@
|
|
|
383
3054
|
pageNumber,
|
|
384
3055
|
pageCount,
|
|
385
3056
|
pageSize,
|
|
3057
|
+
// Advanced search
|
|
3058
|
+
categoryFilter,
|
|
3059
|
+
categoryOptionList,
|
|
3060
|
+
isLangSpecific,
|
|
3061
|
+
languageFilter,
|
|
3062
|
+
languageOptionList,
|
|
3063
|
+
fromDateFilter,
|
|
3064
|
+
toDateFilter,
|
|
3065
|
+
tags,
|
|
3066
|
+
tagRemovalHandler,
|
|
3067
|
+
// Permissions
|
|
3068
|
+
canViewAdministrators,
|
|
3069
|
+
// Clone
|
|
3070
|
+
handleResourceClone,
|
|
3071
|
+
isBusy,
|
|
386
3072
|
};
|
|
387
3073
|
},
|
|
388
3074
|
});
|
|
@@ -527,11 +3213,13 @@
|
|
|
527
3213
|
attrs: {
|
|
528
3214
|
title: _vm.pageTitle,
|
|
529
3215
|
"header-buttons": [
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
3216
|
+
_vm.canViewAdministrators
|
|
3217
|
+
? {
|
|
3218
|
+
text: _vm.$t("blog:newPost"),
|
|
3219
|
+
href: _vm.getBlogPostFormUrl({ postId: "create" }),
|
|
3220
|
+
}
|
|
3221
|
+
: null,
|
|
3222
|
+
].filter(Boolean),
|
|
535
3223
|
},
|
|
536
3224
|
scopedSlots: _vm._u([
|
|
537
3225
|
{
|
|
@@ -556,41 +3244,173 @@
|
|
|
556
3244
|
on: { change: _vm.handleChange },
|
|
557
3245
|
scopedSlots: _vm._u([
|
|
558
3246
|
{
|
|
559
|
-
key: "
|
|
560
|
-
fn: function (
|
|
561
|
-
var row = ref.row;
|
|
3247
|
+
key: "filters",
|
|
3248
|
+
fn: function () {
|
|
562
3249
|
return [
|
|
563
3250
|
_c(
|
|
564
|
-
"
|
|
3251
|
+
"advanced-search",
|
|
565
3252
|
{
|
|
566
|
-
attrs: {
|
|
567
|
-
|
|
568
|
-
title: _vm.$t("blog:edit"),
|
|
569
|
-
disabled: _vm.isDeleting(row.id),
|
|
570
|
-
href: _vm.getBlogPostFormUrl({ postId: row.id }),
|
|
571
|
-
},
|
|
3253
|
+
attrs: { tags: _vm.tags },
|
|
3254
|
+
on: { "click:tag": _vm.tagRemovalHandler },
|
|
572
3255
|
},
|
|
573
|
-
[
|
|
574
|
-
|
|
3256
|
+
[
|
|
3257
|
+
_c(
|
|
3258
|
+
"div",
|
|
3259
|
+
{ staticClass: "filters" },
|
|
3260
|
+
[
|
|
3261
|
+
_c("form-field-multi-select", {
|
|
3262
|
+
staticClass: "filter",
|
|
3263
|
+
attrs: {
|
|
3264
|
+
options: _vm.categoryOptionList,
|
|
3265
|
+
name: "categoryFilter",
|
|
3266
|
+
searchable: true,
|
|
3267
|
+
label: _vm.$t("blog:category"),
|
|
3268
|
+
},
|
|
3269
|
+
model: {
|
|
3270
|
+
value: _vm.categoryFilter,
|
|
3271
|
+
callback: function ($$v) {
|
|
3272
|
+
_vm.categoryFilter = $$v;
|
|
3273
|
+
},
|
|
3274
|
+
expression: "categoryFilter",
|
|
3275
|
+
},
|
|
3276
|
+
}),
|
|
3277
|
+
_vm._v(" "),
|
|
3278
|
+
_vm.isLangSpecific
|
|
3279
|
+
? _c("form-field-multi-select", {
|
|
3280
|
+
staticClass: "filter",
|
|
3281
|
+
attrs: {
|
|
3282
|
+
options: _vm.languageOptionList,
|
|
3283
|
+
name: "languageFilter",
|
|
3284
|
+
searchable: true,
|
|
3285
|
+
label: _vm.$t("blog:language"),
|
|
3286
|
+
},
|
|
3287
|
+
model: {
|
|
3288
|
+
value: _vm.languageFilter,
|
|
3289
|
+
callback: function ($$v) {
|
|
3290
|
+
_vm.languageFilter = $$v;
|
|
3291
|
+
},
|
|
3292
|
+
expression: "languageFilter",
|
|
3293
|
+
},
|
|
3294
|
+
})
|
|
3295
|
+
: _vm._e(),
|
|
3296
|
+
_vm._v(" "),
|
|
3297
|
+
_c("div", { staticClass: "filter" }, [
|
|
3298
|
+
_c("div", { staticClass: "date-label" }, [
|
|
3299
|
+
_vm._v(
|
|
3300
|
+
"\n " +
|
|
3301
|
+
_vm._s(_vm.$t("blog:dateOfPublication")) +
|
|
3302
|
+
"\n "
|
|
3303
|
+
),
|
|
3304
|
+
]),
|
|
3305
|
+
_vm._v(" "),
|
|
3306
|
+
_c(
|
|
3307
|
+
"div",
|
|
3308
|
+
{ staticClass: "date-content" },
|
|
3309
|
+
[
|
|
3310
|
+
_c("form-field", {
|
|
3311
|
+
attrs: {
|
|
3312
|
+
label: _vm.$t("blog:From"),
|
|
3313
|
+
name: "fromDateFilter",
|
|
3314
|
+
type: "date",
|
|
3315
|
+
max: _vm.toDateFilter,
|
|
3316
|
+
},
|
|
3317
|
+
model: {
|
|
3318
|
+
value: _vm.fromDateFilter,
|
|
3319
|
+
callback: function ($$v) {
|
|
3320
|
+
_vm.fromDateFilter = $$v;
|
|
3321
|
+
},
|
|
3322
|
+
expression: "fromDateFilter",
|
|
3323
|
+
},
|
|
3324
|
+
}),
|
|
3325
|
+
_vm._v(" "),
|
|
3326
|
+
_c("form-field", {
|
|
3327
|
+
attrs: {
|
|
3328
|
+
label: _vm.$t("blog:To"),
|
|
3329
|
+
name: "toDateFilter",
|
|
3330
|
+
type: "date",
|
|
3331
|
+
min: _vm.fromDateFilter,
|
|
3332
|
+
},
|
|
3333
|
+
model: {
|
|
3334
|
+
value: _vm.toDateFilter,
|
|
3335
|
+
callback: function ($$v) {
|
|
3336
|
+
_vm.toDateFilter = $$v;
|
|
3337
|
+
},
|
|
3338
|
+
expression: "toDateFilter",
|
|
3339
|
+
},
|
|
3340
|
+
}),
|
|
3341
|
+
],
|
|
3342
|
+
1
|
|
3343
|
+
),
|
|
3344
|
+
]),
|
|
3345
|
+
],
|
|
3346
|
+
1
|
|
3347
|
+
),
|
|
3348
|
+
]
|
|
575
3349
|
),
|
|
3350
|
+
]
|
|
3351
|
+
},
|
|
3352
|
+
proxy: true,
|
|
3353
|
+
},
|
|
3354
|
+
{
|
|
3355
|
+
key: "cell(actions)",
|
|
3356
|
+
fn: function (ref) {
|
|
3357
|
+
var row = ref.row;
|
|
3358
|
+
return [
|
|
3359
|
+
_vm.canViewAdministrators
|
|
3360
|
+
? _c(
|
|
3361
|
+
"base-button",
|
|
3362
|
+
{
|
|
3363
|
+
attrs: {
|
|
3364
|
+
variant: "icon",
|
|
3365
|
+
title: _vm.$t("blog:edit"),
|
|
3366
|
+
disabled: _vm.isBusy(row.id),
|
|
3367
|
+
href: _vm.getBlogPostFormUrl({
|
|
3368
|
+
postId: row.id,
|
|
3369
|
+
}),
|
|
3370
|
+
},
|
|
3371
|
+
},
|
|
3372
|
+
[_c("svg-icon", { attrs: { name: "edit" } })],
|
|
3373
|
+
1
|
|
3374
|
+
)
|
|
3375
|
+
: _vm._e(),
|
|
576
3376
|
_vm._v(" "),
|
|
577
3377
|
_c(
|
|
578
3378
|
"base-button",
|
|
579
3379
|
{
|
|
580
3380
|
attrs: {
|
|
581
3381
|
variant: "icon",
|
|
582
|
-
title: _vm.$t("blog:
|
|
583
|
-
disabled: _vm.
|
|
3382
|
+
title: _vm.$t("blog:clone"),
|
|
3383
|
+
disabled: _vm.isBusy(row.id),
|
|
584
3384
|
},
|
|
585
3385
|
on: {
|
|
586
3386
|
click: function ($event) {
|
|
587
|
-
return _vm.
|
|
3387
|
+
return _vm.handleResourceClone(row.id)
|
|
588
3388
|
},
|
|
589
3389
|
},
|
|
590
3390
|
},
|
|
591
|
-
[_c("svg-icon", { attrs: { name: "
|
|
3391
|
+
[_c("svg-icon", { attrs: { name: "contentCopy" } })],
|
|
592
3392
|
1
|
|
593
3393
|
),
|
|
3394
|
+
_vm._v(" "),
|
|
3395
|
+
_vm.canViewAdministrators
|
|
3396
|
+
? _c(
|
|
3397
|
+
"base-button",
|
|
3398
|
+
{
|
|
3399
|
+
attrs: {
|
|
3400
|
+
variant: "icon",
|
|
3401
|
+
title: _vm.$t("blog:remove"),
|
|
3402
|
+
disabled: _vm.isBusy(row.id),
|
|
3403
|
+
},
|
|
3404
|
+
on: {
|
|
3405
|
+
click: function ($event) {
|
|
3406
|
+
return _vm.handleResourceDelete(row.id)
|
|
3407
|
+
},
|
|
3408
|
+
},
|
|
3409
|
+
},
|
|
3410
|
+
[_c("svg-icon", { attrs: { name: "delete" } })],
|
|
3411
|
+
1
|
|
3412
|
+
)
|
|
3413
|
+
: _vm._e(),
|
|
594
3414
|
]
|
|
595
3415
|
},
|
|
596
3416
|
},
|
|
@@ -609,11 +3429,11 @@
|
|
|
609
3429
|
/* style */
|
|
610
3430
|
const __vue_inject_styles__ = function (inject) {
|
|
611
3431
|
if (!inject) return
|
|
612
|
-
inject("data-v-f119918c_0", { source: "\n\n/*# sourceMappingURL=BlogPostList.vue.map */", map: {"version":3,"sources":["BlogPostList.vue"],"names":[],"mappings":";;AAEA,2CAA2C","file":"BlogPostList.vue"}, media: undefined });
|
|
3432
|
+
inject("data-v-7a3e00a4_0", { source: ".filters[data-v-7a3e00a4] {\n display: flex;\n margin: 0 -10px;\n}\n.filters[data-v-7a3e00a4]:not(:first-child) {\n margin-top: 10px;\n}\n.filters .filter[data-v-7a3e00a4] {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n}\n.date-label[data-v-7a3e00a4] {\n margin-bottom: 0.5rem;\n}\n.date-content[data-v-7a3e00a4] {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n column-gap: 10px;\n}\n\n/*# sourceMappingURL=PostList.vue.map */", map: {"version":3,"sources":["/home/runner/work/tager-admin-blog/tager-admin-blog/src/views/Posts/PostList/PostList.vue","PostList.vue"],"names":[],"mappings":"AAgVA;EACA,aAAA;EACA,eAAA;AC/UA;ADiVA;EACA,gBAAA;AC/UA;ADkVA;EACA,oBAAA;EACA,UAAA;EACA,SAAA;AChVA;ADoVA;EACA,qBAAA;ACjVA;ADoVA;EACA,aAAA;EACA,qCAAA;EACA,gBAAA;ACjVA;;AAEA,uCAAuC","file":"PostList.vue","sourcesContent":["<template>\n <page\n :title=\"pageTitle\"\n :header-buttons=\"\n [\n canViewAdministrators\n ? {\n text: $t('blog:newPost'),\n href: getBlogPostFormUrl({ postId: 'create' }),\n }\n : null,\n ].filter(Boolean)\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 :search-query=\"searchQuery\"\n :pagination=\"{\n pageNumber,\n pageCount,\n pageSize,\n disabled: isRowDataLoading,\n }\"\n data-table=\"blog-post\"\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=\"categoryFilter\"\n :options=\"categoryOptionList\"\n name=\"categoryFilter\"\n :searchable=\"true\"\n :label=\"$t('blog:category')\"\n class=\"filter\"\n />\n\n <form-field-multi-select\n v-if=\"isLangSpecific\"\n v-model=\"languageFilter\"\n :options=\"languageOptionList\"\n name=\"languageFilter\"\n :searchable=\"true\"\n :label=\"$t('blog:language')\"\n class=\"filter\"\n />\n\n <div class=\"filter\">\n <div class=\"date-label\">\n {{ $t('blog:dateOfPublication') }}\n </div>\n\n <div class=\"date-content\">\n <form-field\n v-model=\"fromDateFilter\"\n :label=\"$t('blog:From')\"\n name=\"fromDateFilter\"\n type=\"date\"\n :max=\"toDateFilter\"\n />\n\n <form-field\n v-model=\"toDateFilter\"\n :label=\"$t('blog:To')\"\n name=\"toDateFilter\"\n type=\"date\"\n :min=\"fromDateFilter\"\n />\n </div>\n </div>\n </div>\n </advanced-search>\n </template>\n\n <template v-slot:cell(actions)=\"{ row }\">\n <base-button\n v-if=\"canViewAdministrators\"\n variant=\"icon\"\n :title=\"$t('blog:edit')\"\n :disabled=\"isBusy(row.id)\"\n :href=\"getBlogPostFormUrl({ postId: row.id })\"\n >\n <svg-icon name=\"edit\" />\n </base-button>\n\n <base-button\n variant=\"icon\"\n :title=\"$t('blog:clone')\"\n :disabled=\"isBusy(row.id)\"\n @click=\"handleResourceClone(row.id)\"\n >\n <svg-icon name=\"contentCopy\" />\n </base-button>\n\n <base-button\n v-if=\"canViewAdministrators\"\n variant=\"icon\"\n :title=\"$t('blog: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 { computed, defineComponent, watch } 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 {\n Nullable,\n useResourceClone,\n useResourceDelete,\n} from '@tager/admin-services';\n\nimport { Category, Language, PostFull, PostShort } from '@/typings/model';\nimport {\n clonePost,\n deleteBlogPost,\n getBlogPostList,\n} from '@/services/requests';\nimport { getBlogPostFormUrl } from '@/constants/paths';\nimport {\n useModuleConfig,\n useBlogCategoryList,\n useUserPermission,\n} from '@/hooks';\nimport { Scope } from '@/constants/scopes';\n\nimport { convertPostList, getPostTableColumnDefs } from './PostList.helpers';\nimport { useAdvancedSearch } from './hooks';\n\nexport default defineComponent({\n name: 'BlogPostList',\n setup(props, context) {\n const { t } = useTranslation(context);\n\n const canViewAdministrators = useUserPermission(\n context,\n Scope.AdministratorsView\n );\n\n const categoryId = computed<string>(() => {\n return Array.isArray(context.root.$route.query.category)\n ? context.root.$route.query.category[0] ?? ''\n : context.root.$route.query.category;\n });\n\n /** Fetch module config */\n const {\n data: moduleConfig,\n loading: isModuleConfigLoading,\n } = useModuleConfig({ context });\n\n const languageList = computed<Language[]>(\n () => moduleConfig.value?.languages ?? []\n );\n\n /** Fetch category list */\n const {\n data: categoryList,\n loading: isCategoryListLoading,\n } = useBlogCategoryList({ context });\n\n const selectedCategory = computed<Nullable<Category>>(() =>\n categoryId.value\n ? categoryList.value.find(\n ({ id }) => String(id) === String(categoryId.value)\n ) ?? null\n : null\n );\n\n const pageTitle = computed<string>(() => {\n return selectedCategory.value\n ? `${context.root.$t('blog:postsByCategory')} \"${\n selectedCategory.value.name\n }\"`\n : context.root.$t('blog:posts');\n });\n\n /** Advanced search **/\n\n const {\n categoryFilter,\n categoryOptionList,\n languageFilter,\n languageOptionList,\n fromDateFilter,\n toDateFilter,\n filterParams,\n tags,\n tagRemovalHandler,\n } = useAdvancedSearch({\n context,\n categoryList,\n languageList,\n });\n\n const isLangSpecific = computed<boolean>(\n () => languageOptionList.value.length > 1\n );\n\n /** Fetch Post list */\n const {\n fetchEntityList: fetchPostList,\n isLoading: isPostLoading,\n rowData: postList,\n errorMessage,\n searchQuery,\n handleChange,\n pageNumber,\n pageCount,\n pageSize,\n } = useDataTable<PostShort>({\n fetchEntityList: (params) =>\n getBlogPostList({\n query: params.searchQuery,\n pageNumber: params.pageNumber,\n pageSize: params.pageSize,\n ...filterParams.value,\n }),\n initialValue: [],\n context,\n resourceName: 'Blog post list',\n pageSize: 100,\n });\n\n watch(filterParams, () => {\n if (isModuleConfigLoading.value || isCategoryListLoading.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 fetchPostList();\n }\n });\n\n const displayedPostList = computed<PostShort[]>(() =>\n convertPostList(\n postList.value,\n selectedCategory.value,\n moduleConfig.value?.languages ?? []\n )\n );\n\n const isRowDataLoading = computed<boolean>(\n () =>\n isCategoryListLoading.value ||\n isPostLoading.value ||\n isModuleConfigLoading.value\n );\n\n const { isDeleting, handleResourceDelete } = useResourceDelete({\n deleteResource: deleteBlogPost,\n resourceName: 'Post',\n onSuccess: fetchPostList,\n context,\n });\n\n const { isCloning, handleResourceClone } = useResourceClone({\n cloneResource: clonePost,\n confirmMessage: t('blog:cloneConfirm'),\n successMessage: t('blog:cloneSuccess'),\n failureMessage: t('blog:cloneFailure'),\n onSuccessRedirectTo: (data: PostFull) => `/posts/${data.id}`,\n context,\n });\n\n function isBusy(postId: number): boolean {\n return isDeleting(postId) || isCloning(postId) || isRowDataLoading.value;\n }\n\n const columnDefs = computed<ColumnDefinition<PostShort>[]>(() =>\n getPostTableColumnDefs(moduleConfig.value, context.root.$t)\n );\n\n return {\n columnDefs,\n rowData: displayedPostList,\n handleResourceDelete,\n isDeleting,\n categoryList,\n isRowDataLoading,\n errorMessage,\n getBlogPostFormUrl,\n pageTitle,\n searchQuery,\n handleChange,\n pageNumber,\n pageCount,\n pageSize,\n\n // Advanced search\n categoryFilter,\n categoryOptionList,\n isLangSpecific,\n languageFilter,\n languageOptionList,\n fromDateFilter,\n toDateFilter,\n tags,\n tagRemovalHandler,\n\n // Permissions\n canViewAdministrators,\n\n // Clone\n handleResourceClone,\n isBusy,\n };\n },\n});\n</script>\n\n<style scoped 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\n.date-label {\n margin-bottom: 0.5rem;\n}\n\n.date-content {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n column-gap: 10px;\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.date-label {\n margin-bottom: 0.5rem;\n}\n\n.date-content {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n column-gap: 10px;\n}\n\n/*# sourceMappingURL=PostList.vue.map */"]}, media: undefined });
|
|
613
3433
|
|
|
614
3434
|
};
|
|
615
3435
|
/* scoped */
|
|
616
|
-
const __vue_scope_id__ = "data-v-
|
|
3436
|
+
const __vue_scope_id__ = "data-v-7a3e00a4";
|
|
617
3437
|
/* module identifier */
|
|
618
3438
|
const __vue_module_identifier__ = undefined;
|
|
619
3439
|
/* functional template */
|
|
@@ -637,21 +3457,7 @@
|
|
|
637
3457
|
undefined
|
|
638
3458
|
);
|
|
639
3459
|
|
|
640
|
-
function useBlogPostList(params) {
|
|
641
|
-
const [fetchBlogPostList, resource] = adminServices.useResource({
|
|
642
|
-
fetchResource: () => getBlogPostList({ pageNumber: 1, pageSize: 99999 }),
|
|
643
|
-
initialValue: [],
|
|
644
|
-
context: params.context,
|
|
645
|
-
resourceName: 'Blog post list',
|
|
646
|
-
});
|
|
647
|
-
compositionApi.onMounted(() => {
|
|
648
|
-
fetchBlogPostList();
|
|
649
|
-
});
|
|
650
|
-
return resource;
|
|
651
|
-
}
|
|
652
|
-
|
|
653
3460
|
function convertPostToFormValues(post, languageOptionList, postOptionList, additionalFieldList) {
|
|
654
|
-
var _a, _b;
|
|
655
3461
|
if (!post) {
|
|
656
3462
|
return {
|
|
657
3463
|
title: '',
|
|
@@ -679,11 +3485,15 @@
|
|
|
679
3485
|
excerpt: post.excerpt,
|
|
680
3486
|
body: post.body,
|
|
681
3487
|
date: post.date,
|
|
682
|
-
coverImage: post.coverImage
|
|
3488
|
+
coverImage: post.coverImage
|
|
3489
|
+
? { id: adminServices.createId(), file: post.coverImage }
|
|
3490
|
+
: null,
|
|
683
3491
|
image: post.image ? { id: adminServices.createId(), file: post.image } : null,
|
|
684
|
-
imageMobile: post.imageMobile
|
|
685
|
-
|
|
686
|
-
|
|
3492
|
+
imageMobile: post.imageMobile
|
|
3493
|
+
? { id: adminServices.createId(), file: post.imageMobile }
|
|
3494
|
+
: null,
|
|
3495
|
+
pageTitle: post.pageTitle ?? '',
|
|
3496
|
+
pageDescription: post.pageDescription ?? '',
|
|
687
3497
|
openGraphImage: post.openGraphImage
|
|
688
3498
|
? { id: adminServices.createId(), file: post.openGraphImage }
|
|
689
3499
|
: null,
|
|
@@ -692,32 +3502,31 @@
|
|
|
692
3502
|
value: category.id,
|
|
693
3503
|
label: category.name,
|
|
694
3504
|
})),
|
|
695
|
-
language: currentLangOption
|
|
3505
|
+
language: currentLangOption ?? null,
|
|
696
3506
|
relatedPosts: selectedPostOptionList,
|
|
697
3507
|
tags: post.tags.join(','),
|
|
698
3508
|
additionalFields: additionalFieldList.map((fieldConfig, index) => {
|
|
699
|
-
const postAdditionalField = post.additionalFields.find(item => item.name === fieldConfig.name);
|
|
700
|
-
return adminDynamicField.universalFieldUtils.createFormField(fieldConfig, postAdditionalField
|
|
3509
|
+
const postAdditionalField = post.additionalFields.find((item) => item.name === fieldConfig.name);
|
|
3510
|
+
return adminDynamicField.universalFieldUtils.createFormField(fieldConfig, postAdditionalField?.value);
|
|
701
3511
|
}),
|
|
702
3512
|
};
|
|
703
3513
|
}
|
|
704
3514
|
function convertFormValuesToCreationPayload(values) {
|
|
705
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
706
3515
|
return {
|
|
707
3516
|
title: values.title,
|
|
708
3517
|
excerpt: values.excerpt,
|
|
709
3518
|
urlAlias: values.urlAlias,
|
|
710
3519
|
body: values.body,
|
|
711
3520
|
date: values.date,
|
|
712
|
-
coverImage:
|
|
713
|
-
image:
|
|
714
|
-
imageMobile:
|
|
3521
|
+
coverImage: values.coverImage?.file.id ?? null,
|
|
3522
|
+
image: values.image?.file.id ?? null,
|
|
3523
|
+
imageMobile: values.imageMobile?.file.id ?? null,
|
|
715
3524
|
pageTitle: values.pageTitle,
|
|
716
3525
|
pageDescription: values.pageDescription,
|
|
717
|
-
openGraphImage:
|
|
3526
|
+
openGraphImage: values.openGraphImage?.file.id ?? null,
|
|
718
3527
|
status: 'PUBLISHED',
|
|
719
3528
|
categories: values.categories.map((option) => option.value),
|
|
720
|
-
language:
|
|
3529
|
+
language: values.language?.value ?? null,
|
|
721
3530
|
relatedPosts: values.relatedPosts.map((relatedPostOption) => relatedPostOption.value),
|
|
722
3531
|
tags: values.tags.split(',').filter((tag) => tag.trim().length > 0),
|
|
723
3532
|
additionalFields: values.additionalFields.map((field) => ({
|
|
@@ -727,31 +3536,31 @@
|
|
|
727
3536
|
};
|
|
728
3537
|
}
|
|
729
3538
|
function convertFormValuesToUpdatePayload(values) {
|
|
730
|
-
return
|
|
3539
|
+
return {
|
|
3540
|
+
...convertFormValuesToCreationPayload(values),
|
|
3541
|
+
urlAlias: values.urlAlias,
|
|
3542
|
+
};
|
|
731
3543
|
}
|
|
732
3544
|
function convertCategoryListToOptions(categoryList, languageId) {
|
|
733
3545
|
return categoryList
|
|
734
|
-
.filter((
|
|
735
|
-
.map((
|
|
736
|
-
value: category.id,
|
|
737
|
-
label: category.name,
|
|
738
|
-
}));
|
|
3546
|
+
.filter(({ language }) => (languageId ? language === languageId : true))
|
|
3547
|
+
.map(({ id, name }) => ({ value: id, label: name }));
|
|
739
3548
|
}
|
|
740
3549
|
|
|
741
3550
|
var script$1 = compositionApi.defineComponent({
|
|
742
3551
|
name: 'BlogPostForm',
|
|
743
3552
|
components: { DynamicField: adminDynamicField.DynamicField, ShortCodeConstructor: adminUi.ShortCodeConstructor, FormFooter: adminUi.FormFooter },
|
|
744
3553
|
setup(props, context) {
|
|
745
|
-
var _a, _b;
|
|
746
3554
|
const postId = compositionApi.computed(() => context.root.$route.params.postId);
|
|
747
3555
|
const isCreation = compositionApi.computed(() => postId.value === 'create');
|
|
748
3556
|
const urlAliasChanged = compositionApi.ref(false);
|
|
749
3557
|
/** Fetch module config */
|
|
750
3558
|
const { data: moduleConfig, loading: isModuleConfigLoading, } = useModuleConfig({ context });
|
|
751
|
-
const
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
3559
|
+
const languageList = compositionApi.computed(() => moduleConfig.value?.languages ?? []);
|
|
3560
|
+
const languageOptionList = compositionApi.computed(() => languageList.value.map(({ id, name }) => ({
|
|
3561
|
+
value: id,
|
|
3562
|
+
label: name,
|
|
3563
|
+
})));
|
|
755
3564
|
const isLangSpecific = compositionApi.computed(() => languageOptionList.value.length > 0);
|
|
756
3565
|
/** Fetch category list */
|
|
757
3566
|
const { data: categoryList, loading: isCategoryListLoading, } = useBlogCategoryList({ context });
|
|
@@ -777,18 +3586,17 @@
|
|
|
777
3586
|
context,
|
|
778
3587
|
});
|
|
779
3588
|
const postOptionList = compositionApi.computed(() => postList.value
|
|
780
|
-
.filter((relatedPost) =>
|
|
3589
|
+
.filter((relatedPost) => relatedPost.id !== post.value?.id)
|
|
781
3590
|
.map((post) => ({
|
|
782
3591
|
value: post.id,
|
|
783
3592
|
label: post.title,
|
|
784
3593
|
})));
|
|
785
3594
|
/** Form State */
|
|
786
|
-
const values = compositionApi.ref(convertPostToFormValues(post.value, languageOptionList.value, postOptionList.value,
|
|
3595
|
+
const values = compositionApi.ref(convertPostToFormValues(post.value, languageOptionList.value, postOptionList.value, moduleConfig.value?.fields ?? []));
|
|
787
3596
|
const errors = compositionApi.ref({});
|
|
788
3597
|
const isSubmitting = compositionApi.ref(false);
|
|
789
3598
|
compositionApi.watch([post, languageOptionList, postOptionList, moduleConfig], () => {
|
|
790
|
-
|
|
791
|
-
values.value = convertPostToFormValues(post.value, languageOptionList.value, postOptionList.value, (_b = (_a = moduleConfig.value) === null || _a === void 0 ? void 0 : _a.fields) !== null && _b !== void 0 ? _b : []);
|
|
3599
|
+
values.value = convertPostToFormValues(post.value, languageOptionList.value, postOptionList.value, moduleConfig.value?.fields ?? []);
|
|
792
3600
|
});
|
|
793
3601
|
function submitForm(event) {
|
|
794
3602
|
isSubmitting.value = true;
|
|
@@ -799,7 +3607,6 @@
|
|
|
799
3607
|
: updateBlogPost(postId.value, updateBody);
|
|
800
3608
|
requestPromise
|
|
801
3609
|
.then(({ data }) => {
|
|
802
|
-
var _a, _b;
|
|
803
3610
|
errors.value = {};
|
|
804
3611
|
if (event.type === 'create') {
|
|
805
3612
|
context.root.$router.push(getBlogPostFormUrl({ postId: String(data.id) }));
|
|
@@ -813,7 +3620,7 @@
|
|
|
813
3620
|
}
|
|
814
3621
|
}
|
|
815
3622
|
if (event.type === 'create_create-another') {
|
|
816
|
-
values.value = convertPostToFormValues(null, languageOptionList.value, postOptionList.value,
|
|
3623
|
+
values.value = convertPostToFormValues(null, languageOptionList.value, postOptionList.value, moduleConfig.value?.fields ?? []);
|
|
817
3624
|
}
|
|
818
3625
|
context.root.$toast({
|
|
819
3626
|
variant: 'success',
|
|
@@ -839,17 +3646,13 @@
|
|
|
839
3646
|
});
|
|
840
3647
|
}
|
|
841
3648
|
/** Category Options */
|
|
842
|
-
const categoryOptionList = compositionApi.computed(() =>
|
|
843
|
-
var _a, _b;
|
|
844
|
-
return convertCategoryListToOptions(categoryList.value, (_b = (_a = values.value.language) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : null);
|
|
845
|
-
});
|
|
3649
|
+
const categoryOptionList = compositionApi.computed(() => convertCategoryListToOptions(categoryList.value, values.value.language?.value ?? null));
|
|
846
3650
|
compositionApi.watch([categoryOptionList, moduleConfig], () => {
|
|
847
|
-
var _a;
|
|
848
3651
|
function isOptionExist(selectedCategoryOption) {
|
|
849
3652
|
return categoryOptionList.value.some((option) => option.value === selectedCategoryOption.value);
|
|
850
3653
|
}
|
|
851
3654
|
if (isCreation.value) {
|
|
852
|
-
if (
|
|
3655
|
+
if (moduleConfig?.value?.defaultCategories) {
|
|
853
3656
|
const defaultIds = moduleConfig.value.defaultCategories.map((item) => item.id);
|
|
854
3657
|
values.value.categories = categoryOptionList.value.filter((item) => {
|
|
855
3658
|
return defaultIds.indexOf(item.value) !== -1;
|
|
@@ -864,13 +3667,11 @@
|
|
|
864
3667
|
isPostListLoading.value ||
|
|
865
3668
|
isModuleConfigLoading.value);
|
|
866
3669
|
function getUploadAdapterOptions() {
|
|
867
|
-
|
|
868
|
-
return { uploadScenario: (_a = moduleConfig.value) === null || _a === void 0 ? void 0 : _a.fileScenarios.content };
|
|
3670
|
+
return { uploadScenario: moduleConfig.value?.fileScenarios.content };
|
|
869
3671
|
}
|
|
870
3672
|
const blogPagePath = compositionApi.computed(() => {
|
|
871
|
-
var _a, _b;
|
|
872
3673
|
const origin = process.env.VUE_APP_WEBSITE_URL || window.location.origin;
|
|
873
|
-
return origin + (
|
|
3674
|
+
return origin + (post.value?.urlTemplate ?? '');
|
|
874
3675
|
});
|
|
875
3676
|
const tabList = compositionApi.computed(() => {
|
|
876
3677
|
const hasErrors = adminUi.createTabErrorFinder(errors.value);
|
|
@@ -973,7 +3774,7 @@
|
|
|
973
3774
|
handleSeoFieldGroupChange,
|
|
974
3775
|
handleTitleChange,
|
|
975
3776
|
handleAliasChange,
|
|
976
|
-
urlAliasTemplate
|
|
3777
|
+
urlAliasTemplate,
|
|
977
3778
|
};
|
|
978
3779
|
},
|
|
979
3780
|
});
|
|
@@ -1313,17 +4114,15 @@
|
|
|
1313
4114
|
__vue_render__$1._withStripped = true;
|
|
1314
4115
|
|
|
1315
4116
|
/* style */
|
|
1316
|
-
const __vue_inject_styles__$1 =
|
|
1317
|
-
if (!inject) return
|
|
1318
|
-
inject("data-v-6c25151d_0", { source: "\n\n/*# sourceMappingURL=BlogPostForm.vue.map */", map: {"version":3,"sources":["BlogPostForm.vue"],"names":[],"mappings":";;AAEA,2CAA2C","file":"BlogPostForm.vue"}, media: undefined });
|
|
1319
|
-
|
|
1320
|
-
};
|
|
4117
|
+
const __vue_inject_styles__$1 = undefined;
|
|
1321
4118
|
/* scoped */
|
|
1322
|
-
const __vue_scope_id__$1 =
|
|
4119
|
+
const __vue_scope_id__$1 = undefined;
|
|
1323
4120
|
/* module identifier */
|
|
1324
4121
|
const __vue_module_identifier__$1 = undefined;
|
|
1325
4122
|
/* functional template */
|
|
1326
4123
|
const __vue_is_functional_template__$1 = false;
|
|
4124
|
+
/* style inject */
|
|
4125
|
+
|
|
1327
4126
|
/* style inject SSR */
|
|
1328
4127
|
|
|
1329
4128
|
/* style inject shadow dom */
|
|
@@ -1338,7 +4137,7 @@
|
|
|
1338
4137
|
__vue_is_functional_template__$1,
|
|
1339
4138
|
__vue_module_identifier__$1,
|
|
1340
4139
|
false,
|
|
1341
|
-
|
|
4140
|
+
undefined,
|
|
1342
4141
|
undefined,
|
|
1343
4142
|
undefined
|
|
1344
4143
|
);
|
|
@@ -1346,8 +4145,11 @@
|
|
|
1346
4145
|
function convertCategoryList(categoryList, languages) {
|
|
1347
4146
|
return categoryList.map((category) => {
|
|
1348
4147
|
if (languages.length > 0) {
|
|
1349
|
-
const foundLanguage = languages.find((
|
|
1350
|
-
return
|
|
4148
|
+
const foundLanguage = languages.find(({ id }) => category.language === id);
|
|
4149
|
+
return {
|
|
4150
|
+
...category,
|
|
4151
|
+
language: foundLanguage ? foundLanguage.name : category.language,
|
|
4152
|
+
};
|
|
1351
4153
|
}
|
|
1352
4154
|
return category;
|
|
1353
4155
|
});
|
|
@@ -1358,40 +4160,44 @@
|
|
|
1358
4160
|
: false;
|
|
1359
4161
|
const COLUMN_DEFS = [
|
|
1360
4162
|
{
|
|
1361
|
-
id:
|
|
4163
|
+
id: 1,
|
|
1362
4164
|
name: t('blog:name'),
|
|
1363
4165
|
field: 'name',
|
|
1364
4166
|
type: 'name',
|
|
1365
|
-
format: ({ row }) => {
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
}
|
|
4167
|
+
format: ({ row }) => ({
|
|
4168
|
+
adminLink: {
|
|
4169
|
+
url: getBlogCategoryFormUrl({ categoryId: row.id }),
|
|
4170
|
+
text: getNameWithDepth(row.name, row.depth),
|
|
4171
|
+
},
|
|
4172
|
+
paramList: row.isDefault
|
|
4173
|
+
? [{ name: t('blog:defaultCategory'), value: t('blog:yes') }]
|
|
4174
|
+
: [],
|
|
4175
|
+
}),
|
|
4176
|
+
},
|
|
4177
|
+
{
|
|
4178
|
+
id: 2,
|
|
4179
|
+
name: t('pages:path'),
|
|
4180
|
+
field: 'path',
|
|
4181
|
+
type: 'link',
|
|
4182
|
+
format: ({ row }) => ({
|
|
4183
|
+
url: `${adminServices.getWebsiteOrigin()}${row.url}`,
|
|
4184
|
+
text: row.url,
|
|
4185
|
+
}),
|
|
4186
|
+
options: {
|
|
4187
|
+
shouldOpenNewTab: true,
|
|
1382
4188
|
},
|
|
1383
4189
|
},
|
|
1384
4190
|
isLangSpecific
|
|
1385
|
-
? { id:
|
|
4191
|
+
? { id: 3, name: t('blog:language'), field: 'language' }
|
|
1386
4192
|
: null,
|
|
1387
4193
|
{
|
|
1388
|
-
id:
|
|
4194
|
+
id: 4,
|
|
1389
4195
|
name: t('blog:posts'),
|
|
1390
4196
|
field: 'linkToPosts',
|
|
1391
4197
|
style: { whiteSpace: 'nowrap', width: '130px' },
|
|
1392
4198
|
},
|
|
1393
4199
|
{
|
|
1394
|
-
id:
|
|
4200
|
+
id: 5,
|
|
1395
4201
|
name: t('blog:actions'),
|
|
1396
4202
|
field: 'actions',
|
|
1397
4203
|
style: { whiteSpace: 'nowrap', width: '205px' },
|
|
@@ -1400,32 +4206,94 @@
|
|
|
1400
4206
|
},
|
|
1401
4207
|
];
|
|
1402
4208
|
return COLUMN_DEFS.filter(adminServices.notEmpty);
|
|
4209
|
+
}
|
|
4210
|
+
function getLinkToPostsByCategory(categoryId) {
|
|
4211
|
+
return `${getBlogPostListUrl()}?filter[category]=${categoryId}`;
|
|
4212
|
+
}
|
|
4213
|
+
|
|
4214
|
+
var FilterTypes$1;
|
|
4215
|
+
(function (FilterTypes) {
|
|
4216
|
+
FilterTypes["LANGUAGE"] = "language";
|
|
4217
|
+
})(FilterTypes$1 || (FilterTypes$1 = {}));
|
|
4218
|
+
function useAdvancedSearch$1({ context, languageList }) {
|
|
4219
|
+
/** Language **/
|
|
4220
|
+
const languageOptionList = compositionApi.computed(() => languageList.value.map(({ id, name }) => ({ value: id, label: name })));
|
|
4221
|
+
const initialLanguageFilter = compositionApi.computed(() => {
|
|
4222
|
+
const queryValue = adminUi.getFilterParamAsStringArray(context.root.$route.query, FilterTypes$1.LANGUAGE);
|
|
4223
|
+
return languageOptionList.value.filter(({ value }) => queryValue.some((selected) => selected === value));
|
|
4224
|
+
});
|
|
4225
|
+
const languageFilter = compositionApi.ref(initialLanguageFilter.value);
|
|
4226
|
+
compositionApi.watch(initialLanguageFilter, () => {
|
|
4227
|
+
languageFilter.value = initialLanguageFilter.value;
|
|
4228
|
+
});
|
|
4229
|
+
/** Params **/
|
|
4230
|
+
const filterParams = compositionApi.computed(() => adminUi.getFilterParams({
|
|
4231
|
+
[FilterTypes$1.LANGUAGE]: languageFilter.value.map(({ value }) => value),
|
|
4232
|
+
}));
|
|
4233
|
+
/** Tag removal handler **/
|
|
4234
|
+
function tagRemovalHandler(event) {
|
|
4235
|
+
if (event.name === FilterTypes$1.LANGUAGE) {
|
|
4236
|
+
languageFilter.value = languageFilter.value.filter(({ value }) => value !== event.value);
|
|
4237
|
+
}
|
|
4238
|
+
}
|
|
4239
|
+
/** Tags **/
|
|
4240
|
+
const tags = compositionApi.computed(() => [
|
|
4241
|
+
...languageFilter.value.map(({ value, label }) => ({
|
|
4242
|
+
value,
|
|
4243
|
+
label,
|
|
4244
|
+
name: FilterTypes$1.LANGUAGE,
|
|
4245
|
+
title: context.root.$t('blog:language'),
|
|
4246
|
+
})),
|
|
4247
|
+
]);
|
|
4248
|
+
return {
|
|
4249
|
+
languageFilter,
|
|
4250
|
+
languageOptionList,
|
|
4251
|
+
tagRemovalHandler,
|
|
4252
|
+
tags: tags,
|
|
4253
|
+
filterParams,
|
|
4254
|
+
};
|
|
1403
4255
|
}
|
|
1404
4256
|
|
|
1405
|
-
var script$2 =
|
|
4257
|
+
var script$2 = compositionApi.defineComponent({
|
|
1406
4258
|
name: 'BlogCategoryList',
|
|
1407
4259
|
setup(props, context) {
|
|
4260
|
+
const canViewAdministrators = useUserPermission(context, Scope.AdministratorsView);
|
|
1408
4261
|
/** Fetch module config */
|
|
1409
4262
|
const { data: moduleConfig, loading: isModuleConfigLoading, } = useModuleConfig({ context });
|
|
1410
|
-
const
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
const isLangSpecific = compositionApi.computed(() => languageOptionList.value.length > 0);
|
|
4263
|
+
const languageList = compositionApi.computed(() => moduleConfig.value?.languages ?? []);
|
|
4264
|
+
/** Advanced search **/
|
|
4265
|
+
const { languageFilter, languageOptionList, filterParams, tags, tagRemovalHandler, } = useAdvancedSearch$1({ context, languageList });
|
|
4266
|
+
const isLangSpecific = compositionApi.computed(() => languageOptionList.value.length > 1);
|
|
1415
4267
|
/** Fetch category list */
|
|
1416
|
-
const
|
|
1417
|
-
|
|
4268
|
+
const { fetchEntityList: fetchCategoryList, isLoading: isCategoryListLoading, rowData: categoryList, errorMessage, searchQuery, handleChange, pageNumber, pageCount, pageSize, } = adminUi.useDataTable({
|
|
4269
|
+
fetchEntityList: (params) => getBlogCategoryList({
|
|
4270
|
+
query: params.searchQuery,
|
|
4271
|
+
pageNumber: params.pageNumber,
|
|
4272
|
+
pageSize: params.pageSize,
|
|
4273
|
+
...filterParams.value,
|
|
4274
|
+
}),
|
|
1418
4275
|
initialValue: [],
|
|
1419
4276
|
context,
|
|
1420
4277
|
resourceName: 'Blog category list',
|
|
4278
|
+
pageSize: 100,
|
|
1421
4279
|
});
|
|
1422
|
-
compositionApi.
|
|
1423
|
-
|
|
4280
|
+
compositionApi.watch(filterParams, () => {
|
|
4281
|
+
if (isModuleConfigLoading.value || isCategoryListLoading.value) {
|
|
4282
|
+
return;
|
|
4283
|
+
}
|
|
4284
|
+
const newQuery = {
|
|
4285
|
+
...filterParams.value,
|
|
4286
|
+
query: (context.root.$route.query.query ?? ''),
|
|
4287
|
+
};
|
|
4288
|
+
if (!lodash_isequal(context.root.$route.query, newQuery)) {
|
|
4289
|
+
context.root.$router.replace({ query: newQuery });
|
|
4290
|
+
fetchCategoryList();
|
|
4291
|
+
}
|
|
1424
4292
|
});
|
|
1425
|
-
const { handleResourceDelete: handleCategoryDelete,
|
|
4293
|
+
const { isDeleting, handleResourceDelete: handleCategoryDelete, } = adminServices.useResourceDelete({
|
|
1426
4294
|
deleteResource: deleteBlogCategory,
|
|
1427
4295
|
resourceName: 'Post',
|
|
1428
|
-
onSuccess:
|
|
4296
|
+
onSuccess: fetchCategoryList,
|
|
1429
4297
|
context,
|
|
1430
4298
|
});
|
|
1431
4299
|
const isCategoryMoving = compositionApi.ref(false);
|
|
@@ -1434,7 +4302,7 @@
|
|
|
1434
4302
|
moveBlogCategory(categoryId, direction)
|
|
1435
4303
|
.then((response) => {
|
|
1436
4304
|
if (response.success) {
|
|
1437
|
-
return
|
|
4305
|
+
return fetchCategoryList();
|
|
1438
4306
|
}
|
|
1439
4307
|
})
|
|
1440
4308
|
.catch(console.error)
|
|
@@ -1444,27 +4312,31 @@
|
|
|
1444
4312
|
}
|
|
1445
4313
|
/** Misc */
|
|
1446
4314
|
const isRowDataLoading = compositionApi.computed(() => isCategoryListLoading.value || isModuleConfigLoading.value);
|
|
1447
|
-
|
|
1448
|
-
return `${getBlogPostListUrl()}?category=${categoryId}`;
|
|
1449
|
-
}
|
|
1450
|
-
const displayedCategoryList = compositionApi.computed(() => {
|
|
1451
|
-
var _a, _b;
|
|
1452
|
-
return convertCategoryList(categoryList.value, (_b = (_a = moduleConfig.value) === null || _a === void 0 ? void 0 : _a.languages) !== null && _b !== void 0 ? _b : []);
|
|
1453
|
-
});
|
|
4315
|
+
const displayedCategoryList = compositionApi.computed(() => convertCategoryList(categoryList.value, languageList.value));
|
|
1454
4316
|
const columnDefs = compositionApi.computed(() => getCategoryTableColumnDefs(moduleConfig.value, context.root.$t));
|
|
1455
4317
|
return {
|
|
1456
4318
|
columnDefs,
|
|
1457
4319
|
rowData: displayedCategoryList,
|
|
1458
4320
|
isRowDataLoading,
|
|
1459
|
-
errorMessage
|
|
4321
|
+
errorMessage,
|
|
1460
4322
|
isLangSpecific,
|
|
1461
|
-
languageOptionList,
|
|
1462
4323
|
handleCategoryDelete,
|
|
1463
4324
|
isDeleting,
|
|
1464
4325
|
getBlogCategoryFormUrl,
|
|
1465
4326
|
getLinkToPostsByCategory,
|
|
1466
4327
|
moveCategory,
|
|
1467
4328
|
isCategoryMoving,
|
|
4329
|
+
searchQuery,
|
|
4330
|
+
handleChange,
|
|
4331
|
+
pageNumber,
|
|
4332
|
+
pageCount,
|
|
4333
|
+
pageSize,
|
|
4334
|
+
languageFilter,
|
|
4335
|
+
languageOptionList,
|
|
4336
|
+
tags,
|
|
4337
|
+
tagRemovalHandler,
|
|
4338
|
+
// Permissions
|
|
4339
|
+
canViewAdministrators,
|
|
1468
4340
|
};
|
|
1469
4341
|
},
|
|
1470
4342
|
});
|
|
@@ -1481,133 +4353,194 @@
|
|
|
1481
4353
|
attrs: {
|
|
1482
4354
|
title: _vm.$t("blog:blogCategories"),
|
|
1483
4355
|
"header-buttons": [
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
4356
|
+
_vm.canViewAdministrators
|
|
4357
|
+
? {
|
|
4358
|
+
text: _vm.$t("blog:newCategory"),
|
|
4359
|
+
href: _vm.getBlogCategoryFormUrl({ categoryId: "create" }),
|
|
4360
|
+
}
|
|
4361
|
+
: null,
|
|
4362
|
+
].filter(Boolean),
|
|
1489
4363
|
},
|
|
1490
4364
|
scopedSlots: _vm._u([
|
|
1491
4365
|
{
|
|
1492
4366
|
key: "content",
|
|
1493
4367
|
fn: function () {
|
|
1494
4368
|
return [
|
|
1495
|
-
_c("
|
|
4369
|
+
_c("data-table", {
|
|
1496
4370
|
attrs: {
|
|
1497
4371
|
"column-defs": _vm.columnDefs,
|
|
1498
4372
|
"row-data": _vm.rowData,
|
|
1499
4373
|
loading: _vm.isRowDataLoading,
|
|
1500
4374
|
"error-message": _vm.errorMessage,
|
|
4375
|
+
"search-query": _vm.searchQuery,
|
|
4376
|
+
pagination: {
|
|
4377
|
+
pageNumber: _vm.pageNumber,
|
|
4378
|
+
pageCount: _vm.pageCount,
|
|
4379
|
+
pageSize: _vm.pageSize,
|
|
4380
|
+
disabled: _vm.isRowDataLoading,
|
|
4381
|
+
},
|
|
1501
4382
|
"data-table": "blog-category",
|
|
1502
4383
|
},
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
}),
|
|
1545
|
-
},
|
|
1546
|
-
},
|
|
1547
|
-
[_c("svg-icon", { attrs: { name: "edit" } })],
|
|
1548
|
-
1
|
|
1549
|
-
),
|
|
1550
|
-
_vm._v(" "),
|
|
1551
|
-
_c(
|
|
1552
|
-
"base-button",
|
|
1553
|
-
{
|
|
1554
|
-
attrs: {
|
|
1555
|
-
variant: "icon",
|
|
1556
|
-
title: _vm.$t("blog:moveUp"),
|
|
1557
|
-
disabled: rowIndex === 0 || _vm.isCategoryMoving,
|
|
1558
|
-
},
|
|
1559
|
-
on: {
|
|
1560
|
-
click: function ($event) {
|
|
1561
|
-
return _vm.moveCategory(row.id, "up")
|
|
1562
|
-
},
|
|
1563
|
-
},
|
|
4384
|
+
on: { change: _vm.handleChange },
|
|
4385
|
+
scopedSlots: _vm._u(
|
|
4386
|
+
[
|
|
4387
|
+
_vm.isLangSpecific
|
|
4388
|
+
? {
|
|
4389
|
+
key: "filters",
|
|
4390
|
+
fn: function () {
|
|
4391
|
+
return [
|
|
4392
|
+
_c(
|
|
4393
|
+
"advanced-search",
|
|
4394
|
+
{
|
|
4395
|
+
attrs: { tags: _vm.tags },
|
|
4396
|
+
on: { "click:tag": _vm.tagRemovalHandler },
|
|
4397
|
+
},
|
|
4398
|
+
[
|
|
4399
|
+
_c(
|
|
4400
|
+
"div",
|
|
4401
|
+
{ staticClass: "filters" },
|
|
4402
|
+
[
|
|
4403
|
+
_c("form-field-multi-select", {
|
|
4404
|
+
staticClass: "filter",
|
|
4405
|
+
attrs: {
|
|
4406
|
+
options: _vm.languageOptionList,
|
|
4407
|
+
name: "languageFilter",
|
|
4408
|
+
searchable: true,
|
|
4409
|
+
label: _vm.$t("blog:language"),
|
|
4410
|
+
},
|
|
4411
|
+
model: {
|
|
4412
|
+
value: _vm.languageFilter,
|
|
4413
|
+
callback: function ($$v) {
|
|
4414
|
+
_vm.languageFilter = $$v;
|
|
4415
|
+
},
|
|
4416
|
+
expression: "languageFilter",
|
|
4417
|
+
},
|
|
4418
|
+
}),
|
|
4419
|
+
],
|
|
4420
|
+
1
|
|
4421
|
+
),
|
|
4422
|
+
]
|
|
4423
|
+
),
|
|
4424
|
+
]
|
|
1564
4425
|
},
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
_vm.
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
click: function ($event) {
|
|
1581
|
-
return _vm.moveCategory(row.id, "down")
|
|
4426
|
+
proxy: true,
|
|
4427
|
+
}
|
|
4428
|
+
: null,
|
|
4429
|
+
{
|
|
4430
|
+
key: "cell(link-to-posts)",
|
|
4431
|
+
fn: function (ref) {
|
|
4432
|
+
var row = ref.row;
|
|
4433
|
+
return [
|
|
4434
|
+
_c(
|
|
4435
|
+
"count-button",
|
|
4436
|
+
{
|
|
4437
|
+
attrs: {
|
|
4438
|
+
href: _vm.getLinkToPostsByCategory(row.id),
|
|
4439
|
+
variant: "outline-secondary",
|
|
4440
|
+
count: row.postsCount,
|
|
1582
4441
|
},
|
|
1583
4442
|
},
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
4443
|
+
[
|
|
4444
|
+
_vm._v(
|
|
4445
|
+
"\n " +
|
|
4446
|
+
_vm._s(_vm.$t("blog:posts")) +
|
|
4447
|
+
"\n "
|
|
4448
|
+
),
|
|
4449
|
+
]
|
|
4450
|
+
),
|
|
4451
|
+
]
|
|
4452
|
+
},
|
|
4453
|
+
},
|
|
4454
|
+
{
|
|
4455
|
+
key: "cell(actions)",
|
|
4456
|
+
fn: function (ref) {
|
|
4457
|
+
var row = ref.row;
|
|
4458
|
+
var rowIndex = ref.rowIndex;
|
|
4459
|
+
return [
|
|
4460
|
+
_vm.canViewAdministrators
|
|
4461
|
+
? _c(
|
|
4462
|
+
"base-button",
|
|
4463
|
+
{
|
|
4464
|
+
attrs: {
|
|
4465
|
+
variant: "icon",
|
|
4466
|
+
title: _vm.$t("blog:edit"),
|
|
4467
|
+
disabled: _vm.isDeleting(row.id),
|
|
4468
|
+
href: _vm.getBlogCategoryFormUrl({
|
|
4469
|
+
categoryId: row.id,
|
|
4470
|
+
}),
|
|
4471
|
+
},
|
|
4472
|
+
},
|
|
4473
|
+
[_c("svg-icon", { attrs: { name: "edit" } })],
|
|
4474
|
+
1
|
|
4475
|
+
)
|
|
4476
|
+
: _vm._e(),
|
|
4477
|
+
_vm._v(" "),
|
|
4478
|
+
_c(
|
|
4479
|
+
"base-button",
|
|
4480
|
+
{
|
|
4481
|
+
attrs: {
|
|
4482
|
+
variant: "icon",
|
|
4483
|
+
title: _vm.$t("blog:moveUp"),
|
|
4484
|
+
disabled: rowIndex === 0 || _vm.isCategoryMoving,
|
|
4485
|
+
},
|
|
4486
|
+
on: {
|
|
4487
|
+
click: function ($event) {
|
|
4488
|
+
return _vm.moveCategory(row.id, "up")
|
|
4489
|
+
},
|
|
4490
|
+
},
|
|
1597
4491
|
},
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
4492
|
+
[_c("svg-icon", { attrs: { name: "north" } })],
|
|
4493
|
+
1
|
|
4494
|
+
),
|
|
4495
|
+
_vm._v(" "),
|
|
4496
|
+
_c(
|
|
4497
|
+
"base-button",
|
|
4498
|
+
{
|
|
4499
|
+
attrs: {
|
|
4500
|
+
variant: "icon",
|
|
4501
|
+
title: _vm.$t("blog:moveDown"),
|
|
4502
|
+
disabled:
|
|
4503
|
+
rowIndex === _vm.rowData.length - 1 ||
|
|
4504
|
+
_vm.isCategoryMoving,
|
|
4505
|
+
},
|
|
4506
|
+
on: {
|
|
4507
|
+
click: function ($event) {
|
|
4508
|
+
return _vm.moveCategory(row.id, "down")
|
|
4509
|
+
},
|
|
1601
4510
|
},
|
|
1602
4511
|
},
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
4512
|
+
[_c("svg-icon", { attrs: { name: "south" } })],
|
|
4513
|
+
1
|
|
4514
|
+
),
|
|
4515
|
+
_vm._v(" "),
|
|
4516
|
+
_vm.canViewAdministrators
|
|
4517
|
+
? _c(
|
|
4518
|
+
"base-button",
|
|
4519
|
+
{
|
|
4520
|
+
attrs: {
|
|
4521
|
+
variant: "icon",
|
|
4522
|
+
title: _vm.$t("blog:remove"),
|
|
4523
|
+
disabled:
|
|
4524
|
+
_vm.isDeleting(row.id) ||
|
|
4525
|
+
row.postsCount > 0,
|
|
4526
|
+
},
|
|
4527
|
+
on: {
|
|
4528
|
+
click: function ($event) {
|
|
4529
|
+
return _vm.handleCategoryDelete(row.id)
|
|
4530
|
+
},
|
|
4531
|
+
},
|
|
4532
|
+
},
|
|
4533
|
+
[_c("svg-icon", { attrs: { name: "delete" } })],
|
|
4534
|
+
1
|
|
4535
|
+
)
|
|
4536
|
+
: _vm._e(),
|
|
4537
|
+
]
|
|
4538
|
+
},
|
|
1608
4539
|
},
|
|
1609
|
-
|
|
1610
|
-
|
|
4540
|
+
],
|
|
4541
|
+
null,
|
|
4542
|
+
true
|
|
4543
|
+
),
|
|
1611
4544
|
}),
|
|
1612
4545
|
]
|
|
1613
4546
|
},
|
|
@@ -1620,17 +4553,15 @@
|
|
|
1620
4553
|
__vue_render__$2._withStripped = true;
|
|
1621
4554
|
|
|
1622
4555
|
/* style */
|
|
1623
|
-
const __vue_inject_styles__$2 =
|
|
1624
|
-
if (!inject) return
|
|
1625
|
-
inject("data-v-3d18b3da_0", { source: "\n\n/*# sourceMappingURL=BlogCategoryList.vue.map */", map: {"version":3,"sources":["BlogCategoryList.vue"],"names":[],"mappings":";;AAEA,+CAA+C","file":"BlogCategoryList.vue"}, media: undefined });
|
|
1626
|
-
|
|
1627
|
-
};
|
|
4556
|
+
const __vue_inject_styles__$2 = undefined;
|
|
1628
4557
|
/* scoped */
|
|
1629
|
-
const __vue_scope_id__$2 =
|
|
4558
|
+
const __vue_scope_id__$2 = undefined;
|
|
1630
4559
|
/* module identifier */
|
|
1631
4560
|
const __vue_module_identifier__$2 = undefined;
|
|
1632
4561
|
/* functional template */
|
|
1633
4562
|
const __vue_is_functional_template__$2 = false;
|
|
4563
|
+
/* style inject */
|
|
4564
|
+
|
|
1634
4565
|
/* style inject SSR */
|
|
1635
4566
|
|
|
1636
4567
|
/* style inject shadow dom */
|
|
@@ -1645,65 +4576,72 @@
|
|
|
1645
4576
|
__vue_is_functional_template__$2,
|
|
1646
4577
|
__vue_module_identifier__$2,
|
|
1647
4578
|
false,
|
|
1648
|
-
|
|
4579
|
+
undefined,
|
|
1649
4580
|
undefined,
|
|
1650
4581
|
undefined
|
|
1651
4582
|
);
|
|
1652
4583
|
|
|
1653
4584
|
function convertCategoryToFormValues(category, languageOptionList) {
|
|
1654
|
-
|
|
1655
|
-
const currentLangOption = languageOptionList.find((option) => option.value === (category === null || category === void 0 ? void 0 : category.language));
|
|
4585
|
+
const currentLangOption = languageOptionList.find(({ value }) => value === category?.language);
|
|
1656
4586
|
if (!category) {
|
|
1657
4587
|
return {
|
|
1658
4588
|
name: '',
|
|
1659
4589
|
isDefault: false,
|
|
1660
4590
|
pageTitle: '',
|
|
1661
4591
|
pageDescription: '',
|
|
4592
|
+
openGraphTitle: '',
|
|
4593
|
+
openGraphDescription: '',
|
|
4594
|
+
pageKeywords: '',
|
|
1662
4595
|
openGraphImage: null,
|
|
1663
4596
|
urlAlias: '',
|
|
1664
|
-
language: currentLangOption
|
|
4597
|
+
language: currentLangOption ?? null,
|
|
1665
4598
|
};
|
|
1666
4599
|
}
|
|
1667
4600
|
return {
|
|
1668
4601
|
name: category.name,
|
|
1669
4602
|
isDefault: category.isDefault,
|
|
1670
|
-
pageTitle:
|
|
1671
|
-
pageDescription:
|
|
4603
|
+
pageTitle: category.pageTitle ?? '',
|
|
4604
|
+
pageDescription: category.pageDescription ?? '',
|
|
4605
|
+
pageKeywords: category.pageKeywords ?? '',
|
|
4606
|
+
openGraphTitle: category.openGraphTitle ?? '',
|
|
4607
|
+
openGraphDescription: category.openGraphDescription ?? '',
|
|
1672
4608
|
openGraphImage: category.openGraphImage
|
|
1673
4609
|
? { id: adminServices.createId(), file: category.openGraphImage }
|
|
1674
4610
|
: null,
|
|
1675
4611
|
urlAlias: category.urlAlias,
|
|
1676
|
-
language: currentLangOption
|
|
4612
|
+
language: currentLangOption ?? null,
|
|
1677
4613
|
};
|
|
1678
4614
|
}
|
|
1679
4615
|
function convertCategoryFormValuesToCreationPayload(values) {
|
|
1680
|
-
var _a, _b, _c, _d;
|
|
1681
4616
|
return {
|
|
1682
4617
|
name: values.name,
|
|
1683
4618
|
isDefault: values.isDefault,
|
|
1684
4619
|
pageTitle: values.pageTitle,
|
|
1685
4620
|
pageDescription: values.pageDescription,
|
|
1686
|
-
openGraphImage:
|
|
1687
|
-
language:
|
|
4621
|
+
openGraphImage: values.openGraphImage?.file.id ?? null,
|
|
4622
|
+
language: values.language?.value ?? null,
|
|
1688
4623
|
};
|
|
1689
4624
|
}
|
|
1690
4625
|
function convertCategoryFormValuesToUpdatePayload(values) {
|
|
1691
|
-
return
|
|
4626
|
+
return {
|
|
4627
|
+
...convertCategoryFormValuesToCreationPayload(values),
|
|
4628
|
+
urlAlias: values.urlAlias,
|
|
4629
|
+
};
|
|
1692
4630
|
}
|
|
1693
4631
|
|
|
1694
4632
|
var script$3 = compositionApi.defineComponent({
|
|
1695
4633
|
name: 'BlogCategoryForm',
|
|
1696
4634
|
components: { FormFooter: adminUi.FormFooter },
|
|
1697
4635
|
setup(props, context) {
|
|
4636
|
+
const { t } = adminUi.useTranslation(context);
|
|
1698
4637
|
const categoryId = compositionApi.computed(() => context.root.$route.params.categoryId);
|
|
1699
4638
|
const isCreation = compositionApi.computed(() => categoryId.value === 'create');
|
|
1700
4639
|
/** Fetch module config */
|
|
1701
4640
|
const { data: moduleConfig, loading: isModuleConfigLoading, } = useModuleConfig({ context });
|
|
1702
|
-
const
|
|
1703
|
-
|
|
1704
|
-
label: lang.name,
|
|
1705
|
-
}))) !== null && _b !== void 0 ? _b : []; });
|
|
4641
|
+
const languageList = compositionApi.computed(() => moduleConfig.value?.languages ?? []);
|
|
4642
|
+
const languageOptionList = compositionApi.computed(() => languageList.value.map(({ id, name }) => ({ value: id, label: name })));
|
|
1706
4643
|
const isLangSpecific = compositionApi.computed(() => languageOptionList.value.length > 0);
|
|
4644
|
+
const imageScenario = compositionApi.computed(() => moduleConfig.value?.fileScenarios?.openGraph ?? null);
|
|
1707
4645
|
/** Fetch Category */
|
|
1708
4646
|
const [fetchCategory, { data: category, loading: isCategoryLoading },] = adminServices.useResource({
|
|
1709
4647
|
fetchResource: () => getBlogCategory(categoryId.value),
|
|
@@ -1712,13 +4650,15 @@
|
|
|
1712
4650
|
resourceName: 'Category',
|
|
1713
4651
|
});
|
|
1714
4652
|
compositionApi.onMounted(() => {
|
|
1715
|
-
if (isCreation.value)
|
|
4653
|
+
if (isCreation.value) {
|
|
1716
4654
|
return;
|
|
4655
|
+
}
|
|
1717
4656
|
fetchCategory();
|
|
1718
4657
|
});
|
|
1719
4658
|
compositionApi.watch(categoryId, () => {
|
|
1720
|
-
if (isCreation.value)
|
|
4659
|
+
if (isCreation.value) {
|
|
1721
4660
|
return;
|
|
4661
|
+
}
|
|
1722
4662
|
fetchCategory();
|
|
1723
4663
|
});
|
|
1724
4664
|
/** Form State */
|
|
@@ -1729,12 +4669,13 @@
|
|
|
1729
4669
|
values.value = convertCategoryToFormValues(category.value, languageOptionList.value);
|
|
1730
4670
|
});
|
|
1731
4671
|
function submitForm(event) {
|
|
1732
|
-
var _a, _b;
|
|
1733
4672
|
isSubmitting.value = true;
|
|
1734
4673
|
const creationBody = convertCategoryFormValuesToCreationPayload(values.value);
|
|
1735
4674
|
const updateBody = convertCategoryFormValuesToUpdatePayload(values.value);
|
|
1736
4675
|
if (!isCreation.value) {
|
|
1737
|
-
updateBody.language =
|
|
4676
|
+
updateBody.language = category.value?.language
|
|
4677
|
+
? category.value?.language
|
|
4678
|
+
: null;
|
|
1738
4679
|
}
|
|
1739
4680
|
const requestPromise = isCreation.value
|
|
1740
4681
|
? createBlogCategory(creationBody)
|
|
@@ -1777,10 +4718,21 @@
|
|
|
1777
4718
|
/** Misc */
|
|
1778
4719
|
const isContentLoading = compositionApi.computed(() => isCategoryLoading.value || isModuleConfigLoading.value);
|
|
1779
4720
|
const categoryPagePath = compositionApi.computed(() => {
|
|
1780
|
-
|
|
1781
|
-
const origin = process.env.VUE_APP_WEBSITE_URL || window.location.origin;
|
|
1782
|
-
return origin + ((_b = (_a = category.value) === null || _a === void 0 ? void 0 : _a.urlTemplate) !== null && _b !== void 0 ? _b : '');
|
|
4721
|
+
return `${adminServices.getWebsiteOrigin()}${category.value?.urlTemplate ?? ''}`;
|
|
1783
4722
|
});
|
|
4723
|
+
// SEO
|
|
4724
|
+
function handleSeoFieldGroupChange({ title, description, keywords, image, }) {
|
|
4725
|
+
values.value.pageTitle = title;
|
|
4726
|
+
values.value.pageDescription = description;
|
|
4727
|
+
values.value.pageKeywords = keywords;
|
|
4728
|
+
values.value.openGraphImage = image;
|
|
4729
|
+
}
|
|
4730
|
+
/** Tabs */
|
|
4731
|
+
const tabList = compositionApi.computed(() => [
|
|
4732
|
+
{ id: 'common', label: t('blog:tabs.common') },
|
|
4733
|
+
{ id: 'seo', label: t('blog:tabs.seo') },
|
|
4734
|
+
]);
|
|
4735
|
+
const selectedTabId = compositionApi.ref(tabList.value[0].id);
|
|
1784
4736
|
return {
|
|
1785
4737
|
isCreation,
|
|
1786
4738
|
isContentLoading: isContentLoading,
|
|
@@ -1792,7 +4744,13 @@
|
|
|
1792
4744
|
categoryListUrl: getBlogCategoryListUrl(),
|
|
1793
4745
|
submitForm,
|
|
1794
4746
|
isSubmitting,
|
|
1795
|
-
moduleConfig
|
|
4747
|
+
moduleConfig,
|
|
4748
|
+
// SEO
|
|
4749
|
+
imageScenario,
|
|
4750
|
+
handleSeoFieldGroupChange,
|
|
4751
|
+
// Tabs
|
|
4752
|
+
tabList,
|
|
4753
|
+
selectedTabId,
|
|
1796
4754
|
};
|
|
1797
4755
|
},
|
|
1798
4756
|
});
|
|
@@ -1829,123 +4787,162 @@
|
|
|
1829
4787
|
},
|
|
1830
4788
|
},
|
|
1831
4789
|
[
|
|
1832
|
-
_vm.isCreation
|
|
1833
|
-
?
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
4790
|
+
_vm.isCreation
|
|
4791
|
+
? [
|
|
4792
|
+
_vm.isLangSpecific
|
|
4793
|
+
? _c("form-field-select", {
|
|
4794
|
+
attrs: {
|
|
4795
|
+
name: "language",
|
|
4796
|
+
label: _vm.$t("blog:language"),
|
|
4797
|
+
options: _vm.languageOptionList,
|
|
4798
|
+
error: _vm.errors.language,
|
|
4799
|
+
},
|
|
4800
|
+
model: {
|
|
4801
|
+
value: _vm.values.language,
|
|
4802
|
+
callback: function ($$v) {
|
|
4803
|
+
_vm.$set(_vm.values, "language", $$v);
|
|
4804
|
+
},
|
|
4805
|
+
expression: "values.language",
|
|
4806
|
+
},
|
|
4807
|
+
})
|
|
4808
|
+
: _vm._e(),
|
|
4809
|
+
_vm._v(" "),
|
|
4810
|
+
_c("form-field", {
|
|
4811
|
+
attrs: {
|
|
4812
|
+
name: "name",
|
|
4813
|
+
label: _vm.$t("blog:name"),
|
|
4814
|
+
error: _vm.errors.name,
|
|
1844
4815
|
},
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
attrs: {
|
|
1852
|
-
name: "name",
|
|
1853
|
-
label: _vm.$t("blog:name"),
|
|
1854
|
-
error: _vm.errors.name,
|
|
1855
|
-
},
|
|
1856
|
-
model: {
|
|
1857
|
-
value: _vm.values.name,
|
|
1858
|
-
callback: function ($$v) {
|
|
1859
|
-
_vm.$set(_vm.values, "name", $$v);
|
|
1860
|
-
},
|
|
1861
|
-
expression: "values.name",
|
|
1862
|
-
},
|
|
1863
|
-
}),
|
|
1864
|
-
_vm._v(" "),
|
|
1865
|
-
_c("form-field-checkbox", {
|
|
1866
|
-
attrs: {
|
|
1867
|
-
name: "isDefault",
|
|
1868
|
-
label: _vm.$t("blog:defaultCategory"),
|
|
1869
|
-
error: _vm.errors.isDefault,
|
|
1870
|
-
},
|
|
1871
|
-
model: {
|
|
1872
|
-
value: _vm.values.isDefault,
|
|
1873
|
-
callback: function ($$v) {
|
|
1874
|
-
_vm.$set(_vm.values, "isDefault", $$v);
|
|
1875
|
-
},
|
|
1876
|
-
expression: "values.isDefault",
|
|
1877
|
-
},
|
|
1878
|
-
}),
|
|
1879
|
-
_vm._v(" "),
|
|
1880
|
-
!_vm.isCreation
|
|
1881
|
-
? _c("form-field-url-alias-input", {
|
|
1882
|
-
attrs: {
|
|
1883
|
-
id: "urlAlias",
|
|
1884
|
-
name: "urlAlias",
|
|
1885
|
-
label: _vm.$t("blog:URLAlias"),
|
|
1886
|
-
"url-template": _vm.pagePath,
|
|
1887
|
-
error: _vm.errors.urlAlias,
|
|
1888
|
-
},
|
|
1889
|
-
model: {
|
|
1890
|
-
value: _vm.values.urlAlias,
|
|
1891
|
-
callback: function ($$v) {
|
|
1892
|
-
_vm.$set(_vm.values, "urlAlias", $$v);
|
|
4816
|
+
model: {
|
|
4817
|
+
value: _vm.values.name,
|
|
4818
|
+
callback: function ($$v) {
|
|
4819
|
+
_vm.$set(_vm.values, "name", $$v);
|
|
4820
|
+
},
|
|
4821
|
+
expression: "values.name",
|
|
1893
4822
|
},
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
4823
|
+
}),
|
|
4824
|
+
_vm._v(" "),
|
|
4825
|
+
_c("form-field-checkbox", {
|
|
4826
|
+
attrs: {
|
|
4827
|
+
name: "isDefault",
|
|
4828
|
+
label: _vm.$t("blog:defaultCategory"),
|
|
4829
|
+
error: _vm.errors.isDefault,
|
|
4830
|
+
},
|
|
4831
|
+
model: {
|
|
4832
|
+
value: _vm.values.isDefault,
|
|
4833
|
+
callback: function ($$v) {
|
|
4834
|
+
_vm.$set(_vm.values, "isDefault", $$v);
|
|
4835
|
+
},
|
|
4836
|
+
expression: "values.isDefault",
|
|
4837
|
+
},
|
|
4838
|
+
}),
|
|
4839
|
+
_vm._v(" "),
|
|
4840
|
+
_c("form-field-url-alias-input", {
|
|
4841
|
+
attrs: {
|
|
4842
|
+
id: "urlAlias",
|
|
4843
|
+
name: "urlAlias",
|
|
4844
|
+
label: _vm.$t("blog:URLAlias"),
|
|
4845
|
+
"url-template": _vm.pagePath,
|
|
4846
|
+
error: _vm.errors.urlAlias,
|
|
4847
|
+
},
|
|
4848
|
+
model: {
|
|
4849
|
+
value: _vm.values.urlAlias,
|
|
4850
|
+
callback: function ($$v) {
|
|
4851
|
+
_vm.$set(_vm.values, "urlAlias", $$v);
|
|
4852
|
+
},
|
|
4853
|
+
expression: "values.urlAlias",
|
|
4854
|
+
},
|
|
4855
|
+
}),
|
|
4856
|
+
]
|
|
4857
|
+
: [
|
|
4858
|
+
_c("tab-list", {
|
|
4859
|
+
attrs: {
|
|
4860
|
+
"tab-list": _vm.tabList,
|
|
4861
|
+
"selected-tab-id": _vm.selectedTabId,
|
|
4862
|
+
},
|
|
4863
|
+
on: {
|
|
4864
|
+
"tab:update": function ($event) {
|
|
4865
|
+
_vm.selectedTabId = $event.tabId;
|
|
4866
|
+
},
|
|
4867
|
+
},
|
|
4868
|
+
}),
|
|
4869
|
+
_vm._v(" "),
|
|
4870
|
+
_vm.selectedTabId === "common"
|
|
4871
|
+
? [
|
|
4872
|
+
_c("form-field", {
|
|
4873
|
+
attrs: {
|
|
4874
|
+
name: "name",
|
|
4875
|
+
label: _vm.$t("blog:name"),
|
|
4876
|
+
error: _vm.errors.name,
|
|
4877
|
+
},
|
|
4878
|
+
model: {
|
|
4879
|
+
value: _vm.values.name,
|
|
4880
|
+
callback: function ($$v) {
|
|
4881
|
+
_vm.$set(_vm.values, "name", $$v);
|
|
4882
|
+
},
|
|
4883
|
+
expression: "values.name",
|
|
4884
|
+
},
|
|
4885
|
+
}),
|
|
4886
|
+
_vm._v(" "),
|
|
4887
|
+
_c("form-field-checkbox", {
|
|
4888
|
+
attrs: {
|
|
4889
|
+
name: "isDefault",
|
|
4890
|
+
label: _vm.$t("blog:defaultCategory"),
|
|
4891
|
+
error: _vm.errors.isDefault,
|
|
4892
|
+
},
|
|
4893
|
+
model: {
|
|
4894
|
+
value: _vm.values.isDefault,
|
|
4895
|
+
callback: function ($$v) {
|
|
4896
|
+
_vm.$set(_vm.values, "isDefault", $$v);
|
|
4897
|
+
},
|
|
4898
|
+
expression: "values.isDefault",
|
|
4899
|
+
},
|
|
4900
|
+
}),
|
|
4901
|
+
_vm._v(" "),
|
|
4902
|
+
_c("form-field-url-alias-input", {
|
|
4903
|
+
attrs: {
|
|
4904
|
+
id: "urlAlias",
|
|
4905
|
+
name: "urlAlias",
|
|
4906
|
+
label: _vm.$t("blog:URLAlias"),
|
|
4907
|
+
"url-template": _vm.pagePath,
|
|
4908
|
+
error: _vm.errors.urlAlias,
|
|
4909
|
+
},
|
|
4910
|
+
model: {
|
|
4911
|
+
value: _vm.values.urlAlias,
|
|
4912
|
+
callback: function ($$v) {
|
|
4913
|
+
_vm.$set(_vm.values, "urlAlias", $$v);
|
|
4914
|
+
},
|
|
4915
|
+
expression: "values.urlAlias",
|
|
4916
|
+
},
|
|
4917
|
+
}),
|
|
4918
|
+
]
|
|
4919
|
+
: _vm._e(),
|
|
4920
|
+
_vm._v(" "),
|
|
4921
|
+
_vm.selectedTabId === "seo"
|
|
4922
|
+
? [
|
|
4923
|
+
_c("seo-field-group", {
|
|
4924
|
+
attrs: {
|
|
4925
|
+
title: _vm.values.pageTitle,
|
|
4926
|
+
"title-error-message": _vm.errors.pageTitle,
|
|
4927
|
+
description: _vm.values.pageDescription,
|
|
4928
|
+
"description-error-message":
|
|
4929
|
+
_vm.errors.pageDescription,
|
|
4930
|
+
"should-display-keywords": false,
|
|
4931
|
+
keywords: _vm.values.pageKeywords,
|
|
4932
|
+
"keywords-error-message":
|
|
4933
|
+
_vm.errors.pageKeywords,
|
|
4934
|
+
image: _vm.values.openGraphImage,
|
|
4935
|
+
"image-scenario": _vm.imageScenario,
|
|
4936
|
+
"image-error-message":
|
|
4937
|
+
_vm.errors.openGraphImage,
|
|
4938
|
+
},
|
|
4939
|
+
on: { change: _vm.handleSeoFieldGroupChange },
|
|
4940
|
+
}),
|
|
4941
|
+
]
|
|
4942
|
+
: _vm._e(),
|
|
4943
|
+
],
|
|
1947
4944
|
],
|
|
1948
|
-
|
|
4945
|
+
2
|
|
1949
4946
|
),
|
|
1950
4947
|
]
|
|
1951
4948
|
},
|
|
@@ -1975,17 +4972,15 @@
|
|
|
1975
4972
|
__vue_render__$3._withStripped = true;
|
|
1976
4973
|
|
|
1977
4974
|
/* style */
|
|
1978
|
-
const __vue_inject_styles__$3 =
|
|
1979
|
-
if (!inject) return
|
|
1980
|
-
inject("data-v-a60477f6_0", { source: "\n\n/*# sourceMappingURL=BlogCategoryForm.vue.map */", map: {"version":3,"sources":["BlogCategoryForm.vue"],"names":[],"mappings":";;AAEA,+CAA+C","file":"BlogCategoryForm.vue"}, media: undefined });
|
|
1981
|
-
|
|
1982
|
-
};
|
|
4975
|
+
const __vue_inject_styles__$3 = undefined;
|
|
1983
4976
|
/* scoped */
|
|
1984
|
-
const __vue_scope_id__$3 =
|
|
4977
|
+
const __vue_scope_id__$3 = undefined;
|
|
1985
4978
|
/* module identifier */
|
|
1986
4979
|
const __vue_module_identifier__$3 = undefined;
|
|
1987
4980
|
/* functional template */
|
|
1988
4981
|
const __vue_is_functional_template__$3 = false;
|
|
4982
|
+
/* style inject */
|
|
4983
|
+
|
|
1989
4984
|
/* style inject SSR */
|
|
1990
4985
|
|
|
1991
4986
|
/* style inject shadow dom */
|
|
@@ -2000,153 +4995,7 @@
|
|
|
2000
4995
|
__vue_is_functional_template__$3,
|
|
2001
4996
|
__vue_module_identifier__$3,
|
|
2002
4997
|
false,
|
|
2003
|
-
createInjector,
|
|
2004
4998
|
undefined,
|
|
2005
|
-
undefined
|
|
2006
|
-
);
|
|
2007
|
-
|
|
2008
|
-
function convertBlogSettingsToFormValues(settingItemList) {
|
|
2009
|
-
return settingItemList.map((settingItem) => adminDynamicField.universalFieldUtils.createFormField(settingItem.field, settingItem.value));
|
|
2010
|
-
}
|
|
2011
|
-
function convertSettingValuesToRequestPayload(values) {
|
|
2012
|
-
return {
|
|
2013
|
-
values: values.map((field) => ({
|
|
2014
|
-
name: field.config.name,
|
|
2015
|
-
value: adminDynamicField.universalFieldUtils.getOutgoingValue(field),
|
|
2016
|
-
})),
|
|
2017
|
-
};
|
|
2018
|
-
}
|
|
2019
|
-
|
|
2020
|
-
var script$4 = compositionApi.defineComponent({
|
|
2021
|
-
name: 'BlogSettings',
|
|
2022
|
-
components: { DynamicField: adminDynamicField.DynamicField },
|
|
2023
|
-
setup(props, context) {
|
|
2024
|
-
const [fetchSettingList, { data: settingList, loading }] = adminServices.useResource({
|
|
2025
|
-
fetchResource: getBlogSettingList,
|
|
2026
|
-
initialValue: [],
|
|
2027
|
-
context,
|
|
2028
|
-
resourceName: 'Settings',
|
|
2029
|
-
});
|
|
2030
|
-
compositionApi.onMounted(() => {
|
|
2031
|
-
fetchSettingList();
|
|
2032
|
-
});
|
|
2033
|
-
const isSubmitting = compositionApi.ref(false);
|
|
2034
|
-
const values = compositionApi.ref(convertBlogSettingsToFormValues(settingList.value));
|
|
2035
|
-
compositionApi.watch(settingList, () => {
|
|
2036
|
-
values.value = convertBlogSettingsToFormValues(settingList.value);
|
|
2037
|
-
});
|
|
2038
|
-
const errors = compositionApi.ref({});
|
|
2039
|
-
function submitForm({ shouldExit }) {
|
|
2040
|
-
isSubmitting.value = true;
|
|
2041
|
-
const body = convertSettingValuesToRequestPayload(values.value);
|
|
2042
|
-
updateBlogSettingList(body)
|
|
2043
|
-
.then(() => {
|
|
2044
|
-
errors.value = {};
|
|
2045
|
-
if (shouldExit) {
|
|
2046
|
-
context.root.$router.push(getBlogPostListUrl());
|
|
2047
|
-
}
|
|
2048
|
-
context.root.$toast({
|
|
2049
|
-
variant: 'success',
|
|
2050
|
-
title: context.root.$t('blog:success'),
|
|
2051
|
-
body: context.root.$t('blog:blogSettingsHaveBeenSuccessfullyUpdated'),
|
|
2052
|
-
});
|
|
2053
|
-
})
|
|
2054
|
-
.catch((error) => {
|
|
2055
|
-
console.error(error);
|
|
2056
|
-
errors.value = adminServices.convertRequestErrorToMap(error);
|
|
2057
|
-
context.root.$toast({
|
|
2058
|
-
variant: 'danger',
|
|
2059
|
-
title: context.root.$t('blog:error'),
|
|
2060
|
-
body: context.root.$t('blog:blogSettingsUpdateHasBeenFailed'),
|
|
2061
|
-
});
|
|
2062
|
-
})
|
|
2063
|
-
.finally(() => {
|
|
2064
|
-
isSubmitting.value = false;
|
|
2065
|
-
});
|
|
2066
|
-
}
|
|
2067
|
-
return { isContentLoading: loading, submitForm, isSubmitting, values };
|
|
2068
|
-
},
|
|
2069
|
-
});
|
|
2070
|
-
|
|
2071
|
-
/* script */
|
|
2072
|
-
const __vue_script__$4 = script$4;
|
|
2073
|
-
|
|
2074
|
-
/* template */
|
|
2075
|
-
var __vue_render__$4 = function () {
|
|
2076
|
-
var _vm = this;
|
|
2077
|
-
var _h = _vm.$createElement;
|
|
2078
|
-
var _c = _vm._self._c || _h;
|
|
2079
|
-
return _c("page", {
|
|
2080
|
-
attrs: {
|
|
2081
|
-
title: _vm.$t("blog:blogSettings"),
|
|
2082
|
-
"is-content-loading": _vm.isContentLoading,
|
|
2083
|
-
footer: {
|
|
2084
|
-
backHref: "/",
|
|
2085
|
-
onSubmit: _vm.submitForm,
|
|
2086
|
-
isSubmitting: _vm.isSubmitting,
|
|
2087
|
-
},
|
|
2088
|
-
},
|
|
2089
|
-
scopedSlots: _vm._u([
|
|
2090
|
-
{
|
|
2091
|
-
key: "content",
|
|
2092
|
-
fn: function () {
|
|
2093
|
-
return [
|
|
2094
|
-
_c(
|
|
2095
|
-
"form",
|
|
2096
|
-
{
|
|
2097
|
-
attrs: { novalidate: "" },
|
|
2098
|
-
on: {
|
|
2099
|
-
submit: function ($event) {
|
|
2100
|
-
$event.preventDefault();
|
|
2101
|
-
return _vm.submitForm($event)
|
|
2102
|
-
},
|
|
2103
|
-
},
|
|
2104
|
-
},
|
|
2105
|
-
_vm._l(_vm.values, function (field) {
|
|
2106
|
-
return _c("DynamicField", {
|
|
2107
|
-
key: field.config.name,
|
|
2108
|
-
attrs: { field: field },
|
|
2109
|
-
})
|
|
2110
|
-
}),
|
|
2111
|
-
1
|
|
2112
|
-
),
|
|
2113
|
-
]
|
|
2114
|
-
},
|
|
2115
|
-
proxy: true,
|
|
2116
|
-
},
|
|
2117
|
-
]),
|
|
2118
|
-
})
|
|
2119
|
-
};
|
|
2120
|
-
var __vue_staticRenderFns__$4 = [];
|
|
2121
|
-
__vue_render__$4._withStripped = true;
|
|
2122
|
-
|
|
2123
|
-
/* style */
|
|
2124
|
-
const __vue_inject_styles__$4 = function (inject) {
|
|
2125
|
-
if (!inject) return
|
|
2126
|
-
inject("data-v-dc003c44_0", { source: "\n\n/*# sourceMappingURL=BlogSettings.vue.map */", map: {"version":3,"sources":["BlogSettings.vue"],"names":[],"mappings":";;AAEA,2CAA2C","file":"BlogSettings.vue"}, media: undefined });
|
|
2127
|
-
|
|
2128
|
-
};
|
|
2129
|
-
/* scoped */
|
|
2130
|
-
const __vue_scope_id__$4 = "data-v-dc003c44";
|
|
2131
|
-
/* module identifier */
|
|
2132
|
-
const __vue_module_identifier__$4 = undefined;
|
|
2133
|
-
/* functional template */
|
|
2134
|
-
const __vue_is_functional_template__$4 = false;
|
|
2135
|
-
/* style inject SSR */
|
|
2136
|
-
|
|
2137
|
-
/* style inject shadow dom */
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
const __vue_component__$4 = /*#__PURE__*/normalizeComponent(
|
|
2142
|
-
{ render: __vue_render__$4, staticRenderFns: __vue_staticRenderFns__$4 },
|
|
2143
|
-
__vue_inject_styles__$4,
|
|
2144
|
-
__vue_script__$4,
|
|
2145
|
-
__vue_scope_id__$4,
|
|
2146
|
-
__vue_is_functional_template__$4,
|
|
2147
|
-
__vue_module_identifier__$4,
|
|
2148
|
-
false,
|
|
2149
|
-
createInjector,
|
|
2150
4999
|
undefined,
|
|
2151
5000
|
undefined
|
|
2152
5001
|
);
|
|
@@ -2196,17 +5045,6 @@
|
|
|
2196
5045
|
{ url: route.path, text: t('blog:categoryForm') },
|
|
2197
5046
|
],
|
|
2198
5047
|
},
|
|
2199
|
-
};
|
|
2200
|
-
const BLOG_SETTINGS_ROUTE = {
|
|
2201
|
-
path: BLOG_ROUTE_PATHS.SETTINGS,
|
|
2202
|
-
component: __vue_component__$4,
|
|
2203
|
-
name: 'Settings',
|
|
2204
|
-
meta: {
|
|
2205
|
-
getBreadcrumbs: (route, t) => [
|
|
2206
|
-
{ url: '/', text: t('blog:home') },
|
|
2207
|
-
{ url: getBlogSettingsUrl(), text: t('blog:blogSettings') },
|
|
2208
|
-
],
|
|
2209
|
-
},
|
|
2210
5048
|
};
|
|
2211
5049
|
|
|
2212
5050
|
function getBlogMenuItem(params) {
|
|
@@ -2225,7 +5063,6 @@
|
|
|
2225
5063
|
url: getBlogCategoryFormUrl({ categoryId: 'create' }),
|
|
2226
5064
|
},
|
|
2227
5065
|
{ text: params.t('blog:categories'), url: getBlogCategoryListUrl() },
|
|
2228
|
-
{ text: params.t('blog:settings'), url: getBlogSettingsUrl() },
|
|
2229
5066
|
],
|
|
2230
5067
|
};
|
|
2231
5068
|
}
|
|
@@ -2238,7 +5075,7 @@
|
|
|
2238
5075
|
exports.BLOG_POST_FORM_ROUTE = BLOG_POST_FORM_ROUTE;
|
|
2239
5076
|
exports.BLOG_POST_LIST_ROUTE = BLOG_POST_LIST_ROUTE;
|
|
2240
5077
|
exports.BLOG_ROUTE_PATHS = BLOG_ROUTE_PATHS;
|
|
2241
|
-
exports.
|
|
5078
|
+
exports.clonePost = clonePost;
|
|
2242
5079
|
exports.createBlogCategory = createBlogCategory;
|
|
2243
5080
|
exports.createBlogPost = createBlogPost;
|
|
2244
5081
|
exports.deleteBlogCategory = deleteBlogCategory;
|
|
@@ -2254,12 +5091,10 @@
|
|
|
2254
5091
|
exports.getBlogPostFormUrl = getBlogPostFormUrl;
|
|
2255
5092
|
exports.getBlogPostList = getBlogPostList;
|
|
2256
5093
|
exports.getBlogPostListUrl = getBlogPostListUrl;
|
|
2257
|
-
exports.
|
|
2258
|
-
exports.getBlogSettingsUrl = getBlogSettingsUrl;
|
|
5094
|
+
exports.getUserProfile = getUserProfile;
|
|
2259
5095
|
exports.moveBlogCategory = moveBlogCategory;
|
|
2260
5096
|
exports.updateBlogCategory = updateBlogCategory;
|
|
2261
5097
|
exports.updateBlogPost = updateBlogPost;
|
|
2262
|
-
exports.updateBlogSettingList = updateBlogSettingList;
|
|
2263
5098
|
|
|
2264
5099
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2265
5100
|
|