@tager/admin-files 0.0.5 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/constants/paths.d.ts +4 -4
  2. package/dist/constants/routes.d.ts +3 -3
  3. package/dist/dev/App.vue.d.ts +5 -0
  4. package/dist/dev/config.d.ts +2 -0
  5. package/dist/dev/env.d.ts +1 -0
  6. package/dist/dev/main.d.ts +3 -0
  7. package/dist/index.mjs +330 -0
  8. package/dist/locales/apply.d.ts +1 -0
  9. package/dist/locales/en.d.ts +18 -19
  10. package/dist/locales/ru.d.ts +2 -3
  11. package/dist/main.d.ts +3 -3
  12. package/dist/services/requests.d.ts +16 -16
  13. package/dist/typings/model.d.ts +14 -14
  14. package/dist/utils/paths.d.ts +4 -4
  15. package/dist/views/FilesForm/FilesForm.helpers.d.ts +2 -2
  16. package/dist/views/FilesForm/FilesForm.vue.d.ts +22 -50
  17. package/dist/views/FilesForm/index.d.ts +1 -1
  18. package/dist/views/FilesList/FilesList.vue.d.ts +18 -38
  19. package/dist/views/FilesList/index.d.ts +1 -1
  20. package/package.json +51 -48
  21. package/src/constants/routes.ts +10 -10
  22. package/src/dev/App.vue +38 -0
  23. package/src/dev/config.ts +23 -0
  24. package/src/dev/env.ts +17 -0
  25. package/src/dev/main.ts +36 -0
  26. package/src/locales/apply.ts +9 -0
  27. package/src/locales/en.ts +1 -3
  28. package/src/locales/ru.ts +2 -4
  29. package/src/main.ts +2 -6
  30. package/src/views/FilesForm/FilesForm.vue +30 -22
  31. package/src/views/FilesList/FilesList.vue +29 -28
  32. package/README.md +0 -1
  33. package/dist/dev.d.ts +0 -1
  34. package/dist/index.esm.js +0 -850
  35. package/dist/index.umd.js +0 -862
  36. package/dist/node_modules/@tager/admin-ui/src/utils/common.d.ts +0 -59
  37. package/dist/src/dev.d.ts +0 -1
  38. package/dist/src/typings/model.d.ts +0 -14
  39. package/dist/views/FilesList/components/UrlCell/UrlCell.vue.d.ts +0 -169
  40. package/dist/views/FilesList/components/UrlCell/index.d.ts +0 -1
  41. package/src/dev.ts +0 -41
  42. package/src/typings/sfc.d.ts +0 -12
  43. package/src/typings/shims-tsx.d.ts +0 -13
  44. package/src/typings/shims-vue.d.ts +0 -11
  45. package/src/views/App.vue +0 -36
  46. package/src/views/FilesList/components/UrlCell/UrlCell.vue +0 -68
  47. package/src/views/FilesList/components/UrlCell/index.ts +0 -1
package/dist/index.umd.js DELETED
@@ -1,862 +0,0 @@
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')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@tager/admin-services', '@vue/composition-api', '@tager/admin-ui', 'path-to-regexp'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TagerAdminFiles = {}, global.adminServices, global.compositionApi, global.adminUi, global.pathToRegexp));
5
- }(this, (function (exports, adminServices, compositionApi, adminUi, pathToRegexp) { 'use strict';
6
-
7
- const EN = {
8
- home: 'Home',
9
- success: 'Success',
10
- error: 'Error',
11
- createdSuccessMessage: 'The file was added successfully',
12
- createdErrorMessage: 'Failed to add file',
13
- files: 'Files',
14
- filesList: 'Files List',
15
- filesForm: 'File Form',
16
- createFile: 'Create file',
17
- fileCreation: 'File creation',
18
- file: 'File',
19
- fileName: 'File',
20
- fileType: 'Type',
21
- fileSize: 'Size',
22
- delete: 'Delete',
23
- add: 'Add',
24
- };
25
-
26
- const RU = {
27
- home: 'Главная',
28
- success: 'Успех',
29
- error: 'Ошибка',
30
- createdSuccessMessage: 'Файл был успешно добавлен',
31
- createdErrorMessage: 'Не удалось добавить файл',
32
- files: 'Файлы',
33
- filesList: 'Список файлов',
34
- filesForm: 'Форма файлов',
35
- createFile: 'Создать файл',
36
- fileCreation: 'Создание файла',
37
- file: 'Файл',
38
- fileName: 'Имя файла',
39
- fileType: 'Тип файла',
40
- fileSize: 'Размер',
41
- delete: 'Удалить',
42
- add: 'Добавить',
43
- };
44
-
45
- /**
46
- * filesize
47
- *
48
- * @copyright 2021 Jason Mulligan <jason.mulligan@avoidwork.com>
49
- * @license BSD-3-Clause
50
- * @version 7.0.0
51
- */
52
- const b = /^(b|B)$/,
53
- symbol = {
54
- iec: {
55
- bits: ["b", "Kib", "Mib", "Gib", "Tib", "Pib", "Eib", "Zib", "Yib"],
56
- bytes: ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"]
57
- },
58
- jedec: {
59
- bits: ["b", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb"],
60
- bytes: ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
61
- }
62
- },
63
- fullform = {
64
- iec: ["", "kibi", "mebi", "gibi", "tebi", "pebi", "exbi", "zebi", "yobi"],
65
- jedec: ["", "kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta"]
66
- },
67
- roundingFuncs = {
68
- floor: Math.floor,
69
- ceil: Math.ceil
70
- };
71
-
72
- /**
73
- * filesize
74
- *
75
- * @method filesize
76
- * @param {Mixed} arg String, Int or Float to transform
77
- * @param {Object} descriptor [Optional] Flags
78
- * @return {String} Readable file size String
79
- */
80
- function filesize (arg, descriptor = {}) {
81
- let result = [],
82
- val = 0,
83
- e, base, bits, ceil, full, fullforms, locale, localeOptions, neg, num, output, pad, round, u, unix, separator, spacer, standard, symbols, roundingFunc, precision;
84
-
85
- if (isNaN(arg)) {
86
- throw new TypeError("Invalid number");
87
- }
88
-
89
- bits = descriptor.bits === true;
90
- unix = descriptor.unix === true;
91
- pad = descriptor.pad === true;
92
- base = descriptor.base || 2;
93
- round = descriptor.round !== void 0 ? descriptor.round : unix ? 1 : 2;
94
- locale = descriptor.locale !== void 0 ? descriptor.locale : "";
95
- localeOptions = descriptor.localeOptions || {};
96
- separator = descriptor.separator !== void 0 ? descriptor.separator : "";
97
- spacer = descriptor.spacer !== void 0 ? descriptor.spacer : unix ? "" : " ";
98
- symbols = descriptor.symbols || {};
99
- standard = base === 2 ? descriptor.standard || "jedec" : "jedec";
100
- output = descriptor.output || "string";
101
- full = descriptor.fullform === true;
102
- fullforms = descriptor.fullforms instanceof Array ? descriptor.fullforms : [];
103
- e = descriptor.exponent !== void 0 ? descriptor.exponent : -1;
104
- roundingFunc = roundingFuncs[descriptor.roundingMethod] || Math.round;
105
- num = Number(arg);
106
- neg = num < 0;
107
- ceil = base > 2 ? 1000 : 1024;
108
- precision = isNaN(descriptor.precision) === false ? parseInt(descriptor.precision, 10) : 0;
109
-
110
- // Flipping a negative number to determine the size
111
- if (neg) {
112
- num = -num;
113
- }
114
-
115
- // Determining the exponent
116
- if (e === -1 || isNaN(e)) {
117
- e = Math.floor(Math.log(num) / Math.log(ceil));
118
-
119
- if (e < 0) {
120
- e = 0;
121
- }
122
- }
123
-
124
- // Exceeding supported length, time to reduce & multiply
125
- if (e > 8) {
126
- if (precision > 0) {
127
- precision += 8 - e;
128
- }
129
-
130
- e = 8;
131
- }
132
-
133
- if (output === "exponent") {
134
- return e;
135
- }
136
-
137
- // Zero is now a special case because bytes divide by 1
138
- if (num === 0) {
139
- result[0] = 0;
140
- u = result[1] = unix ? "" : symbol[standard][bits ? "bits" : "bytes"][e];
141
- } else {
142
- val = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e));
143
-
144
- if (bits) {
145
- val = val * 8;
146
-
147
- if (val >= ceil && e < 8) {
148
- val = val / ceil;
149
- e++;
150
- }
151
- }
152
-
153
- const p = Math.pow(10, e > 0 ? round : 0);
154
- result[0] = roundingFunc(val * p) / p;
155
-
156
- if (result[0] === ceil && e < 8 && descriptor.exponent === void 0) {
157
- result[0] = 1;
158
- e++;
159
- }
160
-
161
- u = result[1] = base === 10 && e === 1 ? bits ? "kb" : "kB" : symbol[standard][bits ? "bits" : "bytes"][e];
162
-
163
- if (unix) {
164
- result[1] = standard === "jedec" ? result[1].charAt(0) : e > 0 ? result[1].replace(/B$/, "") : result[1];
165
-
166
- if (b.test(result[1])) {
167
- result[0] = Math.floor(result[0]);
168
- result[1] = "";
169
- }
170
- }
171
- }
172
-
173
- // Decorating a 'diff'
174
- if (neg) {
175
- result[0] = -result[0];
176
- }
177
-
178
- // Setting optional precision
179
- if (precision > 0) {
180
- result[0] = result[0].toPrecision(precision);
181
- }
182
-
183
- // Applying custom symbol
184
- result[1] = symbols[result[1]] || result[1];
185
-
186
- if (locale === true) {
187
- result[0] = result[0].toLocaleString();
188
- } else if (locale.length > 0) {
189
- result[0] = result[0].toLocaleString(locale, localeOptions);
190
- } else if (separator.length > 0) {
191
- result[0] = result[0].toString().replace(".", separator);
192
- }
193
-
194
- if (pad && Number.isInteger(result[0]) === false && round > 0) {
195
- const x = separator || ".",
196
- tmp = result[0].toString().split(x),
197
- s = tmp[1] || "",
198
- l = s.length,
199
- n = round - l;
200
-
201
- result[0] = `${tmp[0]}${x}${s.padEnd(l + n, "0")}`;
202
- }
203
-
204
- if (full) {
205
- result[1] = fullforms[e] ? fullforms[e] : fullform[standard][e] + (bits ? "bit" : "byte") + (result[0] === 1 ? "" : "s");
206
- }
207
-
208
- // Returning Array, Object, or String (default)
209
- return output === "array" ? result : output === "object" ? {value: result[0], symbol: result[1], exponent: e, unit: u} : result.join(spacer);
210
- }
211
-
212
- // Partial application for functional programming
213
- filesize.partial = opt => arg => filesize(arg, opt);
214
-
215
- function getFilesList(params) {
216
- return adminServices.request.get({ path: '/admin/userfiles', params });
217
- }
218
- function getFilesCount() {
219
- return adminServices.request.get({ path: '/admin/userfiles/count' });
220
- }
221
- function deleteFile(fileId) {
222
- return adminServices.request.delete({ path: `/admin/userfiles/${fileId}` });
223
- }
224
- function addFile(payload) {
225
- return adminServices.request.post({ path: '/admin/userfiles', body: payload });
226
- }
227
-
228
- const FILES_ROUTE_PATHS = {
229
- FILES_LIST: '/files',
230
- FILES_FORM: '/files/:fileId',
231
- };
232
-
233
- function getFilesListUrl() {
234
- return FILES_ROUTE_PATHS.FILES_LIST;
235
- }
236
- function getFilesFormUrl(params) {
237
- return pathToRegexp.compile(FILES_ROUTE_PATHS.FILES_FORM)(params);
238
- }
239
-
240
- /**
241
- * Example:
242
- * input: "https://ozitag.com/search?query=some_text"
243
- * output: "/search?query=some_text"
244
- */
245
- function cutUrlOrigin(url) {
246
- if (!adminServices.isAbsoluteUrl(url))
247
- return url;
248
- const urlObject = new URL(url);
249
- return urlObject.href.slice(urlObject.origin.length);
250
- }
251
-
252
- var script$2 = compositionApi.defineComponent({
253
- name: 'UrlCell',
254
- props: {
255
- url: {
256
- type: String,
257
- default: '',
258
- },
259
- },
260
- setup() {
261
- const [isCopied, handleCopy] = adminUi.useCopyToClipboard(500);
262
- return {
263
- isCopied,
264
- handleCopy,
265
- cutUrlOrigin,
266
- };
267
- },
268
- });
269
-
270
- function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
271
- if (typeof shadowMode !== 'boolean') {
272
- createInjectorSSR = createInjector;
273
- createInjector = shadowMode;
274
- shadowMode = false;
275
- }
276
- // Vue.extend constructor export interop.
277
- const options = typeof script === 'function' ? script.options : script;
278
- // render functions
279
- if (template && template.render) {
280
- options.render = template.render;
281
- options.staticRenderFns = template.staticRenderFns;
282
- options._compiled = true;
283
- // functional template
284
- if (isFunctionalTemplate) {
285
- options.functional = true;
286
- }
287
- }
288
- // scopedId
289
- if (scopeId) {
290
- options._scopeId = scopeId;
291
- }
292
- let hook;
293
- if (moduleIdentifier) {
294
- // server build
295
- hook = function (context) {
296
- // 2.3 injection
297
- context =
298
- context || // cached call
299
- (this.$vnode && this.$vnode.ssrContext) || // stateful
300
- (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
301
- // 2.2 with runInNewContext: true
302
- if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
303
- context = __VUE_SSR_CONTEXT__;
304
- }
305
- // inject component styles
306
- if (style) {
307
- style.call(this, createInjectorSSR(context));
308
- }
309
- // register component module identifier for async chunk inference
310
- if (context && context._registeredComponents) {
311
- context._registeredComponents.add(moduleIdentifier);
312
- }
313
- };
314
- // used by ssr in case component is cached and beforeCreate
315
- // never gets called
316
- options._ssrRegister = hook;
317
- }
318
- else if (style) {
319
- hook = shadowMode
320
- ? function (context) {
321
- style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
322
- }
323
- : function (context) {
324
- style.call(this, createInjector(context));
325
- };
326
- }
327
- if (hook) {
328
- if (options.functional) {
329
- // register for functional component in vue file
330
- const originalRender = options.render;
331
- options.render = function renderWithStyleInjection(h, context) {
332
- hook.call(context);
333
- return originalRender(h, context);
334
- };
335
- }
336
- else {
337
- // inject component registration as beforeCreate hook
338
- const existing = options.beforeCreate;
339
- options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
340
- }
341
- }
342
- return script;
343
- }
344
-
345
- const isOldIE = typeof navigator !== 'undefined' &&
346
- /msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
347
- function createInjector(context) {
348
- return (id, style) => addStyle(id, style);
349
- }
350
- let HEAD;
351
- const styles = {};
352
- function addStyle(id, css) {
353
- const group = isOldIE ? css.media || 'default' : id;
354
- const style = styles[group] || (styles[group] = { ids: new Set(), styles: [] });
355
- if (!style.ids.has(id)) {
356
- style.ids.add(id);
357
- let code = css.source;
358
- if (css.map) {
359
- // https://developer.chrome.com/devtools/docs/javascript-debugging
360
- // this makes source maps inside style tags work properly in Chrome
361
- code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
362
- // http://stackoverflow.com/a/26603875
363
- code +=
364
- '\n/*# sourceMappingURL=data:application/json;base64,' +
365
- btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) +
366
- ' */';
367
- }
368
- if (!style.element) {
369
- style.element = document.createElement('style');
370
- style.element.type = 'text/css';
371
- if (css.media)
372
- style.element.setAttribute('media', css.media);
373
- if (HEAD === undefined) {
374
- HEAD = document.head || document.getElementsByTagName('head')[0];
375
- }
376
- HEAD.appendChild(style.element);
377
- }
378
- if ('styleSheet' in style.element) {
379
- style.styles.push(code);
380
- style.element.styleSheet.cssText = style.styles
381
- .filter(Boolean)
382
- .join('\n');
383
- }
384
- else {
385
- const index = style.ids.size - 1;
386
- const textNode = document.createTextNode(code);
387
- const nodes = style.element.childNodes;
388
- if (nodes[index])
389
- style.element.removeChild(nodes[index]);
390
- if (nodes.length)
391
- style.element.insertBefore(textNode, nodes[index]);
392
- else
393
- style.element.appendChild(textNode);
394
- }
395
- }
396
- }
397
-
398
- /* script */
399
- const __vue_script__$2 = script$2;
400
-
401
- /* template */
402
- var __vue_render__$2 = function () {
403
- var _vm = this;
404
- var _h = _vm.$createElement;
405
- var _c = _vm._self._c || _h;
406
- return _c(
407
- "div",
408
- { staticClass: "url-cell" },
409
- [
410
- _c(
411
- "a",
412
- { staticClass: "url-text", attrs: { href: _vm.url, target: "_blank" } },
413
- [_vm._v(_vm._s(_vm.cutUrlOrigin(_vm.url)))]
414
- ),
415
- _vm._v(" "),
416
- _c(
417
- "base-button",
418
- {
419
- staticClass: "copy-button",
420
- attrs: { variant: "icon" },
421
- on: {
422
- click: function ($event) {
423
- return _vm.handleCopy(_vm.url)
424
- },
425
- },
426
- },
427
- [
428
- !_vm.isCopied
429
- ? _c("svg-icon", {
430
- staticClass: "icon-size",
431
- attrs: { name: "contentCopy" },
432
- })
433
- : _c("svg-icon", {
434
- staticClass: "icon-size icon-color-green",
435
- attrs: { name: "done" },
436
- }),
437
- ],
438
- 1
439
- ),
440
- ],
441
- 1
442
- )
443
- };
444
- var __vue_staticRenderFns__$2 = [];
445
- __vue_render__$2._withStripped = true;
446
-
447
- /* style */
448
- const __vue_inject_styles__$2 = function (inject) {
449
- if (!inject) return
450
- inject("data-v-e950ca16_0", { source: ".url-cell[data-v-e950ca16] {\n display: flex;\n align-items: center;\n}\n.url-cell .url-text[data-v-e950ca16] {\n color: #007bff;\n}\n.url-cell .url-text[data-v-e950ca16]:hover {\n color: #0056b3;\n text-decoration: underline;\n}\n.url-cell .copy-button[data-v-e950ca16] {\n margin-left: 5px;\n}\n.url-cell .copy-button .icon-size[data-v-e950ca16] {\n width: 14px;\n height: 14px;\n}\n.url-cell .copy-button .icon-color-green[data-v-e950ca16] {\n color: #22863a;\n}\n\n/*# sourceMappingURL=UrlCell.vue.map */", map: {"version":3,"sources":["/Users/ozerich/Work/Tager/admin/tager-admin-files/src/views/FilesList/components/UrlCell/UrlCell.vue","UrlCell.vue"],"names":[],"mappings":"AAyCA;EACA,aAAA;EACA,mBAAA;ACxCA;AD0CA;EACA,cAAA;ACxCA;AD0CA;EACA,cAAA;EACA,0BAAA;ACxCA;AD4CA;EACA,gBAAA;AC1CA;AD4CA;EACA,WAAA;EACA,YAAA;AC1CA;AD6CA;EACA,cAAA;AC3CA;;AAEA,sCAAsC","file":"UrlCell.vue","sourcesContent":["<template>\n <div class=\"url-cell\">\n <a :href=\"url\" target=\"_blank\" class=\"url-text\">{{ cutUrlOrigin(url) }}</a>\n <base-button variant=\"icon\" class=\"copy-button\" @click=\"handleCopy(url)\">\n <svg-icon v-if=\"!isCopied\" name=\"contentCopy\" class=\"icon-size\" />\n <svg-icon v-else name=\"done\" class=\"icon-size icon-color-green\" />\n </base-button>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent } from '@vue/composition-api';\n\nimport { cutUrlOrigin } from '@tager/admin-ui/src/utils/common';\nimport { useCopyToClipboard } from '@tager/admin-ui';\n\ninterface Props {\n url: string;\n}\n\nexport default defineComponent<Props>({\n name: 'UrlCell',\n props: {\n url: {\n type: String,\n default: '',\n },\n },\n setup() {\n const [isCopied, handleCopy] = useCopyToClipboard(500);\n\n return {\n isCopied,\n handleCopy,\n cutUrlOrigin,\n };\n },\n});\n</script>\n\n<style lang=\"scss\" scoped>\n.url-cell {\n display: flex;\n align-items: center;\n\n .url-text {\n color: #007bff;\n\n &:hover {\n color: #0056b3;\n text-decoration: underline;\n }\n }\n\n .copy-button {\n margin-left: 5px;\n\n .icon-size {\n width: 14px;\n height: 14px;\n }\n\n .icon-color-green {\n color: #22863a;\n }\n }\n}\n</style>\n",".url-cell {\n display: flex;\n align-items: center;\n}\n.url-cell .url-text {\n color: #007bff;\n}\n.url-cell .url-text:hover {\n color: #0056b3;\n text-decoration: underline;\n}\n.url-cell .copy-button {\n margin-left: 5px;\n}\n.url-cell .copy-button .icon-size {\n width: 14px;\n height: 14px;\n}\n.url-cell .copy-button .icon-color-green {\n color: #22863a;\n}\n\n/*# sourceMappingURL=UrlCell.vue.map */"]}, media: undefined });
451
-
452
- };
453
- /* scoped */
454
- const __vue_scope_id__$2 = "data-v-e950ca16";
455
- /* module identifier */
456
- const __vue_module_identifier__$2 = undefined;
457
- /* functional template */
458
- const __vue_is_functional_template__$2 = false;
459
- /* style inject SSR */
460
-
461
- /* style inject shadow dom */
462
-
463
-
464
-
465
- const __vue_component__$2 = /*#__PURE__*/normalizeComponent(
466
- { render: __vue_render__$2, staticRenderFns: __vue_staticRenderFns__$2 },
467
- __vue_inject_styles__$2,
468
- __vue_script__$2,
469
- __vue_scope_id__$2,
470
- __vue_is_functional_template__$2,
471
- __vue_module_identifier__$2,
472
- false,
473
- createInjector,
474
- undefined,
475
- undefined
476
- );
477
-
478
- var script$1 = compositionApi.defineComponent({
479
- name: 'FilesList',
480
- components: {
481
- UrlCell: __vue_component__$2,
482
- },
483
- setup(props, context) {
484
- const { t } = adminUi.useTranslation(context);
485
- const { fetchEntityList: fetchFilesList, isLoading: isFilesListLoading, rowData: filesList, errorMessage, searchQuery, handleChange, pageSize, pageCount, pageNumber, } = adminUi.useDataTable({
486
- fetchEntityList: (params) => getFilesList({
487
- query: params.searchQuery,
488
- pageNumber: params.pageNumber,
489
- pageSize: params.pageSize,
490
- }),
491
- initialValue: [],
492
- context,
493
- resourceName: 'Files list',
494
- pageSize: 100,
495
- });
496
- compositionApi.onMounted(() => {
497
- fetchFilesList();
498
- });
499
- const { handleResourceDelete, isDeleting } = adminServices.useResourceDelete({
500
- deleteResource: deleteFile,
501
- resourceName: 'File',
502
- onSuccess: fetchFilesList,
503
- context,
504
- });
505
- const columnDefs = [
506
- {
507
- id: 1,
508
- name: '#',
509
- field: 'id',
510
- style: { width: '50px', textAlign: 'center' },
511
- headStyle: { width: '50px', textAlign: 'center' },
512
- },
513
- {
514
- id: 2,
515
- name: t('files:fileName'),
516
- field: 'name',
517
- },
518
- {
519
- id: 3,
520
- name: t('files:fileType'),
521
- field: 'type',
522
- },
523
- {
524
- id: 4,
525
- name: t('files:fileSize'),
526
- field: 'size',
527
- format: ({ row }) => filesize(row.size),
528
- },
529
- {
530
- id: 5,
531
- name: 'URL',
532
- field: 'url',
533
- },
534
- {
535
- id: 6,
536
- name: t('files:delete'),
537
- field: 'delete',
538
- style: { textAlign: 'center' },
539
- headStyle: { textAlign: 'center' },
540
- },
541
- ];
542
- return {
543
- columnDefs,
544
- getFilesFormUrl,
545
- rowData: filesList,
546
- isRowDataLoading: isFilesListLoading,
547
- errorMessage: errorMessage,
548
- searchQuery,
549
- handleChange,
550
- pageSize,
551
- pageCount,
552
- pageNumber,
553
- handleResourceDelete,
554
- isDeleting,
555
- };
556
- },
557
- });
558
-
559
- /* script */
560
- const __vue_script__$1 = script$1;
561
-
562
- /* template */
563
- var __vue_render__$1 = function () {
564
- var _vm = this;
565
- var _h = _vm.$createElement;
566
- var _c = _vm._self._c || _h;
567
- return _c(
568
- "page",
569
- {
570
- attrs: {
571
- title: _vm.$t("files:filesList"),
572
- "header-buttons": [
573
- {
574
- text: _vm.$t("files:createFile"),
575
- href: _vm.getFilesFormUrl({ fileId: "create" }),
576
- },
577
- ],
578
- },
579
- },
580
- [
581
- _c("data-table", {
582
- attrs: {
583
- "column-defs": _vm.columnDefs,
584
- "row-data": _vm.rowData,
585
- loading: _vm.isRowDataLoading,
586
- "error-message": _vm.errorMessage,
587
- "search-query": _vm.searchQuery,
588
- pagination: {
589
- pageSize: _vm.pageSize,
590
- pageCount: _vm.pageCount,
591
- pageNumber: _vm.pageNumber,
592
- disabled: _vm.isRowDataLoading,
593
- },
594
- },
595
- on: { change: _vm.handleChange },
596
- scopedSlots: _vm._u([
597
- {
598
- key: "cell(url)",
599
- fn: function (ref) {
600
- var row = ref.row;
601
- return [_c("UrlCell", { attrs: { url: row.url } })]
602
- },
603
- },
604
- {
605
- key: "cell(delete)",
606
- fn: function (ref) {
607
- var row = ref.row;
608
- return [
609
- _c(
610
- "base-button",
611
- {
612
- attrs: {
613
- variant: "icon",
614
- title: _vm.$t("files:delete"),
615
- disabled: _vm.isDeleting(row.id),
616
- },
617
- on: {
618
- click: function ($event) {
619
- return _vm.handleResourceDelete(row.id)
620
- },
621
- },
622
- },
623
- [_c("svg-icon", { attrs: { name: "delete" } })],
624
- 1
625
- ),
626
- ]
627
- },
628
- },
629
- ]),
630
- }),
631
- ],
632
- 1
633
- )
634
- };
635
- var __vue_staticRenderFns__$1 = [];
636
- __vue_render__$1._withStripped = true;
637
-
638
- /* style */
639
- const __vue_inject_styles__$1 = undefined;
640
- /* scoped */
641
- const __vue_scope_id__$1 = undefined;
642
- /* module identifier */
643
- const __vue_module_identifier__$1 = undefined;
644
- /* functional template */
645
- const __vue_is_functional_template__$1 = false;
646
- /* style inject */
647
-
648
- /* style inject SSR */
649
-
650
- /* style inject shadow dom */
651
-
652
-
653
-
654
- const __vue_component__$1 = /*#__PURE__*/normalizeComponent(
655
- { render: __vue_render__$1, staticRenderFns: __vue_staticRenderFns__$1 },
656
- __vue_inject_styles__$1,
657
- __vue_script__$1,
658
- __vue_scope_id__$1,
659
- __vue_is_functional_template__$1,
660
- __vue_module_identifier__$1,
661
- false,
662
- undefined,
663
- undefined,
664
- undefined
665
- );
666
-
667
- function convertFilesFormValuesToCreationPayload(values) {
668
- var _a, _b;
669
- return {
670
- file: (_b = (_a = values.file) === null || _a === void 0 ? void 0 : _a.file.id) !== null && _b !== void 0 ? _b : '',
671
- };
672
- }
673
-
674
- var script = compositionApi.defineComponent({
675
- name: 'FilesForm',
676
- components: { FormFooter: adminUi.FormFooter },
677
- setup(props, context) {
678
- const { t } = adminUi.useTranslation(context);
679
- /** Form state */
680
- const errors = compositionApi.ref({});
681
- const values = compositionApi.ref({ file: null });
682
- const isSubmitting = compositionApi.ref(false);
683
- function submitForm(event) {
684
- isSubmitting.value = true;
685
- const creationPayload = convertFilesFormValuesToCreationPayload(values.value);
686
- addFile(creationPayload)
687
- .then(() => {
688
- errors.value = {};
689
- if (event.type === 'create' ||
690
- event.type === 'save' ||
691
- event.type === 'create_exit' ||
692
- event.type === 'save_exit') {
693
- context.root.$router.push(getFilesListUrl());
694
- }
695
- context.root.$toast({
696
- variant: 'success',
697
- title: t('files:success'),
698
- body: t('files:createdSuccessMessage'),
699
- });
700
- })
701
- .catch((error) => {
702
- console.error(error);
703
- errors.value = adminServices.convertRequestErrorToMap(error);
704
- context.root.$toast({
705
- variant: 'danger',
706
- title: t('files:error'),
707
- body: t('files:createdErrorMessage'),
708
- });
709
- })
710
- .finally(() => {
711
- isSubmitting.value = false;
712
- });
713
- }
714
- return {
715
- values,
716
- errors,
717
- isSubmitting,
718
- submitForm,
719
- getFilesListUrl,
720
- };
721
- },
722
- });
723
-
724
- /* script */
725
- const __vue_script__ = script;
726
-
727
- /* template */
728
- var __vue_render__ = function () {
729
- var _vm = this;
730
- var _h = _vm.$createElement;
731
- var _c = _vm._self._c || _h;
732
- return _c(
733
- "page",
734
- {
735
- attrs: { title: _vm.$t("files:fileCreation") },
736
- scopedSlots: _vm._u([
737
- {
738
- key: "footer",
739
- fn: function () {
740
- return [
741
- _c("FormFooter", {
742
- attrs: {
743
- "back-href": _vm.getFilesListUrl(),
744
- "on-submit": _vm.submitForm,
745
- "is-submitting": _vm.isSubmitting,
746
- "is-creation": true,
747
- "submit-label": "Добавить",
748
- },
749
- }),
750
- ]
751
- },
752
- proxy: true,
753
- },
754
- ]),
755
- },
756
- [
757
- _c(
758
- "form",
759
- {
760
- attrs: { novalidate: "" },
761
- on: {
762
- submit: function ($event) {
763
- $event.preventDefault();
764
- },
765
- },
766
- },
767
- [
768
- [
769
- _c("form-field-file-input", {
770
- attrs: {
771
- error: _vm.errors.file,
772
- label: _vm.$t("files:file"),
773
- name: "file",
774
- },
775
- model: {
776
- value: _vm.values.file,
777
- callback: function ($$v) {
778
- _vm.$set(_vm.values, "file", $$v);
779
- },
780
- expression: "values.file",
781
- },
782
- }),
783
- ],
784
- ],
785
- 2
786
- ),
787
- ]
788
- )
789
- };
790
- var __vue_staticRenderFns__ = [];
791
- __vue_render__._withStripped = true;
792
-
793
- /* style */
794
- const __vue_inject_styles__ = function (inject) {
795
- if (!inject) return
796
- inject("data-v-70cd8b05_0", { source: "\n\n/*# sourceMappingURL=FilesForm.vue.map */", map: {"version":3,"sources":["FilesForm.vue"],"names":[],"mappings":";;AAEA,wCAAwC","file":"FilesForm.vue"}, media: undefined });
797
-
798
- };
799
- /* scoped */
800
- const __vue_scope_id__ = "data-v-70cd8b05";
801
- /* module identifier */
802
- const __vue_module_identifier__ = undefined;
803
- /* functional template */
804
- const __vue_is_functional_template__ = false;
805
- /* style inject SSR */
806
-
807
- /* style inject shadow dom */
808
-
809
-
810
-
811
- const __vue_component__ = /*#__PURE__*/normalizeComponent(
812
- { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
813
- __vue_inject_styles__,
814
- __vue_script__,
815
- __vue_scope_id__,
816
- __vue_is_functional_template__,
817
- __vue_module_identifier__,
818
- false,
819
- createInjector,
820
- undefined,
821
- undefined
822
- );
823
-
824
- const FILES_LIST_ROUTE = {
825
- path: FILES_ROUTE_PATHS.FILES_LIST,
826
- component: __vue_component__$1,
827
- name: 'Files List',
828
- meta: {
829
- getBreadcrumbs: (route, t) => [
830
- { url: '/', text: t('files:home') },
831
- { url: route.path, text: t('files:filesList') },
832
- ],
833
- },
834
- };
835
- const FILES_FORM_ROUTE = {
836
- path: FILES_ROUTE_PATHS.FILES_FORM,
837
- component: __vue_component__,
838
- name: 'Files Form',
839
- meta: {
840
- getBreadcrumbs: (route, t) => [
841
- { url: '/', text: t('files:home') },
842
- { url: FILES_LIST_ROUTE.path, text: t('files:filesList') },
843
- { url: route.path, text: t('files:filesForm') },
844
- ],
845
- },
846
- };
847
-
848
- adminServices.i18n.addTranslations('en', 'files', EN);
849
- adminServices.i18n.addTranslations('ru', 'files', RU);
850
-
851
- exports.FILES_FORM_ROUTE = FILES_FORM_ROUTE;
852
- exports.FILES_LIST_ROUTE = FILES_LIST_ROUTE;
853
- exports.addFile = addFile;
854
- exports.deleteFile = deleteFile;
855
- exports.getFilesCount = getFilesCount;
856
- exports.getFilesFormUrl = getFilesFormUrl;
857
- exports.getFilesList = getFilesList;
858
- exports.getFilesListUrl = getFilesListUrl;
859
-
860
- Object.defineProperty(exports, '__esModule', { value: true });
861
-
862
- })));