From a62a3bd5524abd6649624ef916dc4014c7dbabf3 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Tue, 31 Jan 2023 19:25:39 -0800 Subject: [PATCH] Fixes issue when selects have null values (#2927) --- .../static/dispatch/src/case/type/CaseTypeSelect.vue | 8 +++++--- .../static/dispatch/src/data/query/QuerySelect.vue | 8 +++++--- .../static/dispatch/src/data/source/SourceSelect.vue | 8 +++++--- .../src/data/source/dataFormat/DataFormatSelect.vue | 8 +++++--- .../src/data/source/environment/EnvironmentSelect.vue | 8 +++++--- .../dispatch/src/data/source/status/StatusSelect.vue | 8 +++++--- .../src/data/source/transport/TransportSelect.vue | 8 +++++--- .../static/dispatch/src/data/source/type/TypeSelect.vue | 8 +++++--- .../dispatch/src/document/template/TemplateSelect.vue | 8 +++++--- .../static/dispatch/src/incident/IncidentSelect.vue | 8 +++++--- .../dispatch/src/incident/type/IncidentTypeSelect.vue | 8 +++++--- .../static/dispatch/src/project/ProjectSelect.vue | 8 +++++--- .../static/dispatch/src/tag_type/TagTypeSelect.vue | 8 +++++--- 13 files changed, 65 insertions(+), 39 deletions(-) diff --git a/src/dispatch/static/dispatch/src/case/type/CaseTypeSelect.vue b/src/dispatch/static/dispatch/src/case/type/CaseTypeSelect.vue index 2f69b2acf503..bf96ec4a47f4 100644 --- a/src/dispatch/static/dispatch/src/case/type/CaseTypeSelect.vue +++ b/src/dispatch/static/dispatch/src/case/type/CaseTypeSelect.vue @@ -106,9 +106,11 @@ export default { CaseTypeApi.getAll(filterOptions).then((response) => { this.items = response.data.items - // check to see if the current selection is available in the list and if not we add it - if (!this.items.find((match) => match.id === this.case_type.id)) { - this.items = [this.case_type].concat(this.items) + if (this.case_type) { + // check to see if the current selection is available in the list and if not we add it + if (!this.items.find((match) => match.id === this.case_type.id)) { + this.items = [this.case_type].concat(this.items) + } } this.total = response.data.total diff --git a/src/dispatch/static/dispatch/src/data/query/QuerySelect.vue b/src/dispatch/static/dispatch/src/data/query/QuerySelect.vue index 7c19284208d0..f55d1a06df90 100644 --- a/src/dispatch/static/dispatch/src/data/query/QuerySelect.vue +++ b/src/dispatch/static/dispatch/src/data/query/QuerySelect.vue @@ -131,9 +131,11 @@ export default { QueryApi.getAll(filterOptions).then((response) => { this.items = response.data.items - // check to see if the current selection is available in the list and if not we add it - if (!this.items.find((match) => match.id === this.query.id)) { - this.items = [this.query].concat(this.items) + if (this.query) { + // check to see if the current selection is available in the list and if not we add it + if (!this.items.find((match) => match.id === this.query.id)) { + this.items = [this.query].concat(this.items) + } } this.total = response.data.total diff --git a/src/dispatch/static/dispatch/src/data/source/SourceSelect.vue b/src/dispatch/static/dispatch/src/data/source/SourceSelect.vue index 363e4b353249..706b37607213 100644 --- a/src/dispatch/static/dispatch/src/data/source/SourceSelect.vue +++ b/src/dispatch/static/dispatch/src/data/source/SourceSelect.vue @@ -131,9 +131,11 @@ export default { SourceApi.getAll(filterOptions).then((response) => { this.items = response.data.items - // check to see if the current selection is available in the list and if not we add it - if (!this.items.find((match) => match.id === this.source.id)) { - this.items = [this.source].concat(this.items) + if (this.source) { + // check to see if the current selection is available in the list and if not we add it + if (!this.items.find((match) => match.id === this.source.id)) { + this.items = [this.source].concat(this.items) + } } this.total = response.data.total diff --git a/src/dispatch/static/dispatch/src/data/source/dataFormat/DataFormatSelect.vue b/src/dispatch/static/dispatch/src/data/source/dataFormat/DataFormatSelect.vue index cb32747a338a..355339ee487d 100644 --- a/src/dispatch/static/dispatch/src/data/source/dataFormat/DataFormatSelect.vue +++ b/src/dispatch/static/dispatch/src/data/source/dataFormat/DataFormatSelect.vue @@ -129,9 +129,11 @@ export default { SourceDataFormatApi.getAll(filterOptions).then((response) => { this.items = response.data.items - // check to see if the current selection is available in the list and if not we add it - if (!this.items.find((match) => match.id === this.dataFormat.id)) { - this.items = [this.dataFormat].concat(this.items) + if (this.dataFormat) { + // check to see if the current selection is available in the list and if not we add it + if (!this.items.find((match) => match.id === this.dataFormat.id)) { + this.items = [this.dataFormat].concat(this.items) + } } this.total = response.data.total diff --git a/src/dispatch/static/dispatch/src/data/source/environment/EnvironmentSelect.vue b/src/dispatch/static/dispatch/src/data/source/environment/EnvironmentSelect.vue index 55f78729b429..f027afc9dc1d 100644 --- a/src/dispatch/static/dispatch/src/data/source/environment/EnvironmentSelect.vue +++ b/src/dispatch/static/dispatch/src/data/source/environment/EnvironmentSelect.vue @@ -129,9 +129,11 @@ export default { SourceEnvironmentApi.getAll(filterOptions).then((response) => { this.items = response.data.items - // check to see if the current selection is available in the list and if not we add it - if (!this.items.find((match) => match.id === this.environment.id)) { - this.items = [this.environment].concat(this.items) + if (this.environment) { + // check to see if the current selection is available in the list and if not we add it + if (!this.items.find((match) => match.id === this.environment.id)) { + this.items = [this.environment].concat(this.items) + } } this.total = response.data.total diff --git a/src/dispatch/static/dispatch/src/data/source/status/StatusSelect.vue b/src/dispatch/static/dispatch/src/data/source/status/StatusSelect.vue index ab7f3f119f1c..f5358f203070 100644 --- a/src/dispatch/static/dispatch/src/data/source/status/StatusSelect.vue +++ b/src/dispatch/static/dispatch/src/data/source/status/StatusSelect.vue @@ -129,9 +129,11 @@ export default { SourceStatusApi.getAll(filterOptions).then((response) => { this.items = response.data.items - // check to see if the current selection is available in the list and if not we add it - if (!this.items.find((match) => match.id === this.status.id)) { - this.items = [this.status].concat(this.items) + if (this.status) { + // check to see if the current selection is available in the list and if not we add it + if (!this.items.find((match) => match.id === this.status.id)) { + this.items = [this.status].concat(this.items) + } } this.total = response.data.total diff --git a/src/dispatch/static/dispatch/src/data/source/transport/TransportSelect.vue b/src/dispatch/static/dispatch/src/data/source/transport/TransportSelect.vue index 0dbcc42013e9..6ea31c6e4bbc 100644 --- a/src/dispatch/static/dispatch/src/data/source/transport/TransportSelect.vue +++ b/src/dispatch/static/dispatch/src/data/source/transport/TransportSelect.vue @@ -128,9 +128,11 @@ export default { SourceTransportApi.getAll(filterOptions).then((response) => { this.items = response.data.items - // check to see if the current selection is available in the list and if not we add it - if (!this.items.find((match) => match.id === this.transport.id)) { - this.items = [this.transport].concat(this.items) + if (this.transport) { + // check to see if the current selection is available in the list and if not we add it + if (!this.items.find((match) => match.id === this.transport.id)) { + this.items = [this.transport].concat(this.items) + } } this.total = response.data.total diff --git a/src/dispatch/static/dispatch/src/data/source/type/TypeSelect.vue b/src/dispatch/static/dispatch/src/data/source/type/TypeSelect.vue index 64231be3c6c7..cab982c3699a 100644 --- a/src/dispatch/static/dispatch/src/data/source/type/TypeSelect.vue +++ b/src/dispatch/static/dispatch/src/data/source/type/TypeSelect.vue @@ -129,9 +129,11 @@ export default { SourceTypeApi.getAll(filterOptions).then((response) => { this.items = response.data.items - // check to see if the current selection is available in the list and if not we add it - if (!this.items.find((match) => match.id === this.type.id)) { - this.items = [this.type].concat(this.items) + if (this.type) { + // check to see if the current selection is available in the list and if not we add it + if (!this.items.find((match) => match.id === this.type.id)) { + this.items = [this.type].concat(this.items) + } } this.total = response.data.total diff --git a/src/dispatch/static/dispatch/src/document/template/TemplateSelect.vue b/src/dispatch/static/dispatch/src/document/template/TemplateSelect.vue index 63d5736bdacf..94e73bdefa2d 100644 --- a/src/dispatch/static/dispatch/src/document/template/TemplateSelect.vue +++ b/src/dispatch/static/dispatch/src/document/template/TemplateSelect.vue @@ -154,9 +154,11 @@ export default { DocumentApi.getAll(filterOptions).then((response) => { this.items = response.data.items - // check to see if the current selection is available in the list and if not we add it - if (!this.items.find((match) => match.id === this.template.id)) { - this.items = [this.template].concat(this.items) + if (this.template) { + // check to see if the current selection is available in the list and if not we add it + if (!this.items.find((match) => match.id === this.template.id)) { + this.items = [this.template].concat(this.items) + } } this.total = response.data.total diff --git a/src/dispatch/static/dispatch/src/incident/IncidentSelect.vue b/src/dispatch/static/dispatch/src/incident/IncidentSelect.vue index 3f4119212bab..b1a59801f569 100644 --- a/src/dispatch/static/dispatch/src/incident/IncidentSelect.vue +++ b/src/dispatch/static/dispatch/src/incident/IncidentSelect.vue @@ -129,9 +129,11 @@ export default { IncidentApi.getAll(filterOptions).then((response) => { this.items = response.data.items - // check to see if the current selection is available in the list and if not we add it - if (!this.items.find((match) => match.id === this.incident.id)) { - this.items = [this.incident].concat(this.items) + if (this.incident) { + // check to see if the current selection is available in the list and if not we add it + if (!this.items.find((match) => match.id === this.incident.id)) { + this.items = [this.incident].concat(this.items) + } } this.total = response.data.total diff --git a/src/dispatch/static/dispatch/src/incident/type/IncidentTypeSelect.vue b/src/dispatch/static/dispatch/src/incident/type/IncidentTypeSelect.vue index 5c5f087a55db..296db30d3edc 100644 --- a/src/dispatch/static/dispatch/src/incident/type/IncidentTypeSelect.vue +++ b/src/dispatch/static/dispatch/src/incident/type/IncidentTypeSelect.vue @@ -111,9 +111,11 @@ export default { IncidentTypeApi.getAll(filterOptions).then((response) => { this.items = response.data.items - // check to see if the current selection is available in the list and if not we add it - if (!this.items.find((match) => match.id === this.incident_type.id)) { - this.items = [this.incident_type].concat(this.items) + if (this.incident_type) { + // check to see if the current selection is available in the list and if not we add it + if (!this.items.find((match) => match.id === this.incident_type.id)) { + this.items = [this.incident_type].concat(this.items) + } } this.total = response.data.total diff --git a/src/dispatch/static/dispatch/src/project/ProjectSelect.vue b/src/dispatch/static/dispatch/src/project/ProjectSelect.vue index 2ca97afd949e..1bbe850b8c3d 100644 --- a/src/dispatch/static/dispatch/src/project/ProjectSelect.vue +++ b/src/dispatch/static/dispatch/src/project/ProjectSelect.vue @@ -99,9 +99,11 @@ export default { ProjectApi.getAll(filterOptions).then((response) => { this.items = response.data.items - // check to see if the current selection is available in the list and if not we add it - if (!this.items.find((match) => match.id === this.project.id)) { - this.items = [this.project].concat(this.items) + if (this.project) { + // check to see if the current selection is available in the list and if not we add it + if (!this.items.find((match) => match.id === this.project.id)) { + this.items = [this.project].concat(this.items) + } } this.total = response.data.total diff --git a/src/dispatch/static/dispatch/src/tag_type/TagTypeSelect.vue b/src/dispatch/static/dispatch/src/tag_type/TagTypeSelect.vue index 75ee75100656..09f37a2d929f 100644 --- a/src/dispatch/static/dispatch/src/tag_type/TagTypeSelect.vue +++ b/src/dispatch/static/dispatch/src/tag_type/TagTypeSelect.vue @@ -100,9 +100,11 @@ export default { TagTypeApi.getAll(filterOptions).then((response) => { this.items = response.data.items - // check to see if the current selection is available in the list and if not we add it - if (!this.items.find((match) => match.id === this.tag_type.id)) { - this.items = [this.tag_type].concat(this.items) + if (this.tag_type) { + // check to see if the current selection is available in the list and if not we add it + if (!this.items.find((match) => match.id === this.tag_type.id)) { + this.items = [this.tag_type].concat(this.items) + } } this.total = response.data.total