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