case 4742 - mass close and reopen of cases from the list extensions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-01 09:59:09 -07:00
parent 15c2b157df
commit d1813f6d63
2 changed files with 122 additions and 1 deletions

View File

@@ -0,0 +1,114 @@
<template>
<!-- case 4742: close or reopen the selected cases in one go (Sockeye only, so plain English, no translation keys) -->
<v-expansion-panel v-if="available == true">
<v-expansion-panel-header
disable-icon-rotate
expand-icon="$sockiCheckCircle"
>Close / reopen cases</v-expansion-panel-header
>
<v-expansion-panel-content>
<v-btn
color="blue darken-1"
text
:disabled="jobActive"
:loading="jobActive && !opening"
data-cy="extCloseCases"
@click="doAction(false)"
>Close</v-btn
>
<v-btn
color="blue darken-1"
text
:disabled="jobActive"
:loading="jobActive && opening"
data-cy="extOpenCases"
@click="doAction(true)"
>Reopen</v-btn
>
<v-btn
v-if="jobActive"
color="red darken-1"
text
@click="requestCancel()"
>
{{ $sock.t("Cancel") }}</v-btn
><span v-if="jobActive">{{ progress }}</span>
</v-expansion-panel-content>
</v-expansion-panel>
</template>
<script>
export default {
props: {
dataListSelection: { type: Object, default: null }
},
data: () => ({
jobActive: false,
opening: false,
currentJobId: null,
progress: ""
}),
computed: {
available() {
return (
this.dataListSelection != null &&
this.dataListSelection.SockType == window.$gz.type.GZCase &&
window.$gz.role.getRights(window.$gz.type.GZCase).change
);
}
},
methods: {
async requestCancel() {
await window.$gz.api.upsert(
"job-operations/request-cancel",
this.currentJobId
);
},
async doAction(open) {
const vm = this;
//Clear any possible prior errors
vm.$emit("ext-show-job-log", "clear");
vm.opening = open;
const url = `job-operations/batch-close-cases?open=${open}`;
try {
this.progress = "";
let jobId = await window.$gz.api.upsert(url, this.dataListSelection);
if (jobId.error) {
throw new Error(window.$gz.errorHandler.errorToString(jobId, vm));
}
this.currentJobId = jobId.jobId;
vm.jobActive = true;
let jobProgress = {};
while (vm.jobActive == true) {
await window.$gz.util.sleepAsync(2000);
jobProgress = await window.$gz.api.get(
`job-operations/progress/${this.currentJobId}`
);
if (jobProgress.error) {
throw new Error(
window.$gz.errorHandler.errorToString(jobProgress, vm)
);
}
jobProgress = jobProgress.data;
this.progress = jobProgress.progress;
if (jobProgress.jobStatus == 4 || jobProgress.jobStatus == 0) {
if (jobProgress.jobStatus == 4) {
//emit job id and event to parent for log viewing
vm.$emit("ext-show-job-log", jobId);
}
throw new Error("Job failed");
}
if (jobProgress.jobStatus == 3) {
vm.jobActive = false;
}
}
//Here if it's completed successfully
window.$gz.eventBus.$emit("notify-success", vm.$sock.t("JobCompleted"));
vm.$emit("ext-close-refresh");
} catch (error) {
vm.jobActive = false;
window.$gz.eventBus.$emit("notify-error", vm.$sock.t("JobFailed"));
}
}
}
};
</script>

View File

@@ -24,6 +24,11 @@
<v-expansion-panels focusable>
<ExtensionTags :data-list-selection="dataListSelection" />
<ExtensionExport :data-list-selection="dataListSelection" />
<ExtensionCloseCases
:data-list-selection="dataListSelection"
@ext-close-refresh="close({ refresh: true })"
@ext-show-job-log="handleError($event)"
/>
<ExtensionDelete
:data-list-selection="dataListSelection"
@ext-close-refresh="close({ refresh: true })"
@@ -43,12 +48,14 @@
import ExtensionTags from "./extension-tags-control.vue";
import ExtensionExport from "./extension-export-control.vue";
import ExtensionDelete from "./extension-delete-control.vue";
import ExtensionCloseCases from "./extension-close-cases-control.vue";
export default {
components: {
ExtensionTags,
ExtensionExport,
ExtensionDelete
ExtensionDelete,
ExtensionCloseCases
},
data: () => ({
isVisible: false,