Skip to content

Commit

Permalink
fix(journal): comments can be removed
Browse files Browse the repository at this point in the history
This commit allows the journal to remove comments.  Additionally, the
comment modal has been improved such that, if a unique value is used for
a comment, it is displayed in the input.  This makes the component feel
more like it belongs on the page.
  • Loading branch information
jniles committed Sep 25, 2017
1 parent 76825d2 commit 9bd7a36
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
14 changes: 5 additions & 9 deletions client/src/modules/account_statement/modals/comment.modal.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<form name="ModalForm"
ng-submit="$ctrl.submit(ModalForm)"
novalidate>

<form name="ModalForm" bh-submit="$ctrl.submit(ModalForm)" novalidate>
<div class="modal-header" translate>
ACCOUNT_STATEMENT.COMMENT
</div>
Expand All @@ -12,9 +9,8 @@
<label translate>ACCOUNT_STATEMENT.SELECTED_ROWS</label>
</div>

<div class="form-group"
ng-class="{ 'has-error' : ModalForm.$submitted && ModalForm.comment.$invalid }">
<input type="text" class="form-control" name="comment" ng-model="$ctrl.comment" required>
<div class="form-group" ng-class="{ 'has-error' : ModalForm.$submitted && ModalForm.comment.$invalid }">
<input type="text" class="form-control" name="comment" ng-model="$ctrl.comment">

<div class="help-block" ng-messages="ModalForm.comment.$error" ng-show="ModalForm.$submitted">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
Expand All @@ -23,11 +19,11 @@
</div>

<div class="modal-footer">
<button type="button" class="btn btn-default" ng-click="$ctrl.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="$ctrl.$loading">
<span translate>FORM.BUTTONS.SUBMIT</span>
</bh-loading-button>
</div>
</form>
</form>
1 change: 0 additions & 1 deletion client/src/modules/journal/journal.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ function JournalController(

Journal.openCommentModal({ rows : selectedRows })
.then(function (comment) {
if (!comment) { return; }
updateGridComment(selectedRows, comment);
Notify.success('ACCOUNT_STATEMENT.SUCCESSFULLY_COMMENTED');
})
Expand Down
14 changes: 14 additions & 0 deletions client/src/modules/journal/modals/comment.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,25 @@ CommentJournalController.$inject = [
// Comment Account Statement Controller
function CommentJournalController(Instance, ModalParameters, Journal, Notify) {
var vm = this;
var comments;

vm.cancel = Instance.dismiss;
vm.submit = submit;
vm.rows = ModalParameters.rows;

// get the unique comments
comments = vm.rows
.map(function (row) {
return row.entity.comment;
})
.filter(function (comment, index, array) {
return array.indexOf(comment) === index;
});

if (comments.length === 1) {
vm.comment = comments[0];
}

// submit the comment
function submit(form) {
if (form.$invalid) { return; }
Expand Down
3 changes: 2 additions & 1 deletion server/models/procedures.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,6 @@ BEGIN
sm.document_uuid = document_uuid
GROUP BY inv.uuid;
END $$
DELIMITER ;


/*
Expand Down Expand Up @@ -1648,3 +1647,5 @@ BEGIN
JOIN account ON account.id = combined.account_id
ORDER BY account.number;
END $$

DELIMITER ;

0 comments on commit 9bd7a36

Please sign in to comment.