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: additional job actions, to job config component (#364tt29) #212

Merged
merged 5 commits into from
Aug 26, 2022
Merged
110 changes: 105 additions & 5 deletions src/components/JobConfiguration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,34 @@
<ion-button expand="block" @click="saveChanges()">{{ $t("Save changes") }}</ion-button>
</div>
</section>
<div class="job-actions">
<ion-item slot="start" @click="viewJobHistory(currentJob)" button>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@azkyakhan Thoughts on slot here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This slots over here are not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

<ion-icon slot="start" :icon="timeOutline" />
{{ $t("History") }}
</ion-item>
<ion-item slot="end" @click="runNow(title, currentJob)" button>
<ion-icon slot="start" :icon="flashOutline" />
{{ $t("Run now") }}
</ion-item>
<ion-item slot="start" @click="copyJobInformation(currentJob)" button>
<ion-icon slot="start" :icon="copyOutline" />
{{ $t("Copy details") }}
</ion-item>
<ion-item slot="end" @click="updatePinnedJobs(currentJob?.systemJobEnumId)" button>
<ion-icon slot="start" :icon="pinOutline" />
{{ $t("Pin job") }}
<ion-checkbox :checked="getPinnedJobs.includes(currentJob.systemJobEnumId)" slot="end"></ion-checkbox>
</ion-item>
</div>

</template>

<script lang="ts">
import { defineComponent } from "vue";
import {
IonBadge,
IonButton,
IonCheckbox,
IonContent,
IonDatetime,
IonIcon,
Expand All @@ -86,15 +107,21 @@ import {
IonModal,
IonSelect,
IonSelectOption,
alertController
alertController,
modalController,
} from "@ionic/vue";
import {
calendarClearOutline,
flashOutline,
copyOutline,
timeOutline,
timerOutline,
syncOutline,
personCircleOutline
personCircleOutline,
pinOutline,
} from "ionicons/icons";
import JobHistoryModal from '@/components/JobHistoryModal.vue'
import { Plugins } from '@capacitor/core';
import { handleDateTimeInput, showToast } from "@/utils";
import { mapGetters, useStore } from "vuex";
import { DateTime } from 'luxon';
Expand All @@ -115,7 +142,8 @@ export default defineComponent({
IonList,
IonModal,
IonSelect,
IonSelectOption
IonSelectOption,
IonCheckbox
},
data() {
return {
Expand All @@ -127,6 +155,9 @@ export default defineComponent({
props: ["title", "status", "type"],
computed: {
...mapGetters({
getEnumDescription: 'job/getEnumDescription',
getEnumName: 'job/getEnumName',
getPinnedJobs: 'user/getPinnedJobs',
getJobStatus: 'job/getJobStatus',
getJob: 'job/getJob',
shopifyConfigId: 'user/getShopifyConfigId',
Expand Down Expand Up @@ -286,6 +317,60 @@ export default defineComponent({
if (job) {
job.runTime = handleDateTimeInput(ev['detail'].value)
}
},
async viewJobHistory(job: any) {
const jobHistoryModal = await modalController.create({
component: JobHistoryModal,
componentProps: { currentJob: job }
});
await jobHistoryModal.present();
jobHistoryModal.onDidDismiss().then(() => {
jobHistoryModal.dismiss({ dismissed: true });
})
},
async runNow(header: string, job: any) {
const jobAlert = await alertController
.create({
header,
message: this.$t('This job will be scheduled to run as soon as possible. There may not be enough time to revert this action.', {space: '<br/><br/>'}),
buttons: [
{
text: this.$t("Cancel"),
role: 'cancel',
},
{
text: this.$t('Run now'),
handler: () => {
if (job) {
this.store.dispatch('job/runServiceNow', job)
}
}
}
]
});

return jobAlert.present();
},
async copyJobInformation(job: any) {
const { Clipboard } = Plugins;
const jobDetails = `jobId: ${job.jobId}, jobName: ${this.getEnumName(job.systemJobEnumId)}, jobDescription: ${this.getEnumDescription(job.systemJobEnumId)}`;

await Clipboard.write({
string: jobDetails
}).then(() => {
showToast(this.$t("Copied job details to clipboard"));
})
},
async updatePinnedJobs(enumId: any) {
const pinnedJobs = new Set(this.getPinnedJobs);
if(pinnedJobs.has(enumId)) {
pinnedJobs.delete(enumId);
await this.store.dispatch('user/updatePinnedJobs', { pinnedJobs: [...pinnedJobs] });
emitter.emit("pinnedJobsUpdated", enumId);
} else {
pinnedJobs.add(enumId);
await this.store.dispatch('user/updatePinnedJobs', { pinnedJobs: [...pinnedJobs] });
}
}
},
setup() {
Expand All @@ -294,12 +379,15 @@ export default defineComponent({

return {
calendarClearOutline,
copyOutline,
flashOutline,
timeOutline,
timerOutline,
store,
router,
syncOutline,
personCircleOutline
personCircleOutline,
pinOutline
};
}
});
Expand Down Expand Up @@ -328,7 +416,19 @@ ion-list {

.mobile-only {
display: none;
}
}
.job-actions {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have an "actions" class. So job actions doesn't make sense here I think. "More actions" seems better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated sir

margin-top: var(--spacer-sm);
row-gap: var(--spacer-sm);
display: flex;
flex-wrap: wrap;
}
.job-actions > ion-item {
flex-basis: 50%;
}
.job-actions > ion-item > ion-checkbox{
margin: unset;
}
}

ion-label:nth-child(3) {
Expand Down