fix : field disabled when box is yes
This commit is contained in:
parent
c319a96fb3
commit
37755fdc6a
@ -56,4 +56,33 @@ export class LabelRestrictionService {
|
|||||||
|
|
||||||
return blockLabels;
|
return blockLabels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if Field should be disabled due to a BOX selection in FRP/QNP/TNP.
|
||||||
|
*
|
||||||
|
* We consider both finalized selections and the in-progress/current label (provided via `current`).
|
||||||
|
*
|
||||||
|
* @param selections finalized selections
|
||||||
|
* @param current optional object describing the in-progress row (e.g. { label: 'FRP', isBoxed: true })
|
||||||
|
*/
|
||||||
|
isFieldDisabled(
|
||||||
|
selections: SelectionData[],
|
||||||
|
current?: { label?: string | null; isBoxed?: boolean } | null
|
||||||
|
): boolean {
|
||||||
|
const boxedLabels = new Set(['FRP', 'QNP', 'TNP']);
|
||||||
|
|
||||||
|
// check finalized selections
|
||||||
|
for (const s of selections) {
|
||||||
|
if (s && s.label && boxedLabels.has(s.label) && !!s.isBoxed) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check the in-progress/current row if provided
|
||||||
|
if (current && current.label && boxedLabels.has(String(current.label)) && !!current.isBoxed) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1699,6 +1699,13 @@ if (['FRP', 'QNP', 'TNP'].includes(row.label)) {
|
|||||||
|
|
||||||
canUseField(): boolean {
|
canUseField(): boolean {
|
||||||
if (this.totalAmountLimitReached) return false;
|
if (this.totalAmountLimitReached) return false;
|
||||||
|
|
||||||
|
// If any finalized or the current (in-progress) selection is a boxed FRP/QNP/TNP, disable Field
|
||||||
|
const currentPartial = { label: this.selectedLabel, isBoxed: this.isBoxed };
|
||||||
|
if (this.labelRestrictionService.isFieldDisabled(this.selectionService.getSelections(), currentPartial)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.selectedLabel === 'FRP' || this.selectedLabel === 'QNP') {
|
if (this.selectedLabel === 'FRP' || this.selectedLabel === 'QNP') {
|
||||||
if (!this.isFirstGroupComplete && this.firstGroup.length === 0) return true;
|
if (!this.isFirstGroupComplete && this.firstGroup.length === 0) return true;
|
||||||
if (this.isFirstGroupComplete && this.secondGroup.length === 0) return true;
|
if (this.isFirstGroupComplete && this.secondGroup.length === 0) return true;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user