entity details master : kdk
This commit is contained in:
parent
87149200cb
commit
801e93431e
@ -0,0 +1,180 @@
|
|||||||
|
<div style="max-height: 580px;">
|
||||||
|
<mat-card style="padding: 6px;">
|
||||||
|
<div class="ml-xs mr-xs" style="width: 100%;" fxLayout="row" fxLayoutAlign="center">
|
||||||
|
<h2 mat-dialog-title style="width: 50%;">{{pageTitle}}</h2>
|
||||||
|
<div style="width: 20%;"></div>
|
||||||
|
<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]="_addQuesFrom" (submit)="onSubmit()">
|
||||||
|
<!--<div class="form-group">-->
|
||||||
|
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<mat-select placeholder="Select Entity Type" formControlName="fk_entity_type_id">
|
||||||
|
<mat-option *ngFor="let enti of entityOptions" [value]="enti.entity_type_id">{{ enti.name }}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
<mat-error *ngIf="submitted && f.fk_entity_type_id.hasError('required')" class="mat-text-warn">You must Select Entity Type.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Full Name" formControlName="full_name">
|
||||||
|
<mat-error *ngIf="submitted && f.full_name.hasError('required')" class="mat-text-warn">You must Include Full Name.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Short Name" formControlName="short_name">
|
||||||
|
<mat-error *ngIf="submitted && f.short_name.hasError('required')" class="mat-text-warn">You must Include Short Name.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<mat-select placeholder="Select Region" formControlName="fk_region">
|
||||||
|
<mat-option *ngFor="let reg of geoRecords" [value]="reg.region_id" (click)="selectGeoRegionChanges(reg.state_data)">{{ reg.region_name }}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
<mat-error *ngIf="submitted && f.fk_region.hasError('required')" class="mat-text-warn">You must Select Region.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<mat-select placeholder="Select State" formControlName="fk_state">
|
||||||
|
<mat-option *ngFor="let st of state_m" [value]="st.state_id" (click)="selectGeoStateChanges(st.city_data)">{{ st.state_name }}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
<mat-error *ngIf="submitted && f.fk_state.hasError('required')" class="mat-text-warn">You must Select State.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<mat-select placeholder="Select City" formControlName="fk_city">
|
||||||
|
<mat-option *ngFor="let ct of city_m" [value]="ct.city_id" (click)="selectGeoCityChanges(ct.branch_data)">{{ ct.city_name }}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
<mat-error *ngIf="submitted && f.fk_city.hasError('required')" class="mat-text-warn">You must Select City.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<mat-select placeholder="Select Branch" formControlName="fk_branch">
|
||||||
|
<mat-option *ngFor="let brn of branch_m" [value]="brn.branch_id">{{ brn.branch_name }}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
<mat-error *ngIf="submitted && f.fk_branch.hasError('required')" class="mat-text-warn">You must Select Branch.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Address" formControlName="addressline1">
|
||||||
|
<mat-error *ngIf="submitted && f.addressline1.hasError('required')" class="mat-text-warn">You must Include Address.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Pincode" formControlName="pincode">
|
||||||
|
<mat-error *ngIf="submitted && f.pincode.hasError('required')" class="mat-text-warn">You must Include Pincode.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Official Email" formControlName="official_email">
|
||||||
|
<mat-error *ngIf="submitted && f.official_email.hasError('required')" class="mat-text-warn">You must Include Official Email.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Alternet Email" formControlName="alt_email">
|
||||||
|
<mat-error *ngIf="submitted && f.alt_email.hasError('required')" class="mat-text-warn">You must Select Alternet Email.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Phone Number" formControlName="phone_number">
|
||||||
|
<mat-error *ngIf="submitted && f.phone_number.hasError('required')" class="mat-text-warn">You must Include Phone Number.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Mobile Number" formControlName="mobile_no">
|
||||||
|
<mat-error *ngIf="submitted && f.mobile_no.hasError('required')" class="mat-text-warn">You must Include Mobile Number.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
|
||||||
|
<mat-form-field fxFlex="0 1 calc(33.3% - 32px)" class="ml-xs">
|
||||||
|
<textarea matInput placeholder="Remarks" formControlName="remarks"></textarea>
|
||||||
|
<mat-error *ngIf="submitted && f.remarks.hasError('required')" class="mat-text-warn">You must Include Remarks.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Pan Number" formControlName="pan">
|
||||||
|
<mat-error *ngIf="submitted && f.pan.hasError('required')" class="mat-text-warn">You must Include Pan Number.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="GST Number" formControlName="gst_no">
|
||||||
|
<mat-error *ngIf="submitted && f.gst_no.hasError('required')" class="mat-text-warn">You must Include GST Number.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="GST State Code" formControlName="gst_state_code">
|
||||||
|
<mat-error *ngIf="submitted && f.gst_state_code.hasError('required')" class="mat-text-warn">You must Include GST State Code.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="TAT" formControlName="tat">
|
||||||
|
<mat-error *ngIf="submitted && f.tat.hasError('required')" class="mat-text-warn">You must Include TAT.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
<div fxLayout="row wrap" fxLayoutAlign="start none">
|
||||||
|
<div formArrayName="entity_child" class="example-full-width">
|
||||||
|
<div *ngFor="let answ of _addQuesFrom.controls.entity_child['controls']; let i=index">
|
||||||
|
<div [formGroupName]="i">
|
||||||
|
<div fxLayout="row wrap" style="width: 100%">
|
||||||
|
<div style="width: 90%">
|
||||||
|
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Contact Person" formControlName="contact_person">
|
||||||
|
<!--<mat-error *ngIf="submitted && f.contact_person.hasError('required')" class="mat-text-warn">You must Include Contact Person.</mat-error>-->
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Email" formControlName="contact_email">
|
||||||
|
<!--<mat-error *ngIf="submitted && f.contact_email.hasError('required')" class="mat-text-warn">You must Include Email.</mat-error>-->
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Mobile Number" formControlName="contact_mobile_no">
|
||||||
|
<!--<mat-error *ngIf="submitted && f.contact_mobile_no.hasError('required')" class="mat-text-warn">You must Include Mobile Number.</mat-error>-->
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div style="width:10%">
|
||||||
|
<span *ngIf="_addQuesFrom.controls.entity_child.controls.length > 1" (click)="removeLanguage(i)">
|
||||||
|
<button 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>
|
||||||
|
</div>
|
||||||
|
<button mat-button color="primary" matTooltip="Add More Answer" matTooltipPosition="above" (click)="addLanguage($event); false">Add More</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--Error List Shown Here-->
|
||||||
|
<!--<ul>
|
||||||
|
<li *ngFor="let err of errorMessage">
|
||||||
|
<mat-error>{{err.err}}</mat-error>
|
||||||
|
</li>
|
||||||
|
</ul>-->
|
||||||
|
<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="Save" matTooltipPosition="above" type="submit"><mat-icon>save</mat-icon></button>
|
||||||
|
</div>
|
||||||
|
<!--</div>-->
|
||||||
|
</form>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<notifier-container></notifier-container>
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
.example-full-width{
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
@ -0,0 +1,213 @@
|
|||||||
|
/** Common Imports */
|
||||||
|
import {
|
||||||
|
Component,
|
||||||
|
OnInit,
|
||||||
|
Inject
|
||||||
|
} from '@angular/core';
|
||||||
|
|
||||||
|
import { ActivatedRoute, Router, Params } from '@angular/router';
|
||||||
|
|
||||||
|
import {
|
||||||
|
FormBuilder,
|
||||||
|
FormGroup,
|
||||||
|
Validators,
|
||||||
|
FormArray,
|
||||||
|
} from '@angular/forms';
|
||||||
|
|
||||||
|
import { NotifierService } from 'angular-notifier';
|
||||||
|
|
||||||
|
// import {
|
||||||
|
// MatDialog,
|
||||||
|
// MatDialogRef,
|
||||||
|
// MAT_DIALOG_DATA
|
||||||
|
// } from '@angular/material';
|
||||||
|
/** Service */
|
||||||
|
import { MastersService } from './../../service/masters/masters.service';
|
||||||
|
import { EntityService } from './../../service/entity/entity.service';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Question master add details
|
||||||
|
* : kdk
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'app-entity-add',
|
||||||
|
templateUrl: './entity.add.component.html',
|
||||||
|
styleUrls: ['./entity.add.component.scss']
|
||||||
|
})
|
||||||
|
export class EntityAddComponent implements OnInit {
|
||||||
|
|
||||||
|
public pageTitle: string = "Add Entity Master Details";
|
||||||
|
public _addQuesFrom: FormGroup;
|
||||||
|
public submitted = false;
|
||||||
|
public categories: any = [];
|
||||||
|
public geoRecords: any = [];
|
||||||
|
public entityOptions: any = [];
|
||||||
|
public questionsOptions: any = [];
|
||||||
|
errorMessage: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifier service
|
||||||
|
*/
|
||||||
|
private notifier: NotifierService;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
notifier: NotifierService,
|
||||||
|
private _formBuilder: FormBuilder,
|
||||||
|
private masterService: MastersService,
|
||||||
|
private entityService: EntityService,
|
||||||
|
private router: Router) {
|
||||||
|
this.notifier = notifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
/** Questions Form Datas*/
|
||||||
|
this._addQuesFrom = this._formBuilder.group({
|
||||||
|
fk_entity_type_id: [null, Validators.compose([Validators.required])],
|
||||||
|
full_name: [null, Validators.compose([Validators.required])],
|
||||||
|
short_name: [null, Validators.compose([Validators.required])],
|
||||||
|
fk_region: [null, Validators.compose([Validators.required])],
|
||||||
|
fk_state: [null, Validators.compose([Validators.required])],
|
||||||
|
fk_city: [null, Validators.compose([Validators.required])],
|
||||||
|
fk_branch: [null, Validators.compose([Validators.required])],
|
||||||
|
addressline1: [null, Validators.compose([Validators.required])],
|
||||||
|
pincode: [null, Validators.compose([Validators.required])],
|
||||||
|
official_email: [null, Validators.compose([Validators.required, Validators.email])],
|
||||||
|
alt_email: [null, Validators.compose([Validators.required, Validators.email])],
|
||||||
|
phone_number: [null, Validators.compose([Validators.required])],
|
||||||
|
mobile_no: [null, Validators.compose([Validators.required])],
|
||||||
|
remarks: [null, Validators.compose([Validators.required])],
|
||||||
|
pan: [null, Validators.compose([Validators.required])],
|
||||||
|
gst_no: [null, Validators.compose([Validators.required])],
|
||||||
|
gst_state_code: [null, Validators.compose([Validators.required])],
|
||||||
|
tat: [null, Validators.compose([Validators.required])],
|
||||||
|
entity_child: this._formBuilder.array([
|
||||||
|
this.initAnswers(),
|
||||||
|
])
|
||||||
|
});
|
||||||
|
// OnInit Load Geo Details and Question Type Masters
|
||||||
|
this.getGeoLocationMaster();
|
||||||
|
this.getEntityOptionsMaster();
|
||||||
|
}
|
||||||
|
|
||||||
|
// convenience getter for easy access to form fields
|
||||||
|
get f() { return this._addQuesFrom.controls; }
|
||||||
|
|
||||||
|
// Dynamic Form field creation Functionality : START ===>
|
||||||
|
initAnswers() {
|
||||||
|
return this._formBuilder.group({
|
||||||
|
contact_person: ['', Validators.compose([Validators.required])],
|
||||||
|
contact_email: ['', Validators.compose([Validators.required])],
|
||||||
|
contact_mobile_no: ['', Validators.compose([Validators.required])],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
addLanguage(e) {
|
||||||
|
const control = <FormArray>this._addQuesFrom.controls['entity_child'];
|
||||||
|
control.push(this.initAnswers());
|
||||||
|
}
|
||||||
|
removeLanguage(i: number) {
|
||||||
|
const control = <FormArray>this._addQuesFrom.controls['entity_child'];
|
||||||
|
control.removeAt(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// END ===>
|
||||||
|
|
||||||
|
public state_m: any = [];
|
||||||
|
selectGeoRegionChanges(reg){
|
||||||
|
this._addQuesFrom.controls.fk_state.reset();
|
||||||
|
this._addQuesFrom.controls.fk_city.reset();
|
||||||
|
this._addQuesFrom.controls.fk_branch.reset();
|
||||||
|
this.state_m = [];
|
||||||
|
this.city_m = [];
|
||||||
|
this.branch_m = [];
|
||||||
|
if(reg){
|
||||||
|
this.state_m = reg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public city_m: any = []
|
||||||
|
selectGeoStateChanges(city) {
|
||||||
|
this._addQuesFrom.controls.fk_city.reset();
|
||||||
|
this._addQuesFrom.controls.fk_branch.reset();
|
||||||
|
this.city_m = [];
|
||||||
|
this.branch_m = [];
|
||||||
|
if(city){
|
||||||
|
this.city_m = city;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public branch_m: any = [];
|
||||||
|
selectGeoCityChanges(brn){
|
||||||
|
this._addQuesFrom.controls.fk_branch.reset();
|
||||||
|
this.branch_m = [];
|
||||||
|
if(brn){
|
||||||
|
this.branch_m = brn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getGeoLocationMaster() {
|
||||||
|
this.entityService.getGeoLocationMasterDetails().subscribe(
|
||||||
|
data => {
|
||||||
|
this.geoRecords = data.records;
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
this.notifier.notify('warning', 'No Geo Location Records Found.!');
|
||||||
|
this.errorMessage = "No Category Records Found.";
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
getEntityOptionsMaster() {
|
||||||
|
this.masterService.getAllMasterData('ENTITYTYPE').subscribe(
|
||||||
|
data => {
|
||||||
|
this.entityOptions = data.records.filter(data => data.entity_type_id != 1);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
this.notifier.notify('warning', 'No Answer Type Records Found.!');
|
||||||
|
this.errorMessage = "No Answer Type Record Found.";
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** For Popup Close Button */
|
||||||
|
onNoClick(): void {
|
||||||
|
// this.dialogRef.close();
|
||||||
|
this.router.navigate(['/setting/entity/list']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** To Save/Edited Popup Data */
|
||||||
|
onSubmit() {
|
||||||
|
this.submitted = true;
|
||||||
|
// stop here if form is invalid
|
||||||
|
if (this._addQuesFrom.invalid) {
|
||||||
|
this.errorMessage = "Please Fill All Mandate Fields.";
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
var entityFormValues = this._addQuesFrom.value;
|
||||||
|
|
||||||
|
//To Remove The "Null" With Key also
|
||||||
|
Object.keys(entityFormValues).forEach((key) => (entityFormValues[key] == null) && delete entityFormValues[key]);
|
||||||
|
|
||||||
|
//Add BRANCH data with help Service File
|
||||||
|
this.entityService.addEntityMasterDetails(entityFormValues).subscribe(
|
||||||
|
dataresult => {
|
||||||
|
if (dataresult.status == 200) {
|
||||||
|
console.log(dataresult);
|
||||||
|
this.notifier.notify('success', 'Record Saved Successfully.!');
|
||||||
|
this.router.navigate(['/setting/entity/list']);
|
||||||
|
this._addQuesFrom.reset();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.notifier.notify('warning', 'Something 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 !";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** To Reset Popup Data */
|
||||||
|
onReset() {
|
||||||
|
this._addQuesFrom.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,180 @@
|
|||||||
|
<div style="max-height: 580px;">
|
||||||
|
<mat-card style="padding: 6px;">
|
||||||
|
<div class="ml-xs mr-xs" style="width: 100%;" fxLayout="row" fxLayoutAlign="center">
|
||||||
|
<h2 mat-dialog-title style="width: 50%;">{{pageTitle}}</h2>
|
||||||
|
<div style="width: 20%;"></div>
|
||||||
|
<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]="_addQuesFrom" (submit)="onSubmit()">
|
||||||
|
<!--<div class="form-group">-->
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start" style="padding: 6px 4px;">
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<mat-select placeholder="Select Entity Type" formControlName="fk_entity_type_id">
|
||||||
|
<mat-option *ngFor="let enti of entityOptions" [value]="enti.entity_type_id">{{ enti.name }}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
<mat-error *ngIf="submitted && f.fk_entity_type_id.hasError('required')" class="mat-text-warn">You must Select Entity Type.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start" style="padding: 6px 4px;">
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Full Name" formControlName="full_name">
|
||||||
|
<mat-error *ngIf="submitted && f.full_name.hasError('required')" class="mat-text-warn">You must Include Full Name.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Short Name" formControlName="short_name">
|
||||||
|
<mat-error *ngIf="submitted && f.short_name.hasError('required')" class="mat-text-warn">You must Include Short Name.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start" style="padding: 6px 4px;">
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<mat-select placeholder="Select Region" formControlName="fk_region">
|
||||||
|
<mat-option *ngFor="let reg of geoRecords" [value]="reg.region_id" (click)="selectGeoRegionChanges(reg.state_data)">{{ reg.region_name }}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
<mat-error *ngIf="submitted && f.fk_region.hasError('required')" class="mat-text-warn">You must Select Region.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<mat-select placeholder="Select State" formControlName="fk_state">
|
||||||
|
<mat-option *ngFor="let st of state_m" [value]="st.state_id" (click)="selectGeoStateChanges(st.city_data)">{{ st.state_name }}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
<mat-error *ngIf="submitted && f.fk_state.hasError('required')" class="mat-text-warn">You must Select State.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<mat-select placeholder="Select City" formControlName="fk_city">
|
||||||
|
<mat-option *ngFor="let ct of city_m" [value]="ct.city_id" (click)="selectGeoCityChanges(ct.branch_data)">{{ ct.city_name }}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
<mat-error *ngIf="submitted && f.fk_city.hasError('required')" class="mat-text-warn">You must Select City.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<mat-select placeholder="Select Branch" formControlName="fk_branch">
|
||||||
|
<mat-option *ngFor="let brn of branch_m" [value]="brn.branch_id">{{ brn.branch_name }}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
<mat-error *ngIf="submitted && f.fk_branch.hasError('required')" class="mat-text-warn">You must Select Branch.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start" style="padding: 6px 4px;">
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Address" formControlName="addressline1">
|
||||||
|
<mat-error *ngIf="submitted && f.addressline1.hasError('required')" class="mat-text-warn">You must Include Address.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Pincode" formControlName="pincode">
|
||||||
|
<mat-error *ngIf="submitted && f.pincode.hasError('required')" class="mat-text-warn">You must Include Pincode.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start" style="padding: 6px 4px;">
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Official Email" formControlName="official_email">
|
||||||
|
<mat-error *ngIf="submitted && f.official_email.hasError('required')" class="mat-text-warn">You must Include Official Email.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Alternet Email" formControlName="alt_email">
|
||||||
|
<mat-error *ngIf="submitted && f.alt_email.hasError('required')" class="mat-text-warn">You must Select Alternet Email.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Phone Number" formControlName="phone_number">
|
||||||
|
<mat-error *ngIf="submitted && f.phone_number.hasError('required')" class="mat-text-warn">You must Include Phone Number.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Mobile Number" formControlName="mobile_no">
|
||||||
|
<mat-error *ngIf="submitted && f.mobile_no.hasError('required')" class="mat-text-warn">You must Include Mobile Number.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start" style="padding: 6px 4px;">
|
||||||
|
<mat-form-field fxFlex="0 1 calc(33.3% - 32px)" class="ml-xs">
|
||||||
|
<textarea matInput placeholder="Remarks" formControlName="remarks"></textarea>
|
||||||
|
<mat-error *ngIf="submitted && f.remarks.hasError('required')" class="mat-text-warn">You must Include Remarks.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start" style="padding: 6px 4px;">
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Pan Number" formControlName="pan">
|
||||||
|
<mat-error *ngIf="submitted && f.pan.hasError('required')" class="mat-text-warn">You must Include Pan Number.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="GST Number" formControlName="gst_no">
|
||||||
|
<mat-error *ngIf="submitted && f.gst_no.hasError('required')" class="mat-text-warn">You must Include GST Number.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="GST State Code" formControlName="gst_state_code">
|
||||||
|
<mat-error *ngIf="submitted && f.gst_state_code.hasError('required')" class="mat-text-warn">You must Include GST State Code.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="TAT" formControlName="tat">
|
||||||
|
<mat-error *ngIf="submitted && f.tat.hasError('required')" class="mat-text-warn">You must Include TAT.</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
<div fxLayout="row wrap" fxLayoutAlign="start none" style="padding: 6px 4px;">
|
||||||
|
<div formArrayName="entity_child" class="example-full-width">
|
||||||
|
<div *ngFor="let answ of _addQuesFrom.controls.entity_child['controls']; let i=index">
|
||||||
|
<div [formGroupName]="i">
|
||||||
|
<div fxLayout="row wrap">
|
||||||
|
<div>
|
||||||
|
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Contact Person" formControlName="contact_person">
|
||||||
|
<!--<mat-error *ngIf="submitted && f.contact_person.hasError('required')" class="mat-text-warn">You must Include Contact Person.</mat-error>-->
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Email" formControlName="contact_email">
|
||||||
|
<!--<mat-error *ngIf="submitted && f.contact_email.hasError('required')" class="mat-text-warn">You must Include Email.</mat-error>-->
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
<input matInput placeholder="Mobile Number" formControlName="contact_mobile_no">
|
||||||
|
<!--<mat-error *ngIf="submitted && f.contact_mobile_no.hasError('required')" class="mat-text-warn">You must Include Mobile Number.</mat-error>-->
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<mat-checkbox *ngIf="answ.get('entity_child_id').value != null" formControlName="isactive" [ngModel]="answ.get('isactive').value == 1 ? true : answ.get('isactive').value == 0 ? false : null"
|
||||||
|
(ngModelChange)="answ.get('isactive').value = $event ? 1 : 0"></mat-checkbox>
|
||||||
|
|
||||||
|
<span *ngIf="_addQuesFrom.controls.entity_child.controls.length > 1" (click)="removeLanguage(i)">
|
||||||
|
<button *ngIf="answ.get('entity_child_id').value == null" 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>
|
||||||
|
</div>
|
||||||
|
<button mat-button color="primary" matTooltip="Add More" matTooltipPosition="above" (click)="addLanguage(null, null, null, null, null, $event); false">Add More</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--Error List Shown Here-->
|
||||||
|
<!--<ul>
|
||||||
|
<li *ngFor="let err of errorMessage">
|
||||||
|
<mat-error>{{err.err}}</mat-error>
|
||||||
|
</li>
|
||||||
|
</ul>-->
|
||||||
|
<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)="onReset()"><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>
|
||||||
|
<!--</div>-->
|
||||||
|
</form>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
@ -0,0 +1,253 @@
|
|||||||
|
/** Common Imports */
|
||||||
|
import {
|
||||||
|
Component,
|
||||||
|
OnInit,
|
||||||
|
Inject,
|
||||||
|
ViewChild,
|
||||||
|
Input
|
||||||
|
} from '@angular/core';
|
||||||
|
|
||||||
|
import {
|
||||||
|
FormBuilder,
|
||||||
|
FormGroup,
|
||||||
|
Validators,
|
||||||
|
FormArray,
|
||||||
|
} from '@angular/forms';
|
||||||
|
|
||||||
|
import { NotifierService } from 'angular-notifier';
|
||||||
|
|
||||||
|
/** Service */
|
||||||
|
import { MastersService } from './../../service/masters/masters.service';
|
||||||
|
import { EntityService } from './../../service/entity/entity.service';
|
||||||
|
import { EntityListComponent } from './../entity-list/entity.list.component';
|
||||||
|
/*
|
||||||
|
* Question master details edit component
|
||||||
|
* : kdk
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'app-entity-edit',
|
||||||
|
templateUrl: './entity.edit.component.html',
|
||||||
|
// styleUrls: ['./edit.component.scss']
|
||||||
|
})
|
||||||
|
export class EntityEditComponent implements OnInit{
|
||||||
|
|
||||||
|
@Input() public childMessage: any;
|
||||||
|
|
||||||
|
public pageTitle: string = "Edit Entity Master Details";
|
||||||
|
public _addQuesFrom: FormGroup;
|
||||||
|
public submitted = false;
|
||||||
|
public categories: any = [];
|
||||||
|
public geoRecords: any = [];
|
||||||
|
public entityOptions: any = [];
|
||||||
|
public questionsOptions: any = [];
|
||||||
|
errorMessage: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifier service
|
||||||
|
*/
|
||||||
|
private notifier: NotifierService;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
notifier: NotifierService,
|
||||||
|
private _formBuilder: FormBuilder,
|
||||||
|
private masterService: MastersService,
|
||||||
|
private entityService: EntityService,
|
||||||
|
private entityListComponent: EntityListComponent) {
|
||||||
|
this.notifier = notifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.loadFormData();
|
||||||
|
/** Questions Form Datas*/
|
||||||
|
if (this.childMessage["0"].length > 0) {
|
||||||
|
for (let val of this.childMessage["0"]) {
|
||||||
|
// alert(JSON.stringify(val));
|
||||||
|
let vals = val;
|
||||||
|
this.addLanguage(vals['contact_person'], vals['contact_email'], vals['contact_mobile_no'], vals['entity_child_id'], vals['isactive'], null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnInit Load Geo Details and Question Type Masters
|
||||||
|
this.getGeoLocationMaster();
|
||||||
|
this.getEntityOptionsMaster();
|
||||||
|
}
|
||||||
|
|
||||||
|
// load answer details list
|
||||||
|
loadAnsData() {
|
||||||
|
if (this.childMessage["0"].length > 0) {
|
||||||
|
for (let val of this.childMessage["0"]) {
|
||||||
|
// alert(JSON.stringify(val));
|
||||||
|
let vals = val;
|
||||||
|
this.addLanguage(vals['contact_person'], vals['contact_email'], vals['contact_mobile_no'], vals['entity_child_id'], vals['isactive'], null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
loadFormData() {
|
||||||
|
this._addQuesFrom = this._formBuilder.group({
|
||||||
|
entity_id: [this.childMessage.entity_id],
|
||||||
|
fk_entity_type_id: [this.childMessage.fk_entity_type_id, Validators.compose([Validators.required])],
|
||||||
|
full_name: [this.childMessage.full_name, Validators.compose([Validators.required])],
|
||||||
|
short_name: [this.childMessage.short_name, Validators.compose([Validators.required])],
|
||||||
|
fk_region: [this.childMessage.fk_region, Validators.compose([Validators.required])],
|
||||||
|
fk_state: [this.childMessage.fk_state, Validators.compose([Validators.required])],
|
||||||
|
fk_city: [this.childMessage.fk_city, Validators.compose([Validators.required])],
|
||||||
|
fk_branch: [this.childMessage.fk_branch, Validators.compose([Validators.required])],
|
||||||
|
addressline1: [this.childMessage.addressline1, Validators.compose([Validators.required])],
|
||||||
|
pincode: [this.childMessage.pincode, Validators.compose([Validators.required])],
|
||||||
|
official_email: [this.childMessage.official_email, Validators.compose([Validators.required, Validators.email])],
|
||||||
|
alt_email: [this.childMessage.alt_email, Validators.compose([Validators.required, Validators.email])],
|
||||||
|
phone_number: [this.childMessage.phone_number, Validators.compose([Validators.required])],
|
||||||
|
mobile_no: [this.childMessage.mobile_no, Validators.compose([Validators.required])],
|
||||||
|
remarks: [this.childMessage.remarks, Validators.compose([Validators.required])],
|
||||||
|
pan: [this.childMessage.pan, Validators.compose([Validators.required])],
|
||||||
|
gst_no: [this.childMessage.gst_no, Validators.compose([Validators.required])],
|
||||||
|
gst_state_code: [this.childMessage.gst_state_code, Validators.compose([Validators.required])],
|
||||||
|
tat: [this.childMessage.tat, Validators.compose([Validators.required])],
|
||||||
|
entity_child: this._formBuilder.array([
|
||||||
|
// this.initAnswers(),
|
||||||
|
])
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// convenience getter for easy access to form fields
|
||||||
|
get f() { return this._addQuesFrom.controls; }
|
||||||
|
|
||||||
|
// form entity_child details access
|
||||||
|
get f_ans() { return <FormArray>this._addQuesFrom.get('entity_child'); }
|
||||||
|
|
||||||
|
// Dynamic Form field creation Functionality : START ===>
|
||||||
|
initAnswers(c_person, c_email, e_phn, fk_id, isAct, e) {
|
||||||
|
isAct = isAct == null ? 1 : isAct;
|
||||||
|
return this._formBuilder.group({
|
||||||
|
contact_person: [c_person, Validators.compose([Validators.required])],
|
||||||
|
contact_email: [c_email, Validators.compose([Validators.required])],
|
||||||
|
contact_mobile_no: [e_phn, Validators.compose([Validators.required])],
|
||||||
|
entity_child_id: [fk_id],
|
||||||
|
isactive: [isAct]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
addLanguage(c_person, c_email, e_phn, fk_id, isAct, e) {
|
||||||
|
const control = <FormArray>this._addQuesFrom.controls['entity_child'];
|
||||||
|
control.push(this.initAnswers(c_person, c_email, e_phn, fk_id, isAct, e));
|
||||||
|
}
|
||||||
|
removeLanguage(i: number) {
|
||||||
|
const control = <FormArray>this._addQuesFrom.controls['entity_child'];
|
||||||
|
control.removeAt(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// END ===>
|
||||||
|
|
||||||
|
public state_m: any = [];
|
||||||
|
selectGeoRegionChanges(reg){
|
||||||
|
this._addQuesFrom.controls.fk_state.reset();
|
||||||
|
this._addQuesFrom.controls.fk_city.reset();
|
||||||
|
this._addQuesFrom.controls.fk_branch.reset();
|
||||||
|
this.state_m = [];
|
||||||
|
this.city_m = [];
|
||||||
|
this.branch_m = [];
|
||||||
|
if(reg){
|
||||||
|
this.state_m = reg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public city_m: any = []
|
||||||
|
selectGeoStateChanges(city) {
|
||||||
|
this._addQuesFrom.controls.fk_city.reset();
|
||||||
|
this._addQuesFrom.controls.fk_branch.reset();
|
||||||
|
this.city_m = [];
|
||||||
|
this.branch_m = [];
|
||||||
|
if(city){
|
||||||
|
this.city_m = city;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public branch_m: any = [];
|
||||||
|
selectGeoCityChanges(brn){
|
||||||
|
this._addQuesFrom.controls.fk_branch.reset();
|
||||||
|
this.branch_m = [];
|
||||||
|
if(brn){
|
||||||
|
this.branch_m = brn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getGeoLocationMaster() {
|
||||||
|
this.entityService.getGeoLocationMasterDetails().subscribe(
|
||||||
|
data => {
|
||||||
|
this.geoRecords = data.records;
|
||||||
|
this.setGeoEditSelectDetails();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
this.notifier.notify('warning', 'No Geo Location Records Found.!');
|
||||||
|
this.errorMessage = "No Category Records Found.";
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
setGeoEditSelectDetails() {
|
||||||
|
let state = this.geoRecords.filter(data=>{if(data.region_id === this.childMessage.fk_region){ return data.state_data;}});
|
||||||
|
this.state_m = state[0].state_data;
|
||||||
|
let city = this.state_m.filter(data=>{if(data.state_id === this.childMessage.fk_state){ return data.city_data;}});
|
||||||
|
this.city_m = city[0].city_data;
|
||||||
|
let branch = this.city_m.filter(data=>{if(data.city_id === this.childMessage.fk_city){ return data.branch_data;}});
|
||||||
|
// alert(JSON.stringify(branch));
|
||||||
|
this.branch_m = branch[0].branch_data;
|
||||||
|
}
|
||||||
|
getEntityOptionsMaster() {
|
||||||
|
this.masterService.getAllMasterData('ENTITYTYPE').subscribe(
|
||||||
|
data => {
|
||||||
|
this.entityOptions = data.records.filter(data => data.entity_type_id != 1);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
this.notifier.notify('warning', 'No Answer Type Records Found.!');
|
||||||
|
this.errorMessage = "No Answer Type Record Found.";
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** For Popup Close Button */
|
||||||
|
onNoClick(): void {
|
||||||
|
this.entityListComponent.changeListView();
|
||||||
|
// this.dialogRef.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** To Save/Edited Popup Data */
|
||||||
|
onSubmit() {
|
||||||
|
this.submitted = true;
|
||||||
|
// stop here if form is invalid
|
||||||
|
if (this._addQuesFrom.invalid) {
|
||||||
|
this.errorMessage = "Please Fill All Mandate Fields.";
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
var entityFormValues = this._addQuesFrom.value;
|
||||||
|
|
||||||
|
//To Remove The "Null" With Key also
|
||||||
|
Object.keys(entityFormValues).forEach((key) => (entityFormValues[key] == null) && delete entityFormValues[key]);
|
||||||
|
|
||||||
|
//Add BRANCH data with help Service File
|
||||||
|
this.entityService.updateEntityMasterDetails(entityFormValues).subscribe(
|
||||||
|
dataresult => {
|
||||||
|
if (dataresult.status == 200) {
|
||||||
|
console.log(dataresult);
|
||||||
|
this.notifier.notify('success', 'Record Updated Successfully.!');
|
||||||
|
this._addQuesFrom.reset();
|
||||||
|
this.entityListComponent.changeListView();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.notifier.notify('warning', 'Something 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 !";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** To Reset Popup Data */
|
||||||
|
onReset() {
|
||||||
|
this.loadFormData();
|
||||||
|
this.loadAnsData();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,83 @@
|
|||||||
|
<div *ngIf="listView">
|
||||||
|
<mat-card>
|
||||||
|
|
||||||
|
<mat-card class="mat-elevation-z1">
|
||||||
|
<div style="margin: 6px; padding: 4px;">
|
||||||
|
<div class="p_title" style="font-size: 16px; font-style: bold;">Entity Master</div>
|
||||||
|
<div class="sub_title" style="font-size: 11px;">List of Entity Master Details</div>
|
||||||
|
</div>
|
||||||
|
<div fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutAlign="center none">
|
||||||
|
<div fxFlex="80%">
|
||||||
|
<!--<form [formGroup]="filterFormGroupCtrl">
|
||||||
|
<div fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutGap="0.5px" fxLayoutAlign="start none" style="padding: 6px;">
|
||||||
|
|
||||||
|
<mat-select placeholder="Category" formControlName="category">
|
||||||
|
<mat-option *ngFor="let cat of categories" [value]="cat.question_categroy_id" (click)="getQuestionsMasters()">
|
||||||
|
{{cat.categroy_name}}
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</div>
|
||||||
|
</form>-->
|
||||||
|
</div>
|
||||||
|
<div fxFlex="20%">
|
||||||
|
<!--<a [routerLink]="['/'+'setting/entity/add' ]">-->
|
||||||
|
<button mat-stroked-button color="primary" (click)="addNewQuestion()">
|
||||||
|
Add New Entity</button>
|
||||||
|
<!--</a>-->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--</mat-card-content>-->
|
||||||
|
</mat-card>
|
||||||
|
<!--
|
||||||
|
<mat-card class="mat-elevation-z1">
|
||||||
|
<div style="margin: 6px; padding: 4px;">
|
||||||
|
<div class="p_title" style="font-size: 16px; font-style: bold;">Entity Master</div>
|
||||||
|
<div class="sub_title" style="font-size: 11px;">List of Entity Master Details</div>
|
||||||
|
</div>
|
||||||
|
</mat-card>-->
|
||||||
|
<ng-container *ngIf="enityList.length > 0">
|
||||||
|
<div style="padding: 0 12px;">
|
||||||
|
<mat-card class="product-card" *ngFor="let product of dataSource.connect() | async">
|
||||||
|
<div fxLayout="row" fxLayoutAlign="start start" style="padding: 6px 2px;">
|
||||||
|
<div fxFlex="90%" style="padding: 12px 8px;">
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
|
||||||
|
<div fxFlex="0 1 auto" class="ml-xs" fxFlex="10%">
|
||||||
|
{{ product.entity_name }}
|
||||||
|
</div>
|
||||||
|
<div fxFlex="0 1 auto" class="ml-xs" fxFlex="30%">
|
||||||
|
<div>{{ product.full_name }} ({{product.short_name}})</div>
|
||||||
|
<div> {{ product.branch_name }} </div>
|
||||||
|
<div> {{product.city_name}}, {{product.state_name}} </div>
|
||||||
|
</div>
|
||||||
|
<div fxFlex="0 1 auto" class="ml-xs" fxFlex="30%">
|
||||||
|
<div> {{ product.phone_number }}</div>
|
||||||
|
<div> {{ product.official_email }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
|
||||||
|
<div fxFlex="0 1 auto" class="ml-xs">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div fxFlex="10%">
|
||||||
|
<button mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Close" matTooltipPosition="above" (click)="editEntity(product)"><mat-icon>edit</mat-icon></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
</ng-container>
|
||||||
|
<mat-card *ngIf="noQuesMasterRecrdFound">
|
||||||
|
<div class="no-record-found">No Record Found ... </div>
|
||||||
|
</mat-card>
|
||||||
|
<mat-paginator #paginator class="mat-elevation-z1" [length]="enityList.length" [pageIndex]="pageIndex" [pageSize]="pageSize"
|
||||||
|
[pageSizeOptions]="[5, 10, 25, 100]" (page)="pageEvent = $event; pageChange($event)">
|
||||||
|
</mat-paginator>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="!listView">
|
||||||
|
<app-entity-edit [childMessage]="parentMessage"></app-entity-edit>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<notifier-container></notifier-container>
|
||||||
@ -0,0 +1,168 @@
|
|||||||
|
import { Component, ViewChild, OnInit } from '@angular/core';
|
||||||
|
import { MatPaginator, MatSort, MatTableDataSource, MatDialog, PageEvent } from '@angular/material';
|
||||||
|
import { FormGroup, FormControl, FormBuilder } from '@angular/forms';
|
||||||
|
import { ActivatedRoute, Router, Params } from '@angular/router';
|
||||||
|
import { DataSource } from '@angular/cdk/table';
|
||||||
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
import { MastersService } from './../../service/masters/masters.service';
|
||||||
|
/** Dialog Component */
|
||||||
|
import { EntityAddComponent } from './../entity-add/entity.add.component';
|
||||||
|
// import { EditComponent } from './../entity-edit/entity.edit.component';
|
||||||
|
import { EntityService } from './../../service/entity/entity.service';
|
||||||
|
// import { EntityEditComponent } from "./../entity-edit/entity.edit.component";
|
||||||
|
/*
|
||||||
|
* Questions master List component
|
||||||
|
* : kdk
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'app-entity-list',
|
||||||
|
templateUrl: './entity.list.component.html',
|
||||||
|
// styleUrls: ['./list.component.scss']
|
||||||
|
})
|
||||||
|
export class EntityListComponent implements OnInit {
|
||||||
|
|
||||||
|
public listView: any = true;
|
||||||
|
|
||||||
|
public enityList: any[] = [];
|
||||||
|
public paginationList: any[] = [];
|
||||||
|
public categories: any = [];
|
||||||
|
public search_cid: any = null;
|
||||||
|
public noQuesMasterRecrdFound: boolean = false;
|
||||||
|
|
||||||
|
public filterFormGroupCtrl: FormGroup;
|
||||||
|
|
||||||
|
// @ViewChild(EntityEditComponent) child;
|
||||||
|
|
||||||
|
// pagination variable details
|
||||||
|
length = 50;
|
||||||
|
pageIndex = 0;
|
||||||
|
pageSize = 10;
|
||||||
|
pageEvent: PageEvent;
|
||||||
|
|
||||||
|
// data source variable details
|
||||||
|
questionListData = null;
|
||||||
|
public dataLength: number;
|
||||||
|
public dataSource = new MatTableDataSource();
|
||||||
|
displayedColumns = ['categroy_name', 'question', 'actions'];
|
||||||
|
|
||||||
|
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||||
|
@ViewChild(MatSort) sort: MatSort;
|
||||||
|
|
||||||
|
constructor(private dialog: MatDialog,
|
||||||
|
private masterService: MastersService,
|
||||||
|
private _formBuilder: FormBuilder,
|
||||||
|
private router: Router,
|
||||||
|
private entityService: EntityService) {
|
||||||
|
// this.filterFormGroupCtrl = this._formBuilder.group({
|
||||||
|
// category: [null, '']
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.getCategorMaster();
|
||||||
|
this.getEntityListMasters();
|
||||||
|
}
|
||||||
|
|
||||||
|
// get question master list details
|
||||||
|
getEntityListMasters() {
|
||||||
|
this.noQuesMasterRecrdFound = false;
|
||||||
|
// this.search_cid = this.filterFormGroupCtrl.controls.category.value;
|
||||||
|
console.log(this.search_cid + ", " + this.filterFormGroupCtrl);
|
||||||
|
this.entityService.getEntityListMasterDetails().subscribe(
|
||||||
|
data => {
|
||||||
|
if (data) {
|
||||||
|
if (data.records) {
|
||||||
|
this.enityList = data.records;
|
||||||
|
this.questionListData = data.records;
|
||||||
|
this.dataLength = data.records.length;
|
||||||
|
this.dataSource.data = this.questionListData;
|
||||||
|
} else {
|
||||||
|
this.enityList = [];
|
||||||
|
this.dataLength = null;
|
||||||
|
this.noQuesMasterRecrdFound = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.enityList = [];
|
||||||
|
this.dataLength = null;
|
||||||
|
this.noQuesMasterRecrdFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// get category master details
|
||||||
|
getCategorMaster() {
|
||||||
|
this.masterService.getAllMasterData('QUESTIONCATEGORY').subscribe(
|
||||||
|
data => {
|
||||||
|
this.categories = data.records.filter(category => category.isactive == 1);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
// this.errorMessage = "No Category Record Found.";
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
ngAfterViewInit() {
|
||||||
|
this.dataSource.paginator = this.paginator;
|
||||||
|
this.dataSource.sort = this.sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
applyFilter(filterValue: string) {
|
||||||
|
filterValue = filterValue.trim(); // Remove whitespace
|
||||||
|
filterValue = filterValue.toLowerCase(); // Datasource defaults to lowercase matches
|
||||||
|
this.dataSource.filter = filterValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add questions popup model call
|
||||||
|
addNewQuestion() {
|
||||||
|
this.router.navigate(['/setting/entity/add']);
|
||||||
|
|
||||||
|
// const dialogRef = this.dialog.open(EntityAddComponent, {
|
||||||
|
// data: {},
|
||||||
|
// disableClose: true
|
||||||
|
// });
|
||||||
|
// dialogRef.afterClosed()
|
||||||
|
// .subscribe(dataresult => {
|
||||||
|
// this.getQuestionsMasters();
|
||||||
|
// // this.getBranch();
|
||||||
|
// // this.isPopupOpened = false;
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
public parentMessage: any = [];
|
||||||
|
editEntity(detail){
|
||||||
|
this.parentMessage = detail;
|
||||||
|
this.listView = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
changeListView(){
|
||||||
|
this.getEntityListMasters();
|
||||||
|
this.listView = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// edit questions master details popup model
|
||||||
|
// editQuestion(rowDetails: any) {
|
||||||
|
// const dialogRef = this.dialog.open(EditComponent, {
|
||||||
|
// data: rowDetails,
|
||||||
|
// disableClose: true
|
||||||
|
// });
|
||||||
|
// dialogRef.afterClosed()
|
||||||
|
// .subscribe(dataresult => {
|
||||||
|
// this.getQuestionsMasters();
|
||||||
|
// // this.getBranch();
|
||||||
|
// // this.isPopupOpened = false;
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// padination page event call
|
||||||
|
pageChange(e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// {"dataStatus":true,"status":200,"records":
|
||||||
|
// [
|
||||||
|
// {"entity_id":"4","full_name":"chech","short_name":"check","fk_region":"2","region_name":"South India","fk_state":"2","state_name":"Tamil Nadu","fk_city":"2","city_name":"Chennai","fk_branch":"10","branch_name":"Ahmedabad","addressline1":"c","pincode":"c","official_email":"c@gmail.com","alt_email":"c@gmail.com","phone_number":"3423423444","mobile_no":"234234234","remarks":"234234","createdon":"2018-10-05 05:18:08","fk_createdby":"1","createdby":"sriram v","updatedon":null,"fk_updatedby":null,"updatedby":null,"isactive":"1","pan":"234234","gst_no":"2342","gst_state_code":"dfw","tat":"12","fk_entity_type_id":"2","entity_name":"LENDOR","0":[{"entity_child_id":"1","contact_person":"cc","contact_email":"cc@gmai.com","contact_mobile_no":"23412341234","isactive":"1","createdon":"2018-10-05 05:18:08","fk_createdby":"1","createdby":"sriram v","updatedon":null,"fk_updatedby":null,"updatedby":null}]},
|
||||||
|
// {"entity_id":"1","full_name":"ICICI","short_name":"ICICI","fk_region":"1","region_name":"North India","fk_state":"1","state_name":"Jammu and Kashmir","fk_city":"1","city_name":"Srinagar (summer), Jammu (winter)","fk_branch":"1","branch_name":"Main Branch","addressline1":"add1","pincode":"add2","official_email":null,"alt_email":null,"phone_number":null,"mobile_no":null,"remarks":null,"createdon":"2018-09-28 08:55:56","fk_createdby":"1","createdby":"sriram v","updatedon":"2018-10-03 10:11:28","fk_updatedby":null,"updatedby":null,"isactive":"1","pan":null,"gst_no":null,"gst_state_code":null,"tat":null,"fk_entity_type_id":"2","entity_name":"LENDOR","0":[{"entity_child_id":"2","contact_person":"ccee","contact_email":"ccee@gmai.com","contact_mobile_no":"234123412111","isactive":"1","createdon":"2018-10-05 05:18:08","fk_createdby":"1","createdby":"sriram v","updatedon":"2018-10-05 05:18:08","fk_updatedby":"1","updatedby":"sriram v"}]},
|
||||||
|
// {"entity_id":"8","full_name":"ICICIedited","short_name":"checkee","fk_region":"2","region_name":"South India","fk_state":"2","state_name":"Tamil Nadu","fk_city":"2","city_name":"Chennai","fk_branch":"10","branch_name":"Ahmedabad","addressline1":"cee","pincode":"cee","official_email":"cee@gmail.com","alt_email":"cee@gmail.com","phone_number":"3423423111","mobile_no":"234234111","remarks":"edietd","createdon":"2018-10-05 05:18:08","fk_createdby":"1","createdby":"sriram v","updatedon":"2018-10-05 05:18:08","fk_updatedby":"1","updatedby":"sriram v","isactive":"1","pan":"234111","gst_no":"2111","gst_state_code":"dfwee","tat":"12111","fk_entity_type_id":"2","entity_name":"LENDOR","0":[]}]}
|
||||||
7
ng6-seed/src/app/settings/entity/entity.component.ts
Normal file
7
ng6-seed/src/app/settings/entity/entity.component.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
@Component({
|
||||||
|
template: `<h2>Entity Master Details List</h2>
|
||||||
|
`
|
||||||
|
})
|
||||||
|
export class EntityComponent {
|
||||||
|
}
|
||||||
105
ng6-seed/src/app/settings/entity/entity.module.ts
Normal file
105
ng6-seed/src/app/settings/entity/entity.module.ts
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
|
||||||
|
import { NotifierModule, NotifierOptions } from 'angular-notifier';
|
||||||
|
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||||
|
import {
|
||||||
|
MatCardModule,
|
||||||
|
MatIconModule,
|
||||||
|
MatInputModule,
|
||||||
|
MatRadioModule,
|
||||||
|
MatButtonModule,MatTableModule,MatPaginatorModule,
|
||||||
|
MatProgressBarModule,MatDialogModule, MatSortModule,
|
||||||
|
MatToolbarModule,MatSelectModule,
|
||||||
|
MatListModule, MatMenuModule,
|
||||||
|
MatCheckboxModule
|
||||||
|
} from '@angular/material';
|
||||||
|
import {MatSlideToggleModule} from '@angular/material/slide-toggle';
|
||||||
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
|
|
||||||
|
import { RouterModule } from '@angular/router';
|
||||||
|
import { EntityRouting } from './entity.routing';
|
||||||
|
|
||||||
|
import { EntityComponent } from './entity.component';
|
||||||
|
import { EntityListComponent } from './entity-list/entity.list.component';
|
||||||
|
import { EntityAddComponent } from './entity-add/entity.add.component';
|
||||||
|
import { EntityEditComponent } from './entity-edit/entity.edit.component';
|
||||||
|
|
||||||
|
import { EntityService } from './../service/entity/entity.service';
|
||||||
|
/**
|
||||||
|
* Custom angular notifier options
|
||||||
|
*/
|
||||||
|
const customNotifierOptions: NotifierOptions = {
|
||||||
|
position: {
|
||||||
|
horizontal: {
|
||||||
|
position: 'right',
|
||||||
|
distance: 12
|
||||||
|
},
|
||||||
|
vertical: {
|
||||||
|
position: 'top',
|
||||||
|
distance: 32,
|
||||||
|
gap: 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
theme: 'material',
|
||||||
|
behaviour: {
|
||||||
|
autoHide: 5000,
|
||||||
|
onClick: 'hide',
|
||||||
|
onMouseover: 'pauseAutoHide',
|
||||||
|
showDismissButton: true,
|
||||||
|
stacking: 4
|
||||||
|
},
|
||||||
|
animations: {
|
||||||
|
enabled: true,
|
||||||
|
show: {
|
||||||
|
preset: 'slide',
|
||||||
|
speed: 300,
|
||||||
|
easing: 'ease'
|
||||||
|
},
|
||||||
|
hide: {
|
||||||
|
preset: 'fade',
|
||||||
|
speed: 300,
|
||||||
|
easing: 'ease',
|
||||||
|
offset: 50
|
||||||
|
},
|
||||||
|
shift: {
|
||||||
|
speed: 300,
|
||||||
|
easing: 'ease'
|
||||||
|
},
|
||||||
|
overlap: 150
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
NotifierModule.withConfig(customNotifierOptions),
|
||||||
|
FlexLayoutModule,
|
||||||
|
EntityRouting,
|
||||||
|
MatCardModule,
|
||||||
|
MatIconModule,
|
||||||
|
MatInputModule,
|
||||||
|
MatRadioModule,
|
||||||
|
MatButtonModule,MatTableModule,MatPaginatorModule,
|
||||||
|
MatProgressBarModule,MatDialogModule, MatSortModule,
|
||||||
|
MatToolbarModule,MatSelectModule,MatListModule, MatMenuModule,
|
||||||
|
MatCheckboxModule,
|
||||||
|
MatSlideToggleModule,
|
||||||
|
FormsModule,
|
||||||
|
ReactiveFormsModule
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
EntityComponent,
|
||||||
|
EntityListComponent,
|
||||||
|
EntityEditComponent,
|
||||||
|
EntityAddComponent
|
||||||
|
],
|
||||||
|
entryComponents: [
|
||||||
|
// EntityEditComponent
|
||||||
|
],
|
||||||
|
providers : [
|
||||||
|
EntityService
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
export class EntityModule { }
|
||||||
39
ng6-seed/src/app/settings/entity/entity.routing.ts
Normal file
39
ng6-seed/src/app/settings/entity/entity.routing.ts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { Routes, RouterModule } from '@angular/router';
|
||||||
|
// Entity Component
|
||||||
|
import { EntityComponent } from './entity.component';
|
||||||
|
import { EntityListComponent } from './entity-list/entity.list.component';
|
||||||
|
import { EntityAddComponent } from './entity-add/entity.add.component';
|
||||||
|
import { EntityEditComponent } from './entity-edit/entity.edit.component';
|
||||||
|
/*
|
||||||
|
* Entity Master Router Module details
|
||||||
|
*/
|
||||||
|
const routes: Routes = [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
redirectTo: 'list',
|
||||||
|
pathMatch: 'full',
|
||||||
|
},{
|
||||||
|
path: '',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'list',
|
||||||
|
component: EntityListComponent,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'add',
|
||||||
|
component: EntityAddComponent,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'edit',
|
||||||
|
component: EntityEditComponent,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [RouterModule.forChild(routes)],
|
||||||
|
exports: [RouterModule]
|
||||||
|
})
|
||||||
|
export class EntityRouting {}
|
||||||
101
ng6-seed/src/app/settings/service/entity/entity.service.ts
Normal file
101
ng6-seed/src/app/settings/service/entity/entity.service.ts
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||||
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
import { catchError } from 'rxjs/operators';
|
||||||
|
import { of } from 'rxjs';
|
||||||
|
import 'rxjs/add/operator/map';
|
||||||
|
|
||||||
|
/** Imported Service Files Are., */
|
||||||
|
import { AwsService } from '../../../AwsService/aws.service';
|
||||||
|
/** Consant Value For Created Date And Updated Date */
|
||||||
|
const currentdate = new Date().toJSON().slice(0, 19).replace('T', ' ');
|
||||||
|
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add , Edit, List, Delete Entity Master API service End-point Call Functionality
|
||||||
|
* Kdk
|
||||||
|
*/
|
||||||
|
export class EntityService {
|
||||||
|
private apiUrl = "http://ssa.sineedge.com/sparqapi/api/";
|
||||||
|
private serviceUrl = 'https://jsonplaceholder.typicode.com/users';
|
||||||
|
|
||||||
|
constructor(private _http: HttpClient,
|
||||||
|
private _aws: AwsService) { }
|
||||||
|
|
||||||
|
getUser(): Observable<any> {
|
||||||
|
return this._http.get<any[]>(this.serviceUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get geo location master details list
|
||||||
|
getGeoLocationMasterDetails(): Observable<any> {
|
||||||
|
// Add safe, URL encoded search parameter if there is a search term
|
||||||
|
return this._http.get<any[]>(this.apiUrl + "getLocationHierarchy");
|
||||||
|
}
|
||||||
|
|
||||||
|
// get questions master details list
|
||||||
|
getEntityListMasterDetails(): Observable<any> {
|
||||||
|
// Add safe, URL encoded search parameter if there is a search term
|
||||||
|
return this._http.get<any[]>(this.apiUrl + "listAllEntites/any");
|
||||||
|
}
|
||||||
|
|
||||||
|
// get questions master details list
|
||||||
|
getQuestionMasterDetails(cid: any): Observable<any> {
|
||||||
|
// Add safe, URL encoded search parameter if there is a search term
|
||||||
|
const options = cid ?
|
||||||
|
{ params: new HttpParams().set('cid', cid) } : {};
|
||||||
|
return this._http.get<any[]>(this.apiUrl + "listAllQuestions/get", options);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add question master
|
||||||
|
addEntityMasterDetails(Records: any): Observable<any> {
|
||||||
|
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
|
||||||
|
return this._http.post<any>(this.apiUrl + "saveNewEntity", { 'records': Records})
|
||||||
|
.pipe(
|
||||||
|
catchError(this.handleError('role', []))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// add question master
|
||||||
|
addQuestionMasterDetails(Records: any): Observable<any> {
|
||||||
|
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
|
||||||
|
return this._http.post<any>(this.apiUrl + "saveNewQuestion", { 'records': Records})
|
||||||
|
.pipe(
|
||||||
|
catchError(this.handleError('role', []))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateEntityMasterDetails(Records: any): Observable<any> {
|
||||||
|
Records.fk_updatedby = this._aws.getlocale();//to get user id for who is created the Record
|
||||||
|
Records.updatedon = currentdate;//to get Current date and Time for when the Record is created
|
||||||
|
return this._http.post<any>(this.apiUrl + "saveExistEntity", { 'records': Records})
|
||||||
|
.pipe(
|
||||||
|
catchError(this.handleError('role', []))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateQuestionMasterDetails(Records: any): Observable<any> {
|
||||||
|
Records.fk_updatedby = this._aws.getlocale();//to get user id for who is created the Record
|
||||||
|
Records.updatedon = currentdate;//to get Current date and Time for when the Record is created
|
||||||
|
return this._http.post<any>(this.apiUrl + "saveExistQuestion", { 'records': Records})
|
||||||
|
.pipe(
|
||||||
|
catchError(this.handleError('role', []))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TO Handle The Error
|
||||||
|
*/
|
||||||
|
private handleError<T>(operation = 'operation', result?: T) {
|
||||||
|
|
||||||
|
return (error: any): Observable<T> => {
|
||||||
|
return of(result as T);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -28,12 +28,14 @@ import { RegisterComponent } from '../session/register/register.component';
|
|||||||
import { UserService } from './service/user.service';
|
import { UserService } from './service/user.service';
|
||||||
import { MastersModule } from './masters/masters.module';
|
import { MastersModule } from './masters/masters.module';
|
||||||
|
|
||||||
|
import { EntityModule } from './entity/entity.module';
|
||||||
// import { HttpClientModule } from '@angular/common/http';
|
// import { HttpClientModule } from '@angular/common/http';
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
RouterModule.forChild(SettingsRoutes),MatCardModule,
|
RouterModule.forChild(SettingsRoutes),MatCardModule,
|
||||||
MastersModule,
|
MastersModule,
|
||||||
|
EntityModule,
|
||||||
MatIconModule,
|
MatIconModule,
|
||||||
MatInputModule,
|
MatInputModule,
|
||||||
MatRadioModule,
|
MatRadioModule,
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { Routes } from '@angular/router';
|
import { Routes } from '@angular/router';
|
||||||
import { MastersModule } from './masters/masters.module';
|
import { MastersModule } from './masters/masters.module';
|
||||||
|
import { EntityModule } from './entity/entity.module';
|
||||||
|
|
||||||
export const SettingsRoutes: Routes = [{
|
export const SettingsRoutes: Routes = [{
|
||||||
path: '',
|
path: '',
|
||||||
@ -9,6 +10,9 @@ export const SettingsRoutes: Routes = [{
|
|||||||
},{
|
},{
|
||||||
path:'mastermodule',
|
path:'mastermodule',
|
||||||
loadChildren:'./masters/masters.module#MastersModule'
|
loadChildren:'./masters/masters.module#MastersModule'
|
||||||
|
},{
|
||||||
|
path:'entity',
|
||||||
|
loadChildren:'./entity/entity.module#EntityModule'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}]
|
}]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user