pd changes

This commit is contained in:
gandhimathi 2018-10-06 20:34:53 +05:30
parent c9ed6d410c
commit 51f9964a07
6 changed files with 81 additions and 53 deletions

View File

@ -1,27 +1,43 @@
<mat-card> <div style="max-height: 480px;">
<mat-card style="width: 580px; padding: 2px;">
<mat-card-header> <mat-card-header>
<mat-card-title>{{pageTitle}}</mat-card-title> <mat-card-title>{{pageTitle}}</mat-card-title>
</mat-card-header> </mat-card-header>
<mat-card-content> <mat-card-content>
<form [formGroup]="_pdAllocationForm" (submit)="onSubmit()"> <!-- <form [formGroup]="_pdAllocationForm" (submit)="onSubmit()"> -->
<!--<div class="form-group">--> <mat-list *ngIf="pdOfficerList.length > 0">
<div fxLayout="row" fxLayoutAlign="start none"> <mat-list-item *ngFor="let officer of pdOfficerList">
<mat-form-field class="ml-xs example-full-width"> <p><mat-radio-button (change)="selectPdOfficer(officer)"></mat-radio-button>
<mat-select placeholder="Select Name" formControlName="allocation_id"> {{officer.first_name}}
<mat-option *ngFor="let ct of pdOfficerList" [value]="ct">{{ ct.categroy_name }}</mat-option> </p>
</mat-select> <p style="padding-left: 8%;">
<mat-error *ngIf="readForm.allocation_id.hasError('required')" class="mat-text-warn">Select name.</mat-error> <span matBadge="{{officer.allocated}}" matBadgeOverlap="false" matBadgeColor="accent">Allocated</span>
</mat-form-field> </p>
</div> <p style="padding-left: 8%;">
<span matBadge="{{officer.scheduled}}" matBadgeOverlap="false" >Scheduled</span>
</p>
<p style="padding-left: 8%;">
<span matBadge="{{officer.inprogress}}" matBadgeOverlap="false" matBadgeColor="warn">Inprogress</span>
</p>
</mat-list-item>
</mat-list>
<mat-list *ngIf="pdOfficerList.length == 0">
<mat-list-item>
<p>PD officer not available..</p>
</mat-list-item>
</mat-list>
<div class="row" style="text-align:right;"> <div class="row" style="text-align:right;">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" <button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button"
(click)="closeAllocationComponent()"><mat-icon>close</mat-icon></button> (click)="closeAllocationComponent()"><mat-icon>close</mat-icon></button>
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="submit"><mat-icon>save</mat-icon></button> <button mat-raised-button mat-icon-button (click)="updatePdOfficer(selectedItem)" class="mr-1 mb-1 hover-icon" type="button"><mat-icon>save</mat-icon></button>
</div> </div>
<!--</div>--> <!-- </form> -->
</form>
</mat-card-content> </mat-card-content>
</mat-card> </mat-card>
</div>
<notifier-container></notifier-container>
<notifier-container></notifier-container>

View File

@ -0,0 +1,3 @@
.example-full-width{
width: 100%;
}

View File

@ -15,54 +15,61 @@ export class PdAllocationComponent implements OnInit {
public pdOfficerList: any = []; public pdOfficerList: any = [];
errorMessage: any; errorMessage: any;
notifier : NotifierService; notifier : NotifierService;
selectedItem:any;
isDisabled: boolean;
constructor( notifier: NotifierService, constructor( notifier: NotifierService,
private _fb: FormBuilder, private _fb: FormBuilder,
private dialogRef: MatDialogRef<PdAllocationComponent>, private dialogRef: MatDialogRef<PdAllocationComponent>,
private _pd: PdTrigerService, private _pd: PdTrigerService,
@Inject(MAT_DIALOG_DATA) public data: any) { @Inject(MAT_DIALOG_DATA) public data: any) {
this.notifier=notifier; this.notifier=notifier;
console.log(this.data)
this.getPDOfficerList();
} }
ngOnInit() { ngOnInit() {
this._pdAllocationForm = this._fb.group({ this.isDisabled=true;
pd_primary_id: [null], this.getPDOfficerList(this.data.pd_id);
allocation_id: [null, Validators.compose([Validators.required])],
}); // this._pdAllocationForm = this._fb.group({
// pd_primary_id: [null],
// allocation_id: [null],
// });
} }
// convenience getter for easy access to form fields // convenience getter for easy access to form fields
get readForm() { return this._pdAllocationForm.controls; } // get readForm() { return this._pdAllocationForm.controls; }
// pd officer list // pd officer list
getPDOfficerList(){ getPDOfficerList(pdID:string){
this._pd.getPdOfficerList().subscribe( this._pd.getPdOfficerList(pdID).subscribe(
data => { data => {
if (data.status == 200) { if (data.status == 200) {
this.pdOfficerList=data.records.pd_master_details; this.pdOfficerList=data.records;
} }
}, error => this.errorMessage = <any> error); }, error => this.errorMessage = <any> error);
} }
/** To Save/Edited Popup Data */ // select pd officer list
onSubmit() { selectPdOfficer(selected:any){
// stop here if form is invalid this.isDisabled=false;
if (this._pdAllocationForm.invalid) { this.selectedItem=selected;
this.errorMessage = "Please Fill All Mandate Fields."; // this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
return;
} else {
var updateData = this._pdAllocationForm.value;
//To Remove The "Null" With Key also }
Object.keys(updateData).forEach((key) => (updateData[key] == null) && delete updateData[key]); /** To update pd officer*/
updatePdOfficer(allocateDate:any) {
//Add BRANCH data with help Service File if(this.isDisabled){
this.notifier.notify('warning', 'Please Choose Minimum One PD Officer.!');
}
else {
let updateData = {
"pd_id":this.data.pd_id,
"fk_pd_allocated_to":allocateDate.fk_user_id,
}
this._pd.updatePdOfficer(updateData).subscribe( this._pd.updatePdOfficer(updateData).subscribe(
result => { result => {
if (result.status == 200) { if (result.status == 200) {
this.notifier.notify('success', 'Your Changes Updated.!'); // this.notifier.notify('success', 'Your Changes Updated.!');
this.dialogRef.close(); this.dialogRef.close();
} }
else { else {
@ -72,14 +79,12 @@ get readForm() { return this._pdAllocationForm.controls; }
}, error => { }, error => {
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
this.errorMessage = "Some Thing Wents Wrong Try Again.!"; this.errorMessage = "Some Thing Wents Wrong Try Again.!";
this.dialogRef.close(); // this.dialogRef.close();
}); });
//After Saving the BRANCH data then popup close
// this.dialogRef.close();
} }
} }
/** For Popup Close Button */ /** For Popup Close Button */
closeAllocationComponent(): void { closeAllocationComponent(): void {
this.dialogRef.close(); this.dialogRef.close();
} }
} }

View File

@ -20,8 +20,8 @@ export interface Master {
export class PdTrigerService { export class PdTrigerService {
private apiUrl = "http://ssa.sineedge.com/sparqapi/api/"; //private apiUrl = "http://ssa.sineedge.com/sparqapi/api/";
//private apiUrl = "http://192.168.15.5:9999/AWSEC2/sparqapi/api/"; private apiUrl = "http://192.168.0.5:9999/AWSEC2/sparqapi/api/";
@ -121,15 +121,17 @@ export class PdTrigerService {
} }
// get pd allocation to details // get pd allocation to details
getPdOfficerList(): Observable<any> { getPdOfficerList(pdID:string): Observable<any> {
return this._http.get<any>(this.apiUrl+"getListPDOfficers") return this._http.post<any>(this.apiUrl+"getListPDOfficers",{"pdid":pdID})
.pipe( .pipe(
catchError(this.handleError('operation', [])) catchError(this.handleError('operation', []))
) )
} }
// update pd officer // update pd officer
updatePdOfficer(updateData: any): Observable<any> { updatePdOfficer(updateData: any): Observable<any> {
return this._http.post<any>(this.apiUrl+"updatePDApplicants",{"pd_applicant_details":updateData}) updateData.fk_updatedby = this._aws.getlocale();
updateData.updatedon = currentdate;
return this._http.post<any>(this.apiUrl+"allocatePD",{"records":updateData})
.pipe( .pipe(
catchError(this.handleError('operation', [])) catchError(this.handleError('operation', []))
) )

View File

@ -8,7 +8,7 @@ import {
MatRadioModule, MatRadioModule,
MatButtonModule,MatTableModule,MatPaginatorModule, MatButtonModule,MatTableModule,MatPaginatorModule,
MatProgressBarModule,MatDialogModule, MatSortModule, MatProgressBarModule,MatDialogModule, MatSortModule,
MatToolbarModule,MatSelectModule, MatListModule, MatGridListModule, MatTabsModule } from '@angular/material'; MatToolbarModule,MatSelectModule, MatListModule, MatGridListModule, MatTabsModule, MatCheckboxModule, MatBadgeModule } from '@angular/material';
import {MatSlideToggleModule} from '@angular/material/slide-toggle'; import {MatSlideToggleModule} from '@angular/material/slide-toggle';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload'; import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload';
@ -92,7 +92,7 @@ const customNotifierOptions: NotifierOptions = {
FlexLayoutModule, FlexLayoutModule,
NgxDatatableModule, NgxDatatableModule,
FormsModule,MatSlideToggleModule, FormsModule,MatSlideToggleModule,
MatSelectModule, MatListModule,MatGridListModule, MatTabsModule, MatSelectModule, MatListModule,MatGridListModule, MatTabsModule, MatBadgeModule, MatCheckboxModule,
ReactiveFormsModule, ReactiveFormsModule,
FileUploadModule, FileUploadModule,
TreeModule, TreeModule,

View File

@ -11,7 +11,7 @@ import { PdAllocationComponent } from '../pd-allocation/pd-allocation.component'
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class ViewPdComponent implements OnInit { export class ViewPdComponent implements OnInit {
public notifier:NotifierService; private notifier:NotifierService;
errorMessage: any; errorMessage: any;
pdMasterData: any; pdMasterData: any;
pdApplicantData: any; pdApplicantData: any;
@ -70,7 +70,9 @@ export class ViewPdComponent implements OnInit {
}); });
dialogRef.afterClosed() dialogRef.afterClosed()
.subscribe(dataresult => { .subscribe(dataresult => {
//this.getQuestionsMasters(); this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
this.viewPdDetails(this.childData)
}); });
} }
updateViewComponent(editBack:string) { updateViewComponent(editBack:string) {