@tager/admin-export 0.1.5 → 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 (52) 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 -25
  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 -26
  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 -11
  18. package/dist/views/ExportForm/ExportForm.types.d.ts +7 -7
  19. package/dist/views/ExportForm/ExportForm.vue.d.ts +2693 -9248
  20. package/dist/views/ExportForm/index.d.ts +1 -1
  21. package/dist/views/ExportList/ExportList.vue.d.ts +16 -38
  22. package/dist/views/ExportList/components/CellHistory/CellHistory.helpers.d.ts +1 -1
  23. package/dist/views/ExportList/components/CellHistory/CellHistory.vue.d.ts +19 -230
  24. package/dist/views/ExportList/components/CellHistory/index.d.ts +1 -1
  25. package/dist/views/ExportList/index.d.ts +1 -1
  26. package/package.json +49 -48
  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 +1 -4
  34. package/src/locales/ru.ts +2 -5
  35. package/src/main.ts +2 -6
  36. package/src/views/ExportForm/ExportForm.helpers.ts +0 -2
  37. package/src/views/ExportForm/ExportForm.vue +111 -106
  38. package/src/views/ExportList/ExportList.vue +46 -43
  39. package/src/views/ExportList/components/CellHistory/CellHistory.helpers.ts +2 -2
  40. package/src/views/ExportList/components/CellHistory/CellHistory.vue +4 -7
  41. package/README.md +0 -0
  42. package/dist/dev.d.ts +0 -1
  43. package/dist/index.esm.js +0 -3702
  44. package/dist/index.umd.js +0 -3714
  45. package/dist/views/ExportList/components/CellHistory/CellHistory.types.d.ts +0 -4
  46. package/src/config/config.json +0 -20
  47. package/src/dev.ts +0 -41
  48. package/src/typings/sfc.d.ts +0 -12
  49. package/src/typings/shims-tsx.d.ts +0 -13
  50. package/src/typings/shims-vue.d.ts +0 -11
  51. package/src/views/App.vue +0 -36
  52. package/src/views/ExportList/components/CellHistory/CellHistory.types.ts +0 -5
package/src/locales/ru.ts CHANGED
@@ -1,8 +1,7 @@
1
- import EN from './en';
1
+ import { EN } from './en';
2
2
 
3
- const RU: typeof EN = {
3
+ export const RU: typeof EN = {
4
4
  home: 'Главная',
5
- exportAndImport: 'Экспорт / Импорт',
6
5
  export: 'Экспорт',
7
6
  exportList: 'Список экспортов',
8
7
  exportForm: 'Форма экспорта',
@@ -24,5 +23,3 @@ const RU: typeof EN = {
24
23
  comma: 'Запятая',
25
24
  semicolon: 'Точка с запятой',
26
25
  };
27
-
28
- 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', 'export', EN);
7
- i18n.addTranslations('ru', 'export', RU);
3
+ applyTranslations();
8
4
 
9
5
  export * from './constants/routes';
10
6
  export * from './utils/paths';
@@ -1,5 +1,3 @@
1
- import { computed } from '@vue/composition-api';
2
-
3
1
  import { OptionType } from '@tager/admin-ui';
4
2
  import { FieldUnion, universalFieldUtils } from '@tager/admin-dynamic-field';
5
3
 
@@ -1,70 +1,69 @@
1
1
  <template>
2
- <page :title="$t('export:newExport')" :is-content-loading="isContentLoading">
2
+ <Page :title="$i18n.t('export:newExport')" :is-content-loading="isContentLoading">
3
3
  <form novalidate @submit.prevent>
4
- <form-field-select
5
- v-model="values.strategy"
6
- :options="strategyOptionList"
7
- :error="errors.strategy"
8
- :label="$t('export:exportType')"
9
- name="exportType"
4
+ <FormFieldSelect
5
+ v-model:value="values.strategy"
6
+ name="exportType"
7
+ :error="errors.strategy"
8
+ :label="$i18n.t('export:exportType')"
9
+ :options="strategyOptionList"
10
10
  />
11
11
 
12
12
  <div class="field">
13
- <form-field
14
- v-model="values.filename"
15
- :error="errors.filename"
16
- :label="$t('export:filename')"
17
- name="filename"
13
+ <FormField
14
+ v-model:value="values.filename"
15
+ :error="errors.filename"
16
+ :label="$i18n.t('export:filename')"
17
+ name="filename"
18
18
  />
19
19
 
20
- <form-field-select
21
- v-model="values.format"
22
- :options="formatOptionList"
23
- :error="errors.format"
24
- :label="$t('export:format')"
25
- name="format"
20
+ <FormFieldSelect
21
+ v-model:value="values.format"
22
+ :options="formatOptionList"
23
+ :error="errors.format"
24
+ :label="$i18n.t('export:format')"
25
+ name="format"
26
26
  />
27
27
 
28
- <div />
29
-
30
- <form-field-select
31
- v-if="shouldDisplayDelimiter"
32
- v-model="values.delimiter"
33
- :options="delimiterOptionList"
34
- :error="errors.delimiter"
35
- :label="$t('export:delimiter')"
36
- name="delimiter"
28
+ <FormFieldSelect
29
+ v-if="shouldDisplayDelimiter"
30
+ v-model:value="values.delimiter"
31
+ :options="delimiterOptionList"
32
+ :error="errors.delimiter"
33
+ :label="$i18n.t('export:delimiter')"
34
+ name="delimiter"
37
35
  />
38
36
  </div>
39
-
40
37
  <DynamicField
41
- v-for="field of templateValues"
42
- :key="field.config.name"
43
- :field="field"
38
+ v-for="field of templateValues"
39
+ :key="field.config.name"
40
+ :field="field"
44
41
  />
45
42
  </form>
46
43
 
47
- <template v-slot:footer>
44
+ <template #footer>
48
45
  <FormFooter
49
- :back-href="getExportListUrl()"
50
- :on-submit="submitForm"
51
- :is-submitting="isSubmitting"
52
- :is-creation="true"
46
+ :back-href="getExportListUrl()"
47
+ @submit="submitForm"
48
+ :is-submitting="isSubmitting"
49
+ :is-creation="true"
53
50
  />
54
51
  </template>
55
- </page>
52
+ </Page>
56
53
  </template>
57
54
 
58
55
  <script lang="ts">
59
- import { defineComponent, watch } from '@vue/composition-api';
60
- import { computed, onMounted, ref } from '@vue/composition-api';
56
+ import {defineComponent, onMounted, watch, ref, computed} from "vue";
57
+ import {useRoute, useRouter} from "vue-router";
58
+
59
+ import {useI18n, navigateBack, useToast} from '@tager/admin-services';
60
+ import {Page} from "@tager/admin-layout";
61
61
 
62
- import { convertRequestErrorToMap, useResource } from '@tager/admin-services';
62
+ import {convertRequestErrorToMap, useResource} from '@tager/admin-services';
63
63
  import {
64
64
  OptionType,
65
65
  TagerFormSubmitEvent,
66
- FormFooter,
67
- useTranslation,
66
+ FormFooter, FormField, FormFieldSelect
68
67
  } from '@tager/admin-ui';
69
68
  import {
70
69
  DynamicField,
@@ -73,9 +72,9 @@ import {
73
72
  universalFieldUtils,
74
73
  } from '@tager/admin-dynamic-field';
75
74
 
76
- import { createExport, getStrategies } from '../../services/requests';
77
- import { getExportListUrl } from '../../utils/paths';
78
- import { replaceFileExtension } from '../../utils/common';
75
+ import {createExport, getStrategies} from '../../services/requests';
76
+ import {getExportListUrl} from '../../utils/paths';
77
+ import {replaceFileExtension} from '../../utils/common';
79
78
 
80
79
  import {
81
80
  convertExportFormValuesToCreationPayload,
@@ -83,28 +82,34 @@ import {
83
82
  formatOptionList,
84
83
  isCSVFormat,
85
84
  } from './ExportForm.helpers';
86
- import { FormValues } from './ExportForm.types';
85
+ import {FormValues} from './ExportForm.types';
86
+
87
87
 
88
88
  export default defineComponent({
89
89
  name: 'ExportForm',
90
- components: { DynamicField, FormFooter },
91
- setup(props, context) {
92
- const { t } = useTranslation(context);
90
+ components: {
91
+ DynamicField, FormFooter,
92
+ Page, FormField, FormFieldSelect
93
+ },
94
+ setup() {
95
+ const {t} = useI18n();
96
+ const route = useRoute();
97
+ const router = useRouter();
98
+ const toast = useToast();
93
99
 
94
100
  /** Strategies */
95
101
 
96
102
  const [
97
103
  fetchStrategies,
98
- { data: strategies, loading: isStrategiesLoading },
104
+ {data: strategies, loading: isStrategiesLoading},
99
105
  ] = useResource({
100
106
  fetchResource: getStrategies,
101
107
  initialValue: [],
102
- context,
103
108
  resourceName: 'Strategies',
104
109
  });
105
110
 
106
111
  const strategyOptionList = computed<Array<OptionType>>(() =>
107
- convertStrategiesToStrategyOptionList(strategies.value)
112
+ convertStrategiesToStrategyOptionList(strategies.value)
108
113
  );
109
114
 
110
115
  onMounted(() => {
@@ -114,8 +119,8 @@ export default defineComponent({
114
119
  /** Delimiter **/
115
120
 
116
121
  const delimiterOptionList = computed<Array<OptionType>>(() => [
117
- { value: ',', label: t('export:comma') },
118
- { value: ';', label: t('export:semicolon') },
122
+ {value: ',', label: t('export:comma')},
123
+ {value: ';', label: t('export:semicolon')},
119
124
  ]);
120
125
 
121
126
  /** Form state */
@@ -135,22 +140,22 @@ export default defineComponent({
135
140
 
136
141
  function updateTemplateValues() {
137
142
  const selectedStrategy = strategies.value.find(
138
- (strategy) => strategy.id === values.value.strategy?.value
143
+ (strategy) => strategy.id === values.value.strategy?.value
139
144
  );
140
145
 
141
146
  const fieldTemplateList: Array<FieldConfigUnion> =
142
- selectedStrategy?.fields ?? [];
147
+ selectedStrategy?.fields ?? [];
143
148
 
144
149
  templateValues.value = fieldTemplateList.map((fieldConfig) =>
145
- universalFieldUtils.createFormField(fieldConfig, null)
150
+ universalFieldUtils.createFormField(fieldConfig, null)
146
151
  );
147
152
  }
148
153
 
149
154
  watch(
150
- () => values.value.strategy,
151
- () => {
152
- updateTemplateValues();
153
- }
155
+ () => values.value.strategy,
156
+ () => {
157
+ updateTemplateValues();
158
+ }
154
159
  );
155
160
 
156
161
  onMounted(() => {
@@ -158,64 +163,64 @@ export default defineComponent({
158
163
  });
159
164
 
160
165
  const shouldDisplayDelimiter = ref<boolean>(
161
- isCSVFormat(values.value.format?.value ?? '')
166
+ isCSVFormat(values.value.format?.value ?? '')
162
167
  );
163
168
 
164
169
  watch(
165
- () => values.value.format,
166
- () => {
167
- const newExtension = values.value.format?.value.toLowerCase();
168
-
169
- values.value.filename = replaceFileExtension(
170
- values.value.filename,
171
- newExtension || ''
172
- );
173
-
174
- shouldDisplayDelimiter.value = isCSVFormat(
175
- values.value.format?.value ?? ''
176
- );
177
- }
170
+ () => values.value.format,
171
+ () => {
172
+ const newExtension = values.value.format?.value.toLowerCase();
173
+
174
+ values.value.filename = replaceFileExtension(
175
+ values.value.filename,
176
+ newExtension || ''
177
+ );
178
+
179
+ shouldDisplayDelimiter.value = isCSVFormat(
180
+ values.value.format?.value ?? ''
181
+ );
182
+ }
178
183
  );
179
184
 
180
185
  function submitForm(event: TagerFormSubmitEvent) {
181
186
  isSubmitting.value = true;
182
187
 
183
188
  const creationPayload = convertExportFormValuesToCreationPayload(
184
- values.value,
185
- templateValues.value
189
+ values.value,
190
+ templateValues.value
186
191
  );
187
192
 
188
193
  createExport(creationPayload)
189
- .then(() => {
190
- errors.value = {};
191
-
192
- if (
193
- event.type === 'create' ||
194
- event.type === 'save' ||
195
- event.type === 'create_exit' ||
196
- event.type === 'save_exit'
197
- ) {
198
- context.root.$router.push(getExportListUrl());
199
- }
200
-
201
- context.root.$toast({
202
- variant: 'success',
203
- title: t('export:success'),
204
- body: t('export:createdSuccessMessage'),
205
- });
206
- })
207
- .catch((error) => {
208
- console.error(error);
209
- errors.value = convertRequestErrorToMap(error);
210
- context.root.$toast({
211
- variant: 'danger',
212
- title: t('export:error'),
213
- body: t('export:createdErrorMessage'),
194
+ .then(() => {
195
+ errors.value = {};
196
+
197
+ if (
198
+ event.type === 'create' ||
199
+ event.type === 'save' ||
200
+ event.type === 'create_exit' ||
201
+ event.type === 'save_exit'
202
+ ) {
203
+ navigateBack(router, getExportListUrl());
204
+ }
205
+
206
+ toast.show({
207
+ variant: 'success',
208
+ title: t('export:success'),
209
+ body: t('export:createdSuccessMessage'),
210
+ });
211
+ })
212
+ .catch((error) => {
213
+ console.error(error);
214
+ errors.value = convertRequestErrorToMap(error);
215
+ toast.show({
216
+ variant: 'danger',
217
+ title: t('export:error'),
218
+ body: t('export:createdErrorMessage'),
219
+ });
220
+ })
221
+ .finally(() => {
222
+ isSubmitting.value = false;
214
223
  });
215
- })
216
- .finally(() => {
217
- isSubmitting.value = false;
218
- });
219
224
  }
220
225
 
221
226
  /** Is content loading **/
@@ -1,54 +1,58 @@
1
1
  <template>
2
- <page
3
- :title="$t('export:export')"
4
- :header-buttons="[
2
+ <Page
3
+ :title="$i18n.t('export:export')"
4
+ :header-buttons="[
5
5
  {
6
- text: $t('export:newExport'),
6
+ text: $i18n.t('export:newExport'),
7
7
  href: getExportFormUrl({ exportId: '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';
34
-
33
+ import {defineComponent, onMounted} from "vue";
34
+ import {useI18n} from '@tager/admin-services';
35
+ import {Page} from "@tager/admin-layout";
35
36
  import {
36
- ColumnDefinition,
37
+ type ColumnDefinition,
38
+ DataTable,
37
39
  useDataTable,
38
- useTranslation,
39
- } from '@tager/admin-ui';
40
+ } from "@tager/admin-ui";
40
41
 
41
- import { getExportList } from '../../services/requests';
42
- import { ExportType } from '../../typings/model';
43
- import { getExportFormUrl } from '../../utils/paths';
42
+ import {getExportList} from '../../services/requests';
43
+ import {ExportType} from '../../typings/model';
44
+ import {getExportFormUrl} from '../../utils/paths';
44
45
 
45
- import { CellHistory } from './components/CellHistory';
46
+ import {CellHistory} from './components/CellHistory';
46
47
 
47
48
  export default defineComponent({
48
49
  name: 'ExportList',
49
- components: { CellHistory },
50
- setup(props, context) {
51
- const { t } = useTranslation(context);
50
+ components: {
51
+ Page, CellHistory,
52
+ DataTable,
53
+ },
54
+ setup() {
55
+ const {t} = useI18n();
52
56
 
53
57
  const {
54
58
  fetchEntityList: fetchExportList,
@@ -62,12 +66,11 @@ export default defineComponent({
62
66
  pageNumber,
63
67
  } = useDataTable<ExportType>({
64
68
  fetchEntityList: (params) =>
65
- getExportList({
66
- pageNumber: params.pageNumber,
67
- pageSize: params.pageSize,
68
- }),
69
+ getExportList({
70
+ pageNumber: params.pageNumber,
71
+ pageSize: params.pageSize,
72
+ }),
69
73
  initialValue: [],
70
- context,
71
74
  resourceName: 'Export 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('export:type'),
90
93
  field: 'strategy',
91
- style: { width: '15%' },
92
- headStyle: { width: '15%' },
94
+ style: {width: '15%'},
95
+ headStyle: {width: '15%'},
93
96
  },
94
97
  {
95
98
  id: 3,
96
99
  name: t('export:status'),
97
100
  field: 'status',
98
- style: { width: '15%' },
99
- headStyle: { width: '15%' },
101
+ style: {width: '15%'},
102
+ headStyle: {width: '15%'},
100
103
  },
101
104
  {
102
105
  id: 4,
@@ -108,16 +111,16 @@ export default defineComponent({
108
111
  id: 5,
109
112
  name: t('export:log'),
110
113
  field: 'history',
111
- style: { width: '25%' },
112
- headStyle: { width: '25%' },
114
+ style: {width: '25%'},
115
+ headStyle: {width: '25%'},
113
116
  },
114
117
  {
115
118
  id: 6,
116
119
  name: t('export:file'),
117
120
  field: 'file',
118
121
  type: 'file',
119
- style: { width: '150px', textAlign: 'center' },
120
- headStyle: { width: '150px', textAlign: 'center' },
122
+ style: {width: '150px', textAlign: 'center'},
123
+ headStyle: {width: '150px', textAlign: 'center'},
121
124
  },
122
125
  ];
123
126
 
@@ -1,11 +1,11 @@
1
1
  export function dateTimeFormat(value: number | string | Date): string {
2
2
  const options = {
3
- year: 'numeric',
3
+ /*year: 'numeric',
4
4
  month: 'numeric',
5
5
  day: 'numeric',
6
6
  hour: 'numeric',
7
7
  minute: 'numeric',
8
- second: 'numeric',
8
+ second: 'numeric',*/
9
9
  };
10
10
  const date = new Date(value);
11
11
  return new Intl.DateTimeFormat('ru-RU', options).format(date);
@@ -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: {
package/README.md DELETED
File without changes
package/dist/dev.d.ts DELETED
@@ -1 +0,0 @@
1
- import '@tager/admin-ui/dist/admin-ui.css';