@tager/admin-export 0.1.3 → 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 (54) 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 +506 -0
  8. package/dist/locales/apply.d.ts +1 -0
  9. package/dist/locales/en.d.ts +23 -22
  10. package/dist/locales/ru.d.ts +2 -3
  11. package/dist/main.d.ts +3 -3
  12. package/dist/services/requests.d.ts +8 -8
  13. package/dist/style.css +1 -0
  14. package/dist/typings/model.d.ts +26 -23
  15. package/dist/utils/common.d.ts +1 -1
  16. package/dist/utils/paths.d.ts +4 -4
  17. package/dist/views/ExportForm/ExportForm.helpers.d.ts +11 -8
  18. package/dist/views/ExportForm/ExportForm.types.d.ts +7 -0
  19. package/dist/views/ExportForm/ExportForm.vue.d.ts +2693 -60
  20. package/dist/views/ExportForm/index.d.ts +1 -1
  21. package/dist/views/ExportList/ExportList.vue.d.ts +16 -41
  22. package/dist/views/ExportList/components/CellHistory/CellHistory.helpers.d.ts +1 -0
  23. package/dist/views/ExportList/components/CellHistory/CellHistory.vue.d.ts +19 -0
  24. package/dist/views/ExportList/components/CellHistory/index.d.ts +1 -0
  25. package/dist/views/ExportList/index.d.ts +1 -1
  26. package/package.json +49 -47
  27. package/src/constants/routes.ts +10 -10
  28. package/src/dev/App.vue +38 -0
  29. package/src/dev/config.ts +23 -0
  30. package/src/dev/env.ts +17 -0
  31. package/src/dev/main.ts +36 -0
  32. package/src/locales/apply.ts +9 -0
  33. package/src/locales/en.ts +4 -4
  34. package/src/locales/ru.ts +5 -5
  35. package/src/main.ts +2 -6
  36. package/src/services/requests.ts +1 -1
  37. package/src/typings/model.ts +9 -1
  38. package/src/views/ExportForm/ExportForm.helpers.ts +32 -7
  39. package/src/views/ExportForm/ExportForm.types.ts +8 -0
  40. package/src/views/ExportForm/ExportForm.vue +157 -94
  41. package/src/views/ExportList/ExportList.vue +47 -63
  42. package/src/views/ExportList/components/CellHistory/CellHistory.helpers.ts +12 -0
  43. package/src/views/ExportList/components/CellHistory/CellHistory.vue +38 -0
  44. package/src/views/ExportList/components/CellHistory/index.ts +1 -0
  45. package/README +0 -0
  46. package/dist/dev.d.ts +0 -1
  47. package/dist/index.esm.js +0 -668
  48. package/dist/index.umd.js +0 -679
  49. package/src/config/config.json +0 -20
  50. package/src/dev.ts +0 -41
  51. package/src/typings/sfc.d.ts +0 -12
  52. package/src/typings/shims-tsx.d.ts +0 -13
  53. package/src/typings/shims-vue.d.ts +0 -11
  54. package/src/views/App.vue +0 -36
package/dist/index.esm.js DELETED
@@ -1,668 +0,0 @@
1
- import { request, useResource, convertRequestErrorToMap, i18n } from '@tager/admin-services';
2
- import { defineComponent, onMounted, computed, ref, watch } from '@vue/composition-api';
3
- import { useTranslation, useDataTable, FormFooter } from '@tager/admin-ui';
4
- import { compile } from 'path-to-regexp';
5
-
6
- const EN = {
7
- home: 'Home',
8
- exportAndImport: 'Export / Import',
9
- export: 'Export',
10
- exportList: 'Export List',
11
- exportForm: 'Export Form',
12
- type: 'Type',
13
- exportType: 'Export type',
14
- status: 'status',
15
- message: 'Message',
16
- log: 'Log',
17
- file: 'file',
18
- newExport: 'New export',
19
- exportCreation: 'Export creation',
20
- success: 'Success',
21
- error: 'Error',
22
- createdSuccessMessage: 'Export has been successfully created',
23
- createdErrorMessage: 'Export creation has been failed',
24
- filename: 'File name',
25
- format: 'Format',
26
- };
27
-
28
- const RU = {
29
- home: 'Главная',
30
- exportAndImport: 'Экспорт / Импорт',
31
- export: 'Экспорт',
32
- exportList: 'Список экспортов',
33
- exportForm: 'Форма экспорта',
34
- type: 'Тип',
35
- exportType: 'Тип экспорта',
36
- status: 'Статус',
37
- message: 'Сообщение',
38
- log: 'Лог',
39
- file: 'Файл',
40
- newExport: 'Новый экспорт',
41
- exportCreation: 'Создание экспорта',
42
- success: 'Успех',
43
- error: 'Ошибка',
44
- createdSuccessMessage: 'Экспорт была успешно создан',
45
- createdErrorMessage: 'Создание экспорта не удалось',
46
- filename: 'Имя файла',
47
- format: 'Формат',
48
- };
49
-
50
- function getExportList(params) {
51
- return request.get({ path: '/admin/tager/export', params });
52
- }
53
- function getStrategyList() {
54
- return request.get({ path: '/admin/tager/export/strategies' });
55
- }
56
- function createExport(payload) {
57
- return request.post({ path: '/admin/tager/export', body: payload });
58
- }
59
-
60
- const EXPORT_ROUTE_PATHS = {
61
- EXPORT_LIST: '/export',
62
- EXPORT_FORM: '/export/:exportId',
63
- };
64
-
65
- function getExportListUrl() {
66
- return EXPORT_ROUTE_PATHS.EXPORT_LIST;
67
- }
68
- function getExportFormUrl(params) {
69
- return compile(EXPORT_ROUTE_PATHS.EXPORT_FORM)(params);
70
- }
71
-
72
- var script = defineComponent({
73
- name: 'ExportList',
74
- setup(props, context) {
75
- const { t } = useTranslation(context);
76
- const { fetchEntityList: fetchExportList, isLoading: isExportListLoading, rowData: exportList, errorMessage, searchQuery, handleChange, pageSize, pageCount, pageNumber, } = useDataTable({
77
- fetchEntityList: (params) => getExportList({
78
- pageNumber: params.pageNumber,
79
- pageSize: params.pageSize,
80
- }),
81
- initialValue: [],
82
- context,
83
- resourceName: 'Export list',
84
- pageSize: 100,
85
- });
86
- onMounted(() => {
87
- fetchExportList();
88
- });
89
- const columnDefs = [
90
- {
91
- id: 1,
92
- name: 'ID',
93
- field: 'id',
94
- style: { width: '50px', textAlign: 'center' },
95
- headStyle: { width: '50px', textAlign: 'center' },
96
- },
97
- {
98
- id: 2,
99
- name: t('export:type'),
100
- field: 'strategy',
101
- style: { width: '15%' },
102
- headStyle: { width: '15%' },
103
- },
104
- {
105
- id: 3,
106
- name: t('export:status'),
107
- field: 'status',
108
- style: { width: '15%' },
109
- headStyle: { width: '15%' },
110
- },
111
- {
112
- id: 4,
113
- name: t('export:message'),
114
- field: 'message',
115
- },
116
- {
117
- id: 5,
118
- name: t('export:log'),
119
- field: 'history',
120
- style: { width: '25%' },
121
- headStyle: { width: '25%' },
122
- },
123
- {
124
- id: 6,
125
- name: t('export:file'),
126
- field: 'file',
127
- type: 'file',
128
- style: { width: '150px', textAlign: 'center' },
129
- headStyle: { width: '150px', textAlign: 'center' },
130
- },
131
- ];
132
- function dateTimeFormat(value) {
133
- const options = {
134
- year: 'numeric',
135
- month: 'numeric',
136
- day: 'numeric',
137
- hour: 'numeric',
138
- minute: 'numeric',
139
- second: 'numeric',
140
- };
141
- const date = new Date(value);
142
- return new Intl.DateTimeFormat('ru-RU', options).format(date);
143
- }
144
- return {
145
- columnDefs,
146
- getExportFormUrl,
147
- rowData: exportList,
148
- isRowDataLoading: isExportListLoading,
149
- errorMessage: errorMessage,
150
- searchQuery,
151
- handleChange,
152
- pageSize,
153
- pageCount,
154
- pageNumber,
155
- t,
156
- dateTimeFormat,
157
- };
158
- },
159
- });
160
-
161
- function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
162
- if (typeof shadowMode !== 'boolean') {
163
- createInjectorSSR = createInjector;
164
- createInjector = shadowMode;
165
- shadowMode = false;
166
- }
167
- // Vue.extend constructor export interop.
168
- const options = typeof script === 'function' ? script.options : script;
169
- // render functions
170
- if (template && template.render) {
171
- options.render = template.render;
172
- options.staticRenderFns = template.staticRenderFns;
173
- options._compiled = true;
174
- // functional template
175
- if (isFunctionalTemplate) {
176
- options.functional = true;
177
- }
178
- }
179
- // scopedId
180
- if (scopeId) {
181
- options._scopeId = scopeId;
182
- }
183
- let hook;
184
- if (moduleIdentifier) {
185
- // server build
186
- hook = function (context) {
187
- // 2.3 injection
188
- context =
189
- context || // cached call
190
- (this.$vnode && this.$vnode.ssrContext) || // stateful
191
- (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
192
- // 2.2 with runInNewContext: true
193
- if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
194
- context = __VUE_SSR_CONTEXT__;
195
- }
196
- // inject component styles
197
- if (style) {
198
- style.call(this, createInjectorSSR(context));
199
- }
200
- // register component module identifier for async chunk inference
201
- if (context && context._registeredComponents) {
202
- context._registeredComponents.add(moduleIdentifier);
203
- }
204
- };
205
- // used by ssr in case component is cached and beforeCreate
206
- // never gets called
207
- options._ssrRegister = hook;
208
- }
209
- else if (style) {
210
- hook = shadowMode
211
- ? function (context) {
212
- style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
213
- }
214
- : function (context) {
215
- style.call(this, createInjector(context));
216
- };
217
- }
218
- if (hook) {
219
- if (options.functional) {
220
- // register for functional component in vue file
221
- const originalRender = options.render;
222
- options.render = function renderWithStyleInjection(h, context) {
223
- hook.call(context);
224
- return originalRender(h, context);
225
- };
226
- }
227
- else {
228
- // inject component registration as beforeCreate hook
229
- const existing = options.beforeCreate;
230
- options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
231
- }
232
- }
233
- return script;
234
- }
235
-
236
- /* script */
237
- const __vue_script__ = script;
238
-
239
- /* template */
240
- var __vue_render__ = function () {
241
- var _vm = this;
242
- var _h = _vm.$createElement;
243
- var _c = _vm._self._c || _h;
244
- return _c(
245
- "page",
246
- {
247
- attrs: {
248
- title: _vm.t("export:export"),
249
- "header-buttons": [
250
- {
251
- text: _vm.t("export:newExport"),
252
- href: _vm.getExportFormUrl({ exportId: "create" }),
253
- },
254
- ],
255
- },
256
- },
257
- [
258
- _c("data-table", {
259
- attrs: {
260
- "column-defs": _vm.columnDefs,
261
- "row-data": _vm.rowData,
262
- loading: _vm.isRowDataLoading,
263
- "error-message": _vm.errorMessage,
264
- pagination: {
265
- pageSize: _vm.pageSize,
266
- pageCount: _vm.pageCount,
267
- pageNumber: _vm.pageNumber,
268
- disabled: _vm.isRowDataLoading,
269
- },
270
- "use-search": false,
271
- },
272
- on: { change: _vm.handleChange },
273
- scopedSlots: _vm._u([
274
- {
275
- key: "cell(history)",
276
- fn: function (ref) {
277
- var row = ref.row;
278
- return [
279
- row.history
280
- ? _c(
281
- "ul",
282
- _vm._l(row.history, function (history, index) {
283
- return _c("li", { key: index }, [
284
- _c(
285
- "span",
286
- {
287
- style: {
288
- width: "100px",
289
- display: "inline-block",
290
- },
291
- },
292
- [_vm._v(_vm._s(history.status))]
293
- ),
294
- _vm._v(
295
- "\n " +
296
- _vm._s(_vm.dateTimeFormat(history.datetime)) +
297
- "\n "
298
- ),
299
- ])
300
- }),
301
- 0
302
- )
303
- : _vm._e(),
304
- ]
305
- },
306
- },
307
- ]),
308
- }),
309
- ],
310
- 1
311
- )
312
- };
313
- var __vue_staticRenderFns__ = [];
314
- __vue_render__._withStripped = true;
315
-
316
- /* style */
317
- const __vue_inject_styles__ = undefined;
318
- /* scoped */
319
- const __vue_scope_id__ = undefined;
320
- /* module identifier */
321
- const __vue_module_identifier__ = undefined;
322
- /* functional template */
323
- const __vue_is_functional_template__ = false;
324
- /* style inject */
325
-
326
- /* style inject SSR */
327
-
328
- /* style inject shadow dom */
329
-
330
-
331
-
332
- const __vue_component__ = /*#__PURE__*/normalizeComponent(
333
- { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
334
- __vue_inject_styles__,
335
- __vue_script__,
336
- __vue_scope_id__,
337
- __vue_is_functional_template__,
338
- __vue_module_identifier__,
339
- false,
340
- undefined,
341
- undefined,
342
- undefined
343
- );
344
-
345
- function replaceFileExtension(fileName, newExtension) {
346
- const dotIndex = fileName.lastIndexOf('.');
347
- const fileNameWithoutExtension = fileName.slice(0, dotIndex);
348
- if (newExtension) {
349
- return `${fileNameWithoutExtension}.${newExtension}`;
350
- }
351
- return fileNameWithoutExtension;
352
- }
353
-
354
- function convertExportFormValuesToCreationPayload(values) {
355
- var _a, _b, _c, _d;
356
- return {
357
- strategy: (_b = (_a = values.strategy) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : '',
358
- filename: values.filename,
359
- format: (_d = (_c = values.format) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : '',
360
- };
361
- }
362
-
363
- var script$1 = defineComponent({
364
- name: 'ExportForm',
365
- components: { FormFooter },
366
- setup(props, context) {
367
- const { t } = useTranslation(context);
368
- /** Strategies */
369
- const [fetchStrategyList, { data: strategyList, loading: isStrategyListLoading },] = useResource({
370
- fetchResource: getStrategyList,
371
- initialValue: [],
372
- context,
373
- resourceName: 'Strategy List',
374
- });
375
- const strategyOptionList = computed(() => strategyList.value.map((strategy) => ({
376
- value: strategy.id,
377
- label: strategy.name,
378
- })));
379
- onMounted(() => {
380
- fetchStrategyList();
381
- });
382
- /** Format **/
383
- const formatOptionList = computed(() => [
384
- { value: 'CSV', label: 'CSV' },
385
- { value: 'XLS', label: 'XLS' },
386
- ]);
387
- /** Form state */
388
- const defaultExtension = formatOptionList.value[0];
389
- const errors = ref({});
390
- const values = ref({
391
- strategy: null,
392
- filename: `export.${defaultExtension.value.toLowerCase()}`,
393
- format: defaultExtension,
394
- });
395
- const isSubmitting = ref(false);
396
- watch(() => values.value.format, () => {
397
- var _a;
398
- const newExtension = (_a = values.value.format) === null || _a === void 0 ? void 0 : _a.value.toLowerCase();
399
- values.value.filename = replaceFileExtension(values.value.filename, newExtension || '');
400
- });
401
- function submitForm(event) {
402
- isSubmitting.value = true;
403
- const creationPayload = convertExportFormValuesToCreationPayload(values.value);
404
- createExport(creationPayload)
405
- .then(() => {
406
- errors.value = {};
407
- if (event.type === 'create' ||
408
- event.type === 'save' ||
409
- event.type === 'create_exit' ||
410
- event.type === 'save_exit') {
411
- context.root.$router.push(getExportListUrl());
412
- }
413
- context.root.$toast({
414
- variant: 'success',
415
- title: t('export:success'),
416
- body: t('export:createdSuccessMessage'),
417
- });
418
- })
419
- .catch((error) => {
420
- console.error(error);
421
- errors.value = convertRequestErrorToMap(error);
422
- context.root.$toast({
423
- variant: 'danger',
424
- title: t('export:error'),
425
- body: t('export:createdErrorMessage'),
426
- });
427
- })
428
- .finally(() => {
429
- isSubmitting.value = false;
430
- });
431
- }
432
- /** Is content loading **/
433
- const isContentLoading = computed(() => isStrategyListLoading.value);
434
- return {
435
- values,
436
- errors,
437
- isSubmitting,
438
- submitForm,
439
- getExportListUrl,
440
- strategyOptionList,
441
- formatOptionList,
442
- isContentLoading,
443
- };
444
- },
445
- });
446
-
447
- const isOldIE = typeof navigator !== 'undefined' &&
448
- /msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
449
- function createInjector(context) {
450
- return (id, style) => addStyle(id, style);
451
- }
452
- let HEAD;
453
- const styles = {};
454
- function addStyle(id, css) {
455
- const group = isOldIE ? css.media || 'default' : id;
456
- const style = styles[group] || (styles[group] = { ids: new Set(), styles: [] });
457
- if (!style.ids.has(id)) {
458
- style.ids.add(id);
459
- let code = css.source;
460
- if (css.map) {
461
- // https://developer.chrome.com/devtools/docs/javascript-debugging
462
- // this makes source maps inside style tags work properly in Chrome
463
- code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
464
- // http://stackoverflow.com/a/26603875
465
- code +=
466
- '\n/*# sourceMappingURL=data:application/json;base64,' +
467
- btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) +
468
- ' */';
469
- }
470
- if (!style.element) {
471
- style.element = document.createElement('style');
472
- style.element.type = 'text/css';
473
- if (css.media)
474
- style.element.setAttribute('media', css.media);
475
- if (HEAD === undefined) {
476
- HEAD = document.head || document.getElementsByTagName('head')[0];
477
- }
478
- HEAD.appendChild(style.element);
479
- }
480
- if ('styleSheet' in style.element) {
481
- style.styles.push(code);
482
- style.element.styleSheet.cssText = style.styles
483
- .filter(Boolean)
484
- .join('\n');
485
- }
486
- else {
487
- const index = style.ids.size - 1;
488
- const textNode = document.createTextNode(code);
489
- const nodes = style.element.childNodes;
490
- if (nodes[index])
491
- style.element.removeChild(nodes[index]);
492
- if (nodes.length)
493
- style.element.insertBefore(textNode, nodes[index]);
494
- else
495
- style.element.appendChild(textNode);
496
- }
497
- }
498
- }
499
-
500
- /* script */
501
- const __vue_script__$1 = script$1;
502
-
503
- /* template */
504
- var __vue_render__$1 = function () {
505
- var _vm = this;
506
- var _h = _vm.$createElement;
507
- var _c = _vm._self._c || _h;
508
- return _c(
509
- "page",
510
- {
511
- attrs: {
512
- title: _vm.$t("export:newExport"),
513
- "is-content-loading": _vm.isContentLoading,
514
- },
515
- scopedSlots: _vm._u([
516
- {
517
- key: "footer",
518
- fn: function () {
519
- return [
520
- _c("FormFooter", {
521
- attrs: {
522
- "back-href": _vm.getExportListUrl(),
523
- "on-submit": _vm.submitForm,
524
- "is-submitting": _vm.isSubmitting,
525
- "is-creation": true,
526
- },
527
- }),
528
- ]
529
- },
530
- proxy: true,
531
- },
532
- ]),
533
- },
534
- [
535
- _c(
536
- "form",
537
- {
538
- attrs: { novalidate: "" },
539
- on: {
540
- submit: function ($event) {
541
- $event.preventDefault();
542
- },
543
- },
544
- },
545
- [
546
- [
547
- _c("form-field-select", {
548
- attrs: {
549
- options: _vm.strategyOptionList,
550
- error: _vm.errors.strategy,
551
- label: _vm.$t("export:exportType"),
552
- name: "exportType",
553
- },
554
- model: {
555
- value: _vm.values.strategy,
556
- callback: function ($$v) {
557
- _vm.$set(_vm.values, "strategy", $$v);
558
- },
559
- expression: "values.strategy",
560
- },
561
- }),
562
- _vm._v(" "),
563
- _c(
564
- "div",
565
- { staticClass: "field" },
566
- [
567
- _c("form-field", {
568
- attrs: {
569
- error: _vm.errors.filename,
570
- label: _vm.$t("export:filename"),
571
- name: "filename",
572
- },
573
- model: {
574
- value: _vm.values.filename,
575
- callback: function ($$v) {
576
- _vm.$set(_vm.values, "filename", $$v);
577
- },
578
- expression: "values.filename",
579
- },
580
- }),
581
- _vm._v(" "),
582
- _c("form-field-select", {
583
- attrs: {
584
- options: _vm.formatOptionList,
585
- error: _vm.errors.format,
586
- label: _vm.$t("export:format"),
587
- name: "format",
588
- },
589
- model: {
590
- value: _vm.values.format,
591
- callback: function ($$v) {
592
- _vm.$set(_vm.values, "format", $$v);
593
- },
594
- expression: "values.format",
595
- },
596
- }),
597
- ],
598
- 1
599
- ),
600
- ],
601
- ],
602
- 2
603
- ),
604
- ]
605
- )
606
- };
607
- var __vue_staticRenderFns__$1 = [];
608
- __vue_render__$1._withStripped = true;
609
-
610
- /* style */
611
- const __vue_inject_styles__$1 = function (inject) {
612
- if (!inject) return
613
- inject("data-v-338d6125_0", { source: ".field[data-v-338d6125] {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n column-gap: 20px;\n}\n\n/*# sourceMappingURL=ExportForm.vue.map */", map: {"version":3,"sources":["/home/runner/work/tager-admin-export/tager-admin-export/src/views/ExportForm/ExportForm.vue","ExportForm.vue"],"names":[],"mappings":"AAwLA;EACA,aAAA;EACA,qCAAA;EACA,gBAAA;ACvLA;;AAEA,yCAAyC","file":"ExportForm.vue","sourcesContent":["<template>\n <page :title=\"$t('export:newExport')\" :is-content-loading=\"isContentLoading\">\n <form novalidate @submit.prevent>\n <template>\n <form-field-select\n v-model=\"values.strategy\"\n :options=\"strategyOptionList\"\n :error=\"errors.strategy\"\n :label=\"$t('export:exportType')\"\n name=\"exportType\"\n />\n\n <div class=\"field\">\n <form-field\n v-model=\"values.filename\"\n :error=\"errors.filename\"\n :label=\"$t('export:filename')\"\n name=\"filename\"\n />\n\n <form-field-select\n v-model=\"values.format\"\n :options=\"formatOptionList\"\n :error=\"errors.format\"\n :label=\"$t('export:format')\"\n name=\"format\"\n />\n </div>\n </template>\n </form>\n\n <template v-slot:footer>\n <FormFooter\n :back-href=\"getExportListUrl()\"\n :on-submit=\"submitForm\"\n :is-submitting=\"isSubmitting\"\n :is-creation=\"true\"\n />\n </template>\n </page>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, watch } from '@vue/composition-api';\nimport { computed, onMounted, ref } from '@vue/composition-api';\n\nimport { convertRequestErrorToMap, useResource } from '@tager/admin-services';\nimport {\n OptionType,\n TagerFormSubmitEvent,\n FormFooter,\n useTranslation,\n} from '@tager/admin-ui';\n\nimport { createExport, getStrategyList } from '../../services/requests';\nimport { getExportListUrl } from '../../utils/paths';\nimport { replaceFileExtension } from '../../utils/common';\n\nimport {\n convertExportFormValuesToCreationPayload,\n FormValues,\n} from './ExportForm.helpers';\n\nexport default defineComponent({\n name: 'ExportForm',\n components: { FormFooter },\n setup(props, context) {\n const { t } = useTranslation(context);\n\n /** Strategies */\n\n const [\n fetchStrategyList,\n { data: strategyList, loading: isStrategyListLoading },\n ] = useResource({\n fetchResource: getStrategyList,\n initialValue: [],\n context,\n resourceName: 'Strategy List',\n });\n\n const strategyOptionList = computed<Array<OptionType>>(() =>\n strategyList.value.map<OptionType>((strategy) => ({\n value: strategy.id,\n label: strategy.name,\n }))\n );\n\n onMounted(() => {\n fetchStrategyList();\n });\n\n /** Format **/\n\n const formatOptionList = computed<Array<OptionType>>(() => [\n { value: 'CSV', label: 'CSV' },\n { value: 'XLS', label: 'XLS' },\n ]);\n\n /** Form state */\n\n const defaultExtension = formatOptionList.value[0];\n\n const errors = ref<Record<string, string>>({});\n const values = ref<FormValues>({\n strategy: null,\n filename: `export.${defaultExtension.value.toLowerCase()}`,\n format: defaultExtension,\n });\n const isSubmitting = ref<boolean>(false);\n\n watch(\n () => values.value.format,\n () => {\n const newExtension = values.value.format?.value.toLowerCase();\n\n values.value.filename = replaceFileExtension(\n values.value.filename,\n newExtension || ''\n );\n }\n );\n\n function submitForm(event: TagerFormSubmitEvent) {\n isSubmitting.value = true;\n\n const creationPayload = convertExportFormValuesToCreationPayload(\n values.value\n );\n\n createExport(creationPayload)\n .then(() => {\n errors.value = {};\n\n if (\n event.type === 'create' ||\n event.type === 'save' ||\n event.type === 'create_exit' ||\n event.type === 'save_exit'\n ) {\n context.root.$router.push(getExportListUrl());\n }\n\n context.root.$toast({\n variant: 'success',\n title: t('export:success'),\n body: t('export:createdSuccessMessage'),\n });\n })\n .catch((error) => {\n console.error(error);\n errors.value = convertRequestErrorToMap(error);\n context.root.$toast({\n variant: 'danger',\n title: t('export:error'),\n body: t('export:createdErrorMessage'),\n });\n })\n .finally(() => {\n isSubmitting.value = false;\n });\n }\n\n /** Is content loading **/\n\n const isContentLoading = computed<boolean>(\n () => isStrategyListLoading.value\n );\n\n return {\n values,\n errors,\n isSubmitting,\n submitForm,\n getExportListUrl,\n strategyOptionList,\n formatOptionList,\n isContentLoading,\n };\n },\n});\n</script>\n\n<style lang=\"scss\" scoped>\n.field {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n column-gap: 20px;\n}\n</style>\n",".field {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n column-gap: 20px;\n}\n\n/*# sourceMappingURL=ExportForm.vue.map */"]}, media: undefined });
614
-
615
- };
616
- /* scoped */
617
- const __vue_scope_id__$1 = "data-v-338d6125";
618
- /* module identifier */
619
- const __vue_module_identifier__$1 = undefined;
620
- /* functional template */
621
- const __vue_is_functional_template__$1 = false;
622
- /* style inject SSR */
623
-
624
- /* style inject shadow dom */
625
-
626
-
627
-
628
- const __vue_component__$1 = /*#__PURE__*/normalizeComponent(
629
- { render: __vue_render__$1, staticRenderFns: __vue_staticRenderFns__$1 },
630
- __vue_inject_styles__$1,
631
- __vue_script__$1,
632
- __vue_scope_id__$1,
633
- __vue_is_functional_template__$1,
634
- __vue_module_identifier__$1,
635
- false,
636
- createInjector,
637
- undefined,
638
- undefined
639
- );
640
-
641
- const EXPORT_LIST_ROUTE = {
642
- path: EXPORT_ROUTE_PATHS.EXPORT_LIST,
643
- component: __vue_component__,
644
- name: 'Export List',
645
- meta: {
646
- getBreadcrumbs: (route, t) => [
647
- { url: '/', text: t('export:home') },
648
- { url: route.path, text: t('export:export') },
649
- ],
650
- },
651
- };
652
- const EXPORT_FORM_ROUTE = {
653
- path: EXPORT_ROUTE_PATHS.EXPORT_FORM,
654
- component: __vue_component__$1,
655
- name: 'Export Form',
656
- meta: {
657
- getBreadcrumbs: (route, t) => [
658
- { url: '/', text: t('export:home') },
659
- { url: EXPORT_LIST_ROUTE.path, text: t('export:export') },
660
- { url: route.path, text: t('export:newExport') },
661
- ],
662
- },
663
- };
664
-
665
- i18n.addTranslations('en', 'export', EN);
666
- i18n.addTranslations('ru', 'export', RU);
667
-
668
- export { EXPORT_FORM_ROUTE, EXPORT_LIST_ROUTE, createExport, getExportFormUrl, getExportList, getExportListUrl, getStrategyList };