logic save ketika room di remove semua

This commit is contained in:
Fuzi_fauzia 2024-08-20 16:12:48 +07:00
parent 9529da581a
commit 2b1f6c0cfe
2 changed files with 9 additions and 1 deletions

View File

@ -263,7 +263,7 @@
<button <button
type="submit" type="submit"
class="btn btn-primary" class="btn btn-primary"
[disabled]="disableButton" [disabled]="disableButtonSave"
style=" style="
color: #ffffff !important; color: #ffffff !important;
border-color: #37a647 !important; border-color: #37a647 !important;

View File

@ -38,6 +38,7 @@ export class AddEditListComponent {
roombuildingId: any; roombuildingId: any;
dataRoomBuilding: any; dataRoomBuilding: any;
disableButton: boolean = true; disableButton: boolean = true;
disableButtonSave: boolean = true;
lewatModal: boolean = false; lewatModal: boolean = false;
// userProfileForm: FormGroup; // userProfileForm: FormGroup;
public userList: FormArray; public userList: FormArray;
@ -97,23 +98,29 @@ export class AddEditListComponent {
addPhone() { addPhone() {
this.userList.push(this.createRoom()); this.userList.push(this.createRoom());
this.disableButton = true; this.disableButton = true;
this.disableButtonSave = true;
} }
removePhone(index) { removePhone(index) {
this.userList.removeAt(index); this.userList.removeAt(index);
this.isRoomDuplicate(index); this.isRoomDuplicate(index);
if (this.userList.value.length === 0) {
this.disableButtonSave = true;
}
} }
validateDouble(event: any, index: number) { validateDouble(event: any, index: number) {
const selectedRoomId = (event.target as HTMLSelectElement).value; const selectedRoomId = (event.target as HTMLSelectElement).value;
if (this.isRoomDuplicate(index)) { if (this.isRoomDuplicate(index)) {
this.disableButton = true; this.disableButton = true;
this.disableButtonSave = true;
this.toastr.error("Room", "Data yang ada masukan double!", { this.toastr.error("Room", "Data yang ada masukan double!", {
timeOut: 2000, timeOut: 2000,
closeButton: true, closeButton: true,
}); });
} else { } else {
this.disableButton = false; this.disableButton = false;
this.disableButtonSave = false;
} }
} }
@ -126,6 +133,7 @@ export class AddEditListComponent {
).length; ).length;
if (roomOccurrences === 0) { if (roomOccurrences === 0) {
this.disableButton = false; this.disableButton = false;
this.disableButtonSave = false;
} }
return roomOccurrences > 1; return roomOccurrences > 1;
} }