This commit is contained in:
venbatechnologies@gmail.com 2018-12-15 18:24:47 +05:30
commit 7df70eb364
9 changed files with 524 additions and 174 deletions

View File

@ -43,20 +43,35 @@
</div>
</mat-tab>
<mat-tab label="PD Report">
<div>
<div style="text-align: left; margin: 12px;" class="mb-1">
<button mat-raised-button color="primary" *ngIf="generateBtn" (click)="generateNewPDReport()">Generate Report</button>
<button mat-raised-button color="accent" *ngIf="reGenerateBtn" (click)="reGeneratePFReport()">Re-generate Report</button>
</div>
<div *ngIf="reGenerateBtn">
<div style="text-align: right;">
<mat-select style="width: 50%;" placeholder="Select PD Version" >
<mat-option>--</mat-option>
<mat-option *ngFor="let pd of pdReportVersionList" (click)="changeVersion(pd)" >
{{ pd.doc_name }} <span *ngIf="pd.is_latest == 1" [style.color]="'green'">( Current Version )</span>
</mat-option>
</mat-select>
</div>
<div *ngIf="reGenerateBtn">
<mat-card >
<mat-card-content>
<mat-sidenav-container class="app-inner background-none shadow-none mail-db">
<button matTooltip="Menu" matTooltipPosition="above" (click)="mailnav.toggle()" color="primary" fxHide="false" fxshow.gt-sm mat-icon-button mat-raised-button>
<mat-icon style="color: white;">short_text</mat-icon>
</button>
<mat-sidenav #mailnav [mode]="isOver() ? 'over' : 'side'" [opened]="!isOver()" class="mail-sidebar pl-xs pr-xs">
<mat-card style="text-align:center;"> <button mat-raised-button color="red" *ngIf="reGenerateBtn" (click)="reGeneratePFReport()" style="padding: 0 58px !important;">Re-generate Report</button></mat-card>
<button mat-menu-item *ngFor="let pd of pdReportVersionList" [ngClass]="{'active': selectedItem == item}" (click)="changeVersion(pd)" style="font-size: 0.9em !important;height:6% !important;line-height: normal !important;">
{{ pd.doc_name }}<span *ngIf="pd.is_latest == 1" [style.color]="'green'">( Current Version )</span><br>
<span style="color:rgba(117, 115, 115, 0.87)!important;font-size:13px !important;">{{pd.createdby}}</span><br>
<span style="color:rgba(117, 115, 115, 0.87)!important;font-size:13px !important;">{{pd.createdon}}</span>
<hr>
</button>
</mat-sidenav>
<div class="main-content" fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="100" fxFlex.lg="100" fxFlex.xl="100">
<figure>
<div *ngIf="latestPDDetails">
<div style="margin: 12px;
background: #ddd;
@ -64,16 +79,38 @@
<div style="text-align: right;" class="mb-1">
<button mat-raised-button mat-icon-button class="hover-icon " type="button" matTooltip="Edit" matTooltipPosition="above"
*ngIf="latestPDDetails.is_latest == 1" (click)="addNewQuestion()"><mat-icon>edit</mat-icon></button>
<button mat-stroked-button *ngIf="latestPDDetails.is_latest == 0" (click)="changeDocumentEdit()">Enable Editable</button>
<button mat-stroked-button *ngIf="latestPDDetails.is_latest == 0" (click)="changeDocumentEdit()">Restore</button>
</div>
<div>
<div *ngIf="reGenerateBtn">
<pdf-viewer [src]="latestPDDetails.doc_uri" [original-size]="false" [page]="1">
</pdf-viewer>
</div>
</div>
</div>
</figure>
</div>
</mat-sidenav-container>
</mat-card-content>
</mat-card>
</div>
<div *ngIf="generateBtn">
<div fxLayout="row wrap">
<div class="container" fxLayout fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="10px" fxLayoutGap.xs="0" style="padding: 10%;">
<div fxFlex="100">
<h5 style="text-align:center;color: black;"> {{message}}</h5>
<div style="text-align:center;">
<button mat-raised-button color="primary" *ngIf="generateBtn" (click)="generateNewPDReport()">Generate Report</button>
</div>
</div>
</div>
</div>
</div>
</div>
</mat-tab>
</mat-tab-group>
</mat-card-content>

View File

@ -0,0 +1,119 @@
@import "./../../../../../assets/styles/scss/components/messages";
:host {
margin-left: -5px;
margin-right: -5px;
margin-top: -5px;
display: block;
}
:host /deep/ {
mat-sidenav {
width: 267px;
}
.mat-sidenav-content {
padding: 0;
}
@media (min-width: 959px) {
.mat-sidenav-side {
background-color: transparent;
box-shadow: none!important;
}
}
}
.mat-menu-item-active {
color: red !important;
}
.mat-expansion-panel-header-description {
color: rgba(0, 0, 0, 87);
}
.mat-card-content {
background-color: white;
}
.mat-card-actions {
background-color: white;
}
.text-ellipsis {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.custm-list-item {
cursor: pointer;
}
$base-card-box-shadow:1.5px 2.6px 24px 0 rgba(0, 35, 136, 0.08) !important;
$product-bg-color-hover: rgba(103, 58, 183, 0.7);
.p-list-main {
background: white;
margin: auto;
position: relative;
overflow: hidden !important;
border-radius: 10px 10px 10px 10px;
box-shadow: $base-card-box-shadow;
transform: scale(0.95);
transition: box-shadow 0.5s, transform 0.5s;
&:hover {
transform: scale(1);
box-shadow: 5px 20px 30px rgba(0, 0, 0, 0.2);
}
.p-list {
position: relative;
.top {
height: 100%;
width: 100%;
// background: url(https://s-media-cache-ak0.pinimg.com/736x/49/80/6f/49806f3f1c7483093855ebca1b8ae2c4.jpg) no-repeat center center;
-webkit-background-size: 100%;
-moz-background-size: 100%;
-o-background-size: 100%;
background-size: 100%;
}
.bottom {
width: 200%;
height: 15%;
transition: transform 0.5s;
h1 {
margin: 0;
padding: 0;
}
p {
margin: 0;
padding: 0;
}
.left {
height: 100%;
width: 50%;
background: #f4f4f4;
position: relative;
float: left;
.details {
padding: 5px;
float: left;
// width: calc(70% - 40px);
}
}
.right {
width: 50%;
background: #A6CDDE;
color: white;
float: right;
height: 200%;
overflow: hidden;
.details {
padding: 20px;
float: right;
width: calc(70% - 40px);
}
}
}
}
}

View File

@ -32,6 +32,7 @@ export class PdReportComponent implements OnInit {
// public src;
pdReportRecords:any;
latestPDDetails: any;
message:any;
private notifier: NotifierService;
constructor(notifier: NotifierService, private fb: FormBuilder, private route: ActivatedRoute,
@ -52,8 +53,38 @@ export class PdReportComponent implements OnInit {
this.listPDComponent.showListView(false);
this.getPdReportDetails();
this.getPdReportVersionList();
// start
// end
const elemSidebar = <HTMLElement>document.querySelector('.app-inner .mail-sidebar');
const elemContent = <HTMLElement>document.querySelector('.app-inner .main-content');
if (window.matchMedia(`(min-width: 1560px)`).matches && !this.isMac()) {
// Ps.initialize(elemSidebar, { wheelSpeed: 2, suppressScrollX: true });
// Ps.initialize(elemContent, { wheelSpeed: 2, suppressScrollX: true });
}
// this.loadTemplates(this.startPD);
// this.next = 1;
// this.previous = 2;
}
isMac(): boolean {
let bool = false;
if (navigator.platform.toUpperCase().indexOf('MAC') >= 0 || navigator.platform.toUpperCase().indexOf('IPAD') >= 0) {
bool = true;
}
return bool;
}
isOver(): boolean {
return window.matchMedia(`(max-width: 1560px)`).matches;
}
reGeneratePFReport(){
let data = {
"pd_id": this.startPD,
@ -97,6 +128,7 @@ export class PdReportComponent implements OnInit {
} else {
// this.reGenerateBtn = true;
this.generateBtn = true;
this.message= data.msg;
}
}, err=> {
@ -139,6 +171,7 @@ export class PdReportComponent implements OnInit {
changeVersion(pd : any): void {
this.latestPDDetails = pd;
console.log(this.latestPDDetails);
}
changeDocumentEdit() : void{

View File

@ -25,7 +25,7 @@ import {ActivatedRoute, Router} from "@angular/router";
selector: 'app-address',
templateUrl: './address.component.html',
styleUrls: ['./address.component.scss'],
encapsulation: ViewEncapsulation.None
encapsulation: ViewEncapsulation.None
})

View File

@ -48,6 +48,9 @@ tr.mat-footer-row {
mat-form-field {
margin: 0 2%;
}
::ng-deep .cdk-global-overlay-wrapper{
justify-content: center !important;
}
$base-card-box-shadow:1.5px 2.6px 24px 0 rgba(0, 35, 136, 0.08) !important;
$product-bg-color-hover: rgba(103, 58, 183, 0.7);
.p-list-main {

View File

@ -1,7 +1,6 @@
<form [formGroup]="_neighbourhoodForm" novalidate>
<h2 mat-dialog-title class="paragraph_change">
<div fxFlex="70" align="left" style="padding: 10px !important;">
<h2 mat-dialog-title class="paragraph_change">
<div fxFlex="70" align="left">
<div fxLayout="row wrap">
<div fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="100" fxFlex.lg="100" fxFlex.xl="100">
{{pageTitle}}
@ -10,126 +9,122 @@
</div>
</div>
<div fxFlex="30" align="end" style="padding: 10px !important;">
<div fxFlex="30" align="end">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Close" matTooltipPosition="right" mat-dialog-close><mat-icon>close</mat-icon></button>
</div>
</h2>
<h6>
<div fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="100" fxFlex.lg="100" fxFlex.xl="100">
<mat-radio-group formControlName="check_type" class="example-radio-group">
<mat-radio-button class="example-radio-button" color="primary" [value]="types.id" *ngFor="let types of check_type; let t = index">{{types.type_name}}</mat-radio-button>
</mat-radio-group>
</div>
</h6>
<mat-dialog-content formArrayName="neighbourhood_list" *ngIf="_neighbourhoodForm.controls.check_type.value==0">
<mat-card>
<mat-card *ngFor="let neighbourhood of _neighbourhoodForm.controls.neighbourhood_list['controls']; let n = index;" [formGroupName]="n">
<mat-card-content>
<mat-form-field style="width: 42%">
<input matInput placeholder="Neighbour Name" formControlName="neighbourhood_name" type="text">
</mat-form-field>
<mat-form-field style="width: 40%">
<mat-select placeholder="Do You Know" formControlName="do_know">
<mat-option value="Yes">Yes</mat-option>
<mat-option value="No">No</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 42%" *ngIf="neighbourhood.controls.do_know.value=='Yes'">
<input matInput placeholder="How Long to Know the Applicant " formControlName="how_long_do_know" type="text" (keypress)="keyPress($event)">
</mat-form-field>
<mat-form-field style="width: 42%" *ngIf="neighbourhood.controls.do_know.value=='Yes'">
<mat-select placeholder="Is the Applicant Owner" formControlName="is_applicant_owner">
<mat-option value="Yes">Yes</mat-option>
<mat-option value="No">No</mat-option>
</mat-select>
</mat-form-field>
<button type="button" mat-raised-button mat-icon-button (click)="removeNeighbourhood(n)"
matTooltip="Remove neighbourhood" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" *ngIf="n!=0">
<mat-icon>delete</mat-icon></button>
</mat-card-content>
</mat-card>
<mat-dialog-actions>
<div fxFlex="100" align="end">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Add More" matTooltipPosition="above" (click)="_neighbourhoodForm.controls.check_type.value==0 ? addNeighbourhood() : addReferencecheck()" color="primary"><mat-icon>add</mat-icon></button>
</div>
</mat-dialog-actions>
</mat-card>
</mat-dialog-content>
<mat-dialog-content formArrayName="referencecheck_list" *ngIf="_neighbourhoodForm.controls.check_type.value==1">
<mat-card>
<mat-card *ngFor="let reference of _neighbourhoodForm.controls.referencecheck_list['controls']; let r = index;" [formGroupName]="r">
<mat-dialog-content>
<mat-card>
<mat-card-header>
<div fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="100" fxFlex.lg="100" fxFlex.xl="100">
<mat-radio-group formControlName="check_type" class="example-radio-group">
<mat-radio-button class="example-radio-button" color="primary" [value]="types.id" *ngFor="let types of check_type; let t = index">{{types.type_name}}</mat-radio-button>
</mat-radio-group>
</div>
</mat-card-header>
<mat-card-content formArrayName="neighbourhood_list" *ngIf="_neighbourhoodForm.controls.check_type.value==0">
<mat-card *ngFor="let neighbourhood of _neighbourhoodForm.controls.neighbourhood_list['controls']; let n = index;" [formGroupName]="n">
<mat-card-content>
<mat-form-field style="width: 28%">
<input matInput placeholder="Name" formControlName="reference_name" type="text">
</mat-form-field>
<mat-form-field style="width: 28%">
<input matInput placeholder="Mobile Number" formControlName="mobile" type="text" (keypress)="keyPress($event)">
<mat-error *ngIf="reference['controls'].mobile.hasError('maxlength') || reference['controls'].mobile.hasError('minlength')">Enter Valid Mobile Number. </mat-error>
</mat-form-field>
<mat-form-field style="width: 28%">
<input matInput placeholder="Landline Number" formControlName="landline" type="text" (keypress)="keyPress($event)">
<mat-error *ngIf="reference['controls'].landline.hasError('maxlength') || reference['controls'].landline.hasError('minlength')">Enter Valid Landline Number. </mat-error>
</mat-form-field>
<mat-form-field style="width: 28%">
<textarea matInput placeholder="Location" formControlName="location"></textarea>
</mat-form-field>
<mat-form-field style="width: 28%">
<mat-form-field style="width: 42%">
<input matInput placeholder="Neighbour Name" formControlName="neighbourhood_name" type="text">
</mat-form-field>
<mat-form-field style="width: 40%">
<mat-select placeholder="Do You Know" formControlName="do_know">
<mat-option value="Yes">Yes</mat-option>
<mat-option value="No">No</mat-option>
</mat-select>
</mat-form-field>
<mat-select placeholder="Relation With Business" formControlName="relationship_with">
<mat-option>Select</mat-option>
<mat-option *ngFor="let relationship of busineesRelationshipList" [value]="relationship.relation_with_business_id">
{{relationship.relation_with_business_name | titlecase}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 28%" *ngIf="reference.controls.relationship_with.value==5">
<input matInput placeholder="Others" formControlName="others" type="text">
</mat-form-field>
<p #period_paragraph>Period of Relationship</p>
<mat-form-field style="width: 12%">
<input matInput placeholder="Year" formControlName="year_relation_applicant" type="text" (keypress)="keyPress($event)">
<mat-form-field style="width: 42%" *ngIf="neighbourhood.controls.do_know.value=='Yes'">
<input matInput placeholder="How Long to Know the Applicant " formControlName="how_long_do_know" type="text" (keypress)="keyPress($event)">
</mat-form-field>
<mat-form-field style="width: 12%">
<input matInput placeholder="Month" formControlName="months_relation_applicant" type="text" (keypress)="keyPress($event)">
<mat-form-field style="width: 42%" *ngIf="neighbourhood.controls.do_know.value=='Yes'">
<mat-select placeholder="Is the Applicant Owner" formControlName="is_applicant_owner">
<mat-option value="Yes">Yes</mat-option>
<mat-option value="No">No</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 28%">
<input matInput [placeholder]="reference.controls.relationship_with.value ==4 ? 'Rent Amount' : 'Volume of Business'" formControlName="business_volume_amount" type="text" (keypress)="keyPress($event)">
</mat-form-field>
<mat-form-field style="width: 22%">
<mat-select placeholder="Unit" formControlName="business_volume_unit">
<mat-option>Select</mat-option>
<mat-option *ngFor="let volume of volumeunitList" [value]="volume.frequency_id">
{{volume.name | titlecase}}
</mat-option>
</mat-select>
</mat-form-field>
<button type="button" mat-raised-button mat-icon-button (click)="removeReferencecheck(r)"
matTooltip="Remove Reference Check" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" *ngIf="r!=0">
<button type="button" mat-raised-button mat-icon-button (click)="removeNeighbourhood(n)"
matTooltip="Remove neighbourhood" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" *ngIf="n!=0">
<mat-icon>delete</mat-icon></button>
</mat-card-content>
</mat-card>
<mat-dialog-actions>
<div fxFlex="100" align="end">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Add More" matTooltipPosition="above" (click)="_neighbourhoodForm.controls.check_type.value==0 ? addNeighbourhood() : addReferencecheck()" color="primary"><mat-icon>add</mat-icon></button>
</div>
</mat-dialog-actions>
</mat-card>
</mat-card-content>
<mat-card-content formArrayName="referencecheck_list" *ngIf="_neighbourhoodForm.controls.check_type.value==1">
<mat-card *ngFor="let reference of _neighbourhoodForm.controls.referencecheck_list['controls']; let r = index;" [formGroupName]="r">
<mat-card-content>
<mat-form-field style="width: 28%">
<input matInput placeholder="Name" formControlName="reference_name" type="text">
</mat-form-field>
<mat-form-field style="width: 28%">
<input matInput placeholder="Mobile Number" formControlName="mobile" type="text" (keypress)="keyPress($event)">
<mat-error *ngIf="reference['controls'].mobile.hasError('maxlength') || reference['controls'].mobile.hasError('minlength')">Enter Valid Mobile Number. </mat-error>
</mat-form-field>
<mat-form-field style="width: 28%">
<input matInput placeholder="Landline Number" formControlName="landline" type="text" (keypress)="keyPress($event)">
<mat-error *ngIf="reference['controls'].landline.hasError('maxlength') || reference['controls'].landline.hasError('minlength')">Enter Valid Landline Number. </mat-error>
</mat-form-field>
<mat-form-field style="width: 28%">
<textarea matInput placeholder="Location" formControlName="location"></textarea>
</mat-form-field>
<mat-form-field style="width: 28%">
</mat-dialog-content>
<mat-dialog-actions>
<div fxFlex="60" class="pb-0 text-sm-left" align="left">
<mat-form-field appearance="outline" style="width: 100%">
<mat-label>Remarks</mat-label>
<textarea matInput placeholder="Remarks" formControlName="neighbour_reference_remark" required></textarea>
</mat-form-field>
<mat-select placeholder="Relation With Business" formControlName="relationship_with">
<mat-option>Select</mat-option>
<mat-option *ngFor="let relationship of busineesRelationshipList" [value]="relationship.relation_with_business_id">
{{relationship.relation_with_business_name | titlecase}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 28%" *ngIf="reference.controls.relationship_with.value==5">
<input matInput placeholder="Others" formControlName="others" type="text">
</mat-form-field>
<p #period_paragraph>Period of Relationship</p>
<mat-form-field style="width: 12%">
<input matInput placeholder="Year" formControlName="year_relation_applicant" type="text" (keypress)="keyPress($event)">
</mat-form-field>
<mat-form-field style="width: 12%">
<input matInput placeholder="Month" formControlName="months_relation_applicant" type="text" (keypress)="keyPress($event)">
</mat-form-field>
<mat-form-field style="width: 28%">
<input matInput [placeholder]="reference.controls.relationship_with.value ==4 ? 'Rent Amount' : 'Volume of Business'" formControlName="business_volume_amount" type="text" (keypress)="keyPress($event)">
</mat-form-field>
<mat-form-field style="width: 22%">
<mat-select placeholder="Unit" formControlName="business_volume_unit">
<mat-option>Select</mat-option>
<mat-option *ngFor="let volume of volumeunitList" [value]="volume.frequency_id">
{{volume.name | titlecase}}
</mat-option>
</mat-select>
</mat-form-field>
<button type="button" mat-raised-button mat-icon-button (click)="removeReferencecheck(r)"
matTooltip="Remove Reference Check" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" *ngIf="r!=0">
<mat-icon>delete</mat-icon></button>
</mat-card-content>
</mat-card>
</mat-card-content>
<mat-card-actions align="end">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Add More" matTooltipPosition="above" (click)="_neighbourhoodForm.controls.check_type.value==0 ? addNeighbourhood() : addReferencecheck()" color="primary"><mat-icon>add</mat-icon></button>
</mat-card-actions>
</mat-card>
</mat-dialog-content>
<mat-dialog-actions>
<div fxFlex="60" class="pb-0 text-sm-left" align="left">
<mat-form-field appearance="outline" style="width: 100%">
<mat-label>Remarks</mat-label>
<textarea matInput placeholder="Remarks" formControlName="neighbour_reference_remark" required></textarea>
</mat-form-field>
</div>
<div fxFlex="40" align="end">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Save" matTooltipPosition="above" (click)="saveNeighbourhood(_neighbourhoodForm.value)"><mat-icon>save</mat-icon></button>
</div>
<div fxFlex="40" align="end">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Save" matTooltipPosition="above" (click)="saveNeighbourhood(_neighbourhoodForm.value)"><mat-icon>save</mat-icon></button>
</div>
</mat-dialog-actions>
<notifier-container></notifier-container>
</mat-dialog-actions>
<notifier-container></notifier-container>

View File

@ -1,27 +1,73 @@
<form class="example-form">
<mat-form-field class="example-full-width">
<input matInput placeholder="Add Branch" name="first" [(ngModel)]="newElement.name">
</mat-form-field> <span *ngIf="newElement.name"><mat-icon (click)="addItem()">check</mat-icon></span>
</form>
<div *ngIf="listOfBranch.length > 0">
<mat-list role="list" class="inlist">
<ng-container *ngFor="let branch of listOfBranch; let i = index;">
<mat-list-item role="listitem" *ngIf="branch.isactive == 1" class="list-item" [ngStyle]="{ 'border-color': i === currentElement ? '#f44336' : 'gray'}">
<label style="width: 80%" [hidden]="currentElement === i">{{branch.branch_name}}</label>
<input *ngIf="currentElement === i" matInput placeholder="Add Branch" [(ngModel)]="branch.branch_name">
<span (click)="editItem(i)" [hidden]="currentElement === i"><mat-icon>edit</mat-icon></span>
<span (click)="editItem(-1)" *ngIf="currentElement === i"><mat-icon>check</mat-icon></span>
<span (click)="deleteItem(branch, i)"><mat-icon>delete</mat-icon></span>
</mat-list-item>
</ng-container>
</mat-list>
<!--<div *ngIf="listofCity.length > 0">
<mat-card *ngFor="let city of listofCity; let i = index;">
<h4>{{city.name}}</h4>
<div *ngIf="city.branch_details.length > 0">
<form class="example-form">
<mat-form-field class="example-full-width">
<input matInput placeholder="Add Branch" name="first" [(ngModel)]="newElement[city.name]">
</mat-form-field> <span *ngIf="newElement[city.name]"><mat-icon (click)="addItem(city.name)">check</mat-icon></span>
</form>
<mat-list role="list" class="inlist">
<ng-container *ngFor="let branch of city.branch_details; let i = index;">
<mat-list-item role="listitem" *ngIf="branch.isactive == 1" class="list-item" [ngStyle]="{ 'border-color': i === currentElement ? '#f44336' : 'gray'}">
<label style="width: 80%" [hidden]="currentElement === i">{{branch.branch_name}}</label>
<input *ngIf="currentElement === i" matInput placeholder="Add Branch" [(ngModel)]="branch.branch_name">
<span (click)="editItem(i)" [hidden]="currentElement === i"><mat-icon>edit</mat-icon></span>
<span (click)="editItem(-1)" *ngIf="currentElement === i"><mat-icon>check</mat-icon></span>
<span (click)="deleteItem(branch, i)"><mat-icon>delete</mat-icon></span>
</mat-list-item>
</ng-container>
</mat-list>
</div>
<div *ngIf="city.branch_details.length == 0">
<h2 style="color: #ddd; text-align: center;">No Records Found...</h2>
</div>
</mat-card>
<pre>{{ newElement | json}}</pre>
<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" (click)="reset();false"><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="button"
(click)="saveBranch()"><mat-icon>save</mat-icon></button>
</div>
</div>
<div *ngIf="listOfBranch.length == 0">
<div *ngIf="listofCity.length == 0">
<h2 style="color: #ddd; text-align: center;">No Records Found...</h2>
</div>
</div>-->
<form [formGroup]="_addEntityBranchFrom" (submit)="onSubmit()">
<div formArrayName="branch_details" class="example-full-width">
<mat-card *ngFor="let region of _addEntityBranchFrom.controls.branch_details['controls']; let i=index">
<mat-card-content *ngIf="region.get('isactive').value == 1">
<div [formGroupName]="i">
<div fxLayout="row wrap" fxLayout.xs="column" fxLayoutGap="2%" fxLayoutAlign="center center">
<mat-form-field fxFlex="30%">
<input matInput placeholder="Branch Name" name="first" formControlName="branch_name">
<mat-error *ngIf="submitted && region['controls'].branch_name.hasError('required')" class="mat-text-warn">Branch Name Required.!</mat-error>
</mat-form-field>
<mat-form-field fxFlex="30%">
<mat-select placeholder="City *" formControlName="fk_city_id">
<mat-option *ngFor="let city of m_city" [value]="city.fk_city_id">{{ city.name }}</mat-option>
</mat-select>
<mat-error *ngIf="submitted && region['controls'].fk_city_id.hasError('required')" class="mat-text-warn">City Required.!</mat-error>
</mat-form-field>
<div fxFlex="30%" style="text-align:center;">
<!--<mat-checkbox *ngIf="region.get('entity_lender_branch_id').value != null" formControlName="isactive" [ngModel]="region.get('isactive').value == 1 ? true : region.get('isactive').value == 0 ? false : null"
(ngModelChange)="region.get('isactive').value = $event ? 1 : 0"></mat-checkbox>
<span *ngIf="_addEntityBranchFrom.controls.branch_details.controls.length > 1" (click)="removeLanguage(i)">-->
<button (click)="deleteEntityBranch(i, $event); false" mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Delete" matTooltipPosition="above"><mat-icon>delete</mat-icon></button>
<!--</span>-->
</div>
</div>
</div>
</mat-card-content>
</mat-card>
</div>
<div class="row" style="text-align:right;">
<button mat-raised-button mat-icon-button class="mr-1 mb-1" color="primary" matTooltip="Add More Region Information" matTooltipPosition="above" (click)="addRegionFormData(null, $event); false"><mat-icon>add</mat-icon></button>
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset" matTooltipPosition="above" (click)="reset();false"><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="button" (click)="saveBranch(); false"><mat-icon>save</mat-icon></button>
</div>
</form>

View File

@ -18,9 +18,15 @@ import { EntityService } from './../../../service/entity/entity.service';
export class EntityBranchAddComponent implements OnInit {
@Input() public entityId: number;
public newElement = { name: '' };
public newElement: any= {};
public listofCity = [];
public listOfBranch = [];
public m_city: any = [];
public _addEntityBranchFrom: FormGroup;
public submitted = false;
/**
* Notifier service
*/
@ -32,18 +38,89 @@ export class EntityBranchAddComponent implements OnInit {
private mastersService: MastersService,
private _formBuilder: FormBuilder) {
this.notifier = notifier;
this._addEntityBranchFrom = this._formBuilder.group({
branch_details: this._formBuilder.array([
// this.addRegionFormData(null, null),
])
})
}
ngOnInit() {
this.entityService.getEntityBranchList(this.entityId).subscribe(data => {
if (data.dataStatus) {
this.listOfBranch = data.records;
this.listofCity = data.records;
this.m_city = data.records.city_master;
// this.listOfBranch = data.records;
this.setFormDatas(data.records.branch_details);
}
}, err => {
})
}
setFormDatas(record) {
if (record.length > 0) {
for (let val of record) {
let vals = {
entity_lender_branch_id: val.entity_lender_branch_id,
branch_name: val.branch_name,
fk_entity_id: val.fk_entity_id,
fk_region_id: val.fk_region_id,
fk_city_id: val.fk_city_id,
fk_updatedby: val.fk_updatedby,
fk_createdby: val.fk_createdby,
isactive: val.isactive,
};
this.addRegionFormData(vals, null);
}
}
}
// convenience getter for easy access to form fields
get f() { return this._addEntityBranchFrom.controls; }
// Dynamic Form field creation Functionality : START ===>
initRegionFormLoad(data) {
return this._formBuilder.group({
entity_lender_branch_id: [data.entity_lender_branch_id],
branch_name: [data.branch_name, Validators.compose([Validators.required])],
fk_city_id: [data.fk_city_id, Validators.compose([Validators.required])],
fk_entity_id: [data.fk_entity_id],
fk_updatedby: [data.fk_updatedby],
fk_createdby: [data.fk_createdby],
isactive: [data.isactive],
});
}
addRegionFormData(data, e) {
if (data == null) {
let newDate = {
entity_lender_branch_id: null,
branch_name:null,
fk_entity_id: this.entityId,
fk_createdby: null,
fk_updatedby: null,
fk_city_id: null,
isactive: 1,
}
const control = <FormArray>this._addEntityBranchFrom.controls['branch_details'];
control.push(this.initRegionFormLoad(newDate));
} else {
const control = <FormArray>this._addEntityBranchFrom.controls['branch_details'];
control.push(this.initRegionFormLoad(data));
}
}
deleteEntityBranch(inx, e) {
e.stopPropagation();
const control = <FormArray>this._addEntityBranchFrom.controls['branch_details'];
// let dataS = control.controls[inx].value;
if(control.controls[inx].value['entity_lender_branch_id'] !== null){
console.log( this._addEntityBranchFrom.controls['branch_details']['controls'][inx].controls.isactive);
this._addEntityBranchFrom.controls['branch_details']['controls'][inx].controls.isactive.setValue("0");
console.log( this._addEntityBranchFrom.controls['branch_details']['controls'][inx].controls.isactive.value);
} else {
control.removeAt(inx);
}
}
// public listOfBranch = [
// {
@ -72,17 +149,17 @@ export class EntityBranchAddComponent implements OnInit {
// }
// ];
addItem(): void {
let data = {
"entity_lender_branch_id": null,
"branch_name": this.newElement.name,
"isactive": "1",
"fk_createdby": null,
"fk_updatedby": null,
"fk_entity_id": this.entityId.toString()
}
this.listOfBranch.push(data);
this.newElement.name = '';
addItem(prop): void {
// let data = {
// "entity_lender_branch_id": null,
// "branch_name": this.newElement.name,
// "isactive": "1",
// "fk_createdby": null,
// "fk_updatedby": null,
// "fk_entity_id": this.entityId.toString()
// }
// this.listOfBranch.push(data);
// this.newElement.name = '';
}
public currentElement = -1;
@ -98,8 +175,48 @@ export class EntityBranchAddComponent implements OnInit {
}
}
/** To Save/Edited Popup Data */
onSubmit() {
alert();
this.submitted = true;
// stop here if form is invalid
if (this._addEntityBranchFrom.invalid) {
// this.errorMessage = "Please Fill All Mandate Fields.";
return;
} else {
var formValues = this._addEntityBranchFrom.value;
//To Remove The "Null" With Key also
Object.keys(formValues).forEach((key) => (formValues[key] == null) && delete formValues[key]);
alert(JSON.stringify(formValues.branch_details));
// this.entityService.updateEntityIdRegionInfoDetails(formValues.region_lender).subscribe(
// dataresult => {
// if (dataresult.status == 200) {
// console.log(dataresult);
// this.notifier.notify('success', 'Your Changes Updated.!');
// const arr = <FormArray>this._editEntityRegionFrom.controls.region_lender;
// arr.controls.splice(0);
// // this.getEntityIDRegionInfoDetails();
// }
// else {
// this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
// // this.errorMessage = "Something Wents Wrong Try Again.!";
// }
// }, error => {
// this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
// // this.errorMessage = "Some Thing Wents Wrong Try Again.!";
// });
}
}
saveBranch(): void {
this.entityService.updateEntityIdBranchInfoDetails(this.listOfBranch).subscribe(data => {
// alert();
var formValues = this._addEntityBranchFrom.value;
//To Remove The "Null" With Key also
Object.keys(formValues).forEach((key) => (formValues[key] == null) && delete formValues[key]);
// alert(JSON.stringify(formValues.branch_details));
this.entityService.updateEntityIdBranchInfoDetails(formValues.branch_details).subscribe(data => {
if (data.dataStatus) {
this.notifier.notify('success', 'Your Changes Updated.!');
} else {

View File

@ -233,12 +233,6 @@
<app-entity-edit-vendor-city-info [entityId]="entity_id">
</app-entity-edit-vendor-city-info>
</ng-template>
</mat-tab>
<mat-tab label="TAT Information">
<ng-template matTabContent>
<app-entity-edit-tat [entityId]="entity_id">
</app-entity-edit-tat>
</ng-template>
</mat-tab>
<mat-tab *ngIf="localEntityType == 2" label="Branch">
<ng-template matTabContent>
@ -246,6 +240,12 @@
</app-entity-branch-add>
</ng-template>
</mat-tab>
<mat-tab label="TAT Information">
<ng-template matTabContent>
<app-entity-edit-tat [entityId]="entity_id">
</app-entity-edit-tat>
</ng-template>
</mat-tab>
<!--<mat-tab label="Category">
<ng-template matTabContent>
<app-template-edit-category [questionId]="question_id">