Skip to content

Commit

Permalink
fix(Account Statement): misc UI updates
Browse files Browse the repository at this point in the history
This commit fixes the following issues on the Account Statement module:
 1. Unused requires are removed
 2. The "Configure" cogs are now "Columns" like on other modules
 3. The "print" labels are now "Export to PDF"
 4. Debits/Credits now sort numerically instead of as text
  • Loading branch information
jniles committed Sep 3, 2017
1 parent 39971eb commit 25a4907
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 26 deletions.
54 changes: 31 additions & 23 deletions client/src/modules/account_statement/account_statement.ctrl.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
angular.module('bhima.controllers')
.controller('AccountStatementController', AccountStatementController);
.controller('AccountStatementController', AccountStatementController);

// DI
AccountStatementController.$inject = [
'GeneralLedgerService', 'NotifyService', 'JournalService',
'GridSortingService', 'GridFilteringService', 'GridColumnService',
'SessionService', 'bhConstants', 'uiGridConstants', 'AccountStatementService',
'Store', 'FilterService', 'ModalService', 'LanguageService',
'$filter', 'GridExportService',
'FilterService', 'ModalService', 'LanguageService',
'GridExportService',
];

/**
* @module AccountStatementController
*/
function AccountStatementController(GeneralLedger, Notify, Journal,
Sorting, Filtering, Columns, Session, bhConstants, uiGridConstants,
AccountStatement, Store, Filters, Modal, Languages,
$filter, GridExport) {
AccountStatement, Filters, Modal, Languages, GridExport) {
// global variables
var vm = this;
var cacheKey = 'account-statement';
Expand Down Expand Up @@ -58,7 +57,7 @@ function AccountStatementController(GeneralLedger, Notify, Journal,
{ field : 'trans_date',
displayName : 'TABLE.COLUMNS.DATE',
headerCellFilter : 'translate',
cellFilter : 'date:"' + bhConstants.dates.format + '"',
cellFilter : 'date:"'.concat(bhConstants.dates.format, '"'),
filter : { condition : filtering.filterByDate },
editableCellTemplate : 'modules/journal/templates/date.edit.html',
footerCellTemplate : '<i></i>' },
Expand All @@ -74,6 +73,7 @@ function AccountStatementController(GeneralLedger, Notify, Journal,

{
field : 'debit_equiv',
type : 'number',
displayName : 'TABLE.COLUMNS.DEBIT',
headerCellFilter : 'translate',
cellFilter : 'currency:grid.appScope.enterprise.currency_id',
Expand All @@ -85,6 +85,7 @@ function AccountStatementController(GeneralLedger, Notify, Journal,
},

{ field : 'credit_equiv',
type : 'number',
displayName : 'TABLE.COLUMNS.CREDIT',
headerCellFilter : 'translate',
cellFilter : 'currency:grid.appScope.enterprise.currency_id',
Expand Down Expand Up @@ -124,12 +125,14 @@ function AccountStatementController(GeneralLedger, Notify, Journal,
visible : false },

{ field : 'debit',
type : 'number',
displayName : 'TABLE.COLUMNS.DEBIT_SOURCE',
headerCellFilter : 'translate',
visible : false,
cellTemplate : '/modules/journal/templates/debit.grid.html' },

{ field : 'credit',
type : 'number',
displayName : 'TABLE.COLUMNS.CREDIT_SOURCE',
headerCellFilter : 'translate',
visible : false,
Expand Down Expand Up @@ -181,12 +184,12 @@ function AccountStatementController(GeneralLedger, Notify, Journal,
// comment selected rows
vm.commentRows = function commentRows() {
AccountStatement.openCommentModal({ rows : vm.selectedRows })
.then(function (comment) {
if (!comment) { return; }
updateGridComment(vm.selectedRows, comment);
Notify.success('ACCOUNT_STATEMENT.SUCCESSFULLY_COMMENTED');
})
.catch(Notify.handleError);
.then(function (comment) {
if (!comment) { return; }
updateGridComment(vm.selectedRows, comment);
Notify.success('ACCOUNT_STATEMENT.SUCCESSFULLY_COMMENTED');
})
.catch(Notify.handleError);
};

// update local rows
Expand Down Expand Up @@ -236,9 +239,11 @@ function AccountStatementController(GeneralLedger, Notify, Journal,
return;
}

var uuids = vm.gridApi.selection.getSelectedGridRows().map(function (row) {
return row.entity.uuid;
});
var uuids = vm.gridApi.selection.getSelectedGridRows()
.map(function (row) {
return row.entity.uuid;
});

return { renderer : type || 'pdf', lang : Languages.key, uuids: uuids };
}

Expand All @@ -263,19 +268,22 @@ function AccountStatementController(GeneralLedger, Notify, Journal,
vm.latestViewFilters = AccountStatement.filters.formatView();
}

function toggleLoadingIndicator() {
vm.loading = !vm.loading;
}

// startup
function load(options) {
vm.loading = true;
toggleLoadingIndicator();

vm.hasErrors = false;

GeneralLedger.read(null, options)
.then(function (data) {
vm.gridOptions.data = data;
})
.catch(handleError)
.finally(function () {
vm.loading = false;
});
.then(function (data) {
vm.gridOptions.data = data;
})
.catch(handleError)
.finally(toggleLoadingIndicator);
}

// catch loading errors
Expand Down
6 changes: 3 additions & 3 deletions client/src/modules/account_statement/account_statement.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
<ul uib-dropdown-menu role="menu" class="dropdown-menu-right">
<li role="menuitem">
<a href data-method="configure" ng-click="AccountStateCtrl.openColumnConfigModal()">
<i class="fa fa-cogs"></i> <span translate>FORM.BUTTONS.CONFIGURE</span>
<i class="fa fa-columns"></i> <span translate>FORM.LABELS.COLUMNS</span>
</a>
</li>
<li role="separator" class="divider"></li>
<li role="menuitem">
<a href data-method="print" id="print" ng-click="AccountStateCtrl.exportPdf()">
<a href data-method="export-pdf" id="export-pdf" ng-click="AccountStateCtrl.exportPdf()">
<i class="fa fa-file-pdf-o"></i> <span translate>FORM.BUTTONS.PDF_EXPORT</span>
</a>
</li>
<li role="menuitem">
<a href data-method="export" id="export" ng-click="AccountStateCtrl.exportCsv()">
<a href data-method="export-csv" id="export-csv" ng-click="AccountStateCtrl.exportCsv()">
<i class="fa fa-file-excel-o"></i> <span translate>FORM.BUTTONS.CSV_EXPORT</span>
</a>
</li>
Expand Down

0 comments on commit 25a4907

Please sign in to comment.