From e4c029dc24e7b7f3acedc23131188d87fd1121b5 Mon Sep 17 00:00:00 2001 From: David Whittaker Date: Fri, 8 Dec 2023 14:51:04 -0800 Subject: [PATCH 1/2] Allows for an incident commander to be specified --- src/dispatch/incident/models.py | 1 + src/dispatch/incident/service.py | 4 ++- .../src/incident/ReportSubmissionCard.vue | 25 ++++++++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/dispatch/incident/models.py b/src/dispatch/incident/models.py index 4b2ee2d5b3d4..75b5dbb77036 100644 --- a/src/dispatch/incident/models.py +++ b/src/dispatch/incident/models.py @@ -285,6 +285,7 @@ def description_required(cls, v): class IncidentCreate(IncidentBase): commander: Optional[ParticipantUpdate] + commander_email: Optional[str] incident_priority: Optional[IncidentPriorityCreate] incident_severity: Optional[IncidentSeverityCreate] incident_type: Optional[IncidentTypeCreate] diff --git a/src/dispatch/incident/service.py b/src/dispatch/incident/service.py index c7838fd30bb5..6baeb138fb34 100644 --- a/src/dispatch/incident/service.py +++ b/src/dispatch/incident/service.py @@ -224,7 +224,9 @@ def create(*, db_session, incident_in: IncidentCreate) -> Incident: # add commander commander_email = commander_service_id = None - if incident_in.commander: + if incident_in.commander_email: + commander_email = incident_in.commander_email + elif incident_in.commander: commander_email = incident_in.commander.individual.email else: commander_email, commander_service_id = resolve_and_associate_role( diff --git a/src/dispatch/static/dispatch/src/incident/ReportSubmissionCard.vue b/src/dispatch/static/dispatch/src/incident/ReportSubmissionCard.vue index 066ea2ae2354..bc6fe6c1dacc 100644 --- a/src/dispatch/static/dispatch/src/incident/ReportSubmissionCard.vue +++ b/src/dispatch/static/dispatch/src/incident/ReportSubmissionCard.vue @@ -68,6 +68,17 @@ + + + @@ -105,6 +116,7 @@ import IncidentPrioritySelect from "@/incident/priority/IncidentPrioritySelect.v import IncidentTypeSelect from "@/incident/type/IncidentTypeSelect.vue" import ProjectSelect from "@/project/ProjectSelect.vue" import TagFilterAutoComplete from "@/tag/TagFilterAutoComplete.vue" +import ParticipantSelect from "@/components/ParticipantSelect.vue" export default { setup() { @@ -119,12 +131,20 @@ export default { IncidentPrioritySelect, ProjectSelect, TagFilterAutoComplete, + ParticipantSelect, }, data() { return { isSubmitted: false, project_faq: null, + local_commander: null, + only_one: (value) => { + if (value && value.length > 1) { + return "Only one is allowed" + } + return true + }, } }, @@ -132,7 +152,7 @@ export default { ...mapFields("incident", [ "selected.incident_priority", "selected.incident_type", - "selected.commander", + "selected.commander_email", "selected.title", "selected.tags", "selected.description", @@ -248,9 +268,11 @@ export default { vm.incident_type, vm.title, vm.description, + vm.local_commander, vm.tags, ], () => { + if (Array.isArray(this.local_commander)) this.commander_email = this.local_commander[0].individual.email var queryParams = { project: this.project ? this.project.name : null, incident_priority: this.incident_priority ? this.incident_priority.name : null, @@ -258,6 +280,7 @@ export default { title: this.title, description: this.description, tag: this.tags ? this.tags.map((tag) => tag.name) : null, + commander_email: this.commander_email, } Object.keys(queryParams).forEach((key) => (queryParams[key] ? {} : delete queryParams[key])) router From 57e97881b7875571407af8b81b505c5eccbb352e Mon Sep 17 00:00:00 2001 From: David Whittaker Date: Fri, 8 Dec 2023 14:57:07 -0800 Subject: [PATCH 2/2] Fixing lint errors --- .../static/dispatch/src/incident/ReportSubmissionCard.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dispatch/static/dispatch/src/incident/ReportSubmissionCard.vue b/src/dispatch/static/dispatch/src/incident/ReportSubmissionCard.vue index bc6fe6c1dacc..b1b1d6fbe1b2 100644 --- a/src/dispatch/static/dispatch/src/incident/ReportSubmissionCard.vue +++ b/src/dispatch/static/dispatch/src/incident/ReportSubmissionCard.vue @@ -272,7 +272,8 @@ export default { vm.tags, ], () => { - if (Array.isArray(this.local_commander)) this.commander_email = this.local_commander[0].individual.email + if (Array.isArray(this.local_commander)) + this.commander_email = this.local_commander[0].individual.email var queryParams = { project: this.project ? this.project.name : null, incident_priority: this.incident_priority ? this.incident_priority.name : null,