diff --git a/app/api/db/app.db.sqlite b/app/api/db/app.db.sqlite index b705e71..962d2f0 100644 Binary files a/app/api/db/app.db.sqlite and b/app/api/db/app.db.sqlite differ diff --git a/app/index.html b/app/index.html index 1dadb78..dcf8588 100644 --- a/app/index.html +++ b/app/index.html @@ -11,8 +11,9 @@ - + + @@ -20,6 +21,7 @@ +

kikou

@@ -37,7 +39,6 @@ - @@ -45,6 +46,11 @@ + + + + + @@ -53,6 +59,6 @@ - + diff --git a/app/scripts/app.js b/app/scripts/app.js index a28e094..beb6a26 100644 --- a/app/scripts/app.js +++ b/app/scripts/app.js @@ -1,12 +1,15 @@ 'use strict'; - +//register all modules angular.module('mytodoApp', [ 'ngRoute', 'ngCookies', 'ngResource', 'ngSanitize', 'ui.sortable', - 'xeditable' + 'pascalprecht.translate', + 'xeditable', + 'ui.bootstrap', + 'dialogs.main' //https://github.com/m-e-conroy/angular-dialog-service ]) .config(['$routeProvider', function($routeProvider){ $routeProvider @@ -22,8 +25,22 @@ angular.module('mytodoApp', [ // this is to allow calling GET /todos/ instead of /todos $resourceProvider.defaults.stripTrailingSlashes = false; }]) + .config(['dialogsProvider',function(dialogsProvider){ + + dialogsProvider.setSize('sm'); + }]) + .config(['$translateProvider',function($translateProvider){ + + $translateProvider.useSanitizeValueStrategy('sanitize'); + $translateProvider.preferredLanguage('en-US'); + + $translateProvider.translations('en-US',{ + DIALOGS_OK: 'OK' + }); + + }]) .factory('Todo', ['$resource', function($resource){ - return $resource('/todos/:id', {id:'@id'}, { + return $resource('/api/todos/:id', {id:'@id'}, { update: { method: 'PUT' // this method issues a PUT request } diff --git a/app/scripts/controllers/todos.js b/app/scripts/controllers/todos.js index d8bef79..6413ca4 100644 --- a/app/scripts/controllers/todos.js +++ b/app/scripts/controllers/todos.js @@ -1,18 +1,26 @@ 'use strict'; - +//doc for dialog: https://github.com/m-e-conroy/angular-dialog-service angular.module('mytodoApp') - .controller('MainCtrl', function ($scope, Todo) { + .controller('MainCtrl', function($scope, Todo, dialogs) { - //fetch all todos + //fetch all todos' $scope.todos = Todo.query(); - $scope.delete = function(todo){ - todo.$delete(); - $scope.todos.splice($scope.todos.indexOf(todo), 1); + //$scope.alerts = alertService.get(); + + $scope.delete = function(index) { + var todo = $scope.todos[index]; + Todo.delete(todo, function() { + dialogs.notify('delete', 'cool'); + $scope.todos.splice($scope.todos.indexOf(todo), 1); + }, function() { + dialogs.error('Error', 'server error'); + }); + }; - - $scope.add = function(){ + + $scope.add = function() { var todo = new Todo(); todo.name = $scope.name; todo.$save(); @@ -20,9 +28,14 @@ angular.module('mytodoApp') }; - $scope.update = function(todo){ - todo.$update(); + $scope.update = function(name, index) { + var todo = $scope.todos[index]; + todo.name = name; + Todo.update(todo, + function() {}, + function() { //error + dialogs.error('Error', 'server error'); + } + ); }; - - - }); + }); \ No newline at end of file diff --git a/app/views/todo-edit.html b/app/views/todo-edit.html new file mode 100644 index 0000000..7856001 --- /dev/null +++ b/app/views/todo-edit.html @@ -0,0 +1,37 @@ + + diff --git a/app/views/todos.html b/app/views/todos.html index d828882..3ccf40b 100644 --- a/app/views/todos.html +++ b/app/views/todos.html @@ -1,5 +1,6 @@

My todos

+
@@ -14,13 +15,14 @@

My todos

+