integrasi edit scheduler
This commit is contained in:
		
							parent
							
								
									45e280c007
								
							
						
					
					
						commit
						ecef25f30d
					
				@ -83,7 +83,7 @@
 | 
			
		||||
      </div>
 | 
			
		||||
 | 
			
		||||
      <!-- Checkbox for Repeat -->
 | 
			
		||||
      <div class="form-group col-md-12">
 | 
			
		||||
      <!-- <div class="form-group col-md-12">
 | 
			
		||||
        <label style="color: #242222">Repeat:</label>
 | 
			
		||||
        <div class="form-check">
 | 
			
		||||
          <input
 | 
			
		||||
@ -93,7 +93,7 @@
 | 
			
		||||
          />
 | 
			
		||||
          <label class="form-check-label" style="color: #242222">Yes</label>
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
      </div> -->
 | 
			
		||||
 | 
			
		||||
      <div class="form-group col-md-12">
 | 
			
		||||
        <label for="active" style="color: #242222">Active:</label>
 | 
			
		||||
 | 
			
		||||
@ -16,6 +16,8 @@ import { DeviceService } from "../../service/device.service";
 | 
			
		||||
})
 | 
			
		||||
export class ControlSchedulerComponent {
 | 
			
		||||
  @Input() deviceId: any;
 | 
			
		||||
  @Input() data: any;
 | 
			
		||||
  @Input() mode: any;
 | 
			
		||||
  labelModal: string = "";
 | 
			
		||||
  myForm: FormGroup;
 | 
			
		||||
  dataSwitch = [
 | 
			
		||||
@ -60,6 +62,12 @@ export class ControlSchedulerComponent {
 | 
			
		||||
 | 
			
		||||
  ngOnInit() {
 | 
			
		||||
    this.createForm();
 | 
			
		||||
    if (this.mode === 'add') {
 | 
			
		||||
      this.labelModal = "Add Scheduler";
 | 
			
		||||
    } else if (this.mode === 'edit') {
 | 
			
		||||
      this.editForm();
 | 
			
		||||
      this.labelModal = "Edit Scheduler";
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  createForm() {
 | 
			
		||||
@ -80,6 +88,24 @@ export class ControlSchedulerComponent {
 | 
			
		||||
    this.myForm = this.fb.group(controls);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  editForm(){
 | 
			
		||||
    this.selectedDays = this.data.days || [];
 | 
			
		||||
    this.myForm.patchValue({
 | 
			
		||||
      name: this.data.name,
 | 
			
		||||
      timeset: this.data.timeset,
 | 
			
		||||
      recurring: this.data.recurring,
 | 
			
		||||
      active: this.data.active,
 | 
			
		||||
      switch: this.data.switch,
 | 
			
		||||
    });
 | 
			
		||||
  
 | 
			
		||||
    // Patch the form with the selected days
 | 
			
		||||
    this.selectedDays.forEach((day) => {
 | 
			
		||||
      this.myForm.patchValue({
 | 
			
		||||
        [day]: true,
 | 
			
		||||
      });
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  onDayChange(day: string, isChecked: boolean) {
 | 
			
		||||
    if (isChecked) {
 | 
			
		||||
      this.selectedDays.push(day);
 | 
			
		||||
 | 
			
		||||
@ -104,7 +104,7 @@ export class SchedulerListComponent {
 | 
			
		||||
 | 
			
		||||
    modalRef.componentInstance.deviceId = this.deviceId;
 | 
			
		||||
    modalRef.componentInstance.data = data;
 | 
			
		||||
    modalRef.componentInstance.mode = "add";
 | 
			
		||||
    modalRef.componentInstance.mode = "edit";
 | 
			
		||||
    modalRef.result.then(
 | 
			
		||||
      (result) => {
 | 
			
		||||
        if (result) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user