Skip to content

Commit

Permalink
fix(cashbox): ensure is_auxiliary is updated
Browse files Browse the repository at this point in the history
This commit should fix the issues in cashbox management where cashboxes
were not properly updated with the is_auxiliary field.  It also
generally improves the code by:
 1. Using the translate directive on the client.
 2. Using `db.one()` on the server.
 3. Using `FilterParser` on the server.

Closes Third-Culture-Software#976.
  • Loading branch information
Jonathan Niles committed Feb 9, 2017
1 parent 088b9ce commit 577cf8f
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 114 deletions.
10 changes: 4 additions & 6 deletions client/src/partials/cash/cashboxes/cashboxes.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@
<div class="bhima-title">

<ol class="headercrumb">
<li class="static">{{ "TREE.ADMIN" | translate }}</li>
<li class="title">{{ "CASHBOX.TITLE" | translate }}</li>
<!-- <span class="label label-warning">{{"BUTTON.CREATE" | translate}}</span> -->
<li class="static" translate>TREE.ADMIN</li>
<li class="title" translate>CASHBOX.TITLE</li>
</ol>

<div class="toolbar">
<div class="toolbar-item">
<button class="btn btn-default" ui-sref="cashboxes.create" data-method="create">
<i class="fa fa-plus"></i>
{{ "FORM.BUTTONS.ADD" | translate }}
<i class="fa fa-plus-square"></i>
<span translate>FORM.BUTTONS.ADD</span> <span translate>CASHBOX.CASHBOX</span>
</button>
</div>
</div>
</div>
</div>

<!-- Cashbox mangement content -->
<div class="flex-content">
<div ui-view autoscroll></div>
</div>
29 changes: 14 additions & 15 deletions client/src/partials/cash/cashboxes/update/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<p>
<a ui-sref="cashboxes.list">
<span class="fa fa-arrow-circle-left"></span>
{{ "CASHBOX.BACK" | translate }}
<span translate>CASHBOX.BACK</span>
</a>
</p>
</div>
Expand All @@ -22,31 +22,30 @@
<div>
<div>
<div class="form-group" ng-class="{ 'has-error' : CreateForm.$submitted && CreateForm.label.$invalid }">
<label class="control-label">
{{ "FORM.LABELS.NAME" | translate }}
<label class="control-label" translate>
FORM.LABELS.NAME
</label>
<input class="form-control" name="label" ng-model="UpdateCtrl.box.label" ng-maxlength="CashCtrl.maxLength" required autocomplete="off">
<div class="help-block" ng-messages="CreateForm.label.$error" ng-show="CreateForm.$submitted">
<div ng-messages-include="partials/templates/messages.tmpl.html"></div>
</div>
</div>

<label class="control-label">
{{ "FORM.LABELS.TYPE" | translate }}
</label>

<div class="form-group" ng-class="{ 'has-error' : CreateForm.$submitted && CreateForm.type.$invalid }">
<label class="control-label" translate>
FORM.LABELS.TYPE
</label>
<div class="radio">
<label>
<input type="radio" name="type" ng-model="UpdateCtrl.box.is_auxiliary" value="0" required>
{{ "FORM.LABELS.PRINCIPAL" | translate }}
<input type="radio" name="type" ng-model="UpdateCtrl.box.is_auxiliary" ng-value="0" required>
<span translate>FORM.LABELS.PRINCIPAL</span>
</label>
</div>

<div class="radio">
<label>
<input type="radio" name="type" ng-model="UpdateCtrl.box.is_auxiliary" value="1" required>
{{ "FORM.LABELS.AUXILIARY" | translate }}
<input type="radio" name="type" ng-model="UpdateCtrl.box.is_auxiliary" ng-value="1" required>
<span translate>FORM.LABELS.AUXILIARY</span>
</label>
</div>
<div class="help-block" ng-messages="CreateForm.type.$error" ng-show="CreateForm.$submitted">
Expand All @@ -55,16 +54,16 @@
</div>

<div class="form-group" ng-class="{ 'has-error' : CreateForm.$submitted && CreateForm.project.$invalid }">
<label class="control-label">
{{ "FORM.LABELS.PROJECT" | translate }}
<label class="control-label" translate>
FORM.LABELS.PROJECT
</label>
<select
class="form-control"
name="project"
ng-model="UpdateCtrl.box.project_id"
ng-options="project.id as project.name for project in CashCtrl.projects track by project.id"
required>
<option value="" disabled>{{ "FORM.SELECT.PROJECT" | translate }}</option>
<option value="" disabled translate>FORM.SELECT.PROJECT</option>
</select>
<div class="help-block" ng-messages="CreateForm.project.$error" ng-show="CreateForm.$submitted">
<div ng-messages-include="partials/templates/messages.tmpl.html"></div>
Expand All @@ -76,7 +75,7 @@
<div class="clearfix" style="margin-bottom : 5px">
<div class="pull-right" style="text-align : right">
<bh-loading-button loading-state="CreateForm.$loading">
{{ "FORM.BUTTONS.SUBMIT" | translate }}
<span translate>FORM.BUTTONS.SUBMIT</span>
</bh-loading-button>
</div>
</div>
Expand Down
42 changes: 21 additions & 21 deletions client/src/partials/cash/cashboxes/update/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<p>
<a ui-sref="cashboxes.list">
<span class="fa fa-arrow-circle-left"></span>
{{ "CASHBOX.BACK" | translate }}
<span translate>CASHBOX.BACK</span>
</a>
</p>
</div>
Expand All @@ -23,8 +23,8 @@
<div>
<div>
<div class="form-group" ng-class="{ 'has-error' : UpdateForm.$submitted && UpdateForm.label.$invalid }">
<label class="control-label">
{{ "FORM.LABELS.NAME" | translate }}
<label class="control-label" translate>
FORM.LABELS.NAME
</label>
<input class="form-control" name="label" ng-model="UpdateCtrl.box.label" ng-maxlength="CashCtrl.maxLength" required>
<div class="help-block" ng-messages="UpdateForm.label.$error" ng-show="UpdateForm.$submitted">
Expand All @@ -33,20 +33,20 @@
</div>

<div class="form-group" ng-class="{ 'has-error' : UpdateForm.$submitted && UpdateForm.type.$invalid }">
<label class="control-label">
{{ "FORM.LABELS.TYPE" | translate }}
<label class="control-label" translate>
FORM.LABELS.TYPE
</label>
<div class="radio">
<label>
<input type="radio" name="type" ng-model="UpdateCtrl.box.is_auxiliary" value="0" required>
{{ "FORM.LABELS.PRINCIPAL" | translate }}
<input type="radio" name="type" ng-model="UpdateCtrl.box.is_auxiliary" ng-value="0" required>
<span translate>FORM.LABELS.PRINCIPAL</span>
</label>
</div>

<div class="radio">
<label>
<input type="radio" name="type" ng-model="UpdateCtrl.box.is_auxiliary" value="1" required>
{{ "FORM.LABELS.AUXILIARY" | translate }}
<input type="radio" name="type" ng-model="UpdateCtrl.box.is_auxiliary" ng-value="1" required>
<span translate>FORM.LABELS.AUXILIARY</span>
</label>
</div>
<div class="help-block" ng-messages="UpdateForm.type.$error" ng-show="UpdateForm.$submitted">
Expand All @@ -55,31 +55,31 @@
</div>

<div class="form-group">
<label>{{ "FORM.LABELS.CURRENCIES" | translate }}</label>
<label translate>FORM.LABELS.CURRENCIES</label>
<div ng-repeat="currency in UpdateCtrl.currencies | orderBy:currency.name track by currency.id">
<p ng-class="{ 'text-danger' : !currency.configured }">
<i class="fa fa-alert" ng-if="!currency.configured"></i> {{ currency.name }} ({{ currency.symbol}})
<a class="btn btn-xs btn-default" href="" ng-click="UpdateCtrl.configureCurrency(currency)" data-currency-id="{{ currency.id }}">
<i class="fa fa-pencil-square-o"></i> {{ "FORM.BUTTONS.CONFIGURE" | translate }}
<a class="btn btn-xs btn-default" href ng-click="UpdateCtrl.configureCurrency(currency)" data-currency-id="{{ ::currency.id }}">
<i class="fa fa-pencil-square-o"></i> <span translate>FORM.BUTTONS.CONFIGURE</span>
</a>
</p>
<p ng-if="!currency.configured" class="help-block">
{{ "FORM.INFO.NOT_CONFIGURED" | translate }}
<p ng-if="!currency.configured" class="help-block" translate>
FORM.INFO.NOT_CONFIGURED
</p>
</div>
</div>

<div class="form-group" ng-class="{ 'has-error' : UpdateForm.$submitted && UpdateForm.project.$invalid }">
<label class="control-label">
{{ "FORM.LABELS.PROJECT" | translate }}
<label class="control-label" translate>
FORM.LABELS.PROJECT
</label>
<select
class="form-control"
name="project"
ng-model="UpdateCtrl.box.project_id"
ng-options="project.id as project.name for project in CashCtrl.projects"
required>
<option value="" disabled>{{ "FORM.SELECT.PROJECT" | translate }}</option>
<option value="" disabled translate>FORM.SELECT.PROJECT</option>
</select>
<div class="help-block" ng-messages="UpdateForm.project.$error" ng-show="UpdateForm.$submitted">
<div ng-messages-include="partials/templates/messages.tmpl.html"></div>
Expand All @@ -91,7 +91,7 @@
<div class="clearfix" style="margin-bottom : 5px">
<div class="pull-right" style="text-align : right">
<bh-loading-button loading-state="UpdateForm.$loading">
{{ "FORM.BUTTONS.SUBMIT" | translate }}
<span translate>FORM.BUTTONS.SUBMIT</span>
</bh-loading-button>
</div>
</div>
Expand All @@ -100,12 +100,12 @@

<div class="col-md-7">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-ellipsis-h"></i> {{ "CASHBOX.ACTIONS" | translate }}
<div class="panel-heading" translate>
CASHBOX.ACTIONS
</div>
<div class="panel-body">
<button class="btn btn-danger" type="button" ng-click="UpdateCtrl.remove(UpdateCtrl.box)" data-method="delete">
<i class="fa fa-trash-o"></i> {{ "FORM.BUTTONS.DELETE" | translate }} {{ "CASHBOX.CASHBOX" | translate }}
<i class="fa fa-trash-o"></i> <span translate>FORM.BUTTONS.DELETE</span> <span translate>CASHBOX.CASHBOX</span>
</button>
</div>
</div>
Expand Down
Loading

0 comments on commit 577cf8f

Please sign in to comment.