@tager/admin-import 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 (48) 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 -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 +2688 -9238
  18. package/dist/views/ImportForm/index.d.ts +1 -1
  19. package/dist/views/ImportList/ImportList.vue.d.ts +16 -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 +19 -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 +49 -48
  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 +1 -4
  32. package/src/locales/ru.ts +19 -22
  33. package/src/main.ts +2 -6
  34. package/src/views/ImportForm/ImportForm.vue +79 -76
  35. package/src/views/ImportList/ImportList.vue +45 -41
  36. package/src/views/ImportList/components/CellHistory/CellHistory.helpers.ts +6 -5
  37. package/src/views/ImportList/components/CellHistory/CellHistory.vue +5 -8
  38. package/README.md +0 -1
  39. package/dist/dev.d.ts +0 -1
  40. package/dist/index.esm.js +0 -3624
  41. package/dist/index.umd.js +0 -3636
  42. package/dist/views/ImportList/components/CellHistory/CellHistory.types.d.ts +0 -4
  43. package/src/dev.ts +0 -41
  44. package/src/typings/sfc.d.ts +0 -12
  45. package/src/typings/shims-tsx.d.ts +0 -13
  46. package/src/typings/shims-vue.d.ts +0 -11
  47. package/src/views/App.vue +0 -34
  48. 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,53 +1,52 @@
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
+ @submit="submitForm"
34
+ :is-submitting="isSubmitting"
35
+ :is-creation="true"
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';
44
43
 
45
- import { convertRequestErrorToMap, useResource } from '@tager/admin-services';
44
+ import {convertRequestErrorToMap, navigateBack, useI18n, useResource, useToast} from '@tager/admin-services';
46
45
  import {
47
46
  OptionType,
48
47
  TagerFormSubmitEvent,
49
48
  FormFooter,
50
- useTranslation,
49
+ FormFieldFileInput, FormFieldSelect
51
50
  } from '@tager/admin-ui';
52
51
  import {
53
52
  DynamicField,
@@ -56,42 +55,46 @@ import {
56
55
  universalFieldUtils,
57
56
  } from '@tager/admin-dynamic-field';
58
57
 
59
- import { createImport, getModuleInfo } from '../../services/requests';
60
- import { getImportListUrl } from '../../utils/paths';
58
+ import {createImport, getModuleInfo} from '../../services/requests';
59
+ import {getImportListUrl} from '../../utils/paths';
61
60
 
62
61
  import {
63
62
  convertImportFormValuesToCreationPayload,
64
63
  convertStrategiesToStrategyOptionList,
65
64
  FormValues,
66
65
  } from './ImportForm.helpers';
66
+ import {useRouter} from "vue-router";
67
+ import {Page} from "@tager/admin-layout";
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,59 @@
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
36
  ColumnDefinition,
37
37
  useDataTable,
38
- useTranslation,
38
+ DataTable
39
39
  } from '@tager/admin-ui';
40
40
 
41
- import { getImportList } from '../../services/requests';
42
- import { ImportType } from '../../typings/model';
43
- import { getImportFormUrl } from '../../utils/paths';
41
+ import {
42
+ Page
43
+ } from '@tager/admin-layout';
44
+ import {useI18n} from "@tager/admin-services";
45
+
46
+ import {getImportList} from '../../services/requests';
47
+ import {ImportType} from '../../typings/model';
48
+ import {getImportFormUrl} from '../../utils/paths';
44
49
 
45
- import { CellHistory } from './components/CellHistory';
50
+ import {CellHistory} from './components/CellHistory';
46
51
 
47
52
  export default defineComponent({
48
53
  name: 'ImportList',
49
- components: { CellHistory },
50
- setup(props, context) {
51
- const { t } = useTranslation(context);
54
+ components: {CellHistory, DataTable, Page},
55
+ setup() {
56
+ const {t} = useI18n();
52
57
 
53
58
  const {
54
59
  fetchEntityList: fetchImportList,
@@ -62,12 +67,11 @@ export default defineComponent({
62
67
  pageNumber,
63
68
  } = useDataTable<ImportType>({
64
69
  fetchEntityList: (params) =>
65
- getImportList({
66
- pageNumber: params.pageNumber,
67
- pageSize: params.pageSize,
68
- }),
70
+ getImportList({
71
+ pageNumber: params.pageNumber,
72
+ pageSize: params.pageSize,
73
+ }),
69
74
  initialValue: [],
70
- context,
71
75
  resourceName: 'Import list',
72
76
  pageSize: 100,
73
77
  });
@@ -81,22 +85,22 @@ export default defineComponent({
81
85
  id: 1,
82
86
  name: 'ID',
83
87
  field: 'id',
84
- style: { width: '50px', textAlign: 'center' },
85
- headStyle: { width: '50px', textAlign: 'center' },
88
+ style: {width: '50px', textAlign: 'center'},
89
+ headStyle: {width: '50px', textAlign: 'center'},
86
90
  },
87
91
  {
88
92
  id: 2,
89
93
  name: t('import:type'),
90
94
  field: 'strategy',
91
- style: { width: '150px' },
92
- headStyle: { width: '150px' },
95
+ style: {width: '150px'},
96
+ headStyle: {width: '150px'},
93
97
  },
94
98
  {
95
99
  id: 3,
96
100
  name: t('import:params'),
97
101
  field: 'params',
98
102
  type: 'key-value',
99
- format: ({ row }) => row.params ? row.params.map((param) => {
103
+ format: ({row}) => row.params ? row.params.map((param) => {
100
104
  return {
101
105
  key: param.label,
102
106
  value: param.value
@@ -107,8 +111,8 @@ export default defineComponent({
107
111
  id: 4,
108
112
  name: t('import:status'),
109
113
  field: 'status',
110
- style: { width: '120px' },
111
- headStyle: { width: '120px' },
114
+ style: {width: '120px'},
115
+ headStyle: {width: '120px'},
112
116
  },
113
117
  {
114
118
  id: 5,
@@ -120,16 +124,16 @@ export default defineComponent({
120
124
  id: 6,
121
125
  name: t('import:log'),
122
126
  field: 'history',
123
- style: { width: '250px' },
124
- headStyle: { width: '250px' },
127
+ style: {width: '270px', whiteSpace: 'nowrap'},
128
+ headStyle: {width: '270px'},
125
129
  },
126
130
  {
127
131
  id: 7,
128
132
  name: t('import:file'),
129
133
  field: 'file',
130
134
  type: 'file',
131
- style: { width: '150px', textAlign: 'center' },
132
- headStyle: { width: '150px', textAlign: 'center' },
135
+ style: {width: '150px', textAlign: 'center'},
136
+ headStyle: {width: '150px', textAlign: 'center'},
133
137
  },
134
138
  ];
135
139
 
@@ -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,11 @@
10
10
  </template>
11
11
 
12
12
  <script lang="ts">
13
- import { defineComponent, PropType } from '@vue/composition-api';
13
+ import {defineComponent, PropType} from "vue";
14
+ import {dateTimeFormat} from './CellHistory.helpers';
15
+ import {HistoryType} from "../../../../typings/model";
14
16
 
15
- import { HistoryType } from '../../../../typings/model';
16
-
17
- import { Props } from './CellHistory.types';
18
- import { dateTimeFormat } from './CellHistory.helpers';
19
-
20
- export default defineComponent<Props>({
17
+ export default defineComponent({
21
18
  name: 'CellHistory',
22
19
  props: {
23
20
  history: {
@@ -36,6 +33,6 @@ export default defineComponent<Props>({
36
33
  <style lang="scss" scoped>
37
34
  .name {
38
35
  display: inline-block;
39
- width: 75px;
36
+ width: 100px;
40
37
  }
41
38
  </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';