Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/dispatch/search_filter/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ def get_filters(common: CommonParameters):
return search_filter_sort_paginate(model="SearchFilter", **common)


@router.get("/{search_filter_id}", response_model=SearchFilterRead)
def get_search_filter(
db_session: DbSession,
search_filter_id: PrimaryKey,
):
"""Get a search filter by id."""
search_filter = get(db_session=db_session, search_filter_id=search_filter_id)
if not search_filter:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail=[{"msg": "A search filter with this id does not exist."}],
)
return search_filter


@router.post("", response_model=SearchFilterRead)
def create_search_filter(
db_session: DbSession,
Expand Down
28 changes: 26 additions & 2 deletions src/dispatch/static/dispatch/src/search/EditDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,20 @@
<v-list-item-title>{{ notification.name }}</v-list-item-title>
</v-list-item>
</v-list>
<div class="text-body-1 ml-1 mt-2">Search Filter Expression</div>
<div class="text-body-1 ml-1 mt-2 d-flex align-center">
Search Filter Expression
<v-spacer />
<v-btn
size="small"
color="secondary"
variant="outlined"
@click="reloadExpression"
class="ml-2"
>
<v-icon start>mdi-refresh</v-icon>
Refresh
</v-btn>
</div>
<v-divider class="mt-2" />
<v-list style="max-height: 500px">
<v-list-item>
Expand Down Expand Up @@ -147,7 +160,7 @@ export default {
},

methods: {
...mapActions("search", ["closeCreateEdit", "save"]),
...mapActions("search", ["closeCreateEdit", "save", "get"]),
convertToParticipant(individual) {
return {
individual: {
Expand All @@ -156,6 +169,17 @@ export default {
},
}
},
async reloadExpression() {
if (this.id) {
try {
await this.get(this.id)
} catch (error) {
console.error("[EditDialog] Fetch error:", error)
}
} else {
console.warn("Cannot reload: search filter ID is missing or invalid")
}
},
},
}
</script>
10 changes: 10 additions & 0 deletions src/dispatch/static/dispatch/src/search/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ const actions = {
commit("SET_DIALOG_CREATE_EDIT", false)
commit("RESET_SELECTED")
},
async get({ commit }, searchFilterId) {
try {
const response = await SearchApi.get(searchFilterId)
commit("SET_SELECTED", response.data)
return response.data
} catch (error) {
console.error("Error getting search filter:", error)
throw error
}
},
}

const mutations = {
Expand Down
Loading