Instanceof operator was not working so changed the way of checking it
This commit is contained in:
@@ -20,7 +20,7 @@ export class AccountDetailComponent implements OnInit, AfterViewInit {
|
||||
form: FormGroup<{
|
||||
code: FormControl<number | string>;
|
||||
name: FormControl<string | null>;
|
||||
type: FormControl<any>;
|
||||
type: FormControl<number>;
|
||||
isActive: FormControl<boolean>;
|
||||
isReconcilable: FormControl<boolean>;
|
||||
costCentre: FormControl<string | null>;
|
||||
@@ -40,7 +40,7 @@ export class AccountDetailComponent implements OnInit, AfterViewInit {
|
||||
this.form = new FormGroup({
|
||||
code: new FormControl<string | number>({ value: 0, disabled: true }, { nonNullable: true }),
|
||||
name: new FormControl<string | null>(null),
|
||||
type: new FormControl<any>(''),
|
||||
type: new FormControl<number>(0, { nonNullable: true }),
|
||||
isActive: new FormControl<boolean>(true, { nonNullable: true }),
|
||||
isReconcilable: new FormControl<boolean>(false, { nonNullable: true }),
|
||||
costCentre: new FormControl<string | null>(null),
|
||||
@@ -121,7 +121,7 @@ export class AccountDetailComponent implements OnInit, AfterViewInit {
|
||||
getItem(): Account {
|
||||
const formModel = this.form.value;
|
||||
this.item.name = formModel.name!;
|
||||
this.item.type = formModel.type;
|
||||
this.item.type = formModel.type!;
|
||||
this.item.isActive = formModel.isActive!;
|
||||
this.item.isReconcilable = formModel.isReconcilable!;
|
||||
this.item.costCentre.id = formModel.costCentre!;
|
||||
|
||||
@@ -6,7 +6,6 @@ import { merge, Observable, of as observableOf } from 'rxjs';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
|
||||
import { Account } from '../../core/account';
|
||||
import { AccountType } from '../../core/account-type';
|
||||
|
||||
/** Simple sort comparator for example ID/Name columns (for client-side sorting). */
|
||||
const compare = (a: string | number | boolean, b: string | number | boolean, isAsc: boolean) =>
|
||||
@@ -92,7 +91,7 @@ export class AccountListDataSource extends DataSource<Account> {
|
||||
case 'name':
|
||||
return compare(a.name, b.name, isAsc);
|
||||
case 'type':
|
||||
return compare((a.type as AccountType).name, (b.type as AccountType).name, isAsc);
|
||||
return compare(a.typeName, b.typeName, isAsc);
|
||||
case 'isActive':
|
||||
return compare(a.isActive, b.isActive, isAsc);
|
||||
case 'isReconcilable':
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<!-- Type Column -->
|
||||
<ng-container matColumnDef="type">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Type</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.type.name }}</mat-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.typeName }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Is Active? Column -->
|
||||
|
||||
@@ -50,10 +50,7 @@ export class AccountListComponent implements OnInit, AfterViewInit {
|
||||
const data = value as { list: Account[]; accountTypes: AccountType[] };
|
||||
this.accountTypes = data.accountTypes;
|
||||
data.list.forEach(
|
||||
(x) =>
|
||||
(x.type = new AccountType({
|
||||
name: this.accountTypes.find((y) => y.id === x.type)?.name,
|
||||
})),
|
||||
(x) => (x.typeName = this.accountTypes.find((y) => y.id === x.type)?.name!),
|
||||
);
|
||||
this.list = data.list;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user