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