This repository has been archived by the owner on Jan 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
correct todo delete error, try angular-dialogs and translations
- Loading branch information
Showing
7 changed files
with
97 additions
and
22 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,41 @@ | ||
'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(); | ||
$scope.todos.push(todo); | ||
}; | ||
|
||
|
||
$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'); | ||
} | ||
); | ||
}; | ||
|
||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<div class="modal fade"> | ||
<div class="modal-dialog modal-lg"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<button type="button" class="close" ng-click="close()" data-dismiss="modal" aria-hidden="true">×</button> | ||
<h2 class="modal-title">Edit Todo</h2> | ||
</div> | ||
<div class="modal-body"> | ||
|
||
<form name="todo-edit" class="form-horizontal" role="form"> | ||
<div class="form-group"> | ||
<label for="todoname">Description:</label> | ||
<input name="todoname" type="text" ng-model="todo.name" class="form-control"> | ||
</div> | ||
<div class="form-group"> | ||
<label for="assignees">Assign task to:</label> | ||
<select name="assignees" id="assignees" class="form-control" | ||
ng-options="assignee.name for assignee in assignees track by assignee.id" | ||
ng-model="selectedAssignee"></select> | ||
</div> | ||
<div class="form-group"> | ||
<label for="labels">Labels:</label> | ||
<select name="labels" id="labels" class="form-control" | ||
ng-options="label.name for label in labels track by label.id" | ||
ng-model="selectedLabels" multiple></select> | ||
</div> | ||
|
||
</form> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" ng-click="submit(todo)" class="btn btn-primary" data-dismiss="modal">OK</button> | ||
<button type="button" ng-click="cancel()" class="btn">Cancel</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters