Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented: Validation to set only future date and time on setting job runtime. (#2tzb5w4) #255

Merged
merged 3 commits into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions src/components/InitialJobConfiguration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
<ion-item>
<ion-icon slot="start" :icon="timeOutline" />
<ion-label class="ion-text-wrap">{{ $t("Run time") }}</ion-label>
<ion-label class="ion-text-wrap" @click="() => isOpen = true" slot="end">{{ currentJob?.runTime ? getTime(currentJob?.runTime) : $t('Select run time') }}</ion-label>
<ion-label class="ion-text-wrap" @click="() => isOpen = true" slot="end">{{ runTime ? getTime(runTime) : $t('Select run time') }}</ion-label>
<ion-modal :is-open="isOpen" @didDismiss="() => isOpen = false">
<ion-content force-overscroll="false">
<ion-datetime
hour-cycle="h12"
:min="minDateTime"
:value="currentJob?.runTime ? getDateTime(currentJob.runTime) : ''"
hour-cycle="h23"
:value="runTime ? getDateTime(runTime) : ''"
@ionChange="updateRunTime($event, currentJob)"
:show-default-buttons="true"
/>
</ion-content>
</ion-modal>
Expand Down Expand Up @@ -121,7 +121,7 @@ import {
import { mapGetters, useStore } from "vuex";
import { translate } from "@/i18n";
import { DateTime } from 'luxon';
import { handleDateTimeInput,isFutureDate } from '@/utils';
import { handleDateTimeInput,isFutureDate, showToast } from '@/utils';

export default defineComponent({
name: "InitialJobConfiguration",
Expand All @@ -143,9 +143,13 @@ export default defineComponent({
isOpen: false,
lastShopifyOrderId: this.shopifyOrderId,
minDateTime: DateTime.now().toISO(),
jobEnums: JSON.parse(process.env?.VUE_APP_INITIAL_JOB_ENUMS as string) as any
jobEnums: JSON.parse(process.env?.VUE_APP_INITIAL_JOB_ENUMS as string) as any,
runTime: '' as any,
}
},
mounted() {
this.runTime = this.currentJob?.runTime
},
props: ['type', 'shopifyOrderId'],
computed: {
...mapGetters({
Expand Down Expand Up @@ -207,7 +211,14 @@ export default defineComponent({
},
updateRunTime(ev: CustomEvent, job: any) {
if (job) {
job.runTime = handleDateTimeInput(ev['detail'].value)
const currTime = DateTime.now().toMillis();
const setTime = handleDateTimeInput(ev['detail'].value);

if(setTime > currTime) {
this.runTime = setTime;
} else {
showToast(translate("Provide a future date and time"))
}
}
}
},
Expand Down Expand Up @@ -261,4 +272,10 @@ ion-item:nth-child(2) > ion-label:nth-child(3) {
display: none;
}
}

ion-modal {
--width: 290px;
--height: 440px;
--border-radius: 8px;
}
</style>
28 changes: 22 additions & 6 deletions src/components/JobConfiguration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<ion-item>
<ion-icon slot="start" :icon="timeOutline" />
<ion-label class="ion-text-wrap">{{ $t("Run time") }}</ion-label>
<ion-label class="ion-text-wrap" @click="() => isOpen = true" slot="end">{{ currentJob?.runTime ? getTime(currentJob.runTime) : $t('Select run time') }}</ion-label>
<ion-label class="ion-text-wrap" @click="() => isOpen = true" slot="end">{{ runTime ? getTime(runTime) : $t('Select run time') }}</ion-label>
<!-- TODO: display a button when we are not having a runtime and open the datetime component
on click of that button
Currently, when mapping the same datetime component for label and button so it's not working so for
Expand All @@ -25,10 +25,10 @@
<ion-modal class="date-time-modal" :is-open="isOpen" @didDismiss="() => isOpen = false">
<ion-content force-overscroll="false">
<ion-datetime
hour-cycle="h12"
:min="minDateTime"
:value="currentJob?.runTime ? getDateTime(currentJob.runTime) : ''"
hour-cycle="h23"
:value="runTime ? getDateTime(runTime) : ''"
@ionChange="updateRunTime($event, currentJob)"
:show-default-buttons="true"
ymaheshwari1 marked this conversation as resolved.
Show resolved Hide resolved
/>
</ion-content>
</ion-modal>
Expand Down Expand Up @@ -150,9 +150,12 @@ export default defineComponent({
return {
isOpen: false,
jobStatus: this.status,
minDateTime: DateTime.now().toISO()
runTime: '' as any,
}
},
mounted() {
this.runTime = this.currentJob?.runTime
},
updated() {
// When updating the job, the job is fetched again with the latest values
// Updated value should be set to instance variable jobStatus
Expand Down Expand Up @@ -324,7 +327,14 @@ export default defineComponent({
},
updateRunTime(ev: CustomEvent, job: any) {
if (job) {
job.runTime = handleDateTimeInput(ev['detail'].value)
const currTime = DateTime.now().toMillis();
ymaheshwari1 marked this conversation as resolved.
Show resolved Hide resolved
const setTime = handleDateTimeInput(ev['detail'].value);

if(setTime > currTime) {
this.runTime = setTime;
} else {
showToast(translate("Provide a future date and time"))
}
}
},
async viewJobHistory(job: any) {
Expand Down Expand Up @@ -442,4 +452,10 @@ ion-label:nth-child(3) {
cursor: pointer;
}


ion-modal {
--width: 290px;
--height: 440px;
--border-radius: 8px;
}
</style>
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"Pin job": "Pin job",
"Pinned jobs": "Pinned jobs",
"Pipeline": "Pipeline",
"Provide a future date and time": "Provide a future date and time",
"Process Uploads": "Process Uploads",
"Product": "Product",
"Products": "Products",
Expand Down