Skip to content

Commit

Permalink
fix(purchases): use proper checkbox html
Browse files Browse the repository at this point in the history
This commit fixes the purchase registry to use bootstrap-compliant HTML in
its search modal.
  • Loading branch information
Jonathan Niles committed Feb 16, 2017
1 parent 1b729d9 commit cc86400
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 42 deletions.
35 changes: 16 additions & 19 deletions client/src/partials/purchases/modals/search.modal.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,45 @@
angular.module('bhima.controllers')
.controller('SearchPurchaseOrderModalController', SearchPurchaseOrderModalController);
.controller('SearchPurchaseOrderModalController', SearchPurchaseOrderModalController);

// dependencies injections
SearchPurchaseOrderModalController.$inject = [
'UserService', 'SupplierService', 'NotifyService', '$uibModalInstance', 'SearchFilterFormatService'
'UserService', 'SupplierService', 'NotifyService', '$uibModalInstance', 'SearchFilterFormatService',
];

function SearchPurchaseOrderModalController(Users, Suppliers, Notify, Instance, SearchFilterFormat) {
var vm = this;

// gloabal variables
// global variables
var noMissingDatePart;

// global methods
vm.validate = validate;
vm.cancel = Instance.close;
vm.submit = submit;

// init
// init
init();

// load users
// load users
Users.read()
.then(function (users) {
.then(function (users) {
vm.users = users;
})
.catch(Notify.handleError);
})
.catch(Notify.handleError);

// load suppliers
// load suppliers
Suppliers.read()
.then(function (suppliers) {
.then(function (suppliers) {
vm.suppliers = suppliers;
})
.catch(Notify.handleError);
})
.catch(Notify.handleError);

function init() {
vm.bundle = {
dateFrom: new Date(),
dateTo: new Date(),
is_confirmed: 0,
is_received: 0,
is_cancelled: 0
vm.bundle = {
dateFrom : new Date(),
dateTo : new Date(),
};

validate();
}

Expand All @@ -54,5 +52,4 @@ function SearchPurchaseOrderModalController(Users, Suppliers, Notify, Instance,
noMissingDatePart = (vm.bundle.dateFrom && vm.bundle.dateTo) || (!vm.bundle.dateFrom && !vm.bundle.dateTo);
vm.validDateRange = noMissingDatePart ? true : false;
}

}
38 changes: 19 additions & 19 deletions client/src/partials/purchases/modals/search.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
<!-- user -->
<div class="form-group">
<label class="control-label" translate>FORM.LABELS.USER</label>

<ui-select name="user" ng-model="$ctrl.bundle.user_id" theme="bootstrap">
<ui-select name="user" ng-model="$ctrl.bundle.user_id">
<ui-select-match>
<span>{{$select.selected.display_name}}</span>
</ui-select-match>
Expand All @@ -61,32 +60,33 @@

<!-- status -->
<div class="form-group">
<fieldset>
<legend translate>FORM.LABELS.STATUS</legend>
<label>
<input type="checkbox" name="is_confirmed" ng-true-value="1" ng-false-value="0" ng-model="$ctrl.bundle.is_confirmed">
<span translate>PURCHASES.STATUS.CONFIRMED</span>
</label><br>
<p class="control-label" style="margin-bottom:5px;">
<strong translate>FORM.LABELS.STATUS</strong>
</p>

<label class="checkbox-inline">
<input type="checkbox" name="is_confirmed" ng-true-value="1" ng-false-value="0" ng-model="$ctrl.bundle.is_confirmed">
<span translate>PURCHASES.STATUS.CONFIRMED</span>
</label>

<label>
<input type="checkbox" name="is_received" ng-true-value="1" ng-false-value="0" ng-model="$ctrl.bundle.is_received">
<span translate>PURCHASES.STATUS.RECEIVED</span>
</label><br>
<label class="checkbox-inline">
<input type="checkbox" name="is_received" ng-true-value="1" ng-false-value="0" ng-model="$ctrl.bundle.is_received">
<span translate>PURCHASES.STATUS.RECEIVED</span>
</label>

<label>
<input type="checkbox" name="is_cancelled" ng-true-value="1" ng-false-value="0" ng-model="$ctrl.bundle.is_cancelled">
<span translate>PURCHASES.STATUS.CANCELLED</span>
</label>
</fieldset>
<label class="checkbox-inline">
<input type="checkbox" name="is_cancelled" ng-true-value="1" ng-false-value="0" ng-model="$ctrl.bundle.is_cancelled">
<span translate>PURCHASES.STATUS.CANCELLED</span>
</label>
</div>
</fieldset>

</div>

<div class="modal-footer">
<button type="button" class="btn btn-default" ng-click="$ctrl.cancel()" data-method="cancel" translate>
<button type="button" class="btn btn-default" ng-click="$ctrl.cancel()" data-method="cancel" translate>
FORM.BUTTONS.CLOSE
</button>

<bh-loading-button loading-state="ModalForm.$loading" disabled="!$ctrl.validDateRange">
<span translate>FORM.BUTTONS.SUBMIT</span>
</bh-loading-button>
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/finance/cash.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ function reference(req, res, next) {
FROM cash JOIN project ON cash.project_id = project.id
)c WHERE c.reference = ?;`;

db.one(sql, [ ref , 'cash'])
db.one(sql, [ ref ], ref, 'cash')
.then(function (payment) {
// references should be unique - return the first one
res.status(200).json(payment);
Expand Down
5 changes: 2 additions & 3 deletions server/lib/filter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

const _ = require('lodash');
const db = require('./db');

const RESERVED_KEYWORDS = ['limit', 'detailed'];
const DEFAULT_LIMIT_KEY = 'limit';
Expand Down Expand Up @@ -124,7 +122,7 @@ class FilterParser {
* @method reversed
*
* @description
* 'reversed criteria' currently stands as joining with the voucer table on reference_uuid
* 'reversed criteria' currently stands as joining with the voucher table on reference_uuid
* if a voucher exists for this record it will contain a `type_id`
*
* @TODO this is the first example of a 'toggle' filter, this should be more carefully
Expand Down Expand Up @@ -242,6 +240,7 @@ class FilterParser {
if (limit) {
limitString = `LIMIT ${limit} `;
}

return limitString;
}
}
Expand Down

0 comments on commit cc86400

Please sign in to comment.