@tager/admin-import 0.1.3 → 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.
Files changed (51) 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 +6 -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 +405 -0
  8. package/dist/locales/apply.d.ts +1 -0
  9. package/dist/locales/en.d.ts +19 -21
  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 -33
  15. package/dist/utils/paths.d.ts +4 -4
  16. package/dist/views/ImportForm/ImportForm.helpers.d.ts +9 -9
  17. package/dist/views/ImportForm/ImportForm.vue.d.ts +4163 -9238
  18. package/dist/views/ImportForm/index.d.ts +1 -1
  19. package/dist/views/ImportList/ImportList.vue.d.ts +17 -38
  20. package/dist/views/ImportList/components/CellHistory/CellHistory.helpers.d.ts +1 -1
  21. package/dist/views/ImportList/components/CellHistory/CellHistory.vue.d.ts +20 -230
  22. package/dist/views/ImportList/components/CellHistory/index.d.ts +1 -1
  23. package/dist/views/ImportList/index.d.ts +1 -1
  24. package/package.json +46 -49
  25. package/src/constants/routes.ts +10 -10
  26. package/src/dev/App.vue +40 -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 +1 -4
  32. package/src/locales/ru.ts +19 -22
  33. package/src/main.ts +2 -6
  34. package/src/services/requests.ts +4 -4
  35. package/src/typings/model.ts +4 -4
  36. package/src/views/ImportForm/ImportForm.helpers.ts +3 -3
  37. package/src/views/ImportForm/ImportForm.vue +84 -81
  38. package/src/views/ImportList/ImportList.vue +45 -42
  39. package/src/views/ImportList/components/CellHistory/CellHistory.helpers.ts +6 -5
  40. package/src/views/ImportList/components/CellHistory/CellHistory.vue +5 -6
  41. package/README.md +0 -1
  42. package/dist/dev.d.ts +0 -1
  43. package/dist/index.esm.js +0 -3624
  44. package/dist/index.umd.js +0 -3636
  45. package/dist/views/ImportList/components/CellHistory/CellHistory.types.d.ts +0 -4
  46. package/src/dev.ts +0 -41
  47. package/src/typings/sfc.d.ts +0 -12
  48. package/src/typings/shims-tsx.d.ts +0 -13
  49. package/src/typings/shims-vue.d.ts +0 -11
  50. package/src/views/App.vue +0 -34
  51. package/src/views/ImportList/components/CellHistory/CellHistory.types.ts +0 -5
package/src/locales/ru.ts CHANGED
@@ -1,24 +1,21 @@
1
- import EN from './en';
1
+ import {EN} from './en';
2
2
 
3
- const RU: typeof EN = {
4
- home: 'Главная',
5
- exportAndImport: 'Экспорт / Импорт',
6
- import: 'Импорт',
7
- importList: 'Список импортов',
8
- importForm: 'Форма импорта',
9
- type: 'Тип',
10
- importType: 'Тип импорта',
11
- status: 'Статус',
12
- message: 'Сообщение',
13
- log: 'Лог',
14
- params: 'Параметры',
15
- file: 'Файл',
16
- newImport: 'Новый импорт',
17
- importCreation: 'Создание импорта',
18
- success: 'Успех',
19
- error: 'Ошибка',
20
- createdSuccessMessage: 'Импорт была успешно создан',
21
- createdErrorMessage: 'Создание импорта не удалось',
3
+ export const RU: typeof EN = {
4
+ home: 'Главная',
5
+ import: 'Импорт',
6
+ importList: 'Список импортов',
7
+ importForm: 'Форма импорта',
8
+ type: 'Тип',
9
+ importType: 'Тип импорта',
10
+ status: 'Статус',
11
+ message: 'Сообщение',
12
+ log: 'Лог',
13
+ params: 'Параметры',
14
+ file: 'Файл',
15
+ newImport: 'Новый импорт',
16
+ importCreation: 'Создание импорта',
17
+ success: 'Успех',
18
+ error: 'Ошибка',
19
+ createdSuccessMessage: 'Импорт была успешно создан',
20
+ createdErrorMessage: 'Создание импорта не удалось',
22
21
  };
23
-
24
- export default RU;
package/src/main.ts CHANGED
@@ -1,10 +1,6 @@
1
- import { i18n } from '@tager/admin-services';
1
+ import { applyTranslations } from './locales/apply';
2
2
 
3
- import EN from './locales/en';
4
- import RU from './locales/ru';
5
-
6
- i18n.addTranslations('en', 'import', EN);
7
- i18n.addTranslations('ru', 'import', RU);
3
+ applyTranslations();
8
4
 
9
5
  export * from './constants/routes';
10
6
  export * from './utils/paths';
@@ -1,9 +1,9 @@
1
- import { request, ResponseBody } from '@tager/admin-services';
1
+ import { request, type ResponseBody } from '@tager/admin-services';
2
2
 
3
3
  import {
4
- ModuleInfoType,
5
- ImportCreatePayload,
6
- ImportType,
4
+ type ModuleInfoType,
5
+ type ImportCreatePayload,
6
+ type ImportType,
7
7
  } from '../typings/model';
8
8
 
9
9
  export function getImportList(params?: {
@@ -1,8 +1,8 @@
1
- import { FileType } from '@tager/admin-services';
1
+ import { type FileType } from '@tager/admin-services';
2
2
  import {
3
- FieldConfigUnion,
4
- FieldShortType,
5
- OutgoingValueUnion,
3
+ type FieldConfigUnion,
4
+ type FieldShortType,
5
+ type OutgoingValueUnion,
6
6
  } from '@tager/admin-dynamic-field';
7
7
 
8
8
  export interface HistoryType {
@@ -1,7 +1,7 @@
1
- import { OptionType, SingleFileInputValueType } from '@tager/admin-ui';
2
- import { FieldUnion, universalFieldUtils } from '@tager/admin-dynamic-field';
1
+ import { type OptionType, type SingleFileInputValueType } from '@tager/admin-ui';
2
+ import { type FieldUnion, universalFieldUtils } from '@tager/admin-dynamic-field';
3
3
 
4
- import { ImportCreatePayload, StrategyType } from '../../typings/model';
4
+ import { type ImportCreatePayload, type StrategyType } from '../../typings/model';
5
5
 
6
6
  export type FormValues = {
7
7
  strategy: OptionType | null;
@@ -1,97 +1,100 @@
1
1
  <template>
2
- <page
3
- :title="$t('import:importCreation')"
4
- :is-content-loading="isContentLoading"
2
+ <Page
3
+ :title="$i18n.t('import:importCreation')"
4
+ :is-content-loading="isContentLoading"
5
5
  >
6
6
  <form novalidate @submit.prevent>
7
- <form-field-select
8
- v-model="values.strategy"
9
- :options="strategyOptionList"
10
- :error="errors.strategy"
11
- name="importType"
12
- :label="$t('import:importType')"
7
+ <FormFieldSelect
8
+ v-model:value="values.strategy"
9
+ :options="strategyOptionList"
10
+ :error="errors.strategy"
11
+ name="importType"
12
+ :label="$i18n.t('import:importType')"
13
13
  />
14
14
 
15
- <form-field-file-input
16
- v-model="values.file"
17
- :error="errors.file"
18
- :label="$t('import:file')"
19
- name="file"
20
- :scenario="strategyFileScenario"
15
+ <FormFieldFileInput
16
+ v-model:value="values.file"
17
+ :error="errors.file"
18
+ :label="$i18n.t('import:file')"
19
+ name="file"
20
+ :scenario="strategyFileScenario"
21
21
  />
22
22
 
23
23
  <DynamicField
24
- v-for="field of templateValues"
25
- :key="field.config.name"
26
- :field="field"
24
+ v-for="field of templateValues"
25
+ :key="field.config.name"
26
+ :field="field"
27
27
  />
28
28
  </form>
29
29
 
30
- <template v-slot:footer>
30
+ <template #footer>
31
31
  <FormFooter
32
- :back-href="getImportListUrl()"
33
- :on-submit="submitForm"
34
- :is-submitting="isSubmitting"
35
- :is-creation="true"
32
+ :back-href="getImportListUrl()"
33
+ :is-submitting="isSubmitting"
34
+ :is-creation="true"
35
+ @submit="submitForm"
36
36
  />
37
37
  </template>
38
- </page>
38
+ </Page>
39
39
  </template>
40
40
 
41
41
  <script lang="ts">
42
- import { defineComponent, watch } from '@vue/composition-api';
43
- import { computed, onMounted, ref } from '@vue/composition-api';
42
+ import {defineComponent, watch, computed, onMounted, ref} from 'vue';
43
+ import {useRouter} from "vue-router";
44
44
 
45
- import { convertRequestErrorToMap, useResource } from '@tager/admin-services';
45
+ import {convertRequestErrorToMap, navigateBack, useI18n, useResource, useToast} from '@tager/admin-services';
46
46
  import {
47
- OptionType,
48
- TagerFormSubmitEvent,
47
+ type OptionType,
48
+ type TagerFormSubmitEvent,
49
49
  FormFooter,
50
- useTranslation,
50
+ FormFieldFileInput, FormFieldSelect
51
51
  } from '@tager/admin-ui';
52
52
  import {
53
53
  DynamicField,
54
- FieldConfigUnion,
55
- FieldUnion,
54
+ type FieldConfigUnion,
55
+ type FieldUnion,
56
56
  universalFieldUtils,
57
57
  } from '@tager/admin-dynamic-field';
58
+ import {Page} from "@tager/admin-layout";
58
59
 
59
- import { createImport, getModuleInfo } from '../../services/requests';
60
- import { getImportListUrl } from '../../utils/paths';
60
+ import {createImport, getModuleInfo} from '../../services/requests';
61
+ import {getImportListUrl} from '../../utils/paths';
61
62
 
62
63
  import {
63
64
  convertImportFormValuesToCreationPayload,
64
65
  convertStrategiesToStrategyOptionList,
65
- FormValues,
66
+ type FormValues,
66
67
  } from './ImportForm.helpers';
67
68
 
68
69
  export default defineComponent({
69
70
  name: 'ImportForm',
70
- components: { DynamicField, FormFooter },
71
- setup(props, context) {
72
- const { t } = useTranslation(context);
71
+ components: {Page, FormFieldFileInput, DynamicField, FormFooter, FormFieldSelect},
72
+ setup() {
73
+ const {t} = useI18n();
74
+
75
+ const toast = useToast();
76
+ const router = useRouter();
73
77
 
74
78
  /** Strategies */
75
79
 
76
80
  const [
77
81
  fetchModuleInfo,
78
- { data: moduleInfo, loading: isModuleInfoLoading },
82
+ {data: moduleInfo, loading: isModuleInfoLoading},
79
83
  ] = useResource({
80
84
  fetchResource: getModuleInfo,
81
85
  initialValue: {
82
86
  fileScenario: '',
83
87
  strategies: [],
84
88
  },
85
- context,
86
89
  resourceName: 'Module info',
87
90
  });
88
91
 
89
92
  const strategyFileScenario = computed<string>(
90
- () => moduleInfo.value.fileScenario
93
+ () => moduleInfo.value.fileScenario
91
94
  );
92
95
 
93
96
  const strategyOptionList = computed<Array<OptionType>>(() =>
94
- convertStrategiesToStrategyOptionList(moduleInfo.value.strategies)
97
+ convertStrategiesToStrategyOptionList(moduleInfo.value.strategies)
95
98
  );
96
99
 
97
100
  onMounted(() => {
@@ -101,28 +104,28 @@ export default defineComponent({
101
104
  /** Form state */
102
105
 
103
106
  const errors = ref<Record<string, string>>({});
104
- const values = ref<FormValues>({ strategy: null, file: null });
107
+ const values = ref<FormValues>({strategy: null, file: null});
105
108
  const isSubmitting = ref<boolean>(false);
106
109
  const templateValues = ref<Array<FieldUnion>>([]);
107
110
 
108
111
  function updateTemplateValues() {
109
112
  const selectedStrategy = moduleInfo.value.strategies.find(
110
- (strategy) => strategy.id === values.value.strategy?.value
113
+ (strategy) => strategy.id === values.value.strategy?.value
111
114
  );
112
115
 
113
116
  const fieldTemplateList: Array<FieldConfigUnion> =
114
- selectedStrategy?.fields ?? [];
117
+ selectedStrategy?.fields ?? [];
115
118
 
116
119
  templateValues.value = fieldTemplateList.map((fieldConfig) =>
117
- universalFieldUtils.createFormField(fieldConfig, null)
120
+ universalFieldUtils.createFormField(fieldConfig, null)
118
121
  );
119
122
  }
120
123
 
121
124
  watch(
122
- () => values.value.strategy,
123
- () => {
124
- updateTemplateValues();
125
- }
125
+ () => values.value.strategy,
126
+ () => {
127
+ updateTemplateValues();
128
+ }
126
129
  );
127
130
 
128
131
  onMounted(() => {
@@ -133,41 +136,41 @@ export default defineComponent({
133
136
  isSubmitting.value = true;
134
137
 
135
138
  const creationPayload = convertImportFormValuesToCreationPayload(
136
- values.value,
137
- templateValues.value
139
+ values.value,
140
+ templateValues.value
138
141
  );
139
142
 
140
143
  createImport(creationPayload)
141
- .then(() => {
142
- errors.value = {};
143
-
144
- if (
145
- event.type === 'create' ||
146
- event.type === 'save' ||
147
- event.type === 'create_exit' ||
148
- event.type === 'save_exit'
149
- ) {
150
- context.root.$router.push(getImportListUrl());
151
- }
152
-
153
- context.root.$toast({
154
- variant: 'success',
155
- title: t('import:success'),
156
- body: t('import:createdSuccessMessage'),
157
- });
158
- })
159
- .catch((error) => {
160
- console.error(error);
161
- errors.value = convertRequestErrorToMap(error);
162
- context.root.$toast({
163
- variant: 'danger',
164
- title: t('import:error'),
165
- body: t('import:createdErrorMessage'),
144
+ .then(() => {
145
+ errors.value = {};
146
+
147
+ if (
148
+ event.type === 'create' ||
149
+ event.type === 'save' ||
150
+ event.type === 'create_exit' ||
151
+ event.type === 'save_exit'
152
+ ) {
153
+ navigateBack(router, getImportListUrl());
154
+ }
155
+
156
+ toast.show({
157
+ variant: 'success',
158
+ title: t('import:success'),
159
+ body: t('import:createdSuccessMessage'),
160
+ });
161
+ })
162
+ .catch((error) => {
163
+ console.error(error);
164
+ errors.value = convertRequestErrorToMap(error);
165
+ toast.show({
166
+ variant: 'danger',
167
+ title: t('import:error'),
168
+ body: t('import:createdErrorMessage'),
169
+ });
170
+ })
171
+ .finally(() => {
172
+ isSubmitting.value = false;
166
173
  });
167
- })
168
- .finally(() => {
169
- isSubmitting.value = false;
170
- });
171
174
  }
172
175
 
173
176
  /** Is content loading **/
@@ -1,54 +1,58 @@
1
1
  <template>
2
- <page
3
- :title="$t('import:import')"
4
- :header-buttons="[
2
+ <Page
3
+ :title="$i18n.t('import:import')"
4
+ :header-buttons="[
5
5
  {
6
- text: $t('import:newImport'),
6
+ text: $i18n.t('import:newImport'),
7
7
  href: getImportFormUrl({ importId: 'create' }),
8
8
  },
9
9
  ]"
10
10
  >
11
- <data-table
12
- :column-defs="columnDefs"
13
- :row-data="rowData"
14
- :loading="isRowDataLoading"
15
- :error-message="errorMessage"
16
- :pagination="{
11
+ <DataTable
12
+ :column-defs="columnDefs"
13
+ :row-data="rowData"
14
+ :loading="isRowDataLoading"
15
+ :error-message="errorMessage"
16
+ :pagination="{
17
17
  pageSize,
18
18
  pageCount,
19
19
  pageNumber,
20
20
  disabled: isRowDataLoading,
21
21
  }"
22
- :use-search="false"
23
- @change="handleChange"
22
+ :use-search="false"
23
+ @change="handleChange"
24
24
  >
25
- <template v-slot:cell(history)="{ row }">
26
- <CellHistory :history="row.history" />
25
+ <template #cell(history)="{ row }">
26
+ <CellHistory :history="row.history"/>
27
27
  </template>
28
- </data-table>
29
- </page>
28
+ </DataTable>
29
+ </Page>
30
30
  </template>
31
31
 
32
32
  <script lang="ts">
33
- import { defineComponent, onMounted } from '@vue/composition-api';
33
+ import {defineComponent, onMounted} from 'vue';
34
34
 
35
35
  import {
36
- ColumnDefinition,
36
+ type ColumnDefinition,
37
37
  useDataTable,
38
- useTranslation,
38
+ DataTable
39
39
  } from '@tager/admin-ui';
40
+ import {
41
+ Page
42
+ } from '@tager/admin-layout';
43
+ import {useI18n} from "@tager/admin-services";
40
44
 
41
- import { getImportList } from '../../services/requests';
42
- import { ImportType } from '../../typings/model';
43
- import { getImportFormUrl } from '../../utils/paths';
45
+ import {getImportList} from '../../services/requests';
46
+ import {type ImportType} from '../../typings/model';
47
+ import {getImportFormUrl} from '../../utils/paths';
44
48
 
45
- import { CellHistory } from './components/CellHistory';
49
+ import {CellHistory} from './components/CellHistory';
46
50
 
47
51
  export default defineComponent({
48
52
  name: 'ImportList',
49
- components: { CellHistory },
50
- setup(props, context) {
51
- const { t } = useTranslation(context);
53
+ components: {CellHistory, DataTable, Page},
54
+ setup() {
55
+ const {t} = useI18n();
52
56
 
53
57
  const {
54
58
  fetchEntityList: fetchImportList,
@@ -62,12 +66,11 @@ export default defineComponent({
62
66
  pageNumber,
63
67
  } = useDataTable<ImportType>({
64
68
  fetchEntityList: (params) =>
65
- getImportList({
66
- pageNumber: params.pageNumber,
67
- pageSize: params.pageSize,
68
- }),
69
+ getImportList({
70
+ pageNumber: params.pageNumber,
71
+ pageSize: params.pageSize,
72
+ }),
69
73
  initialValue: [],
70
- context,
71
74
  resourceName: 'Import list',
72
75
  pageSize: 100,
73
76
  });
@@ -81,22 +84,22 @@ export default defineComponent({
81
84
  id: 1,
82
85
  name: 'ID',
83
86
  field: 'id',
84
- style: { width: '50px', textAlign: 'center' },
85
- headStyle: { width: '50px', textAlign: 'center' },
87
+ style: {width: '50px', textAlign: 'center'},
88
+ headStyle: {width: '50px', textAlign: 'center'},
86
89
  },
87
90
  {
88
91
  id: 2,
89
92
  name: t('import:type'),
90
93
  field: 'strategy',
91
- style: { width: '150px' },
92
- headStyle: { width: '150px' },
94
+ style: {width: '150px'},
95
+ headStyle: {width: '150px'},
93
96
  },
94
97
  {
95
98
  id: 3,
96
99
  name: t('import:params'),
97
100
  field: 'params',
98
101
  type: 'key-value',
99
- format: ({ row }) => row.params ? row.params.map((param) => {
102
+ format: ({row}) => row.params ? row.params.map((param) => {
100
103
  return {
101
104
  key: param.label,
102
105
  value: param.value
@@ -107,8 +110,8 @@ export default defineComponent({
107
110
  id: 4,
108
111
  name: t('import:status'),
109
112
  field: 'status',
110
- style: { width: '120px' },
111
- headStyle: { width: '120px' },
113
+ style: {width: '120px'},
114
+ headStyle: {width: '120px'},
112
115
  },
113
116
  {
114
117
  id: 5,
@@ -120,16 +123,16 @@ export default defineComponent({
120
123
  id: 6,
121
124
  name: t('import:log'),
122
125
  field: 'history',
123
- style: { width: '250px' },
124
- headStyle: { width: '250px' },
126
+ style: {width: '270px', whiteSpace: 'nowrap'},
127
+ headStyle: {width: '270px'},
125
128
  },
126
129
  {
127
130
  id: 7,
128
131
  name: t('import:file'),
129
132
  field: 'file',
130
133
  type: 'file',
131
- style: { width: '150px', textAlign: 'center' },
132
- headStyle: { width: '150px', textAlign: 'center' },
134
+ style: {width: '150px', textAlign: 'center'},
135
+ headStyle: {width: '150px', textAlign: 'center'},
133
136
  },
134
137
  ];
135
138
 
@@ -1,12 +1,13 @@
1
1
  export function dateTimeFormat(value: number | string | Date): string {
2
- const options = {
3
- year: 'numeric',
2
+
3
+ const date = new Date(value);
4
+
5
+ return new Intl.DateTimeFormat('ru-RU', {
6
+ "year": "numeric",
4
7
  month: 'numeric',
5
8
  day: 'numeric',
6
9
  hour: 'numeric',
7
10
  minute: 'numeric',
8
11
  second: 'numeric',
9
- };
10
- const date = new Date(value);
11
- return new Intl.DateTimeFormat('ru-RU', options).format(date);
12
+ }).format(date);
12
13
  }
@@ -10,14 +10,13 @@
10
10
  </template>
11
11
 
12
12
  <script lang="ts">
13
- import { defineComponent, PropType } from '@vue/composition-api';
13
+ import {defineComponent, type PropType} from "vue";
14
14
 
15
- import { HistoryType } from '../../../../typings/model';
15
+ import {type HistoryType} from "../../../../typings/model";
16
16
 
17
- import { Props } from './CellHistory.types';
18
- import { dateTimeFormat } from './CellHistory.helpers';
17
+ import {dateTimeFormat} from './CellHistory.helpers';
19
18
 
20
- export default defineComponent<Props>({
19
+ export default defineComponent({
21
20
  name: 'CellHistory',
22
21
  props: {
23
22
  history: {
@@ -36,6 +35,6 @@ export default defineComponent<Props>({
36
35
  <style lang="scss" scoped>
37
36
  .name {
38
37
  display: inline-block;
39
- width: 75px;
38
+ width: 100px;
40
39
  }
41
40
  </style>
package/README.md DELETED
@@ -1 +0,0 @@
1
- # tager-admin-import
package/dist/dev.d.ts DELETED
@@ -1 +0,0 @@
1
- import '@tager/admin-ui/dist/admin-ui.css';