@tager/admin-export 0.1.4 → 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 (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 +512 -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 -24
  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 -9
  18. package/dist/views/ExportForm/ExportForm.types.d.ts +7 -0
  19. package/dist/views/ExportForm/ExportForm.vue.d.ts +2693 -74
  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 +1 -4
  34. package/src/locales/ru.ts +2 -5
  35. package/src/main.ts +2 -6
  36. package/src/services/requests.ts +1 -1
  37. package/src/typings/model.ts +8 -1
  38. package/src/views/ExportForm/ExportForm.helpers.ts +31 -8
  39. package/src/views/ExportForm/ExportForm.types.ts +8 -0
  40. package/src/views/ExportForm/ExportForm.vue +143 -118
  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.md +0 -0
  46. package/dist/dev.d.ts +0 -1
  47. package/dist/index.esm.js +0 -714
  48. package/dist/index.umd.js +0 -725
  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
@@ -1 +1 @@
1
- export { default } from './ExportForm.vue';
1
+ export { default } from './ExportForm.vue';
@@ -1,41 +1,16 @@
1
- import { ColumnDefinition } from '@tager/admin-ui';
2
- import { ExportType } from '../../typings/model';
3
- import { getExportFormUrl } from '../../utils/paths';
4
- declare const _default: import("vue").ComponentOptions<import("vue").default, import("@vue/composition-api").ShallowUnwrapRef<{
5
- columnDefs: ColumnDefinition<ExportType>[];
6
- getExportFormUrl: typeof getExportFormUrl;
7
- rowData: import("@vue/composition-api").Ref<ExportType[]>;
8
- isRowDataLoading: import("@vue/composition-api").ComputedRef<boolean>;
9
- errorMessage: import("@vue/composition-api").Ref<import("@tager/admin-services").Nullable<string>>;
10
- searchQuery: import("@vue/composition-api").Ref<string>;
11
- handleChange: (event: import("@tager/admin-ui").TableChangeEvent) => void;
12
- pageSize: import("@vue/composition-api").Ref<number>;
13
- pageCount: import("@vue/composition-api").ComputedRef<number>;
14
- pageNumber: import("@vue/composition-api").Ref<number>;
15
- t: import("i18next").TFunction;
16
- dateTimeFormat: (value: number | string | Date) => string;
17
- }> & {
18
- [key: string]: unknown;
19
- }, {}, {}, unknown, {
20
- [x: string]: any;
21
- }> & import("vue").VueConstructor<import("vue").default> & (new (...args: any[]) => import("@vue/composition-api").ComponentRenderProxy<{
22
- [x: string]: any;
23
- }, import("@vue/composition-api").ShallowUnwrapRef<{
24
- columnDefs: ColumnDefinition<ExportType>[];
25
- getExportFormUrl: typeof getExportFormUrl;
26
- rowData: import("@vue/composition-api").Ref<ExportType[]>;
27
- isRowDataLoading: import("@vue/composition-api").ComputedRef<boolean>;
28
- errorMessage: import("@vue/composition-api").Ref<import("@tager/admin-services").Nullable<string>>;
29
- searchQuery: import("@vue/composition-api").Ref<string>;
30
- handleChange: (event: import("@tager/admin-ui").TableChangeEvent) => void;
31
- pageSize: import("@vue/composition-api").Ref<number>;
32
- pageCount: import("@vue/composition-api").ComputedRef<number>;
33
- pageNumber: import("@vue/composition-api").Ref<number>;
34
- t: import("i18next").TFunction;
35
- dateTimeFormat: (value: number | string | Date) => string;
36
- }>, {
37
- [x: string]: any;
38
- }, {}, {}, {
39
- [x: string]: any;
40
- }>);
41
- export default _default;
1
+ import { type ColumnDefinition } from "@tager/admin-ui";
2
+ import { ExportType } from '../../typings/model';
3
+ import { getExportFormUrl } from '../../utils/paths';
4
+ declare const _default: import("vue").DefineComponent<{}, {
5
+ columnDefs: ColumnDefinition<ExportType>[];
6
+ getExportFormUrl: typeof getExportFormUrl;
7
+ rowData: import("vue").Ref<ExportType[]>;
8
+ isRowDataLoading: import("vue").ComputedRef<boolean>;
9
+ errorMessage: import("vue").Ref<import("@tager/admin-services").Nullable<string>>;
10
+ searchQuery: import("vue").Ref<string>;
11
+ handleChange: (event: import("@tager/admin-ui/dist/components/DataTable/DataTable.types").TableChangeEvent) => void;
12
+ pageSize: import("vue").Ref<number>;
13
+ pageCount: import("vue").ComputedRef<number>;
14
+ pageNumber: import("vue").Ref<number>;
15
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
16
+ export default _default;
@@ -0,0 +1 @@
1
+ export declare function dateTimeFormat(value: number | string | Date): string;
@@ -0,0 +1,19 @@
1
+ import { PropType } from "vue";
2
+ import { dateTimeFormat } from './CellHistory.helpers';
3
+ import { HistoryType } from "../../../../typings/model";
4
+ declare const _default: import("vue").DefineComponent<{
5
+ history: {
6
+ type: PropType<HistoryType[]>;
7
+ default: () => never[];
8
+ };
9
+ }, {
10
+ dateTimeFormat: typeof dateTimeFormat;
11
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
12
+ history: {
13
+ type: PropType<HistoryType[]>;
14
+ default: () => never[];
15
+ };
16
+ }>>, {
17
+ history: HistoryType[];
18
+ }>;
19
+ export default _default;
@@ -0,0 +1 @@
1
+ export { default as CellHistory } from './CellHistory.vue';
@@ -1 +1 @@
1
- export { default } from './ExportList.vue';
1
+ export { default } from './ExportList.vue';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tager/admin-export",
3
- "version": "0.1.4",
3
+ "version": "1.0.1",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": "dist/index.esm.js",
@@ -10,62 +10,64 @@
10
10
  "typings",
11
11
  "src"
12
12
  ],
13
+ "exports": {
14
+ "./css": "./dist/style.css",
15
+ ".": "./dist/index.mjs"
16
+ },
13
17
  "scripts": {
18
+ "build:js": "vite build",
19
+ "build:package": "concurrently --success first \"yarn build:js\" \"yarn emit-declarations\"",
20
+ "emit-declarations": "vue-tsc --project tsconfig.json --emitDeclarationOnly",
14
21
  "start": "vue-cli-service serve",
15
- "lint": "vue-cli-service lint",
16
- "build": "rollup --config",
17
- "prepare": "vue-docgen-web-types && yarn build",
18
- "tager:update": "node scripts/tager-update.js",
19
- "yalc:clean": "yalc remove --all"
22
+ "prepare": "yarn build:package",
23
+ "tager:update": "yarn upgrade --latest --scope @tager"
20
24
  },
21
25
  "dependencies": {
26
+ "lodash.isequal": "^4.5.0",
22
27
  "lodash.kebabcase": "^4.1.1",
28
+ "lodash.pick": "^4.4.0",
23
29
  "path-to-regexp": "^6.1.0"
24
30
  },
25
31
  "devDependencies": {
26
- "@rollup/plugin-commonjs": "^14.0.0",
27
- "@rollup/plugin-node-resolve": "^8.1.0",
28
- "@tager/admin-layout": "^0.5.1",
29
- "@tager/admin-services": "^0.2.23",
30
- "@tager/admin-ui": "^0.8.59",
31
- "@types/lodash.kebabcase": "^4.1.6",
32
- "@types/node": "12.x",
33
- "@typescript-eslint/eslint-plugin": "^2.26.0",
34
- "@typescript-eslint/parser": "^2.26.0",
35
- "@vue/cli-plugin-babel": "~4.4.6",
36
- "@vue/cli-plugin-eslint": "~4.4.6",
37
- "@vue/cli-plugin-router": "~4.4.6",
38
- "@vue/cli-plugin-typescript": "~4.4.6",
39
- "@vue/cli-service": "~4.4.6",
40
- "@vue/composition-api": "^1.0.0-beta.14",
41
- "@vue/eslint-config-prettier": "^6.0.0",
42
- "@vue/eslint-config-typescript": "^5.0.2",
43
- "babel-eslint": "^10.1.0",
44
- "core-js": "^3.6.5",
45
- "eslint": "^6.7.2",
46
- "eslint-plugin-import": "^2.22.0",
47
- "eslint-plugin-prettier": "^3.1.4",
48
- "eslint-plugin-vue": "^6.2.2",
49
- "prettier": "^2.0.5",
50
- "rollup": "^2.23.1",
51
- "rollup-plugin-typescript2": "^0.27.2",
52
- "rollup-plugin-vue": "^5.1.9",
53
- "sass-loader": "^9.0.3",
54
- "typescript": "~3.9.6",
55
- "vue": "2.6.x",
56
- "vue-docgen-web-types": "^0.1.6",
57
- "vue-router": "^3.5.1",
58
- "vue-template-compiler": "^2.6.11"
32
+ "@babel/core": "^7.17.9",
33
+ "@babel/eslint-parser": "^7.17.0",
34
+ "@rushstack/eslint-patch": "^1.1.2",
35
+ "@tager/admin-dynamic-field": "^1.0.0",
36
+ "@tager/admin-layout": "^1.0.0",
37
+ "@tager/admin-services": "^1.0.0",
38
+ "@tager/admin-ui": "^1.0.1",
39
+ "@types/lodash.isequal": "^4.5.6",
40
+ "@types/lodash.pick": "^4.4.7",
41
+ "@types/node": "16.x",
42
+ "@typescript-eslint/eslint-plugin": "^5.21.0",
43
+ "@typescript-eslint/parser": "^5.21.0",
44
+ "@vitejs/plugin-vue": "^2.3.1",
45
+ "@vue/cli-plugin-babel": "^5.0.4",
46
+ "@vue/cli-plugin-typescript": "^5.0.4",
47
+ "@vue/cli-service": "~5.0.0",
48
+ "@vue/eslint-config-prettier": "^7.0.0",
49
+ "@vue/eslint-config-typescript": "^10.0.0",
50
+ "concurrently": "^7.1.0",
51
+ "core-js": "^3.22.3",
52
+ "eslint": "^8.14.0",
53
+ "eslint-config-prettier": "^8.5.0",
54
+ "eslint-plugin-import": "^2.26.0",
55
+ "eslint-plugin-prettier": "^4.0.0",
56
+ "eslint-plugin-vue": "^8.7.1",
57
+ "sass": "^1.51.0",
58
+ "sass-loader": "^12.6.0",
59
+ "typescript": "^4.6.3",
60
+ "vite": "^2.9.6",
61
+ "vue": "^3.2.31",
62
+ "vue-router": "^4.0.14",
63
+ "vue-tsc": "^0.34.10"
59
64
  },
60
65
  "peerDependencies": {
61
- "@tager/admin-layout": ">=0.4.2",
62
- "@tager/admin-services": ">=0.2.11",
63
- "@tager/admin-ui": ">=0.7.5",
64
- "@vue/composition-api": ">=1.0.0-beta.14",
65
- "vue": "2.6.x"
66
- },
67
- "resolutions": {
68
- "prettier": "2.x"
66
+ "@tager/admin-layout": "^1.0.0",
67
+ "@tager/admin-services": "^1.0.0",
68
+ "@tager/admin-ui": "^1.0.1",
69
+ "vue": "^3.2.31",
70
+ "vue-router": "^4.0.14"
69
71
  },
70
72
  "publishConfig": {
71
73
  "access": "public"
@@ -1,31 +1,31 @@
1
- import { CustomRouteConfig } from '@tager/admin-layout';
1
+ import type { RouteRecordRaw } from 'vue-router';
2
2
 
3
3
  import ExportList from '../views/ExportList';
4
4
  import ExportForm from '../views/ExportForm';
5
5
 
6
6
  import { EXPORT_ROUTE_PATHS } from './paths';
7
7
 
8
- export const EXPORT_LIST_ROUTE: CustomRouteConfig = {
8
+ export const EXPORT_LIST_ROUTE: RouteRecordRaw = {
9
9
  path: EXPORT_ROUTE_PATHS.EXPORT_LIST,
10
10
  component: ExportList,
11
11
  name: 'Export List',
12
12
  meta: {
13
- getBreadcrumbs: (route, t) => [
14
- { url: '/', text: t('export:home') },
15
- { url: route.path, text: t('export:export') },
13
+ getBreadcrumbs: (route, i18n) => [
14
+ { url: '/', text: i18n.t('export:home') },
15
+ { url: route.path, text: i18n.t('export:export') },
16
16
  ],
17
17
  },
18
18
  };
19
19
 
20
- export const EXPORT_FORM_ROUTE: CustomRouteConfig = {
20
+ export const EXPORT_FORM_ROUTE: RouteRecordRaw = {
21
21
  path: EXPORT_ROUTE_PATHS.EXPORT_FORM,
22
22
  component: ExportForm,
23
23
  name: 'Export Form',
24
24
  meta: {
25
- getBreadcrumbs: (route, t) => [
26
- { url: '/', text: t('export:home') },
27
- { url: EXPORT_LIST_ROUTE.path, text: t('export:export') },
28
- { url: route.path, text: t('export:newExport') },
25
+ getBreadcrumbs: (route, i18n) => [
26
+ { url: '/', text: i18n.t('export:home') },
27
+ { url: EXPORT_LIST_ROUTE.path, text: i18n.t('export:export') },
28
+ { url: route.path, text: i18n.t('export:newExport') },
29
29
  ],
30
30
  },
31
31
  };
@@ -0,0 +1,38 @@
1
+ <template>
2
+ <PageLayout :sidebar-menu-list="sidebarMenuList">
3
+ <router-view/>
4
+ </PageLayout>
5
+ </template>
6
+
7
+ <script lang="ts">
8
+ import {defineComponent} from 'vue';
9
+ import {MenuItemType, PageLayout} from "@tager/admin-layout";
10
+ import {ViewListIcon} from "@tager/admin-ui";
11
+ import {getExportListUrl} from '../utils/paths';
12
+ import {useI18n} from "@tager/admin-services";
13
+
14
+ export default defineComponent({
15
+ name: 'App',
16
+ components: {
17
+ PageLayout,
18
+ },
19
+ setup() {
20
+ const i18n = useI18n();
21
+
22
+ const sidebarMenuList: Array<MenuItemType> = [
23
+ {
24
+ id: 'exportAndImport',
25
+ text: i18n.t('export:export'),
26
+ icon: ViewListIcon,
27
+ children: [{text: i18n.t('export:export'), url: getExportListUrl()}],
28
+ },
29
+ ];
30
+
31
+ return {
32
+ sidebarMenuList,
33
+ };
34
+ },
35
+ });
36
+ </script>
37
+
38
+ <style scoped lang="scss"></style>
@@ -0,0 +1,23 @@
1
+ import type { AppConfigType } from '@tager/admin-services';
2
+
3
+ export const OZITAG_CONFIG: AppConfigType = {
4
+ APP_NAME: 'OZiTAG_ADMIN',
5
+ TITLE_TEMPLATE: 'OZiTAG Admin - {{title}}',
6
+ LANGUAGE: 'EN',
7
+ BRAND: {
8
+ small: {
9
+ logo: 'logo-small.svg',
10
+ },
11
+ large: {
12
+ logo: 'logo.svg',
13
+ label: 'OZiTAG',
14
+ 'label-color': '#DD6900',
15
+ },
16
+ subtitle: '',
17
+ },
18
+ SPLASH_SCREEN: {
19
+ enabled: true,
20
+ logo: 'logo-white.svg',
21
+ background: '#1e1e1e',
22
+ },
23
+ };
package/src/dev/env.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { initializeEnvironment } from '@tager/admin-services';
2
+
3
+ export function populateEnvironment() {
4
+ initializeEnvironment({
5
+ publicPath: process.env.VUE_APP_PUBLIC_PATH,
6
+ appEnv: process.env.VUE_APP_ENV,
7
+ apiUrl: process.env.VUE_APP_API_URL,
8
+ accessToken: process.env.VUE_APP_ACCESS_TOKEN,
9
+ websiteUrl: process.env.VUE_APP_WEBSITE_URL,
10
+ websiteButtonUrl: process.env.VUE_APP_WEBSITE_BUTTON_URL,
11
+ sentryDsn: process.env.VUE_APP_SENTRY_DSN,
12
+ sentryEnv: process.env.VUE_APP_SENTRY_ENVIRONMENT,
13
+ baseUrl: process.env.BASE_URL,
14
+ nodeEnv: process.env.NODE_ENV,
15
+ version: process.env.VUE_APP_VERSION,
16
+ });
17
+ }
@@ -0,0 +1,36 @@
1
+ import { createApp } from 'vue';
2
+
3
+ import { configStore, i18n, i18nPlugin } from '@tager/admin-services';
4
+ import { createRouter } from '@tager/admin-layout';
5
+ import '@tager/admin-ui/css';
6
+ import '@tager/admin-layout/css';
7
+ import '@tager/admin-dynamic-field/css';
8
+
9
+ import { applyTranslations } from '../locales/apply';
10
+ import { EXPORT_LIST_ROUTE, EXPORT_FORM_ROUTE } from '../constants/routes';
11
+
12
+ import { OZITAG_CONFIG } from './config';
13
+ import App from './App.vue';
14
+ import { populateEnvironment } from './env';
15
+
16
+ populateEnvironment();
17
+
18
+ configStore.setConfig(OZITAG_CONFIG);
19
+
20
+ const router = createRouter(
21
+ {
22
+ routes: [EXPORT_LIST_ROUTE, EXPORT_FORM_ROUTE],
23
+ },
24
+ { useTitleSync: false }
25
+ );
26
+
27
+ const app = createApp(App);
28
+
29
+ app.use(router);
30
+ app.use(i18nPlugin);
31
+
32
+ applyTranslations();
33
+
34
+ i18n.init({ debug: true, lng: 'ru' }).then(() => {
35
+ app.mount('#app');
36
+ });
@@ -0,0 +1,9 @@
1
+ import { i18n } from '@tager/admin-services';
2
+
3
+ import { EN } from './en';
4
+ import { RU } from './ru';
5
+
6
+ export function applyTranslations() {
7
+ i18n.addTranslations('en', 'export', EN);
8
+ i18n.addTranslations('ru', 'export', RU);
9
+ }
package/src/locales/en.ts CHANGED
@@ -1,6 +1,5 @@
1
- const EN = {
1
+ export const EN = {
2
2
  home: 'Home',
3
- exportAndImport: 'Export / Import',
4
3
  export: 'Export',
5
4
  exportList: 'Export List',
6
5
  exportForm: 'Export Form',
@@ -22,5 +21,3 @@ const EN = {
22
21
  comma: 'Comma',
23
22
  semicolon: 'Semicolon',
24
23
  };
25
-
26
- export default EN;
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';
@@ -13,7 +13,7 @@ export function getExportList(params?: {
13
13
  return request.get({ path: '/admin/tager/export', params });
14
14
  }
15
15
 
16
- export function getStrategyList(): Promise<ResponseBody<Array<StrategyType>>> {
16
+ export function getStrategies(): Promise<ResponseBody<Array<StrategyType>>> {
17
17
  return request.get({ path: '/admin/tager/export/strategies' });
18
18
  }
19
19
 
@@ -1,6 +1,11 @@
1
1
  import { FileType } from '@tager/admin-services';
2
+ import {
3
+ FieldConfigUnion,
4
+ FieldShortType,
5
+ OutgoingValueUnion,
6
+ } from '@tager/admin-dynamic-field';
2
7
 
3
- interface HistoryType {
8
+ export interface HistoryType {
4
9
  readonly datetime: string;
5
10
  readonly status: string;
6
11
  }
@@ -17,6 +22,7 @@ export interface ExportType {
17
22
  export interface StrategyType {
18
23
  id: string;
19
24
  name: string;
25
+ fields: Array<FieldConfigUnion>;
20
26
  }
21
27
 
22
28
  export interface ExportCreatePayload {
@@ -24,4 +30,5 @@ export interface ExportCreatePayload {
24
30
  filename: string;
25
31
  format: string;
26
32
  delimiter: string;
33
+ params: Array<FieldShortType<OutgoingValueUnion>>;
27
34
  }
@@ -1,21 +1,44 @@
1
1
  import { OptionType } from '@tager/admin-ui';
2
+ import { FieldUnion, universalFieldUtils } from '@tager/admin-dynamic-field';
2
3
 
3
- import { ExportCreatePayload } from '../../typings/model';
4
+ import { ExportCreatePayload, StrategyType } from '../../typings/model';
4
5
 
5
- export type FormValues = {
6
- strategy: OptionType | null;
7
- filename: string;
8
- format: OptionType | null;
9
- delimiter: OptionType | null;
10
- };
6
+ import { FormValues } from './ExportForm.types';
11
7
 
12
8
  export function convertExportFormValuesToCreationPayload(
13
- values: FormValues
9
+ values: FormValues,
10
+ templateValues: Array<FieldUnion>
14
11
  ): ExportCreatePayload {
15
12
  return {
16
13
  strategy: values.strategy?.value ?? '',
17
14
  filename: values.filename,
18
15
  format: values.format?.value ?? '',
19
16
  delimiter: values.delimiter?.value ?? '',
17
+ params: templateValues.map((field) => ({
18
+ name: field.config.name,
19
+ value: universalFieldUtils.getOutgoingValue(field),
20
+ })),
20
21
  };
21
22
  }
23
+
24
+ export function convertStrategiesToStrategyOptionList(
25
+ strategies: Array<StrategyType>
26
+ ): Array<OptionType> {
27
+ return strategies.map((strategy) => ({
28
+ label: strategy.name,
29
+ value: strategy.id,
30
+ }));
31
+ }
32
+
33
+ export const formatOptionList = [
34
+ { value: 'CSV', label: 'CSV' },
35
+ { value: 'XLS', label: 'XLS' },
36
+ { value: 'XML', label: 'XML' },
37
+ { value: 'YAML', label: 'YAML' },
38
+ { value: 'JSON', label: 'JSON' },
39
+ { value: 'TXT', label: 'TXT' },
40
+ ];
41
+
42
+ export function isCSVFormat(format: string): boolean {
43
+ return format === 'CSV';
44
+ }
@@ -0,0 +1,8 @@
1
+ import { OptionType } from '@tager/admin-ui';
2
+
3
+ export interface FormValues {
4
+ strategy: OptionType | null;
5
+ filename: string;
6
+ format: OptionType | null;
7
+ delimiter: OptionType | null;
8
+ }