Skip to content

Commit

Permalink
fix(vouchers): support patient ui-glitches
Browse files Browse the repository at this point in the history
The following ui glitches have been fixed on the support patient modal:
 1. The currencies are now right-aligned in the patient form for easy
 comparison.
 2. The account selection now includes validation to disallow empty
 selections.
 3. Remove title accounts from the bhAccountSelection

References #1915.
  • Loading branch information
jniles committed Aug 2, 2017
1 parent ddd8195 commit 553a3af
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
append-to-body="true"
required>
<ui-select-match placeholder="{{ 'FORM.PLACEHOLDERS.ACCOUNT' | translate }}">
<strong>{{$select.selected.number}}</strong> <span>{{$select.selected.label}}</span>
<span><strong>{{$select.selected.number}}</strong> {{$select.selected.label}}</span>
</ui-select-match>
<ui-select-choices
class="ui-grid-ui-select"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
angular.module('bhima.controllers')
.controller('SupportPatientKitController', SupportPatientKitController);
.controller('SupportPatientKitController', SupportPatientKitController);

// DI definition
SupportPatientKitController.$inject = [
Expand All @@ -11,14 +11,14 @@ SupportPatientKitController.$inject = [
function SupportPatientKitController(Instance, Notify, Session, Data, bhConstants, Debtors, Invoices) {
var vm = this;

var MAX_DECIMAL_PRECISION = bhConstants.precision.MAX_DECIMAL_PRECISION;

// global variables
vm.enterprise = Session.enterprise;
vm.gridOptions = {};
vm.tool = Data;
vm.patientInvoice = false;

var MAX_DECIMAL_PRECISION = bhConstants.precision.MAX_DECIMAL_PRECISION;

// expose to the view
vm.selectPatientInvoices = selectPatientInvoices;
vm.close = Instance.close;
Expand All @@ -28,15 +28,15 @@ function SupportPatientKitController(Instance, Notify, Session, Data, bhConstant

// debtors from store
Debtors.store()
.then(function (data) {
vm.patients = data;
})
.catch(Notify.handleError);
.then(function (data) {
vm.patients = data;
})
.catch(Notify.handleError);

// get debtor group invoices
function selectPatientInvoices(debtorId) {
// load patient invoices
vm.debtorUuid = debtorId;
vm.debtorUuid = debtorId;

Debtors.invoices(debtorId, { balanced: 0 })
.then(function (invoices) {
Expand All @@ -50,16 +50,16 @@ function SupportPatientKitController(Instance, Notify, Session, Data, bhConstant

// make sure we are always within precision
vm.totalInvoices = Number.parseFloat(vm.totalInvoices.toFixed(MAX_DECIMAL_PRECISION));
return Invoices.read(null, {debtor_uuid: debtorId});

return Invoices.read(null, { debtor_uuid: debtorId });
})
.then(function (data) {
vm.invoices = data;
})
})
.catch(Notify.handleError);
}

function loadInvoice(patient){
function loadInvoice(patient) {
vm.patient = patient;
selectPatientInvoices(patient.debtor_uuid);
}
Expand Down Expand Up @@ -111,7 +111,7 @@ function SupportPatientKitController(Instance, Notify, Session, Data, bhConstant
return {
label : entity.text,
type : 'D',
uuid : entity.uuid
uuid : entity.uuid,
};
}

Expand All @@ -135,24 +135,27 @@ function SupportPatientKitController(Instance, Notify, Session, Data, bhConstant
debit : 0,
credit : 0,
reference_uuid : undefined,
entity_uuid : undefined
entity_uuid : undefined,
};
}

/* ================ Invoice grid parameters ===================== */
vm.gridOptions.appScopeProvider = vm;
vm.gridOptions.enableFiltering = true;
vm.gridOptions.onRegisterApi = onRegisterApi;
vm.gridOptions.enableFiltering = true;
vm.gridOptions.onRegisterApi = onRegisterApi;
vm.gridOptions.fastWatch = true;
vm.gridOptions.flatEntityAccess = true;

vm.gridOptions.columnDefs = [
{ field: 'reference', displayName: 'TABLE.COLUMNS.REFERENCE', headerCellFilter: 'translate' },
{ field: 'date', cellFilter: 'date', displayName: 'TABLE.COLUMNS.BILLING_DATE', headerCellFilter: 'translate', enableFiltering: false },
{ field : 'balance', displayName : 'TABLE.COLUMNS.BALANCE',
headerCellFilter : 'translate', enableFiltering : false,
cellTemplate : '/modules/templates/grid/balance.cell.html'
}
{ field : 'balance',
displayName : 'TABLE.COLUMNS.BALANCE',
headerCellFilter : 'translate',
cellClass : 'text-right',
enableFiltering : false,
cellTemplate : '/modules/templates/grid/balance.cell.html',
},
];

function onRegisterApi(gridApi) {
Expand All @@ -161,7 +164,7 @@ function SupportPatientKitController(Instance, Notify, Session, Data, bhConstant
vm.gridApi.selection.on.rowSelectionChangedBatch(null, rowSelectionCallback);
}

function rowSelectionCallback(row) {
function rowSelectionCallback() {
vm.selectedRows = vm.gridApi.selection.getSelectedRows();
vm.totalSelected = vm.selectedRows.reduce(function (current, previous) {
return current + previous.balance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
<bh-account-select
name="account_id"
account-id="ToolCtrl.account_id"
on-select-callback="ToolCtrl.onSelectAccount(account)">
on-select-callback="ToolCtrl.onSelectAccount(account)"
validation-trigger="ToolForm.$submitted"
exclude-title-accounts="true">
</bh-account-select>

<bh-find-patient
Expand Down

0 comments on commit 553a3af

Please sign in to comment.