Skip to content

Commit

Permalink
Merge #3147
Browse files Browse the repository at this point in the history
3147: (Low Priority) Chore: minor tweaks to ui standards r=jniles a=sfount

This commit updates a few small UI issues on the cashbox management
module. It also cleans up client code failing lint.

Closes #3122

Co-authored-by: Steven Fountain <[email protected]>
  • Loading branch information
bors[bot] and sfount committed Sep 6, 2018
2 parents c1639ec + e36e238 commit 4ac94e1
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 57 deletions.
6 changes: 3 additions & 3 deletions client/src/modules/cash/cashboxes/cashboxes.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

<!-- edit cashbox -->
<li ng-if="CashCtrl.isEditState()" class="title">
{{ CashCtrl.state.params.label }}
{{ CashCtrl.state.params.label }}
<span class="label label-info" translate>FORM.LABELS.EDIT</span>
</li>

<!-- create cashbox -->
<li ng-if="CashCtrl.isCreateState()" class="title">
<span ng-if="CashCtrl.isCreateState()" class="title">
<span class="label label-success" translate>FORM.LABELS.CREATE</span>
</li>
</span>
</ol>

<div class="toolbar" ng-if="!CashCtrl.isUpdateState()">
Expand Down
20 changes: 12 additions & 8 deletions client/src/modules/cash/cashboxes/cashboxes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
angular.module('bhima.controllers')
.controller('CashboxController', CashboxController);
.controller('CashboxController', CashboxController);

CashboxController.$inject = [
'SessionService', 'ProjectService', 'CashboxService', 'util',
Expand All @@ -14,7 +14,7 @@ CashboxController.$inject = [
* ease of use thought the application.
*/
function CashboxController(Session, Projects, Boxes, util, Notify, $state) {
var vm = this;
const vm = this;

// bind variables
vm.state = $state;
Expand Down Expand Up @@ -47,14 +47,18 @@ function CashboxController(Session, Projects, Boxes, util, Notify, $state) {
// fired on startup
function startup() {
// load projects
Projects.read().then(function (projects) {
vm.projects = projects;
}).catch(Notify.handleError);
Projects.read()
.then((projects) => {
vm.projects = projects;
})
.catch(Notify.handleError);

// load cashboxes
Boxes.read().then(function (cashboxes) {
vm.cashboxes = cashboxes;
}).catch(Notify.handleError);
Boxes.read()
.then((cashboxes) => {
vm.cashboxes = cashboxes;
})
.catch(Notify.handleError);
}

startup();
Expand Down
61 changes: 30 additions & 31 deletions client/src/modules/cash/cashboxes/cashboxes.routes.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
angular.module('bhima.routes')
.config(['$stateProvider', function ($stateProvider) {
$stateProvider
.state('cashboxes', {
abstract : true,
url : '/cashboxes',
controller : 'CashboxController as CashCtrl',
templateUrl : 'modules/cash/cashboxes/cashboxes.html',
params : {
label : null,
},
})
.config(['$stateProvider', configureCashBoxRoutes]);

.state('cashboxes.list', {
url : '',
templateUrl : 'modules/cash/cashboxes/cashboxes.list.html',
})

.state('cashboxes.create', {
url : '/create',
templateUrl : 'modules/cash/cashboxes/update/add.html',
controller : 'CashboxUpdateController as UpdateCtrl',
})

.state('cashboxes.edit', {
url : '/:uuid/edit',
params : {
id : { squash: true, value: null },
},
templateUrl : 'modules/cash/cashboxes/update/edit.html',
controller : 'CashboxUpdateController as UpdateCtrl',
});
}]);
function configureCashBoxRoutes($stateProvider) {
$stateProvider
.state('cashboxes', {
abstract : true,
url : '/cashboxes',
controller : 'CashboxController as CashCtrl',
templateUrl : 'modules/cash/cashboxes/cashboxes.html',
params : {
label : null,
},
})
.state('cashboxes.list', {
url : '',
templateUrl : 'modules/cash/cashboxes/cashboxes.list.html',
})
.state('cashboxes.create', {
url : '/create',
templateUrl : 'modules/cash/cashboxes/update/add.html',
controller : 'CashboxUpdateController as UpdateCtrl',
})
.state('cashboxes.edit', {
url : '/:uuid/edit',
params : {
id : { squash : true, value : null },
},
templateUrl : 'modules/cash/cashboxes/update/edit.html',
controller : 'CashboxUpdateController as UpdateCtrl',
});
}
22 changes: 11 additions & 11 deletions client/src/modules/cash/cashboxes/configure_currency/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ CashboxCurrencyModalController.$inject = [
* cashboxes. Each cashbox must have a currencied account defined for each currency
* supported by the application.
*/
function CashboxCurrencyModalController(ModalInstance, Accounts, Boxes, currency, cashbox, data, Notify) {
var vm = this;
function CashboxCurrencyModalController(ModalInstance, Accounts, CashBoxes, currency, cashbox, data, Notify) {
const vm = this;

// if a currency matches, we are updating. Otherwise, we are creating.
var currencyIds = cashbox.currencies.map(function (row) {
const currencyIds = cashbox.currencies.map((row) => {
return row.currency_id;
});

// determine whether we will send a POST or a PUT request to the server
var method = (currencyIds.indexOf(currency.id) > -1) ?
'update' :
'create';
const method = (currencyIds.indexOf(currency.id) > -1)
? 'update'
: 'create';

// bind data
vm.currency = currency;
Expand Down Expand Up @@ -51,19 +51,19 @@ function CashboxCurrencyModalController(ModalInstance, Accounts, Boxes, currency
function submit(form) {

// if the form has errors, exit immediately
if (form.$invalid) { return; }
if (form.$invalid) { return null; }

// if the form was never touched, just dismiss it.
if (form.$pristine) { vm.dismiss(); }

// send either a create or an update request to the server
var promise = (method === 'create') ?
Boxes.currencies.create(vm.cashbox.id, vm.data) :
Boxes.currencies.update(vm.cashbox.id, vm.data);
const promise = (method === 'create')
? CashBoxes.currencies.create(vm.cashbox.id, vm.data)
: CashBoxes.currencies.update(vm.cashbox.id, vm.data);

// upon successful completion, close the modal or error out
return promise
.then(function () { ModalInstance.close(); })
.then(() => { ModalInstance.close(); })
.catch(Notify.handleError);
}
}
7 changes: 4 additions & 3 deletions client/src/modules/cash/cashboxes/update/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@
</div>

<div class="col-md-7">
<div class="panel panel-default">
<div class="panel-heading" translate>
CASHBOX.ACTIONS
<div class="panel panel-warning">
<div class="panel-heading">
<i class="fa fa-exclamation-triangle"></i>
<span translate>CASHBOX.ACTIONS</span>
</div>
<div class="panel-body">
<button class="btn btn-danger" type="button" ng-click="UpdateCtrl.remove(UpdateCtrl.box)" data-method="delete">
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/cash/cashboxes/update/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function CashboxUpdateController($state, Modal, ModalService, Notify, Boxes, Cur
function submit(form) {
if (form.$invalid) {
Notify.danger('FORM.ERRORS.HAS_ERRORS');
return;
return null;
}

const box = angular.copy(vm.box);
Expand Down

0 comments on commit 4ac94e1

Please sign in to comment.