client/app/books/books_controller.js
author rougeronj
Wed, 27 May 2015 19:02:43 +0200
changeset 99 c7c424e9eed5
parent 91 f7a844a9079e
child 146 c6fa8ee3f562
permissions -rw-r--r--
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24
21ecbde9e080 add books controller to handle list of books
rougeronj
parents:
diff changeset
     1
(function(){
99
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
     2
    'use strict';
91
f7a844a9079e merge the changes of Camille
rougeronj
parents: 74
diff changeset
     3
99
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
     4
    angular.module('ammicoBooks',['ngRoute', 'ui.sortable'])
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
     5
    .controller('booksCtrl', function($scope, $location, $modal, Book, Slide){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
     6
        $scope.editable = true;
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
     7
        
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
     8
        $scope.books = Book.query({format:'json'}, function(data){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
     9
            data.sort(function (a, b) {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    10
                return a.date < b.date;
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    11
            });
74
44ebb0d0b836 get the book id of the book to delete from the template instead of $index (because we reorder the list so $index are not really clear anymore)
rougeronj
parents: 69
diff changeset
    12
99
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    13
            for (var i = 0; i < data.length; i++) {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    14
                if (data[i].idArticle === null){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    15
                    data[i].slides = Slide.query({idBook:data[i].id, limit: 5, format:'json'});
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    16
                }
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    17
            }
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    18
        });
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    19
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    20
        $scope.toggleModal = function (index) {
91
f7a844a9079e merge the changes of Camille
rougeronj
parents: 74
diff changeset
    21
99
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    22
            var modalInstance = $modal.open({
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    23
                templateUrl: 'books/add_book_modal.html',
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    24
                controller: 'ModalAddBookCtrl',
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    25
                size: 'sm'
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    26
            });
91
f7a844a9079e merge the changes of Camille
rougeronj
parents: 74
diff changeset
    27
99
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    28
            modalInstance.result.then(function (idBook) {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    29
                var newSlide = {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    30
                    book: idBook,
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    31
                    idInventory: $scope.results.hits[index].metas_dict.inventorynumber
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    32
                };
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    33
                Slide.save(newSlide);
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    34
            });
91
f7a844a9079e merge the changes of Camille
rougeronj
parents: 74
diff changeset
    35
        };
f7a844a9079e merge the changes of Camille
rougeronj
parents: 74
diff changeset
    36
99
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    37
        $scope.addBook = function (idParent) {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    38
            $modal.open({
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    39
                templateUrl: 'books/add_modal.html',
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    40
                controller: 'ModalAddBookCtrl'
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    41
            }).result.then(function (title) {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    42
                Book.save({idParent:idParent, title: title}, function(newBook){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    43
                    $scope.books.push(newBook);
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    44
                });
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    45
            });
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    46
        };
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    47
        $scope.deleteItem = function(item){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    48
            if(window.confirm('Êtes-vous sûr(e) de vouloir effacer cet élément ? Cette action est irrémédiable.')){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    49
                Slide.delete({idSlide: item.id}, function(){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    50
                    $scope.book.slides.splice($scope.book.slides.indexOf(item), 1);
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    51
                },
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    52
                function(error) {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    53
                    if (error.status === 404){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    54
                        $scope.book.slides.splice($scope.book.indexOf(item), 1);
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    55
                    }
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    56
                });
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    57
            }
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    58
        };
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    59
        $scope.deleteBook = function(book){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    60
            if(window.confirm('Êtes-vous sûr(e) de vouloir effacer cet élément ? Cette action est irrémédiable.')){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    61
                Book.delete({idBook: book.id}, function(){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    62
                    $scope.books.splice($scope.books.indexOf(book), 1);
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    63
                },
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    64
                function(error) {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    65
                    if (error.status === 404){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    66
                        $scope.books.splice($scope.books.indexOf(book), 1);
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    67
                    }
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    68
                });
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    69
            }
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    70
        };
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    71
    })
91
f7a844a9079e merge the changes of Camille
rougeronj
parents: 74
diff changeset
    72
99
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    73
    .controller('bookCtrl', function($scope, $location, $routeParams, $modal, Book, Slide, Order) {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    74
        $scope.editable = true;
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    75
        
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    76
        $scope.book = Book.get({idBook:$routeParams.idBook, format:'json'}, function(data){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    77
            data.slides = Slide.query({idBook: data.id, format:'json'}, function(data){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    78
                data.sort(function (a, b) {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    79
                    return a.orderIndex > b.orderIndex;
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    80
                });
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    81
            });
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    82
        });
91
f7a844a9079e merge the changes of Camille
rougeronj
parents: 74
diff changeset
    83
99
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    84
        $scope.toggleModal = function (index) {
74
44ebb0d0b836 get the book id of the book to delete from the template instead of $index (because we reorder the list so $index are not really clear anymore)
rougeronj
parents: 69
diff changeset
    85
99
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    86
            var modalInstance = $modal.open({
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    87
                templateUrl: 'books/add_book_modal.html',
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    88
                controller: 'ModalAddBookCtrl',
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    89
                size: 'sm'
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    90
            });
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    91
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    92
            modalInstance.result.then(function (idBook) {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    93
                var newSlide = {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    94
                    book: idBook,
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    95
                    idInventory: $scope.results.hits[index].metas_dict.inventorynumber
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    96
                };
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    97
                Slide.save(newSlide);
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    98
            });
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
    99
        };
74
44ebb0d0b836 get the book id of the book to delete from the template instead of $index (because we reorder the list so $index are not really clear anymore)
rougeronj
parents: 69
diff changeset
   100
99
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   101
        $scope.sortableOptions = {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   102
                stop: function() {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   103
                    var order = $scope.book.slides.map(function(i){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   104
                        return i.id;
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   105
                    });
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   106
                    Order.save({idBook:$routeParams.idBook}, {order: order});
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   107
                }
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   108
        };
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   109
        
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   110
        $scope.deleteItem = function(item){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   111
            if(window.confirm('Êtes-vous sûr(e) de vouloir effacer cet élément ? Cette action est irrémédiable.')){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   112
                Slide.delete({idSlide: item.id}, function(){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   113
                    $scope.book.slides.splice($scope.book.slides.indexOf(item), 1);
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   114
                },
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   115
                function(error) {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   116
                    if (error.status === 404){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   117
                        $scope.book.slides.splice($scope.book.indexOf(item), 1);
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   118
                    }
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   119
                });
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   120
            }
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   121
        };
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   122
    })
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   123
    .controller('ModalAddBookCtrl', function ($scope, Book, $modalInstance) {
91
f7a844a9079e merge the changes of Camille
rougeronj
parents: 74
diff changeset
   124
99
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   125
        $scope.add = function(){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   126
            $modalInstance.close($scope.title);
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   127
        };
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   128
        $scope.cancel = function () {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   129
            $modalInstance.dismiss('cancel');
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   130
        }
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   131
        ;
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   132
        $scope.books = Book.query({format:'json'});
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   133
        
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   134
        $scope.addToBook = function(idBook){
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   135
            $modalInstance.close(idBook);
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   136
        };
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   137
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   138
        $scope.cancel = function () {
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   139
            $modalInstance.dismiss('cancel');
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   140
        };
c7c424e9eed5 refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents: 91
diff changeset
   141
    });
24
21ecbde9e080 add books controller to handle list of books
rougeronj
parents:
diff changeset
   142
})();