From 1ef7f601995bd9d62701a37e7af97f516844d85f Mon Sep 17 00:00:00 2001 From: amansinghbais <singh11amanbais@gmail.com> Date: Wed, 4 Oct 2023 19:14:24 +0530 Subject: [PATCH 1/5] Implemented: facility Switcher from dxp-components in settings page (dxp/138) --- package-lock.json | 340 +++++++++++++++++++++++++++-------------- package.json | 4 +- src/adapter/index.ts | 3 +- src/main.ts | 5 +- src/views/Settings.vue | 63 +++----- vue.config.js | 11 +- 6 files changed, 262 insertions(+), 164 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6af436a4..b69e6528 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,8 +14,8 @@ "@casl/ability": "^6.0.0", "@hotwax/app-version-info": "^1.0.0", "@hotwax/apps-theme": "^1.1.0", - "@hotwax/dxp-components": "^1.3.4", - "@hotwax/oms-api": "^1.7.0", + "@hotwax/dxp-components": "file:../dxp-components", + "@hotwax/oms-api": "^1.10.0", "@ionic/core": "6.7.5", "@ionic/vue": "6.7.5", "@ionic/vue-router": "6.7.5", @@ -62,6 +62,38 @@ "vue-cli-plugin-i18n": "^1.0.1" } }, + "../dxp-components": { + "version": "1.7.5", + "license": "Apache-2.0", + "dependencies": { + "@hotwax/oms-api": "^1.8.1", + "@ionic/core": "^6.7.5", + "@ionic/vue": "^6.7.5", + "@types/vue-barcode-reader": "^0.0.0", + "firebase": "^10.3.1", + "luxon": "^3.3.0", + "pinia": "2.0.36", + "pinia-plugin-persistedstate": "^3.1.0", + "vue": "^3.3.4", + "vue-barcode-reader": "^1.0.3", + "vue-i18n": "^9.2.2" + }, + "devDependencies": { + "@babel/types": "^7.22.11", + "@types/luxon": "^3.3.0", + "@types/node": "^20.5.7", + "@vitejs/plugin-vue": "^4.3.4", + "@vue/eslint-config-prettier": "^8.0.0", + "@vue/eslint-config-typescript": "^11.0.3", + "@vue/tsconfig": "^0.1.3", + "eslint": "^8.48.0", + "eslint-plugin-vue": "^9.17.0", + "rollup-plugin-typescript2": "^0.35.0", + "typescript": "~4.7.4", + "vite": "^4.4.9", + "vue-tsc": "^1.8.8" + } + }, "node_modules/@aashutoshrathi/word-wrap": { "version": "1.2.6", "dev": true, @@ -2127,20 +2159,13 @@ "license": "Apache-2.0" }, "node_modules/@hotwax/dxp-components": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/@hotwax/dxp-components/-/dxp-components-1.3.4.tgz", - "integrity": "sha512-uw0dmxm19lzsgcLWZ2fQBAZem0d7TkxGR0iSq1c7Bj1mkAJZXH5JbP12w0lYhtes7Q1MjhHPlWljCh6624E9XA==", - "dependencies": { - "@hotwax/oms-api": "^1.8.1", - "luxon": "^3.3.0", - "pinia": "2.0.36", - "pinia-plugin-persistedstate": "^3.1.0", - "vue": "^3.3.4" - } + "resolved": "../dxp-components", + "link": true }, "node_modules/@hotwax/oms-api": { - "version": "1.8.1", - "license": "Apache-2.0", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@hotwax/oms-api/-/oms-api-1.10.0.tgz", + "integrity": "sha512-Li9vqTsGHqfTalL2FWDAIPSEdiZyRLDQOcHzXf5YFo8yTLEgiBM1kvfl12nXYWRpVtE9DPDMHkqxkWRlQTM/Lw==", "dependencies": { "@types/node-json-transform": "^1.0.0", "axios": "^0.21.1", @@ -6129,6 +6154,15 @@ "node": ">=0.10.0" } }, + "node_modules/@vue/cli-plugin-unit-jest/node_modules/is-wsl": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", + "integrity": "sha512-gfygJYZ2gLTDlmbWMI0CE2MwnFzSN/2SZfkMlItC4K/JBlsWVDB0bO6XhqcY13YXE7iMcAJnzTCJjPiTeJJ0Mw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/@vue/cli-plugin-unit-jest/node_modules/istanbul-lib-coverage": { "version": "2.0.5", "dev": true, @@ -6667,6 +6701,28 @@ "node": ">=0.10.0" } }, + "node_modules/@vue/cli-plugin-unit-jest/node_modules/node-notifier": { + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-5.4.5.tgz", + "integrity": "sha512-tVbHs7DyTLtzOiN78izLA85zRqB9NvEXkAf014Vx3jtSvn/xBl6bR8ZYifj+dFcFrKI21huSQgJZ6ZtL3B4HfQ==", + "dev": true, + "dependencies": { + "growly": "^1.3.0", + "is-wsl": "^1.1.0", + "semver": "^5.5.0", + "shellwords": "^0.1.1", + "which": "^1.3.0" + } + }, + "node_modules/@vue/cli-plugin-unit-jest/node_modules/node-notifier/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true, + "bin": { + "semver": "bin/semver" + } + }, "node_modules/@vue/cli-plugin-unit-jest/node_modules/normalize-path": { "version": "2.1.1", "dev": true, @@ -22616,33 +22672,77 @@ "license": "MIT" }, "node_modules/node-notifier": { - "version": "5.4.5", + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-10.0.1.tgz", + "integrity": "sha512-YX7TSyDukOZ0g+gmzjB6abKu+hTGvO8+8+gIFDsRCU2t8fLV/P2unmt+LGFaIa4y64aX98Qksa97rgz4vMNeLQ==", "dev": true, - "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "growly": "^1.3.0", - "is-wsl": "^1.1.0", - "semver": "^5.5.0", + "is-wsl": "^2.2.0", + "semver": "^7.3.5", "shellwords": "^0.1.1", - "which": "^1.3.0" + "uuid": "^8.3.2", + "which": "^2.0.2" } }, - "node_modules/node-notifier/node_modules/is-wsl": { - "version": "1.1.0", + "node_modules/node-notifier/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, - "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "yallist": "^4.0.0" + }, "engines": { - "node": ">=4" + "node": ">=10" } }, "node_modules/node-notifier/node_modules/semver": { - "version": "5.7.2", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, - "license": "ISC", + "optional": true, + "peer": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, "bin": { - "semver": "bin/semver" + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/node-notifier/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "optional": true, + "peer": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" } }, + "node_modules/node-notifier/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true, + "optional": true, + "peer": true + }, "node_modules/node-releases": { "version": "2.0.13", "dev": true, @@ -23437,61 +23537,6 @@ "node": ">=0.10.0" } }, - "node_modules/pinia": { - "version": "2.0.36", - "license": "MIT", - "dependencies": { - "@vue/devtools-api": "^6.5.0", - "vue-demi": "*" - }, - "funding": { - "url": "https://github.com/sponsors/posva" - }, - "peerDependencies": { - "@vue/composition-api": "^1.4.0", - "typescript": ">=4.4.4", - "vue": "^2.6.14 || ^3.2.0" - }, - "peerDependenciesMeta": { - "@vue/composition-api": { - "optional": true - }, - "typescript": { - "optional": true - } - } - }, - "node_modules/pinia-plugin-persistedstate": { - "version": "3.2.0", - "license": "MIT", - "peerDependencies": { - "pinia": "^2.0.0" - } - }, - "node_modules/pinia/node_modules/vue-demi": { - "version": "0.14.5", - "hasInstallScript": true, - "license": "MIT", - "bin": { - "vue-demi-fix": "bin/vue-demi-fix.js", - "vue-demi-switch": "bin/vue-demi-switch.js" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/antfu" - }, - "peerDependencies": { - "@vue/composition-api": "^1.0.0-rc.1", - "vue": "^3.0.0-0 || ^2.6.0" - }, - "peerDependenciesMeta": { - "@vue/composition-api": { - "optional": true - } - } - }, "node_modules/pinkie": { "version": "2.0.4", "dev": true, @@ -27608,7 +27653,7 @@ }, "node_modules/typescript": { "version": "4.7.4", - "devOptional": true, + "dev": true, "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", @@ -31937,19 +31982,38 @@ "version": "1.2.3" }, "@hotwax/dxp-components": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/@hotwax/dxp-components/-/dxp-components-1.3.4.tgz", - "integrity": "sha512-uw0dmxm19lzsgcLWZ2fQBAZem0d7TkxGR0iSq1c7Bj1mkAJZXH5JbP12w0lYhtes7Q1MjhHPlWljCh6624E9XA==", + "version": "file:../dxp-components", "requires": { + "@babel/types": "^7.22.11", "@hotwax/oms-api": "^1.8.1", + "@ionic/core": "^6.7.5", + "@ionic/vue": "^6.7.5", + "@types/luxon": "^3.3.0", + "@types/node": "^20.5.7", + "@types/vue-barcode-reader": "^0.0.0", + "@vitejs/plugin-vue": "^4.3.4", + "@vue/eslint-config-prettier": "^8.0.0", + "@vue/eslint-config-typescript": "^11.0.3", + "@vue/tsconfig": "^0.1.3", + "eslint": "^8.48.0", + "eslint-plugin-vue": "^9.17.0", + "firebase": "^10.3.1", "luxon": "^3.3.0", "pinia": "2.0.36", "pinia-plugin-persistedstate": "^3.1.0", - "vue": "^3.3.4" + "rollup-plugin-typescript2": "^0.35.0", + "typescript": "~4.7.4", + "vite": "^4.4.9", + "vue": "^3.3.4", + "vue-barcode-reader": "^1.0.3", + "vue-i18n": "^9.2.2", + "vue-tsc": "^1.8.8" } }, "@hotwax/oms-api": { - "version": "1.8.1", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@hotwax/oms-api/-/oms-api-1.10.0.tgz", + "integrity": "sha512-Li9vqTsGHqfTalL2FWDAIPSEdiZyRLDQOcHzXf5YFo8yTLEgiBM1kvfl12nXYWRpVtE9DPDMHkqxkWRlQTM/Lw==", "requires": { "@types/node-json-transform": "^1.0.0", "axios": "^0.21.1", @@ -34728,6 +34792,12 @@ } } }, + "is-wsl": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", + "integrity": "sha512-gfygJYZ2gLTDlmbWMI0CE2MwnFzSN/2SZfkMlItC4K/JBlsWVDB0bO6XhqcY13YXE7iMcAJnzTCJjPiTeJJ0Mw==", + "dev": true + }, "istanbul-lib-coverage": { "version": "2.0.5", "dev": true @@ -35123,6 +35193,27 @@ } } }, + "node-notifier": { + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-5.4.5.tgz", + "integrity": "sha512-tVbHs7DyTLtzOiN78izLA85zRqB9NvEXkAf014Vx3jtSvn/xBl6bR8ZYifj+dFcFrKI21huSQgJZ6ZtL3B4HfQ==", + "dev": true, + "requires": { + "growly": "^1.3.0", + "is-wsl": "^1.1.0", + "semver": "^5.5.0", + "shellwords": "^0.1.1", + "which": "^1.3.0" + }, + "dependencies": { + "semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true + } + } + }, "normalize-path": { "version": "2.1.1", "dev": true, @@ -45887,23 +45978,61 @@ } }, "node-notifier": { - "version": "5.4.5", + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-10.0.1.tgz", + "integrity": "sha512-YX7TSyDukOZ0g+gmzjB6abKu+hTGvO8+8+gIFDsRCU2t8fLV/P2unmt+LGFaIa4y64aX98Qksa97rgz4vMNeLQ==", "dev": true, + "optional": true, + "peer": true, "requires": { "growly": "^1.3.0", - "is-wsl": "^1.1.0", - "semver": "^5.5.0", + "is-wsl": "^2.2.0", + "semver": "^7.3.5", "shellwords": "^0.1.1", - "which": "^1.3.0" + "uuid": "^8.3.2", + "which": "^2.0.2" }, "dependencies": { - "is-wsl": { - "version": "1.1.0", - "dev": true + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "optional": true, + "peer": true, + "requires": { + "yallist": "^4.0.0" + } }, "semver": { - "version": "5.7.2", - "dev": true + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "optional": true, + "peer": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "optional": true, + "peer": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true, + "optional": true, + "peer": true } } }, @@ -46421,23 +46550,6 @@ "version": "2.3.0", "dev": true }, - "pinia": { - "version": "2.0.36", - "requires": { - "@vue/devtools-api": "^6.5.0", - "vue-demi": "*" - }, - "dependencies": { - "vue-demi": { - "version": "0.14.5", - "requires": {} - } - } - }, - "pinia-plugin-persistedstate": { - "version": "3.2.0", - "requires": {} - }, "pinkie": { "version": "2.0.4", "dev": true @@ -49284,7 +49396,7 @@ }, "typescript": { "version": "4.7.4", - "devOptional": true + "dev": true }, "uglify-js": { "version": "3.4.10", diff --git a/package.json b/package.json index e3e94bc3..9d1ccea2 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ "@casl/ability": "^6.0.0", "@hotwax/app-version-info": "^1.0.0", "@hotwax/apps-theme": "^1.1.0", - "@hotwax/dxp-components": "^1.3.4", - "@hotwax/oms-api": "^1.7.0", + "@hotwax/dxp-components": "file:../dxp-components", + "@hotwax/oms-api": "^1.10.0", "@ionic/core": "6.7.5", "@ionic/vue": "6.7.5", "@ionic/vue-router": "6.7.5", diff --git a/src/adapter/index.ts b/src/adapter/index.ts index 0d512378..99fa8352 100644 --- a/src/adapter/index.ts +++ b/src/adapter/index.ts @@ -1,8 +1,9 @@ -import { api, client, initialise, resetConfig, updateInstanceUrl, updateToken } from '@hotwax/oms-api' +import { api, client, getConfig, initialise, resetConfig, updateInstanceUrl, updateToken } from '@hotwax/oms-api' export { api, client, + getConfig, initialise, resetConfig, updateInstanceUrl, diff --git a/src/main.ts b/src/main.ts index d27124dd..b86d0a97 100644 --- a/src/main.ts +++ b/src/main.ts @@ -33,6 +33,7 @@ import permissionRules from '@/authorization/Rules'; import permissionActions from '@/authorization/Actions'; import { dxpComponents } from '@hotwax/dxp-components' import { login, logout, loader } from './user-utils'; +import { getConfig, initialise } from './adapter'; const app = createApp(App) .use(IonicVue, { @@ -50,7 +51,9 @@ const app = createApp(App) login, logout, loader, - appLoginUrl: process.env.VUE_APP_LOGIN_URL as string + appLoginUrl: process.env.VUE_APP_LOGIN_URL as string, + getConfig, + initialise }); // Filters are removed in Vue 3 and global filter introduced https://v3.vuejs.org/guide/migration/filters.html#global-filters diff --git a/src/views/Settings.vue b/src/views/Settings.vue index fd91a018..bc555ff7 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -51,22 +51,8 @@ <ion-icon slot="end" :icon="openOutline" /> </ion-button> </ion-card> - <ion-card> - <ion-card-header> - <ion-card-title> - {{ $t("Facility") }} - </ion-card-title> - </ion-card-header> - <ion-card-content> - {{ $t('Specify which facility you want to operate from. Order, inventory and other configuration data will be specific to the facility you select.') }} - </ion-card-content> - <ion-item lines="none"> - <ion-label>{{ $t("Select facility") }}</ion-label> - <ion-select interface="popover" v-model="currentFacilityId" @ionChange="setFacility($event)"> - <ion-select-option v-for="facility in (userProfile ? userProfile.facilities : [])" :key="facility.facilityId" :value="facility.facilityId" >{{ facility.name }}</ion-select-option> - </ion-select> - </ion-item> - </ion-card> + + <FacilitySwitcher @check-facility="checkFacility"/> </section> <hr /> <div class="section-header"> @@ -111,7 +97,7 @@ </template> <script lang="ts"> -import { alertController, IonAvatar, IonButton, IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle, IonContent, IonHeader,IonIcon, IonItem, IonLabel, IonPage, IonSelect, IonSelectOption, IonTitle, IonToggle, IonToolbar, modalController } from '@ionic/vue'; +import { alertController, IonAvatar, IonButton, IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle, IonContent, IonHeader,IonIcon, IonItem, IonLabel, IonPage, IonTitle, IonToggle, IonToolbar, modalController } from '@ionic/vue'; import { defineComponent } from 'vue'; import { codeWorkingOutline, ellipsisVertical, personCircleOutline, storefrontOutline, openOutline} from 'ionicons/icons' import { mapGetters, useStore } from 'vuex'; @@ -128,31 +114,28 @@ export default defineComponent({ name: 'Settings', components: { IonAvatar, - IonButton, + IonButton, IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle, - IonContent, - IonHeader, + IonContent, + IonHeader, IonIcon, - IonItem, - IonLabel, - IonPage, - IonSelect, - IonSelectOption, + IonItem, + IonLabel, + IonPage, IonTitle, IonToggle, IonToolbar, Image - }, +}, data() { return { baseURL: process.env.VUE_APP_BASE_URL, appInfo: (process.env.VUE_APP_VERSION_INFO ? JSON.parse(process.env.VUE_APP_VERSION_INFO) : {}) as any, appVersion: "", - currentFacilityId: "", currentQOHViewConfig: {} as any }; }, @@ -160,7 +143,6 @@ export default defineComponent({ this.appVersion = this.appInfo.branch ? (this.appInfo.branch + "-" + this.appInfo.revision) : this.appInfo.tag; }, ionViewWillEnter() { - this.currentFacilityId = this.currentFacility.facilityId; this.getViewQOHConfig(); }, computed: { @@ -205,18 +187,9 @@ export default defineComponent({ // Fetch the updated configuration await this.getViewQOHConfig(); }, - setFacility (event: any) { - // adding check for this.currentFacility.facilityId as it gets set to undefined on logout - // but setFacility is called again due to :value="currentFacility.facilityId" in ion-select - if (this.userProfile && this.currentFacility.facilityId && event.detail.value != this.currentFacility.facilityId ) { - if (Object.keys(this.uploadProducts).length > 0) { - this.presentAlertOnFacilityChange(event.detail.value); - } else { - this.store.dispatch('user/setFacility', { - 'facility': this.userProfile.facilities.find((fac: any) => fac.facilityId == event.detail.value) - }); - this.currentFacilityId = this.currentFacility.facilityId; - } + checkFacility (facilityId: any) { + if (Object.keys(this.uploadProducts).length > 0) { + this.presentAlertOnFacilityChange(facilityId); } }, async presentAlertOnLogout() { @@ -239,27 +212,27 @@ export default defineComponent({ await alert.present(); }, async presentAlertOnFacilityChange(facilityId: string) { + let facilityUpdateCancelled = false const alert = await alertController.create({ header: this.$t('Set facility'), message: this.$t('The products in the upload list will be removed.'), buttons: [{ text: this.$t('Cancel'), handler: () => { - this.currentFacilityId = this.currentFacility.facilityId + facilityUpdateCancelled = true } }, { text: this.$t('Ok'), handler: () => { this.store.dispatch('product/clearUploadProducts'); - this.store.dispatch('user/setFacility', { - 'facility': this.userProfile.facilities.find((fac: any) => fac.facilityId == facilityId) - }); - this.currentFacilityId = this.currentFacility.facilityId } }] }); await alert.present(); + if(facilityUpdateCancelled) { + throw new Error('Facility Update Cancelled') + } }, async changeTimeZone() { const timeZoneModal = await modalController.create({ diff --git a/vue.config.js b/vue.config.js index aec5bde1..d6c807fd 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,3 +1,4 @@ +const path = require('path') require("@hotwax/app-version-info") module.exports = { pluginOptions: { @@ -12,5 +13,13 @@ module.exports = { enableInSFC: true } }, - runtimeCompiler: true + configureWebpack: { + resolve: { + alias: { + vue: path.resolve('./node_modules/vue') + } + } + }, + runtimeCompiler: true, + transpileDependencies: ['@hotwax/dxp-components'] } From cdb19bec17260d1a6add019e6e5dfd55a58f664f Mon Sep 17 00:00:00 2001 From: amansinghbais <singh11amanbais@gmail.com> Date: Thu, 5 Oct 2023 10:00:35 +0530 Subject: [PATCH 2/5] Improved: code for handling before facility change emit (dxp/138) --- src/views/Settings.vue | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/views/Settings.vue b/src/views/Settings.vue index bc555ff7..31f0c94d 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -187,9 +187,9 @@ export default defineComponent({ // Fetch the updated configuration await this.getViewQOHConfig(); }, - checkFacility (facilityId: any) { + checkFacility(facilityId: any) { if (Object.keys(this.uploadProducts).length > 0) { - this.presentAlertOnFacilityChange(facilityId); + this.presentAlertOnFacilityChange(); } }, async presentAlertOnLogout() { @@ -211,7 +211,8 @@ export default defineComponent({ }); await alert.present(); }, - async presentAlertOnFacilityChange(facilityId: string) { + async presentAlertOnFacilityChange() { + let facilityUpdateCancelled = false const alert = await alertController.create({ header: this.$t('Set facility'), From 2be293d83202508f6809f54469232dfb75eddde1 Mon Sep 17 00:00:00 2001 From: amansinghbais <singh11amanbais@gmail.com> Date: Fri, 6 Oct 2023 14:23:13 +0530 Subject: [PATCH 3/5] Improved: logic for handling alert before setFacility (dxp/138) --- src/views/Settings.vue | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 31f0c94d..220f9fe4 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -130,12 +130,13 @@ export default defineComponent({ IonToggle, IonToolbar, Image -}, + }, data() { return { baseURL: process.env.VUE_APP_BASE_URL, appInfo: (process.env.VUE_APP_VERSION_INFO ? JSON.parse(process.env.VUE_APP_VERSION_INFO) : {}) as any, appVersion: "", + currentFacilityId: "", currentQOHViewConfig: {} as any }; }, @@ -143,6 +144,7 @@ export default defineComponent({ this.appVersion = this.appInfo.branch ? (this.appInfo.branch + "-" + this.appInfo.revision) : this.appInfo.tag; }, ionViewWillEnter() { + this.currentFacilityId = this.currentFacility.facilityId; this.getViewQOHConfig(); }, computed: { @@ -189,7 +191,7 @@ export default defineComponent({ }, checkFacility(facilityId: any) { if (Object.keys(this.uploadProducts).length > 0) { - this.presentAlertOnFacilityChange(); + this.presentAlertOnFacilityChange(facilityId); } }, async presentAlertOnLogout() { @@ -211,29 +213,27 @@ export default defineComponent({ }); await alert.present(); }, - async presentAlertOnFacilityChange() { - - let facilityUpdateCancelled = false + async presentAlertOnFacilityChange(facilityId: string) { const alert = await alertController.create({ header: this.$t('Set facility'), message: this.$t('The products in the upload list will be removed.'), buttons: [{ text: this.$t('Cancel'), handler: () => { - facilityUpdateCancelled = true + this.store.dispatch('user/setFacility', { + 'facility': this.userProfile.facilities.find((fac: any) => fac.facilityId == this.currentFacilityId) + }); } }, { text: this.$t('Ok'), handler: () => { this.store.dispatch('product/clearUploadProducts'); + this.currentFacilityId = facilityId; } }] }); await alert.present(); - if(facilityUpdateCancelled) { - throw new Error('Facility Update Cancelled') - } }, async changeTimeZone() { const timeZoneModal = await modalController.create({ From d3c4a8bd6fcf479976f9689325f490a831dfbad0 Mon Sep 17 00:00:00 2001 From: amansinghbais <singh11amanbais@gmail.com> Date: Mon, 9 Oct 2023 18:20:27 +0530 Subject: [PATCH 4/5] Improved: dxp component name changed to DxpFacilitySwitcher (dxp/138) --- package-lock.json | 1 + src/views/Settings.vue | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index b69e6528..9894d85a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -63,6 +63,7 @@ } }, "../dxp-components": { + "name": "@hotwax/dxp-components", "version": "1.7.5", "license": "Apache-2.0", "dependencies": { diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 220f9fe4..1fef429c 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -52,7 +52,7 @@ </ion-button> </ion-card> - <FacilitySwitcher @check-facility="checkFacility"/> + <DxpFacilitySwitcher @check-facility="checkFacility"/> </section> <hr /> <div class="section-header"> From dbf31f2cb0c2e11268e439eef99ff35cde440be6 Mon Sep 17 00:00:00 2001 From: amansinghbais <singh11amanbais@gmail.com> Date: Tue, 10 Oct 2023 16:25:07 +0530 Subject: [PATCH 5/5] Improved: unused filter in actions (dxp/138) --- src/store/modules/user/actions.ts | 6 ++---- src/views/Settings.vue | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 9ae8cfab..b682c37c 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -122,10 +122,8 @@ const actions: ActionTree<UserState, RootState> = { // update current facility information async setFacility ({ commit, state }, payload) { - let facility = payload.facility; - if(!facility && state.current?.facilities) { - facility = state.current.facilities.find((facility: any) => facility.facilityId === payload.facilityId); - } + const facility = payload.facility; + commit(types.USER_CURRENT_FACILITY_UPDATED, facility); const eComStore = await UserService.getCurrentEComStore(undefined, facility?.facilityId); commit(types.USER_CURRENT_ECOM_STORE_UPDATED, eComStore) diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 1fef429c..0e771040 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -52,7 +52,7 @@ </ion-button> </ion-card> - <DxpFacilitySwitcher @check-facility="checkFacility"/> + <DxpFacilitySwitcher @before-set-facility="beforeSetFacility"/> </section> <hr /> <div class="section-header"> @@ -189,7 +189,7 @@ export default defineComponent({ // Fetch the updated configuration await this.getViewQOHConfig(); }, - checkFacility(facilityId: any) { + beforeSetFacility(facilityId: any) { if (Object.keys(this.uploadProducts).length > 0) { this.presentAlertOnFacilityChange(facilityId); }