Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Active cases and incidents respect project filter query arg #2668

Merged
merged 2 commits into from
Nov 7, 2022
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
32 changes: 20 additions & 12 deletions src/dispatch/static/dispatch/src/case/Status.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
</template>

<script>
import { mapFields } from "vuex-map-fields"
import SearchUtils from "@/search/utils"
import RouterUtils from "@/router/utils"

import CaseApi from "@/case/api"
import CaseSummaryTable from "@/case/CaseSummaryTable.vue"
import OrganizationBanner from "@/organization/OrganizationBanner.vue"
Expand All @@ -41,31 +45,35 @@ export default {
return {
items: [],
loading: false,
filters: { status: ["New"] },
}
},

created() {
this.filters = {
...this.filters,
...RouterUtils.deserializeFilters(this.query),
}
this.getActive()
},

computed: {
...mapFields("route", ["query"]),
},

methods: {
getActive() {
this.error = null
this.loading = "error"
CaseApi.getAll({
filter: JSON.stringify({
and: [
{
model: "Case",
field: "status",
op: "==",
value: "New",
},
],
}),
let filterOptions = {
sortBy: ["reported_at"],
descending: [true],
itemsPerPage: -1,
}).then((response) => {
filters: { ...this.filters },
}
filterOptions = SearchUtils.createParametersFromTableOptions({ ...filterOptions })

CaseApi.getAll(filterOptions).then((response) => {
this.items = response.data.items
this.loading = false
})
Expand Down
37 changes: 25 additions & 12 deletions src/dispatch/static/dispatch/src/incident/Status.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
</template>

<script>
import { mapFields } from "vuex-map-fields"
import SearchUtils from "@/search/utils"
import RouterUtils from "@/router/utils"

import IncidentApi from "@/incident/api"
import IncidentSummaryTable from "@/incident/IncidentSummaryTable.vue"
import OrganizationBanner from "@/organization/OrganizationBanner.vue"
Expand All @@ -35,28 +39,37 @@ export default {
return {
items: [],
loading: false,
filters: { status: ["Active"] },
}
},

created() {
this.filters = {
...this.filters,
...RouterUtils.deserializeFilters(this.query),
}
this.getActive()
},

computed: {
...mapFields("route", ["query"]),
},

methods: {
getActive() {
this.error = null
this.loading = "error"
IncidentApi.getAll({
filter: JSON.stringify({
and: [
{
model: "Incident",
field: "status",
op: "==",
value: "Active",
},
],
}),
}).then((response) => {

let filterOptions = {
sortBy: ["reported_at"],
descending: [true],
itemsPerPage: -1,
filters: { ...this.filters },
}

filterOptions = SearchUtils.createParametersFromTableOptions({ ...filterOptions })

IncidentApi.getAll(filterOptions).then((response) => {
this.items = response.data.items
this.loading = false
})
Expand Down