Skip to content

Commit

Permalink
Improved: runtime logic and bottom sheet modal (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
amansinghbais committed Oct 23, 2023
1 parent fd03327 commit c5fd952
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 36 deletions.
42 changes: 16 additions & 26 deletions src/components/BatchModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</ion-toolbar>
</ion-header>

<ion-content class="custom-ion-content">
<ion-content>
<ion-item>
<ion-label position="fixed">{{ $t('Name') }}</ion-label>
<ion-input :placeholder="currentDateTime = getCurrentDateTime()" v-model="jobName" />
Expand All @@ -27,14 +27,12 @@
<ion-item>
<ion-icon slot="start" :icon="warningOutline" />
<ion-label>{{ $t('Unfillable orders') }}</ion-label>
<ion-toggle slot="end" :checked="unfillableOrder" @click="unfillableOrder = !unfillableOrder; updateCustomParameters()"></ion-toggle>
<ion-toggle slot="end" :checked="unfillableOrder" @ion-change="unfillableOrder = !unfillableOrder; updateCustomParameters()" />
</ion-item>

<ion-list v-if="customOptionalParameters.length || customRequiredParameters.length">
<ion-item lines="none">
<ion-label>
{{ 'More Parameters' }}
</ion-label>
<ion-label>{{ $t('More parameters') }}</ion-label>
</ion-item>

<ion-item-divider v-if="customRequiredParameters.length">
Expand All @@ -43,18 +41,17 @@

<ion-item :key="index" v-for="(parameter, index) in customRequiredParameters">
<ion-label>{{ parameter.name }}</ion-label>
<ion-input :placeholder="parameter.name" v-model="parameter.value" />
<ion-input :placeholder="parameter.value ? parameter.value : parameter.name" v-model="parameter.value" />
<ion-note slot="helper">{{ parameter.type }}</ion-note>
</ion-item>

<ion-item-divider v-if="customOptionalParameters.length" color="light">
<ion-label>{{ $t('Optional Parameters') }}</ion-label>
</ion-item-divider>

<ion-item :key="parameter.value" v-for="parameter in customOptionalParameters">
<ion-item :key="index" v-for="(parameter, index) in customOptionalParameters">
<ion-label>{{ parameter.name }}</ion-label>
<!-- Todo: look into issue with input taking one character at a time -->
<ion-input :placeholder="parameter.name" v-model="parameter.value" />
<ion-input :placeholder="parameter.value ? parameter.value : parameter.name" v-model="parameter.value"/>
<ion-note slot="helper">{{ parameter.type }}</ion-note>
</ion-item>
</ion-list>
Expand All @@ -73,7 +70,7 @@
<ion-icon slot="start" :icon="timeOutline" />
<ion-label>{{ $t('Run time') }}</ion-label>
<ion-select interface="popover" :placeholder="$t('Select')" :value="runTime" @ionChange="updateRunTime($event)">
<ion-select-option v-for="runTime in runTimes" :key="runTime.value" :value="runTime.value">{{ $t(runTime.label) }}</ion-select-option>
<ion-select-option v-for="runTime in runTimes" :key="runTime.value" :value="runTime.value">{{ runTime.label }}</ion-select-option>
</ion-select>

<ion-modal class="date-time-modal" :is-open="isDateTimeModalOpen" @didDismiss="() => isDateTimeModalOpen = false">
Expand All @@ -95,9 +92,8 @@
</ion-select>
</ion-item>
</ion-card>

</ion-content>
<ion-fab :disabled="!hasPermission(Actions.APP_JOB_UPDATE) || isRequiredParametersMissing" @click="updateJob()" vertical="bottom" horizontal="end" slot="fixed">
<ion-fab :disabled="!hasPermission(Actions.APP_JOB_UPDATE) || isRequiredParametersMissing" @click="updateJob()" vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button>
<ion-icon :icon="checkmarkDoneOutline" />
</ion-fab-button>
Expand Down Expand Up @@ -135,7 +131,7 @@ import { defineComponent } from 'vue';
import { closeOutline, checkmarkDoneOutline, ticketOutline, timeOutline, timerOutline, warningOutline } from 'ionicons/icons';
import { mapGetters, useStore } from 'vuex';
import { DateTime } from 'luxon';
import { handleDateTimeInput, generateAllowedFrequencies, generateAllowedRunTimes, generateJobCustomParameters, generateJobCustomOptions, getNowTimestamp, hasJobDataError, isCustomRunTime, showToast } from '@/utils';
import { handleDateTimeInput, generateAllowedFrequencies, generateAllowedRunTimes, generateJobCustomParameters, generateJobCustomOptions, getNowTimestamp, hasJobDataError, isCustomRunTime, isFutureDate, showToast } from '@/utils';
import { translate } from '@/i18n'
import CustomFrequencyModal from '@/components/CustomFrequencyModal.vue';
import { Actions, hasPermission } from '@/authorization'
Expand Down Expand Up @@ -242,9 +238,12 @@ export default defineComponent({
// return if job has missing data or error
if (hasJobDataError(job)) return;
if (this.runTime) {
job['runTime'] = DateTime.now().toMillis() + this.runTime
job.runTime = this.runTime != 0 ? (!isCustomRunTime(this.runTime) ? DateTime.now().toMillis() + this.runTime : this.runTime) : ''
// if job runTime is not a valid date then making runTime as empty
if (job?.runTime && !isFutureDate(job?.runTime)) {
job.runTime = ''
}
job['jobStatus'] = this.jobStatus !== 'SERVICE_DRAFT' ? this.jobStatus : 'HOURLY';
Expand Down Expand Up @@ -314,13 +313,4 @@ export default defineComponent({
};
},
});
</script>

<style scoped>
ion-content {
--offset-bottom: 100px;
}
.custom-ion-content {
--offset-bottom: 100px;
}
</style>
</script>
3 changes: 1 addition & 2 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"Automatically ship orders that are packed and have a tracking number if required.": "Automatically ship orders that are packed and have a tracking number if required.",
"Back-order parking": "Back-order parking",
"Backorder": "Backorder",
"Batch name": "Batch name",
"Batches": "Batches",
"before auto cancelation": "before auto cancelation",
"Before importing historical orders in bulk, make sure all products are set up or else order import will not run correctly.": "Before importing historical orders in bulk, make sure all products are set up or else order import will not run correctly.",
Expand Down Expand Up @@ -129,6 +128,7 @@
"Miscellaneous": "Miscellaneous",
"Miscellaneous jobs": "Miscellaneous jobs",
"More jobs": "More jobs",
"More parameters": "More parameters",
"More options": "More options",
"Name": "Name",
"New broker run": "New broker run",
Expand All @@ -152,7 +152,6 @@
"Open": "Open",
"Optional Parameters": "Optional Parameters",
"Order parking": "Order parking",
"Order queue": "Order queue",
"Order status": "Order status",
"Orders": "Orders",
"Order fulfillment": "Order fulfillment",
Expand Down
11 changes: 3 additions & 8 deletions src/views/Brokering.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ import { useRouter } from 'vue-router'
import { mapGetters } from "vuex";
import JobConfiguration from '@/components/JobConfiguration.vue';
import { DateTime } from 'luxon';
import { generateJobCustomOptions, generateJobCustomParameters, hasError, isFutureDate, showToast } from '@/utils';
import { generateJobCustomOptions, generateJobCustomParameters, isFutureDate } from '@/utils';
import emitter from '@/event-bus';
import MoreJobs from '@/components/MoreJobs.vue';
import { Actions, hasPermission } from '@/authorization'
Expand Down Expand Up @@ -152,15 +152,10 @@ export default defineComponent({
},
methods: {
async addBatch() {
const batchmodal = await modalController.create({
component: BatchModal
});
return batchmodal.present();
},
async editBatch(id: string, enumId: string) {
const batchmodal = await modalController.create({
component: BatchModal,
componentProps: {id, enumId}
breakpoints: [0, 0.25, 0.5, 0.75, 1],
initialBreakpoint: 1
});
return batchmodal.present();
},
Expand Down

0 comments on commit c5fd952

Please sign in to comment.