From fa3efacb4be857e754c287fb5e7f98d72b360376 Mon Sep 17 00:00:00 2001 From: jhasselgren Date: Tue, 12 Aug 2014 23:57:57 +0200 Subject: [PATCH] Autosave --- app/js/controller/ActivitiesController.js | 36 +++++++++++------------ app/js/directives.js | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/js/controller/ActivitiesController.js b/app/js/controller/ActivitiesController.js index 7f5f396..3749629 100644 --- a/app/js/controller/ActivitiesController.js +++ b/app/js/controller/ActivitiesController.js @@ -37,14 +37,14 @@ app.controller('ActivityController', function($scope, $sce, $location, $interval else{ console.log("Scope not modified"); } - }, 60000); + }, 30000); } var timeout = null; - $scope.$watch('data.currentActivity.description', function(newVal, oldVal){ + $scope.$watch('data.currentActivity', function(newVal, oldVal){ if(newVal != oldVal){ if(timeout){ @@ -52,26 +52,26 @@ app.controller('ActivityController', function($scope, $sce, $location, $interval } timeout = $timeout(function(){ - console.log("data.currentActivity.description changed"); + console.log("data.currentActivity changed"); $scope.modified = true; console.log("modified = true"); },1000); }; - }); - - $scope.$watch('data.currentActivity.shortDescription', function(newVal, oldVal){ - if(newVal != oldVal){ - if(timeout){ - $timeout.cancel(timeout); - } - - timeout = $timeout(function(){ - console.log("data.currentActivity.shortDescription changed"); - $scope.modified = true; - console.log("modified = true"); - },1000); - }; - }); + }, true); + +// $scope.$watch('data.currentActivity.shortDescription', function(newVal, oldVal){ +// if(newVal != oldVal){ +// if(timeout){ +// $timeout.cancel(timeout); +// } +// +// timeout = $timeout(function(){ +// console.log("data.currentActivity.shortDescription changed"); +// $scope.modified = true; +// console.log("modified = true"); +// },1000); +// }; +// }); $scope.$on('currentActivity.updated', function(event){ console.log(event); diff --git a/app/js/directives.js b/app/js/directives.js index 6845948..a581a84 100644 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -167,7 +167,7 @@ app.directive("thing", function(Data, backEndAdress, activityDataService){ scope: { thing: "=" }, - controller: function($scope){ + controller: function($rootScope, $scope){ this.activityId = Data.currentActivity.id; this.backEndAdress = backEndAdress;