From 106b111dd296058968310016acb38531a4a2b749 Mon Sep 17 00:00:00 2001 From: k2maan Date: Wed, 8 Nov 2023 14:58:36 +0530 Subject: [PATCH 1/4] Implemented: support for editing custom parameters on 'run now' (#628) --- src/components/JobConfiguration.vue | 50 +++++++++------------------- src/components/JobParameterModal.vue | 38 ++++++++++++++++++--- 2 files changed, 49 insertions(+), 39 deletions(-) diff --git a/src/components/JobConfiguration.vue b/src/components/JobConfiguration.vue index a27be9a9..7eaef23f 100644 --- a/src/components/JobConfiguration.vue +++ b/src/components/JobConfiguration.vue @@ -46,16 +46,16 @@ - + {{ $t('Add custom parameters') }} - + {{ name }}: {{ value }} - + @@ -94,7 +94,7 @@ {{ $t("History") }} - + {{ $t("Run now") }} @@ -388,33 +388,6 @@ export default defineComponent({ jobHistoryModal.dismiss({ dismissed: true }); }) }, - async runNow(job: any) { - const jobAlert = await alertController - .create({ - header: this.$t("Run now"), - message: this.$t('Running this job now will not replace this job. A copy of this job will be created and run immediately. You may not be able to reverse this action.', { space: '

' }), - buttons: [ - { - text: this.$t("Cancel"), - role: 'cancel', - }, - { - text: this.$t('Run now'), - handler: () => { - if (job && !hasJobDataError(job)) { - - // preparing the custom parameters those needs to passed with the job - const jobCustomParameters = generateJobCustomParameters(this.customRequiredParameters, this.customOptionalParameters, job.runtimeData) - - this.store.dispatch('job/runServiceNow', { job, jobCustomParameters }) - } - } - } - ] - }); - - return jobAlert.present(); - }, async copyJobInformation(job: any) { const { Clipboard } = Plugins; const jobDetails = `jobId: ${job.jobId}, jobName: ${job.enumName}, jobDescription: ${job.description} ${job.runtimeData ? (", runtimeData: " + JSON.stringify(job.runtimeData)) : ""}`; @@ -447,10 +420,19 @@ export default defineComponent({ if (setTime > currTime) this.generateRunTimes(setTime) else showToast(translate("Provide a future date and time")) }, - async openJobCustomParameterModal() { + async openJobCustomParameterModal(runNow?: boolean) { const jobParameterModal = await modalController.create({ - component: JobParameterModal, - componentProps: { customOptionalParameters: this.customOptionalParameters, customRequiredParameters: this.customRequiredParameters, currentJob: this.currentJob }, + component: JobParameterModal, + // deep cloning the props for the 'run now' case as the parameter objects are + // v-modeled in the job parameter modal hence, changes are reflected back on the UI + // (because of reference) which is misleading as the job with edited changes + // has already ran + componentProps: { + customOptionalParameters: runNow ? JSON.parse(JSON.stringify(this.customOptionalParameters)) : this.customOptionalParameters, + customRequiredParameters: runNow ? JSON.parse(JSON.stringify(this.customRequiredParameters)) : this.customRequiredParameters, + currentJob: runNow ? JSON.parse(JSON.stringify(this.currentJob)) : this.currentJob, + runNow + }, breakpoints: [0, 0.25, 0.5, 0.75, 1], initialBreakpoint: 0.75 }); diff --git a/src/components/JobParameterModal.vue b/src/components/JobParameterModal.vue index 487a119b..208696b5 100644 --- a/src/components/JobParameterModal.vue +++ b/src/components/JobParameterModal.vue @@ -1,8 +1,9 @@