Skip to content

Commit

Permalink
refactor(review): refactor the code based on the review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
DedrickEnc committed Aug 14, 2017
1 parent 3b1711d commit fed4ff6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
12 changes: 5 additions & 7 deletions client/src/js/components/bhPatientGroupSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,26 @@ angular.module('bhima.components')
});

PatientGroupSelectController.$inject = [
'PatientGroupService'
'PatientGroupService', 'NotifyService'
];

/**
* Patient Group selection component
*
*/
function PatientGroupSelectController(PatientGroups) {
function PatientGroupSelectController(PatientGroups, Notify) {
var $ctrl = this;

$ctrl.$onInit = function onInit() {
// fired when a patient group has been selected
$ctrl.onSelectCallback = $ctrl.onSelectCallback || angular.noop;

$ctrl.$onInit = function onInit() {
// default for label
$ctrl.label = $ctrl.label || 'PATIENT_GROUP.PATIENT_GROUP';

// load all patient groups
PatientGroups.read()
.then(function (pgs) {
$ctrl.patientGroups = pgs;
});
})
.catch(Notify.handleError);
};

$ctrl.onSelect = function ($item, $model) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/patients/registry/registry.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</div>
</div>

<div class="flex-util" style="min-height : 35px; padding-top : 7px; max-height: initial">
<div class="flex-util bh-filter-bar">
<bh-filters
style="max-width:90%"
filters="PatientRegistryCtrl.latestViewFilters"
Expand Down
7 changes: 7 additions & 0 deletions client/src/modules/patients/registry/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ function PatientRegistryController($state, Patients, Notify, AppCache,

// startup function. Checks for cached filters and loads them. This behavior could be changed.
function startup() {

if($state.params.filters) {
var changes = [{ key : $state.params.filters.key, value : $state.params.filters.value }]
Patients.filters.replaceFilters(changes);
Patients.cacheFilters();
}

load(Patients.filters.formatHTTP(true));
vm.latestViewFilters = Patients.filters.formatView();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Check links', () => {
helpers.navigate('#!/patients/groups');

element.all(by.css('[class="fa fa-list"]')).get(2).click();
expectNumberOfGridRows(4);
expectNumberOfGridRows(2);
});

it('Check link betwen Debtor Groups -> Patient Registry', () => {
Expand Down

0 comments on commit fed4ff6

Please sign in to comment.