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