perbaikan master building
This commit is contained in:
parent
8d9840acec
commit
3ef7dab91f
|
@ -56,11 +56,13 @@ export class AddEditMasterComponent implements OnInit {
|
|||
}
|
||||
|
||||
editForm() {
|
||||
console.log(this.dataRow);
|
||||
|
||||
const formControls = {
|
||||
id: this.dataRow.id,
|
||||
name: [this.dataRow.name, Validators.required],
|
||||
status: [this.dataRow.status, Validators.required],
|
||||
headerId: this.dataRow.headerId,
|
||||
headerId: this.dataRow.header_id,
|
||||
};
|
||||
|
||||
if (this.category) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="modal-header" style="background-color: #000000 !important">
|
||||
<h4 class="modal-title" style="color: #ffffff">Add New Row</h4>
|
||||
<h4 class="modal-title" style="color: #ffffff">{{labelModal}}</h4>
|
||||
<button type="button" class="close" aria-label="Close" (click)="activeModal.dismiss('Cross click')">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
|
@ -95,7 +95,7 @@
|
|||
<div class="form-group col-md-6">
|
||||
<label for="statusId" style="color: #ffffff">Status:</label>
|
||||
<select
|
||||
id="projectinput5"
|
||||
id="statusId"
|
||||
class="form-control"
|
||||
formControlName="statusId"
|
||||
[ngClass]="{'is-invalid': myForm.get('statusId').invalid && myForm.get('statusId').touched}"
|
||||
|
|
|
@ -18,7 +18,7 @@ export class AddEditMasterBuildingComponent {
|
|||
dataStatus: any[];
|
||||
filteredDataStatus: any[];
|
||||
dataMasterStatus: any;
|
||||
|
||||
labelModal: any;
|
||||
constructor(
|
||||
public activeModal: NgbActiveModal,
|
||||
private fb: FormBuilder,
|
||||
|
@ -30,7 +30,11 @@ export class AddEditMasterBuildingComponent {
|
|||
this.authService.checkTokenAndRedirect();
|
||||
this.createForm();
|
||||
this.listDataStatus();
|
||||
|
||||
if (this.mode === "add") {
|
||||
this.labelModal = "Add Row"
|
||||
} else {
|
||||
this.labelModal = "Edit Row"
|
||||
}
|
||||
if (this.dataRow) {
|
||||
this.editForm();
|
||||
}
|
||||
|
@ -52,7 +56,7 @@ export class AddEditMasterBuildingComponent {
|
|||
this.myForm = this.fb.group({
|
||||
id: this.dataRow.id,
|
||||
name: [this.dataRow.name, Validators.required],
|
||||
statusId: [this.dataRow.statusId, Validators.required],
|
||||
statusId: [this.dataRow.status_id, Validators.required],
|
||||
email: [this.dataRow.email, [Validators.required, Validators.email]],
|
||||
owner: [this.dataRow.owner, Validators.required],
|
||||
address: [this.dataRow.address, Validators.required],
|
||||
|
|
|
@ -139,7 +139,7 @@
|
|||
</ng-template>
|
||||
</ngx-datatable-column>
|
||||
<ngx-datatable-column
|
||||
name="statusId"
|
||||
name="StatusName"
|
||||
[flexGrow]="1"
|
||||
[minWidth]="90"
|
||||
>
|
||||
|
@ -151,7 +151,7 @@
|
|||
let-value="value"
|
||||
>
|
||||
<p style="color: #ffffff">
|
||||
{{ value === 2 ? "Aktif" : "Nonaktif" }}
|
||||
{{ value }}
|
||||
</p>
|
||||
</ng-template>
|
||||
</ngx-datatable-column>
|
||||
|
|
|
@ -74,6 +74,8 @@ export class MasterBuildingComponent {
|
|||
openAddMasterModal() {
|
||||
const modalRef = this.modalService.open(AddEditMasterBuildingComponent, {
|
||||
size: "lg",
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
});
|
||||
|
||||
modalRef.componentInstance.mode = "add";
|
||||
|
|
|
@ -55,6 +55,8 @@ export class AddEditMasterRoomComponent {
|
|||
}
|
||||
|
||||
editForm() {
|
||||
console.log(this.dataRow);
|
||||
|
||||
this.myForm = this.fb.group({
|
||||
id: this.dataRow.id,
|
||||
name: [this.dataRow.roomEntity.name, Validators.required],
|
||||
|
@ -80,9 +82,7 @@ export class AddEditMasterRoomComponent {
|
|||
listDataBuilding() {
|
||||
this.monitoringApiService.getMasterBuildingData().subscribe((res) => {
|
||||
this.dataBuilding = res.results.data;
|
||||
this.filteredDataBuilding = this.dataBuilding.filter(
|
||||
(item) => item.statusId === 2
|
||||
);
|
||||
this.filteredDataBuilding = this.dataBuilding
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -109,6 +109,8 @@ export class MasterRoomComponent {
|
|||
}
|
||||
|
||||
editRow(row) {
|
||||
console.log(row);
|
||||
|
||||
const modalRef = this.modalService.open(AddEditMasterRoomComponent, {
|
||||
size: "lg",
|
||||
backdrop: "static", // Add this line
|
||||
|
@ -120,11 +122,27 @@ export class MasterRoomComponent {
|
|||
modalRef.result.then(
|
||||
(result) => {
|
||||
if (result) {
|
||||
console.log(result);
|
||||
const filteredData = {
|
||||
id: result.id,
|
||||
name: result.name,
|
||||
description: result.description,
|
||||
};
|
||||
this.monitoringApiService
|
||||
.putMasterRoomParam(result, row.id)
|
||||
.putMasterRoomParam(filteredData, row.id)
|
||||
.subscribe((res) => {
|
||||
console.log(res);
|
||||
const transformedData = {
|
||||
buildingId: result.buildingId,
|
||||
roomId: res.data.id,
|
||||
statusId: result.statusId,
|
||||
};
|
||||
this.monitoringApiService
|
||||
.puttBuildingRoom(transformedData, row.id)
|
||||
.subscribe((res) => {
|
||||
this.fetchData();
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
(reason) => {
|
||||
|
|
|
@ -180,6 +180,7 @@ export class BuildingService {
|
|||
});
|
||||
return this.http.post<any>(url, data, { headers });
|
||||
}
|
||||
|
||||
putMasterRoomParam(data: any, id: any): Observable<any> {
|
||||
const url = `https://kapi.absys.ninja/hemat/room/${id}`;
|
||||
const headers = new HttpHeaders({
|
||||
|
|
Loading…
Reference in New Issue