From ca91a63ac2c3ed3134050307d4694a40ad0f1204 Mon Sep 17 00:00:00 2001 From: Jose Chirivella Date: Thu, 30 Nov 2023 12:28:37 -0600 Subject: [PATCH 1/2] FOUR-12672 Defaulting to the prop Types --- .../screens/components/CreateScreenModal.vue | 12 ++++++------ resources/js/utils/filterScreenType.js | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/resources/js/processes/screens/components/CreateScreenModal.vue b/resources/js/processes/screens/components/CreateScreenModal.vue index 7466406596..14b77402dc 100644 --- a/resources/js/processes/screens/components/CreateScreenModal.vue +++ b/resources/js/processes/screens/components/CreateScreenModal.vue @@ -78,7 +78,7 @@ v-if="isProjectsInstalled" v-model="formData.projects" :errors="errors.projects" - :projectId="projectId" + :project-id="projectId" :label="$t('Project')" :required="isProjectSelectionRequired" api-get="projects" @@ -161,13 +161,13 @@ export default { this.resetFormData(); this.resetErrors(); if (this.isQuickCreate === true) { - this.screenTypes = filterScreenType(); + this.screenTypes = filterScreenType() ?? this.types; // in any case the screenType if the only one, default to the first value if (Object.keys(this.screenTypes).length === 1) this.formData.type = Object.keys(this.screenTypes)[0]; } if (this.callFromAiModeler === true) { this.screenTypes = this.types; - } + } }, methods: { show() { @@ -193,10 +193,10 @@ export default { this.resetErrors(); }, close() { - this.$bvModal.hide('createScreen'); + this.$bvModal.hide("createScreen"); this.disabled = false; - this.$emit('reload'); - }, + this.$emit("reload"); + }, onSubmit() { this.resetErrors(); // single click diff --git a/resources/js/utils/filterScreenType.js b/resources/js/utils/filterScreenType.js index b6b55288e7..e1ef413b49 100644 --- a/resources/js/utils/filterScreenType.js +++ b/resources/js/utils/filterScreenType.js @@ -4,6 +4,7 @@ import { ScreenTypes } from "../models/screens"; * Filter the screen types based on the task */ export function filterScreenType() { - const screen = new URLSearchParams(window.location.search).get("screenType").split(","); + const screen = new URLSearchParams(window.location.search).get("screenType")?.split(","); + if (!screen) return; return Object.fromEntries(Object.entries(ScreenTypes).filter(([key]) => screen.includes(key))); } From d75cccc3d9760ee221bcfc204f459a7bfdf7e71f Mon Sep 17 00:00:00 2001 From: Jose Chirivella Date: Thu, 30 Nov 2023 12:47:47 -0600 Subject: [PATCH 2/2] FOUR-12672 Added jsdoc for the return type --- resources/js/utils/filterScreenType.js | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/js/utils/filterScreenType.js b/resources/js/utils/filterScreenType.js index e1ef413b49..f5fc057c4c 100644 --- a/resources/js/utils/filterScreenType.js +++ b/resources/js/utils/filterScreenType.js @@ -2,6 +2,7 @@ import { ScreenTypes } from "../models/screens"; /** * Filter the screen types based on the task + * @return {?Object}; */ export function filterScreenType() { const screen = new URLSearchParams(window.location.search).get("screenType")?.split(",");