filter book in the request through 'type' parameter instead of filtering on client side
--- a/client/app/books/books.html Thu Jun 11 15:36:42 2015 +0200
+++ b/client/app/books/books.html Thu Jun 11 15:37:51 2015 +0200
@@ -1,7 +1,7 @@
<accordion close-others="false">
- <accordion-group ng-repeat="book in books | filter:{ id_article: 'null' }" is-open=true>
+ <accordion-group ng-repeat="book in books" is-open=true>
<accordion-heading>
--- a/client/app/books/books_controller.js Thu Jun 11 15:36:42 2015 +0200
+++ b/client/app/books/books_controller.js Thu Jun 11 15:37:51 2015 +0200
@@ -5,15 +5,13 @@
.controller('booksCtrl', function($scope, $location, $modal, Book, Slide){
$scope.editable = true;
- $scope.books = Book.query({format:'json'}, function(data){
+ $scope.books = Book.query({type: 'book', format:'json'}, function(data){
data.sort(function (a, b) {
return a.date < b.date;
});
for (var i = 0; i < data.length; i++) {
- if (data[i].id_article === null){
- data[i].slides = Slide.query({idBook:data[i].id, limit: 5, format:'json'});
- }
+ data[i].slides = Slide.query({idBook:data[i].id, limit: 5, format:'json'});
}
});
--- a/client/app/my_visit/my_visit.html Thu Jun 11 15:36:42 2015 +0200
+++ b/client/app/my_visit/my_visit.html Thu Jun 11 15:37:51 2015 +0200
@@ -1,25 +1,21 @@
-
-
<accordion close-others="false">
- <accordion-group ng-repeat="parentBook in books | filter:{ parent_visit: 'null', id_article: '!null' } | orderBy: 'date' | limitTo : 1" is-open=true>
+ <accordion-group is-open=true>
<accordion-heading>
- <a class="title" ng-click="$event.stopPropagation();" href="#/my_visit/{{parentBook.id}}">{{ parentBook.title }}</a>
+ <a class="title" ng-click="$event.stopPropagation();" href="#/my_visit/{{last_visit.id}}">{{ last_visit.title }}</a>
<a class="pull-right" ng-click="$event.preventDefault(); $event.stopPropagation(); share($index)"><span class="glyphicon glyphicon-share"></span></a>
<a class="pull-right" ng-click="$event.preventDefault(); $event.stopPropagation(); edit()"><span class="glyphicon glyphicon-cog"></span></a>
- <a class="pull-right" ng-click="$event.stopPropagation();" href="#/slideshow/{{ parentBook.id }}"><span class="glyphicon glyphicon-eye-open"></span></a>
- <a class="pull-right" ng-click="$event.preventDefault(); $event.stopPropagation(); addBook(parentBook.id)">Créer un Book</a>
+ <a class="pull-right" ng-click="$event.stopPropagation();" href="#/slideshow/{{ last_visit.id }}"><span class="glyphicon glyphicon-eye-open"></span></a>
+ <a class="pull-right" ng-click="$event.preventDefault(); $event.stopPropagation(); addBook(last_visit.id)">Créer un Book</a>
</accordion-heading>
- <p class="nbrObjects">{{parentBook.slides.length}} objets</p>
+ <p class="nbrObjects">{{last_visit.slides.length}} objets</p>
<ul ng:model="slides" class="list-unstyled list-inline gallery container-fluid">
- <li class="item" ng-class="{'no-img': !slide.details.images[0]}" ng-repeat="slide in parentBook.slides">
+ <li class="item" ng-class="{'no-img': !slide.details.images[0]}" ng-repeat="slide in last_visit.slides">
<ng-include src="'books/galleryItem.html'"></ng-include>
</li>
</ul>
</accordion-group>
-</accordion>
-
-<a class="btn btn-default" ng-click="addBook()"><span class="glyphicon glyphicon-plus"></span></a>
\ No newline at end of file
+</accordion>
\ No newline at end of file
--- a/client/app/my_visit/my_visit_controller.js Thu Jun 11 15:36:42 2015 +0200
+++ b/client/app/my_visit/my_visit_controller.js Thu Jun 11 15:37:51 2015 +0200
@@ -5,16 +5,14 @@
.controller('my_visitCtrl', function($scope, $location, $modal, Book, Slide){
//get list book
- $scope.books = Book.query({format:'json'}, function(data){
+ Book.query({type: 'visit', format:'json'}, function(data){
data.sort(function (a, b) {
- return a.date < b.date;
+ return a.date > b.date;
});
-
- for (var i = 0; i < data.length; i++) {
- if (data[i].id_article){
- data[i].slides = Slide.query({idBook:data[i].id, format:'json'});
- }
- }
+ if (data.length >= 1){
+ $scope.last_visit = data[0];
+ $scope.last_visit.slides = Slide.query({idBook:data[0].id, format:'json'});
+ }
});
$scope.addBook = function (idParent) {
--- a/client/app/visites/visites.html Thu Jun 11 15:36:42 2015 +0200
+++ b/client/app/visites/visites.html Thu Jun 11 15:37:51 2015 +0200
@@ -1,5 +1,5 @@
<accordion close-others="false">
- <accordion-group ng-repeat="visit in books | filter:{ parent_visit: 'null', id_article: '!null' } | orderBy: 'date' " is-open=true>
+ <accordion-group ng-repeat="visit in visits | orderBy: 'date' " is-open=true>
<accordion-heading>
<a class="title" ng-click="$event.stopPropagation();" href="#/visites/{{ visit.id }}">{{ visit.title }}</a>
@@ -21,6 +21,4 @@
</accordion-group>
-</accordion>
-
-<a class="btn btn-default" ng-click="addBook()"><span class="glyphicon glyphicon-plus"></span></a>
\ No newline at end of file
+</accordion>
\ No newline at end of file
--- a/client/app/visites/visites_controller.js Thu Jun 11 15:36:42 2015 +0200
+++ b/client/app/visites/visites_controller.js Thu Jun 11 15:37:51 2015 +0200
@@ -5,15 +5,13 @@
.controller('visitesCtrl', function($scope, $location, $modal, Book, Slide){
//get list book
- $scope.books = Book.query({format:'json'}, function(data){
+ $scope.visits = Book.query({type: 'visit', format:'json'}, function(data){
data.sort(function (a, b) {
return a.date < b.date;
});
for (var i = 0; i < data.length; i++) {
- if (data[i].id_article){
- data[i].slides = Slide.query({idBook:data[i].id, limit: 5, format:'json'});
- }
+ data[i].slides = Slide.query({idBook:data[i].id, limit: 5, format:'json'});
}
});