Fix: Error in ledger where show results were not updated as the $watch was only for hidden items and did not detect and filter the change in the list.
Fix: Error in ledger where if an entry was selected, if show button was triggered using the return key, it would open that entry instead of loading data
This commit is contained in:
1 parent
d99fc89e34
commit
09a27e099e
6 files changed
+66
-20
No files matched your search
+2
-14
@@ -125,21 +125,9 @@ overlordDirective.directive('chosen', ['$parse', function ($parse) {
|
||||
overlordDirective.directive('keypress', [function () {
|
||||
return function (scope, element, attrs) {
|
||||
var keypress = scope.$eval(attrs.keypress || '{}');
|
||||
for (var k in keypress) {
|
||||
if (keypress.hasOwnProperty(k)) {
|
||||
(function (k, val) {
|
||||
Mousetrap.bind(k, val);
|
||||
})(k, keypress[k]);
|
||||
}
|
||||
}
|
||||
Mousetrap.bind(keypress);
|
||||
element.on('$destroy', function () {
|
||||
for (var k in keypress) {
|
||||
if (keypress.hasOwnProperty(k)) {
|
||||
(function (k) {
|
||||
Mousetrap.unbind(k);
|
||||
})(k);
|
||||
}
|
||||
}
|
||||
Mousetrap.unbind(keypress);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
@@ -35,12 +35,20 @@ var LedgerCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'ledger
|
||||
$scope.selected = index;
|
||||
};
|
||||
|
||||
|
||||
// Replace with $watchGroup in AngularJS 1.3+
|
||||
$scope.$watch('hidden', function () {
|
||||
var filtered = $scope.doFilter($scope.hidden, $scope.info.Body);
|
||||
$scope.ledger = filtered.Body;
|
||||
$scope.footer = filtered.Footer;
|
||||
}, true);
|
||||
|
||||
$scope.$watch('info', function () {
|
||||
var filtered = $scope.doFilter($scope.hidden, $scope.info.Body);
|
||||
$scope.ledger = filtered.Body;
|
||||
$scope.footer = filtered.Footer;
|
||||
}, true);
|
||||
|
||||
$scope.doFilter = _.memoize(function (hidden, input) {
|
||||
var data = angular.copy(input),
|
||||
debit = 0, credit = 0, running = 0;
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
|
||||
var ReconcileCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'reconcile', 'Reconcile', 'Account', function ($scope, $routeParams, $location, asDate, reconcile, Reconcile, Account) {
|
||||
$scope.info = reconcile;
|
||||
$scope.hidden = [];
|
||||
$scope.show = function () {
|
||||
var id = $scope.info.Account.LedgerID,
|
||||
startDate = asDate($scope.info.StartDate),
|
||||
finishDate = asDate($scope.info.FinishDate);
|
||||
if (id === $routeParams.id && startDate === $routeParams.StartDate && finishDate === $routeParams.FinishDate) {
|
||||
Reconcile.get({id: id, StartDate: startDate, FinishDate: finishDate}, function (data) {
|
||||
$scope.doFilter.cache = {};
|
||||
$scope.info = data;
|
||||
});
|
||||
} else {
|
||||
@@ -49,7 +47,7 @@ var ReconcileCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'rec
|
||||
};
|
||||
|
||||
$scope.shortcuts = {
|
||||
'up': function () {
|
||||
'up': function (e) {
|
||||
if ($scope.selected > 0) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = $scope.selected -= 1;
|
||||
@@ -58,7 +56,7 @@ var ReconcileCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'rec
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
'down': function () {
|
||||
'down': function (e) {
|
||||
if ($scope.selected < $scope.info.Body.length - 1) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = $scope.selected += 1;
|
||||
@@ -67,7 +65,7 @@ var ReconcileCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'rec
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
'enter': function () {
|
||||
'enter': function (e) {
|
||||
var path = $scope.info.Body[$scope.selected].Url.replace(/^(?:\/\/|[^\/]+)*/, "");
|
||||
$scope.$apply(function () {
|
||||
$location.path(path).search('StartDate', null).search('FinishDate', null);
|
||||
|
||||
Reference in new issue
Block a user