Преглед изворни кода

loan edit moved to ngModel

tags/2.037
Patrick Sun пре 4 година
родитељ
комит
2017cd6c53
18 измењених фајлова са 135 додато и 145 уклоњено
  1. +2
    -1
      src/app/app-routing.module.ts
  2. +1
    -0
      src/app/list-all-loans/list-all-loans.component.html
  3. +8
    -3
      src/app/list-all-loans/list-all-loans.component.ts
  4. +1
    -1
      src/app/loan-edit-people/loan-edit-people.component.ts
  5. +20
    -17
      src/app/loan-edit/basicinfo/basicinfo.component.html
  6. +5
    -60
      src/app/loan-edit/basicinfo/basicinfo.component.ts
  7. +0
    -1
      src/app/loan-edit/loan-edit.component.html
  8. +16
    -11
      src/app/loan-edit/loan-edit.component.ts
  9. +1
    -1
      src/app/loan-edit/people-reward/people-reward.component.html
  10. +4
    -0
      src/app/loan-edit/people-reward/people-reward.component.scss
  11. +3
    -2
      src/app/loan-edit/people-reward/people-reward.component.ts
  12. +15
    -6
      src/app/loan-edit/trail-income/trail-income.component.html
  13. +1
    -0
      src/app/loan-edit/trail-income/trail-income.component.ts
  14. +11
    -11
      src/app/main-menu-items.ts
  15. +42
    -5
      src/app/models/loan.model.ts
  16. +0
    -4
      src/app/people-select/people-select.component.scss
  17. +0
    -15
      src/app/service/auth.service.ts
  18. +5
    -7
      src/app/service/loan.single.service.ts

+ 2
- 1
src/app/app-routing.module.ts Прегледај датотеку

{path : 'transaction', component: TransactionComponent, canActivate: [AuthGuard]}, {path : 'transaction', component: TransactionComponent, canActivate: [AuthGuard]},
{path : 'transaction-list', component: TransactionListComponent, canActivate: [AuthGuard]}, {path : 'transaction-list', component: TransactionListComponent, canActivate: [AuthGuard]},
{path : 'list-all-loans', component: ListAllLoansComponent, }, {path : 'list-all-loans', component: ListAllLoansComponent, },
{path : 'start-a-new-loan', component: LoanEditComponent, },
{path : 'edit-loan/:id', component: LoanEditComponent, },
{path : 'edit-loan', component: LoanEditComponent, },
]; ];


@NgModule({ @NgModule({

+ 1
- 0
src/app/list-all-loans/list-all-loans.component.html Прегледај датотеку

[filterable]="true" [filterable]="true"
(dataStateChange)="dataStateChange($event)" (dataStateChange)="dataStateChange($event)"
(filterChange)="filterChange($event)" (filterChange)="filterChange($event)"
(cellClick)="onCellClick($event)"
class="fullheight_grid" class="fullheight_grid"
> >
<ng-template kendoGridToolbarTemplate> <ng-template kendoGridToolbarTemplate>

+ 8
- 3
src/app/list-all-loans/list-all-loans.component.ts Прегледај датотеку

import {Component, OnInit, ViewChild, ViewEncapsulation} from '@angular/core'; import {Component, OnInit, ViewChild, ViewEncapsulation} from '@angular/core';
import {DataStateChangeEvent, GridComponent, GridDataResult} from '@progress/kendo-angular-grid';
import {CellCloseEvent, DataStateChangeEvent, GridComponent, GridDataResult} from '@progress/kendo-angular-grid';
import {CompositeFilterDescriptor, SortDescriptor, toODataString} from '@progress/kendo-data-query'; import {CompositeFilterDescriptor, SortDescriptor, toODataString} from '@progress/kendo-data-query';
import {LoanSummaryService} from '../service/loan_summary.service'; import {LoanSummaryService} from '../service/loan_summary.service';
import {AuthService} from '../service/auth.service'; import {AuthService} from '../service/auth.service';
import {Observable} from 'rxjs'; import {Observable} from 'rxjs';
import {Router} from '@angular/router';


@Component({ @Component({
selector: 'app-list-all-loans', selector: 'app-list-all-loans',
@ViewChild(GridComponent, { static: true }) public grid: GridComponent; @ViewChild(GridComponent, { static: true }) public grid: GridComponent;




constructor(private service: LoanSummaryService, private auth: AuthService) { }
constructor(private service: LoanSummaryService, private auth: AuthService, private router: Router) { }


public ngOnInit(): void { public ngOnInit(): void {
// Bind directly to the service as it is a Subject // Bind directly to the service as it is a Subject
this.loadData(); this.loadData();


// Expand the first row initially // Expand the first row initially
//this.grid.expandRow(0);
// this.grid.expandRow(0);
} }


public filterChange(filter: CompositeFilterDescriptor): void { public filterChange(filter: CompositeFilterDescriptor): void {
return this.service.queryAll({skip: 0, take: 999999, sort: this.sort, filter: this.filter}); return this.service.queryAll({skip: 0, take: 999999, sort: this.sort, filter: this.filter});
} }


public onCellClick(event: CellCloseEvent): void {
this.router.navigate(['/edit-loan/' + event.dataItem.Id]);
}

} }

+ 1
- 1
src/app/loan-edit-people/loan-edit-people.component.ts Прегледај датотеку

} }


console.log(this.Loan.Client, this.Loan.Broker, this.Loan.OtherRewarder, this.role); console.log(this.Loan.Client, this.Loan.Broker, this.Loan.OtherRewarder, this.role);
this.ps.syncPeople(this.Loan).subscribe( resp => {});
this.ps.syncPeople(this.Loan.cloneForJson()).subscribe( resp => {});
this.NotifyNext.emit(true); this.NotifyNext.emit(true);
} }



+ 20
- 17
src/app/loan-edit/basicinfo/basicinfo.component.html Прегледај датотеку

<div class="row"> <div class="row">
<div class="col-sm-9"> <div class="col-sm-9">
<form class="k-form" [formGroup]="basicInfo" (ngSubmit)="next()">
<form class="k-form" >
<ng-container > <ng-container >
<fieldset class="k-form-fieldset"> <fieldset class="k-form-fieldset">
<legend class="k-form-legend"></legend> <legend class="k-form-legend"></legend>
<kendo-formfield> <kendo-formfield>
<kendo-label [for]="LoanId" text="Loan ID"></kendo-label> <kendo-label [for]="LoanId" text="Loan ID"></kendo-label>
<input formControlName="LoanId" kendoTextBox #LoanId />
<input kendoTextBox #LoanId readonly name="LoanId" [(ngModel)]="Loan.Id" [ngModelOptions]="{standalone: true}"/>


<kendo-formhint>Unique transaction <kendo-formhint>Unique transaction
ID from SuperCredit (Auto generated when save, cannot be changed) </kendo-formhint> ID from SuperCredit (Auto generated when save, cannot be changed) </kendo-formhint>
<kendo-label [for]="Status" [text]="'Progress Status'" ></kendo-label> <kendo-label [for]="Status" [text]="'Progress Status'" ></kendo-label>
<kendo-dropdownlist <kendo-dropdownlist
#Status #Status
formControlName="Status"
name ="Status"
[data]="listLoanStatus" [data]="listLoanStatus"
[defaultItem]="{ text: 'Select Status', value: null }" [defaultItem]="{ text: 'Select Status', value: null }"
[textField]="'text'" [textField]="'text'"
[valueField]="'value'" [valueField]="'value'"
required required
[valuePrimitive] = "true" [valuePrimitive] = "true"
[(ngModel)] = "Loan.Status"
[ngModelOptions]="{standalone: true}"
> >
</kendo-dropdownlist> </kendo-dropdownlist>
<kendo-formhint>cannot be changed after settlement</kendo-formhint> <kendo-formhint>cannot be changed after settlement</kendo-formhint>
<kendo-formfield> <kendo-formfield>
<kendo-label [for]="Lender" text="Lender Organization"> <kendo-label [for]="Lender" text="Lender Organization">
</kendo-label> </kendo-label>
<kendo-textbox (valueChange)="onLenderNameChange($event)"
formControlName="Lender" #Lender
[clearButton]="true"
></kendo-textbox>
<kendo-formhint>E.g. NAB Bank, cannot be changed after settlement</kendo-formhint>
<kendo-textbox name="Lender" [(ngModel)] = "Loan.Lender" #Lender [clearButton]="true"
disabled> </kendo-textbox>
<kendo-formhint>info determined by trail income info</kendo-formhint>
<kendo-formerror>Error: Lender is required</kendo-formerror> <kendo-formerror>Error: Lender is required</kendo-formerror>
</kendo-formfield> </kendo-formfield>
<div class="vertical-spacer"></div> <div class="vertical-spacer"></div>
<kendo-formfield> <kendo-formfield>
<kendo-label [for]="Item" text="Loan Target"> <kendo-label [for]="Item" text="Loan Target">
</kendo-label> </kendo-label>
<kendo-textbox formControlName="Item" #Item [clearButton]="true" ></kendo-textbox>
<kendo-textbox #Item name="Item" [clearButton]="true" [(ngModel)]="Loan.Item" required minlength="1" maxlength="120"
[ngModelOptions]="{standalone: true}"></kendo-textbox>
<kendo-formhint>E.g. 333 Opera House, Sydney Road, NSW 2000 , cannot be changed after settlement</kendo-formhint> <kendo-formhint>E.g. 333 Opera House, Sydney Road, NSW 2000 , cannot be changed after settlement</kendo-formhint>
<kendo-formerror>Loan Target is required</kendo-formerror> <kendo-formerror>Loan Target is required</kendo-formerror>
</kendo-formfield> </kendo-formfield>




<kendo-formfield> <kendo-formfield>
<kendo-label [for]="Amount" text="Loan Limit"> </kendo-label>
<kendo-numerictextbox formControlName="Amount" #Amount [min]="100" [max]="1000000000" [format]="'c0'"></kendo-numerictextbox>
<kendo-label [for]="Amount" text="Loan Limit"> </kendo-label>
<kendo-numerictextbox #Amount name="Amount" [min]="100" [max]="1000000000" [format]="'c0'" [(ngModel)]="Loan.Amount"></kendo-numerictextbox>
<kendo-formhint>E.g. 80000, cannot be changed after settlement</kendo-formhint> <kendo-formhint>E.g. 80000, cannot be changed after settlement</kendo-formhint>
<kendo-formerror>Error: Limit should be between 100 ~ 1,000,000,000</kendo-formerror> <kendo-formerror>Error: Limit should be between 100 ~ 1,000,000,000</kendo-formerror>
</kendo-formfield> </kendo-formfield>


<kendo-formfield> <kendo-formfield>
<kendo-label [for]="Settlement" [optional]="false" text="Settlement Date"></kendo-label> <kendo-label [for]="Settlement" [optional]="false" text="Settlement Date"></kendo-label>
<kendo-datepicker #Settlement formControlName="Settlement"
<kendo-datepicker #Settlement name="Settlement"
[(ngModel)]="Loan.Settlement"
[min]="minSettlement" [max]="maxSettlement"> [min]="minSettlement" [max]="maxSettlement">
</kendo-datepicker> </kendo-datepicker>
<kendo-formhint>Date Settled</kendo-formhint>
<kendo-formhint>Date settled or expected to be settled</kendo-formhint>
</kendo-formfield> </kendo-formfield>
<bkp-divider-shadow-bottom></bkp-divider-shadow-bottom> <bkp-divider-shadow-bottom></bkp-divider-shadow-bottom>




<kendo-formfield> <kendo-formfield>
<kendo-label [for]="Description" [optional]="false" <kendo-label [for]="Description" [optional]="false"
text="Quick notes: ( < 1000 words ) " (click)="showDemoDescription($event)"></kendo-label>
<kendo-editor #Description formControlName="Description" style="height: 500px;" ></kendo-editor>
text="Quick notes: ( < 1000 words ) "
(click)="showDemoDescription($event)"></kendo-label>
<kendo-editor #Description name="description" style="height: 500px;" [(ngModel)]="Loan.Description"></kendo-editor>
</kendo-formfield> </kendo-formfield>
<bkp-divider-shadow-bottom></bkp-divider-shadow-bottom> <bkp-divider-shadow-bottom></bkp-divider-shadow-bottom>
<div class="vertical-spacer"></div> <div class="vertical-spacer"></div>
<kendo-formfield> <kendo-formfield>
<kendo-label [for]="Rating" [optional]="false" <kendo-label [for]="Rating" [optional]="false"
text="Rating: " (click)="showDemoDescription($event)"></kendo-label> text="Rating: " (click)="showDemoDescription($event)"></kendo-label>
<app-rating-input #Rating formControlName="Rating" ></app-rating-input>
<app-rating-input #Rating name="rating" [(ngModel)]="Loan.Rating" ></app-rating-input>
</kendo-formfield> </kendo-formfield>


</fieldset> </fieldset>
</ng-container> </ng-container>
<div class="k-form-buttons k-buttons-end"> <div class="k-form-buttons k-buttons-end">
<div> <div>
<button class="k-button k-primary" type="submit" >Next ▶ </button>
<button class="k-button k-primary" type="submit" (click)="next()" >Next ▶ </button>
</div> </div>
</div> </div>
</form> </form>

+ 5
- 60
src/app/loan-edit/basicinfo/basicinfo.component.ts Прегледај датотеку

constructor( private service: LoanSingleService) { } constructor( private service: LoanSingleService) { }


@Input() Loan: LoanModel; @Input() Loan: LoanModel;
@Output() lenderNameChanged = new EventEmitter<string>();
@Output() NotifyNext = new EventEmitter<boolean>(); @Output() NotifyNext = new EventEmitter<boolean>();
@Output() errorOccurred = new EventEmitter<string>(); @Output() errorOccurred = new EventEmitter<string>();


public minSettlement: Date = new Date(2015, 0, 1); public minSettlement: Date = new Date(2015, 0, 1);
public maxSettlement: Date = new Date(2030, 4, 31); public maxSettlement: Date = new Date(2030, 4, 31);


public basicInfo: FormGroup ;

public DemoDescription = ` public DemoDescription = `
<h1> Rich Text Editing </h1> <h1> Rich Text Editing </h1>
<table> <table>
]; ];


ngOnInit(): void { ngOnInit(): void {
this.basicInfo = new FormGroup({
LoanId: new FormControl({value: this.Loan.Id, disabled: true}),
Status: new FormControl(),
Item: new FormControl(this.Loan.Item, Validators.required),
Lender : new FormControl({value: 'SuperCredit', disabled: false}, Validators.required),
Amount: new FormControl(100, [Validators.required , Validators.min(100), Validators.max(1000000000)]),
Settlement: new FormControl(new Date(2020, 0, 9)),
Description: new FormControl( '', Validators.maxLength(2000)),
Rating: new FormControl({value: this.Loan.Rating, disabled: false}),
});
this.LoadBasic();
}

onLenderNameChange(value: string): void {
console.log('emit lender change');
this.lenderNameChanged.emit(value);
} }


public next(): void { public next(): void {
this.basicInfo.markAllAsTouched();
// console.log(this.basicInfo, this.Loan);
this.Loan.Lender = this.basicInfo.value.Lender;
this.Loan.Status = this.basicInfo.value.Status;
this.Loan.Item = this.basicInfo.value.Item;
this.Loan.Amount = this.basicInfo.value.Amount;
this.Loan.Settlement = this.basicInfo.value.Settlement;
this.Loan.Description = this.basicInfo.value.Description;
this.Loan.Rating = this.basicInfo.value.Rating;
this.service.updateBasicInfo(this.Loan).subscribe( this.service.updateBasicInfo(this.Loan).subscribe(
resp => { resp => {
// console.log(resp);
// move to next step
if ( this.Loan.Id === '' ) {
this.Loan.Id = resp.Id;
}
this.NotifyNext.emit(true); this.NotifyNext.emit(true);
}, },
err => { err => {
); );
} }


public loanStatus(value: string): {text: string, value: string} {
this.listLoanStatus.forEach(( v) => {
if (v.value = value) {
return v;
}
});
return null;
}

public showDemoDescription($event): void{ public showDemoDescription($event): void{
this.basicInfo.get('Description').setValue(this.DemoDescription);
}
public LoadBasic(): void {
if (this.Loan === undefined) {
return ;
}
this.basicInfo.get('LoanId').setValue(this.Loan.Id);
this.basicInfo.get('Lender').setValue(this.Loan.Lender);
this.lenderNameChanged.emit(this.basicInfo.get('Lender').value);
this.basicInfo.get('Status').setValue(this.Loan.Status);
this.basicInfo.get('Item').setValue(this.Loan.Item);
this.basicInfo.get('Amount').setValue(this.Loan.Amount);
this.basicInfo.get('Settlement').setValue(this.Loan.Settlement);
this.basicInfo.get('Description').setValue(this.Loan.Description);
this.basicInfo.get('Rating').setValue(this.Loan.Rating);
return ;
if ( this.Loan.Status === 'Settled') {
this.basicInfo.get('Status').disable({onlySelf: true, emitEvent: false});
this.basicInfo.get('Item').disable({onlySelf: true, emitEvent: false});
this.basicInfo.get('Amount').disable({onlySelf: true, emitEvent: false});
}
this.Loan.Description = this.DemoDescription;
} }

} }

+ 0
- 1
src/app/loan-edit/loan-edit.component.html Прегледај датотеку

<app-loan-basic-info *ngIf="currentStep === 0" <app-loan-basic-info *ngIf="currentStep === 0"
#basicInfo #basicInfo
[Loan]="Loan" [Loan]="Loan"
(lenderNameChanged)="onLenderNameChange($event)"
(NotifyNext) ="next(0, $event)" (NotifyNext) ="next(0, $event)"
(errorOccurred)="showError($event)" (errorOccurred)="showError($event)"
></app-loan-basic-info> ></app-loan-basic-info>

+ 16
- 11
src/app/loan-edit/loan-edit.component.ts Прегледај датотеку

import {LoanSingleService} from '../service/loan.single.service'; import {LoanSingleService} from '../service/loan.single.service';
import {LoanModel} from '../models/loan.model'; import {LoanModel} from '../models/loan.model';
import {BasicinfoComponent} from './basicinfo/basicinfo.component'; import {BasicinfoComponent} from './basicinfo/basicinfo.component';
import {ActivatedRoute} from '@angular/router';
import {AuthService} from '../service/auth.service';




@Component({ @Component({




public Loan: LoanModel = new LoanModel(''); public Loan: LoanModel = new LoanModel('');
public LenderName: string;
public curStepSuccess = false; public curStepSuccess = false;


public showDelete = false; public showDelete = false;
public dialogOpened = false; public dialogOpened = false;
public errorMessage = ''; public errorMessage = '';


constructor( private lss: LoanSingleService) { }
constructor( private lss: LoanSingleService, private actRoute: ActivatedRoute, private auth: AuthService) { }


// public get currentStepError(): boolean{ // public get currentStepError(): boolean{
// const ret = false; // TODO: set the value // const ret = false; // TODO: set the value
this.currentStep -= 1; this.currentStep -= 1;
} }


public onLenderNameChange(value: string): void{
this.LenderName = value;
}



ngOnInit(): void { ngOnInit(): void {
const demoId = '049836b8-07ad-448a-b048-865e8e85f1fe';
this.loadLoanById(demoId);
const LoanId = this.actRoute.snapshot.params.id;
if ( LoanId !== undefined && LoanId.length > 10 ) {
this.loadLoanById(LoanId);
}else{
this.startNewLoan();
}
} }


public del(): void { public del(): void {


public loadLoanById(id: string): void { public loadLoanById(id: string): void {
const self = this; const self = this;
console.log('loading loan ', this.Loan.Id);
console.log('loading loan for edit ... ', id);
this.lss.getLoan(id).subscribe( this.lss.getLoan(id).subscribe(
resp => { resp => {
this.Loan.Response = resp; this.Loan.Response = resp;
this.Loan.apiUrlFunc = self.lss.apiUrlFunc();
this.Loan.auth = this.auth;
this.Loan.lss = this.lss;
self.LoanUpdated.emit(this.Loan); self.LoanUpdated.emit(this.Loan);
self.basicInfo.LoadBasic();
} }
); );
} }


public startNewLoan(): void{
this.Loan = LoanModel.EmptyNew(this.lss, this.auth);
}

public action(status): void { public action(status): void {
this.dialogOpened = false; this.dialogOpened = false;
} }

+ 1
- 1
src/app/loan-edit/people-reward/people-reward.component.html Прегледај датотеку

(remove)="removeHandler($event)" (remove)="removeHandler($event)"
> >
<ng-template kendoGridToolbarTemplate> <ng-template kendoGridToolbarTemplate>
<button kendoGridAddCommand icon="plus" [primary]="true">Add new</button>
<button kendoGridAddCommand icon="plus" [primary]="true" class="toolbarAddNew">Add new</button>
</ng-template> </ng-template>


<kendo-grid-command-column title="action" width="80"> <kendo-grid-command-column title="action" width="80">

+ 4
- 0
src/app/loan-edit/people-reward/people-reward.component.scss Прегледај датотеку

margin-right: 8px; margin-right: 8px;
border-radius: 50%; border-radius: 50%;
} }

.toolbarAddNew {
margin-bottom:100px;
}

+ 3
- 2
src/app/loan-edit/people-reward/people-reward.component.ts Прегледај датотеку

Amount: 0, Amount: 0,
Description: '', Description: '',
PayOutId: 0, PayOutId: 0,
Ts: new Date()
}); });


sender.addRow(this.formGroup); sender.addRow(this.formGroup);
this.formGroup = createFormGroup(dataItem); this.formGroup = createFormGroup(dataItem);
this.editedRowIndex = rowIndex; this.editedRowIndex = rowIndex;
sender.editRow(rowIndex, this.formGroup); sender.editRow(rowIndex, this.formGroup);
console.log('editing' , dataItem, this.formGroup);
// console.log('editing' , dataItem, this.formGroup);
} }


public cancelHandler({ sender, rowIndex }): void{ public cancelHandler({ sender, rowIndex }): void{
this.pendingReward[idx].Description = reward.Description; this.pendingReward[idx].Description = reward.Description;
this.pendingReward[idx].Ts = reward.Ts; this.pendingReward[idx].Ts = reward.Ts;
} }
console.log(resp);
// console.log(resp);
} }


); );

+ 15
- 6
src/app/loan-edit/trail-income/trail-income.component.html Прегледај датотеку

<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-12">
<form class="k-form"> <form class="k-form">
<ng-container [formGroup]="trailIncome">
<bkp-divider><kendo-icon [name]="'file-pdf'"> </kendo-icon>&nbsp;Record from {{LenderName}} </bkp-divider>
<ng-container >
<bkp-divider><kendo-icon [name]="'file-pdf'"> </kendo-icon>&nbsp;Record from {{Loan.Lender}} </bkp-divider>
<div style="text-align: center">
<kendo-chip label="SuperCredit Loan ID {{Loan.Id}}" [removable]="false" > </kendo-chip>
</div>

<div class="vertical-spacer"></div>


<kendo-label [for]="LoanIdLabel" text="SuperCredit Loan ID"></kendo-label>
<p #LoanIdLabel> {{Loan.Id}} </p>
<kendo-formfield>
<kendo-label [for]="Lender" text="Fund Supplier's Name"></kendo-label>
<input #Lender name="Lender" kendoTextBox [(ngModel)]="Loan.Lender" />
<kendo-formhint>Unique Name for a fund provider </kendo-formhint>
<kendo-formerror>Error: Lender name is required</kendo-formerror>
</kendo-formfield>
<div class="vertical-spacer"></div> <div class="vertical-spacer"></div>


<kendo-formfield> <kendo-formfield>
<kendo-label [for]="LenderLoanNumber" text="Fund Supplier's Loan Identification"></kendo-label> <kendo-label [for]="LenderLoanNumber" text="Fund Supplier's Loan Identification"></kendo-label>
<input #LenderLoanNumber formControlName="LenderLoanNumber" kendoTextBox />
<kendo-formhint>Unique transaction ID from Funds supplier </kendo-formhint>
<input #LenderLoanNumber name="LenderLoanNumber" [(ngModel)]="Loan.LenderLoanNumber" kendoTextBox />
<kendo-formhint>Unique transaction ID from Funds supplier </kendo-formhint>
<kendo-formerror>Error: the ID is required</kendo-formerror> <kendo-formerror>Error: the ID is required</kendo-formerror>
</kendo-formfield> </kendo-formfield>
<div class="vertical-spacer"></div> <div class="vertical-spacer"></div>

+ 1
- 0
src/app/loan-edit/trail-income/trail-income.component.ts Прегледај датотеку



public trailIncome: FormGroup = new FormGroup({ public trailIncome: FormGroup = new FormGroup({
LenderLoanNumber: new FormControl(), LenderLoanNumber: new FormControl(),
Lender: new FormControl(),
}); });


constructor() { } constructor() { }

+ 11
- 11
src/app/main-menu-items.ts Прегледај датотеку

icon: 'more-vertical', icon: 'more-vertical',
items: [ items: [
{ text: 'Summary', fa: faChartArea, url: './#dashboard'}, { text: 'Summary', fa: faChartArea, url: './#dashboard'},
{ text: '--', separator: "true" },
{ text: '--', separator: 'true' },
{ text: 'Logout', icon: 'logout', url: './#login'}] { text: 'Logout', icon: 'logout', url: './#login'}]
}, },
{ {
text: 'Loans', text: 'Loans',
icon: 'dollar', icon: 'dollar',
items: [ items: [
{ text: 'Start New Loan', icon: 'plus', url: "./#start-a-new-loan" },
{ text: 'List All New', icon: 'table' ,url: './#list-all-loans' },
{ text: 'Start New Loan', icon: 'plus', url: './#edit-loan/' },
{ text: 'List All New', icon: 'table' , url: './#list-all-loans' },
] ]
}, },
{ {
items: [ items: [
{ text: 'List All', icon: 'table', url: '#' }, { text: 'List All', icon: 'table', url: '#' },
{ text: 'By Broker', icon: 'table', url: '#' }, { text: 'By Broker', icon: 'table', url: '#' },
{ text: '--', separator: "true" },
{ text: '--', separator: 'true' },
{ text: 'PaidImport From ...', icon : 'upload'} { text: 'PaidImport From ...', icon : 'upload'}
] ]
}, },
items: [ items: [
{ text: 'Add ', icon: 'plus', url: '#' }, { text: 'Add ', icon: 'plus', url: '#' },
{ text: 'List All', fa: faIdCard }, { text: 'List All', fa: faIdCard },
{ text: '--', separator: "true" },
{ text: 'Search' ,icon: 'search'},
{ text: '--', separator: "true" },
{ text: 'Broadcast', icon:'email' },
{ text: '--', separator: 'true' },
{ text: 'Search' , icon: 'search'},
{ text: '--', separator: 'true' },
{ text: 'Broadcast', icon: 'email' },
] ]
}, },


items: [ items: [
{ text: 'Add ', icon: 'plus', url: '#' }, { text: 'Add ', icon: 'plus', url: '#' },
{ text: 'List All', fa: faIdCardAlt}, { text: 'List All', fa: faIdCardAlt},
{ text: '--', separator: "true" },
{ text: '--', separator: 'true' },
{ text: 'Search' , icon: 'search'}, { text: 'Search' , icon: 'search'},
{ text: '--', separator: "true" },
{ text: '--', separator: 'true' },
{ text: 'Broadcast' , icon : 'email'}, { text: 'Broadcast' , icon : 'email'},
{ text: '--', separator: "true" },
{ text: '--', separator: 'true' },
{ text: 'UnPaid', fa : faMoneyCheck }, { text: 'UnPaid', fa : faMoneyCheck },
] ]
} }

+ 42
- 5
src/app/models/loan.model.ts Прегледај датотеку

import {BrokerModel} from './broker.model'; import {BrokerModel} from './broker.model';
import {PayInModel} from './pay-in.model'; import {PayInModel} from './pay-in.model';
import {RewardModel} from './reward.model'; import {RewardModel} from './reward.model';
import {ApiUrL} from '../service/auth.service';
import {AuthService} from '../service/auth.service';
import {LoanSingleService} from '../service/loan.single.service';


export interface LoanModelCallBacks { export interface LoanModelCallBacks {
getUserName(userId: string): string; getUserName(userId: string): string;
public Description?: string, public Description?: string,


public Lender?: string, public Lender?: string,
public LenderLoanNumber?: string,
public Client?: PeopleModel[], public Client?: PeopleModel[],
public Broker?: BrokerModel[], public Broker?: BrokerModel[],
public OtherRewarder?: PeopleModel[], public OtherRewarder?: PeopleModel[],
public PayIn?: PayInModel[], public PayIn?: PayInModel[],
public PeopleMap?: PeopleMapModel[], public PeopleMap?: PeopleMapModel[],


public apiUrlFunc?: ApiUrL
public auth?: AuthService,
public lss?: LoanSingleService
){} ){}


public static EmptyNew(lss: LoanSingleService, auth: AuthService): LoanModel {
const nLoan = new LoanModel(
'', 0 , '', '', 0, new Date(), '',
'', '', [], [], [], [], [], [], [],
auth, lss
);
return nLoan;
}


public set Response(resp: LoanModel) { public set Response(resp: LoanModel) {
this.Id = resp.Id; this.Id = resp.Id;


this.Description = resp.Description; this.Description = resp.Description;


this.Lender = resp.Lender; this.Lender = resp.Lender;
this.LenderLoanNumber = resp.LenderLoanNumber;


this.setClient(resp.Client); this.setClient(resp.Client);
this.setBroker(resp.Broker); this.setBroker(resp.Broker);


private setClient(v: any[]): void{ private setClient(v: any[]): void{
this.Client = []; this.Client = [];
v.forEach((c) =>{
v.forEach((c) => {
this.Client.push( this.Client.push(
new PeopleModel(c.Id, c.First, c.Last, c.Middle, c.Title, c.Display, c.Nick) new PeopleModel(c.Id, c.First, c.Last, c.Middle, c.Title, c.Display, c.Nick)
); );


private setOtherRewarder(v: any[]): void{ private setOtherRewarder(v: any[]): void{
this.OtherRewarder = []; this.OtherRewarder = [];
v.forEach((c) =>{
v.forEach((c) => {
this.OtherRewarder.push( this.OtherRewarder.push(
new PeopleModel(c.Id, c.First, c.Last, c.Middle, c.Title, c.Display, c.Nick) new PeopleModel(c.Id, c.First, c.Last, c.Middle, c.Title, c.Display, c.Nick)
); );
} }


public getUserPhotoUrl(id: string): string { public getUserPhotoUrl(id: string): string {
const url = this.apiUrlFunc.getUrl('avatar/') + id;
const url = this.auth.getUrl('avatar/') + id;
return 'url("' + url + '")'; return 'url("' + url + '")';
} }


return role; return role;
} }


// remove auth serivce and lss service for Json.stringify
public cloneForJson(): LoanModel {
return new LoanModel(
this.Id,
this.Amount,
this.Status,
this.Item,
this.Rating,
this.Settlement,
this.Description,
this.Lender,
this.LenderLoanNumber,
this.Client,
this.Broker,
this.OtherRewarder,
this.Reward,
this.RewardPeople,
this.PayIn,
this.PeopleMap,
undefined,
undefined
);
}
} }

+ 0
- 4
src/app/people-select/people-select.component.scss Прегледај датотеку

margin-right: 8px; margin-right: 8px;
border-radius: 50%; border-radius: 50%;
} }

.toolbarAddNew{
padding-bottom: 20px
}

+ 0
- 15
src/app/service/auth.service.ts Прегледај датотеку

import {EventEmitter, Injectable, OnDestroy, OnInit} from '@angular/core'; import {EventEmitter, Injectable, OnDestroy, OnInit} from '@angular/core';
import { NotificationService } from '@progress/kendo-angular-notification';
import {HttpClient, HttpEvent, HttpHandler, HttpInterceptor, HttpParams, HttpRequest} from '@angular/common/http'; import {HttpClient, HttpEvent, HttpHandler, HttpInterceptor, HttpParams, HttpRequest} from '@angular/common/http';
import {apiV1LoginResponse} from '../models/api-v1-login-response'; import {apiV1LoginResponse} from '../models/api-v1-login-response';
import {Observable} from 'rxjs';
import {AppComponent} from '../app.component';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
import {PeopleModel} from '../models/people.model';

export interface ApiUrL {
getUrl(key: string): string;
};


@Injectable() @Injectable()
export class AuthService { export class AuthService {
// not found if arrive here // not found if arrive here
return s; return s;
} }

public apiUrlFunc(): ApiUrL {
return {
getUrl: this.getUrl.bind(this)
};
}

} }

+ 5
- 7
src/app/service/loan.single.service.ts Прегледај датотеку

import {HttpClient} from '@angular/common/http'; import {HttpClient} from '@angular/common/http';
import {ApiUrL, AuthService} from './auth.service';
import {AuthService} from './auth.service';
import {Observable} from 'rxjs'; import {Observable} from 'rxjs';
import {LoanModel} from '../models/loan.model'; import {LoanModel} from '../models/loan.model';
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {RewardModel} from '../models/reward.model'; import {RewardModel} from '../models/reward.model';
import {ClonerService} from './clone.service';


@Injectable() @Injectable()
export class LoanSingleService { export class LoanSingleService {


constructor(private http: HttpClient, private auth: AuthService ){ }
constructor(private http: HttpClient, private auth: AuthService, private dcs: ClonerService ){ }


getLoan(loanId: string): Observable<LoanModel> { getLoan(loanId: string): Observable<LoanModel> {
return this.http.get<LoanModel>(this.auth.getUrl('loan/' + loanId)); return this.http.get<LoanModel>(this.auth.getUrl('loan/' + loanId));
} }


public updateBasicInfo(loan: LoanModel): Observable<any>{ public updateBasicInfo(loan: LoanModel): Observable<any>{
return this.http.post(this.auth.getUrl('loan/basic/' + loan.Id), loan);
return this.http.post(this.auth.getUrl('loan/basic/' + loan.Id), loan.cloneForJson());
} }


public photoUrl(peopleId: string): string{ public photoUrl(peopleId: string): string{
return 'url("' + url + '")'; return 'url("' + url + '")';
} }


public apiUrlFunc(): ApiUrL {
return this.auth.apiUrlFunc();
}

public saveReward(reward: RewardModel, isNew: boolean ): Observable<RewardModel> { public saveReward(reward: RewardModel, isNew: boolean ): Observable<RewardModel> {
console.log('saving', reward, isNew, this); console.log('saving', reward, isNew, this);
return this.http.post<RewardModel>(this.auth.getUrl('reward/'), reward); return this.http.post<RewardModel>(this.auth.getUrl('reward/'), reward);
} }
); );
} }

} }

Loading…
Откажи
Сачувај