From 0e209486694bd955e417f40b995c2a5b8746fa4a Mon Sep 17 00:00:00 2001 From: Aditya Sharma Date: Tue, 4 Jul 2023 18:30:17 +0530 Subject: [PATCH] Implemented support for the default alias If default alias configuration is set the login page should prepopulate the OMS field --- .env.example | 3 ++- src/views/login.vue | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index aff94577..b518990c 100644 --- a/.env.example +++ b/.env.example @@ -11,4 +11,5 @@ VUE_APP_BASE_URL= VUE_APP_ORDER_IN_BRKRNG_FILTERS=["orderTypeId: SALES_ORDER", "facilityId: _NA_", "orderStatusId: ORDER_APPROVED", "!orderItemStatusId: ITEM_CANCELLED" ] VUE_APP_PERMISSION_ID= VUE_APP_ALIAS= -VUE_APP_CTGRY_AND_BRKRNG_JOB=["JOB_REL_PREODR_CAT", "JOB_BKR_ORD", "JOB_RLS_ORD_DTE"] \ No newline at end of file +VUE_APP_CTGRY_AND_BRKRNG_JOB=["JOB_REL_PREODR_CAT", "JOB_BKR_ORD", "JOB_RLS_ORD_DTE"] +VUE_APP_DEFAULT_ALIAS= \ No newline at end of file diff --git a/src/views/login.vue b/src/views/login.vue index 2436e005..57483eb7 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -56,7 +56,8 @@ export default defineComponent({ password: "", instanceUrl: "", baseURL: process.env.VUE_APP_BASE_URL, - alias: process.env.VUE_APP_ALIAS ? JSON.parse(process.env.VUE_APP_ALIAS) : {} + alias: process.env.VUE_APP_ALIAS ? JSON.parse(process.env.VUE_APP_ALIAS) : {}, + defaultAlias: process.env.VUE_APP_DEFAULT_ALIAS, }; }, computed: { @@ -65,7 +66,16 @@ export default defineComponent({ }) }, mounted() { - this.instanceUrl= this.currentInstanceUrl; + this.instanceUrl = this.currentInstanceUrl; + if (this.currentInstanceUrl) { + // If the current URL is available in alias show it for consistency + const currentInstanceUrlAlias = Object.keys(this.alias).find((key) => this.alias[key] === this.currentInstanceUrl); + currentInstanceUrlAlias && (this.instanceUrl = currentInstanceUrlAlias); + } + // If there is no current preference set the default one + if (!this.instanceUrl && this.defaultAlias) { + this.instanceUrl = this.defaultAlias; + } }, methods: { login: function () {