Skip to content

Commit

Permalink
fix(stock): force refresh grid index
Browse files Browse the repository at this point in the history
This commit forces the grid to use the correct index by referencing it
in the HTML.  Previously, grid cells were being reused instead of being
updated.  By referencing the index directly, the grid responds with the
correct index.

Closes #2492.
  • Loading branch information
jniles committed Feb 7, 2018
1 parent 28cbc25 commit 5849d99
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
6 changes: 3 additions & 3 deletions client/src/modules/stock/StockForm.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function StockFormService(StockItem, Store, AppCache, Session, $timeout) {
StockForm.prototype.setup = function setup() {
this.details = {
date: new Date(),
user_id: Session.user.id
user_id: Session.user.id,
};
};

Expand Down Expand Up @@ -80,14 +80,14 @@ function StockFormService(StockItem, Store, AppCache, Session, $timeout) {
StockForm.prototype.clear = function clear() {
this.store.clear();

$timeout(function () {
$timeout(() => {
this.setup();

// validate() is only set up to test on submission as it checks the validity
// of individual items which will not have been configured, manually
// reset error state
delete this._error;
}.bind(this));
});
};

/**
Expand Down
10 changes: 1 addition & 9 deletions client/src/modules/stock/entry/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,7 @@ function StockEntryController(
}

function removeItem(index) {
const data = vm.gridOptions.data.filter((row, i)=>{
if(index !== i){
return true;
}
return false;
});
vm.gridOptions.data = data;
vm.stockForm.store.data = data;

vm.stockForm.removeItem(index);
hasValidInput();
}

Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/stock/entry/templates/actions.tmpl.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="ui-grid-cell-contents text-center">
<a class="text-action" ng-click="grid.appScope.removeItem(grid.renderContainers.body.visibleRowCache.indexOf(row))" tabindex="-1"><i class="fa fa-trash-o text-danger"></i></a>
<a class="text-action" ng-click="grid.appScope.removeItem(row.entity.id)" tabindex="-1"><i class="fa fa-trash-o text-danger"></i></a>
</div>

0 comments on commit 5849d99

Please sign in to comment.