Commit 29d61a5f by Your Name

Update ปุ่มเพิ่ม Contact

parent 9e9a7ed7
<div class="content">
<div class="card">
<div class="card-body">
<form [formGroup]="myFormAddContact">
<div class="row">
<div class="col-6 md-1">
<label>ชื่อผู้แจ้ง Bug:</label>
<input input class=" form-control" placeholder="" type="text" formControlName="ctName" />
</div>
<div class="col-6 md-1">
<label for="typeahead-focus">หัวข้อการแจ้ง Bug:</label>
<input input class=" form-control" placeholder="" type="text" formControlName="ctHead" />
</div>
</div>
<div class="row">
<div class="col-6 md-1">
<label for="typeahead-focus">หน้าต่างที่ต้องการแจ้ง Bug:</label>
<input id="typeahead-focus" type="text" class="form-control"
[ngbTypeahead]="search" (focus)="focus$.next($any($event).target.value)"
(click)="click$.next($any($event).target.value)" #instance="ngbTypeahead" formControlName="ctTab" />
</div>
<div class="col-6 mb-1">
<label for="exampleFormControlSelect1">วันที่เริ่มต้น</label>
<input type="date" class="form-control" value="" formControlName="sDate" />
</div>
</div>
<div class=" row">
<div class=" col-md-12">
<div class=" form-group">
<label> หมายเหตุ </label>
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3"
placeholder="......" formControlName="ctDesc"></textarea>
</div>
</div>
</div>
</form>
<div class="card-footer">
<div class="d-grid gap-2 d-md-flex justify-content-md-center">
<button class="btn btn-primary btn-sm" [disabled]="" type="submit"
(click)="saveContact()">บันทึก</button>
<button class="btn btn-primary btn-sm" type="cancel"
(click)="model.dismiss('Cross click')">ยกเลิก</button>
</div>
</div>
</div>
</div>
<button class="btn btn-lg btn-outline-primary" (click)="openAdd(addContact)">เพิ่มรายการ</button>
<div class="card">
<div class="row text-center">
<div class="col-sm-12">
......@@ -119,7 +76,7 @@
<div class=" form-group">
<label> หน้าต่างที่มี BUG </label>
<input readonly class=" form-control" placeholder="" type="text"
formControlName="ctTab" />
formControlName="ctTab" />
</div>
</div>
</div>
......@@ -128,14 +85,15 @@
<div class=" form-group">
<label> ชื่อผู้แจ้ง </label>
<input readonly class=" form-control" placeholder="" type="text"
formControlName="ctName" />
formControlName="ctName" />
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12 mb-1">
<label for="exampleFormControlSelect1">วันที่แจ้ง</label>
<input readonly type="date" class="form-control" formControlName="sDate" />
<input readonly type="date" class="form-control" [(ngModel)]="modelContact.sDate"
formControlName="sDate" />
</div>
</div>
<div class=" row">
......@@ -167,4 +125,60 @@
</div>
</div>
</div>
</ng-template>
<ng-template #addContact let-modal>
<div class=" col-md-12" style="padding: 0; ">
<div class="card" style="margin: 0; ">
<div class="card-body">
<form [formGroup]="myFormContact">
<div class="row">
<div class="col-6 md-1">
<label>ชื่อผู้แจ้ง Bug:</label>
<input input class=" form-control" placeholder="" type="text" formControlName="ctName"
[(ngModel)]="modelContact.ctName" />
</div>
<div class="col-6 md-1">
<label for="typeahead-focus">หัวข้อการแจ้ง Bug:</label>
<input input class=" form-control" placeholder="" type="text" formControlName="ctHead"
[(ngModel)]="modelContact.ctHead" />
</div>
</div>
<div class="row">
<div class="col-6 md-1">
<label for="typeahead-focus">หน้าต่างที่ต้องการแจ้ง Bug:</label>
<input id="typeahead-focus" type="text" class="form-control"
[(ngModel)]="modelContact.ctTab" [ngbTypeahead]="search"
(focus)="focus$.next($any($event).target.value)"
(click)="click$.next($any($event).target.value)" #instance="ngbTypeahead"
formControlName="ctTab" />
</div>
<div class="col-6 mb-1">
<label for="exampleFormControlSelect1">วันที่เริ่มต้น</label>
<input type="date" class="form-control" value="" formControlName="sDate"
[(ngModel)]="modelContact.sDate">
</div>
</div>
<div class=" row">
<div class=" col-md-12">
<div class=" form-group">
<label> หมายเหตุ </label>
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3"
placeholder="......" formControlName="ctDesc"
[(ngModel)]="modelContact.ctDesc"></textarea>
</div>
</div>
</div>
</form>
<div class="card-footer">
<div class="d-grid gap-2 d-md-flex justify-content-md-center">
<button class="btn btn-primary btn-sm" [disabled]="" type="submit"
(click)="saveContact()">บันทึก</button>
<button class="btn btn-primary btn-sm" type="cancel"
(click)="model.dismiss('Cross click')">ยกเลิก</button>
</div>
</div>
</div>
</div>
</div>
</ng-template>
\ No newline at end of file
......@@ -6,11 +6,11 @@ import { Subject } from 'rxjs/internal/Subject';
import { Contact } from 'src/app/models/contact.model';
import { ContactService } from 'src/app/service/contact.service';
const pages = ['หน้าหลัก','รายการอุปกรณ์','รายการจอง-เบิกทั้งหมด'];
const pages = ['หน้าหลัก', 'รายการอุปกรณ์', 'รายการจอง-เบิกทั้งหมด'];
@Component({
selector: 'app-contact-admin',
templateUrl:'./contact-admin.component.html',
templateUrl: './contact-admin.component.html',
styleUrls: ['./contact-admin.component.scss']
})
export class ContactAdminComponent implements OnInit {
......@@ -30,16 +30,16 @@ export class ContactAdminComponent implements OnInit {
modelContact = new Contact();
myFormContact : FormGroup;
myFormAddContact : FormGroup;
myFormContact: FormGroup;
myFormAddContact: FormGroup;
sDate = "";
@ViewChild('instance', {static: true}) instance: NgbTypeahead;
@ViewChild('instance', { static: true }) instance: NgbTypeahead;
focus$ = new Subject<string>();
click$ = new Subject<string>();
constructor(private ContactService : ContactService,private modalService: NgbModal) { }
constructor(private ContactService: ContactService, private modalService: NgbModal) { }
ngOnInit(): void {
this.listContact = this.ContactService.getListContact();
......@@ -86,11 +86,11 @@ export class ContactAdminComponent implements OnInit {
}
}
openContact(content : string ,item : Contact) {
this.modelContact = item ;
openContact(content: string, item: Contact) {
this.modelContact = item;
let sDate = this.modelContact.sDate.split('/')
this.sDate = sDate[0]+"-"+sDate[1]+"-"+sDate[2]
this.sDate = sDate[0] + "-" + sDate[1] + "-" + sDate[2]
this.myFormContact = new FormGroup({
ctName: new FormControl(this.modelContact.ctName),
......@@ -106,12 +106,12 @@ export class ContactAdminComponent implements OnInit {
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
});
console.log("date",this.modelContact)
console.log("date", this.modelContact)
}
saveContact() {
this.modelContact.sDate = this.modelContact.sDate.split("-")[0]+"/"+this.modelContact.sDate.split("-")[1]+"/"+this.modelContact.sDate.split("-")[2];
this.modelContact.ctStatus = 0 ;
this.modelContact.sDate = this.modelContact.sDate.split("-")[0] + "/" + this.modelContact.sDate.split("-")[1] + "/" + this.modelContact.sDate.split("-")[2];
this.modelContact.ctStatus = 0;
this.ContactService.addContact(this.modelContact);
this.modalService.dismissAll();
this.ngOnInit();
......@@ -119,14 +119,24 @@ export class ContactAdminComponent implements OnInit {
saveStatusContact() {
this.modelContact.ctName = this.myFormContact.value.ctName
this.modelContact.ctDesc = this.myFormContact.value.ctDesc
this.modelContact.ctTab = this.myFormContact.value.ctTab
this.modelContact.ctName = this.myFormContact.value.ctName
this.modelContact.ctDesc = this.myFormContact.value.ctDesc
this.modelContact.ctTab = this.myFormContact.value.ctTab
this.modelContact.ctHead = this.myFormContact.value.ctHead
this.modelContact.ctStatus = this.myFormContact.value.ctStatus
this.modelContact.sDate = this.myFormContact.value.sDate
this.modelContact.ctStatus = this.myFormContact.value.ctStatus
this.modelContact.sDate = this.myFormContact.value.sDate
this.ContactService.updateContact(this.modelContact)
this.modalService.dismissAll();
this.ngOnInit();
}
openAdd(addContact) {
this.modelContact = new Contact;
this.modalService.open(addContact, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
});
}
}
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