Fix: Autocomplete could fuck up and was definitely doing it in product.
When checking for .name, it would error out if the input was null Fix: Journal addRow reset would reset Debit/Credit
This commit is contained in:
@ -3,7 +3,7 @@ import { FormControl, FormGroup } from '@angular/forms';
|
||||
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { debounceTime, distinctUntilChanged, map, switchMap } from 'rxjs/operators';
|
||||
import { debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators';
|
||||
|
||||
import { Account } from '../core/account';
|
||||
import { AccountBalance } from '../core/account-balance';
|
||||
@ -39,7 +39,6 @@ export class ReceiptDialogComponent implements OnInit {
|
||||
this.accBal = null;
|
||||
// Setup Account Autocomplete
|
||||
this.accounts = this.form.controls.account.valueChanges.pipe(
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
switchMap((x) => (x === null ? observableOf([]) : this.accountSer.autocomplete(x))),
|
||||
@ -54,8 +53,8 @@ export class ReceiptDialogComponent implements OnInit {
|
||||
this.account = this.data.journal.account;
|
||||
}
|
||||
|
||||
displayFn(account?: Account): string {
|
||||
return account ? account.name : '';
|
||||
displayFn(account?: Account | string): string {
|
||||
return !account ? '' : typeof account === 'string' ? account : account.name;
|
||||
}
|
||||
|
||||
accountSelected(event: MatAutocompleteSelectedEvent): void {
|
||||
|
||||
@ -7,7 +7,7 @@ import { Hotkey, HotkeysService } from 'angular2-hotkeys';
|
||||
import { round } from 'mathjs';
|
||||
import * as moment from 'moment';
|
||||
import { BehaviorSubject, Observable, of as observableOf } from 'rxjs';
|
||||
import { debounceTime, distinctUntilChanged, map, switchMap } from 'rxjs/operators';
|
||||
import { debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators';
|
||||
|
||||
import { AuthService } from '../auth/auth.service';
|
||||
import { Account } from '../core/account';
|
||||
@ -83,7 +83,6 @@ export class ReceiptComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.accBal = null;
|
||||
// Listen to Account Autocomplete Change
|
||||
this.accounts = this.form.controls.addRow.controls.account.valueChanges.pipe(
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
switchMap((x) => (x === null ? observableOf([]) : this.accountSer.autocomplete(x))),
|
||||
@ -333,8 +332,8 @@ export class ReceiptComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
displayFn(account?: Account): string {
|
||||
return account ? account.name : '';
|
||||
displayFn(account?: Account | string): string {
|
||||
return !account ? '' : typeof account === 'string' ? account : account.name;
|
||||
}
|
||||
|
||||
accountSelected(event: MatAutocompleteSelectedEvent): void {
|
||||
|
||||
Reference in New Issue
Block a user