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-title>{{pageTitle}}</mat-card-title>
</mat-card-header>
<mat-card-content>
<form [formGroup]="_pdAllocationForm" (submit)="onSubmit()">
<!--<div class="form-group">-->
<div fxLayout="row" fxLayoutAlign="start none">
<mat-form-field class="ml-xs example-full-width">
<mat-select placeholder="Select Name" formControlName="allocation_id">
<mat-option *ngFor="let ct of pdOfficerList" [value]="ct">{{ ct.categroy_name }}</mat-option>
</mat-select>
<mat-error *ngIf="readForm.allocation_id.hasError('required')" class="mat-text-warn">Select name.</mat-error>
</mat-form-field>
</div>
<!-- <form [formGroup]="_pdAllocationForm" (submit)="onSubmit()"> -->
<mat-list *ngIf="pdOfficerList.length > 0">
<mat-list-item *ngFor="let officer of pdOfficerList">
<p><mat-radio-button (change)="selectPdOfficer(officer)"></mat-radio-button>
{{officer.first_name}}
</p>
<p style="padding-left: 8%;">
<span matBadge="{{officer.allocated}}" matBadgeOverlap="false" matBadgeColor="accent">Allocated</span>
</p>
<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;">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="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>-->
</form>
<!-- </form> -->
</mat-card-content>
</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 = [];
errorMessage: any;
notifier : NotifierService;
selectedItem:any;
isDisabled: boolean;
constructor( notifier: NotifierService,
private _fb: FormBuilder,
private dialogRef: MatDialogRef<PdAllocationComponent>,
private _pd: PdTrigerService,
@Inject(MAT_DIALOG_DATA) public data: any) {
this.notifier=notifier;
console.log(this.data)
this.getPDOfficerList();
}
ngOnInit() {
this._pdAllocationForm = this._fb.group({
pd_primary_id: [null],
allocation_id: [null, Validators.compose([Validators.required])],
});
this.isDisabled=true;
this.getPDOfficerList(this.data.pd_id);
// this._pdAllocationForm = this._fb.group({
// pd_primary_id: [null],
// allocation_id: [null],
// });
}
// convenience getter for easy access to form fields
get readForm() { return this._pdAllocationForm.controls; }
// get readForm() { return this._pdAllocationForm.controls; }
// pd officer list
getPDOfficerList(){
this._pd.getPdOfficerList().subscribe(
getPDOfficerList(pdID:string){
this._pd.getPdOfficerList(pdID).subscribe(
data => {
if (data.status == 200) {
this.pdOfficerList=data.records.pd_master_details;
this.pdOfficerList=data.records;
}
}, error => this.errorMessage = <any> error);
}
/** To Save/Edited Popup Data */
onSubmit() {
// stop here if form is invalid
if (this._pdAllocationForm.invalid) {
this.errorMessage = "Please Fill All Mandate Fields.";
return;
} else {
var updateData = this._pdAllocationForm.value;
// select pd officer list
selectPdOfficer(selected:any){
this.isDisabled=false;
this.selectedItem=selected;
// this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
//To Remove The "Null" With Key also
Object.keys(updateData).forEach((key) => (updateData[key] == null) && delete updateData[key]);
//Add BRANCH data with help Service File
}
/** To update pd officer*/
updatePdOfficer(allocateDate:any) {
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(
result => {
if (result.status == 200) {
this.notifier.notify('success', 'Your Changes Updated.!');
// this.notifier.notify('success', 'Your Changes Updated.!');
this.dialogRef.close();
}
else {
@ -72,14 +79,12 @@ get readForm() { return this._pdAllocationForm.controls; }
}, error => {
this.notifier.notify('warning', 'Something 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 */
closeAllocationComponent(): void {
this.dialogRef.close();
}
closeAllocationComponent(): void {
this.dialogRef.close();
}
}

View File

@ -20,8 +20,8 @@ export interface Master {
export class PdTrigerService {
private apiUrl = "http://ssa.sineedge.com/sparqapi/api/";
//private apiUrl = "http://192.168.15.5:9999/AWSEC2/sparqapi/api/";
//private apiUrl = "http://ssa.sineedge.com/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
getPdOfficerList(): Observable<any> {
return this._http.get<any>(this.apiUrl+"getListPDOfficers")
getPdOfficerList(pdID:string): Observable<any> {
return this._http.post<any>(this.apiUrl+"getListPDOfficers",{"pdid":pdID})
.pipe(
catchError(this.handleError('operation', []))
)
}
// update pd officer
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(
catchError(this.handleError('operation', []))
)

View File

@ -8,7 +8,7 @@ import {
MatRadioModule,
MatButtonModule,MatTableModule,MatPaginatorModule,
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 { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload';
@ -92,7 +92,7 @@ const customNotifierOptions: NotifierOptions = {
FlexLayoutModule,
NgxDatatableModule,
FormsModule,MatSlideToggleModule,
MatSelectModule, MatListModule,MatGridListModule, MatTabsModule,
MatSelectModule, MatListModule,MatGridListModule, MatTabsModule, MatBadgeModule, MatCheckboxModule,
ReactiveFormsModule,
FileUploadModule,
TreeModule,

View File

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