Skip to content

Commit

Permalink
Allow export of incident/case tags (#5613)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Kevin Glisson <[email protected]>

* Export tags as tag_type.name/tag.name

* Preview case tag column as 'tag_type.name/tag.name'

---------

Co-authored-by: kevgliss <[email protected]>
Co-authored-by: Kevin Glisson <[email protected]>
  • Loading branch information
3 people authored Dec 16, 2024
1 parent e3ee407 commit 39ce28a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/dispatch/static/dispatch/src/case/TableExportDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
<template #item.status="{ item }">
<case-status :status="item.status" :id="item.id" />
</template>
<template #item.tags="{ item }">
<span v-for="tag in item.tags" :key="tag">
<v-chip> {{ tag.tag_type.name }}/{{ tag.name }} </v-chip>
</span>
</template>
</v-data-table>
<v-spacer />
<v-btn @click="closeExport()" variant="text"> Cancel </v-btn>
Expand Down Expand Up @@ -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 },
],
Expand Down Expand Up @@ -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()
Expand Down
19 changes: 19 additions & 0 deletions src/dispatch/static/dispatch/src/incident/TableExportDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@
<template #item.status="{ item }">
<incident-status :status="item.status" :id="item.id" />
</template>
<template #item.tags="{ item }">
<span v-for="tag in item.tags" :key="tag">
<v-chip> {{ tag.tag_type.name }}/{{ tag.name }} </v-chip>
</span>
</template>
</v-data-table>
<v-spacer />
<v-btn @click="closeExport()" variant="text"> Cancel </v-btn>
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 39ce28a

Please sign in to comment.