<label class="checkiconImg bg-white">
<input type="checkbox"
[(ngModel)]="quoteSupplierCover.isShowInComparisonTool"
/>
<span class="geekmark ShowInComparisonToolCheckBox"
pTooltip="Please deselect this before you select other."
tooltipEvent="hover"
(click)="checkRemark(coverIndex, roundIndex)"
[tooltipDisabled]="!quoteSupplierCover.showWarningToolTip"></span>
</label>
This checkbox allows users to choose whether or not the remarks provided in the input (not shown here) should be displayed in a separate comparison tool. Before enabling this feature, we need to ensure that no other rounds have a checked review. In such cases, the user must uncheck those and check the current one they wish to display. The issue arises when !hasComparisonToolSet evaluates to true, as it does not update isShowInComparisonTool to true, causing the checkbox and geekmark to remain green.
checkRemark(quoteSupplierIndex, roundIndex) {
if (this.negotiationRounds[roundIndex] && this.negotiationRounds[roundIndex][1].quoteCoverageAssessments[quoteSupplierIndex]) {
try {
this.negotiationRounds[roundIndex][1].quoteCoverageAssessments[quoteSupplierIndex].isShowInComparisonTool = false;
} finally {
// Check other rounds for any that have the comparison tool set
const hasComparisonToolSet = this.negotiationRounds
.filter((_, idx) => idx !== roundIndex)
.some(round => {
const isShowInComparisonTool = round[1].quoteCoverageAssessments[quoteSupplierIndex]?.isShowInComparisonTool === true;
if (isShowInComparisonTool) {
round[1].quoteCoverageAssessments[quoteSupplierIndex].showWarningToolTip = true;
}
return isShowInComparisonTool;
});
if (!hasComparisonToolSet) {
// Reset values if no other round has it set
console.log("No other rounds with comparison tool set, resetting values.");
const assessment = this.negotiationRounds[roundIndex][1].quoteCoverageAssessments[quoteSupplierIndex];
assessment.isShowInComparisonTool = true;
assessment.showWarningToolTip = false;
if (assessment.remarks !== null && assessment.isShowInComparisonTool === true && assessment.remarksType === 0) {
this.showRemark = true;
}
}
}
}
}
Attempted to add
(ngModelChange)="checkRemark(coverIndex, roundIndex)"
directly to the checkbox like this:
<label class="checkiconImg bg-white">
<input type="checkbox"
[(ngModel)]="quoteSupplierCover.isShowInComparisonTool"
(ngModelChange)="checkRemark(coverIndex, roundIndex)" />
<span class="geekmark ShowInComparisonToolCheckBox"
pTooltip="Please deselect this before you select other."
tooltipEvent="hover"
[tooltipDisabled]="!quoteSupplierCover.showWarningToolTip"></span>
</label>
However, despite updating the model, the checkbox remained checked even though quoteSupplierCover.isShowInComparisonTool was false for that particular case.