Skip to content

Commit

Permalink
fix(bhDebGroup): fix conflict from params of components for the test E2E
Browse files Browse the repository at this point in the history
  • Loading branch information
lomamech committed Jul 10, 2017
1 parent a398f7c commit 31eeb8c
Show file tree
Hide file tree
Showing 25 changed files with 213 additions and 225 deletions.
18 changes: 11 additions & 7 deletions client/src/js/components/bhDebtorGroupSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ angular.module('bhima.components')
.component('bhDebtorGroupSelect', {
templateUrl : 'modules/templates/bhDebtorGroupSelect.tmpl.html',
controller : DebtorGroupSelectController,
transclude : true,
// transclude : true,
bindings : {
debtorGroupUuid : '<',
disable : '<?',
onSelectCallback : '&',
name : '@?',
required : '<?',
label : '@?',
required : '<?',
validationTrigger : '<',
},
});

DebtorGroupSelectController.$inject = [
'DebtorService'
'DebtorService',
];

/**
Expand All @@ -23,25 +25,27 @@ DebtorGroupSelectController.$inject = [
function DebtorGroupSelectController(Debtors) {
var $ctrl = this;

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

// default for form name
$ctrl.name = $ctrl.name || 'DebtorForm';

// translated label for the form input
$ctrl.label = $ctrl.label || 'FORM.LABELS.DEBTOR_GROUP';

// load all Debtor Group
Debtors.groups()
.then(function (debtorGroups) {
.then(function (debtorGroups) {
$ctrl.debtorGroups = debtorGroups;
});

$ctrl.valid = true;

};

// fires the onSelectCallback bound to the component boundary
$ctrl.onSelect = function ($item, $model) {
$ctrl.onSelect = function ($item) {
$ctrl.onSelectCallback({ debtorGroup : $item });
};
}
20 changes: 5 additions & 15 deletions client/src/modules/cash/payments/templates/search.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,11 @@
<bh-clear on-clear="$ctrl.clear('user_id')"></bh-clear>
</bh-user-select>

<div class="form-group">
<label class="control-label" translate>
FORM.LABELS.DEBTOR_GROUP
</label>
<bh-clear on-clear="$ctrl.clear('debtor_group_uuid')"></bh-clear>
<!-- @todo make data driven selects components to handle loading and error states -->
<ui-select
name="debtor_group_uuid"
ng-model="$ctrl.searchQueries.debtor_group_uuid">
<ui-select-match placeholder="{{ 'FORM.PLACEHOLDERS.DEBTOR_GROUP' | translate }}"><span>{{$select.selected.name}}</span></ui-select-match>
<ui-select-choices ui-select-focus-patch repeat="group.uuid as group in ($ctrl.debtorGroups | filter:$select.search | orderBy:'name') track by group.uuid">
<span ng-bind-html="group.name | highlight:$select.search"></span>
</ui-select-choices>
</ui-select>
</div>
<bh-debtor-group-select
debtor-group-uuid = "$ctrl.searchQueries.debtor_group_uuid"
on-select-callback = "$ctrl.onSelectDebtor(debtorGroup)">
<bh-clear on-clear="$ctrl.clear('debtor_group_uuid')"></bh-clear>
</bh-debtor-group-select>

<div class="form-group">
<label class="control-label" translate>
Expand Down
27 changes: 15 additions & 12 deletions client/src/modules/cash/payments/templates/search.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ angular.module('bhima.controllers')
.controller('SearchCashPaymentModalController', SearchCashPaymentModalController);

SearchCashPaymentModalController.$inject = [
'CashboxService', 'NotifyService', '$uibModalInstance', 'filters', 'Store', 'PeriodService', 'util', 'DebtorGroupService',
'CashboxService', 'NotifyService', '$uibModalInstance', 'filters', 'Store', 'PeriodService', 'util',
];

/**
Expand All @@ -13,20 +13,21 @@ SearchCashPaymentModalController.$inject = [
* POJO and are attached to the view. They are modified here and returned to the parent controller
* as a POJO.
*/
function SearchCashPaymentModalController(Cashboxes, Notify, Instance, filters, Store, Periods, util, DebtorGroups) {
function SearchCashPaymentModalController(Cashboxes, Notify, Instance, filters, Store, Periods, util) {
var vm = this;
var changes = new Store({ identifier : 'key' });
vm.filters = filters;

vm.searchQueries = {};
vm.defaultQueries = {};

// @TODO ideally these should be passed in when the modal is initialised
// these are known when the filter service is defined
var searchQueryOptions = [
'is_caution', 'reference', 'cashbox_id', 'user_id', 'reference_patient', 'currency_id', 'reversed',
];


vm.filters = filters;

vm.searchQueries = {};
vm.defaultQueries = {};

// assign already defined custom filters to searchQueries object
vm.searchQueries = util.maskObjectFromKeys(filters, searchQueryOptions);

Expand All @@ -37,18 +38,20 @@ function SearchCashPaymentModalController(Cashboxes, Notify, Instance, filters,

vm.cancel = Instance.close;

// Set up page elements data (debtor select data)
vm.onSelectDebtor = onSelectDebtor;

function onSelectDebtor(debtorGroup) {
vm.searchQueries.debtor_group_uuid = debtorGroup.uuid;
}

// cashboxes
Cashboxes.read()
.then(function (list) {
vm.cashboxes = list;
})
.catch(Notify.handleError);

DebtorGroups.read()
.then(function (result) {
vm.debtorGroups = result;
});

// custom filter user_id - assign the value to the searchQueries object
vm.onSelectUser = function onSelectUser(user) {
vm.searchQueries.user_id = user.id;
Expand Down
35 changes: 9 additions & 26 deletions client/src/modules/employees/registration/employees.html
Original file line number Diff line number Diff line change
Expand Up @@ -196,33 +196,16 @@
</div>

<!-- Employee debtor group-->
<div class="form-group"
ng-class="{'has-error' : DetailForm.debtor_group.$invalid && EmployeeRegistrationForm.$submitted}">

<!-- Warning for incomplete data - the page will not be able to continue -->
<uib-alert class="text-danger" type="danger" ng-if="EmployeeCtrl.debtorGroups.length === 0">
<i class="fa fa-warning"></i>
<span translate>FORM.LABELS.NO_DEBTOR_GROUP</span> <b><span translate>FORM.LABELS.CONTACT_ADMIN</span></b>
</uib-alert>

<label class="col-md-3 control-label" translate>FORM.LABELS.DEBTOR_GROUP</label>
<div class="col-md-9">
<ui-select
name="debtor_group"
ng-model="EmployeeCtrl.employee.debtor_group_uuid"
required>
<ui-select-match placeholder="{{ 'FORM.SELECT.DEBTOR_GROUP' | translate }}">
<span>{{$select.selected.name}}</span>
</ui-select-match>
<ui-select-choices ui-select-focus-patch repeat="dg.uuid as dg in EmployeeCtrl.debtorGroups | filter:{name : $select.search} | orderBy:'name'">
<span ng-bind-html="dg.name | highlight:$select.search"></span>
</ui-select-choices>
</ui-select>

<div class="help-block" ng-messages="DetailForm.debtor_group.$error" ng-show="EmployeeRegistrationForm.$submitted">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
<div class="row">
<div class="col-md-1 col-md-offset-1">
</div>
<div class="col-md-9 col-md-offset-1">
<bh-debtor-group-select
debtor-group-uuid = "EmployeeCtrl.employee.debtor_group_uuid"
validation-trigger="EmployeeRegistrationForm.$submitted"
on-select-callback = "EmployeeCtrl.onSelectDebtor(debtorGroup)">
</bh-debtor-group-select>
</div>
</div>

<!-- Employee location -->
Expand Down
31 changes: 15 additions & 16 deletions client/src/modules/employees/registration/employees.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ angular.module('bhima.controllers')

EmployeeController.$inject = [
'EmployeeService', 'ServiceService', 'GradeService', 'FunctionService',
'CreditorGroupService', 'DebtorGroupService', 'util', 'NotifyService',
'bhConstants', 'ReceiptModal', 'SessionService'
'CreditorGroupService', 'util', 'NotifyService',
'bhConstants', 'ReceiptModal', 'SessionService',
];

function EmployeeController(Employees, Services, Grades, Functions, CreditorGroups, DebtorGroups, util, Notify, bhConstants, Receipts, Session) {
function EmployeeController(Employees, Services, Grades, Functions, CreditorGroups, util, Notify, bhConstants, Receipts, Session,) {
var vm = this;
vm.enterprise = Session.enterprise;

Expand All @@ -18,7 +18,7 @@ function EmployeeController(Employees, Services, Grades, Functions, CreditorGrou
// Expose validation rule for date
vm.datepickerOptions = {
maxDate : new Date(),
minDate : bhConstants.dates.minDOB
minDate : bhConstants.dates.minDOB,
};

// Expose employee to the scope
Expand All @@ -27,11 +27,18 @@ function EmployeeController(Employees, Services, Grades, Functions, CreditorGrou
// Expose methods to the scope
vm.submit = submit;

// Set up page elements data (debtor select data)
vm.onSelectDebtor = onSelectDebtor;

function onSelectDebtor(debtorGroup) {
vm.employee.debtor_group_uuid = debtorGroup.uuid;
}

// Loading Grades
Grades.read(null, { detailed : 1 }).then(function (data) {
data.forEach(function (g){
data.forEach(function (g) {
g.format = g.code + ' - ' + g.text;
});
});
vm.grades = data;
}).catch(Notify.handleError);

Expand All @@ -40,15 +47,10 @@ function EmployeeController(Employees, Services, Grades, Functions, CreditorGrou
vm.creditorGroups = data;
}).catch(Notify.handleError);

// Loading Debtor Groups
DebtorGroups.read().then(function (data) {
vm.debtorGroups = data;
}).catch(Notify.handleError);

// Loading Services
Services.read().then(function (services) {
vm.services = services;
}).catch(Notify.handleError);
}).catch(Notify.handleError);

// Loading Functions
Functions.read().then(function (data) {
Expand All @@ -58,10 +60,7 @@ function EmployeeController(Employees, Services, Grades, Functions, CreditorGrou

// submit the data to the server
function submit(employeeForm) {
var promise;

if (employeeForm.$invalid) { return Notify.danger('FORM.ERRORS.INVALID');}

if (employeeForm.$invalid) { return Notify.danger('FORM.ERRORS.INVALID'); }
return Employees.create(vm.employee)
.then(function (feedBack) {
Receipts.patient(feedBack.patient_uuid, true);
Expand Down
14 changes: 7 additions & 7 deletions client/src/modules/invoices/patientInvoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ function PatientInvoiceController(Patients, PatientInvoices, PatientInvoiceForm,
enableColumnMenus : false,
rowTemplate : 'modules/templates/grid/error.row.html',
columnDefs : [
{ field: 'status', width: 25, displayName : '', cellTemplate: 'modules/invoices/templates/grid/status.tmpl.html' },
{ field: 'code', displayName: 'TABLE.COLUMNS.CODE', headerCellFilter: 'translate', cellTemplate: 'modules/invoices/templates/grid/code.tmpl.html' },
{ field: 'description', displayName: 'TABLE.COLUMNS.DESCRIPTION', headerCellFilter: 'translate' },
{ field: 'quantity', displayName: 'TABLE.COLUMNS.QUANTITY', headerCellFilter: 'translate', cellTemplate: 'modules/invoices/templates/grid/quantity.tmpl.html' },
{ field: 'transaction_price', displayName: 'FORM.LABELS.UNIT_PRICE', headerCellFilter: 'translate', cellTemplate: 'modules/invoices/templates/grid/unit.tmpl.html' },
{ field: 'amount', displayName: 'TABLE.COLUMNS.AMOUNT', headerCellFilter: 'translate', cellTemplate: 'modules/invoices/templates/grid/amount.tmpl.html' },
{ field: 'actions', width: 25, cellTemplate: 'modules/invoices/templates/grid/actions.tmpl.html' },
{ field: 'status', width : 25, displayName : '', cellTemplate: 'modules/invoices/templates/grid/status.tmpl.html' },
{ field: 'code', displayName : 'TABLE.COLUMNS.CODE', headerCellFilter: 'translate', cellTemplate: 'modules/invoices/templates/grid/code.tmpl.html' },
{ field: 'description', displayName : 'TABLE.COLUMNS.DESCRIPTION', headerCellFilter: 'translate' },
{ field: 'quantity', displayName : 'TABLE.COLUMNS.QUANTITY', headerCellFilter: 'translate', cellTemplate: 'modules/invoices/templates/grid/quantity.tmpl.html' },
{ field: 'transaction_price', displayName : 'FORM.LABELS.UNIT_PRICE', headerCellFilter: 'translate', cellTemplate: 'modules/invoices/templates/grid/unit.tmpl.html' },
{ field: 'amount', displayName : 'TABLE.COLUMNS.AMOUNT', headerCellFilter: 'translate', cellTemplate: 'modules/invoices/templates/grid/amount.tmpl.html' },
{ field: 'actions', width : 25, cellTemplate: 'modules/invoices/templates/grid/actions.tmpl.html' },
],
onRegisterApi : exposeGridScroll,
data : vm.Invoice.store.data,
Expand Down
1 change: 1 addition & 0 deletions client/src/modules/invoices/patientInvoice.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ function PatientInvoiceService(Modal, Session, Api, Filters, AppCache, Periods,
{ key : 'billingDateTo', label : 'FORM.LABELS.DATE', comparitor : '<', valueFilter : 'date' },
{ key : 'reversed', label : 'FORM.INFO.CREDIT_NOTE' },
{ key : 'defaultPeriod', label : 'TABLE.COLUMNS.PERIOD', valueFilter : 'translate' },
{ key : 'debtor_group_uuid', label : 'FORM.LABELS.DEBTOR_GROUP' },
{ key : 'cash_uuid', label : 'FORM.INFO.PAYMENT' },
]);

Expand Down
21 changes: 5 additions & 16 deletions client/src/modules/invoices/registry/search.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,11 @@
</select>
</div>

<div class="form-group">
<label class="control-label" translate>
FORM.LABELS.DEBTOR_GROUP
</label>
<bh-clear on-clear="$ctrl.clear('debtor_group_uuid')"></bh-clear>

<!-- @todo make data driven selects components to handle loading and error states -->
<ui-select
name="debtor_group_uuid"
ng-model="$ctrl.searchQueries.debtor_group_uuid">
<ui-select-match placeholder="{{ 'FORM.PLACEHOLDERS.DEBTOR_GROUP' | translate }}"><span>{{$select.selected.name}}</span></ui-select-match>
<ui-select-choices ui-select-focus-patch repeat="group.uuid as group in ($ctrl.debtorGroups | filter:$select.search | orderBy:'name') track by group.uuid">
<span ng-bind-html="group.name | highlight:$select.search"></span>
</ui-select-choices>
</ui-select>
</div>
<bh-debtor-group-select
debtor-group-uuid = "$ctrl.searchQueries.debtor_group_uuid"
on-select-callback = "$ctrl.onSelectDebtor(debtorGroup)">
<bh-clear on-clear="$ctrl.clear('debtor_group_uuid')"></bh-clear>
</bh-debtor-group-select>

<bh-user-select
user-id="$ctrl.searchQueries.user_id"
Expand Down
18 changes: 10 additions & 8 deletions client/src/modules/invoices/registry/search.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ angular.module('bhima.controllers')
.controller('InvoiceRegistrySearchModalController', InvoiceRegistrySearchModalController);

InvoiceRegistrySearchModalController.$inject = [
'$uibModalInstance', 'ServiceService', 'filters', 'NotifyService', 'Store', 'PeriodService', 'util', 'DebtorGroupService'
'$uibModalInstance', 'ServiceService', 'filters', 'NotifyService', 'Store', 'PeriodService', 'util'
];

/**
Expand All @@ -12,7 +12,7 @@ InvoiceRegistrySearchModalController.$inject = [
* This controller is responsible to collecting data from the search form and modifying
* the underlying filters before passing them back to the parent controller.
*/
function InvoiceRegistrySearchModalController(ModalInstance, Services, filters, Notify, Store, Periods, util, DebtorGroups) {
function InvoiceRegistrySearchModalController(ModalInstance, Services, filters, Notify, Store, Periods, util) {
var vm = this;
var changes = new Store({ identifier : 'key' });
vm.filters = filters;
Expand All @@ -24,6 +24,13 @@ function InvoiceRegistrySearchModalController(ModalInstance, Services, filters,
vm.defaultQueries.limit = filters.limit;
}

// Set up page elements data (debtor select data)
vm.onSelectDebtor = onSelectDebtor;

function onSelectDebtor(debtorGroup) {
vm.searchQueries.debtor_group_uuid = debtorGroup.uuid;
}

// @TODO ideally these should be passed in when the modal is initialised
// these are known when the filter service is defined
var searchQueryOptions = [
Expand All @@ -42,11 +49,6 @@ function InvoiceRegistrySearchModalController(ModalInstance, Services, filters,
})
.catch(Notify.handleError);

DebtorGroups.read()
.then(function (result) {
vm.debtorGroups = result;
});

// custom filter user_id - assign the value to the searchQueries object
vm.onSelectUser = function onSelectUser(user) {
vm.searchQueries.user_id = user.id;
Expand Down Expand Up @@ -75,7 +77,7 @@ function InvoiceRegistrySearchModalController(ModalInstance, Services, filters,
};

// returns the filters to the journal to be used to refresh the page
vm.submit = function submit(form) {
vm.submit = function submit() {
// push all searchQuery values into the changes array to be applied
angular.forEach(vm.searchQueries, function (value, key) {
if (angular.isDefined(value)) {
Expand Down
Loading

0 comments on commit 31eeb8c

Please sign in to comment.