# HG changeset patch # User rougeronj # Date 1427968927 -7200 # Node ID dac1df90b49ea9a44c3bc34b3652eb1f7c695181 # Parent ce9aefce6e41e978e778f92f60cb9bc69c16de83 fucntion and button to add a book diff -r ce9aefce6e41 -r dac1df90b49e client/app/books/add_modal.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/app/books/add_modal.html Thu Apr 02 12:02:07 2015 +0200 @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff -r ce9aefce6e41 -r dac1df90b49e client/app/books/book.css --- a/client/app/books/book.css Thu Apr 02 11:58:19 2015 +0200 +++ b/client/app/books/book.css Thu Apr 02 12:02:07 2015 +0200 @@ -41,3 +41,13 @@ margin-top: 20px; padding: 6px 0 10px; } + +.add-book{ + padding:20px; +} +.add-book input{ + margin-bottom: 10px; +} +.add-book button{ + +} \ No newline at end of file diff -r ce9aefce6e41 -r dac1df90b49e client/app/books/books.html --- a/client/app/books/books.html Thu Apr 02 11:58:19 2015 +0200 +++ b/client/app/books/books.html Thu Apr 02 12:02:07 2015 +0200 @@ -1,9 +1,10 @@

Liste des books :

\ No newline at end of file + + \ No newline at end of file diff -r ce9aefce6e41 -r dac1df90b49e client/app/books/books_controller.js --- a/client/app/books/books_controller.js Thu Apr 02 11:58:19 2015 +0200 +++ b/client/app/books/books_controller.js Thu Apr 02 12:02:07 2015 +0200 @@ -5,11 +5,18 @@ .service('booksModel', function(searchApi) { this.books = searchApi.listBooks.query({format:'json'}); }) - .controller('booksCtrl', function($scope, $location, booksModel){ + .controller('booksCtrl', function($scope, $location, booksModel, $modal){ $scope.books = booksModel.books; $scope.searchSubmit = function(){ $location.path('/search/' + $scope.q); }; + + $scope.addBook = function () { + $modal.open({ + templateUrl: 'books/add_modal.html', + controller: 'ModalAddBookCtrl' + }); + }; }) .controller('bookCtrl', function($scope, searchApi, $routeParams) { $scope.slides = searchApi.booksSlides.query({idBook:$routeParams.idBook, format:'json'}); @@ -34,5 +41,16 @@ } } }; + }) + .controller('ModalAddBookCtrl', function ($scope, searchApi, $modalInstance) { + + $scope.add = function(){ + searchApi.listBooks.save({title: $scope.title}); + $modalInstance.close(); + }; + + $scope.cancel = function () { + $modalInstance.dismiss('cancel'); + }; }); })();