Skip to content

Commit

Permalink
Disabled the pop button if no entities are selected #3618
Browse files Browse the repository at this point in the history
Signed-off-by: ClementBouvierN <clement.bouvierneveu@rte-france.com>
  • Loading branch information
ClementBouvierN committed Jan 17, 2023
1 parent a37b0bd commit c46d2f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Expand Up @@ -39,6 +39,7 @@
<button id="opfab-card-details-entity-choice-btn-cancel" type="button" class="opfab-btn-cancel"
(click)="cancelEntitiesChoice()" translate>button.cancel</button>
<button id="opfab-card-details-entity-choice-btn-confirm" type="button" class="opfab-btn"
[disabled]='!isEntityFormFilled'
(click)="submitEntitiesChoice()" translate>button.ok</button>
</div>
</ng-template>
Expand Up @@ -62,6 +62,7 @@ export class CardResponseComponent implements OnChanges, OnInit {

public showButton = false;
public isUserEnabledToRespond = false;
public isEntityFormFilled = true;
public sendingResponseInProgress: boolean;

private entityChoiceModal: NgbModalRef;
Expand Down Expand Up @@ -95,6 +96,7 @@ export class CardResponseComponent implements OnChanges, OnInit {
this.selectEntitiesForm = new FormGroup({
entities: new FormControl([])
});
this.listenToEntitiesSelection();
}

ngOnChanges(): void {
Expand All @@ -120,6 +122,14 @@ export class CardResponseComponent implements OnChanges, OnInit {
: 'response.btnUnlock';
}

private listenToEntitiesSelection(): void {
this.selectEntitiesForm.get('entities').valueChanges.subscribe((selectedEntities) => {
this.isEntityFormFilled = selectedEntities.length >= 1;
console.log("BOOLEAN : ", this.isEntityFormFilled);
console.log("LIST : ", selectedEntities);
})
}

private computeEntityOptionsDropdownListForResponse(): void {
this.userEntityOptionsDropdownList = [];
if (!!this.userEntityIdsPossibleForResponse)
Expand Down

0 comments on commit c46d2f9

Please sign in to comment.