Fix indent.
This commit is contained in:
parent
f8fa34f269
commit
fc75945a76
@ -1,3 +1,4 @@
|
|||||||
|
// vim: set tw=80 ts=2 sw=2 sts=2 :
|
||||||
import { CurrencyPipe } from '@angular/common';
|
import { CurrencyPipe } from '@angular/common';
|
||||||
import { Component, Inject } from '@angular/core';
|
import { Component, Inject } from '@angular/core';
|
||||||
import { Observable } from 'rxjs/Rx';
|
import { Observable } from 'rxjs/Rx';
|
||||||
@ -14,8 +15,8 @@ import { AccountDeleteModalComponent } from './accountDeleteModal.component';
|
|||||||
import { AccountEditModalComponent } from './accountEditModal.component';
|
import { AccountEditModalComponent } from './accountEditModal.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'account-list',
|
selector: 'account-list',
|
||||||
template: `
|
template: `
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<table class="table table-striped table-condensed table-hover">
|
<table class="table table-striped table-condensed table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
@ -87,164 +88,164 @@ import { AccountEditModalComponent } from './accountEditModal.component';
|
|||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
export class AccountListComponent {
|
export class AccountListComponent {
|
||||||
static $inject = [
|
static $inject = [
|
||||||
'AccountService',
|
'AccountService',
|
||||||
'AccountBalancesService',
|
'AccountBalancesService',
|
||||||
'ToastrService',
|
'ToastrService',
|
||||||
'Logger',
|
'Logger',
|
||||||
'NgbModal'
|
'NgbModal'
|
||||||
];
|
];
|
||||||
|
|
||||||
accounts: Account[];
|
accounts: Account[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private AccountService: AccountService,
|
private AccountService: AccountService,
|
||||||
private AccountBalancesService: AccountBalancesService,
|
private AccountBalancesService: AccountBalancesService,
|
||||||
private ToastrService: ToastrService,
|
private ToastrService: ToastrService,
|
||||||
private Logger: Logger,
|
private Logger: Logger,
|
||||||
private NgbModal: NgbModal
|
private NgbModal: NgbModal
|
||||||
) {
|
) {
|
||||||
// Load accounts.
|
// Load accounts.
|
||||||
this.load();
|
this.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the class for an account current value compared to authorized
|
||||||
|
* overdraft.
|
||||||
|
*/
|
||||||
|
rowClass(account) {
|
||||||
|
// eslint-disable-next-line camelcase
|
||||||
|
if (!account || !account.authorized_overdraft || !account.current) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// eslint-disable-next-line camelcase
|
||||||
* Return the class for an account current value compared to authorized
|
if (account.current < account.authorized_overdraft) {
|
||||||
* overdraft.
|
return 'danger';
|
||||||
*/
|
} else if (account.current < 0) {
|
||||||
rowClass(account) {
|
return 'warning';
|
||||||
// eslint-disable-next-line camelcase
|
}
|
||||||
if (!account || !account.authorized_overdraft || !account.current) {
|
};
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
/*
|
||||||
if (account.current < account.authorized_overdraft) {
|
* Return the class for a value compared to account authorized overdraft.
|
||||||
return 'danger';
|
*/
|
||||||
} else if (account.current < 0) {
|
valueClass(account, value) {
|
||||||
return 'warning';
|
if (!account || !value) {
|
||||||
}
|
return;
|
||||||
};
|
}
|
||||||
|
|
||||||
/*
|
// eslint-disable-next-line camelcase
|
||||||
* Return the class for a value compared to account authorized overdraft.
|
if (value < account.authorized_overdraft) {
|
||||||
*/
|
return 'text-danger';
|
||||||
valueClass(account, value) {
|
} else if (value < 0) {
|
||||||
if (!account || !value) {
|
return 'text-warning';
|
||||||
return;
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
load() {
|
||||||
if (value < account.authorized_overdraft) {
|
this.AccountService.query().subscribe(accounts => {
|
||||||
return 'text-danger';
|
this.accounts = accounts.map((account: Account) => {
|
||||||
} else if (value < 0) {
|
this.Logger.log(account);
|
||||||
return 'text-warning';
|
this.AccountBalancesService
|
||||||
}
|
.get(account.id)
|
||||||
};
|
.subscribe((accountBalances: AccountBalances) => {
|
||||||
|
account.balances = accountBalances;
|
||||||
|
})
|
||||||
|
return account;
|
||||||
|
})
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
load() {
|
/*
|
||||||
this.AccountService.query().subscribe(accounts => {
|
* Add an empty account.
|
||||||
this.accounts = accounts.map((account: Account) => {
|
*/
|
||||||
this.Logger.log(account);
|
add() {
|
||||||
this.AccountBalancesService
|
const modal = this.NgbModal.open(AccountEditModalComponent, {
|
||||||
.get(account.id)
|
windowClass: 'in'
|
||||||
.subscribe((accountBalances: AccountBalances) => {
|
});
|
||||||
account.balances = accountBalances;
|
|
||||||
})
|
|
||||||
return account;
|
|
||||||
})
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
modal.componentInstance.account = new Account();
|
||||||
* Add an empty account.
|
|
||||||
*/
|
|
||||||
add() {
|
|
||||||
const modal = this.NgbModal.open(AccountEditModalComponent, {
|
|
||||||
windowClass: 'in'
|
|
||||||
});
|
|
||||||
|
|
||||||
modal.componentInstance.account = new Account();
|
modal.result.then((account: Account) => {
|
||||||
|
this.Logger.log("Modal closed => save account", account);
|
||||||
|
this.save(account);
|
||||||
|
}, (reason) => function(reason) {
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
modal.result.then((account: Account) => {
|
/*
|
||||||
this.Logger.log("Modal closed => save account", account);
|
* Save account.
|
||||||
this.save(account);
|
*/
|
||||||
}, (reason) => function(reason) {
|
save(account) {
|
||||||
});
|
var observable: Observable<Account>;
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
if(account.id) {
|
||||||
* Save account.
|
observable = this.AccountService.update(account);
|
||||||
*/
|
} else {
|
||||||
save(account) {
|
observable = this.AccountService.create(account);
|
||||||
var observable: Observable<Account>;
|
}
|
||||||
|
|
||||||
if(account.id) {
|
observable.subscribe(account => {
|
||||||
observable = this.AccountService.update(account);
|
this.ToastrService.success('Account #' + account.id + ' saved.');
|
||||||
} else {
|
|
||||||
observable = this.AccountService.create(account);
|
|
||||||
}
|
|
||||||
|
|
||||||
observable.subscribe(account => {
|
this.load();
|
||||||
this.ToastrService.success('Account #' + account.id + ' saved.');
|
}, result => {
|
||||||
|
this.Logger.error('Error while saving account', account, result);
|
||||||
|
|
||||||
this.load();
|
this.ToastrService.error(
|
||||||
}, result => {
|
'Error while saving account: ' + result.message
|
||||||
this.Logger.error('Error while saving account', account, result);
|
);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
this.ToastrService.error(
|
confirmDelete(account) {
|
||||||
'Error while saving account: ' + result.message
|
const modal = this.NgbModal.open(AccountDeleteModalComponent, {
|
||||||
);
|
windowClass: 'in'
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
confirmDelete(account) {
|
modal.componentInstance.account = account;
|
||||||
const modal = this.NgbModal.open(AccountDeleteModalComponent, {
|
|
||||||
windowClass: 'in'
|
|
||||||
});
|
|
||||||
|
|
||||||
modal.componentInstance.account = account;
|
modal.result.then((account: Account) => {
|
||||||
|
this.delete(account);
|
||||||
|
}, (reason) => function(reason) {
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
modal.result.then((account: Account) => {
|
/*
|
||||||
this.delete(account);
|
* Delete an account.
|
||||||
}, (reason) => function(reason) {
|
*/
|
||||||
});
|
delete(account) {
|
||||||
};
|
var id = account.id;
|
||||||
|
|
||||||
/*
|
this.AccountService.delete(account).subscribe(account => {
|
||||||
* Delete an account.
|
this.ToastrService.success('account #' + id + ' deleted.');
|
||||||
*/
|
|
||||||
delete(account) {
|
|
||||||
var id = account.id;
|
|
||||||
|
|
||||||
this.AccountService.delete(account).subscribe(account => {
|
this.load();
|
||||||
this.ToastrService.success('account #' + id + ' deleted.');
|
|
||||||
|
|
||||||
this.load();
|
return account;
|
||||||
|
}, function(result) {
|
||||||
|
this.ToastrService.error(
|
||||||
|
'An error occurred while trying to delete account #' +
|
||||||
|
id + ':<br />' + result
|
||||||
|
);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return account;
|
/*
|
||||||
}, function(result) {
|
* Open the popup to modify the account, save it on confirm.
|
||||||
this.ToastrService.error(
|
*/
|
||||||
'An error occurred while trying to delete account #' +
|
modify(account) {
|
||||||
id + ':<br />' + result
|
const modal = this.NgbModal.open(AccountEditModalComponent, {
|
||||||
);
|
windowClass: 'in'
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
modal.componentInstance.account = account;
|
||||||
* Open the popup to modify the account, save it on confirm.
|
|
||||||
*/
|
|
||||||
modify(account) {
|
|
||||||
const modal = this.NgbModal.open(AccountEditModalComponent, {
|
|
||||||
windowClass: 'in'
|
|
||||||
});
|
|
||||||
|
|
||||||
modal.componentInstance.account = account;
|
modal.result.then((account: Account) => {
|
||||||
|
this.Logger.log("Modal closed => save account", account);
|
||||||
modal.result.then((account: Account) => {
|
this.save(account);
|
||||||
this.Logger.log("Modal closed => save account", account);
|
}, (reason) => function(reason) {
|
||||||
this.save(account);
|
});
|
||||||
}, (reason) => function(reason) {
|
};
|
||||||
});
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user