From 1fd0578e844ded1a5cae10c28224879bb4995292 Mon Sep 17 00:00:00 2001 From: liza-pohranichna Date: Fri, 16 Feb 2024 17:23:14 +0200 Subject: [PATCH 01/13] feature: new section in progress [WTEL-4195] --- package-lock.json | 82 +++++++++-- package.json | 2 +- src/app/locale/en/en.js | 3 + src/app/locale/ru/ru.js | 3 + src/app/locale/ua/ua.js | 3 + .../_internals/NavigationPages.lookup.js | 5 + src/app/router/_internals/RouteNames.enum.js | 1 + src/app/router/router.js | 8 ++ .../global-variables/api/global-variables.js | 130 ++++++++++++++++++ .../components/the-global-variables.vue | 76 ++++++++++ 10 files changed, 300 insertions(+), 13 deletions(-) create mode 100644 src/modules/system/modules/global-variables/api/global-variables.js create mode 100644 src/modules/system/modules/global-variables/components/the-global-variables.vue diff --git a/package-lock.json b/package-lock.json index ca8ce4c4d..522669032 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,7 +33,7 @@ "vue-router": "^4.2.5", "vue2-dropzone": "^3.6.0", "vuex": "^4.1.0", - "webitel-sdk": "^23.12.14" + "webitel-sdk": "^23.12.18" }, "devDependencies": { "@vitejs/plugin-vue": "^4.4.0", @@ -845,17 +845,35 @@ "@types/chai": "*" } }, + "node_modules/@types/debug": { + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", + "integrity": "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==", + "dependencies": { + "@types/ms": "*" + } + }, "node_modules/@types/estree": { "version": "1.0.1", "dev": true, "license": "MIT" }, + "node_modules/@types/events": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.3.tgz", + "integrity": "sha512-trOc4AAUThEz9hapPtSd7wf5tiQKvTtu5b371UxXdTuqzIh0ArcRspRP0i0Viu+LXstIQ1z96t1nsPxT9ol01g==" + }, "node_modules/@types/istanbul-lib-coverage": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==", "dev": true }, + "node_modules/@types/ms": { + "version": "0.7.34", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.34.tgz", + "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" + }, "node_modules/@types/node": { "version": "20.2.5", "dev": true, @@ -8218,22 +8236,20 @@ } }, "node_modules/webitel-sdk": { - "version": "23.12.14", - "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-23.12.14.tgz", - "integrity": "sha512-wil/ny1zlfTavywb/yMqiXaLk/vdSqe8dbcef00Q6qbZAJV5H3kwYOy0CGKIGPXTjCXVnRfkERhJyC6NSC1PfQ==", + "version": "23.12.20", + "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-23.12.20.tgz", + "integrity": "sha512-CrmHrj94xiGHkOXnn9SFsxhiMVR4vgI6TjTDtBdHTSbHtbfrqS5J8aypd2qzNR7Gi+WRHOVVP6tJFjYtPUBMYg==", "dependencies": { "@types/webrtc": "~0.0.41", "deep-copy": "1.4.2", "ee-ts": "1.0.1", "json-refs": "3.0.13", - "jssip": "=3.3.6", + "jssip": "=3.10.1", "query-string": "7.0.0" }, "peerDependencies": { "axios": "1.6.5", - "ee-ts": "1.0.1", - "jssip": "=3.3.6", - "tslib": ">=1.10.0" + "ee-ts": "1.0.1" } }, "node_modules/webitel-sdk/node_modules/@types/webrtc": { @@ -8241,6 +8257,18 @@ "resolved": "https://registry.npmjs.org/@types/webrtc/-/webrtc-0.0.41.tgz", "integrity": "sha512-8ffcmVtlMQe4GgVavKyCVRkiCOXguAkFNT6KmXb+aE5kB6D/qpI6aNpdHeHI206oJdmIhdTyObHbJ6I8Gq90Pg==" }, + "node_modules/webitel-sdk/node_modules/jssip": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/jssip/-/jssip-3.10.1.tgz", + "integrity": "sha512-V82JW6fZF02VInHMKgTO9oEXbkZwqezGj9SNaQPh+btriC16FfSPsRBnD+i9IhU9C86JA9le6Z8AZirYnbKi2g==", + "dependencies": { + "@types/debug": "^4.1.7", + "@types/events": "^3.0.0", + "debug": "^4.3.1", + "events": "^3.3.0", + "sdp-transform": "^2.14.1" + } + }, "node_modules/webitel-sdk/node_modules/query-string": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/query-string/-/query-string-7.0.0.tgz", @@ -8901,16 +8929,34 @@ "@types/chai": "*" } }, + "@types/debug": { + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", + "integrity": "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==", + "requires": { + "@types/ms": "*" + } + }, "@types/estree": { "version": "1.0.1", "dev": true }, + "@types/events": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.3.tgz", + "integrity": "sha512-trOc4AAUThEz9hapPtSd7wf5tiQKvTtu5b371UxXdTuqzIh0ArcRspRP0i0Viu+LXstIQ1z96t1nsPxT9ol01g==" + }, "@types/istanbul-lib-coverage": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==", "dev": true }, + "@types/ms": { + "version": "0.7.34", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.34.tgz", + "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" + }, "@types/node": { "version": "20.2.5", "dev": true @@ -13907,15 +13953,15 @@ "dev": true }, "webitel-sdk": { - "version": "23.12.14", - "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-23.12.14.tgz", - "integrity": "sha512-wil/ny1zlfTavywb/yMqiXaLk/vdSqe8dbcef00Q6qbZAJV5H3kwYOy0CGKIGPXTjCXVnRfkERhJyC6NSC1PfQ==", + "version": "23.12.20", + "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-23.12.20.tgz", + "integrity": "sha512-CrmHrj94xiGHkOXnn9SFsxhiMVR4vgI6TjTDtBdHTSbHtbfrqS5J8aypd2qzNR7Gi+WRHOVVP6tJFjYtPUBMYg==", "requires": { "@types/webrtc": "~0.0.41", "deep-copy": "1.4.2", "ee-ts": "1.0.1", "json-refs": "3.0.13", - "jssip": "=3.3.6", + "jssip": "=3.10.1", "query-string": "7.0.0" }, "dependencies": { @@ -13924,6 +13970,18 @@ "resolved": "https://registry.npmjs.org/@types/webrtc/-/webrtc-0.0.41.tgz", "integrity": "sha512-8ffcmVtlMQe4GgVavKyCVRkiCOXguAkFNT6KmXb+aE5kB6D/qpI6aNpdHeHI206oJdmIhdTyObHbJ6I8Gq90Pg==" }, + "jssip": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/jssip/-/jssip-3.10.1.tgz", + "integrity": "sha512-V82JW6fZF02VInHMKgTO9oEXbkZwqezGj9SNaQPh+btriC16FfSPsRBnD+i9IhU9C86JA9le6Z8AZirYnbKi2g==", + "requires": { + "@types/debug": "^4.1.7", + "@types/events": "^3.0.0", + "debug": "^4.3.1", + "events": "^3.3.0", + "sdp-transform": "^2.14.1" + } + }, "query-string": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/query-string/-/query-string-7.0.0.tgz", diff --git a/package.json b/package.json index 16f0cf401..f74ec2c37 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "vue-router": "^4.2.5", "vue2-dropzone": "^3.6.0", "vuex": "^4.1.0", - "webitel-sdk": "^23.12.14" + "webitel-sdk": "^23.12.18" }, "devDependencies": { "@vitejs/plugin-vue": "^4.4.0", diff --git a/src/app/locale/en/en.js b/src/app/locale/en/en.js index 5ce755dc0..7298da07d 100644 --- a/src/app/locale/en/en.js +++ b/src/app/locale/en/en.js @@ -1063,6 +1063,9 @@ export default { configuration: 'Configuration | Configurations', parameter: 'Parameter', }, + globalVariables: { + globalVariables: 'Global Variable | Global Variables', + }, }, pagination: { diff --git a/src/app/locale/ru/ru.js b/src/app/locale/ru/ru.js index 40a805b67..7d541870a 100644 --- a/src/app/locale/ru/ru.js +++ b/src/app/locale/ru/ru.js @@ -1062,6 +1062,9 @@ export default { configuration: 'Конфигурация | Конфигурации', parameter: 'Параметр', }, + globalVariables: { + globalVariables: 'Global Variable | Global Variables', + }, }, pagination: { rowsPerPage: 'Количество строк на странице', diff --git a/src/app/locale/ua/ua.js b/src/app/locale/ua/ua.js index 7a3764c78..69ebfe9a5 100644 --- a/src/app/locale/ua/ua.js +++ b/src/app/locale/ua/ua.js @@ -1061,6 +1061,9 @@ export default { configuration: 'Конфігурація | Конфігурації', parameter: 'Параметр', }, + globalVariables: { + globalVariables: 'Global Variable | Global Variables', + }, }, pagination: { rowsPerPage: 'Кількість записів', diff --git a/src/app/router/_internals/NavigationPages.lookup.js b/src/app/router/_internals/NavigationPages.lookup.js index d055da45f..00eba021c 100644 --- a/src/app/router/_internals/NavigationPages.lookup.js +++ b/src/app/router/_internals/NavigationPages.lookup.js @@ -181,6 +181,11 @@ const nav = Object.freeze([ locale: `WebitelApplications.${WebitelApplications.ADMIN}.sections.${AdminSections.CONFIGURATION}`, route: 'configuration', }, + { + value: 'global-variables', + locale: `objects.system.global-variables.global-variables`, + route: 'global-variables', + }, ], }, ]); diff --git a/src/app/router/_internals/RouteNames.enum.js b/src/app/router/_internals/RouteNames.enum.js index d4e5e0237..72d65dd02 100644 --- a/src/app/router/_internals/RouteNames.enum.js +++ b/src/app/router/_internals/RouteNames.enum.js @@ -49,6 +49,7 @@ export default Object.freeze({ // SYSTEM CHANGELOGS: 'changelogs', CONFIGURATION: 'configuration', + GLOBAL_VARIABLES: 'global-variables', SETTINGS_PAGE: 'settings', PAGE_403: 'access-denied', diff --git a/src/app/router/router.js b/src/app/router/router.js index 98edd11cc..24c2fb3c0 100755 --- a/src/app/router/router.js +++ b/src/app/router/router.js @@ -70,6 +70,7 @@ const OpenedTrigger = () => import('../../modules/integrations/modules/triggers/ const Changelogs = () => import('../../modules/system/modules/changelogs/components/the-changelogs.vue'); const OpenedChangelog = () => import('../../modules/system/modules/changelogs/components/opened-changelog.vue'); const Configuration = () => import('../../modules/system/modules/configuration/components/the-configuration.vue'); +const GlobalVariables = () => import('../../modules/system/modules/global-variables/components/the-global-variables.vue'); const checkAppAccess = (to, from, next) => { const hasReadAccess = store.getters['userinfo/CHECK_APP_ACCESS'](store.getters['userinfo/THIS_APP']); @@ -714,6 +715,13 @@ const router = createRouter({ component: Configuration, beforeEnter: checkRouteAccess, }, + + { + path: '/system/global-variables', + name: RouteNames.GLOBAL_VARIABLES, + component: GlobalVariables, + // beforeEnter: checkRouteAccess, + }, ], }, { diff --git a/src/modules/system/modules/global-variables/api/global-variables.js b/src/modules/system/modules/global-variables/api/global-variables.js new file mode 100644 index 000000000..68c7857fb --- /dev/null +++ b/src/modules/system/modules/global-variables/api/global-variables.js @@ -0,0 +1,130 @@ +import { + getDefaultGetListResponse, + getDefaultGetParams, +} from '@webitel/ui-sdk/src/api/defaults'; +import applyTransform, { + camelToSnake, + merge, + mergeEach, + notify, + sanitize, + snakeToCamel, + starToSearch, +} from '@webitel/ui-sdk/src/api/transformers'; +import { SchemaVariablesServiceApiFactory } from 'webitel-sdk'; +import instance from '../../../../../app/api/instance'; +import configuration from '../../../../../app/api/openAPIConfig'; + +const service = new SchemaVariablesServiceApiFactory(configuration, '', instance); + +const getList = async (params) => { + const { + page, + size, + search, + sort, + fields, + } = applyTransform(params, [ + merge(getDefaultGetParams()), + starToSearch('search'), + ]); + + try { + const response = await service.searchSchemaVariable( + page, + size, + search, + sort, + fields, + ); + const { items, next } = applyTransform(response.data, [ + snakeToCamel(), + merge(getDefaultGetListResponse()), + ]); + return { + items, + next, + }; + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +const get = async ({ itemId: id }) => { + try { + const response = await service.readSchemaVariable(id); + return applyTransform(response.data, [ + snakeToCamel(), + ]); + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +// const fieldsToSend = ['id', 'name', 'value']; + +const add = async ({ itemInstance }) => { + const item = applyTransform(itemInstance, [ + // sanitize(fieldsToSend), + camelToSnake(), + ]); + try { + const response = await service.createSchemaVariable(item); + return applyTransform(response.data, [ + snakeToCamel(), + ]); + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +const update = async ({ itemInstance, itemId: id }) => { + const item = applyTransform(itemInstance, [ + // sanitize(fieldsToSend), + camelToSnake(), + ]); + try { + const response = await service.updateSchemaVariable(id, item); + return applyTransform(response.data, [ + snakeToCamel(), + ]); + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +const deleteItem = async ({ id }) => { + try { + const response = await service.deleteSchemaVariable(id); + return applyTransform(response.data, []); + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +const getLookup = (params) => getList({ + ...params, + fields: params.fields || ['name'], + }); + + +const GlobalVariablesAPI = { + getList, + get, + add, + update, + delete: deleteItem, + getLookup, +}; + +export default GlobalVariablesAPI; diff --git a/src/modules/system/modules/global-variables/components/the-global-variables.vue b/src/modules/system/modules/global-variables/components/the-global-variables.vue new file mode 100644 index 000000000..82a46d88b --- /dev/null +++ b/src/modules/system/modules/global-variables/components/the-global-variables.vue @@ -0,0 +1,76 @@ + + + From d69288d413a19e8f66ed8fab35822d9889ed464a Mon Sep 17 00:00:00 2001 From: liza-pohranichna Date: Fri, 16 Feb 2024 18:28:52 +0200 Subject: [PATCH 02/13] feature: new section in progress [WTEL-4195] --- src/app/locale/en/en.js | 2 +- .../global-variables/api/global-variables.js | 6 ++--- .../components/the-global-variables.vue | 10 +++++---- .../store/_internals/headers.js | 22 +++++++++++++++++++ .../store/global-variables.js | 11 ++++++++++ src/modules/system/store/system.js | 2 ++ 6 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 src/modules/system/modules/global-variables/store/_internals/headers.js create mode 100644 src/modules/system/modules/global-variables/store/global-variables.js diff --git a/src/app/locale/en/en.js b/src/app/locale/en/en.js index 7298da07d..85c46a97c 100644 --- a/src/app/locale/en/en.js +++ b/src/app/locale/en/en.js @@ -1064,7 +1064,7 @@ export default { parameter: 'Parameter', }, globalVariables: { - globalVariables: 'Global Variable | Global Variables', + globalVariables: 'Global variable | Global variables', }, }, diff --git a/src/modules/system/modules/global-variables/api/global-variables.js b/src/modules/system/modules/global-variables/api/global-variables.js index 68c7857fb..f5d25f9fb 100644 --- a/src/modules/system/modules/global-variables/api/global-variables.js +++ b/src/modules/system/modules/global-variables/api/global-variables.js @@ -65,11 +65,11 @@ const get = async ({ itemId: id }) => { } }; -// const fieldsToSend = ['id', 'name', 'value']; +const fieldsToSend = ['id', 'name', 'value', 'encrypt']; const add = async ({ itemInstance }) => { const item = applyTransform(itemInstance, [ - // sanitize(fieldsToSend), + sanitize(fieldsToSend), camelToSnake(), ]); try { @@ -86,7 +86,7 @@ const add = async ({ itemInstance }) => { const update = async ({ itemInstance, itemId: id }) => { const item = applyTransform(itemInstance, [ - // sanitize(fieldsToSend), + sanitize(fieldsToSend), camelToSnake(), ]); try { diff --git a/src/modules/system/modules/global-variables/components/the-global-variables.vue b/src/modules/system/modules/global-variables/components/the-global-variables.vue index 82a46d88b..9668f8db6 100644 --- a/src/modules/system/modules/global-variables/components/the-global-variables.vue +++ b/src/modules/system/modules/global-variables/components/the-global-variables.vue @@ -62,15 +62,17 @@ export default { // }, data: () => ({ - // namespace, + namespace, isGlobalVariablesPopup: false, + }), + computed: { path() { return [ { name: this.$t('objects.system.system') }, - { name: this.$tc('objects.system.globalVariables.globalVariables', 1), route: '/system/global-variables' }, + { name: this.$tc('objects.system.globalVariables.globalVariables', 1), route: 'global-variables' }, ]; - }, - }), + } + }, methods: {}, } diff --git a/src/modules/system/modules/global-variables/store/_internals/headers.js b/src/modules/system/modules/global-variables/store/_internals/headers.js new file mode 100644 index 000000000..d6b3af8a9 --- /dev/null +++ b/src/modules/system/modules/global-variables/store/_internals/headers.js @@ -0,0 +1,22 @@ +import { SortSymbols } from '@webitel/ui-sdk/src/scripts/sortQueryAdapters'; + +export default [ + { + value: 'key', + locale: 'objects.system.changelogs.objects', + field: 'key', + sort: SortSymbols.NONE, + }, + { + value: 'value', + locale: 'reusable.state', + field: 'value', + sort: SortSymbols.NONE, + }, + { + value: 'encrypted', + locale: 'reusable.state', + field: 'encrypted', + sort: SortSymbols.NONE, + }, +]; diff --git a/src/modules/system/modules/global-variables/store/global-variables.js b/src/modules/system/modules/global-variables/store/global-variables.js new file mode 100644 index 000000000..3cfb26246 --- /dev/null +++ b/src/modules/system/modules/global-variables/store/global-variables.js @@ -0,0 +1,11 @@ +import ObjectStoreModule + from '../../../../../app/store/BaseStoreModules/StoreModules/ObjectStoreModule'; +import headers from './_internals/headers'; +import GlobalVariablesAPI from '/src/modules/system/modules/global-variables/api/global-variables'; + +const globalVariables = new ObjectStoreModule({ headers }) + .attachAPIModule(GlobalVariablesAPI) + .generateAPIActions() + .getModule(); + +export default globalVariables; diff --git a/src/modules/system/store/system.js b/src/modules/system/store/system.js index 1741bee99..72b495a9b 100644 --- a/src/modules/system/store/system.js +++ b/src/modules/system/store/system.js @@ -1,10 +1,12 @@ import changelogs from '../modules/changelogs/store/changelogs'; import configuration from '../modules/configuration/store/configuration'; +import globalVariables from '../modules/global-variables/store/global-variables'; export default { namespaced: true, modules: { changelogs, configuration, + globalVariables, }, }; From 2f304bbad6cea011bbf93b89abc5d2d62f87b58c Mon Sep 17 00:00:00 2001 From: lizacoma Date: Wed, 21 Feb 2024 18:17:19 +0200 Subject: [PATCH 03/13] feature: in progress [WTEL-4195] --- package-lock.json | 14 +- package.json | 2 +- src/app/locale/en/en.js | 1 + src/app/locale/ru/ru.js | 3 +- src/app/locale/ua/ua.js | 3 +- .../deleteMixin/tableDeleteMixin.js | 1 + .../_internals/NavigationPages.lookup.js | 4 +- src/app/router/router.js | 2 +- .../global-variables/api/global-variables.js | 6 +- .../components/global-variables-popup.vue | 155 +++++++++++++++++ .../components/the-global-variables.vue | 159 +++++++++++++++--- .../store/_internals/headers.js | 14 +- .../store/global-variables.js | 23 ++- 13 files changed, 338 insertions(+), 49 deletions(-) create mode 100644 src/modules/system/modules/global-variables/components/global-variables-popup.vue diff --git a/package-lock.json b/package-lock.json index 522669032..e2f7f18a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@vuelidate/validators": "^2.0.0", "@vueuse/core": "^10.3.0", "@webitel/flow-ui-sdk": "^0.1.14", - "@webitel/ui-sdk": "^24.2.44", + "@webitel/ui-sdk": "^24.2.52", "axios": "^1.6.5", "clipboard-copy": "^4.0.1", "cron-validator": "^1.3.1", @@ -1392,9 +1392,9 @@ } }, "node_modules/@webitel/ui-sdk": { - "version": "24.2.44", - "resolved": "https://registry.npmjs.org/@webitel/ui-sdk/-/ui-sdk-24.2.44.tgz", - "integrity": "sha512-52YaVlb1jdb0hlg/z214RvMUsneu25q6rbCkIMWLekBkSN1IKcMLOgjNdcIKlFBaj3aplQAm/TlnbUN0cBxihA==", + "version": "24.2.52", + "resolved": "https://registry.npmjs.org/@webitel/ui-sdk/-/ui-sdk-24.2.52.tgz", + "integrity": "sha512-WLonqBwICFISqVD/ztpPB/8wpSyv0dz8AE/M9/dEPNBEooJFzpJWfM/HMFSUI6oQzfDR9yb/q+ItniDn1BMCTw==", "dependencies": { "@floating-ui/vue": "^1.0.1", "@vuelidate/core": "^2.0.3", @@ -9313,9 +9313,9 @@ } }, "@webitel/ui-sdk": { - "version": "24.2.44", - "resolved": "https://registry.npmjs.org/@webitel/ui-sdk/-/ui-sdk-24.2.44.tgz", - "integrity": "sha512-52YaVlb1jdb0hlg/z214RvMUsneu25q6rbCkIMWLekBkSN1IKcMLOgjNdcIKlFBaj3aplQAm/TlnbUN0cBxihA==", + "version": "24.2.52", + "resolved": "https://registry.npmjs.org/@webitel/ui-sdk/-/ui-sdk-24.2.52.tgz", + "integrity": "sha512-WLonqBwICFISqVD/ztpPB/8wpSyv0dz8AE/M9/dEPNBEooJFzpJWfM/HMFSUI6oQzfDR9yb/q+ItniDn1BMCTw==", "requires": { "@floating-ui/vue": "^1.0.1", "@vuelidate/core": "^2.0.3", diff --git a/package.json b/package.json index f74ec2c37..4d8a5e30c 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@vuelidate/validators": "^2.0.0", "@vueuse/core": "^10.3.0", "@webitel/flow-ui-sdk": "^0.1.14", - "@webitel/ui-sdk": "^24.2.44", + "@webitel/ui-sdk": "^24.2.52", "axios": "^1.6.5", "clipboard-copy": "^4.0.1", "cron-validator": "^1.3.1", diff --git a/src/app/locale/en/en.js b/src/app/locale/en/en.js index 85c46a97c..4afceb5df 100644 --- a/src/app/locale/en/en.js +++ b/src/app/locale/en/en.js @@ -1065,6 +1065,7 @@ export default { }, globalVariables: { globalVariables: 'Global variable | Global variables', + encrypted: 'Encrypted', }, }, diff --git a/src/app/locale/ru/ru.js b/src/app/locale/ru/ru.js index 7d541870a..093190148 100644 --- a/src/app/locale/ru/ru.js +++ b/src/app/locale/ru/ru.js @@ -1063,7 +1063,8 @@ export default { parameter: 'Параметр', }, globalVariables: { - globalVariables: 'Global Variable | Global Variables', + globalVariables: 'Глобальная переменная | Глобальные переменные', + encrypted: 'Зашифровано', }, }, pagination: { diff --git a/src/app/locale/ua/ua.js b/src/app/locale/ua/ua.js index 69ebfe9a5..abc53b260 100644 --- a/src/app/locale/ua/ua.js +++ b/src/app/locale/ua/ua.js @@ -1062,7 +1062,8 @@ export default { parameter: 'Параметр', }, globalVariables: { - globalVariables: 'Global Variable | Global Variables', + globalVariables: 'Глобальна змінна | Глобальні змінні', + encrypted: 'Зашифровано', }, }, pagination: { diff --git a/src/app/mixins/baseMixins/baseTableMixin/deleteMixin/tableDeleteMixin.js b/src/app/mixins/baseMixins/baseTableMixin/deleteMixin/tableDeleteMixin.js index d74b7935d..1dca7388b 100644 --- a/src/app/mixins/baseMixins/baseTableMixin/deleteMixin/tableDeleteMixin.js +++ b/src/app/mixins/baseMixins/baseTableMixin/deleteMixin/tableDeleteMixin.js @@ -1,6 +1,7 @@ export default { methods: { deleteData(deleted) { + console.log('deleteData deleted:', deleted); return this.dispatchDelete(deleted); }, dispatchDelete() { diff --git a/src/app/router/_internals/NavigationPages.lookup.js b/src/app/router/_internals/NavigationPages.lookup.js index 00eba021c..70a5c4b18 100644 --- a/src/app/router/_internals/NavigationPages.lookup.js +++ b/src/app/router/_internals/NavigationPages.lookup.js @@ -182,8 +182,8 @@ const nav = Object.freeze([ route: 'configuration', }, { - value: 'global-variables', - locale: `objects.system.global-variables.global-variables`, + value: AdminSections.GLOBAL_VARIABLES, + locale: `WebitelApplications.${WebitelApplications.ADMIN}.sections.${AdminSections.GLOBAL_VARIABLES}`, route: 'global-variables', }, ], diff --git a/src/app/router/router.js b/src/app/router/router.js index 24c2fb3c0..3f63885df 100755 --- a/src/app/router/router.js +++ b/src/app/router/router.js @@ -720,7 +720,7 @@ const router = createRouter({ path: '/system/global-variables', name: RouteNames.GLOBAL_VARIABLES, component: GlobalVariables, - // beforeEnter: checkRouteAccess, + beforeEnter: checkRouteAccess, }, ], }, diff --git a/src/modules/system/modules/global-variables/api/global-variables.js b/src/modules/system/modules/global-variables/api/global-variables.js index f5d25f9fb..882b9ca88 100644 --- a/src/modules/system/modules/global-variables/api/global-variables.js +++ b/src/modules/system/modules/global-variables/api/global-variables.js @@ -67,7 +67,8 @@ const get = async ({ itemId: id }) => { const fieldsToSend = ['id', 'name', 'value', 'encrypt']; -const add = async ({ itemInstance }) => { +const add = async ({itemInstance}) => { + console.log('add API:', itemInstance) const item = applyTransform(itemInstance, [ sanitize(fieldsToSend), camelToSnake(), @@ -85,10 +86,12 @@ const add = async ({ itemInstance }) => { }; const update = async ({ itemInstance, itemId: id }) => { + console.log('update API id:', id, 'itemInstance:', itemInstance); const item = applyTransform(itemInstance, [ sanitize(fieldsToSend), camelToSnake(), ]); + console.log('update API item:', item); try { const response = await service.updateSchemaVariable(id, item); return applyTransform(response.data, [ @@ -102,6 +105,7 @@ const update = async ({ itemInstance, itemId: id }) => { }; const deleteItem = async ({ id }) => { + console.log('deleteItem id:', id); try { const response = await service.deleteSchemaVariable(id); return applyTransform(response.data, []); diff --git a/src/modules/system/modules/global-variables/components/global-variables-popup.vue b/src/modules/system/modules/global-variables/components/global-variables-popup.vue new file mode 100644 index 000000000..ab9e6c7a6 --- /dev/null +++ b/src/modules/system/modules/global-variables/components/global-variables-popup.vue @@ -0,0 +1,155 @@ + + + + + diff --git a/src/modules/system/modules/global-variables/components/the-global-variables.vue b/src/modules/system/modules/global-variables/components/the-global-variables.vue index 9668f8db6..c1894e56b 100644 --- a/src/modules/system/modules/global-variables/components/the-global-variables.vue +++ b/src/modules/system/modules/global-variables/components/the-global-variables.vue @@ -3,12 +3,28 @@ @@ -29,50 +122,62 @@ import tableComponentMixin from '/src/app/mixins/objectPagesMixins/objectTableMixin/tableComponentMixin.js'; import DeleteConfirmationPopup from '@webitel/ui-sdk/src/modules/DeleteConfirmationPopup/components/delete-confirmation-popup.vue'; +import GlobalVariablesPopup from './global-variables-popup.vue'; import { useDeleteConfirmationPopup } from '@webitel/ui-sdk/src/modules/DeleteConfirmationPopup/composables/useDeleteConfirmationPopup'; import { useDummy } from '/src/app/composables/useDummy'; -import RouteNames from '../../../../../app/router/_internals/RouteNames.enum'; +import baseObjectMixin from '../../../../../app/mixins/baseMixins/baseObjectMixin/baseObjectMixin'; -const namespace = 'system/global-variables'; +const namespace = 'system/globalVariables'; export default { name: 'TheGlobalVariables', - mixins: [tableComponentMixin], + components: { DeleteConfirmationPopup, GlobalVariablesPopup }, + mixins: [tableComponentMixin, baseObjectMixin], - // setup() { - // const { dummy } = useDummy({ namespace, showAction: true }); - // const { - // isVisible: isDeleteConfirmationPopup, - // deleteCount, - // deleteCallback, - // - // askDeleteConfirmation, - // closeDelete, - // } = useDeleteConfirmationPopup(); - // - // return { - // dummy, - // isDeleteConfirmationPopup, - // deleteCount, - // deleteCallback, - // - // askDeleteConfirmation, - // closeDelete, - // }; - // }, + setup() { + const { dummy } = useDummy({ namespace, showAction: true }); + const { + isVisible: isDeleteConfirmationPopup, + deleteCount, + deleteCallback, + + askDeleteConfirmation, + closeDelete, + } = useDeleteConfirmationPopup(); + + return { + dummy, + isDeleteConfirmationPopup, + deleteCount, + deleteCallback, + + askDeleteConfirmation, + closeDelete, + }; + }, data: () => ({ namespace, isGlobalVariablesPopup: false, + editedItem: null, }), computed: { path() { return [ { name: this.$t('objects.system.system') }, - { name: this.$tc('objects.system.globalVariables.globalVariables', 1), route: 'global-variables' }, + { name: this.$tc('objects.system.globalVariables.globalVariables', 1), route: '/system/global-variables' }, ]; } }, - methods: {}, + methods: { + edit(item) { + this.editedItem = item; + this.isGlobalVariablesPopup = true; + }, + close() { + this.isGlobalVariablesPopup = false; + this.editedItem = null; + }, + }, } diff --git a/src/modules/system/modules/global-variables/store/_internals/headers.js b/src/modules/system/modules/global-variables/store/_internals/headers.js index d6b3af8a9..f71472d51 100644 --- a/src/modules/system/modules/global-variables/store/_internals/headers.js +++ b/src/modules/system/modules/global-variables/store/_internals/headers.js @@ -2,21 +2,21 @@ import { SortSymbols } from '@webitel/ui-sdk/src/scripts/sortQueryAdapters'; export default [ { - value: 'key', - locale: 'objects.system.changelogs.objects', - field: 'key', + value: 'name', + locale: 'objects.key', + field: 'name', sort: SortSymbols.NONE, }, { value: 'value', - locale: 'reusable.state', + locale: ['vocabulary.values', 1], field: 'value', sort: SortSymbols.NONE, }, { - value: 'encrypted', - locale: 'reusable.state', - field: 'encrypted', + value: 'encrypt', + locale: 'objects.system.globalVariables.encrypted', + field: 'encrypt', sort: SortSymbols.NONE, }, ]; diff --git a/src/modules/system/modules/global-variables/store/global-variables.js b/src/modules/system/modules/global-variables/store/global-variables.js index 3cfb26246..0b552ed2a 100644 --- a/src/modules/system/modules/global-variables/store/global-variables.js +++ b/src/modules/system/modules/global-variables/store/global-variables.js @@ -1,7 +1,28 @@ import ObjectStoreModule from '../../../../../app/store/BaseStoreModules/StoreModules/ObjectStoreModule'; import headers from './_internals/headers'; -import GlobalVariablesAPI from '/src/modules/system/modules/global-variables/api/global-variables'; +import GlobalVariablesAPI from '../api/global-variables'; + +const actions = { + ADD_ITEM: async (context, { itemInstance }) => { + try { + await context.dispatch('api/POST_ITEM', { itemInstance }); + } finally { + await context.dispatch('LOAD_DATA_LIST'); + } + }, + UPDATE_ITEM: async (context, { etag, itemInstance }) => { + try { + await context.dispatch('api/UPD_ITEM', { + parentId: context.getters.PARENT_ID, + etag, + itemInstance, + }); + } finally { + await context.dispatch('LOAD_DATA_LIST'); + } + }, +}; const globalVariables = new ObjectStoreModule({ headers }) .attachAPIModule(GlobalVariablesAPI) From 8563b302246eaf1af1392657ad4fbe0c0a4f5190 Mon Sep 17 00:00:00 2001 From: lizacoma Date: Thu, 22 Feb 2024 23:51:04 +0200 Subject: [PATCH 04/13] feature: in progress [WTEL-4195] --- src/app/locale/en/en.js | 1 + src/app/locale/ru/ru.js | 1 + src/app/locale/ua/ua.js | 1 + .../baseObjectMixin/baseObjectMixin.js | 3 + .../components/global-variables-popup.vue | 185 +++++++----------- .../components/the-global-variables.vue | 42 ++-- .../store/global-variables.js | 39 ++-- 7 files changed, 129 insertions(+), 143 deletions(-) diff --git a/src/app/locale/en/en.js b/src/app/locale/en/en.js index 4afceb5df..fcd5cf5c1 100644 --- a/src/app/locale/en/en.js +++ b/src/app/locale/en/en.js @@ -1066,6 +1066,7 @@ export default { globalVariables: { globalVariables: 'Global variable | Global variables', encrypted: 'Encrypted', + valueInfo: 'Enter value only if you want to edit', }, }, diff --git a/src/app/locale/ru/ru.js b/src/app/locale/ru/ru.js index 093190148..517089f6d 100644 --- a/src/app/locale/ru/ru.js +++ b/src/app/locale/ru/ru.js @@ -1065,6 +1065,7 @@ export default { globalVariables: { globalVariables: 'Глобальная переменная | Глобальные переменные', encrypted: 'Зашифровано', + valueInfo: 'Введите значение, если хотите перезаписать его', }, }, pagination: { diff --git a/src/app/locale/ua/ua.js b/src/app/locale/ua/ua.js index abc53b260..bd8490f06 100644 --- a/src/app/locale/ua/ua.js +++ b/src/app/locale/ua/ua.js @@ -1064,6 +1064,7 @@ export default { globalVariables: { globalVariables: 'Глобальна змінна | Глобальні змінні', encrypted: 'Зашифровано', + valueInfo: 'Введіть значення, якщо хочете перезаписати його', }, }, pagination: { diff --git a/src/app/mixins/baseMixins/baseObjectMixin/baseObjectMixin.js b/src/app/mixins/baseMixins/baseObjectMixin/baseObjectMixin.js index 6fea2e6c3..72422fc56 100644 --- a/src/app/mixins/baseMixins/baseObjectMixin/baseObjectMixin.js +++ b/src/app/mixins/baseMixins/baseObjectMixin/baseObjectMixin.js @@ -23,6 +23,7 @@ export default { }, disabledSave() { + console.log('this.checkValidations():', this.checkValidations()); // if there's a validation problem // OR it's edit and any fields haven't changed return this.checkValidations() || @@ -33,12 +34,14 @@ export default { methods: { ...mapActions({ loadItem(dispatch, payload) { + console.log() return dispatch(`${this.namespace}/LOAD_ITEM`, payload); }, addItem(dispatch, payload) { return dispatch(`${this.namespace}/ADD_ITEM`, payload); }, updateItem(dispatch, payload) { + console.log('updateItem action:', payload, 'this.namespace:', this.namespace); return dispatch(`${this.namespace}/UPDATE_ITEM`, payload); }, }), diff --git a/src/modules/system/modules/global-variables/components/global-variables-popup.vue b/src/modules/system/modules/global-variables/components/global-variables-popup.vue index ab9e6c7a6..8f458cfb7 100644 --- a/src/modules/system/modules/global-variables/components/global-variables-popup.vue +++ b/src/modules/system/modules/global-variables/components/global-variables-popup.vue @@ -5,151 +5,114 @@ @close="close" > - - - diff --git a/src/modules/system/modules/global-variables/components/the-global-variables.vue b/src/modules/system/modules/global-variables/components/the-global-variables.vue index c1894e56b..5735a0d7f 100644 --- a/src/modules/system/modules/global-variables/components/the-global-variables.vue +++ b/src/modules/system/modules/global-variables/components/the-global-variables.vue @@ -19,10 +19,9 @@
@@ -85,13 +84,13 @@ {{ item.name }} +
@@ -126,13 +135,16 @@ import GlobalVariablesPopup from './global-variables-popup.vue'; import { useDeleteConfirmationPopup } from '@webitel/ui-sdk/src/modules/DeleteConfirmationPopup/composables/useDeleteConfirmationPopup'; import { useDummy } from '/src/app/composables/useDummy'; import baseObjectMixin from '../../../../../app/mixins/baseMixins/baseObjectMixin/baseObjectMixin'; +import openedObjectMixin from '../../../../../app/mixins/objectPagesMixins/openedObjectMixin/openedObjectMixin'; +import { mapActions, mapState } from 'vuex'; +import getNamespacedState from '@webitel/ui-sdk/src/store/helpers/getNamespacedState'; const namespace = 'system/globalVariables'; export default { name: 'TheGlobalVariables', components: { DeleteConfirmationPopup, GlobalVariablesPopup }, - mixins: [tableComponentMixin, baseObjectMixin], + mixins: [tableComponentMixin, baseObjectMixin, openedObjectMixin], setup() { const { dummy } = useDummy({ namespace, showAction: true }); @@ -159,9 +171,14 @@ export default { data: () => ({ namespace, isGlobalVariablesPopup: false, - editedItem: null, + // editedItem: null, }), computed: { + ...mapState({ + id(state) { + return getNamespacedState(state, this.namespace).itemId; + }, + }), path() { return [ { name: this.$t('objects.system.system') }, @@ -170,14 +187,15 @@ export default { } }, methods: { + ...mapActions({ + setItemId(dispatch, payload) { + return dispatch(`${namespace}/SET_ITEM_ID`, payload); + }, + }), edit(item) { - this.editedItem = item; + this.setItemId(item.id); this.isGlobalVariablesPopup = true; }, - close() { - this.isGlobalVariablesPopup = false; - this.editedItem = null; - }, }, } diff --git a/src/modules/system/modules/global-variables/store/global-variables.js b/src/modules/system/modules/global-variables/store/global-variables.js index 0b552ed2a..45827b050 100644 --- a/src/modules/system/modules/global-variables/store/global-variables.js +++ b/src/modules/system/modules/global-variables/store/global-variables.js @@ -3,26 +3,25 @@ import ObjectStoreModule import headers from './_internals/headers'; import GlobalVariablesAPI from '../api/global-variables'; -const actions = { - ADD_ITEM: async (context, { itemInstance }) => { - try { - await context.dispatch('api/POST_ITEM', { itemInstance }); - } finally { - await context.dispatch('LOAD_DATA_LIST'); - } - }, - UPDATE_ITEM: async (context, { etag, itemInstance }) => { - try { - await context.dispatch('api/UPD_ITEM', { - parentId: context.getters.PARENT_ID, - etag, - itemInstance, - }); - } finally { - await context.dispatch('LOAD_DATA_LIST'); - } - }, -}; +// const actions = { +// // ADD_ITEM: async (context, { itemInstance }) => { +// // try { +// // await context.dispatch('api/POST_ITEM', { itemInstance }); +// // } finally { +// // await context.dispatch('LOAD_DATA_LIST'); +// // } +// // }, +// UPDATE_ITEM: async (context, { itemInstance }) => { +// console.log('UPDATE_ITEM action'); +// try { +// await context.dispatch('api/UPD_ITEM', { +// itemInstance, +// }); +// } finally { +// await context.dispatch('LOAD_DATA_LIST'); +// } +// }, +// }; const globalVariables = new ObjectStoreModule({ headers }) .attachAPIModule(GlobalVariablesAPI) From 8b451d609f6968a8753e0fdb07c86bbd4e7f4ce6 Mon Sep 17 00:00:00 2001 From: lizacoma Date: Thu, 22 Feb 2024 23:59:20 +0200 Subject: [PATCH 05/13] feature: sedde new actions in global variables store [WTEL-4195] --- .../store/global-variables.js | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/modules/system/modules/global-variables/store/global-variables.js b/src/modules/system/modules/global-variables/store/global-variables.js index 45827b050..f06d26d5a 100644 --- a/src/modules/system/modules/global-variables/store/global-variables.js +++ b/src/modules/system/modules/global-variables/store/global-variables.js @@ -3,29 +3,25 @@ import ObjectStoreModule import headers from './_internals/headers'; import GlobalVariablesAPI from '../api/global-variables'; -// const actions = { -// // ADD_ITEM: async (context, { itemInstance }) => { -// // try { -// // await context.dispatch('api/POST_ITEM', { itemInstance }); -// // } finally { -// // await context.dispatch('LOAD_DATA_LIST'); -// // } -// // }, -// UPDATE_ITEM: async (context, { itemInstance }) => { -// console.log('UPDATE_ITEM action'); -// try { -// await context.dispatch('api/UPD_ITEM', { -// itemInstance, -// }); -// } finally { -// await context.dispatch('LOAD_DATA_LIST'); -// } -// }, -// }; +const actions = { + ADD_ITEM: async (context) => { + if (!context.state.itemId) { + const { id } = await context.dispatch('POST_ITEM'); + context.dispatch('SET_ITEM_ID', id); + await context.dispatch('LOAD_DATA_LIST'); + } + }, + UPDATE_ITEM: async (context) => { + if (context.state.itemInstance._dirty) { + await context.dispatch('UPD_ITEM'); + await context.dispatch('LOAD_DATA_LIST'); + } + }, +}; const globalVariables = new ObjectStoreModule({ headers }) .attachAPIModule(GlobalVariablesAPI) .generateAPIActions() - .getModule(); + .getModule({ actions }); export default globalVariables; From e5b7e05f4cd2f8bbb9f027107ab5cd1c0fb7ce2b Mon Sep 17 00:00:00 2001 From: lizacoma Date: Fri, 23 Feb 2024 17:50:10 +0200 Subject: [PATCH 06/13] feature: in progress [WTEL-4195] --- package-lock.json | 14 +++++------ package.json | 2 +- .../baseObjectMixin/baseObjectMixin.js | 5 +++- .../global-variables/api/global-variables.js | 23 +++++++++++++++---- .../components/global-variables-popup.vue | 13 +++++------ .../components/the-global-variables.vue | 5 ++-- 6 files changed, 38 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index e2f7f18a9..a609304b5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,7 +33,7 @@ "vue-router": "^4.2.5", "vue2-dropzone": "^3.6.0", "vuex": "^4.1.0", - "webitel-sdk": "^23.12.18" + "webitel-sdk": "^23.12.24" }, "devDependencies": { "@vitejs/plugin-vue": "^4.4.0", @@ -8236,9 +8236,9 @@ } }, "node_modules/webitel-sdk": { - "version": "23.12.20", - "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-23.12.20.tgz", - "integrity": "sha512-CrmHrj94xiGHkOXnn9SFsxhiMVR4vgI6TjTDtBdHTSbHtbfrqS5J8aypd2qzNR7Gi+WRHOVVP6tJFjYtPUBMYg==", + "version": "23.12.24", + "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-23.12.24.tgz", + "integrity": "sha512-u1h6yXmdvGLv2QSFjle634vWPpFthlh6DOunjjuULeKvXmRueJUnEqXQrPM/44bPpxSm8ElEilaZAI7S6mGyIg==", "dependencies": { "@types/webrtc": "~0.0.41", "deep-copy": "1.4.2", @@ -13953,9 +13953,9 @@ "dev": true }, "webitel-sdk": { - "version": "23.12.20", - "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-23.12.20.tgz", - "integrity": "sha512-CrmHrj94xiGHkOXnn9SFsxhiMVR4vgI6TjTDtBdHTSbHtbfrqS5J8aypd2qzNR7Gi+WRHOVVP6tJFjYtPUBMYg==", + "version": "23.12.24", + "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-23.12.24.tgz", + "integrity": "sha512-u1h6yXmdvGLv2QSFjle634vWPpFthlh6DOunjjuULeKvXmRueJUnEqXQrPM/44bPpxSm8ElEilaZAI7S6mGyIg==", "requires": { "@types/webrtc": "~0.0.41", "deep-copy": "1.4.2", diff --git a/package.json b/package.json index 4d8a5e30c..e4bc1d7db 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "vue-router": "^4.2.5", "vue2-dropzone": "^3.6.0", "vuex": "^4.1.0", - "webitel-sdk": "^23.12.18" + "webitel-sdk": "^23.12.24" }, "devDependencies": { "@vitejs/plugin-vue": "^4.4.0", diff --git a/src/app/mixins/baseMixins/baseObjectMixin/baseObjectMixin.js b/src/app/mixins/baseMixins/baseObjectMixin/baseObjectMixin.js index 72422fc56..173f22553 100644 --- a/src/app/mixins/baseMixins/baseObjectMixin/baseObjectMixin.js +++ b/src/app/mixins/baseMixins/baseObjectMixin/baseObjectMixin.js @@ -23,7 +23,10 @@ export default { }, disabledSave() { - console.log('this.checkValidations():', this.checkValidations()); + console.log('this.checkValidations():', this.checkValidations(), + 'this.itemInstance._dirty:', this.itemInstance._dirty, + '!this.itemInstance._dirty && !!this.id:', !this.itemInstance._dirty && !!this.id, + 'itemInstance:', this.itemInstance); // if there's a validation problem // OR it's edit and any fields haven't changed return this.checkValidations() || diff --git a/src/modules/system/modules/global-variables/api/global-variables.js b/src/modules/system/modules/global-variables/api/global-variables.js index 882b9ca88..e565b63ae 100644 --- a/src/modules/system/modules/global-variables/api/global-variables.js +++ b/src/modules/system/modules/global-variables/api/global-variables.js @@ -5,7 +5,6 @@ import { import applyTransform, { camelToSnake, merge, - mergeEach, notify, sanitize, snakeToCamel, @@ -68,7 +67,6 @@ const get = async ({ itemId: id }) => { const fieldsToSend = ['id', 'name', 'value', 'encrypt']; const add = async ({itemInstance}) => { - console.log('add API:', itemInstance) const item = applyTransform(itemInstance, [ sanitize(fieldsToSend), camelToSnake(), @@ -86,12 +84,10 @@ const add = async ({itemInstance}) => { }; const update = async ({ itemInstance, itemId: id }) => { - console.log('update API id:', id, 'itemInstance:', itemInstance); const item = applyTransform(itemInstance, [ sanitize(fieldsToSend), camelToSnake(), ]); - console.log('update API item:', item); try { const response = await service.updateSchemaVariable(id, item); return applyTransform(response.data, [ @@ -104,8 +100,24 @@ const update = async ({ itemInstance, itemId: id }) => { } }; +const patch = async ({ id, changes }) => { + const body = applyTransform(changes, [ + sanitize(fieldsToSend), + camelToSnake(), + ]); + try { + const response = await service.patchSchemaVariable(id, body); + return applyTransform(response.data, [ + snakeToCamel(), + ]); + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + const deleteItem = async ({ id }) => { - console.log('deleteItem id:', id); try { const response = await service.deleteSchemaVariable(id); return applyTransform(response.data, []); @@ -127,6 +139,7 @@ const GlobalVariablesAPI = { get, add, update, + patch, delete: deleteItem, getLookup, }; diff --git a/src/modules/system/modules/global-variables/components/global-variables-popup.vue b/src/modules/system/modules/global-variables/components/global-variables-popup.vue index 8f458cfb7..471aa0cf0 100644 --- a/src/modules/system/modules/global-variables/components/global-variables-popup.vue +++ b/src/modules/system/modules/global-variables/components/global-variables-popup.vue @@ -17,7 +17,6 @@ :label="$t('objects.key')" required /> - isSwitcherOn: {{ isSwitcherOn }} inputType: {{ inputType }} !item.id), + $autoDirty: true }, + encrypt: { $autoDirty: true } }, }, - computed: { - // isSwitcherOn() { - // return (this.id && this.itemInstance.encrypt); - // } - }, + computed: {}, methods: { async save() { + if (!this.disabledSave) { if (this.id) { await this.updateItem(); } else { @@ -101,6 +99,7 @@ export default { } } this.close(); + } }, async loadPageData() { try { diff --git a/src/modules/system/modules/global-variables/components/the-global-variables.vue b/src/modules/system/modules/global-variables/components/the-global-variables.vue index 5735a0d7f..6c7b9c23d 100644 --- a/src/modules/system/modules/global-variables/components/the-global-variables.vue +++ b/src/modules/system/modules/global-variables/components/the-global-variables.vue @@ -84,13 +84,13 @@ {{ item.name }}