From 66a19034dd6538b311fbec64d551b412516eaf90 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Sun, 18 Jun 2017 00:43:28 +0200 Subject: [PATCH] Replace load arguments by controller variables, in order to link them to input controls later. --- src/operations/index.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/operations/index.js b/src/operations/index.js index bbf5206..60b6b20 100644 --- a/src/operations/index.js +++ b/src/operations/index.js @@ -60,6 +60,9 @@ var operationModule = angular.module('accountant.operations', [ var vm = this; + vm.minDate = moment().date(1).month(11).year(2016); + vm.maxDate = moment(); + /* * Add an empty operation. */ @@ -75,12 +78,12 @@ var operationModule = angular.module('accountant.operations', [ /* * Load operations. */ - vm.load = function(begin, end) { + vm.load = function() { return Operation.query({ // eslint-disable-next-line camelcase account_id: $routeParams.accountId, - begin: begin.format('YYYY-MM-DD'), - end: end.format('YYYY-MM-DD') + begin: vm.minDate.format('YYYY-MM-DD'), + end: vm.maxDate.format('YYYY-MM-DD') }); }; @@ -111,7 +114,7 @@ var operationModule = angular.module('accountant.operations', [ return operation.$save().then(function(operation) { Notification.success('Operation #' + operation.id + ' saved.'); - vm.operations = vm.load(moment().date(1).year(2000), moment()); + vm.operations = vm.load(); return operation; }, function(result){ @@ -142,7 +145,7 @@ var operationModule = angular.module('accountant.operations', [ return operation.$delete().then(function() { Notification.success('Operation #' + id + ' deleted.'); - vm.operations = vm.load(moment().date(1).year(2000), moment()); + vm.operations = vm.load(); return operation; }, function(result) { @@ -188,7 +191,7 @@ var operationModule = angular.module('accountant.operations', [ vm.onRangeSelected = angular.noop; }); - vm.operations = vm.load(moment().date(1).year(2000), moment()); + vm.operations = vm.load(); }) .component('operationModifyModalComponent', {