@tager/admin-files 0.0.7 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/paths.d.ts +4 -4
- package/dist/constants/routes.d.ts +3 -3
- package/dist/dev/App.vue.d.ts +6 -0
- package/dist/dev/config.d.ts +2 -0
- package/dist/dev/env.d.ts +1 -0
- package/dist/dev/main.d.ts +3 -0
- package/dist/index.mjs +315 -0
- package/dist/locales/apply.d.ts +1 -0
- package/dist/locales/en.d.ts +18 -19
- package/dist/locales/ru.d.ts +2 -3
- package/dist/main.d.ts +3 -3
- package/dist/services/requests.d.ts +16 -16
- package/dist/typings/model.d.ts +14 -14
- package/dist/utils/paths.d.ts +4 -4
- package/dist/views/FilesForm/FilesForm.helpers.d.ts +2 -2
- package/dist/views/FilesForm/FilesForm.vue.d.ts +23 -50
- package/dist/views/FilesForm/index.d.ts +1 -1
- package/dist/views/FilesList/FilesList.vue.d.ts +19 -37
- package/dist/views/FilesList/index.d.ts +1 -1
- package/package.json +47 -49
- package/src/constants/routes.ts +10 -10
- package/src/dev/App.vue +38 -0
- package/src/dev/config.ts +23 -0
- package/src/dev/env.ts +17 -0
- package/src/dev/main.ts +36 -0
- package/src/locales/apply.ts +9 -0
- package/src/locales/en.ts +1 -3
- package/src/locales/ru.ts +2 -4
- package/src/main.ts +2 -6
- package/src/services/requests.ts +2 -2
- package/src/typings/model.ts +1 -1
- package/src/views/FilesForm/FilesForm.helpers.ts +1 -1
- package/src/views/FilesForm/FilesForm.vue +32 -26
- package/src/views/FilesList/FilesList.vue +51 -49
- package/README.md +0 -1
- package/dist/dev.d.ts +0 -1
- package/dist/index.esm.js +0 -738
- package/dist/index.umd.js +0 -750
- package/src/dev.ts +0 -41
- package/src/typings/sfc.d.ts +0 -12
- package/src/typings/shims-tsx.d.ts +0 -13
- package/src/typings/shims-vue.d.ts +0 -11
- package/src/views/App.vue +0 -36
package/dist/index.esm.js
DELETED
|
@@ -1,738 +0,0 @@
|
|
|
1
|
-
import { request, useResourceDelete, convertRequestErrorToMap, i18n } from '@tager/admin-services';
|
|
2
|
-
import { defineComponent, onMounted, ref } from '@vue/composition-api';
|
|
3
|
-
import { useTranslation, useDataTable, cutUrlOrigin, 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
|
-
var script$1 = defineComponent({
|
|
240
|
-
name: 'FilesList',
|
|
241
|
-
components: {},
|
|
242
|
-
setup(props, context) {
|
|
243
|
-
const { t } = useTranslation(context);
|
|
244
|
-
const { fetchEntityList: fetchFilesList, isLoading: isFilesListLoading, rowData: filesList, errorMessage, searchQuery, handleChange, pageSize, pageCount, pageNumber, } = useDataTable({
|
|
245
|
-
fetchEntityList: (params) => getFilesList({
|
|
246
|
-
query: params.searchQuery,
|
|
247
|
-
pageNumber: params.pageNumber,
|
|
248
|
-
pageSize: params.pageSize,
|
|
249
|
-
}),
|
|
250
|
-
initialValue: [],
|
|
251
|
-
context,
|
|
252
|
-
resourceName: 'Files list',
|
|
253
|
-
pageSize: 100,
|
|
254
|
-
});
|
|
255
|
-
onMounted(() => {
|
|
256
|
-
fetchFilesList();
|
|
257
|
-
});
|
|
258
|
-
const { handleResourceDelete, isDeleting } = useResourceDelete({
|
|
259
|
-
deleteResource: deleteFile,
|
|
260
|
-
resourceName: 'File',
|
|
261
|
-
onSuccess: fetchFilesList,
|
|
262
|
-
context,
|
|
263
|
-
});
|
|
264
|
-
const columnDefs = [
|
|
265
|
-
{
|
|
266
|
-
id: 1,
|
|
267
|
-
name: 'ID',
|
|
268
|
-
field: 'id',
|
|
269
|
-
style: { width: '50px', textAlign: 'center' },
|
|
270
|
-
headStyle: { width: '50px', textAlign: 'center' },
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
id: 2,
|
|
274
|
-
name: t('files:fileName'),
|
|
275
|
-
field: 'name',
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
id: 3,
|
|
279
|
-
name: t('files:fileType'),
|
|
280
|
-
field: 'type',
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
id: 4,
|
|
284
|
-
name: t('files:fileSize'),
|
|
285
|
-
field: 'size',
|
|
286
|
-
format: ({ row }) => filesize(row.size),
|
|
287
|
-
style: { whiteSpace: 'nowrap' },
|
|
288
|
-
headStyle: { whiteSpace: 'nowrap' },
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
id: 5,
|
|
292
|
-
name: 'URL',
|
|
293
|
-
type: 'link',
|
|
294
|
-
field: 'url',
|
|
295
|
-
format: ({ row }) => ({
|
|
296
|
-
url: row.url,
|
|
297
|
-
text: cutUrlOrigin(row.url)
|
|
298
|
-
}),
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
id: 6,
|
|
302
|
-
name: t('files:delete'),
|
|
303
|
-
field: 'delete',
|
|
304
|
-
style: { textAlign: 'center' },
|
|
305
|
-
headStyle: { textAlign: 'center' },
|
|
306
|
-
},
|
|
307
|
-
];
|
|
308
|
-
return {
|
|
309
|
-
columnDefs,
|
|
310
|
-
getFilesFormUrl,
|
|
311
|
-
rowData: filesList,
|
|
312
|
-
isRowDataLoading: isFilesListLoading,
|
|
313
|
-
errorMessage: errorMessage,
|
|
314
|
-
searchQuery,
|
|
315
|
-
handleChange,
|
|
316
|
-
pageSize,
|
|
317
|
-
pageCount,
|
|
318
|
-
pageNumber,
|
|
319
|
-
handleResourceDelete,
|
|
320
|
-
isDeleting,
|
|
321
|
-
};
|
|
322
|
-
},
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
|
|
326
|
-
if (typeof shadowMode !== 'boolean') {
|
|
327
|
-
createInjectorSSR = createInjector;
|
|
328
|
-
createInjector = shadowMode;
|
|
329
|
-
shadowMode = false;
|
|
330
|
-
}
|
|
331
|
-
// Vue.extend constructor export interop.
|
|
332
|
-
const options = typeof script === 'function' ? script.options : script;
|
|
333
|
-
// render functions
|
|
334
|
-
if (template && template.render) {
|
|
335
|
-
options.render = template.render;
|
|
336
|
-
options.staticRenderFns = template.staticRenderFns;
|
|
337
|
-
options._compiled = true;
|
|
338
|
-
// functional template
|
|
339
|
-
if (isFunctionalTemplate) {
|
|
340
|
-
options.functional = true;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
// scopedId
|
|
344
|
-
if (scopeId) {
|
|
345
|
-
options._scopeId = scopeId;
|
|
346
|
-
}
|
|
347
|
-
let hook;
|
|
348
|
-
if (moduleIdentifier) {
|
|
349
|
-
// server build
|
|
350
|
-
hook = function (context) {
|
|
351
|
-
// 2.3 injection
|
|
352
|
-
context =
|
|
353
|
-
context || // cached call
|
|
354
|
-
(this.$vnode && this.$vnode.ssrContext) || // stateful
|
|
355
|
-
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
|
|
356
|
-
// 2.2 with runInNewContext: true
|
|
357
|
-
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
|
|
358
|
-
context = __VUE_SSR_CONTEXT__;
|
|
359
|
-
}
|
|
360
|
-
// inject component styles
|
|
361
|
-
if (style) {
|
|
362
|
-
style.call(this, createInjectorSSR(context));
|
|
363
|
-
}
|
|
364
|
-
// register component module identifier for async chunk inference
|
|
365
|
-
if (context && context._registeredComponents) {
|
|
366
|
-
context._registeredComponents.add(moduleIdentifier);
|
|
367
|
-
}
|
|
368
|
-
};
|
|
369
|
-
// used by ssr in case component is cached and beforeCreate
|
|
370
|
-
// never gets called
|
|
371
|
-
options._ssrRegister = hook;
|
|
372
|
-
}
|
|
373
|
-
else if (style) {
|
|
374
|
-
hook = shadowMode
|
|
375
|
-
? function (context) {
|
|
376
|
-
style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
|
|
377
|
-
}
|
|
378
|
-
: function (context) {
|
|
379
|
-
style.call(this, createInjector(context));
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
if (hook) {
|
|
383
|
-
if (options.functional) {
|
|
384
|
-
// register for functional component in vue file
|
|
385
|
-
const originalRender = options.render;
|
|
386
|
-
options.render = function renderWithStyleInjection(h, context) {
|
|
387
|
-
hook.call(context);
|
|
388
|
-
return originalRender(h, context);
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
else {
|
|
392
|
-
// inject component registration as beforeCreate hook
|
|
393
|
-
const existing = options.beforeCreate;
|
|
394
|
-
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
return script;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
/* script */
|
|
401
|
-
const __vue_script__$1 = script$1;
|
|
402
|
-
|
|
403
|
-
/* template */
|
|
404
|
-
var __vue_render__$1 = function () {
|
|
405
|
-
var _vm = this;
|
|
406
|
-
var _h = _vm.$createElement;
|
|
407
|
-
var _c = _vm._self._c || _h;
|
|
408
|
-
return _c(
|
|
409
|
-
"page",
|
|
410
|
-
{
|
|
411
|
-
attrs: {
|
|
412
|
-
title: _vm.$t("files:filesList"),
|
|
413
|
-
"header-buttons": [
|
|
414
|
-
{
|
|
415
|
-
text: _vm.$t("files:createFile"),
|
|
416
|
-
href: _vm.getFilesFormUrl({ fileId: "create" }),
|
|
417
|
-
},
|
|
418
|
-
],
|
|
419
|
-
},
|
|
420
|
-
},
|
|
421
|
-
[
|
|
422
|
-
_c("data-table", {
|
|
423
|
-
attrs: {
|
|
424
|
-
"column-defs": _vm.columnDefs,
|
|
425
|
-
"row-data": _vm.rowData,
|
|
426
|
-
loading: _vm.isRowDataLoading,
|
|
427
|
-
"error-message": _vm.errorMessage,
|
|
428
|
-
"search-query": _vm.searchQuery,
|
|
429
|
-
pagination: {
|
|
430
|
-
pageSize: _vm.pageSize,
|
|
431
|
-
pageCount: _vm.pageCount,
|
|
432
|
-
pageNumber: _vm.pageNumber,
|
|
433
|
-
disabled: _vm.isRowDataLoading,
|
|
434
|
-
},
|
|
435
|
-
},
|
|
436
|
-
on: { change: _vm.handleChange },
|
|
437
|
-
scopedSlots: _vm._u([
|
|
438
|
-
{
|
|
439
|
-
key: "cell(delete)",
|
|
440
|
-
fn: function (ref) {
|
|
441
|
-
var row = ref.row;
|
|
442
|
-
return [
|
|
443
|
-
_c(
|
|
444
|
-
"base-button",
|
|
445
|
-
{
|
|
446
|
-
attrs: {
|
|
447
|
-
variant: "icon",
|
|
448
|
-
title: _vm.$t("files:delete"),
|
|
449
|
-
disabled: _vm.isDeleting(row.id),
|
|
450
|
-
},
|
|
451
|
-
on: {
|
|
452
|
-
click: function ($event) {
|
|
453
|
-
return _vm.handleResourceDelete(row.id)
|
|
454
|
-
},
|
|
455
|
-
},
|
|
456
|
-
},
|
|
457
|
-
[_c("svg-icon", { attrs: { name: "delete" } })],
|
|
458
|
-
1
|
|
459
|
-
),
|
|
460
|
-
]
|
|
461
|
-
},
|
|
462
|
-
},
|
|
463
|
-
]),
|
|
464
|
-
}),
|
|
465
|
-
],
|
|
466
|
-
1
|
|
467
|
-
)
|
|
468
|
-
};
|
|
469
|
-
var __vue_staticRenderFns__$1 = [];
|
|
470
|
-
__vue_render__$1._withStripped = true;
|
|
471
|
-
|
|
472
|
-
/* style */
|
|
473
|
-
const __vue_inject_styles__$1 = undefined;
|
|
474
|
-
/* scoped */
|
|
475
|
-
const __vue_scope_id__$1 = undefined;
|
|
476
|
-
/* module identifier */
|
|
477
|
-
const __vue_module_identifier__$1 = undefined;
|
|
478
|
-
/* functional template */
|
|
479
|
-
const __vue_is_functional_template__$1 = false;
|
|
480
|
-
/* style inject */
|
|
481
|
-
|
|
482
|
-
/* style inject SSR */
|
|
483
|
-
|
|
484
|
-
/* style inject shadow dom */
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
const __vue_component__$1 = /*#__PURE__*/normalizeComponent(
|
|
489
|
-
{ render: __vue_render__$1, staticRenderFns: __vue_staticRenderFns__$1 },
|
|
490
|
-
__vue_inject_styles__$1,
|
|
491
|
-
__vue_script__$1,
|
|
492
|
-
__vue_scope_id__$1,
|
|
493
|
-
__vue_is_functional_template__$1,
|
|
494
|
-
__vue_module_identifier__$1,
|
|
495
|
-
false,
|
|
496
|
-
undefined,
|
|
497
|
-
undefined,
|
|
498
|
-
undefined
|
|
499
|
-
);
|
|
500
|
-
|
|
501
|
-
function convertFilesFormValuesToCreationPayload(values) {
|
|
502
|
-
var _a, _b;
|
|
503
|
-
return {
|
|
504
|
-
file: (_b = (_a = values.file) === null || _a === void 0 ? void 0 : _a.file.id) !== null && _b !== void 0 ? _b : '',
|
|
505
|
-
};
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
var script = defineComponent({
|
|
509
|
-
name: 'FilesForm',
|
|
510
|
-
components: { FormFooter },
|
|
511
|
-
setup(props, context) {
|
|
512
|
-
const { t } = useTranslation(context);
|
|
513
|
-
/** Form state */
|
|
514
|
-
const errors = ref({});
|
|
515
|
-
const values = ref({ file: null });
|
|
516
|
-
const isSubmitting = ref(false);
|
|
517
|
-
function submitForm(event) {
|
|
518
|
-
isSubmitting.value = true;
|
|
519
|
-
const creationPayload = convertFilesFormValuesToCreationPayload(values.value);
|
|
520
|
-
addFile(creationPayload)
|
|
521
|
-
.then(() => {
|
|
522
|
-
errors.value = {};
|
|
523
|
-
if (event.type === 'create' ||
|
|
524
|
-
event.type === 'save' ||
|
|
525
|
-
event.type === 'create_exit' ||
|
|
526
|
-
event.type === 'save_exit') {
|
|
527
|
-
context.root.$router.push(getFilesListUrl());
|
|
528
|
-
}
|
|
529
|
-
context.root.$toast({
|
|
530
|
-
variant: 'success',
|
|
531
|
-
title: t('files:success'),
|
|
532
|
-
body: t('files:createdSuccessMessage'),
|
|
533
|
-
});
|
|
534
|
-
})
|
|
535
|
-
.catch((error) => {
|
|
536
|
-
console.error(error);
|
|
537
|
-
errors.value = convertRequestErrorToMap(error);
|
|
538
|
-
context.root.$toast({
|
|
539
|
-
variant: 'danger',
|
|
540
|
-
title: t('files:error'),
|
|
541
|
-
body: t('files:createdErrorMessage'),
|
|
542
|
-
});
|
|
543
|
-
})
|
|
544
|
-
.finally(() => {
|
|
545
|
-
isSubmitting.value = false;
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
return {
|
|
549
|
-
values,
|
|
550
|
-
errors,
|
|
551
|
-
isSubmitting,
|
|
552
|
-
submitForm,
|
|
553
|
-
getFilesListUrl,
|
|
554
|
-
};
|
|
555
|
-
},
|
|
556
|
-
});
|
|
557
|
-
|
|
558
|
-
const isOldIE = typeof navigator !== 'undefined' &&
|
|
559
|
-
/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
|
|
560
|
-
function createInjector(context) {
|
|
561
|
-
return (id, style) => addStyle(id, style);
|
|
562
|
-
}
|
|
563
|
-
let HEAD;
|
|
564
|
-
const styles = {};
|
|
565
|
-
function addStyle(id, css) {
|
|
566
|
-
const group = isOldIE ? css.media || 'default' : id;
|
|
567
|
-
const style = styles[group] || (styles[group] = { ids: new Set(), styles: [] });
|
|
568
|
-
if (!style.ids.has(id)) {
|
|
569
|
-
style.ids.add(id);
|
|
570
|
-
let code = css.source;
|
|
571
|
-
if (css.map) {
|
|
572
|
-
// https://developer.chrome.com/devtools/docs/javascript-debugging
|
|
573
|
-
// this makes source maps inside style tags work properly in Chrome
|
|
574
|
-
code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
|
|
575
|
-
// http://stackoverflow.com/a/26603875
|
|
576
|
-
code +=
|
|
577
|
-
'\n/*# sourceMappingURL=data:application/json;base64,' +
|
|
578
|
-
btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) +
|
|
579
|
-
' */';
|
|
580
|
-
}
|
|
581
|
-
if (!style.element) {
|
|
582
|
-
style.element = document.createElement('style');
|
|
583
|
-
style.element.type = 'text/css';
|
|
584
|
-
if (css.media)
|
|
585
|
-
style.element.setAttribute('media', css.media);
|
|
586
|
-
if (HEAD === undefined) {
|
|
587
|
-
HEAD = document.head || document.getElementsByTagName('head')[0];
|
|
588
|
-
}
|
|
589
|
-
HEAD.appendChild(style.element);
|
|
590
|
-
}
|
|
591
|
-
if ('styleSheet' in style.element) {
|
|
592
|
-
style.styles.push(code);
|
|
593
|
-
style.element.styleSheet.cssText = style.styles
|
|
594
|
-
.filter(Boolean)
|
|
595
|
-
.join('\n');
|
|
596
|
-
}
|
|
597
|
-
else {
|
|
598
|
-
const index = style.ids.size - 1;
|
|
599
|
-
const textNode = document.createTextNode(code);
|
|
600
|
-
const nodes = style.element.childNodes;
|
|
601
|
-
if (nodes[index])
|
|
602
|
-
style.element.removeChild(nodes[index]);
|
|
603
|
-
if (nodes.length)
|
|
604
|
-
style.element.insertBefore(textNode, nodes[index]);
|
|
605
|
-
else
|
|
606
|
-
style.element.appendChild(textNode);
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
/* script */
|
|
612
|
-
const __vue_script__ = script;
|
|
613
|
-
|
|
614
|
-
/* template */
|
|
615
|
-
var __vue_render__ = function () {
|
|
616
|
-
var _vm = this;
|
|
617
|
-
var _h = _vm.$createElement;
|
|
618
|
-
var _c = _vm._self._c || _h;
|
|
619
|
-
return _c(
|
|
620
|
-
"page",
|
|
621
|
-
{
|
|
622
|
-
attrs: { title: _vm.$t("files:fileCreation") },
|
|
623
|
-
scopedSlots: _vm._u([
|
|
624
|
-
{
|
|
625
|
-
key: "footer",
|
|
626
|
-
fn: function () {
|
|
627
|
-
return [
|
|
628
|
-
_c("FormFooter", {
|
|
629
|
-
attrs: {
|
|
630
|
-
"back-href": _vm.getFilesListUrl(),
|
|
631
|
-
"on-submit": _vm.submitForm,
|
|
632
|
-
"is-submitting": _vm.isSubmitting,
|
|
633
|
-
"is-creation": true,
|
|
634
|
-
"submit-label": "Добавить",
|
|
635
|
-
},
|
|
636
|
-
}),
|
|
637
|
-
]
|
|
638
|
-
},
|
|
639
|
-
proxy: true,
|
|
640
|
-
},
|
|
641
|
-
]),
|
|
642
|
-
},
|
|
643
|
-
[
|
|
644
|
-
_c(
|
|
645
|
-
"form",
|
|
646
|
-
{
|
|
647
|
-
attrs: { novalidate: "" },
|
|
648
|
-
on: {
|
|
649
|
-
submit: function ($event) {
|
|
650
|
-
$event.preventDefault();
|
|
651
|
-
},
|
|
652
|
-
},
|
|
653
|
-
},
|
|
654
|
-
[
|
|
655
|
-
[
|
|
656
|
-
_c("form-field-file-input", {
|
|
657
|
-
attrs: {
|
|
658
|
-
error: _vm.errors.file,
|
|
659
|
-
label: _vm.$t("files:file"),
|
|
660
|
-
name: "file",
|
|
661
|
-
},
|
|
662
|
-
model: {
|
|
663
|
-
value: _vm.values.file,
|
|
664
|
-
callback: function ($$v) {
|
|
665
|
-
_vm.$set(_vm.values, "file", $$v);
|
|
666
|
-
},
|
|
667
|
-
expression: "values.file",
|
|
668
|
-
},
|
|
669
|
-
}),
|
|
670
|
-
],
|
|
671
|
-
],
|
|
672
|
-
2
|
|
673
|
-
),
|
|
674
|
-
]
|
|
675
|
-
)
|
|
676
|
-
};
|
|
677
|
-
var __vue_staticRenderFns__ = [];
|
|
678
|
-
__vue_render__._withStripped = true;
|
|
679
|
-
|
|
680
|
-
/* style */
|
|
681
|
-
const __vue_inject_styles__ = function (inject) {
|
|
682
|
-
if (!inject) return
|
|
683
|
-
inject("data-v-5f7d9380_0", { source: "\n\n/*# sourceMappingURL=FilesForm.vue.map */", map: {"version":3,"sources":["FilesForm.vue"],"names":[],"mappings":";;AAEA,wCAAwC","file":"FilesForm.vue"}, media: undefined });
|
|
684
|
-
|
|
685
|
-
};
|
|
686
|
-
/* scoped */
|
|
687
|
-
const __vue_scope_id__ = "data-v-5f7d9380";
|
|
688
|
-
/* module identifier */
|
|
689
|
-
const __vue_module_identifier__ = undefined;
|
|
690
|
-
/* functional template */
|
|
691
|
-
const __vue_is_functional_template__ = false;
|
|
692
|
-
/* style inject SSR */
|
|
693
|
-
|
|
694
|
-
/* style inject shadow dom */
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
const __vue_component__ = /*#__PURE__*/normalizeComponent(
|
|
699
|
-
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
700
|
-
__vue_inject_styles__,
|
|
701
|
-
__vue_script__,
|
|
702
|
-
__vue_scope_id__,
|
|
703
|
-
__vue_is_functional_template__,
|
|
704
|
-
__vue_module_identifier__,
|
|
705
|
-
false,
|
|
706
|
-
createInjector,
|
|
707
|
-
undefined,
|
|
708
|
-
undefined
|
|
709
|
-
);
|
|
710
|
-
|
|
711
|
-
const FILES_LIST_ROUTE = {
|
|
712
|
-
path: FILES_ROUTE_PATHS.FILES_LIST,
|
|
713
|
-
component: __vue_component__$1,
|
|
714
|
-
name: 'Files List',
|
|
715
|
-
meta: {
|
|
716
|
-
getBreadcrumbs: (route, t) => [
|
|
717
|
-
{ url: '/', text: t('files:home') },
|
|
718
|
-
{ url: route.path, text: t('files:filesList') },
|
|
719
|
-
],
|
|
720
|
-
},
|
|
721
|
-
};
|
|
722
|
-
const FILES_FORM_ROUTE = {
|
|
723
|
-
path: FILES_ROUTE_PATHS.FILES_FORM,
|
|
724
|
-
component: __vue_component__,
|
|
725
|
-
name: 'Files Form',
|
|
726
|
-
meta: {
|
|
727
|
-
getBreadcrumbs: (route, t) => [
|
|
728
|
-
{ url: '/', text: t('files:home') },
|
|
729
|
-
{ url: FILES_LIST_ROUTE.path, text: t('files:filesList') },
|
|
730
|
-
{ url: route.path, text: t('files:filesForm') },
|
|
731
|
-
],
|
|
732
|
-
},
|
|
733
|
-
};
|
|
734
|
-
|
|
735
|
-
i18n.addTranslations('en', 'files', EN);
|
|
736
|
-
i18n.addTranslations('ru', 'files', RU);
|
|
737
|
-
|
|
738
|
-
export { FILES_FORM_ROUTE, FILES_LIST_ROUTE, addFile, deleteFile, getFilesCount, getFilesFormUrl, getFilesList, getFilesListUrl };
|