|
|
|
|
|
|
|
|
import {Component, Input, OnInit} from '@angular/core'; |
|
|
import {Component, Input, OnInit} from '@angular/core'; |
|
|
import {PayInModel} from '../models/pay-in.model'; |
|
|
import {PayInModel} from '../models/pay-in.model'; |
|
|
import {FormControl, FormGroup, Validators} from '@angular/forms'; |
|
|
import {FormControl, FormGroup, Validators} from '@angular/forms'; |
|
|
|
|
|
import {PayInListFilterModel} from '../models/pay-in-list.filter.model'; |
|
|
|
|
|
import {PayInService} from '../service/pay-in.service'; |
|
|
|
|
|
import {PayInListResult} from '../models/pay-in-list-result.model'; |
|
|
|
|
|
|
|
|
const createFormGroup = dataItem => new FormGroup({ |
|
|
const createFormGroup = dataItem => new FormGroup({ |
|
|
Id: new FormControl({value: dataItem.Id, disabled: true}, Validators.required), |
|
|
Id: new FormControl({value: dataItem.Id, disabled: true}, Validators.required), |
|
|
|
|
|
|
|
|
styleUrls: ['./pay-in.component.scss'] |
|
|
styleUrls: ['./pay-in.component.scss'] |
|
|
}) |
|
|
}) |
|
|
export class PayInComponent implements OnInit { |
|
|
export class PayInComponent implements OnInit { |
|
|
@Input() public AllPayIn: PayInModel[] = []; |
|
|
|
|
|
public formGroup: FormGroup; |
|
|
|
|
|
|
|
|
@Input() loanFilter: string[] = []; |
|
|
|
|
|
@Input() uploadsFilter: string[] = []; |
|
|
|
|
|
@Input() allowAddNew = false; // TODO: |
|
|
|
|
|
@Input() allowEdit = false; // TODO: |
|
|
|
|
|
@Input() pageSize = 10; |
|
|
|
|
|
@Input() skip = 0; |
|
|
|
|
|
@Input() dateStart = new Date('1900-01-01'); |
|
|
|
|
|
@Input() dateEnd = new Date('2038-12-31'); |
|
|
|
|
|
|
|
|
|
|
|
public gridData: PayInListResult = { data: [], total: 0}; |
|
|
|
|
|
public incomeFormGroup: FormGroup; |
|
|
private editedRowIndex: number; |
|
|
private editedRowIndex: number; |
|
|
|
|
|
|
|
|
public trailIncome: FormGroup; |
|
|
|
|
|
public showBalance = true; |
|
|
public showBalance = true; |
|
|
public showOffsetBalance = true; |
|
|
public showOffsetBalance = true; |
|
|
|
|
|
|
|
|
public splitButtonItems: Array<any> = [{ |
|
|
|
|
|
text: 'Keep Text Only', |
|
|
|
|
|
icon: 'paste-plain-text', |
|
|
|
|
|
click: () => { console.log('Keep Text Only click handler'); } |
|
|
|
|
|
}, { |
|
|
|
|
|
text: 'Paste as HTML', |
|
|
|
|
|
icon: 'paste-as-html' |
|
|
|
|
|
}, { |
|
|
|
|
|
text: 'Paste Markdown', |
|
|
|
|
|
icon: 'paste-markdown' |
|
|
|
|
|
}, { |
|
|
|
|
|
text: 'Set Default Paste' |
|
|
|
|
|
}]; |
|
|
|
|
|
|
|
|
|
|
|
constructor() { } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(private pis: PayInService) { } |
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
ngOnInit(): void { |
|
|
|
|
|
this.pis.getPayInList(new PayInListFilterModel()).subscribe( |
|
|
|
|
|
( resp: PayInListResult) => { |
|
|
|
|
|
console.log(resp); |
|
|
|
|
|
this.gridData = resp; |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// this.showBalance = balance >= 0 ; |
|
|
// this.showBalance = balance >= 0 ; |
|
|
// this.showOffsetBalance = offsetBalance >= 0 ; |
|
|
// this.showOffsetBalance = offsetBalance >= 0 ; |
|
|
|
|
|
|
|
|
this.formGroup = createFormGroup({ |
|
|
|
|
|
|
|
|
this.incomeFormGroup = createFormGroup({ |
|
|
Id: 0, |
|
|
Id: 0, |
|
|
Trail: 168, |
|
|
Trail: 168, |
|
|
Ts: new Date(), |
|
|
Ts: new Date(), |
|
|
|
|
|
|
|
|
OffsetBalance: offsetBalance |
|
|
OffsetBalance: offsetBalance |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
sender.addRow(this.formGroup); |
|
|
|
|
|
|
|
|
sender.addRow(this.incomeFormGroup); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public editHandler({ sender, rowIndex, dataItem }): void { |
|
|
public editHandler({ sender, rowIndex, dataItem }): void { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.showBalance = dataItem.Balance >= 0 ; |
|
|
this.showBalance = dataItem.Balance >= 0 ; |
|
|
this.showOffsetBalance = dataItem.OffsetBalance >= 0 ; |
|
|
this.showOffsetBalance = dataItem.OffsetBalance >= 0 ; |
|
|
this.formGroup = createFormGroup(dataItem); |
|
|
|
|
|
|
|
|
this.incomeFormGroup = createFormGroup(dataItem); |
|
|
this.editedRowIndex = rowIndex; |
|
|
this.editedRowIndex = rowIndex; |
|
|
sender.editRow(rowIndex, this.formGroup); |
|
|
|
|
|
|
|
|
sender.editRow(rowIndex, this.incomeFormGroup); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private closeEditor(grid, rowIndex = this.editedRowIndex): void{ |
|
|
private closeEditor(grid, rowIndex = this.editedRowIndex): void{ |
|
|
grid.closeRow(rowIndex); |
|
|
grid.closeRow(rowIndex); |
|
|
this.editedRowIndex = undefined; |
|
|
this.editedRowIndex = undefined; |
|
|
this.formGroup = undefined; |
|
|
|
|
|
|
|
|
this.incomeFormGroup = undefined; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |