Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(component) bh-bebtor-group-history #3611

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/src/i18n/en/debtor_group.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"DEBTOR_GROUP": {
"BACK": "Back to Debtor Groups",
"CHANGE" : "Debtor group changes",
"CLICK_TO_ADD" : "Click here to add a debtor group",
"CREATE": "Create Debtor Group",
"CREATE_ANOTHER": "Create another Debtor Group",
Expand Down
1 change: 1 addition & 0 deletions client/src/i18n/fr/debtor_group.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"DEBTOR_GROUP": {
"BACK": "Retour vers les Groupes Débiteurs",
"CHANGE" : "Changement de group débiteur",
"CLICK_TO_ADD" : "Cliquer ici pour ajouter un Groupe Débiteur",
"CREATE": "Créer un Groupe Débiteur",
"CREATE_ANOTHER": "Créer un autre Groupe Débiteur",
Expand Down
38 changes: 38 additions & 0 deletions client/src/js/components/bhDebtorGroupHistory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
angular.module('bhima.components')
.component('bhDebtorGroupHistory', {
templateUrl : 'modules/templates/bhDebtorGroupHistory.tmpl.html',
controller : bhDebtorGroupHistoryController,
transclude : true,
bindings : {
debtorUuid : '<',
limit : '@?',
},
});

bhDebtorGroupHistoryController.$inject = ['DebtorGroupService', 'NotifyService'];
/**
* Debtor group history component
*
*/
function bhDebtorGroupHistoryController(DebtorGroup, Notify) {
const $ctrl = this;

// fired at the beginning
$ctrl.$onInit = () => {
$ctrl.limit = $ctrl.limit || 5;
loadHistory();
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also put a $onChanges binding so that we reload the history when the debtorUuid changes.


$ctrl.$onChanges = () => {
loadHistory();
};

function loadHistory() {
const parameters = { limit : $ctrl.limit };
DebtorGroup.history($ctrl.debtorUuid, parameters)
.then(groupChanges => {
$ctrl.groupChanges = groupChanges;
})
.catch(Notify.handleError);
}
}
7 changes: 7 additions & 0 deletions client/src/modules/debtors/groups.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function DebtorGroupService(Modal, Session, $translate, Api) {
service.updateInvoicingFees = updateInvoicingFees;
service.updateSubsidies = updateSubsidies;
service.invoices = invoices;
service.history = history;
service.remove = service.delete;

service.manageInvoicingFees = manageInvoicingFees;
Expand Down Expand Up @@ -117,5 +118,11 @@ function DebtorGroupService(Modal, Session, $translate, Api) {
.then(service.util.unwrapHttpResponse);
}

function history(debtorUuid, parameters) {
const url = `${baseUrl}history/${debtorUuid}`;
return service.$http.get(url, { params : parameters || {} })
.then(service.util.unwrapHttpResponse);
}

return service;
}
5 changes: 5 additions & 0 deletions client/src/modules/patients/edit/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@
class="btn btn-warning btn-block"
ng-click="PatientEditCtrl.updateDebtorGroup()"><span translate>FORM.BUTTONS.GROUPS_DEBTOR_UPDATE</span></button>
</div>

<bh-debtor-group-history
debtor-uuid="PatientEditCtrl.medical.debtor_uuid"
limit="5">
</bh-debtor-group-history>
</form>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions client/src/modules/patients/edit/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function PatientEdit($stateParams, Patients, util, moment, Notify, ScrollTo, Gro
const vm = this;
const referenceId = $stateParams.uuid;

vm.medical = {};
vm.patient = null;
vm.unknownId = false;

Expand Down
Loading