company detail changes :ps

This commit is contained in:
venbatechnologies@gmail.com 2018-10-13 18:01:11 +05:30
parent 1fa575187a
commit e18cd082fb
17 changed files with 341 additions and 69 deletions

View File

@ -1,13 +0,0 @@
import { CompanyDetailsModule } from './company-details.module';
describe('CompanyDetailsModule', () => {
let companyDetailsModule: CompanyDetailsModule;
beforeEach(() => {
companyDetailsModule = new CompanyDetailsModule();
});
it('should create an instance', () => {
expect(companyDetailsModule).toBeTruthy();
});
});

View File

@ -1,10 +0,0 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
CommonModule
],
declarations: []
})
export class CompanyDetailsModule { }

View File

@ -1,12 +0,0 @@
import { Routes } from '@angular/router';
//import { MastersComponent } from './masters.component';
export const CompanyDetailsRoutes: Routes = [
{
//path: '',
//component: PdTeamListComponent
//component: IndustryMasterListComponent
}];

View File

@ -0,0 +1,81 @@
<mat-card-content>
<h2> Company &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</h2>
<form [formGroup]="_companyForm" (submit)="onSubmit()">
<div class="form-group">
<div class="ml-xs mr-xs">
<mat-form-field style="width: 100%">
<!-- <input matInput type="text" placeholder="Name" required [formControl]="_companyForm.controls['name']"> -->
<input matInput type="text" placeholder="Name" required formControlName="name">
<!-- <mat-error *ngIf="!_companyForm.controls['name'].valid && _companyForm.controls['name'].touched" class="mat-text-warn">You must include a Name.</mat-error> -->
</mat-form-field>
</div>
<div class="ml-xs mr-xs">
<mat-form-field style="width: 100%">
<input matInput type="text" placeholder="Addressline1" required formControlName="addressline1">
<!-- <mat-error *ngIf="!_companyForm.controls['addressline1'].valid && _companyForm.controls['addressline1'].touched" class="mat-text-warn">You must include a addressline1.</mat-error> -->
</mat-form-field>
</div>
<div class="ml-xs mr-xs">
<mat-form-field style="width: 100%">
<input matInput type="text" placeholder="Addressline2" formControlName="addressline2">
<!-- <mat-error *ngIf="!_companyForm.controls['addressline2'].valid && _companyForm.controls['addressline2'].touched" class="mat-text-warn">You must include a Name.</mat-error> -->
</mat-form-field>
</div>
<div class="ml-xs mr-xs">
<mat-form-field style="width: 100%">
<input matInput type="text" placeholder="Addressline3" formControlName="addressline3">
<!-- <mat-error *ngIf="!_companyForm.controls['addressline3'].valid && _companyForm.controls['addressline3'].touched" class="mat-text-warn">You must include a Name.</mat-error> -->
</mat-form-field>
</div>
<div class="ml-xs mr-xs">
<mat-form-field style="width: 100%">
<mat-select placeholder="City" required formControlName="city" (selectionChange)="getRelevantState($event)">
<mat-option *ngFor="let cd of citydatas" [value]="cd.city_id">{{ cd.name }}</mat-option>
</mat-select>
<!-- <mat-error *ngIf="!_companyForm.controls['city'].valid && _companyForm.controls['city'].touched" class="mat-text-warn">You must include a City.</mat-error> -->
</mat-form-field>
<!-- <small *ngIf="!_branchForm.controls['fk_city_id'].valid && _branchForm.controls['fk_city_id'].touched" class="mat-text-warn">You must Pickup City Name.</small> -->
</div>
<div class="ml-xs mr-xs">
<mat-form-field style="width: 100%">
<mat-select placeholder="State" formControlName="state" [disabled]="true">
<mat-option *ngFor="let sd of stateDatas" [value]="sd.state_id">{{ sd.name }}</mat-option>
</mat-select>
<!-- <mat-error *ngIf="!_companyForm.controls['state'].valid && _companyForm.controls['state'].touched" class="mat-text-warn">You must Pickup a State.</mat-error> -->
</mat-form-field>
</div>
<div class="ml-xs mr-xs">
<mat-form-field style="width: 100%">
<input matInput type="text" placeholder="Pin code" required formControlName="pincode">
<mat-hint>pincode should be in 6 digit format</mat-hint>
<!-- <mat-error *ngIf="_companyForm.controls['pincode'].hasError('required') && _companyForm.controls['pincode'].touched" class="mat-text-warn">You must include phone number.</mat-error> -->
<!-- <mat-error *ngIf="!_companyForm.controls['pincode'].valid && _companyForm.controls['pincode'].touched" class="mat-text-warn">You must include a pincode number.</mat-error> -->
<!-- <mat-error *ngIf="_companyForm.controls['pincode'].hasError('minlength') && _companyForm.controls['pincode'].touched" class="mat-text-warn">Your pincode must be at least 5 characters long.</mat-error>
<mat-error *ngIf="_companyForm.controls['pincode'].hasError('maxlength') && _companyForm.controls['pincode'].touched" class="mat-text-warn">Your pincode name cannot exceed 6 characters.</mat-error> -->
</mat-form-field>
</div>
<br>
<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="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" [disabled]="!_companyForm.valid"><mat-icon>save</mat-icon></button>
</div>
</div>
</form>
</mat-card-content>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CompanyComponent } from './company.component';
describe('CompanyComponent', () => {
let component: CompanyComponent;
let fixture: ComponentFixture<CompanyComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CompanyComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CompanyComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,180 @@
import { Component,
OnInit,
Inject } from '@angular/core';
import { FormBuilder,
FormGroup,
Validators,
FormControl } from '@angular/forms';
/** Service */
import { MastersService } from '../../../service/masters/masters.service';
@Component({
selector: 'app-company',
templateUrl: './company.component.html',
styleUrls: ['./company.component.scss']
})
export class CompanyComponent implements OnInit {
public _companyForm: FormGroup;
public companyData: any = [];
stateDatas: any[];
citydatas: any[];
errorMessage:string;
constructor(private _formBuilder: FormBuilder,
private _mastersService: MastersService) { }
FetchFormValue() {
this._mastersService.getAllCompany().subscribe(
dataresult => {
if(dataresult.dataStatus == true){
this.companyData = dataresult.records;
this._companyForm.controls['company_id'].setValue(this.companyData[0].company_id);
this._companyForm.controls['name'].setValue(this.companyData[0].name);
this._companyForm.controls['addressline1'].setValue(this.companyData[0].addressline1);
this._companyForm.controls['addressline2'].setValue(this.companyData[0].addressline2);
this._companyForm.controls['addressline3'].setValue(this.companyData[0].addressline3);
this._companyForm.controls['city'].setValue(this.companyData[0].city);
this._companyForm.controls['state'].setValue(this.companyData[0].state);
this._companyForm.controls['pincode'].setValue(this.companyData[0].pincode);
}
}
)
}
ngOnInit() {
this.CompanyFormData();
this.FetchFormValue();
// this._mastersService.getAllCompany().subscribe(
// dataresult => {
// if(dataresult.dataStatus == true){
// this.companyData = dataresult.records;
// this._companyForm.controls['company_id'].setValue(this.companyData[0].company_id);
// this._companyForm.controls['name'].setValue(this.companyData[0].name);
// this._companyForm.controls['addressline1'].setValue(this.companyData[0].addressline1);
// this._companyForm.controls['addressline2'].setValue(this.companyData[0].addressline2);
// this._companyForm.controls['addressline3'].setValue(this.companyData[0].addressline3);
// this._companyForm.controls['city'].setValue(this.companyData[0].city);
// this._companyForm.controls['state'].setValue(this.companyData[0].state);
// this._companyForm.controls['pincode'].setValue(this.companyData[0].pincode);
// }
// }
// )
this._mastersService.getAllMasterData('STATE')
.subscribe(
data => {
if (data.dataStatus == true){
this.stateDatas = data.records;
this.stateDatas = this.stateDatas.filter(dataresult=>dataresult.isactive == 1 );
}
}, error => this.errorMessage = <any> error);
this._mastersService.getAllMasterData('CITY')
.subscribe(
data => {
if (data.dataStatus == true){
this.citydatas = data.records;
this.citydatas = this.citydatas.filter(dataresult=>dataresult.isactive == 1 );
//this._companyForm.controls['state'].setValue(this.companyData[0].state);
}
}, error => this.errorMessage = <any> error);
}
getRelevantState(event){
// console.log(event);
// console.log('cityid',event.value);
// console.log('statedata',this.stateDatas);
//let cityid = event.value;
let alldata = this.citydatas.filter(data => data.city_id == event.value);
// console.log('to getrelated id datas',alldata);
// console.log('get correct', alldata[0].name);
this._companyForm.controls['state'].setValue(alldata[0].fk_state_id);
//event.source.disabled = true;
}
/** For CompanyFormData */
CompanyFormData() {
this._companyForm = this._formBuilder.group({
company_id: [null],
name: [null, Validators.compose([Validators.required])],
addressline1: [null, Validators.compose([Validators.required])],
addressline2: [null],
addressline3: [null],
city: [null, Validators.compose([Validators.required])],
state: [null,{disabled: true}],
pincode: [null, Validators.compose([Validators.required, Validators.minLength(5), Validators.maxLength(6)])],
});
}
/** To Save/Edited Popup Data */
onSubmit() {
var CompanyFormValue = this._companyForm.value;
if(isNaN(this._companyForm['company_id']))
{
Object.keys(CompanyFormValue).forEach((key) => ( CompanyFormValue[key] == null) && delete CompanyFormValue[key]);
//After Saving the Company data then popup close
this._mastersService.addCompanyDetails(CompanyFormValue).subscribe(
dataresult=>{
if (dataresult.dataStatus == true){
alert("Data Saved Successfully");
}
else{
alert("SomeThing Wents Wrong Try Again !");
}
});
} else {
this._mastersService.editMasterDetails(CompanyFormValue,'COMPANY').subscribe(
dataresult=>{
if (dataresult.dataStatus == true){
alert("Data Edited Successfully");
}
else{
alert("SomeThing Wents Wrong Try Again !");
}
}
);
}
}
/** To Reset Popup Data For Edit*/
onResetForEdit(){
//this.CompanyFormData();
this.FetchFormValue();
}
isEmptyObject(obj) {
return (obj && (Object.keys(obj).length === 0));
}
}

View File

@ -7,7 +7,10 @@
<br>
<mat-form-field>
<mat-select color="accent" placeholder="Select" #singleSelect required [formControl]="masterCtrl">
<ngx-mat-select-search [formControl]="masterFilterCtrl" ></ngx-mat-select-search>
<ngx-mat-select-search [formControl]="masterFilterCtrl"
[placeholderLabel]="'Find Masters...'"
[noEntriesFoundLabel]="'no matching found'">
</ngx-mat-select-search>
<mat-option *ngFor="let master of filteredMasters | async" [value]="master.id">
{{master.name}}
</mat-option>
@ -70,9 +73,10 @@
<div *ngIf="masterCtrl.value =='master-18'">
<app-lender-hierarchy-list></app-lender-hierarchy-list>
</div>
<!-- <div *ngIf="masterCtrl.value =='master-19'">
<app-company-list></app-company-list>
</div> -->
<div *ngIf="masterCtrl.value =='master-19'">
<!-- <app-company-list></app-company-list> -->
<app-company></app-company>
</div>
<div *ngIf="masterCtrl.value =='master-20'">
<app-question-category-list></app-question-category-list>
</div>

View File

@ -3,7 +3,7 @@
//import { startWith } from 'rxjs/operators';
import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild, Input } from '@angular/core';
import { FormControl, FormGroup, FormBuilder } from '@angular/forms';
import { ReplaySubject } from 'rxjs';
import { MatSelect } from '@angular/material';
@ -118,7 +118,7 @@ export class MastersComponent implements OnInit {
{id: 'master-16',name: 'Customer Segment'},
{id: 'master-17',name: 'Designation'},
{id: 'master-18',name: 'Lender Hierarchy'},
// {id: 'master-19',name: 'Company Details'},
{id: 'master-19',name: 'Company Details'},
{id: 'master-20',name: 'Question Category'},
{id: 'master-21',name: 'PD Type'},
{id: 'master-22',name: 'Approach to PD location'},
@ -126,16 +126,14 @@ export class MastersComponent implements OnInit {
{id: 'master-24',name: 'PD Notification'},
// {id: 'master-25',name: 'PD Office Lender'},
// {id: 'master-25',name: 'PD Team'},
];
/** list of masters filtered by search keyword */
public filteredMasters: ReplaySubject<Master[]> = new ReplaySubject<Master[]>(1);
@ViewChild('singleSelect') singleSelect: MatSelect;
/** Subject that emits when the component has been destroyed. */
private _onDestroy = new Subject<void>();

View File

@ -82,6 +82,7 @@ import { CityDialogComponent } from './component/city/city-dialog/city-dialog.co
import { RegionsDialogComponent } from './component/regions/regions-dialog/regions-dialog.component';
import { QuestionCategoryDialogComponent } from './component/question-category/question-category-dialog/question-category-dialog.component';
import { PdNotificationListComponent } from './component/pd-notification/pd-notification-list.component';
import { CompanyComponent } from './component/company/company.component';
//import { PdTeamListComponent } from './component/pd-team/pd-team-list/pd-team-list.component';
@ -206,6 +207,7 @@ const customNotifierOptions: NotifierOptions = {
CustomerSegmentDialogComponent,
StatesDialogComponent,
CompanyDialogComponent,
CompanyComponent,
CityDialogComponent,
RegionsDialogComponent,
QuestionCategoryDialogComponent,

View File

@ -28,7 +28,7 @@
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<mat-select placeholder="City" required formControlName="fk_city" multiple>
<mat-option *ngFor="let cd of citydatas" [value]="cd.city_id" (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-error *ngIf="submitted && f.fk_city.hasError('required')" class="mat-text-warn">You must Select Cities.</mat-error>
</mat-form-field>
@ -78,7 +78,7 @@
<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="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="Reset" matTooltipPosition="above" type="button" (click)="onResetForEdit($event)" ><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>
</mat-card>

View File

@ -162,9 +162,9 @@ export class PdTeamEditComponent implements OnInit {
}
/** To Reset Popup Data For Add*/
onResetForEdit(){
this.PdTeamFormDatas();
}
// onResetForEdit(){
// this.PdTeamFormDatas();
// }
/**on change function for customer segment to dispaly the as List in html page */
onChangeCustomerSegmentDatas($event){
@ -182,11 +182,12 @@ export class PdTeamEditComponent implements OnInit {
/**on change function for City to display the as List in html page */
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 ){
if($event.source._selected == true ){
for(let Duplication_City of this.pdTeamCityArray){
@ -199,7 +200,7 @@ export class PdTeamEditComponent implements OnInit {
if(data.name == cityName.name){
alert('"'+data.name+'" Already Existing with "'+ teamname +'"');
$event.source._selected = false;
mycheck++;
mycheck=1;
}
}
@ -217,6 +218,7 @@ export class PdTeamEditComponent implements OnInit {
}
}
/**on change function for Product to display the data as List in html page */
onChangeProductDatas($event){

View File

@ -19,7 +19,7 @@
</div>
<div *ngIf="noRecordFound" class="nocontent ml-xs mr-xs" style="width: 90%;">No records found</div>
<div class="ml-xs mr-xs" style="width: 10%; text-align: right;">
<button mat-fab class="mr-1 mb-1" style="margin-top: 7px;" [color]="color" (click)="addPdTeam()" matTooltip="Add PD Team" matTooltipPosition="above"><mat-icon>add</mat-icon></button>
<button mat-fab class="mr-1 mb-1" style="margin-top: 7px;" [color]="color" matTooltip="Add PD Team" matTooltipPosition="above" [routerLink]="['/setting/pdteam/addpdteam']" ><mat-icon>add</mat-icon></button>
</div>
</div>
@ -76,7 +76,7 @@
</mat-row>
</mat-table>
<mat-paginator *ngIf="!noRecordFound" [pageSizeOptions]="[5, 10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
<mat-paginator *ngIf="!noRecordFound" [pageSize]="pageSize" [pageSizeOptions]="[5, 10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
</div>
</mat-card-content>
</mat-card>

View File

@ -1,7 +1,7 @@
import { Component,
OnInit,
ViewChild } from '@angular/core';
import { Router } from '@angular/router';
import { MatSort,
MatPaginator,
MatTableDataSource } from '@angular/material';
@ -29,6 +29,7 @@ export class PdTeamListComponent implements OnInit {
loader: boolean = false;
PdTeamList: any = [];
color = 'primary';
pageSize = 10;
userData = null;
noRecordFound: boolean = false;
@ -44,7 +45,7 @@ export class PdTeamListComponent implements OnInit {
@ViewChild(MatSort) sort: MatSort;
constructor(notifier: NotifierService,
private router: Router,
private _MasterService: MastersService,
private _PdTeamService: PdTeamService) {
this.getPdTeam();
@ -53,11 +54,6 @@ export class PdTeamListComponent implements OnInit {
ngOnInit() { this.getPdTeam(); }
/** To add data */
addPdTeam() {
this.router.navigate(['/setting/pdteam/addpdteam']);
}
/** To edit data */
editPdTeam(detail){
@ -100,6 +96,25 @@ export class PdTeamListComponent implements OnInit {
})
}
/** For Changing Active States., which means both Changing Active And Inactive alternatively */
isactivePdTeam(id: number,isactive : number) {
let ActiveDatas = isactive == 0
? { 'pdteam_id':id,'isactive': '1'}
: { 'pdteam_id':id,'isactive': '0'}
this._MasterService.editMasterDetails(ActiveDatas,'PDTEAM')
.subscribe(dataresult=>{
if (dataresult.dataStatus == true){
//alert("my check");
this.getPdTeam();
}
else{
alert("SomeThing Wents Wrong Try Again !");
}
});
}
/** For Display Tables Pagination And Sorting */
ngAfterViewInit() {
this.dataSource.paginator = this.paginator;

View File

@ -286,7 +286,7 @@ editPDAllocationType(Records: any,MasterName:string): Observable<any> {
// formData.append('logo',Records.logo);
// formData.append('records',JSON.stringify(Records));
return this._http.post<any>(this.apiUrl+"saveCompany", ArrayData)
return this._http.post<any>(this.apiUrl+"saveMaster", ArrayData)
.pipe(
catchError(this.handleError('role', []))
)

View File

@ -64,7 +64,7 @@ return this._http.post<any>(this.apiUrl+"savePDTeam", ArrayData)
Records.updatedon = currentdate;//to get Current date and Time for when the Record is updated
var ArrayData = { "records": Records }
console.log(ArrayData);
return this._http.post(this.apiUrl+'savePDTeam',ArrayData)
.pipe(
catchError(this.handleError('role', []))