diff --git a/src/dispatch/database/service.py b/src/dispatch/database/service.py index bab3e6ff6c9a..3988565b51d9 100644 --- a/src/dispatch/database/service.py +++ b/src/dispatch/database/service.py @@ -112,7 +112,7 @@ def __init__(self, filter_spec): def get_named_models(self): if "model" in self.filter_spec: model = self.filter_spec["model"] - if model in ["Participant", "Commander"]: + if model in ["Participant", "Commander", "Assignee"]: return {"IndividualContact"} if model == "TagAll": return {"Tag"} @@ -122,7 +122,7 @@ def get_named_models(self): def format_for_sqlalchemy(self, query, default_model): filter_spec = self.filter_spec - if filter_spec.get("model") in ["Participant", "Commander"]: + if filter_spec.get("model") in ["Participant", "Commander", "Assignee"]: filter_spec["model"] = "IndividualContact" elif filter_spec.get("model") == "TagAll": filter_spec["model"] = "Tag" @@ -360,6 +360,7 @@ def apply_filter_specific_joins(model: Base, filter_spec: dict, query: orm.query (DispatchUser, "Organization"): (DispatchUser.organizations, True), (Case, "Tag"): (Case.tags, True), (Case, "TagType"): (Case.tags, True), + (Case, "IndividualContact"): (Case.participants, True), (Incident, "Tag"): (Incident.tags, True), (Incident, "TagType"): (Incident.tags, True), (Incident, "IndividualContact"): (Incident.participants, True), @@ -375,6 +376,8 @@ def apply_filter_specific_joins(model: Base, filter_spec: dict, query: orm.query # Replace mapping if looking for commander if "Commander" in str(filter_spec): model_map.update({(Incident, "IndividualContact"): (Incident.commander, True)}) + if "Assignee" in str(filter_spec): + model_map.update({(Case, "IndividualContact"): (Case.assignee, True)}) filter_models = get_named_models(filters) joined_models = [] diff --git a/src/dispatch/static/dispatch/src/case/TableFilterDialog.vue b/src/dispatch/static/dispatch/src/case/TableFilterDialog.vue index 5c42fbb09808..1f02a3018d49 100644 --- a/src/dispatch/static/dispatch/src/case/TableFilterDialog.vue +++ b/src/dispatch/static/dispatch/src/case/TableFilterDialog.vue @@ -42,6 +42,26 @@ :project="local_project" /> + + + Case Participant + Show only cases with this participant + + + + @@ -85,6 +105,8 @@ const local_reported_at = ref({}) const local_status = ref([]) const local_tag = ref([]) const local_tag_type = ref([]) +const local_participant = ref(null) +const local_participant_is_assignee = ref(false) const case_priority = computed( () => store.state.case_management.table.options.filters.case_priority @@ -107,10 +129,24 @@ const numFilters = computed(() => { status.value?.length || 0, tag.value?.length || 0, tag_type.value?.length || 0, + local_participant.value == null ? 0 : 1, ]) }) const applyFilters = () => { + let filtered_participant = null + let filtered_assignee = null + if (Array.isArray(local_participant.value)) { + local_participant.value = local_participant.value[0] + } + if (local_participant_is_assignee.value) { + filtered_assignee = local_participant.value + filtered_participant = null + } else { + filtered_assignee = null + filtered_participant = local_participant.value + } + const filters = { case_priority: local_case_priority.value, case_severity: local_case_severity.value, @@ -121,6 +157,8 @@ const applyFilters = () => { status: local_status.value, tag: local_tag.value, tag_type: local_tag_type.value, + participant: filtered_participant, + assignee: filtered_assignee, } // Commit the mutation to update the filters in the Vuex store diff --git a/src/dispatch/static/dispatch/src/case/store.js b/src/dispatch/static/dispatch/src/case/store.js index 8b0f6a2fbf76..69aba0c04ada 100644 --- a/src/dispatch/static/dispatch/src/case/store.js +++ b/src/dispatch/static/dispatch/src/case/store.js @@ -26,6 +26,7 @@ const getDefaultSelectedState = () => { incidents: [], loading: false, name: null, + participant: null, project: null, related: [], reporter: null, @@ -91,6 +92,7 @@ const state = { start: null, end: null, }, + participant: null, }, q: "", page: 1, diff --git a/src/dispatch/static/dispatch/src/router/utils.js b/src/dispatch/static/dispatch/src/router/utils.js index ccd5c72c20ef..6a8989627bed 100644 --- a/src/dispatch/static/dispatch/src/router/utils.js +++ b/src/dispatch/static/dispatch/src/router/utils.js @@ -14,7 +14,7 @@ export default { return } each(value, function (item) { - if (["commander", "participant"].includes(key)) { + if (["commander", "participant", "assignee"].includes(key)) { if (has(flatFilters, key)) { if (typeof item === "string" || item instanceof String) { flatFilters[key].push(item) @@ -85,7 +85,7 @@ export default { } return } - if (["commander", "participant"].includes(key)) { + if (["commander", "participant", "assignee"].includes(key)) { if (typeof value === "string" || value instanceof String) { if (has(filters, key)) { filters[key].push({ email: value }) diff --git a/src/dispatch/static/dispatch/src/search/utils.js b/src/dispatch/static/dispatch/src/search/utils.js index 42c3ca613ffb..729bd49da823 100644 --- a/src/dispatch/static/dispatch/src/search/utils.js +++ b/src/dispatch/static/dispatch/src/search/utils.js @@ -137,7 +137,7 @@ export default { if (!value) { return } - if (["commander", "participant"].includes(key) && has(value, "email")) { + if (["commander", "participant", "assignee"].includes(key) && has(value, "email")) { subFilter.push({ model: toPascalCase(key), field: "email",