pd team changes : ps
This commit is contained in:
parent
c155ddb133
commit
0f863ed043
@ -28,7 +28,7 @@
|
|||||||
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
|
||||||
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
<mat-select placeholder="City" required formControlName="fk_city" multiple>
|
<mat-select placeholder="City" required formControlName="fk_city" multiple>
|
||||||
<mat-option *ngFor="let cd of citydatas" [value]="cd" (onSelectionChange)="onChangeCityDatas($event)" >{{ cd.name }} </mat-option>
|
<mat-option *ngFor="let cd of citydatas" [value]="cd.city_id" (onSelectionChange)="onChangeCityDatas($event)" >{{ cd.name }} </mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
<mat-error *ngIf="submitted && f.fk_city.hasError('required')" class="mat-text-warn">You must Select Cities.</mat-error>
|
<mat-error *ngIf="submitted && f.fk_city.hasError('required')" class="mat-text-warn">You must Select Cities.</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
@ -47,7 +47,7 @@
|
|||||||
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
|
||||||
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
<mat-select placeholder="Product" required formControlName="fk_product" multiple>
|
<mat-select placeholder="Product" required formControlName="fk_product" multiple>
|
||||||
<mat-option *ngFor="let pd of productdatas " [value]="pd" (onSelectionChange)="onChangeProductDatas($event)" >{{ pd.name }} </mat-option>
|
<mat-option *ngFor="let pd of productdatas " [value]="pd.product_id" (onSelectionChange)="onChangeProductDatas($event)" >{{ pd.name }} </mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
<mat-error *ngIf="submitted && f.fk_product.hasError('required')" class="mat-text-warn">You must Select Product.</mat-error>
|
<mat-error *ngIf="submitted && f.fk_product.hasError('required')" class="mat-text-warn">You must Select Product.</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
@ -64,7 +64,7 @@
|
|||||||
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
|
||||||
<mat-select placeholder="Customer Segment" required formControlName="fk_customer_segment" multiple>
|
<mat-select placeholder="Customer Segment" required formControlName="fk_customer_segment" multiple>
|
||||||
<mat-option *ngFor="let csd of customerSegmentdatas" [value]="csd" (onSelectionChange)="onChangeCustomerSegmentDatas($event)">{{csd.name}}</mat-option>
|
<mat-option *ngFor="let csd of customerSegmentdatas" [value]="csd.customer_segment_id" (onSelectionChange)="onChangeCustomerSegmentDatas($event)">{{csd.name}}</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
<mat-error *ngIf="submitted && f.fk_customer_segment.hasError('required')" class="mat-text-warn">You must Select Customer Segment.</mat-error>
|
<mat-error *ngIf="submitted && f.fk_customer_segment.hasError('required')" class="mat-text-warn">You must Select Customer Segment.</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|||||||
@ -10,8 +10,9 @@ import { FormBuilder,
|
|||||||
import { MastersService } from '../../service/masters/masters.service';
|
import { MastersService } from '../../service/masters/masters.service';
|
||||||
import { PdTeamService } from '../../service/masters/pd-team.service';
|
import { PdTeamService } from '../../service/masters/pd-team.service';
|
||||||
import { NotifierService } from 'angular-notifier';
|
import { NotifierService } from 'angular-notifier';
|
||||||
import { PdTeamDialogComponent } from '../pd-team-dialog/pd-team-dialog.component';
|
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { empty } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-pd-team-add',
|
selector: 'app-pd-team-add',
|
||||||
@ -21,6 +22,7 @@ import { Router } from '@angular/router';
|
|||||||
export class PdTeamAddComponent implements OnInit {
|
export class PdTeamAddComponent implements OnInit {
|
||||||
|
|
||||||
public _pdTeamForm: FormGroup;
|
public _pdTeamForm: FormGroup;
|
||||||
|
private notifier: NotifierService;
|
||||||
public submitted = false;
|
public submitted = false;
|
||||||
color = 'primary';
|
color = 'primary';
|
||||||
errorMessage:string;
|
errorMessage:string;
|
||||||
@ -32,7 +34,7 @@ productdatas: any[];
|
|||||||
customerSegmentdatas: any[];
|
customerSegmentdatas: any[];
|
||||||
|
|
||||||
//This Type Of Array Declaration
|
//This Type Of Array Declaration
|
||||||
pdTeamCityArray: Array<{teamid: number, cityid: number}> = [];
|
pdTeamCityArray:any= [];
|
||||||
pdTeamProductArray: Array<{teamid: number, productid: number}> = [];
|
pdTeamProductArray: Array<{teamid: number, productid: number}> = [];
|
||||||
pdTeamCustomerSegmentArray: Array<{teamid: number, customerid: number}> = [];
|
pdTeamCustomerSegmentArray: Array<{teamid: number, customerid: number}> = [];
|
||||||
|
|
||||||
@ -47,13 +49,24 @@ constructor(private _formBuilder: FormBuilder,
|
|||||||
private _router: Router,
|
private _router: Router,
|
||||||
private _masterService: MastersService)
|
private _masterService: MastersService)
|
||||||
{
|
{
|
||||||
this._notifier = _notifier;
|
this.notifier = _notifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.PdTeamFormDatas();
|
this.PdTeamFormDatas();
|
||||||
|
|
||||||
|
/** For Checking City Validation datas - checking purpose - Already exists are not */
|
||||||
|
this._pdTeamService.getAllPdTeamCityMapping()
|
||||||
|
.subscribe(
|
||||||
|
dataresult => {
|
||||||
|
if(dataresult.dataStatus == true){
|
||||||
|
//this.AllPDTeamMapData = dataresult.records;
|
||||||
|
this.pdTeamCityArray = dataresult.records;
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log('All Datas for Validation purpose',this.pdTeamCityArray);
|
||||||
/** To Display The City Data For City DropDown */
|
/** To Display The City Data For City DropDown */
|
||||||
this._masterService.getAllMasterData('CITY').subscribe(
|
this._masterService.getAllMasterData('CITY').subscribe(
|
||||||
dataresult => {
|
dataresult => {
|
||||||
@ -117,69 +130,87 @@ onNoClick(): void {
|
|||||||
/** To Save/Edited Popup Data */
|
/** To Save/Edited Popup Data */
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
this.submitted = true;
|
this.submitted = true;
|
||||||
|
var pdTeamFormValues = this._pdTeamForm.value;
|
||||||
|
Object.keys(pdTeamFormValues).forEach(
|
||||||
|
(key) => ( pdTeamFormValues[key] == null) && delete pdTeamFormValues[key]);
|
||||||
// stop here if form is invalid
|
// stop here if form is invalid
|
||||||
if (this._pdTeamForm.invalid) {
|
// if (pdTeamFormValues.invalid) {
|
||||||
// this.errorMessage = "Please Fill All Mandate Fields.";
|
// // this.errorMessage = "Please Fill All Mandate Fields.";
|
||||||
// return;
|
// // return;
|
||||||
alert('Please Fill All Mandate Fields.');
|
// alert('Please Fill All Mandate Fields.');
|
||||||
} else {
|
// } else {
|
||||||
|
|
||||||
|
|
||||||
var pdTeamFormValues = this._pdTeamForm.value;
|
|
||||||
|
|
||||||
//To Remove The "Null" With Key also
|
//To Remove The "Null" With Key also
|
||||||
Object.keys(pdTeamFormValues).forEach(
|
|
||||||
(key) => ( pdTeamFormValues[key] == null) && delete pdTeamFormValues[key]);
|
|
||||||
|
|
||||||
this._pdTeamService.addPdTeamDetail(this._pdTeamForm.value).subscribe(
|
this._pdTeamService.addPdTeamDetail(this._pdTeamForm.value).subscribe(
|
||||||
dataresult => {
|
dataresult => {
|
||||||
if (dataresult.status == 200) {
|
if (dataresult.status == 200) {
|
||||||
console.log(dataresult);
|
|
||||||
this._notifier.notify('success', 'Record Edited Successfully.!');
|
this.notifier.notify('success', 'Record Edited Successfully.!');
|
||||||
// alert('Record Successfully.!');
|
alert('Success.!');
|
||||||
this._router.navigate(['/setting/pdteam/pdteamlist']);
|
this._router.navigate(['/setting/pdteam/pdteamlist']);
|
||||||
this._pdTeamForm.reset();
|
this._pdTeamForm.reset();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this._notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||||
|
alert('Wrong.!');
|
||||||
//alert('Some Thing Wents Wrong Try Again !');
|
//alert('Some Thing Wents Wrong Try Again !');
|
||||||
//this.errorMessage = "Some Thing Wents Wrong Try Again !";
|
//this.errorMessage = "Some Thing Wents Wrong Try Again !";
|
||||||
}
|
}
|
||||||
}, error => {
|
|
||||||
this._notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
|
||||||
// this.errorMessage = "Something Wents Wrong Try Again !";
|
|
||||||
//alert('Some Thing Wents Wrong Try Again !');
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** To Reset Popup Data For Add*/
|
|
||||||
|
|
||||||
onResetForAdd(){
|
|
||||||
alert("reset function");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**on change function for customer segment to dispaly the as List in html page */
|
/**on change function for customer segment to dispaly the as List in html page */
|
||||||
onChangeCustomerSegmentDatas($event){
|
onChangeCustomerSegmentDatas($event){
|
||||||
let CustomerSegmentName = $event.source.value.name;
|
//let CustomerSegmentName = $event.source.value.name;
|
||||||
|
let CustomerSegmentName = this.customerSegmentdatas.filter(cs=>cs.customer_segment_id == $event.source.value)[0];
|
||||||
|
|
||||||
if($event.source._selected === true ){
|
if($event.source._selected === true ){
|
||||||
this.selectedSegmentDatas.push(CustomerSegmentName);
|
this.selectedSegmentDatas.push(CustomerSegmentName.name);
|
||||||
}
|
}
|
||||||
else if($event.source._selected === false ){
|
else if($event.source._selected === false ){
|
||||||
let index = this.selectedSegmentDatas.indexOf(CustomerSegmentName);
|
let index = this.selectedSegmentDatas.indexOf(CustomerSegmentName.name);
|
||||||
this.selectedSegmentDatas.splice(index,1);
|
this.selectedSegmentDatas.splice(index,1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**on change function for City to display the as List in html page */
|
/**on change function for City to display the as List in html page */
|
||||||
onChangeCityDatas($event){
|
onChangeCityDatas($event){
|
||||||
|
var mycheck = 0 ;
|
||||||
|
//let cityName = $event.source.value;
|
||||||
|
let cityName = this.citydatas.filter(city=>city.city_id == $event.source.value)[0];
|
||||||
|
|
||||||
let cityName = $event.source.value.name;
|
|
||||||
if($event.source._selected === true ){
|
if($event.source._selected === true ){
|
||||||
this.selectedCityDatas.push(cityName);
|
|
||||||
|
for(let Duplication_City of this.pdTeamCityArray){
|
||||||
|
|
||||||
|
let teamname = Duplication_City.team_name;
|
||||||
|
let dup_cityname = Duplication_City.CITYMAP.filter(city=>city.city_id == $event.source.value);
|
||||||
|
|
||||||
|
if(dup_cityname != ''){
|
||||||
|
for(let data of dup_cityname){
|
||||||
|
|
||||||
|
if(data.name == cityName.name){
|
||||||
|
alert('"'+data.name+'" Already Existing with "'+ teamname +'"');
|
||||||
|
$event.source._selected = false;
|
||||||
|
mycheck++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mycheck == 0){
|
||||||
|
this.selectedCityDatas.push(cityName.name);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if($event.source._selected === false ){
|
else if($event.source._selected === false ){
|
||||||
let index = this.selectedCityDatas.indexOf(cityName);
|
let index = this.selectedCityDatas.indexOf(cityName.name);
|
||||||
this.selectedCityDatas.splice(index,1);
|
this.selectedCityDatas.splice(index,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,12 +219,14 @@ onChangeCityDatas($event){
|
|||||||
/**on change function for Product to display the data as List in html page */
|
/**on change function for Product to display the data as List in html page */
|
||||||
onChangeProductDatas($event){
|
onChangeProductDatas($event){
|
||||||
|
|
||||||
let productName = $event.source.value.name;
|
//let productName = $event.source.value.name;
|
||||||
|
let productName = this.productdatas.filter(product=>product.product_id == $event.source.value )[0];
|
||||||
|
|
||||||
if($event.source._selected === true ){
|
if($event.source._selected === true ){
|
||||||
this.selectedProductDatas.push(productName);
|
this.selectedProductDatas.push(productName.name);
|
||||||
}
|
}
|
||||||
else if($event.source._selected === false ){
|
else if($event.source._selected === false ){
|
||||||
let index = this.selectedProductDatas.indexOf(productName);
|
let index = this.selectedProductDatas.indexOf(productName.name);
|
||||||
this.selectedProductDatas.splice(index,1);
|
this.selectedProductDatas.splice(index,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,86 +0,0 @@
|
|||||||
<div class="ml-xs mr-xs" style="width: 100%;"
|
|
||||||
fxLayout="row"
|
|
||||||
fxLayoutAlign="center">
|
|
||||||
<h2 mat-dialog-title style="width: 70%;"> PD Team Details </h2>
|
|
||||||
<div style="width: 30%;text-align:right;">
|
|
||||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Close" matTooltipPosition="above" (click)="onNoClick()"><mat-icon>close</mat-icon></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form [formGroup]="_pdTeamForm" (submit)="onSubmit()">
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<mat-dialog-content>
|
|
||||||
|
|
||||||
<div class="ml-xs mr-xs">
|
|
||||||
<mat-form-field style="width: 100%">
|
|
||||||
<input matInput type="text" placeholder="Team Name" required [formControl]="_pdTeamForm.controls['team_name']">
|
|
||||||
<mat-error *ngIf="!_pdTeamForm.controls['team_name'].valid && _pdTeamForm.controls['team_name'].touched" class="mat-text-warn">You must include a team name.</mat-error>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ml-xs mr-xs">
|
|
||||||
<mat-form-field>
|
|
||||||
<mat-select placeholder="Pick Up Lender Name" required [formControl]="_pdTeamForm.controls['fk_lender_id']" (selectionChange)="doSomething()" >
|
|
||||||
<mat-option *ngFor="let ld of lenderdatas" [value]="ld" >{{ ld.short_name }} {{ ld.full_name }} </mat-option>
|
|
||||||
</mat-select>
|
|
||||||
<mat-error *ngIf="!_pdTeamForm.controls['fk_lender_id'].valid && _pdTeamForm.controls['fk_lender_id'].touched" class="mat-text-warn">You must Pick up Lender Name.</mat-error>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ml-xs mr-xs">
|
|
||||||
<mat-form-field>
|
|
||||||
<mat-select placeholder="Pick Up City name" required [formControl]="_pdTeamForm.controls['fk_city_id']" (selectionChange)="doSomething()" >
|
|
||||||
<mat-option *ngFor="let cd of citydatas" [value]="cd">{{ cd.name }}</mat-option>
|
|
||||||
</mat-select>
|
|
||||||
<mat-error *ngIf="!_pdTeamForm.controls['fk_city_id'].valid && _pdTeamForm.controls['fk_city_id'].touched" class="mat-text-warn">You must Pick Up the City Name.</mat-error>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<th style="text-align: center;">S.no</th>
|
|
||||||
<th style="text-align: left;">Lender Name</th>
|
|
||||||
<th style="text-align: left;">City Name</th>
|
|
||||||
<th style="text-align: right;">Action</th>
|
|
||||||
</thead>
|
|
||||||
<tr *ngFor="let PD of PDTeamMapping; let i=index">
|
|
||||||
|
|
||||||
<td style="text-align: center;">{{i+1}}</td>
|
|
||||||
<td style="text-align: left;">{{PD.lender_name }}</td>
|
|
||||||
<td style="text-align: left;">{{PD.city_name }}</td>
|
|
||||||
<td style="text-align: right;">
|
|
||||||
<button mat-icon-button class="hover-icon" matTooltip="RemoveData" matTooltipPosition="above" type="button" (click)="deletePdTeamMap(PD,i)"><mat-icon>delete</mat-icon></button>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr *ngFor="let PM of tempArray; let i=index">
|
|
||||||
|
|
||||||
<td style="text-align: center;" >{{i+PDTeamMaplen+1}}</td>
|
|
||||||
<td style="text-align: left;">{{PM.lenderid.full_name}}</td>
|
|
||||||
<td style="text-align: left;">{{PM.cityid.name}}</td>
|
|
||||||
<td style="text-align: right;">
|
|
||||||
<button mat-icon-button matTooltip="RemoveData" matTooltipPosition="above" (click)="removevalue(i)"><mat-icon>delete</mat-icon></button>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<hr><br>
|
|
||||||
|
|
||||||
<div class="row" style="text-align:right;">
|
|
||||||
<!-- <button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" [color]='color' matTooltip="Reset" matTooltipPosition="above" type="reset" ><mat-icon>settings_backup_restore</mat-icon></button> -->
|
|
||||||
<!-- <button *ngIf="_pdTeamForm.controls['pdteam_id']);else Editreset;" mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" [color]='color' matTooltip="Reset" matTooltipPosition="above" type="reset" ><mat-icon>settings_backup_restore</mat-icon></button> -->
|
|
||||||
<button *ngIf="isEmptyObject(_pdTeamForm.controls['pdteam_id']);else Editreset;"
|
|
||||||
mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset" matTooltipPosition="above" type="button" (click)="onResetForAdd()" ><mat-icon>settings_backup_restore</mat-icon></button>
|
|
||||||
<ng-template #Editreset>
|
|
||||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset" matTooltipPosition="above" type="button" (click)="onResetForEdit()" ><mat-icon>settings_backup_restore</mat-icon></button>
|
|
||||||
</ng-template>
|
|
||||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Save" matTooltipPosition="above" type="submit" [disabled]="!_pdTeamForm.valid"><mat-icon>save</mat-icon></button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</mat-dialog-content>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<notifier-container></notifier-container>
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
mat-form-field{
|
|
||||||
width:100%;
|
|
||||||
}
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { PdTeamDialogComponent } from './pd-team-dialog.component';
|
|
||||||
|
|
||||||
describe('PdTeamDialogComponent', () => {
|
|
||||||
let component: PdTeamDialogComponent;
|
|
||||||
let fixture: ComponentFixture<PdTeamDialogComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [ PdTeamDialogComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(PdTeamDialogComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,537 +0,0 @@
|
|||||||
import { Component,
|
|
||||||
OnInit,
|
|
||||||
Inject } from '@angular/core';
|
|
||||||
import { FormBuilder,
|
|
||||||
FormGroup,
|
|
||||||
Validators,
|
|
||||||
FormControl } from '@angular/forms';
|
|
||||||
import { MatDialog,
|
|
||||||
MatDialogRef,
|
|
||||||
MAT_DIALOG_DATA } from '@angular/material';
|
|
||||||
/** Service */
|
|
||||||
import { MastersService } from '../../service/masters/masters.service';
|
|
||||||
import { PdTeamService } from '../../service/masters/pd-team.service';
|
|
||||||
import { NotifierService } from 'angular-notifier';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-pd-team-dialog',
|
|
||||||
templateUrl: './pd-team-dialog.component.html',
|
|
||||||
styleUrls: ['./pd-team-dialog.component.scss']
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
export class PdTeamDialogComponent implements OnInit {
|
|
||||||
|
|
||||||
public _pdTeamForm: FormGroup;
|
|
||||||
private notifier: NotifierService;
|
|
||||||
color = 'primary';
|
|
||||||
citydatas: any[];
|
|
||||||
lenderdatas: any[];
|
|
||||||
errorMessage:string;
|
|
||||||
selectedValueForLender: any;
|
|
||||||
selectedValueForCity: any;
|
|
||||||
tempArray: Array<{lenderid: number, cityid: number}> = [];
|
|
||||||
PDTeamMapping: any[];
|
|
||||||
AllPDTeamMapData: any[];
|
|
||||||
PDTeamMaplen:any = 0;
|
|
||||||
|
|
||||||
|
|
||||||
constructor(private _formBuilder: FormBuilder,notifier: NotifierService,
|
|
||||||
private dialogRef: MatDialogRef<PdTeamDialogComponent>,
|
|
||||||
private _pdTeamService: PdTeamService,
|
|
||||||
private _masterService: MastersService,
|
|
||||||
@Inject(MAT_DIALOG_DATA) public data: any) {
|
|
||||||
this.notifier = notifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.PdTeamFormDatas();
|
|
||||||
if(isNaN(this.data.pdteam_id)){}
|
|
||||||
else{
|
|
||||||
this._pdTeamService.getAllPdTeamMapListWithPK(this.data.pdteam_id) // note, removed this.countries =
|
|
||||||
.subscribe(
|
|
||||||
dataresult => {
|
|
||||||
if(dataresult.dataStatus == true){
|
|
||||||
this.PDTeamMapping = dataresult.records;
|
|
||||||
this.PDTeamMaplen = this.PDTeamMapping.length;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this._pdTeamService.getAllPdTeamMapList() // note, removed this.countries =
|
|
||||||
.subscribe(
|
|
||||||
dataresult => {
|
|
||||||
if(dataresult.dataStatus == true){
|
|
||||||
this.AllPDTeamMapData = dataresult.records;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/** For City Drop Datas*/
|
|
||||||
this._masterService.getAllMasterData('CITY')
|
|
||||||
.subscribe(
|
|
||||||
dataresult => {
|
|
||||||
if (dataresult.status == 200) {
|
|
||||||
this.citydatas = dataresult.records;
|
|
||||||
this.citydatas = this.citydatas.filter(city=>city.isactive == 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
}, error => this.errorMessage = <any> error);
|
|
||||||
|
|
||||||
/** For Entity Drop Datas*/
|
|
||||||
this._masterService.getAllMasterData('ENTITY')
|
|
||||||
.subscribe(
|
|
||||||
dataresult => {
|
|
||||||
if (dataresult.status == 200) {
|
|
||||||
this.lenderdatas = dataresult.records;
|
|
||||||
this.lenderdatas = this.lenderdatas.filter(entity=>entity.isactive == 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
}, error => this.errorMessage = <any> error);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Pd Team Form Datas */
|
|
||||||
PdTeamFormDatas(){
|
|
||||||
this._pdTeamForm = this._formBuilder.group({
|
|
||||||
|
|
||||||
pdteam_id: [this.data.pdteam_id],
|
|
||||||
team_name: [this.data.team_name, Validators.compose([Validators.required])],
|
|
||||||
fk_city_id: [null, Validators.compose([Validators.required])],
|
|
||||||
fk_lender_id: [null, Validators.compose([Validators.required])],
|
|
||||||
temp_array: [this.tempArray]
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// isactivePDTeamChild(PD.pdteam_map_id,PD.isactive)
|
|
||||||
isactivePDTeamChild(id: number,isactive : number) {
|
|
||||||
|
|
||||||
let ActiveDatas = isactive == 0
|
|
||||||
? { 'pdteam_map_id':id,'isactive': '1'}
|
|
||||||
: { 'pdteam_map_id':id,'isactive': '0'}
|
|
||||||
|
|
||||||
//private _masterService: MastersService,
|
|
||||||
this._masterService.editMasterDetails(ActiveDatas,'PDTEAMMAP')
|
|
||||||
.subscribe(dataresult=>{
|
|
||||||
if (dataresult.dataStatus == true){
|
|
||||||
//alert("Successfully InActive !");
|
|
||||||
this.notifier.notify('success', 'Record Successfully InActive.!');
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
|
|
||||||
//alert("SomeThing Wents Wrong Try Again !");
|
|
||||||
this.notifier.notify('warning', 'Sorry Try Again !');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// deletePdTeamMap(arr: any) {
|
|
||||||
// //console.log(arr);
|
|
||||||
// //var PrimaryKeyWithValue ={'pdteam_map_id':arr.id};
|
|
||||||
// //fk_team_id
|
|
||||||
// this._pdTeamService.updatePdTeam(arr)
|
|
||||||
// .subscribe( data => { });
|
|
||||||
// this._pdTeamService.deletePdTeamMap(arr)
|
|
||||||
// .subscribe( data => { });
|
|
||||||
// //this.getPdTeam();
|
|
||||||
// }
|
|
||||||
|
|
||||||
deletePdTeamMap(PdTeamMaparr,i) {
|
|
||||||
let datas :any = [];
|
|
||||||
this._pdTeamService.deletePdTeamMapDetails(PdTeamMaparr)
|
|
||||||
.subscribe(data => {
|
|
||||||
datas = data;
|
|
||||||
if(datas.dataStatus == true){
|
|
||||||
this.PDTeamMapping.splice(i, 1);
|
|
||||||
//alert('Deleted Successfully');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
removevalue(i:number) {
|
|
||||||
//const index: number = this.tempArray.indexOf(i);
|
|
||||||
if (i !== -1) {
|
|
||||||
this.tempArray.splice(i, 1);
|
|
||||||
}
|
|
||||||
//console.log('delete function',this.tempArray);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
doSomething(){
|
|
||||||
var check = 0 ;
|
|
||||||
// console.log(this._pdTeamForm.controls['fk_city_id'].value.city_id);
|
|
||||||
// console.log(this._pdTeamForm.controls['fk_lender_id'].value.entity_id);
|
|
||||||
if((this._pdTeamForm.controls['fk_city_id'].value.city_id != '')
|
|
||||||
&&(this._pdTeamForm.controls['fk_lender_id'].value.entity_id != ''))
|
|
||||||
{
|
|
||||||
|
|
||||||
this.tempArray.forEach(item => {
|
|
||||||
if((item.cityid['city_id'] == this._pdTeamForm.controls['fk_city_id'].value.city_id) &&
|
|
||||||
(item.lenderid['entity_id'] == this._pdTeamForm.controls['fk_lender_id'].value.entity_id))
|
|
||||||
{
|
|
||||||
check++;
|
|
||||||
//alert('');
|
|
||||||
this.notifier.notify('info', 'Already Exists.!');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if(this.AllPDTeamMapData !== undefined){
|
|
||||||
|
|
||||||
this.AllPDTeamMapData.forEach(item => {
|
|
||||||
if(item.fk_team_id != this._pdTeamForm.controls['pdteam_id'].value){
|
|
||||||
if((item.fk_city_id == this._pdTeamForm.controls['fk_city_id'].value.city_id) &&
|
|
||||||
(item.fk_lender_id == this._pdTeamForm.controls['fk_lender_id'].value.entity_id))
|
|
||||||
{
|
|
||||||
check++;
|
|
||||||
//this.notifier.notify('success', 'Already Exists.!');
|
|
||||||
//alert('Already Exists on Other Team "'+item.team_name+'"');
|
|
||||||
this.notifier.notify( 'info', 'Already Exists on Other Team'+item.team_name );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isNaN(this.data.pdteam_id)) {}
|
|
||||||
else{
|
|
||||||
// console.log(this.PDTeamMapping.length);
|
|
||||||
if(this.PDTeamMapping !== undefined){
|
|
||||||
this.PDTeamMapping.forEach(item => {
|
|
||||||
if((item.fk_city_id == this._pdTeamForm.controls['fk_city_id'].value.city_id) &&
|
|
||||||
(item.fk_lender_id == this._pdTeamForm.controls['fk_lender_id'].value.entity_id))
|
|
||||||
{
|
|
||||||
check++;
|
|
||||||
//alert('Already Exists');
|
|
||||||
this.notifier.notify( 'info', 'Already Exists');
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// this.tempArray.forEach(this.data, function (value, key) {
|
|
||||||
|
|
||||||
// if((value.cityid.city_id == this._pdTeamForm.controls['fk_city_id'].value.city_id) &&
|
|
||||||
// (value.lenderid.entity_id == this._pdTeamForm.controls['fk_lender_id'].value.entity_id))
|
|
||||||
// {
|
|
||||||
// check++;
|
|
||||||
// console.log('for loop');
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
if(check == 0){
|
|
||||||
|
|
||||||
if((this._pdTeamForm.controls['fk_lender_id'].value != null) && (this._pdTeamForm.controls['fk_city_id'].value != null)){
|
|
||||||
|
|
||||||
this.tempArray.push({
|
|
||||||
'lenderid':this._pdTeamForm.controls['fk_lender_id'].value,
|
|
||||||
'cityid': this._pdTeamForm.controls['fk_city_id'].value
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
//console.log('if condition',check);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
//console.log('else condition',check);
|
|
||||||
}
|
|
||||||
// console.log('Temparray',this.tempArray);
|
|
||||||
// console.log(this._pdTeamForm.controls['fk_city_id'].value);
|
|
||||||
// console.log(this._pdTeamForm.controls['fk_lender_id'].value);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/** For Popup Close Button */
|
|
||||||
onNoClick(): void {
|
|
||||||
this.dialogRef.close();
|
|
||||||
}
|
|
||||||
// OnSumbitForAdd(){
|
|
||||||
// this._pdTeamForm.controls['team_name'].value;
|
|
||||||
// this._pdTeamService.addPdTeamDetail(pdTeamFormValues).subscribe(
|
|
||||||
// dataresult=>{
|
|
||||||
// if (dataresult.dataStatus == true){ }
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
/** To Save/Edited Popup Data */
|
|
||||||
onSubmit() {
|
|
||||||
|
|
||||||
var pdTeamFormValues = this._pdTeamForm.value;
|
|
||||||
|
|
||||||
if(isNaN(this.data.pdteam_id)) {
|
|
||||||
//console.log(pdTeamFormValues);
|
|
||||||
//To Remove The "Null" With Key
|
|
||||||
Object.keys(pdTeamFormValues).forEach(
|
|
||||||
//getAllPdTeam();
|
|
||||||
(key) => ( pdTeamFormValues[key] == null) && delete pdTeamFormValues[key] &&
|
|
||||||
delete pdTeamFormValues['fk_lender_id'] && delete pdTeamFormValues['fk_city_id']);
|
|
||||||
|
|
||||||
|
|
||||||
//this.lenderdatas = this.lenderdatas.filter(entity=>entity.isactive == 1 );
|
|
||||||
//this.lenderdatas = this.lenderdatas.filter(entity=>entity.isactive == 1 );
|
|
||||||
//console.log(pdTeamFormValues);
|
|
||||||
//this._memberService.addMasterDetails(OccupationFormValues,'OCCUPATIONMEMBERS').subscribe(
|
|
||||||
this._pdTeamService.addPdTeamDetail(pdTeamFormValues).subscribe(
|
|
||||||
dataresult=>{
|
|
||||||
console.log(dataresult);
|
|
||||||
if (dataresult.dataStatus == true){
|
|
||||||
//After Saving the data then popup close
|
|
||||||
this.dialogRef.close();
|
|
||||||
//Need To Dispaly saving Datas
|
|
||||||
// alert("Data Saved Successfully");
|
|
||||||
this.notifier.notify('success', 'Record Saved Successfully.!');
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
//alert("");
|
|
||||||
this.notifier.notify('warning', 'SomeThing Wents Wrong Try Again !');
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
Object.keys(pdTeamFormValues).forEach(
|
|
||||||
(key) => delete pdTeamFormValues['fk_lender_id'] && delete pdTeamFormValues['fk_city_id']);
|
|
||||||
|
|
||||||
this._pdTeamService.editPdTeamDetail(pdTeamFormValues).subscribe(
|
|
||||||
|
|
||||||
dataresult=>{
|
|
||||||
if (dataresult.dataStatus == true){
|
|
||||||
//After Editing the data then popup close
|
|
||||||
this.dialogRef.close();
|
|
||||||
//Need To Display saving Datas
|
|
||||||
//alert("Data Edited Successfully");
|
|
||||||
this.notifier.notify('success', 'Record Edited Successfully.!');
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
//alert("SomeThing Wents Wrong Try Again !");
|
|
||||||
this.notifier.notify('warning', 'SomeThing Wents Wrong Try Again !');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// onSubmit() {
|
|
||||||
// if (isNaN(this.data.ID)) {
|
|
||||||
// this._memberService.addMembersOccupation(this._occupationForm.value);
|
|
||||||
// this.dialogRef.close();
|
|
||||||
// } else {
|
|
||||||
// this._memberService.editMembersOccupation(this._occupationForm.value);
|
|
||||||
// this.dialogRef.close();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/** To Reset Popup Data For Add*/
|
|
||||||
|
|
||||||
onResetForAdd(){
|
|
||||||
this._pdTeamForm.reset();
|
|
||||||
this.tempArray = [];
|
|
||||||
//console.log(this.tempArray);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** To Reset Popup Data For Edit*/
|
|
||||||
onResetForEdit(){
|
|
||||||
this.PdTeamFormDatas();
|
|
||||||
this.tempArray = [];
|
|
||||||
}
|
|
||||||
isEmptyObject(obj) {
|
|
||||||
return (obj && (Object.keys(obj).length === 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/** End Of Pd Dialog Component */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
import { Component,
|
|
||||||
OnInit,
|
|
||||||
ViewChild,
|
|
||||||
Inject } from '@angular/core';
|
|
||||||
import { FormBuilder,
|
|
||||||
FormGroup,
|
|
||||||
FormArray,
|
|
||||||
Validators,
|
|
||||||
FormControl } from '@angular/forms';
|
|
||||||
import { MatDialog,
|
|
||||||
MatOption,
|
|
||||||
MatDialogRef,
|
|
||||||
MAT_DIALOG_DATA } from '@angular/material';
|
|
||||||
|
|
||||||
/** Service *
|
|
||||||
import { MastersService } from '../../../../service/masters/masters.service';
|
|
||||||
import { PdTeamService } from '../../../../service/masters/pd-team.service';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-pd-team-dialog',
|
|
||||||
templateUrl: './pd-team-dialog.component.html',
|
|
||||||
styleUrls: ['./pd-team-dialog.component.scss']
|
|
||||||
})
|
|
||||||
|
|
||||||
export class PdTeamDialogComponent implements OnInit {
|
|
||||||
|
|
||||||
public _pdTeamForm: FormGroup;
|
|
||||||
citydatas: any[];
|
|
||||||
lenderdatas: any[];
|
|
||||||
errorMessage:string;
|
|
||||||
|
|
||||||
@ViewChild('allSelected') private allSelected: MatOption;
|
|
||||||
|
|
||||||
constructor(private _formBuilder: FormBuilder,
|
|
||||||
private dialogRef: MatDialogRef<PdTeamDialogComponent>,
|
|
||||||
private _MastersService: MastersService,
|
|
||||||
private _PdTeamService: PdTeamService,
|
|
||||||
@Inject(MAT_DIALOG_DATA) public data: any) { }
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
|
|
||||||
this._pdTeamForm = this._formBuilder.group({
|
|
||||||
|
|
||||||
pdteam_id: [this.data.pdteam_id],
|
|
||||||
team_name: [this.data.team_name, Validators.compose([Validators.required])],
|
|
||||||
fk_city_id: [this.data.fk_city_id, Validators.compose([Validators.required])],
|
|
||||||
fk_lender_id: [this.data.fk_lender_id, Validators.compose([Validators.required])],
|
|
||||||
// city_ids: this._formBuilder.array([
|
|
||||||
// this._formBuilder.group({
|
|
||||||
// pdteam_city_mapping_id: [this.data.pdteam_city_mapping_id],
|
|
||||||
// fk_team_id:[this.data.pdteam_id],
|
|
||||||
// fk_city_id: [this.data.fk_city_id]
|
|
||||||
// })
|
|
||||||
// ])
|
|
||||||
// city_ids: [this._formBuilder.group({
|
|
||||||
// pdteam_city_mapping_id: [this.data.pdteam_city_mapping_id],
|
|
||||||
// fk_team_id:[this.data.pdteam_id],
|
|
||||||
// fk_city_id: [this.data.fk_city_id, Validators.compose([Validators.required])],
|
|
||||||
// })
|
|
||||||
// ]
|
|
||||||
// fk_city_id: this._formBuilder.array([this.data.fk_city_id, Validators.compose([Validators.required])])
|
|
||||||
|
|
||||||
});
|
|
||||||
console.log(this._pdTeamForm);
|
|
||||||
|
|
||||||
/** For SelectDrop Datas For Multiple Datas*
|
|
||||||
// this._MastersService.getAllMasterData('CITY')
|
|
||||||
// .subscribe(
|
|
||||||
// data => {
|
|
||||||
// let userRole:any = [];
|
|
||||||
// if (data.status == 200) {
|
|
||||||
// this.citydatas = data.records;
|
|
||||||
// this.citydatas = this.citydatas.filter(city=>city.isactive == 1 );
|
|
||||||
// if(this.data.pdteam_id != null){
|
|
||||||
// for (let cities of this.data[0]) {
|
|
||||||
// //console.log(role);
|
|
||||||
// userRole.push(this.citydatas.filter(city => city.city_id == cities.fk_city_id)[0]);
|
|
||||||
// this._pdTeamForm.controls['fk_city_id'].setValue(userRole);
|
|
||||||
// }
|
|
||||||
// console.log(userRole);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }, error => this.errorMessage = <any> error);
|
|
||||||
|
|
||||||
/** For Drop Datas*
|
|
||||||
this._MastersService.getAllMasterData('CITY')
|
|
||||||
.subscribe(
|
|
||||||
dataresult => {
|
|
||||||
if (dataresult.status == 200) {
|
|
||||||
this.citydatas = dataresult.records;
|
|
||||||
this.citydatas = this.citydatas.filter(city=>city.isactive == 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
}, error => this.errorMessage = <any> error);
|
|
||||||
|
|
||||||
/** For Drop Datas*
|
|
||||||
this._MastersService.getAllMasterData('ENTITY')
|
|
||||||
.subscribe(
|
|
||||||
dataresult => {
|
|
||||||
if (dataresult.status == 200) {
|
|
||||||
this.lenderdatas = dataresult.records;
|
|
||||||
this.lenderdatas = this.lenderdatas.filter(entity=>entity.isactive == 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
}, error => this.errorMessage = <any> error);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//pdteam_id, team_name, createdon, fk_createdby, updatedon, fk_updatedby, isactive
|
|
||||||
/** For Popup Close Button *
|
|
||||||
onNoClick(): void {
|
|
||||||
this.dialogRef.close();
|
|
||||||
}
|
|
||||||
//pdteam_id, team_name, createdon, fk_createdby, updatedon, fk_updatedby, isactive
|
|
||||||
/** To Save/Edited Popup Data *
|
|
||||||
onSubmit() {
|
|
||||||
|
|
||||||
var pdTeamFormValues = this._pdTeamForm.value;
|
|
||||||
|
|
||||||
console.log('b4 null val pdTeamFormValues',pdTeamFormValues);
|
|
||||||
if(isNaN(this.data.pdteam_id)) {
|
|
||||||
|
|
||||||
Object.keys(pdTeamFormValues).forEach(
|
|
||||||
(key) => (pdTeamFormValues[key] == null) && delete pdTeamFormValues[key]
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log('After null val pdTeamFormValues',pdTeamFormValues);
|
|
||||||
// // var start_index = 2
|
|
||||||
// // var number_of_elements_to_remove = 1;
|
|
||||||
// // var removed_elements = pdTeamFormValues.splice(start_index, number_of_elements_to_remove);
|
|
||||||
// // console.log(removed_elements);
|
|
||||||
// //["k"]
|
|
||||||
|
|
||||||
// pdTeamFormValues.splice(3, 1);
|
|
||||||
// console.log(pdTeamFormValues);
|
|
||||||
|
|
||||||
this._PdTeamService.addPdTeamDetail(pdTeamFormValues).subscribe(
|
|
||||||
dataresult=>{
|
|
||||||
if (dataresult.dataStatus == true){
|
|
||||||
//After Saving the data then popup close
|
|
||||||
this.dialogRef.close();
|
|
||||||
//Need To Dispaly saving Datas
|
|
||||||
alert("Data Saved Successfully");
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
alert("SomeThing Wents Wrong Try Again !");
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
} else { alert('Not Yet Completed Edit Function'); }
|
|
||||||
// //this._MastersService.editProductMaster(this._pdTeamForm.value);
|
|
||||||
// this._MastersService.editMasterDetails(this._pdTeamForm.value,'PDTEAM').subscribe( dataresult=>{
|
|
||||||
// if (dataresult.dataStatus == true){
|
|
||||||
// //After Editing0 the data then popup close
|
|
||||||
// this.dialogRef.close();
|
|
||||||
// //Need To Display saving Datas
|
|
||||||
// alert("Data Edited Successfully");
|
|
||||||
// }
|
|
||||||
// else{
|
|
||||||
// alert("SomeThing Wents Wrong Try Again !");
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
/** To Reset Popup Data /
|
|
||||||
onReset(){
|
|
||||||
this._pdTeamForm.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
/** End Of Product Master Component*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -28,7 +28,7 @@
|
|||||||
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
|
||||||
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
<mat-select placeholder="City" required formControlName="fk_city" multiple>
|
<mat-select placeholder="City" required formControlName="fk_city" multiple>
|
||||||
<mat-option *ngFor="let cd of citydatas" [value]="cd" (onSelectionChange)="onChangeCityDatas($event)" >{{ cd.name }} </mat-option>
|
<mat-option *ngFor="let cd of citydatas" [value]="cd.city_id" (onSelectionChange)="onChangeCityDatas($event)" >{{ cd.name }} </mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
<mat-error *ngIf="submitted && f.fk_city.hasError('required')" class="mat-text-warn">You must Select Cities.</mat-error>
|
<mat-error *ngIf="submitted && f.fk_city.hasError('required')" class="mat-text-warn">You must Select Cities.</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
@ -47,7 +47,7 @@
|
|||||||
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
|
||||||
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
<mat-select placeholder="Product" required formControlName="fk_product" multiple>
|
<mat-select placeholder="Product" required formControlName="fk_product" multiple>
|
||||||
<mat-option *ngFor="let pd of productdatas " [value]="pd" (onSelectionChange)="onChangeProductDatas($event)" >{{ pd.name }} </mat-option>
|
<mat-option *ngFor="let pd of productdatas " [value]="pd.product_id" (onSelectionChange)="onChangeProductDatas($event)" >{{ pd.name }} </mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
<mat-error *ngIf="submitted && f.fk_product.hasError('required')" class="mat-text-warn">You must Select Product.</mat-error>
|
<mat-error *ngIf="submitted && f.fk_product.hasError('required')" class="mat-text-warn">You must Select Product.</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
@ -64,7 +64,7 @@
|
|||||||
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
|
||||||
<mat-select placeholder="Customer Segment" required formControlName="fk_customer_segment" multiple>
|
<mat-select placeholder="Customer Segment" required formControlName="fk_customer_segment" multiple>
|
||||||
<mat-option *ngFor="let csd of customerSegmentdatas" [value]="csd" (onSelectionChange)="onChangeCustomerSegmentDatas($event)">{{csd.name}}</mat-option>
|
<mat-option *ngFor="let csd of customerSegmentdatas" [value]="csd.customer_segment_id" (onSelectionChange)="onChangeCustomerSegmentDatas($event)">{{csd.name}}</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
<mat-error *ngIf="submitted && f.fk_customer_segment.hasError('required')" class="mat-text-warn">You must Select Customer Segment.</mat-error>
|
<mat-error *ngIf="submitted && f.fk_customer_segment.hasError('required')" class="mat-text-warn">You must Select Customer Segment.</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
@ -77,7 +77,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<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" matTooltip="Reset" matTooltipPosition="above" type="reset"><mat-icon>settings_backup_restore</mat-icon></button>
|
<!-- <button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset" matTooltipPosition="above" type="reset"><mat-icon>settings_backup_restore</mat-icon></button> -->
|
||||||
|
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset" matTooltipPosition="above" type="button" (click)="onResetForEdit()" ><mat-icon>settings_backup_restore</mat-icon></button>
|
||||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Save" matTooltipPosition="above" type="submit"><mat-icon>save</mat-icon></button>
|
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Save" matTooltipPosition="above" type="submit"><mat-icon>save</mat-icon></button>
|
||||||
</div>
|
</div>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
|||||||
@ -1,32 +1,35 @@
|
|||||||
|
|
||||||
import { Component, OnInit, Inject } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
|
|
||||||
import { FormBuilder,
|
import { FormBuilder,
|
||||||
FormGroup,
|
FormGroup,
|
||||||
Validators,
|
Validators,
|
||||||
FormControl } from '@angular/forms';
|
FormControl } from '@angular/forms';
|
||||||
import { MatDialog,
|
|
||||||
MatDialogRef,
|
|
||||||
MAT_DIALOG_DATA } from '@angular/material';
|
|
||||||
|
|
||||||
/** Service */
|
/** Service */
|
||||||
import { MastersService } from '../../service/masters/masters.service';
|
import { MastersService } from '../../service/masters/masters.service';
|
||||||
import { PdTeamService } from '../../service/masters/pd-team.service';
|
import { PdTeamService } from '../../service/masters/pd-team.service';
|
||||||
import { NotifierService } from 'angular-notifier';
|
import { NotifierService } from 'angular-notifier';
|
||||||
import { PdTeamDialogComponent } from '../pd-team-dialog/pd-team-dialog.component';
|
|
||||||
import { Router } from '@angular/router';
|
/** Here this component is like as a partent component */
|
||||||
|
import { PdTeamListComponent } from './../pd-team-list/pd-team-list.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-pd-team-edit',
|
selector: 'app-pd-team-edit',
|
||||||
templateUrl: './pd-team-edit.component.html',
|
templateUrl: './pd-team-edit.component.html',
|
||||||
styleUrls: ['./pd-team-edit.component.scss']
|
styleUrls: ['./pd-team-edit.component.scss']
|
||||||
})
|
})
|
||||||
|
|
||||||
export class PdTeamEditComponent implements OnInit {
|
export class PdTeamEditComponent implements OnInit {
|
||||||
|
|
||||||
public _pdTeamForm: FormGroup;
|
public _pdTeamForm: FormGroup;
|
||||||
public submitted = false;
|
public submitted = false;
|
||||||
|
private notifier: NotifierService;
|
||||||
color = 'primary';
|
color = 'primary';
|
||||||
errorMessage:string;
|
errorMessage:string;
|
||||||
|
|
||||||
|
//This "childMessage" to get the function or data from partent component
|
||||||
|
@Input() public childMessage: any;
|
||||||
|
|
||||||
//This Type Of Array Declaration for select dropdown to list the datas
|
//This Type Of Array Declaration for select dropdown to list the datas
|
||||||
citydatas: any[];
|
citydatas: any[];
|
||||||
@ -34,8 +37,8 @@ export class PdTeamEditComponent implements OnInit {
|
|||||||
productdatas: any[];
|
productdatas: any[];
|
||||||
customerSegmentdatas: any[];
|
customerSegmentdatas: any[];
|
||||||
|
|
||||||
//This Type Of Array Declaration
|
//This Type Of Array Declaration for Validation
|
||||||
pdTeamCityArray: Array<{teamid: number, cityid: number}> = [];
|
pdTeamCityArray:any= [];
|
||||||
pdTeamProductArray: Array<{teamid: number, productid: number}> = [];
|
pdTeamProductArray: Array<{teamid: number, productid: number}> = [];
|
||||||
pdTeamCustomerSegmentArray: Array<{teamid: number, customerid: number}> = [];
|
pdTeamCustomerSegmentArray: Array<{teamid: number, customerid: number}> = [];
|
||||||
|
|
||||||
@ -43,165 +46,213 @@ export class PdTeamEditComponent implements OnInit {
|
|||||||
selectedCityDatas : any=[];
|
selectedCityDatas : any=[];
|
||||||
selectedProductDatas : any=[];
|
selectedProductDatas : any=[];
|
||||||
selectedSegmentDatas : any=[];
|
selectedSegmentDatas : any=[];
|
||||||
|
//EditDatasforFormGroup: any;
|
||||||
|
|
||||||
constructor(private _formBuilder: FormBuilder,
|
constructor(private _formBuilder: FormBuilder,
|
||||||
private _notifier: NotifierService,
|
private _notifier: NotifierService,
|
||||||
private _pdTeamService: PdTeamService,
|
private _pdTeamService: PdTeamService,
|
||||||
private _router: Router,
|
private _PdTeamListComponent: PdTeamListComponent,
|
||||||
private _masterService: MastersService)
|
private _masterService: MastersService) {
|
||||||
{
|
this.notifier = _notifier;
|
||||||
this._notifier = _notifier;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Onready function */
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.PdTeamFormDatas();
|
|
||||||
|
this.PdTeamFormDatas();
|
||||||
|
//console.log('hai I am Child This onready function',this.childMessage);
|
||||||
|
// this._pdTeamService.getAllPDTeamWithPDTeamID(this.childMessage).subscribe(
|
||||||
|
// dataresult => {
|
||||||
|
// console.log(dataresult);
|
||||||
|
// this.EditDatasforFormGroup = dataresult.records;
|
||||||
|
// console.log(this.EditDatasforFormGroup);
|
||||||
|
// });
|
||||||
|
/** For Checking City Validation datas - checking purpose - Already exists are not */
|
||||||
|
this._pdTeamService.getAllPdTeamCityMapping().subscribe(
|
||||||
|
dataresult => {
|
||||||
|
if(dataresult.dataStatus == true){
|
||||||
|
//this.AllPDTeamMapData = dataresult.records;
|
||||||
|
this.pdTeamCityArray = dataresult.records;
|
||||||
|
}
|
||||||
|
}, error => this.errorMessage = <any> error);
|
||||||
|
|
||||||
|
/** To Display The City Data For City DropDown */
|
||||||
|
this._masterService.getAllMasterData('CITY').subscribe(
|
||||||
|
dataresult => {
|
||||||
|
if (dataresult.dataStatus == true) {
|
||||||
|
this.citydatas = dataresult.records;
|
||||||
|
this.citydatas = this.citydatas.filter(city=>city.isactive == 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
}, error => this.errorMessage = <any> error);
|
||||||
|
|
||||||
|
/** To Display The Entities Data For Entities DropDown */
|
||||||
|
this._masterService.getAllMasterData('ENTITY').subscribe(
|
||||||
|
dataresult => {
|
||||||
|
if (dataresult.dataStatus == true) {
|
||||||
|
this.lenderdatas = dataresult.records;
|
||||||
|
this.lenderdatas = this.lenderdatas.filter(entity=>entity.isactive == 1 );
|
||||||
|
}
|
||||||
|
}, error => this.errorMessage = <any> error);
|
||||||
|
|
||||||
/** To Display The City Data For City DropDown */
|
/** To Display The Entities Data For Entities DropDown */
|
||||||
this._masterService.getAllMasterData('CITY').subscribe(
|
this._masterService.getAllMasterData('PRODUCTS').subscribe(
|
||||||
dataresult => {
|
dataresult => {
|
||||||
if (dataresult.status == 200) {
|
if (dataresult.dataStatus == true) {
|
||||||
this.citydatas = dataresult.records;
|
this.productdatas = dataresult.records;
|
||||||
this.citydatas = this.citydatas.filter(city=>city.isactive == 1 );
|
this.productdatas = this.productdatas.filter(product=>product.isactive == 1 );
|
||||||
}
|
}
|
||||||
|
}, error => this.errorMessage = <any> error);
|
||||||
}, error => this.errorMessage = <any> error);
|
|
||||||
|
/** To Display The Entities Data For Entities DropDown */
|
||||||
/** To Display The Entities Data For Entities DropDown */
|
this._masterService.getAllMasterData('CUSTOMERSEGMENT').subscribe(
|
||||||
this._masterService.getAllMasterData('ENTITY').subscribe(
|
dataresult => {
|
||||||
dataresult => {
|
if (dataresult.dataStatus == true) {
|
||||||
if (dataresult.status == 200) {
|
this.customerSegmentdatas = dataresult.records;
|
||||||
this.lenderdatas = dataresult.records;
|
this.customerSegmentdatas = this.customerSegmentdatas.filter(segment=>segment.isactive == 1 );
|
||||||
this.lenderdatas = this.lenderdatas.filter(entity=>entity.isactive == 1 );
|
}
|
||||||
}
|
}, error => this.errorMessage = <any> error)
|
||||||
}, error => this.errorMessage = <any> error);
|
|
||||||
|
|
||||||
/** To Display The Entities Data For Entities DropDown */
|
|
||||||
this._masterService.getAllMasterData('PRODUCTS').subscribe(
|
|
||||||
dataresult => {
|
|
||||||
if (dataresult.status == 200) {
|
|
||||||
this.productdatas = dataresult.records;
|
|
||||||
this.productdatas = this.productdatas.filter(product=>product.isactive == 1 );
|
|
||||||
}
|
}
|
||||||
}, error => this.errorMessage = <any> error);
|
|
||||||
|
|
||||||
/** To Display The Entities Data For Entities DropDown */
|
|
||||||
this._masterService.getAllMasterData('CUSTOMERSEGMENT').subscribe(
|
|
||||||
dataresult => {
|
|
||||||
if (dataresult.status == 200) {
|
|
||||||
this.customerSegmentdatas = dataresult.records;
|
|
||||||
this.customerSegmentdatas = this.customerSegmentdatas.filter(segment=>segment.isactive == 1 );
|
|
||||||
}
|
|
||||||
}, error => this.errorMessage = <any> error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Pd Team Form Datas */
|
/** Pd Team Form Datas */
|
||||||
PdTeamFormDatas(){
|
PdTeamFormDatas(){
|
||||||
this._pdTeamForm = this._formBuilder.group({
|
//console.log('Patricular pdteam_id Datas',this.childMessage);
|
||||||
pdteam_id: [null, Validators.compose([Validators.required])],
|
|
||||||
team_name: [null, Validators.compose([Validators.required])],
|
|
||||||
fk_lender: [null, Validators.compose([Validators.required])],
|
|
||||||
fk_city: [null, Validators.compose([Validators.required])],
|
|
||||||
fk_customer_segment: [null, Validators.compose([Validators.required])],
|
|
||||||
fk_product:[null, Validators.compose([Validators.required])],
|
|
||||||
|
|
||||||
|
// let PdTeamcity:any = [];
|
||||||
|
// for (let ptc of this.childMessage[0].CITYMAP) {
|
||||||
|
// //PdTeamcity.push(ptc);
|
||||||
|
// PdTeamcity.push(this.citydatas.filter(dataresults => this.selectedCityDatas == ptc));
|
||||||
|
// //this._pdTeamForm.controls['fk_city'].setValue(PdTeamcity);
|
||||||
|
// }
|
||||||
|
// console.log('PdTeamcity',PdTeamcity);
|
||||||
|
|
||||||
|
let PdTeamCity:any = [];
|
||||||
|
for(let ptc of this.childMessage[0].CITYMAP){
|
||||||
|
PdTeamCity.push(ptc.city_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
let PdTeamProduct:any = [];
|
||||||
|
for(let ptp of this.childMessage[0].PRODUCTS){
|
||||||
|
PdTeamProduct.push(ptp.product_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
let PdTeamCS:any = [];
|
||||||
|
for(let ptcs of this.childMessage[0].CUSTOMERSEGMENT){
|
||||||
|
PdTeamCS.push(ptcs.customer_segment_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._pdTeamForm = this._formBuilder.group({
|
||||||
|
pdteam_id: [this.childMessage[0].pdteam_id, Validators.compose([Validators.required])],
|
||||||
|
team_name: [this.childMessage[0].team_name, Validators.compose([Validators.required])],
|
||||||
|
fk_lender: [this.childMessage[0].fk_lender_id, Validators.compose([Validators.required])],
|
||||||
|
fk_city: [PdTeamCity, Validators.compose([Validators.required])],
|
||||||
|
fk_customer_segment: [PdTeamCS, Validators.compose([Validators.required])],
|
||||||
|
fk_product:[PdTeamProduct, Validators.compose([Validators.required])],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** convenience getter for easy access to form fields */
|
/** convenience getter for easy access to form fields */
|
||||||
get f() { return this._pdTeamForm.controls; }
|
get f() { return this._pdTeamForm.controls; }
|
||||||
|
|
||||||
/** For Popup Close Button */
|
/** For Popup Close Button */
|
||||||
onNoClick(): void {
|
onNoClick(): void {
|
||||||
this._router.navigate(['/setting/pdteam/pdteamlist']);
|
this._PdTeamListComponent.changeListView();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** To Save/Edited Popup Data */
|
|
||||||
/** To Save/Edited Popup Data */
|
|
||||||
onSubmit() {
|
|
||||||
this.submitted = true;
|
|
||||||
// stop here if form is invalid
|
|
||||||
if (this._pdTeamForm.invalid) {
|
|
||||||
// this.errorMessage = "Please Fill All Mandate Fields.";
|
|
||||||
// return;
|
|
||||||
alert('Please Fill All Mandate Fields.');
|
|
||||||
} else {
|
|
||||||
|
|
||||||
var pdTeamFormValues = this._pdTeamForm.value;
|
|
||||||
|
|
||||||
//To Remove The "Null" With Key also
|
|
||||||
Object.keys(pdTeamFormValues).forEach(
|
|
||||||
(key) => ( pdTeamFormValues[key] == null) && delete pdTeamFormValues[key]);
|
|
||||||
|
|
||||||
this._pdTeamService.addPdTeamDetail(this._pdTeamForm.value).subscribe(
|
|
||||||
dataresult => {
|
|
||||||
if (dataresult.status == 200) {
|
|
||||||
console.log(dataresult);
|
|
||||||
// this._notifier.notify('success', 'Record Saved Successfully.!');
|
|
||||||
alert('Record Saved Successfully.!');
|
|
||||||
this._router.navigate(['/setting/pdteam/pdteamlist']);
|
|
||||||
this._pdTeamForm.reset();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//this._notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
|
||||||
alert('Some Thing Wents Wrong Try Again !');
|
|
||||||
//this.errorMessage = "Some Thing Wents Wrong Try Again !";
|
|
||||||
}
|
|
||||||
}, error => {
|
|
||||||
// this._notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
|
||||||
// this.errorMessage = "Something Wents Wrong Try Again !";
|
|
||||||
alert('Some Thing Wents Wrong Try Again !');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** To Reset Popup Data For Add*/
|
/** To Reset Popup Data For Add*/
|
||||||
|
onResetForEdit(){
|
||||||
onResetForAdd(){
|
this.PdTeamFormDatas();
|
||||||
alert("reset function");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**on change function for customer segment to dispaly the as List in html page */
|
/**on change function for customer segment to dispaly the as List in html page */
|
||||||
onChangeCustomerSegmentDatas($event){
|
onChangeCustomerSegmentDatas($event){
|
||||||
let CustomerSegmentName = $event.source.value.name;
|
//let CustomerSegmentName = $event.source.value.name;
|
||||||
|
let CustomerSegmentName = this.customerSegmentdatas.filter(cs=>cs.customer_segment_id == $event.source.value)[0];
|
||||||
|
|
||||||
if($event.source._selected === true ){
|
if($event.source._selected === true ){
|
||||||
this.selectedSegmentDatas.push(CustomerSegmentName);
|
this.selectedSegmentDatas.push(CustomerSegmentName.name);
|
||||||
}
|
}
|
||||||
else if($event.source._selected === false ){
|
else if($event.source._selected === false ){
|
||||||
let index = this.selectedSegmentDatas.indexOf(CustomerSegmentName);
|
let index = this.selectedSegmentDatas.indexOf(CustomerSegmentName.name);
|
||||||
this.selectedSegmentDatas.splice(index,1);
|
this.selectedSegmentDatas.splice(index,1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**on change function for City to display the as List in html page */
|
/**on change function for City to display the as List in html page */
|
||||||
onChangeCityDatas($event){
|
onChangeCityDatas($event){
|
||||||
|
var mycheck = 0 ;
|
||||||
|
//let cityName = $event.source.value;
|
||||||
|
let cityName = this.citydatas.filter(city=>city.city_id == $event.source.value)[0];
|
||||||
|
|
||||||
|
if($event.source._selected === true ){
|
||||||
|
|
||||||
|
for(let Duplication_City of this.pdTeamCityArray){
|
||||||
|
|
||||||
|
let teamname = Duplication_City.team_name;
|
||||||
|
let dup_cityname = Duplication_City.CITYMAP.filter(city=>city.city_id == $event.source.value);
|
||||||
|
|
||||||
|
if(dup_cityname != ''){
|
||||||
|
for(let data of dup_cityname){
|
||||||
|
|
||||||
|
if(data.name == cityName.name){
|
||||||
|
alert('"'+data.name+'" Already Existing with "'+ teamname +'"');
|
||||||
|
$event.source._selected = false;
|
||||||
|
mycheck++;
|
||||||
|
}
|
||||||
|
|
||||||
let cityName = $event.source.value.name;
|
}
|
||||||
if($event.source._selected === true ){
|
}
|
||||||
this.selectedCityDatas.push(cityName);
|
}
|
||||||
}
|
|
||||||
else if($event.source._selected === false ){
|
if(mycheck == 0){
|
||||||
let index = this.selectedCityDatas.indexOf(cityName);
|
this.selectedCityDatas.push(cityName.name);
|
||||||
this.selectedCityDatas.splice(index,1);
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
|
else if($event.source._selected === false ){
|
||||||
|
let index = this.selectedCityDatas.indexOf(cityName.name);
|
||||||
|
this.selectedCityDatas.splice(index,1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**on change function for Product to display the data as List in html page */
|
/**on change function for Product to display the data as List in html page */
|
||||||
onChangeProductDatas($event){
|
onChangeProductDatas($event){
|
||||||
|
|
||||||
let productName = $event.source.value.name;
|
//let productName = $event.source.value.name;
|
||||||
|
let productName = this.productdatas.filter(product=>product.product_id == $event.source.value )[0];
|
||||||
if($event.source._selected === true ){
|
if($event.source._selected === true ){
|
||||||
this.selectedProductDatas.push(productName);
|
this.selectedProductDatas.push(productName.name);
|
||||||
}
|
}
|
||||||
else if($event.source._selected === false ){
|
else if($event.source._selected === false ){
|
||||||
let index = this.selectedProductDatas.indexOf(productName);
|
let index = this.selectedProductDatas.indexOf(productName.name);
|
||||||
this.selectedProductDatas.splice(index,1);
|
this.selectedProductDatas.splice(index,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** To Edited form Data */
|
||||||
|
onSubmit() {
|
||||||
|
|
||||||
|
var pdTeamFormValues = this._pdTeamForm.value;
|
||||||
|
Object.keys(pdTeamFormValues).forEach(
|
||||||
|
(key) => ( pdTeamFormValues[key] == null) && delete pdTeamFormValues[key]);
|
||||||
|
|
||||||
|
this._pdTeamService.editPdTeamDetail(pdTeamFormValues).subscribe(
|
||||||
|
|
||||||
|
dataresult=>{
|
||||||
|
if (dataresult.dataStatus == true){
|
||||||
|
alert("Data Edited Successfully");
|
||||||
|
this.notifier.notify('success', 'Record Edited Successfully.!');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
alert("SomeThing Wents Wrong Try Again !");
|
||||||
|
this.notifier.notify('warning', 'SomeThing Wents Wrong Try Again !');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/** End Of PD TEAM ADD Component */
|
/** End Of PD Team Edit Component */
|
||||||
@ -1,4 +1,5 @@
|
|||||||
<mat-card>
|
<div *ngIf="listView">
|
||||||
|
<mat-card>
|
||||||
<div fxLayout="row" fxLayoutAlign="start center" class="mb-1">
|
<div fxLayout="row" fxLayoutAlign="start center" class="mb-1">
|
||||||
<div class="ml-xs mr-xs" style="width: 30%;">
|
<div class="ml-xs mr-xs" style="width: 30%;">
|
||||||
<mat-card-title><span> PD Team Masters</span></mat-card-title>
|
<mat-card-title><span> PD Team Masters</span></mat-card-title>
|
||||||
@ -22,9 +23,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<mat-table *ngIf="!noRecordFound" [dataSource]="dataSource" matSort >
|
||||||
|
|
||||||
<mat-table *ngIf="!noRecordFound" [dataSource]="dataSource" matSort >
|
|
||||||
|
|
||||||
<ng-container matColumnDef="serialno">
|
<ng-container matColumnDef="serialno">
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Sl </mat-header-cell>
|
<mat-header-cell *matHeaderCellDef mat-sort-header>Sl </mat-header-cell>
|
||||||
@ -67,7 +66,7 @@
|
|||||||
<mat-header-cell *matHeaderCellDef> Actions </mat-header-cell>
|
<mat-header-cell *matHeaderCellDef> Actions </mat-header-cell>
|
||||||
<mat-cell *matCellDef="let row">
|
<mat-cell *matCellDef="let row">
|
||||||
|
|
||||||
<button mat-icon-button [color]="color" class="hover-icon" matTooltip="Edit" matTooltipPosition="above" (click)="editPdTeam(row)"><mat-icon>edit</mat-icon></button>
|
<button mat-icon-button [color]="color" class="hover-icon" matTooltip="Edit" matTooltipPosition="above" (click)="editPdTeam(row.pdteam_id)"><mat-icon>edit</mat-icon></button>
|
||||||
|
|
||||||
</mat-cell>
|
</mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
@ -79,7 +78,10 @@
|
|||||||
|
|
||||||
<mat-paginator *ngIf="!noRecordFound" [pageSizeOptions]="[5, 10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
|
<mat-paginator *ngIf="!noRecordFound" [pageSizeOptions]="[5, 10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div *ngIf="noRecordFound" class="nocontent">No records found</div> -->
|
|
||||||
|
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
<notifier-container></notifier-container>
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
<notifier-container></notifier-container>
|
||||||
|
<div *ngIf="!listView">
|
||||||
|
<app-pd-team-edit [childMessage]="parentMessage"></app-pd-team-edit>
|
||||||
|
</div>
|
||||||
|
|||||||
@ -11,8 +11,6 @@ import { PdTeamService } from '../../service/masters/pd-team.service';
|
|||||||
|
|
||||||
import { NotifierService } from 'angular-notifier';
|
import { NotifierService } from 'angular-notifier';
|
||||||
|
|
||||||
/** Dialog Component */
|
|
||||||
import { PdTeamDialogComponent } from '../pd-team-dialog/pd-team-dialog.component';
|
|
||||||
/** Add Component */
|
/** Add Component */
|
||||||
//import { } from '../pd-team-add/pd-team-add.component;
|
//import { } from '../pd-team-add/pd-team-add.component;
|
||||||
/** Edit Component */
|
/** Edit Component */
|
||||||
@ -33,10 +31,13 @@ export class PdTeamListComponent implements OnInit {
|
|||||||
color = 'primary';
|
color = 'primary';
|
||||||
userData = null;
|
userData = null;
|
||||||
noRecordFound: boolean = false;
|
noRecordFound: boolean = false;
|
||||||
|
|
||||||
private notifier: NotifierService;
|
private notifier: NotifierService;
|
||||||
|
public listView: any = true;
|
||||||
public dataLength: number;
|
public dataLength: number;
|
||||||
public dataSource = new MatTableDataSource();
|
public dataSource = new MatTableDataSource();
|
||||||
|
public parentMessage: any = [];
|
||||||
|
|
||||||
displayedColumns = ['serialno','team_name','lender_name','actions','isactive'];
|
displayedColumns = ['serialno','team_name','lender_name','actions','isactive'];
|
||||||
|
|
||||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||||
@ -50,7 +51,7 @@ export class PdTeamListComponent implements OnInit {
|
|||||||
this.notifier = notifier;
|
this.notifier = notifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {}
|
ngOnInit() { this.getPdTeam(); }
|
||||||
|
|
||||||
/** To add data */
|
/** To add data */
|
||||||
addPdTeam() {
|
addPdTeam() {
|
||||||
@ -58,10 +59,22 @@ export class PdTeamListComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** To edit data */
|
/** To edit data */
|
||||||
editPdTeam() {
|
editPdTeam(detail){
|
||||||
this.router.navigate(['/setting/pdteam/editpdteam']);
|
|
||||||
|
this._PdTeamService.getAllPDTeamWithPDTeamID(detail).subscribe(
|
||||||
|
dataresult => {
|
||||||
|
this.parentMessage = dataresult;
|
||||||
|
this.parentMessage = this.parentMessage.records;
|
||||||
|
this.listView = false;
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changeListView(){
|
||||||
|
this.getPdTeam();
|
||||||
|
this.listView = true;
|
||||||
|
}
|
||||||
|
|
||||||
/** To get data for listing */
|
/** To get data for listing */
|
||||||
getPdTeam() {
|
getPdTeam() {
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { NotifierModule, NotifierOptions } from 'angular-notifier';
|
||||||
|
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||||
import {
|
import {
|
||||||
MatCardModule,
|
MatCardModule,
|
||||||
MatIconModule,
|
MatIconModule,
|
||||||
@ -17,19 +19,17 @@ import { MatTooltipModule } from '@angular/material/tooltip';
|
|||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
import { NgxMatSelectSearchModule } from 'ngx-mat-select-search';
|
import { NgxMatSelectSearchModule } from 'ngx-mat-select-search';
|
||||||
import { NgxDatatableModule } from '@swimlane/ngx-datatable';
|
import { NgxDatatableModule } from '@swimlane/ngx-datatable';
|
||||||
import { NotifierModule, NotifierOptions } from 'angular-notifier';
|
|
||||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
|
||||||
|
|
||||||
import { PdTeamDialogComponent } from './pd-team-dialog/pd-team-dialog.component';
|
|
||||||
import { PdTeamListComponent } from './pd-team-list/pd-team-list.component';
|
import { PdTeamListComponent } from './pd-team-list/pd-team-list.component';
|
||||||
|
|
||||||
|
import { PdTeamAddComponent } from './pd-team-add/pd-team-add.component';
|
||||||
|
import { PdTeamEditComponent } from './pd-team-edit/pd-team-edit.component';
|
||||||
|
|
||||||
/** Route */
|
/** Route */
|
||||||
import { PdTeamRoutes } from './pd-team.routing';
|
import { PdTeamRoutes } from './pd-team.routing';
|
||||||
|
|
||||||
/** Service */
|
/** Service */
|
||||||
import { PdTeamService } from '../service/masters/pd-team.service';
|
import { PdTeamService } from '../service/masters/pd-team.service';
|
||||||
import { PdTeamAddComponent } from './pd-team-add/pd-team-add.component';
|
|
||||||
import { PdTeamEditComponent } from './pd-team-edit/pd-team-edit.component';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom angular notifier options
|
* Custom angular notifier options
|
||||||
@ -100,12 +100,13 @@ const customNotifierOptions: NotifierOptions = {
|
|||||||
MatTooltipModule,
|
MatTooltipModule,
|
||||||
NotifierModule.withConfig(customNotifierOptions),
|
NotifierModule.withConfig(customNotifierOptions),
|
||||||
],
|
],
|
||||||
declarations: [PdTeamDialogComponent,
|
declarations: [
|
||||||
PdTeamListComponent,
|
PdTeamListComponent,
|
||||||
PdTeamAddComponent,
|
PdTeamAddComponent,
|
||||||
PdTeamEditComponent],
|
PdTeamEditComponent],
|
||||||
|
|
||||||
providers: [PdTeamService ],
|
providers: [PdTeamService]
|
||||||
entryComponents: [PdTeamDialogComponent]
|
|
||||||
|
//entryComponents: [PdTeamDialogComponent]
|
||||||
})
|
})
|
||||||
export class PdTeamModule { }
|
export class PdTeamModule { }
|
||||||
|
|||||||
@ -25,6 +25,7 @@ export class PdTeamService {
|
|||||||
|
|
||||||
//private apiUrl = "http://ssa.sineedge.com/sparqapi/api/";
|
//private apiUrl = "http://ssa.sineedge.com/sparqapi/api/";
|
||||||
private apiUrl = "http://localhost/sparqapi/api/";
|
private apiUrl = "http://localhost/sparqapi/api/";
|
||||||
|
pk: { "primary_key": any; };
|
||||||
|
|
||||||
|
|
||||||
constructor(private _http: HttpClient,
|
constructor(private _http: HttpClient,
|
||||||
@ -37,7 +38,7 @@ private apiUrl = "http://localhost/sparqapi/api/";
|
|||||||
* 1st argument is "Records": any - Set of Data To Adding to database
|
* 1st argument is "Records": any - Set of Data To Adding to database
|
||||||
*/
|
*/
|
||||||
addPdTeamDetail(Records: any): Observable<any> {
|
addPdTeamDetail(Records: any): Observable<any> {
|
||||||
console.log('From Service Data',Records);
|
console.log('Add PD team Details In Service',Records);
|
||||||
Records.fk_createdby = this._aws.getlocale();//to get user id for who is created the Record
|
Records.fk_createdby = this._aws.getlocale();//to get user id for who is created the Record
|
||||||
Records.createdon = currentdate;//to get Current date and Time for when the Record is created
|
Records.createdon = currentdate;//to get Current date and Time for when the Record is created
|
||||||
// Records.fk_updatedby = this._aws.getlocale();//to get user id for who is update the record
|
// Records.fk_updatedby = this._aws.getlocale();//to get user id for who is update the record
|
||||||
@ -58,7 +59,7 @@ return this._http.post<any>(this.apiUrl+"savePDTeam", ArrayData)
|
|||||||
* 1st argument is "Records": any - Set of Updated Data
|
* 1st argument is "Records": any - Set of Updated Data
|
||||||
*/
|
*/
|
||||||
editPdTeamDetail(Records: any): Observable<any> {
|
editPdTeamDetail(Records: any): Observable<any> {
|
||||||
|
console.log('Update PD team Details In Service',Records);
|
||||||
Records.fk_updatedby = this._aws.getlocale();//to get user id for who is update the record
|
Records.fk_updatedby = this._aws.getlocale();//to get user id for who is update the record
|
||||||
Records.updatedon = currentdate;//to get Current date and Time for when the Record is updated
|
Records.updatedon = currentdate;//to get Current date and Time for when the Record is updated
|
||||||
|
|
||||||
@ -134,16 +135,24 @@ return this._http.post<any>(this.apiUrl+"savePDTeam", ArrayData)
|
|||||||
* TO Get the Master Datas using API Call
|
* TO Get the Master Datas using API Call
|
||||||
* 1st argument is "TableName" :string - Table Name
|
* 1st argument is "TableName" :string - Table Name
|
||||||
*/
|
*/
|
||||||
getAllPdTeamList(): Observable<any> {
|
getAllPdTeam(): Observable<any> {
|
||||||
|
|
||||||
return this._http.get<any>(this.apiUrl+"getListOfPDTeam")
|
return this._http.post<any>(this.apiUrl+'getListOfPDTeam','')
|
||||||
.pipe(
|
.pipe(
|
||||||
catchError(this.handleError('role', []))
|
catchError(this.handleError('role', []))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getAllPDTeamWithPDTeamID(Primarykey): Observable<any> {
|
||||||
|
|
||||||
/** Get All PD Team Child Data using API call Based on Primary Key */
|
var pk = { "primary_key":Primarykey }
|
||||||
|
return this._http.post<any>(this.apiUrl+'getListOfPDTeam',pk)
|
||||||
|
.pipe(
|
||||||
|
catchError(this.handleError('role', []))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// /** Get All PD Team Child Data using API call Based on Primary Key */
|
||||||
getAllPdTeamMapListWithPK(Primarykey): Observable<any> {
|
getAllPdTeamMapListWithPK(Primarykey): Observable<any> {
|
||||||
var pk = { "primary_key":Primarykey }
|
var pk = { "primary_key":Primarykey }
|
||||||
|
|
||||||
@ -165,6 +174,14 @@ return this._http.post<any>(this.apiUrl+"savePDTeam", ArrayData)
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getAllPdTeamCityMapping(): Observable<any> {
|
||||||
|
//var vaildateKey = { "vaildate_key": 'cityvaildation1' }
|
||||||
|
return this._http.get<any>(this.apiUrl+'getListOfPDTeamCityMapping')
|
||||||
|
.pipe(
|
||||||
|
catchError(this.handleError('role', []))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TO get City Data For Listing Screen
|
* TO get City Data For Listing Screen
|
||||||
@ -192,12 +209,11 @@ return this._http.post<any>(this.apiUrl+"savePDTeam", ArrayData)
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
getAllPdTeam(): Observable<any> {
|
// getAllPdTeam(): Observable<any> {
|
||||||
return this._http.get(this.apiUrl+'getListOfPDTeam')
|
// return this._http.get(this.apiUrl+'getListOfPDTeam')
|
||||||
.pipe(
|
// .pipe(
|
||||||
catchError(this.handleError('role', []))
|
// catchError(this.handleError('role', []))
|
||||||
)
|
// )
|
||||||
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user