entity details updated : kdk
This commit is contained in:
parent
d46f78a301
commit
3973f15797
@ -5,7 +5,13 @@
|
||||
type="button" (click)="onNoClick()"><mat-icon>close</mat-icon></button>
|
||||
</div>
|
||||
</div>
|
||||
<mat-card style="padding: 12px 8px;">
|
||||
|
||||
<div>
|
||||
<mat-dialog-content class="mat-typography">
|
||||
<mat-card style="padding: 6px;">
|
||||
<mat-tab-group>
|
||||
<mat-tab label="Add TAT">
|
||||
<div style="margin: 12px;" *ngIf="!listShow">
|
||||
<form [formGroup]="tatForm" (submit)="onSubmit()">
|
||||
<div fxLayout="row wrap" fxLayout.xs="column" fxLayoutGap="6px" fxLayoutAlign="start">
|
||||
<mat-form-field>
|
||||
@ -21,14 +27,14 @@
|
||||
<div>
|
||||
<mat-form-field>
|
||||
<mat-select (selectionChange)="selectedPD($event)" placeholder="PD Type" formControlName="toppings1" multiple>
|
||||
<mat-option *ngFor="let pd of m_pdType" [value]="pd.id">{{pd.name}}</mat-option>
|
||||
<mat-option *ngFor="let pd of m_pdType" [value]="pd.pd_type_id">{{pd.type_name}}</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="submitted && f.toppings1.hasError('required')" class="mat-text-warn">PD Type Required.!</mat-error>
|
||||
</mat-form-field>
|
||||
<div style="height: 160px; overflow: auto;">
|
||||
<ul style="list-style: none; margin: 0px;padding: 0px;">
|
||||
<li *ngFor="let pdName of selectedItem">
|
||||
<mat-chip>{{pdName.name}}</mat-chip>
|
||||
<mat-chip>{{pdName.type_name}}</mat-chip>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -36,7 +42,7 @@
|
||||
<div>
|
||||
<mat-form-field>
|
||||
<mat-select (selectionChange)="selectedProduct($event)" placeholder="Product" formControlName="toppings2" multiple>
|
||||
<mat-option *ngFor="let prdct of m_product" [value]="prdct.id">{{prdct.name}}</mat-option>
|
||||
<mat-option *ngFor="let prdct of m_product" [value]="prdct.product_id">{{prdct.name}}</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="submitted && f.toppings2.hasError('required')" class="mat-text-warn">Product Required.!</mat-error>
|
||||
</mat-form-field>
|
||||
@ -51,7 +57,7 @@
|
||||
<div>
|
||||
<mat-form-field>
|
||||
<mat-select (selectionChange)="selectedCity($event)" placeholder="City" formControlName="toppings3" multiple>
|
||||
<mat-option *ngFor="let city of m_city" [value]="city.id">{{city.name}}</mat-option>
|
||||
<mat-option *ngFor="let city of m_city" [value]="city.city_id">{{city.name}}</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="submitted && f.toppings3.hasError('required')" class="mat-text-warn">City Required.!</mat-error>
|
||||
</mat-form-field>
|
||||
@ -69,11 +75,72 @@
|
||||
<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>
|
||||
</form>
|
||||
<div *ngIf="existValArray.length > 0">
|
||||
<h5><b>Note : </b> Following are already exist for this Entity.</h5>
|
||||
<ul>
|
||||
<li *ngFor="let val of existValArray">{{ val }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div *ngIf="listShow">
|
||||
<div>
|
||||
<h4 fxLayout="row" fxLayoutAlign="center">Before Submit , Pleast Verify your selected values as below.</h4>
|
||||
<mat-card fxLayout="row wrap" fxLayout.xs="column" fxLayoutGap="6px" fxLayoutAlign="start">
|
||||
<div><label> Tat Value 1</label>
|
||||
<div>{{tatValue1}}</div>
|
||||
</div>
|
||||
<div><label> Tat Value 2</label>
|
||||
<div>{{tatValue2}}</div>
|
||||
</div>
|
||||
</mat-card>
|
||||
</div>
|
||||
<div>
|
||||
<mat-card class="example-container">
|
||||
<table mat-table [dataSource]="transactions" class="mat-elevation-z8">
|
||||
|
||||
<!-- Checkbox Column -->
|
||||
<ng-container matColumnDef="select">
|
||||
<th mat-header-cell *matHeaderCellDef>
|
||||
<mat-checkbox (change)="$event ? masterToggle() : null" [checked]="selection.hasValue() && isAllSelected()" [indeterminate]="selection.hasValue() && !isAllSelected()">
|
||||
</mat-checkbox>
|
||||
</th>
|
||||
<td mat-cell *matCellDef="let row">
|
||||
<mat-checkbox (click)="$event.stopPropagation()" (change)="$event ? selection.toggle(row) : null" [checked]="selection.isSelected(row)">
|
||||
</mat-checkbox>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="pd">
|
||||
<th mat-header-cell *matHeaderCellDef> Pd Type </th>
|
||||
<td mat-cell *matCellDef="let transaction"> {{transaction.pd_type.name}} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="product">
|
||||
<th mat-header-cell *matHeaderCellDef> Product </th>
|
||||
<td mat-cell *matCellDef="let transaction"> {{transaction.product.name}} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="city">
|
||||
<th mat-header-cell *matHeaderCellDef> City </th>
|
||||
<td mat-cell *matCellDef="let transaction"> {{transaction.city.name}} </td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
<!--<tr mat-footer-row *matFooterRowDef="displayedColumns"></tr>-->
|
||||
</table>
|
||||
</mat-card>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="end">
|
||||
<button *ngIf="selection.selected.length == 0" mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset"
|
||||
matTooltipPosition="above" type="button" (click)="onDataSubmit()"><mat-icon>save</mat-icon></button>
|
||||
<button *ngIf="selection.selected.length > 0" mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset"
|
||||
matTooltipPosition="above" type="button" (click)="onDelete()"><mat-icon>delete</mat-icon></button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
|
||||
</mat-card>
|
||||
</mat-dialog-content>
|
||||
<!--<mat-dialog-actions align="end">
|
||||
<div fxLayout="row" fxLayoutAlign="end">
|
||||
</div>
|
||||
</mat-dialog-actions>-->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -0,0 +1,111 @@
|
||||
<div style="width: inherit;">
|
||||
<div class="ml-xs mr-xs" style="width: 100%;" fxLayout="row" fxLayoutAlign="end">
|
||||
<div style="text-align:right;">
|
||||
<button mat-raised-button mat-icon-button color="primary" class="mr-1 mb-1 hover-icon" matTooltip="Close" matTooltipPosition="above"
|
||||
type="button" (click)="onNoClick()"><mat-icon>close</mat-icon></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<mat-dialog-content class="mat-typography">
|
||||
<mat-card style="padding: 6px;">
|
||||
<mat-tab-group>
|
||||
<mat-tab label="TAT Details">
|
||||
<mat-card>
|
||||
<form [formGroup]="tatListEditForm" (submit)="onSubmit()">
|
||||
<div fxLayout="row wrap" fxLayout.xs="column" fxLayoutGap="6px" fxLayoutAlign="start">
|
||||
<mat-form-field>
|
||||
<input placeholder="TAT Value 1" matInput formControlName="tat1">
|
||||
<mat-error *ngIf="submitted && f.tat1.hasError('required')" class="mat-text-warn">TAT 1 Value Required.!</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input placeholder="TAT Value 2" matInput formControlName="tat2">
|
||||
<mat-error *ngIf="submitted && f.tat2.hasError('required')" class="mat-text-warn">TAT 2 Value Required.!</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="end">
|
||||
<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>
|
||||
</form>
|
||||
</mat-card>
|
||||
<table *ngIf="dataSource.length > 0" mat-table [dataSource]="dataSource" class="mat-elevation-z8">
|
||||
<ng-container matColumnDef="select">
|
||||
<th mat-header-cell *matHeaderCellDef>
|
||||
<mat-checkbox (change)="$event ? masterToggle() : null" [checked]="selection.hasValue() && isAllSelected()" [indeterminate]="selection.hasValue() && !isAllSelected()">
|
||||
</mat-checkbox>
|
||||
</th>
|
||||
<td mat-cell *matCellDef="let row">
|
||||
<mat-checkbox (click)="$event.stopPropagation()" (change)="$event ? selection.toggle(row) : null" [checked]="selection.isSelected(row)">
|
||||
</mat-checkbox>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="pd">
|
||||
<th mat-header-cell *matHeaderCellDef> Pd Type </th>
|
||||
<td mat-cell *matCellDef="let transaction"> {{transaction.pd_type.name}} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="product">
|
||||
<th mat-header-cell *matHeaderCellDef> Product </th>
|
||||
<td mat-cell *matCellDef="let transaction"> {{transaction.product.name}} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="city">
|
||||
<th mat-header-cell *matHeaderCellDef> City </th>
|
||||
<td mat-cell *matCellDef="let transaction"> {{transaction.city.name}} </td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
</table>
|
||||
<button *ngIf="selection?.selected.length > 0" mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset"
|
||||
matTooltipPosition="above" type="button" (click)="onDelete()"><mat-icon>delete</mat-icon></button>
|
||||
</mat-tab>
|
||||
<mat-tab label="Add TAT">
|
||||
<div style="margin: 12px;" *ngIf="!listShow">
|
||||
<form [formGroup]="tatEditAddForm" (submit)="onSubmitEditAddForm()">
|
||||
<div fxLayout="row wrap" fxLayout.xs="column" fxLayoutGap="6px" fxLayoutAlign="start">
|
||||
<div>
|
||||
<mat-form-field>
|
||||
<mat-select (selectionChange)="selectedDetails($event)" placeholder="PD Type" formControlName="pd_type" >
|
||||
<mat-option *ngFor="let pd of m_pdType" [value]="pd.pd_type_id">{{pd.type_name}}</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="submitted && f.toppings1.hasError('required')" class="mat-text-warn">PD Type Required.!</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div>
|
||||
<mat-form-field>
|
||||
<mat-select (selectionChange)="selectedDetails($event)" placeholder="Product" formControlName="product">
|
||||
<mat-option *ngFor="let prdct of m_product" [value]="prdct.product_id">{{prdct.name}}</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="submitted && f.toppings2.hasError('required')" class="mat-text-warn">Product Required.!</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div>
|
||||
<mat-form-field>
|
||||
<mat-select (selectionChange)="selectedDetails($event)" placeholder="City" formControlName="city">
|
||||
<mat-option *ngFor="let city of m_city" [value]="city.city_id">{{city.name}}</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="submitted && f.toppings3.hasError('required')" class="mat-text-warn">City Required.!</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="end">
|
||||
<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="Save" matTooltipPosition="above" type="submit"><mat-icon>save</mat-icon></button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
<!--<pre>
|
||||
{{ selection?.selected.length}}
|
||||
</pre>-->
|
||||
</mat-card>
|
||||
</mat-dialog-content>
|
||||
<mat-dialog-actions align="end">
|
||||
<div fxLayout="row" fxLayoutAlign="end">
|
||||
</div>
|
||||
</mat-dialog-actions>
|
||||
</div>
|
||||
</div>
|
||||
@ -4,21 +4,21 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<mat-card *ngFor="let data of entityTatListDetails">
|
||||
<mat-card *ngFor="let data of listOfTatDetails">
|
||||
<div fxLayout="row wrap" fxLayout.xs="column" fxLayoutGap="2%" fxLayoutAlign="center center">
|
||||
<div fxFlex="48%">
|
||||
<div class="text-line-limit">
|
||||
<div *ngFor="let comb of data.tatCombinations; let last = last">{{comb.pd.name}} - {{comb.product.name}} - {{comb.city.name}} <span *ngIf="!last">,</span></div>
|
||||
<div *ngFor="let comb of data.child; let last = last">{{comb.pd_type.name}} - {{comb.product.name}} - {{comb.city.name}} <span *ngIf="!last">,</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div fxFlex="9%">
|
||||
{{data.tatVal1}}
|
||||
{{data.tat1}}
|
||||
</div>
|
||||
<div fxFlex="9%">
|
||||
{{data.tatVal2}}
|
||||
{{data.tat2}}
|
||||
</div>
|
||||
<div fxFlex="18%">
|
||||
<button mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Edit" matTooltipPosition="above" (click)="editDetails(data)"><mat-icon>edit</mat-icon></button>
|
||||
<button mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Edit" matTooltipPosition="above" (click)="editTatInfoDetails(data)"><mat-icon>edit</mat-icon></button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card>
|
||||
@ -14,3 +14,11 @@
|
||||
// height: 1.2em;
|
||||
// white-space: nowrap;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
tr.mat-footer-row {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@ -4,12 +4,12 @@ import { FormGroup, FormControl, FormBuilder, Validators, FormArray } from '@ang
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { NotifierService } from 'angular-notifier';
|
||||
|
||||
import { MastersService } from './../../../service/masters/masters.service';
|
||||
import { EntityService } from './../../../service/entity/entity.service';
|
||||
|
||||
import { SelectionModel } from '@angular/cdk/collections';
|
||||
|
||||
@Component({
|
||||
selector: 'app-entity-edit-tat',
|
||||
templateUrl: './entity-edit-tat.component.html',
|
||||
@ -25,6 +25,8 @@ export class EntityEditTatComponent implements OnInit {
|
||||
*/
|
||||
private notifier: NotifierService;
|
||||
|
||||
listOfTatDetails = [];
|
||||
|
||||
constructor(notifier: NotifierService,
|
||||
private entityService: EntityService,
|
||||
private mastersService: MastersService,
|
||||
@ -32,55 +34,51 @@ export class EntityEditTatComponent implements OnInit {
|
||||
this.notifier = notifier;
|
||||
}
|
||||
ngOnInit() {
|
||||
this.getListofEntityTATInfo();
|
||||
}
|
||||
|
||||
getListofEntityTATInfo() {
|
||||
this.entityService.getEntityTATInfoDetails(this.entityId).subscribe(data => {
|
||||
if (data.dataStatus) {
|
||||
this.listOfTatDetails = data.records;
|
||||
} else {
|
||||
|
||||
}
|
||||
}, err => {
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
addNewTatDetails() {
|
||||
const dialogRef = this.dialog.open(DialogEntityAddTatComponent, {
|
||||
data: { entity_id: this.entityId },
|
||||
disableClose: true
|
||||
disableClose: true,
|
||||
maxWidth: '100vw',
|
||||
maxHeight: '100vh',
|
||||
height: '100%',
|
||||
width: '100%'
|
||||
});
|
||||
dialogRef.afterClosed()
|
||||
.subscribe(dataresult => {
|
||||
this.getListofEntityTATInfo();
|
||||
});
|
||||
}
|
||||
|
||||
entityTatListDetails: any = [ {
|
||||
'm_id': 1,
|
||||
'tatVal1': 3,
|
||||
'tatVal2':10,
|
||||
"tatCombinations" : [
|
||||
{
|
||||
'c_id': 1,
|
||||
'pd': {
|
||||
'id': 1,
|
||||
'name': 'PD Type 1'
|
||||
},
|
||||
'product': {
|
||||
'id': 2,
|
||||
'name': 'Product 2'
|
||||
},
|
||||
'city' : {
|
||||
'id': 3,
|
||||
'name': 'City 3'
|
||||
editTatInfoDetails(details) {
|
||||
const dialogRef = this.dialog.open(DialogEntityEditListTatComponent, {
|
||||
data: { entity_id: this.entityId, tat_details: details },
|
||||
disableClose: true,
|
||||
maxWidth: '100vw',
|
||||
maxHeight: '100vh',
|
||||
height: '100%',
|
||||
width: '100%'
|
||||
});
|
||||
dialogRef.afterClosed()
|
||||
.subscribe(dataresult => {
|
||||
this.getListofEntityTATInfo();
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
'c_id': 2,
|
||||
'pd': {
|
||||
'id': 2,
|
||||
'name': 'PD Type 2'
|
||||
},
|
||||
'product': {
|
||||
'id': 1,
|
||||
'name': 'Product 1'
|
||||
},
|
||||
'city' : {
|
||||
'id': 1,
|
||||
'name': 'City 1'
|
||||
}
|
||||
}
|
||||
]
|
||||
}]
|
||||
|
||||
}
|
||||
|
||||
@ -96,9 +94,233 @@ export class EntityEditTatComponent implements OnInit {
|
||||
// var exist = result1.filter(a => valueApi.indexOf(a) > -1);
|
||||
// console.log("exit :" + exist);
|
||||
|
||||
@Component({
|
||||
selector: 'dialog-entity-edit-list-tat',
|
||||
styles: [`
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
tr.mat-footer-row {
|
||||
font-weight: bold;
|
||||
}
|
||||
`
|
||||
],
|
||||
templateUrl: './entity-edit-list-tat.component.html'
|
||||
})
|
||||
export class DialogEntityEditListTatComponent implements OnInit {
|
||||
|
||||
|
||||
tatListEditForm: FormGroup;
|
||||
tatEditAddForm: FormGroup;
|
||||
submitted: Boolean = false;
|
||||
/**
|
||||
* Notifier service
|
||||
*/
|
||||
private notifier: NotifierService;
|
||||
masterDataCombination = [];
|
||||
|
||||
constructor(notifier: NotifierService,
|
||||
private entityService: EntityService,
|
||||
private mastersService: MastersService,
|
||||
public dialogRef: MatDialogRef<DialogEntityAddTatComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||
private _formBuilder: FormBuilder) {
|
||||
this.notifier = notifier;
|
||||
this.dataSource = this.data.tat_details.child;
|
||||
this.tatListEditForm = this._formBuilder.group({
|
||||
tat1: [this.data.tat_details.tat1, Validators.compose([Validators.required])],
|
||||
tat2: [this.data.tat_details.tat2, Validators.compose([Validators.required])],
|
||||
});
|
||||
|
||||
this.tatEditAddForm = this._formBuilder.group({
|
||||
pd_type: ['', Validators.compose([Validators.required])],
|
||||
product: ['', Validators.compose([Validators.required])],
|
||||
city: ['', Validators.compose([Validators.required])]
|
||||
})
|
||||
|
||||
this.masterDataCombination = this.dataSource.map(data => {
|
||||
return data.pd_type.id + '' + data.product.id + '' + data.city.id;
|
||||
});
|
||||
}
|
||||
|
||||
m_pdType = [];
|
||||
m_product = [];
|
||||
m_city = [];
|
||||
|
||||
// m_pdType = [{ 'id': 1, 'name': 'PD Type 1' }, { 'id': 2, 'name': 'PD Type 2' }];
|
||||
// m_product = [{ 'id': 1, 'name': 'Product 1' }, { 'id': 2, 'name': 'Product 2' }, { 'id': 3, 'name': 'Product 3' }];
|
||||
// m_city = [{ 'id': 1, 'name': 'City 1' }, { 'id': 2, 'name': 'City 2' }, { 'id': 3, 'name': 'City 3' }];
|
||||
|
||||
|
||||
ngOnInit(): void {
|
||||
this.getCityMasters();
|
||||
this.getProductMasters();
|
||||
this.getPdTypeMasters();
|
||||
}
|
||||
|
||||
|
||||
getCityMasters() {
|
||||
this.mastersService.getAllMasterData('CITY').subscribe(
|
||||
data => {
|
||||
this.m_city = data.records;
|
||||
},
|
||||
error => {
|
||||
this.notifier.notify('warning', 'No City Master Records Found.!');
|
||||
// this.errorMessage = "No Region Master Record Found.";
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
getProductMasters() {
|
||||
this.mastersService.getAllMasterData('PRODUCTS').subscribe(
|
||||
data => {
|
||||
this.m_product = data.records;
|
||||
},
|
||||
error => {
|
||||
this.notifier.notify('warning', 'No City Master Records Found.!');
|
||||
// this.errorMessage = "No Region Master Record Found.";
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
getPdTypeMasters() {
|
||||
this.mastersService.getAllMasterData('PDTYPE').subscribe(
|
||||
data => {
|
||||
this.m_pdType = data.records;
|
||||
},
|
||||
error => {
|
||||
this.notifier.notify('warning', 'No City Master Records Found.!');
|
||||
// this.errorMessage = "No Region Master Record Found.";
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
get f() { return this.tatListEditForm.controls };
|
||||
get f1() { return this.tatEditAddForm.controls };
|
||||
|
||||
onSubmit() {
|
||||
this.submitted = true;
|
||||
if (this.tatListEditForm.invalid) {
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onSubmitEditAddForm() {
|
||||
let finalArr = [];
|
||||
let data = this.tatEditAddForm.value;
|
||||
finalArr.push(data.pd_type + '' + data.product + '' + data.city);
|
||||
if (this.masterDataCombination.length > 0) {
|
||||
finalArr.map(d => {
|
||||
// alert(this.masterDataCombination.indexOf(d));
|
||||
if(this.masterDataCombination.indexOf(d) > -1){
|
||||
|
||||
finalArr.splice(this.masterDataCombination.indexOf(d), 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.selection.clear();
|
||||
let record: any = {};
|
||||
|
||||
record.tat1 = this.data.tat_details.tat1;
|
||||
record.tat2 = this.data.tat_details.tat2;
|
||||
record.entity_tat_master_id = this.data.tat_details.entity_tat_master_id;
|
||||
record.fk_entity_id = this.data.entity_id;
|
||||
record.child = finalArr;
|
||||
this.entityService.saveEntityTATInfo(record).subscribe(data=>{
|
||||
if(data.dataStatus){
|
||||
this.notifier.notify('success', 'Your Changes Updated.!');
|
||||
this.dialogRef.close();
|
||||
} else {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
|
||||
}
|
||||
}, err => {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
onNoClick(): void {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
|
||||
dataSource: Transaction[] = [];
|
||||
|
||||
/** Whether the number of selected elements matches the total number of rows. */
|
||||
isAllSelected() {
|
||||
const numSelected = this.selection.selected.length;
|
||||
const numRows = this.dataSource.length;
|
||||
return numSelected === numRows;
|
||||
}
|
||||
|
||||
/** Selects all rows if they are not all selected; otherwise clear selection. */
|
||||
masterToggle() {
|
||||
this.isAllSelected() ?
|
||||
this.selection.clear() :
|
||||
this.dataSource.forEach(row => this.selection.select(row));
|
||||
}
|
||||
|
||||
|
||||
selection = new SelectionModel<Transaction>(true, []);
|
||||
displayedColumns: string[] = ['select', 'pd', 'product', 'city'];
|
||||
|
||||
onDelete() {
|
||||
let data = this.selection.selected.map(x => x['entity_tat_child_id']);
|
||||
|
||||
let record: any = {};
|
||||
record.entity_tat_master_id = this.data.tat_details.entity_tat_master_id;
|
||||
record.fk_entity_id = this.data.entity_id;
|
||||
record.entity_tat_child_id_details = data;
|
||||
|
||||
this.entityService.deleteTATInfoDetails(record).subscribe(data=>{
|
||||
if(data.dataStatus){
|
||||
this.notifier.notify('success', 'Your Changes Updated.!');
|
||||
this.dialogRef.close();
|
||||
} else {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
|
||||
}
|
||||
} , err => {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
|
||||
})
|
||||
|
||||
// alert(JSON.stringify(record));
|
||||
|
||||
// if(data.length > 0){
|
||||
|
||||
// } else {
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
selectedDetails(e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'dialog-entity-add-tat',
|
||||
styles: [``
|
||||
styles: [`
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
tr.mat-footer-row {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.example-container {
|
||||
height: 400px;
|
||||
overflow: auto;
|
||||
}
|
||||
`
|
||||
],
|
||||
templateUrl: './entity-add-tat.component.html'
|
||||
})
|
||||
@ -123,9 +345,13 @@ export class DialogEntityAddTatComponent implements OnInit {
|
||||
|
||||
toppingList1: any[] = [{ 'id': 1, 'name': 'Extra cheese' }, { 'id': 2, 'name': 'Mushroom' }, { 'id': 3, 'name': 'Onion' }];
|
||||
|
||||
m_pdType = [{ 'id': 1, 'name': 'PD Type 1' }, { 'id': 2, 'name': 'PD Type 2' }];
|
||||
m_product = [{ 'id': 1, 'name': 'Product 1' }, { 'id': 2, 'name': 'Product 2' }, { 'id': 3, 'name': 'Product 3' }];
|
||||
m_city = [{ 'id': 1, 'name': 'City 1' }, { 'id': 2, 'name': 'City 2' }, { 'id': 3, 'name': 'City 3' }];
|
||||
m_pdType = [];
|
||||
m_product = [];
|
||||
m_city = [];
|
||||
|
||||
// m_pdType = [{ 'id': 1, 'name': 'PD Type 1' }, { 'id': 2, 'name': 'PD Type 2' }];
|
||||
// m_product = [{ 'id': 1, 'name': 'Product 1' }, { 'id': 2, 'name': 'Product 2' }, { 'id': 3, 'name': 'Product 3' }];
|
||||
// m_city = [{ 'id': 1, 'name': 'City 1' }, { 'id': 2, 'name': 'City 2' }, { 'id': 3, 'name': 'City 3' }];
|
||||
/**
|
||||
* Notifier service
|
||||
*/
|
||||
@ -148,7 +374,9 @@ export class DialogEntityAddTatComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
this.getCityMasters();
|
||||
this.getProductMasters();
|
||||
this.getPdTypeMasters();
|
||||
}
|
||||
|
||||
get f() { return this.tatForm.controls };
|
||||
@ -157,19 +385,19 @@ export class DialogEntityAddTatComponent implements OnInit {
|
||||
|
||||
selectedPD(e) {
|
||||
this.selectedArr = [...e.value];
|
||||
this.selectedItem = this.m_pdType.filter(val => this.selectedArr.indexOf(val.id) > -1)
|
||||
this.selectedItem = this.m_pdType.filter(val => this.selectedArr.indexOf(val.pd_type_id) > -1)
|
||||
}
|
||||
|
||||
selectedProductItem: any;
|
||||
selectedProduct(e) {
|
||||
this.selectedProductArr = [...e.value];
|
||||
this.selectedProductItem = this.m_product.filter(val => this.selectedProductArr.indexOf(val.id) > -1)
|
||||
this.selectedProductItem = this.m_product.filter(val => this.selectedProductArr.indexOf(val.product_id) > -1)
|
||||
}
|
||||
|
||||
selectedCityItem: any;
|
||||
selectedCity(e) {
|
||||
this.selectedCityArr = [...e.value];
|
||||
this.selectedCityItem = this.m_city.filter(val => this.selectedCityArr.indexOf(val.id) > -1)
|
||||
this.selectedCityItem = this.m_city.filter(val => this.selectedCityArr.indexOf(val.city_id) > -1)
|
||||
}
|
||||
|
||||
getEntityIdCityDetails() {
|
||||
@ -201,33 +429,83 @@ export class DialogEntityAddTatComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
getProductMasters() {
|
||||
this.mastersService.getAllMasterData('PRODUCTS').subscribe(
|
||||
data => {
|
||||
this.m_product = data.records;
|
||||
},
|
||||
error => {
|
||||
this.notifier.notify('warning', 'No City Master Records Found.!');
|
||||
// this.errorMessage = "No Region Master Record Found.";
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
getPdTypeMasters() {
|
||||
this.mastersService.getAllMasterData('PDTYPE').subscribe(
|
||||
data => {
|
||||
this.m_pdType = data.records;
|
||||
},
|
||||
error => {
|
||||
this.notifier.notify('warning', 'No City Master Records Found.!');
|
||||
// this.errorMessage = "No Region Master Record Found.";
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
resultApi = ['123', '211'];
|
||||
|
||||
getIdPdName(id) {
|
||||
let pdF = this.m_pdType.filter(a => a.id == id);
|
||||
return pdF[0].name;
|
||||
let pdF = this.m_pdType.filter(a => a.pd_type_id == id);
|
||||
let data = {
|
||||
id: id,
|
||||
name: pdF[0].type_name
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
getIdProductName(id) {
|
||||
let pdF = this.m_product.filter(a => a.id == id);
|
||||
return pdF[0].name;
|
||||
let pdF = this.m_product.filter(a => a.product_id == id);
|
||||
let data = {
|
||||
id: id,
|
||||
name: pdF[0].name
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
getIdCityName(id) {
|
||||
let pdF = this.m_city.filter(a => a.id == id);
|
||||
return pdF[0].name;
|
||||
let pdF = this.m_city.filter(a => a.city_id == id);
|
||||
let data = {
|
||||
id: id,
|
||||
name: pdF[0].name
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public existValArray: any = [];
|
||||
|
||||
// transactions : [] = new MatTableDataSource<Transaction>(this.existValArray);
|
||||
|
||||
listShow: Boolean = false;
|
||||
transactions: Transaction[] = [];
|
||||
tatValue1 = '';
|
||||
tatValue2 = '';
|
||||
onSubmit() {
|
||||
this.submitted = true;
|
||||
if (this.tatForm.invalid) {
|
||||
return
|
||||
} else {
|
||||
this.listShow = true;
|
||||
let arr1 = this.tatForm.controls['toppings1'].value;
|
||||
let arr2 = this.tatForm.controls['toppings2'].value;
|
||||
let arr3 = this.tatForm.controls['toppings3'].value
|
||||
let arr3 = this.tatForm.controls['toppings3'].value;
|
||||
|
||||
this.tatValue1 = this.tatForm.controls['toppings4'].value;
|
||||
this.tatValue2 = this.tatForm.controls['toppings5'].value;
|
||||
|
||||
let array1 = [...arr1];
|
||||
let array2 = [...arr2];
|
||||
@ -236,24 +514,102 @@ export class DialogEntityAddTatComponent implements OnInit {
|
||||
a1.concat(array2.map(w => v1 + "" + w)), []).reduce((a2, v2, i3) =>
|
||||
a2.concat(array3.map(u => v2 + "" + u)), []);
|
||||
|
||||
|
||||
let exist = this.resultApi.filter(a => result1.indexOf(a) > -1);
|
||||
if (exist) {
|
||||
// alert(result1);
|
||||
// alert(exist);
|
||||
this.existValArray = [];
|
||||
exist.forEach(a=>{
|
||||
result1.forEach(a => {
|
||||
let pdName = this.getIdPdName(a[0]);
|
||||
let productName = this.getIdProductName(a[1]);
|
||||
let cityName = this.getIdCityName(a[2]);
|
||||
this.existValArray.push(`${pdName}, ${productName}, ${cityName}`);
|
||||
let data = {
|
||||
pd_type: pdName,
|
||||
product: productName,
|
||||
city: cityName
|
||||
}
|
||||
this.existValArray.push(data);
|
||||
});
|
||||
this.transactions = this.existValArray;
|
||||
} else {
|
||||
// api add new here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onDelete() {
|
||||
this.selection.selected.map(data => {
|
||||
let inx = this.transactions.indexOf(data);
|
||||
this.transactions.splice(inx, 1);
|
||||
});
|
||||
let dataTS = JSON.stringify(this.transactions);
|
||||
this.transactions.length = 0;
|
||||
this.transactions = JSON.parse(dataTS);
|
||||
this.selection.clear();
|
||||
}
|
||||
|
||||
onDataSubmit() {
|
||||
let record: any = {};
|
||||
record.fk_entity_id = this.data.entity_id;
|
||||
record.tat1 = this.tatForm.controls['toppings4'].value;
|
||||
record.tat2 = this.tatForm.controls['toppings5'].value;
|
||||
record.child = this.transactions.map(data => {
|
||||
return `${data.pd_type.id}${data.product.id}${data.city.id}`
|
||||
});
|
||||
this.entityService.saveEntityTATInfo(record).subscribe(data => {
|
||||
if (data.dataStatus) {
|
||||
this.dialogRef.close();
|
||||
this.notifier.notify('success', 'Your Changes Updated.!');
|
||||
} else {
|
||||
this.notifier.notify('warning', 'No City Master Records Found.!');
|
||||
}
|
||||
}, err => {
|
||||
this.notifier.notify('warning', 'No City Master Records Found.!');
|
||||
})
|
||||
}
|
||||
|
||||
onNoClick(): void {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
|
||||
/** Whether the number of selected elements matches the total number of rows. */
|
||||
isAllSelected() {
|
||||
const numSelected = this.selection.selected.length;
|
||||
const numRows = this.transactions.length;
|
||||
return numSelected === numRows;
|
||||
}
|
||||
|
||||
/** Selects all rows if they are not all selected; otherwise clear selection. */
|
||||
masterToggle() {
|
||||
this.isAllSelected() ?
|
||||
this.selection.clear() :
|
||||
this.transactions.forEach(row => this.selection.select(row));
|
||||
}
|
||||
|
||||
|
||||
selection = new SelectionModel<Transaction>(true, []);
|
||||
displayedColumns: string[] = ['select', 'pd', 'product', 'city'];
|
||||
// transactions: Transaction[] = [
|
||||
// {item: { name :'Beach ball'}, cost: 4},
|
||||
// // {item: 'Towel', cost: 5},
|
||||
// // {item: 'Frisbee', cost: 2},
|
||||
// // {item: 'Sunscreen', cost: 4},
|
||||
// // {item: 'Cooler', cost: 25},
|
||||
// // {item: 'Swim suit', cost: 15},
|
||||
// ];
|
||||
}
|
||||
|
||||
|
||||
export interface Transaction {
|
||||
pd_type: {
|
||||
name: string,
|
||||
id: any
|
||||
},
|
||||
product: {
|
||||
name: string,
|
||||
id: any
|
||||
},
|
||||
city: {
|
||||
name: string,
|
||||
id: any
|
||||
}
|
||||
}
|
||||
@ -31,7 +31,7 @@ import { EntityService } from './../service/entity/entity.service';
|
||||
import { EntityEditRegionComponent } from './entity-edit/entity-edit-region/entity-edit-region.component';
|
||||
|
||||
import { EntityEditTatComponent } from './entity-edit/entity-edit-tat/entity-edit-tat.component';
|
||||
import { DialogEntityAddTatComponent } from './entity-edit/entity-edit-tat/entity-edit-tat.component';
|
||||
import { DialogEntityAddTatComponent, DialogEntityEditListTatComponent } from './entity-edit/entity-edit-tat/entity-edit-tat.component';
|
||||
|
||||
import { EntityEditPriceComponent } from './entity-edit/entity-edit-price/entity-edit-price.component';
|
||||
import { EntityEditBillingInfoComponent } from './entity-edit/entity-edit-billing-info/entity-edit-billing-info.component';
|
||||
@ -113,6 +113,7 @@ const customNotifierOptions: NotifierOptions = {
|
||||
EntityEditRegionComponent,
|
||||
EntityEditTatComponent,
|
||||
DialogEntityAddTatComponent,
|
||||
DialogEntityEditListTatComponent,
|
||||
EntityEditPriceComponent,
|
||||
EntityEditBillingInfoComponent,
|
||||
DialogAddEditBillingInfo,
|
||||
@ -123,6 +124,7 @@ const customNotifierOptions: NotifierOptions = {
|
||||
EntityEditComponent,
|
||||
DialogAddEditBillingInfo,
|
||||
DialogEntityAddTatComponent,
|
||||
DialogEntityEditListTatComponent,
|
||||
EntityAddComponent
|
||||
],
|
||||
providers : [
|
||||
|
||||
@ -186,6 +186,22 @@ export class EntityService {
|
||||
return this._http.post<any[]>(this.apiUrl + "saveLenderBranches", {'records': Records });
|
||||
}
|
||||
|
||||
saveEntityTATInfo(Records: any): Observable<any>{
|
||||
Records.fk_updatedby = this._aws.getlocale();
|
||||
Records.fk_createdby = this._aws.getlocale();
|
||||
console.log(JSON.stringify(Records));
|
||||
return this._http.post<any[]>(this.apiUrl + "saveTATInfo", {'records': Records });
|
||||
}
|
||||
|
||||
getEntityTATInfoDetails(entity_id): Observable<any>{
|
||||
return this._http.post<any[]>(this.apiUrl + "getFullTATInfo", {'records': {"fk_entity_id" : entity_id }});
|
||||
}
|
||||
|
||||
deleteTATInfoDetails(record): Observable<any>{
|
||||
record.fk_updatedby = this._aws.getlocale();
|
||||
return this._http.post<any[]>(this.apiUrl + "deleteTATCombimaion", {'records': record});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TO Handle The Error
|
||||
|
||||
Loading…
Reference in New Issue
Block a user