From 299d98b3f0316cf6e337d97a3a0fe442dbc3d214 Mon Sep 17 00:00:00 2001 From: Baptiste Lemoine Date: Tue, 28 Aug 2018 11:15:07 +0200 Subject: [PATCH] debounce to save --- .../views/logged/previsionnel.html.twig | 17 +++++------ assets/js/parts/main.js | 28 +++++++++++-------- caisse-bliss-frontend | 1 - 3 files changed, 25 insertions(+), 21 deletions(-) delete mode 160000 caisse-bliss-frontend diff --git a/app/Resources/views/logged/previsionnel.html.twig b/app/Resources/views/logged/previsionnel.html.twig index 1185e606..328867b0 100755 --- a/app/Resources/views/logged/previsionnel.html.twig +++ b/app/Resources/views/logged/previsionnel.html.twig @@ -13,7 +13,8 @@
- Chargement ... + + Chargement
Modifications sauvegardées @@ -30,11 +31,11 @@

Euros disponibles au départ: - +
Gains moyen par mois: - +

@@ -101,20 +102,20 @@ - + - + - + {{ e.repeat * e.amount }} - + @@ -124,7 +125,7 @@ € - + diff --git a/assets/js/parts/main.js b/assets/js/parts/main.js index b8c4926f..66005cec 100755 --- a/assets/js/parts/main.js +++ b/assets/js/parts/main.js @@ -229,6 +229,7 @@ angular initialLoadingDone: false, loading: false, lines: 24, + debounceTime: 300, // miliseconds to wait before updating model and saving changes /** * expenses kind of the user */ @@ -288,6 +289,19 @@ angular return previsionTable; }; + $scope.updateconf = (rep) => { + $scope.config.loading = false; + $scope.config.initialLoadingDone = true; + $scope.config.disponibility = rep.data.disponibility; + $scope.config.averageMonthlyEarnings = rep.data.averageMonthlyEarnings; + // default data when user has nothing saved + console.log('rep.data.expenses.length', rep.data.expenses.length) + if (!rep.data.expenses.length) { + $scope.expenses = exampleExpenses; + } else { + $scope.expenses = rep.data.expenses; + } + }; // http related calls $scope.fetchExpenses = () => { console.log('fetch expenses...'); @@ -295,17 +309,7 @@ angular $http.get('get-my-expenses').then((rep) => { console.log('get-my-expenses', rep.data.expenses); - $scope.config.loading = false; - $scope.config.initialLoadingDone = true; - $scope.config.disponibility = rep.data.disponibility; - $scope.config.averageMonthlyEarnings = rep.data.averageMonthlyEarnings; - // default data when user has nothing saved - console.log('rep.data.expenses.length', rep.data.expenses.length) - if (!rep.data.expenses.length) { - $scope.expenses = exampleExpenses; - } else { - $scope.expenses = rep.data.expenses; - } + $scope.updateconf(rep) }, $scope.manageError) }; @@ -324,7 +328,7 @@ angular }) .then((rep) => { console.log('save-my-expenses', rep); - $scope.config.loading = false; + $scope.updateconf(rep) }, $scope.manageError) }; diff --git a/caisse-bliss-frontend b/caisse-bliss-frontend deleted file mode 160000 index 474d8db5..00000000 --- a/caisse-bliss-frontend +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 474d8db5d74ec1283bf9b9e1a0fe03221538d44c