<div class="row" *ngFor="let day of workingDays; let i = index"> <div class="col-md-2">…
- User
</div> <div class="col-md-2 d-flex align-items-end"> <div class="form-group"> <div class="form-check"> <input class="customRadio" type="radio" [name]="'status' + i" [value]="'fullDay'" [(ngModel)]="workingDays[i].fullDay" id="fullDay{{i}}" /> <label [for]="'fullDay' + i">Full Day</label> </div> </div> </div> <div class="col-md-2" *ngIf="timeFlag[i]&&!workingDays[i].closed && !workingDays[i].fullDay"> <div class="form-group"> <label>HR From</label> <div class="input-group"> <input type="time" class="form-control" placeholder="HH:MM" name="hrFrom{{i}}" [(ngModel)]="workingDays[i].hrFrom"> </div> </div> </div> <div class="col-md-2" *ngIf="timeFlag[i]&&!workingDays[i].closed && !workingDays[i].fullDay"> <div class="form-group"> <label>HR To</label> <div class="input-group"> <input type="time" class="form-control" placeholder="HH:MM" name="hrTo+{{i}}" [(ngModel)]="workingDays[i].hrTo"> </div> </div> </div> <div class="col-md-2 d-flex align-items-end"> <div class="form-group"> <a class="btn btn-vfColor btn-sm " ngbTooltip="Custom Time" (click)="toggleTime(i)"> <i aria-hidden="true" class="fa-regular fa-clock"> </i> </a> </div> </div> </div> <div class="d-flex justify-content-center mt-4"> <button *ngIf="!storeRequest.id" type="submit" class="btn btn-vfColor btn-lg" [ngClass]="{ dimmed:!form.valid}" (click)="createStore()"> Save </button> add condition to save button that must be dimmed until all days radio button checked by either fullday or closed - Assistant
To achieve the condition of making the save button dimmed until all days' radio buttons are checked by either full day or closed, you can add a method in your component file that checks if all days have a selection made. Here is an example of how you can do this:
First, add a method in your component file:
isAllDaysSelected(): boolean { for (let day of this.workingDays) { if (!day.closed && !day.fullDay) { return false; } } return true; }Then, you can use this method in your template to conditionally disable the save button:
<button *ngIf="!storeRequest.id" type="submit" class="btn btn-vfColor btn-lg" [ngClass]="{ dimmed: !form.valid || !isAllDaysSelected() }" (click)="createStore()"> Save </button>Now, the save button will be dimmed if not all days have a radio button selected by either full day or closed.
- User
add to condition or hrfrom and hrto not empty
- Assistant
To include the condition that
hrFromandhrToshould also not be empty in addition to checking if all days have a radio button selected by either full day or closed, you can modify theisAllDaysSelected()method in your component file as follows:isAllDaysSelected(): boolean { for (let day of this.workingDays) { if (!day.closed && !day.fullDay && (!day.hrFrom || !day.hrTo)) { return false; } } return true; }With this modification, the
isAllDaysSelected()method now checks ifhrFromandhrToare not empty in addition to checking if the radio buttons are selected.Then, update the conditional statement in your template to also consider the
hrFromandhrToconditions:<button *ngIf="!storeRequest.id" type="submit" class="btn btn-vfColor btn-lg" [ngClass]="{ dimmed: !form.valid || !isAllDaysSelected() }" (click)="createStore()"> Save </button>Now, the save button will be dimmed if not all days have a radio button selected by either full day or closed, and if
hrFromorhrToare empty for any day. - User
don't be editable until hrfrom and to not empty in this code will be clicked when hrfrom filled regardless hrto
- Assistant
To make the save button clickable only when
hrFromis filled for each day (regardless ofhrTo), you can modify theisAllDaysSelected()method in your component file to check ifhrFromis not empty for each day. Here's how you can do it:Update the
isAllDaysSelected()method in your component file:isAllDaysSelected(): boolean { for (let day of this.workingDays) { if ((!day.hrFrom || !day.hrFrom.trim()) && (!day.closed && !day.fullDay)) { return false; } } return true; }With this modification, the
isAllDaysSelected()method now checks ifhrFromis not empty (and not just whitespace) in addition to checking if the radio buttons are selected.Then, update the conditional statement in your template to consider the new condition:
<button *ngIf="!storeRequest.id" type="submit" class="btn btn-vfColor btn-lg" [ngClass]="{ dimmed: !form.valid || !isAllDaysSelected() }" (click)="createStore()"> Save </button>Now, the save button will only be clickable when
hrFromis filled for each day, regardless of . - User
no i want button not clickable until hrto not empty
- Assistant
To make the save button clickable only when both
hrFromandhrToare filled for each day, you can modify theisAllDaysSelected()method in your component file to check if bothhrFromandhrToare not empty. Here's how you can do it:Update the
isAllDaysSelected()method in your component file:isAllDaysSelected(): boolean { for (let day of this.workingDays) { if ((!day.hrFrom || !day.hrFrom.trim()) || (!day.hrTo || !day.hrTo.trim()) || (!day.closed && !day.fullDay)) { return false; } } return true; }With this modification, the
isAllDaysSelected()method now checks if bothhrFromandhrToare not empty (and not just whitespace) in addition to checking if the radio buttons are selected.Then, update the conditional statement in your template to consider the new condition:
<button *ngIf="!storeRequest.id" type="submit" class="btn btn-vfColor btn-lg" [ngClass]="{ dimmed: !form.valid || !isAllDaysSelected() }" (click)="createStore()"> Save </button>