Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Windvis committed Jan 26, 2022
2 parents 925ff70 + 55cf568 commit 6bd0fea
Show file tree
Hide file tree
Showing 4 changed files with 3,466 additions and 2,047 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default class AdministrativeUnitsAdministrativeUnitLocalInvolvementsEditC
@service router;
@service store;
@tracked showTotalFinancingPercentageError = false;
isFinancialInvolvementType = isFinancialInvolvementType;

INVOLVEMENT_TYPE = INVOLVEMENT_TYPE;
classificationCodes = [
CLASSIFICATION_CODE.MUNICIPALITY,
CLASSIFICATION_CODE.PROVINCE,
Expand All @@ -34,7 +34,15 @@ export default class AdministrativeUnitsAdministrativeUnitLocalInvolvementsEditC
}

get isValidTotalFinancingPercentage() {
return this.totalFinancingPercentage === 100;
let hasFinancialLocalInvolvements = this.model.involvements.some(
(involvement) => isFinancialInvolvementType(involvement)
);

if (hasFinancialLocalInvolvements) {
return this.totalFinancingPercentage === 100;
} else {
return true;
}
}

setup() {
Expand Down Expand Up @@ -133,3 +141,7 @@ export default class AdministrativeUnitsAdministrativeUnitLocalInvolvementsEditC
}
}
}

function isFinancialInvolvementType(involvement) {
return involvement.involvementType?.id === INVOLVEMENT_TYPE.FINANCIAL;
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,35 +116,28 @@
</td>
<td>
{{#let
(eq
involvement.involvementType.id this.INVOLVEMENT_TYPE.FINANCIAL
)
as |isFinancialInvolvementType|
}}
{{#let
(or
involvement.error.percentage.validation
(if
(and
isFinancialInvolvementType
this.showTotalFinancingPercentageError
)
"Het totaal van alle percentages moet gelijk zijn aan 100"
(or
involvement.error.percentage.validation
(if
(and
(this.isFinancialInvolvementType involvement)
this.showTotalFinancingPercentageError
)
"Het totaal van alle percentages moet gelijk zijn aan 100"
)
as |errorMessage|
}}
<AuInput
@disabled={{not isFinancialInvolvementType}}
@error={{errorMessage}}
aria-labelledby="financial-percentage"
value={{involvement.percentage}}
{{on "input" (fn this.handlePercentageChange involvement)}}
/>
{{#if errorMessage}}
<AuHelpText @error={{true}}>{{errorMessage}}</AuHelpText>
{{/if}}
{{/let}}
)
as |errorMessage|
}}
<AuInput
@disabled={{not (this.isFinancialInvolvementType involvement)}}
@error={{errorMessage}}
aria-labelledby="financial-percentage"
value={{involvement.percentage}}
{{on "input" (fn this.handlePercentageChange involvement)}}
/>
{{#if errorMessage}}
<AuHelpText @error={{true}}>{{errorMessage}}</AuHelpText>
{{/if}}
{{/let}}
</td>
<td class="align-middle">
Expand Down
Loading

0 comments on commit 6bd0fea

Please sign in to comment.