--- /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 @@
+<div class="modal-header ng-scope">
+ <h3 class="modal-title">Ajouter un nouveau Book</h3>
+</div>
+
+<div class="modal-body ng-scope">
+ <input type="text" class="form-control" ng-model='title' placeholder="Titre"></input>
+</div>
+
+<div class="modal-footer ng-scope">
+ <button ng-click="cancel()" class="btn btn-warning">Cancel</button>
+ <button ng-click="add()" class="btn btn-primary">OK</button>
+</div>
\ No newline at end of file
--- 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
--- 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 @@
<p>Liste des books :</p>
<ul class="row ">
- <li class="" ng-repeat="i in books">
+ <li class="" ng-repeat="i in books | orderBy:'-date'">
<div>
<a class="visite" href="#/books/{{ i.id }}">{{ i.title }}</a>
</div>
</li>
-</ul>
\ No newline at end of file
+</ul>
+<a class="btn btn-default" ng-click="addBook()"><span class="glyphicon glyphicon-plus"></span></a>
\ No newline at end of file
--- 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');
+ };
});
})();