Skip to content

Commit

Permalink
Merge pull request #1079 from MTES-MCT/issue/2302
Browse files Browse the repository at this point in the history
#patch (2302) Ajout de 2 filtres sur les procédures administratives
  • Loading branch information
superfeedboy authored Jan 6, 2025
2 parents ca09539 + 9725289 commit 7319c68
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,28 @@ export default {
{ value: "unknown", label: "Raison inconnue" },
],
},
administrativeOrder: {
label: "Procédure administrative",
id: "administrativeOrder",
options: [
{ value: "unknown", label: "Inconnu" },
{ value: "none", label: "Aucune" },
{
value: "evacuationUnderTimeLimit",
label: "Procédure en cours",
},
],
},
rhi: {
label: "Opération RHI",
id: "rhi",
options: [
{ value: "unknown", label: "Inconnu" },
{ value: "none", label: "Aucune" },
{
value: "insalubrityOrder",
label: "Procédure en cours",
},
],
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ const groupedFilters = {
filters.actors,
filters.heatwave,
...(userStore.hasJusticePermission ? [filters.justice] : []),
...(userStore.hasJusticePermission
? [filters.administrativeOrder]
: []),
...(userStore.hasJusticePermission ? [filters.rhi] : []),
],
},
close: {
Expand All @@ -94,6 +98,10 @@ const groupedFilters = {
filters.origin,
filters.closingReason,
...(userStore.hasJusticePermission ? [filters.justice] : []),
...(userStore.hasJusticePermission
? [filters.administrativeOrder]
: []),
...(userStore.hasJusticePermission ? [filters.rhi] : []),
filters.fieldType,
filters.population,
],
Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/webapp/src/stores/towns.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ export const useTownsStore = defineStore("towns", () => {
filters.properties.value.population = [];
filters.properties.value.fieldType = [];
filters.properties.value.justice = [];
filters.properties.value.administrativeOrder = [];
filters.properties.value.rhi = [];
filters.properties.value.origin = [];
filters.properties.value.target = [];
// Filtres spécifiques aux sites ouverts
Expand Down
39 changes: 39 additions & 0 deletions packages/frontend/webapp/src/utils/filterShantytowns.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ export default function (shantytowns, filters) {
return false;
}

if (
filters.administrativeOrder.length > 0 &&
!checkAdministrativeOrder(shantytown, filters.administrativeOrder)
) {
return false;
}

if (filters.rhi.length > 0 && !checkRhi(shantytown, filters.rhi)) {
return false;
}

if (
filters.origin.length > 0 &&
!checkOrigin(shantytown, filters.origin)
Expand Down Expand Up @@ -242,6 +253,34 @@ function checkJustice(shantytown, filters) {
});
}

function checkAdministrativeOrder(shantytown, filters) {
return filters.some((value) => {
if (value === "evacuationUnderTimeLimit") {
return shantytown.evacuationUnderTimeLimit === true;
}

if (value === "none") {
return shantytown.evacuationUnderTimeLimit === false;
}

return typeof shantytown.evacuationUnderTimeLimit !== "boolean";
});
}

function checkRhi(shantytown, filters) {
return filters.some((value) => {
if (value === "insalubrityOrder") {
return shantytown.insalubrityOrder === true;
}

if (value === "none") {
return shantytown.insalubrityOrder === false;
}

return typeof shantytown.insalubrityOrder !== "boolean";
});
}

/**
* Filter on closingReasons
*/
Expand Down

0 comments on commit 7319c68

Please sign in to comment.