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

Fixed: job information disappear after cancelling (#462) #480

Merged
merged 1 commit into from
May 15, 2023
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
7 changes: 4 additions & 3 deletions src/components/JobConfiguration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ import {
} from "ionicons/icons";
import JobHistoryModal from '@/components/JobHistoryModal.vue'
import { Plugins } from '@capacitor/core';
import { isCustomRunTime, generateAllowedRunTimes, generateAllowedFrequencies, handleDateTimeInput, showToast } from "@/utils";
import { isCustomRunTime, generateAllowedRunTimes, generateAllowedFrequencies, handleDateTimeInput, showToast, hasError } from "@/utils";
import { mapGetters, useStore } from "vuex";
import { DateTime } from 'luxon';
import { translate } from '@/i18n'
Expand Down Expand Up @@ -214,7 +214,7 @@ export default defineComponent({
const runTimes = JSON.parse(JSON.stringify(generateAllowedRunTimes()))
let selectedRunTime
// 0 check for the 'Now' value and '' check for initial render
if (currentRunTime || currentRunTime === 0 || currentRunTime === '') {
if (currentRunTime || currentRunTime === 0 ) {
selectedRunTime = runTimes.some((runTime: any) => runTime.value === currentRunTime)
if (!selectedRunTime) runTimes.push({ label: this.getTime(currentRunTime), value: currentRunTime })
}
Expand Down Expand Up @@ -257,7 +257,7 @@ export default defineComponent({
text: this.$t('Cancel'),
handler: () => {
this.store.dispatch('job/cancelJob', job).then((resp) => {
if(resp.data?.successMessage) {
if(!hasError(resp)) {
emitter.emit('jobUpdated');
const category = this.$route.params?.category;
if (category) {
Expand Down Expand Up @@ -309,6 +309,7 @@ export default defineComponent({
if (job?.statusId === 'SERVICE_DRAFT') {
this.store.dispatch('job/scheduleService', job).then((job: any) => {
if(job?.jobId) {
emitter.emit('jobUpdated');
const category = this.$route.params.category;
if (category) {
this.router.push({ name: 'JobDetails', params: { jobId: job?.jobId, category: category }, replace: true });
Expand Down
4 changes: 3 additions & 1 deletion src/store/modules/job/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,16 +711,18 @@ const actions: ActionTree<JobState, RootState> = {
if (state.current && Object.keys(state.current).length) {
const fetchJobsResponse = fetchJobsResponses[0];
if (fetchJobsResponse.status === 200 && !hasError(fetchJobsResponse) && fetchJobsResponse.data?.docs.length) {
commit(types.JOB_CURRENT_UPDATED, fetchJobsResponse);
commit(types.JOB_CURRENT_UPDATED, fetchJobsResponse.data.docs[0]);
}
}
showToast(translate('Service updated successfully'))
} else {
showToast(translate('Something went wrong'))
return Promise.reject('Something went wrong' + resp.data);
}
} catch (err) {
showToast(translate('Something went wrong'))
logger.error(err)
return Promise.reject('Something went wrong' + err);
}
return resp;
},
Expand Down
4 changes: 4 additions & 0 deletions src/views/Miscellaneous.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ export default defineComponent({
JobConfiguration
},
mounted() {
emitter.on('jobUpdated', this.getMiscellaneousJobs);
this.getMiscellaneousJobs();
},
unmounted() {
emitter.off('jobUpdated', this.getMiscellaneousJobs);
},
data() {
return {
currentJob: '' as any,
Expand Down