From 39ce28a3ee6db5851970dc7c25580177acadf08a Mon Sep 17 00:00:00 2001 From: Avery Date: Mon, 16 Dec 2024 10:12:14 -0800 Subject: [PATCH] Allow export of incident/case tags (#5613) * Allow export of tag fields for Incidents and Cases. * Add tags and tickets fields to get cases request (#5564) * Add tags and tickets fields to get cases request * Attempt to move include parameter in GET requests to Cases into database service. * Adding tests * Adding tests * Add tags and ticket fields back to CaseReadMinimal * Switch test from Incident to Case. * remove duplicates * Fix unused variable assignment * Fixing tests --------- Co-authored-by: kevgliss Co-authored-by: Kevin Glisson * Export tags as tag_type.name/tag.name * Preview case tag column as 'tag_type.name/tag.name' --------- Co-authored-by: kevgliss Co-authored-by: Kevin Glisson --- .../dispatch/src/case/TableExportDialog.vue | 13 +++++++++++++ .../src/incident/TableExportDialog.vue | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/dispatch/static/dispatch/src/case/TableExportDialog.vue b/src/dispatch/static/dispatch/src/case/TableExportDialog.vue index 60fb16242f0f..512950ed8de1 100644 --- a/src/dispatch/static/dispatch/src/case/TableExportDialog.vue +++ b/src/dispatch/static/dispatch/src/case/TableExportDialog.vue @@ -92,6 +92,11 @@ + Cancel @@ -171,6 +176,7 @@ export default { { text: "Severity", value: "case_severity.name", sortable: false }, { text: "Priority", value: "case_priority.name", sortable: false }, { text: "Assignee", value: "assignee.email", sortable: false }, + { text: "Tags", value: "tags", sortable: false }, { text: "Document Weblink", value: "case_document.weblink", sortable: false }, { text: "Storage Weblink", value: "storage.weblink", sortable: false }, ], @@ -216,6 +222,13 @@ export default { return CaseApi.getAll(params) .then((response) => { let items = response.data.items + items = items.map((item) => { + if ("tags" in item) { + const tags = item["tags"].map((tag) => `${tag.tag_type.name}/${tag.name}`) + item["tags"] = tags.join(", ") + } + return item + }) Util.exportCSV(items, "case-details-export.csv") this.exportLoading = false this.closeExport() diff --git a/src/dispatch/static/dispatch/src/incident/TableExportDialog.vue b/src/dispatch/static/dispatch/src/incident/TableExportDialog.vue index 188bf02d8d71..9d9b7636f424 100644 --- a/src/dispatch/static/dispatch/src/incident/TableExportDialog.vue +++ b/src/dispatch/static/dispatch/src/incident/TableExportDialog.vue @@ -93,6 +93,11 @@ + Cancel @@ -302,6 +307,13 @@ export default { value: "closed_at", sortable: false, }, + { + text: "Tags", + title: "Tags", + key: "tags", + value: "tags", + sortable: false, + }, { text: "Incident Document Weblink", title: "Incident Document Weblink", @@ -366,6 +378,13 @@ export default { return IncidentApi.getAll(params) .then((response) => { let items = response.data.items + items = items.map((item) => { + if ("tags" in item) { + const tags = item["tags"].map((tag) => `${tag.tag_type.name}/${tag.name}`) + item["tags"] = tags.join(", ") + } + return item + }) const fieldOrder = this.selectedFields.map((field) => field.value) Util.exportCSVOrdered(items, "incident-details-export.csv", fieldOrder) this.exportLoading = false