Skip to content

Commit

Permalink
fix(shelter): reset non applicable field of computed field
Browse files Browse the repository at this point in the history
  • Loading branch information
guilbep committed Mar 26, 2024
1 parent 0663394 commit 1adba16
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions frontend/src/store/ShelterModuleUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ export function computeShelter(value: Shelter): Shelter {
TOTAL_TECH_PERF_ITEMS - nonApplicableTechnicalScore.length;
resultShelter.technical_performance.completed =
technicalScore.completed === totalToBeCompleted;

// habitability
const habitabilityScore = getScore(resultShelter.habitability);
const nonApplicableHabitabilityScore = getNonApplicableScore(
Expand Down Expand Up @@ -179,23 +178,25 @@ export function updateTechnicalPerformance(localShelter: Shelter): Shelter {
// Ratio of window and ventilation openings area to floor area > 0.05
localShelter.technical_performance.input_2a_1 =
windowArea / floorArea > 0.05 ? 1 : -1;

localShelter.technical_performance.input_2a_1na = undefined; // force reset of disabled field
// Ratio of windows area to floor area > 0.10
localShelter.technical_performance.input_2c_1 =
windowArea / floorArea > 0.1 ? 1 : -1;
localShelter.technical_performance.input_2c_1na = undefined; // force reset of disabled field

// Window opening dimensions < 60x60cm
const hasAWindowTooBig =
getMaxWindowArea(localShelter.geometry.windows_dimensions) >= 0.36;
localShelter.technical_performance.input_3b_4 = hasAWindowTooBig ? -1 : 1;
localShelter.technical_performance.input_3b_4na = undefined; // force reset of disabled field
return localShelter;
}

export function updateHabitability(localShelter: Shelter): Shelter {
localShelter.habitability.input5 = areDoorsBiggerThan90cm(
localShelter.geometry
);

localShelter.habitability.input5na = undefined; // force non applicable reset
// add non applicable because it does rely on the technical performance
localShelter.habitability.input12 =
localShelter.technical_performance.input_3b_6;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export default class Step7 extends Vue {
this.localShelter.habitability.input5 = areDoorsBiggerThan90cm(
this.localShelter.geometry
);
this.localShelter.habitability.input5na = undefined; // force non applicable reset
}
});
}
Expand Down

0 comments on commit 1adba16

Please sign in to comment.