Commit 12cd07db by DESKTOP-HF0LVOG\myhr

Update Validator หน้าอุปกรณ์ และ admin

parent 591bb041
......@@ -52,15 +52,11 @@ export class AdminEquirmentComponent implements OnInit {
rDesc: new FormControl('')
});
myFormRoom: FormGroup;
myFormEquir: FormGroup;
constructor(private modalService: NgbModal, private equirmentService: EquirmentService, private roomService: RoomService, private RoomDetailService: RoomDetailService
, private fb: FormBuilder) {
console.log()
this.RoomForm = this.fb.group({
rName: ["",],
rType: ["",],
rDesc: ["",]
});
this.RoomForm.valueChanges.subscribe(console.log);
}
ngOnInit() {
......@@ -68,6 +64,34 @@ export class AdminEquirmentComponent implements OnInit {
this.listRoomModel = this.roomService.getListRoom();
this.collectionSizeListRoom = this.listRoomModel.length
console.log("listRoom", this.listRoomModel)
this.myFormRoom = new FormGroup({
userNameForm : new FormControl('',[Validators.required]),
rTelephone : new FormControl('',[Validators.required]),
email : new FormControl('',[Validators.required, Validators.email]),
rName : new FormControl('',[Validators.required]),
rDesc : new FormControl('',[Validators.required]),
rType : new FormControl('',[Validators.required]),
sDate : new FormControl('',[Validators.required]),
eDate : new FormControl('',[Validators.required]),
sTime : new FormControl('',[Validators.required]),
eTime : new FormControl('',[Validators.required]),
Remark : new FormControl()
});
this.myFormEquir = new FormGroup({
userNameForm : new FormControl('',[Validators.required]),
eTelephone : new FormControl('',[Validators.required]),
email : new FormControl('',[Validators.required, Validators.email]),
eqName : new FormControl('',[Validators.required]),
eqDesc : new FormControl('',[Validators.required]),
eqType : new FormControl('',[Validators.required]),
eqPic : new FormControl('',[Validators.required]),
sDate : new FormControl('',[Validators.required]),
eDate : new FormControl('',[Validators.required]),
sTime : new FormControl('',[Validators.required]),
eTime : new FormControl('',[Validators.required]),
Quantity : new FormControl('',[Validators.required]),
Remark : new FormControl('',[Validators.required]),
})
}
bookEquir(editLend, item: Equirment) {
......@@ -168,20 +192,18 @@ export class AdminEquirmentComponent implements OnInit {
});
}
openItemDetail(content: string, item: ItemDetail) {
this.modelItemDetail = item;
console.log(item);
this.modalService.open(content, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
openItemDetail(contentequirment) {
this.modelEquirment = new Equirment();
this.modalService.open(contentequirment, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
});
}
openRoomDetail(content: string, item: RoomDetail) {
this.modelRoomDetail = item;
console.log(item);
this.modalService.open(content, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
openRoomDetail(contentroom) {
this.modelRoom = new MyRoom();
this.modalService.open(contentroom, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
......
......@@ -9,6 +9,7 @@ import { RoomDetailService } from 'src/app/service/room-detail.service';
import { MyRoom, Room } from 'src/app/models/rooms.model';
import { EquirmentService } from 'src/app/service/equirment.service';
import { RoomService } from 'src/app/service/room.service';
import { FormControl, FormGroup, Validators } from '@angular/forms';
@Component({
selector: 'app-admin-pending',
......@@ -185,11 +186,42 @@ export class AdminPendingComponent implements OnInit {
return parsed && this.calendar.isValid(NgbDate.from(parsed)) ? NgbDate.from(parsed) : currentValue;
}
myFormRoom: FormGroup;
myFormEquir: FormGroup;
ngOnInit(): void {
this.listitemDetail = this.ItemDetailService.getListItemDetail();
this.listroomDetail = this.RoomDetailService.getListRoomDetail();
this.collectionSizeListRoom = this.listitemDetail.length;
console.log(this.listitemDetail);
this.myFormRoom = new FormGroup({
userNameForm : new FormControl('',[Validators.required]),
rTelephone : new FormControl('',[Validators.required]),
email : new FormControl('',[Validators.required, Validators.email]),
rName : new FormControl('',[Validators.required]),
rDesc : new FormControl('',[Validators.required]),
rType : new FormControl('',[Validators.required]),
sDate : new FormControl('',[Validators.required]),
eDate : new FormControl('',[Validators.required]),
sTime : new FormControl('',[Validators.required]),
eTime : new FormControl('',[Validators.required]),
Remark : new FormControl()
});
this.myFormEquir = new FormGroup({
userNameForm : new FormControl('',[Validators.required]),
eTelephone : new FormControl('',[Validators.required]),
email : new FormControl('',[Validators.required, Validators.email]),
eqName : new FormControl('',[Validators.required]),
eqDesc : new FormControl('',[Validators.required]),
eqType : new FormControl('',[Validators.required]),
eqPic : new FormControl('',[Validators.required]),
sDate : new FormControl('',[Validators.required]),
eDate : new FormControl('',[Validators.required]),
sTime : new FormControl('',[Validators.required]),
eTime : new FormControl('',[Validators.required]),
Quantity : new FormControl('',[Validators.required]),
Remark : new FormControl('',[Validators.required]),
})
}
saveEquirment() {
......
......@@ -131,13 +131,16 @@
<h5 class=" title">Add Equirment</h5>
</div>
<div class=" card-body">
<form [formGroup]="myFormEquir" class="needs-validation">
<div class=" row">
<div class=" col-md-12">
<div class=" form-group">
<label> ชื่อ </label>
<input class=" form-control" placeholder="" type="text" [(ngModel)]="modelEquirment.eqName"
value="" />
<input class=" form-control" placeholder="" type="text"
[(ngModel)]="modelEquirment.eqName" value="" formControlName="eqName" />
<div style="color: red;" *ngIf="myFormEquir.controls.eqName.status=='INVALID'">
Invalid
Equirment Name.</div>
</div>
</div>
</div>
......@@ -147,11 +150,14 @@
<label> หมวดหมู่ </label>
<br>
<select class="form-select" aria-label="Default select example"
[(ngModel)]="modelEquirment.eqType">
[(ngModel)]="modelEquirment.eqType" formControlName="eqType">
<option selected>เลือกหมวดหมู่</option>
<option value="4">IT</option>
<option value="5">Company</option>
</select>
<div style="color: red;" *ngIf="myFormEquir.controls.eqType.status=='INVALID'">
Invalid
Equirment Type.</div>
</div>
</div>
</div>
......@@ -160,14 +166,19 @@
<div class=" form-group">
<label> รายละเอียด</label>
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3"
placeholder="......" [(ngModel)]="modelEquirment.eqDesc"></textarea>
placeholder="......" [(ngModel)]="modelEquirment.eqDesc"
formControlName="eqDesc"></textarea>
<div style="color: red;" *ngIf="myFormEquir.controls.eqDesc.status=='INVALID'">
Invalid
Equirment Desc.</div>
</div>
</div>
</div>
<label for="exampleFormControlFile">แนบไฟล์รูปภาพ</label>
<input type="file" class="form-control-file" id="exampleFormControlFile">
<input type="file" class="form-control-file" id="exampleFormControlFile" formControlName="eqPic">
</form>
</div>
<div class=" card-footer">
<button class=" btn btn-fill btn-danger" type="submit" (click)="saveEquirment()">Save</button>
<button class=" btn btn-fill btn-danger" type="cancel"
......@@ -181,14 +192,19 @@
<div class=" col-md-12" style="padding: 0; ">
<div class="card" style="margin: 0; ">
<div class=" card-header">
<h5 class=" title">Add Equirment</h5>
<h5 class=" title">เพิ่มรายการ</h5>
</div>
<div class=" card-body">
<form [formGroup]="myFormRoom" class="needs-validation">
<div class=" row">
<div class=" col-md-12">
<div class=" form-group">
<label> ชื่อ </label>
<input class=" form-control" placeholder="" type="text" [(ngModel)]="modelRoom.rName">
<input class=" form-control" placeholder="" type="text" [(ngModel)]="modelRoom.rName"
formControlName="rName">
<div style="color: red;" *ngIf="myFormRoom.controls.rName.status=='INVALID'">
Invalid
Name.</div>
</div>
</div>
</div>
......@@ -198,11 +214,13 @@
<label> ประเภท </label>
<br>
<select class="form-select" aria-label="Default select example"
[(ngModel)]="modelRoom.rType">
<option selected>เลือกประเภท</option>
[(ngModel)]="modelRoom.rType" formControlName="rType">
<option value="1">ห้อง</option>
<option value="2">รถ</option>
</select>
<div style="color: red;" *ngIf="myFormRoom.controls.rType.status=='INVALID'">
Invalid
Type.</div>
</div>
</div>
</div>
......@@ -211,12 +229,17 @@
<div class=" form-group">
<label> รายละเอียด</label>
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3"
placeholder="......" [(ngModel)]="modelRoom.rDesc"></textarea>
placeholder="......" [(ngModel)]="modelRoom.rDesc"
formControlName="rDesc"></textarea>
<div style="color: red;" *ngIf="myFormRoom.controls.rDesc.status=='INVALID'">
Invalid
Desc.</div>
</div>
</div>
</div>
<label for="exampleFormControlFile">แนบไฟล์รูปภาพ</label>
<input type="file" class="form-control-file" id="exampleFormControlFile">
</form>
</div>
<div class=" card-footer">
<button class=" btn btn-fill btn-danger" type="submit" (click)="saveRoom()">Save</button>
......
......@@ -59,8 +59,9 @@ export class EquipmentComponent implements OnInit {
userNameForm : new FormControl('',[Validators.required]),
rTelephone : new FormControl('',[Validators.required]),
email : new FormControl('',[Validators.required, Validators.email]),
rName : new FormControl(),
rDesc : new FormControl(),
rName : new FormControl('',[Validators.required]),
rDesc : new FormControl('',[Validators.required]),
rType : new FormControl('',[Validators.required]),
sDate : new FormControl('',[Validators.required]),
eDate : new FormControl('',[Validators.required]),
sTime : new FormControl('',[Validators.required]),
......@@ -73,6 +74,8 @@ export class EquipmentComponent implements OnInit {
email : new FormControl('',[Validators.required, Validators.email]),
eqName : new FormControl('',[Validators.required]),
eqDesc : new FormControl('',[Validators.required]),
eqType : new FormControl('',[Validators.required]),
eqPic : new FormControl('',[Validators.required]),
sDate : new FormControl('',[Validators.required]),
eDate : new FormControl('',[Validators.required]),
sTime : new FormControl('',[Validators.required]),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment