Merge branch 'master' of https://bitbucket.org/sriramv18/sparqsineedge
This commit is contained in:
commit
f997ccfe6d
@ -0,0 +1,25 @@
|
|||||||
|
<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">
|
||||||
|
<mat-list-item role="listitem" *ngFor="let branch of listOfBranch; let i = index;" 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(i)"><mat-icon>delete</mat-icon></span>
|
||||||
|
</mat-list-item>
|
||||||
|
</mat-list>
|
||||||
|
|
||||||
|
<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">
|
||||||
|
<h2 style="color: #ddd; text-align: center;">No Records Found...</h2>
|
||||||
|
</div>
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
.inlist{
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inlist > * {
|
||||||
|
width: 350px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-item {
|
||||||
|
border: 1px solid gray;
|
||||||
|
margin: 2px;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { EntityBranchAddComponent } from './entity-branch-add.component';
|
||||||
|
|
||||||
|
describe('EntityBranchAddComponent', () => {
|
||||||
|
let component: EntityBranchAddComponent;
|
||||||
|
let fixture: ComponentFixture<EntityBranchAddComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ EntityBranchAddComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(EntityBranchAddComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,125 @@
|
|||||||
|
import { Component, ViewChild, OnInit, OnDestroy, Input, Inject } from '@angular/core';
|
||||||
|
import { MatPaginator, MatSort, MatTableDataSource, MatDialog, MatDialogRef, MAT_DIALOG_DATA, PageEvent } from '@angular/material';
|
||||||
|
import { FormGroup, FormControl, FormBuilder, Validators, FormArray } from '@angular/forms';
|
||||||
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import { DataSource } from '@angular/cdk/table';
|
||||||
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
|
||||||
|
import { NotifierService } from 'angular-notifier';
|
||||||
|
|
||||||
|
import { MastersService } from './../../../service/masters/masters.service';
|
||||||
|
import { EntityService } from './../../../service/entity/entity.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-entity-branch-add',
|
||||||
|
templateUrl: './entity-branch-add.component.html',
|
||||||
|
styleUrls: ['./entity-branch-add.component.scss']
|
||||||
|
})
|
||||||
|
export class EntityBranchAddComponent implements OnInit {
|
||||||
|
|
||||||
|
@Input() public entityId: number;
|
||||||
|
public newElement = { name: '' };
|
||||||
|
public listOfBranch = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifier service
|
||||||
|
*/
|
||||||
|
private notifier: NotifierService;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
notifier: NotifierService,
|
||||||
|
private entityService: EntityService,
|
||||||
|
private mastersService: MastersService,
|
||||||
|
private _formBuilder: FormBuilder) {
|
||||||
|
this.notifier = notifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.entityService.getEntityBranchList(this.entityId).subscribe(data => {
|
||||||
|
if (data.dataStatus) {
|
||||||
|
this.listOfBranch = data.records;
|
||||||
|
}
|
||||||
|
}, err => {
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// public listOfBranch = [
|
||||||
|
// {
|
||||||
|
// "entity_lender_branch_id": 1,
|
||||||
|
// "branch_name": "Dev Test Branch 1",
|
||||||
|
// "isactive": "1",
|
||||||
|
// "fk_createdby": "1",
|
||||||
|
// "fk_updatedby": "1",
|
||||||
|
// "fk_entity_id": "1"
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// "entity_lender_branch_id": 2,
|
||||||
|
// "branch_name": "Dev Test Branch 2",
|
||||||
|
// "isactive": "1",
|
||||||
|
// "fk_createdby": "1",
|
||||||
|
// "fk_updatedby": "1",
|
||||||
|
// "fk_entity_id": "1"
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// "entity_lender_branch_id": 3,
|
||||||
|
// "branch_name": "Dev Test Branch 3",
|
||||||
|
// "isactive": "1",
|
||||||
|
// "fk_createdby": "1",
|
||||||
|
// "fk_updatedby": "1",
|
||||||
|
// "fk_entity_id": "1"
|
||||||
|
// }
|
||||||
|
// ];
|
||||||
|
|
||||||
|
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 = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public currentElement = -1;
|
||||||
|
editItem(i): void {
|
||||||
|
this.currentElement = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteItem(i): void {
|
||||||
|
this.listOfBranch.splice(i, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
saveBranch(): void {
|
||||||
|
this.entityService.updateEntityIdBranchInfoDetails(this.listOfBranch).subscribe(data => {
|
||||||
|
if (data.dataStatus) {
|
||||||
|
this.notifier.notify('success', 'Your Changes Updated.!');
|
||||||
|
} else {
|
||||||
|
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||||
|
}
|
||||||
|
}, err => {
|
||||||
|
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
reset(): void {
|
||||||
|
this.listOfBranch = [];
|
||||||
|
this.ngOnInit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// "records": [
|
||||||
|
// {
|
||||||
|
// "entity_lender_branch_id": null,
|
||||||
|
// "branch_name": "Dev Test Branch",
|
||||||
|
// "isactive": "1",
|
||||||
|
// "fk_createdby": "1",
|
||||||
|
// "fk_updatedby": "1",
|
||||||
|
// "fk_entity_id": "1"
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
@ -239,6 +239,12 @@
|
|||||||
<app-entity-edit-tat [entityId]="entity_id">
|
<app-entity-edit-tat [entityId]="entity_id">
|
||||||
</app-entity-edit-tat>
|
</app-entity-edit-tat>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
</mat-tab>
|
||||||
|
<mat-tab label="Branch">
|
||||||
|
<ng-template matTabContent>
|
||||||
|
<app-entity-branch-add [entityId]="entity_id">
|
||||||
|
</app-entity-branch-add>
|
||||||
|
</ng-template>
|
||||||
</mat-tab>
|
</mat-tab>
|
||||||
<!--<mat-tab label="Category">
|
<!--<mat-tab label="Category">
|
||||||
<ng-template matTabContent>
|
<ng-template matTabContent>
|
||||||
|
|||||||
@ -38,6 +38,7 @@ import { EntityEditBillingInfoComponent } from './entity-edit/entity-edit-billin
|
|||||||
|
|
||||||
import { DialogAddEditBillingInfo } from './entity-edit/entity-edit-billing-info/entity-edit-billing-info.component';
|
import { DialogAddEditBillingInfo } from './entity-edit/entity-edit-billing-info/entity-edit-billing-info.component';
|
||||||
import { EntityEditVendorCityInfoComponent } from './entity-edit/entity-edit-vendor-city-info/entity-edit-vendor-city-info.component';
|
import { EntityEditVendorCityInfoComponent } from './entity-edit/entity-edit-vendor-city-info/entity-edit-vendor-city-info.component';
|
||||||
|
import { EntityBranchAddComponent } from './entity-edit/entity-branch-add/entity-branch-add.component';
|
||||||
// import { MatTooltipModule } from '@angular/material/tooltip';
|
// import { MatTooltipModule } from '@angular/material/tooltip';
|
||||||
/**
|
/**
|
||||||
* Custom angular notifier options
|
* Custom angular notifier options
|
||||||
@ -115,7 +116,8 @@ const customNotifierOptions: NotifierOptions = {
|
|||||||
EntityEditPriceComponent,
|
EntityEditPriceComponent,
|
||||||
EntityEditBillingInfoComponent,
|
EntityEditBillingInfoComponent,
|
||||||
DialogAddEditBillingInfo,
|
DialogAddEditBillingInfo,
|
||||||
EntityEditVendorCityInfoComponent
|
EntityEditVendorCityInfoComponent,
|
||||||
|
EntityBranchAddComponent
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
EntityEditComponent,
|
EntityEditComponent,
|
||||||
|
|||||||
@ -165,6 +165,22 @@ export class EntityService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getEntityBranchList(entity_id: any): Observable<any> {
|
||||||
|
// Add safe, URL encoded search parameter if there is a search term
|
||||||
|
const options = entity_id ?
|
||||||
|
{ params: new HttpParams().set('entityid', entity_id) } : {};
|
||||||
|
|
||||||
|
return this._http.get<any[]>(this.apiUrl + "listLenderBranches", options);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateEntityIdBranchInfoDetails(Records: any): Observable<any>{
|
||||||
|
Records.map(data=>{
|
||||||
|
data.fk_updatedby = data.fk_createdby == null ? null : this._aws.getlocale();
|
||||||
|
data.fk_createdby = data.fk_createdby == null ? this._aws.getlocale() : data.fk_createdby;
|
||||||
|
})
|
||||||
|
return this._http.post<any[]>(this.apiUrl + "saveLenderBranches", {'records': Records });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TO Handle The Error
|
* TO Handle The Error
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user