refactor idArticle to id_article and idInventory to id_inventory
remove "/" from resource path
--- a/client/app/books/add_book_modal.html Tue Jun 09 19:09:29 2015 +0200
+++ b/client/app/books/add_book_modal.html Tue Jun 09 19:10:45 2015 +0200
@@ -5,13 +5,13 @@
<div class="modal-body ng-scope">
<ul class="row ">
Les books de vos visites:
- <li class="" ng-repeat="i in books | filter:{parent_visit:'!null'}:filter:{ parent_visit: 'null', idArticle: 'null' }">
+ <li class="" ng-repeat="i in books | filter:{parent_visit:'!null'}:filter:{ parent_visit: 'null', id_article: 'null' }">
<div>
<a ng-click="addToBook(i.id)">{{ i.title }}</a>
</div>
</li>
Autres Books:
- <li class="" ng-repeat="i in books | filter:{ parent_visit: 'null', idArticle: 'null' }">
+ <li class="" ng-repeat="i in books | filter:{ parent_visit: 'null', id_article: 'null' }">
<div>
<a ng-click="addToBook(i.id)">{{ i.title }}</a>
</div>
--- a/client/app/books/books.html Tue Jun 09 19:09:29 2015 +0200
+++ b/client/app/books/books.html Tue Jun 09 19:10:45 2015 +0200
@@ -1,7 +1,7 @@
<accordion close-others="false">
- <accordion-group ng-repeat="book in books | filter:{ parent_visit: '!null', idArticle: 'null' }" is-open=true>
+ <accordion-group ng-repeat="book in books | filter:{ parent_visit: '!null', id_article: 'null' }" is-open=true>
<accordion-heading>
@@ -15,11 +15,6 @@
<p class="nbrObjects">{{book.count}} objets</p>
- <div class="list-books" ng-repeat="childBook in books | filter:{ parent_visit: book.id }:true">
- <a href="#/books/{{ childBook.id }}">{{ childBook.title }}</a>
- <a class="pull-right" ng-click="deleteItem(childBook)"><span class="glyphicon glyphicon-minus"></span></a>
- </div>
-
<ul ng:model="slides" class="list-inline gallery container-fluid">
<li class="item" ng-class="{'no-img': !slide.details.images[0]}" ng-repeat="slide in book.slides">
<ng-include src="'books/galleryItem.html'"></ng-include>
--- a/client/app/books/books_controller.js Tue Jun 09 19:09:29 2015 +0200
+++ b/client/app/books/books_controller.js Tue Jun 09 19:10:45 2015 +0200
@@ -11,28 +11,15 @@
});
for (var i = 0; i < data.length; i++) {
- if (data[i].idArticle === null){
+ if (data[i].id_article === null){
data[i].slides = Slide.query({idBook:data[i].id, limit: 5, format:'json'});
}
}
});
-
- $scope.toggleModal = function (index) {
-
- var modalInstance = $modal.open({
- templateUrl: 'books/add_book_modal.html',
- controller: 'ModalAddBookCtrl',
- size: 'sm'
- });
-
- modalInstance.result.then(function (idBook) {
- var newSlide = {
- book: idBook,
- idInventory: $scope.results.hits[index].metas_dict.inventorynumber
- };
- Slide.save(newSlide);
- });
- };
+
+// $scope.$on('slideDeleted', function (event, data) {
+// console.log(data); // 'Data to send'
+// });
$scope.addBook = function (idParent) {
$modal.open({
@@ -44,30 +31,6 @@
});
});
};
- $scope.deleteItem = function(item){
- if(window.confirm('Êtes-vous sûr(e) de vouloir effacer cet élément ? Cette action est irrémédiable.')){
- Slide.delete({idSlide: item.id}, function(){
- $scope.book.slides.splice($scope.book.slides.indexOf(item), 1);
- },
- function(error) {
- if (error.status === 404){
- $scope.book.slides.splice($scope.book.indexOf(item), 1);
- }
- });
- }
- };
- $scope.deleteBook = function(book){
- if(window.confirm('Êtes-vous sûr(e) de vouloir effacer cet élément ? Cette action est irrémédiable.')){
- Book.delete({idBook: book.id}, function(){
- $scope.books.splice($scope.books.indexOf(book), 1);
- },
- function(error) {
- if (error.status === 404){
- $scope.books.splice($scope.books.indexOf(book), 1);
- }
- });
- }
- };
})
.controller('bookCtrl', function($scope, $location, $routeParams, $modal, Book, Slide, Order) {
@@ -81,23 +44,6 @@
});
});
- $scope.toggleModal = function (index) {
-
- var modalInstance = $modal.open({
- templateUrl: 'books/add_book_modal.html',
- controller: 'ModalAddBookCtrl',
- size: 'sm'
- });
-
- modalInstance.result.then(function (idBook) {
- var newSlide = {
- book: idBook,
- idInventory: $scope.results.hits[index].metas_dict.inventorynumber
- };
- Slide.save(newSlide);
- });
- };
-
$scope.sortableOptions = {
stop: function() {
var order = $scope.book.slides.map(function(i){
--- a/client/app/books/galleryItem.html Tue Jun 09 19:09:29 2015 +0200
+++ b/client/app/books/galleryItem.html Tue Jun 09 19:10:45 2015 +0200
@@ -2,7 +2,7 @@
<a href="#/slide/{{slide.id}}"><img ng-src="{{ slide.details.images[0] }}" my-customer /></a>
<div class="gallery-buttons">
<a ng-click="slide.toggleFavorite()"><span ng-class="{'glyphicon-star': slide.favorite, 'glyphicon-star-empty': !slide.favorite}" class="glyphicon"></span></a>
- <a ng-click="toggleModal($index)"><span class="glyphicon glyphicon-plus"></span></a>
+ <a ng-click="slide.addToBook();"><span class="glyphicon glyphicon-plus"></span></a>
<a ng-show="editable" class="pull-right" ng-click="slide.remove(book.slides)"><span class="glyphicon glyphicon-trash"></span></a>
</div>
<a href="#/slide/{{slide.id}}"><p>{{ slide.details.title }}</p></a>
\ No newline at end of file
--- a/client/app/components/app_service.js Tue Jun 09 19:09:29 2015 +0200
+++ b/client/app/components/app_service.js Tue Jun 09 19:10:45 2015 +0200
@@ -4,11 +4,11 @@
angular.module('ammicoCommon', ['ngRoute'])
.factory('Book', function($resource, context) {
- var books = $resource(context.urls.ammicoUrl+'/books/:idBook', {idBook:'@id'}, {update: { method: 'PUT'}});
+ var books = $resource(context.urls.ammicoUrl+'books/:idBook', {idBook:'@id', idExpo: context.idExpo}, {update: { method: 'PUT'}});
return books;
})
- .factory('Slide', function($resource, context) {
- var slides = $resource(context.urls.ammicoUrl+'/slides/:idSlide', {idSlide:'@id'}, {update: { method: 'PUT'}});
+ .factory('Slide', function($resource, context, $modal) {
+ var slides = $resource(context.urls.ammicoUrl+'slides/:idSlide', {idSlide:'@id'}, {update: { method: 'PUT'}});
angular.extend(slides.prototype, {
@@ -16,6 +16,24 @@
this.favorite = !this.favorite;
this.$update();
},
+ addToBook: function () {
+ var _this = this;
+ var modalInstance = $modal.open({
+ templateUrl: 'books/add_book_modal.html',
+ controller: 'ModalAddBookCtrl',
+ size: 'sm'
+ });
+
+ modalInstance.result.then(function (idBook) {
+ var newSlide = _this;
+ newSlide.book = idBook;
+ delete newSlide["id"];
+ slides.save(newSlide);
+ });
+ },
+ update: function(){
+ console.log('test');
+ },
remove: function (array) {
var _this = this;
if(window.confirm('Êtes-vous sûr(e) de vouloir effacer cet élément ? Cette action est irrémédiable.')){
@@ -23,6 +41,7 @@
if (array){
array.splice(array.indexOf(_this), 1);
}
+ //$scope.$emit("slideDeleted", array);
},
function(error) {
if (error.status === 404 && array){
@@ -36,7 +55,7 @@
return slides;
})
.factory('Order', function($resource, context) {
- return $resource(context.urls.ammicoUrl+'/books/:idBook/order', {idBook:'@id'});
+ return $resource(context.urls.ammicoUrl+'books/:idBook/order', {idBook:'@id'});
})
.service('Utils', function($resource, context, $sce) {
this.sanitizeUrls = function(data){
@@ -48,10 +67,10 @@
};
})
.service('authApi', function($resource, context) {
- this.login = $resource(context.urls.ammicoUrl+'/auth/api-token-auth');
- this.logout = $resource(context.urls.ammicoUrl+'/auth/logout');
- this.user = $resource(context.urls.ammicoUrl+'/auth/user');
- this.test = $resource(context.urls.ammicoUrl+'/auth/auth');
+ this.login = $resource(context.urls.ammicoUrl+'auth/api-token-auth', {idExpo: context.idExpo});
+ this.logout = $resource(context.urls.ammicoUrl+'auth/logout');
+ this.user = $resource(context.urls.ammicoUrl+'auth/user');
+ this.test = $resource(context.urls.ammicoUrl+'auth/auth');
})
.service('searchApi', function($resource, context) {
this.searchResource = function(params){
--- a/client/app/index.html Tue Jun 09 19:09:29 2015 +0200
+++ b/client/app/index.html Tue Jun 09 19:10:45 2015 +0200
@@ -78,11 +78,17 @@
.value('context', {
<!-- build:token -->
<!-- endbuild -->
+ <!-- build:idExpo -->
+ idExpo: "1",
+ <!-- endbuild -->
record: angular.fromJson('{"record": "record value"}'),
urls: {
- base_static: "./",
- ammicoUrl: "http://127.0.0.1:8000/ammico",
+ <!-- build:ammicoUrl -->
+ ammicoUrl: "http://127.0.0.1:8000/ammico/",
+ <!-- endbuild -->
+ <!-- build:searchUrl -->
searchUrl: "http://ammico.labs.exalead.com/search-api"
+ <!-- endbuild -->
}
});
--- a/client/app/my_visit/my_visit.html Tue Jun 09 19:09:29 2015 +0200
+++ b/client/app/my_visit/my_visit.html Tue Jun 09 19:10:45 2015 +0200
@@ -1,7 +1,7 @@
<accordion close-others="false">
- <accordion-group ng-repeat="parentBook in books | filter:{ parent_visit: 'null', idArticle: '!null' } | orderBy: 'date' | limitTo : 1" is-open=true>
+ <accordion-group ng-repeat="parentBook in books | filter:{ parent_visit: 'null', id_article: '!null' } | orderBy: 'date' | limitTo : 1" is-open=true>
<accordion-heading>
<a class="title" ng-click="$event.stopPropagation();" href="#/my_visit/{{parentBook.id}}">{{ parentBook.title }}</a>
--- a/client/app/my_visit/my_visit_controller.js Tue Jun 09 19:09:29 2015 +0200
+++ b/client/app/my_visit/my_visit_controller.js Tue Jun 09 19:10:45 2015 +0200
@@ -11,7 +11,7 @@
});
for (var i = 0; i < data.length; i++) {
- if (data[i].idArticle){
+ if (data[i].id_article){
data[i].slides = Slide.query({idBook:data[i].id, format:'json'});
}
}
--- a/client/app/search/modal.html Tue Jun 09 19:09:29 2015 +0200
+++ b/client/app/search/modal.html Tue Jun 09 19:10:45 2015 +0200
@@ -5,13 +5,13 @@
<div class="modal-body ng-scope">
<ul class="row ">
Les books de vos visites:
- <li class="" ng-repeat="i in books | filter:{parent_visit:'!null'}:filter:{ parent_visit: 'null', idArticle: 'null' }">
+ <li class="" ng-repeat="i in books | filter:{parent_visit:'!null'}:filter:{ parent_visit: 'null', id_article: 'null' }">
<div>
<a ng-click="addToBook(i.id)">{{ i.title }}</a>
</div>
</li>
Autres Books:
- <li class="" ng-repeat="i in books | filter:{ parent_visit: 'null', idArticle: 'null' }">
+ <li class="" ng-repeat="i in books | filter:{ parent_visit: 'null', id_article: 'null' }">
<div>
<a ng-click="addToBook(i.id)">{{ i.title }}</a>
</div>
--- a/client/app/search/search_controller.js Tue Jun 09 19:09:29 2015 +0200
+++ b/client/app/search/search_controller.js Tue Jun 09 19:10:45 2015 +0200
@@ -24,7 +24,7 @@
modalInstance.result.then(function (idBook) {
var newSlide = {
book: idBook,
- idInventory: $scope.results.hits[index].metas_dict.inventorynumber
+ id_inventory: $scope.results.hits[index].metas_dict.inventorynumber
};
Slide.save(newSlide);
});
--- a/client/app/visites/add_book_modal.html Tue Jun 09 19:09:29 2015 +0200
+++ b/client/app/visites/add_book_modal.html Tue Jun 09 19:10:45 2015 +0200
@@ -5,13 +5,13 @@
<div class="modal-body ng-scope">
<ul class="row ">
Les books de vos visites:
- <li class="" ng-repeat="i in books | filter:{parent_visit:'!null'}:filter:{ parent_visit: 'null', idArticle: 'null' }">
+ <li class="" ng-repeat="i in books | filter:{parent_visit:'!null'}:filter:{ parent_visit: 'null', id_article: 'null' }">
<div>
<a ng-click="addToBook(i.id)">{{ i.title }}</a>
</div>
</li>
Autres Books:
- <li class="" ng-repeat="i in books | filter:{ parent_visit: 'null', idArticle: 'null' }">
+ <li class="" ng-repeat="i in books | filter:{ parent_visit: 'null', id_article: 'null' }">
<div>
<a ng-click="addToBook(i.id)">{{ i.title }}</a>
</div>
--- a/client/app/visites/visites.html Tue Jun 09 19:09:29 2015 +0200
+++ b/client/app/visites/visites.html Tue Jun 09 19:10:45 2015 +0200
@@ -1,5 +1,5 @@
<accordion close-others="false">
- <accordion-group ng-repeat="visit in books | filter:{ parent_visit: 'null', idArticle: '!null' } | orderBy: 'date' " is-open=true>
+ <accordion-group ng-repeat="visit in books | filter:{ parent_visit: 'null', id_article: '!null' } | orderBy: 'date' " is-open=true>
<accordion-heading>
<a class="title" ng-click="$event.stopPropagation();" href="#/visites/{{ visit.id }}">{{ visit.title }}</a>
--- a/client/app/visites/visites_controller.js Tue Jun 09 19:09:29 2015 +0200
+++ b/client/app/visites/visites_controller.js Tue Jun 09 19:10:45 2015 +0200
@@ -11,7 +11,7 @@
});
for (var i = 0; i < data.length; i++) {
- if (data[i].idArticle){
+ if (data[i].id_article){
data[i].slides = Slide.query({idBook:data[i].id, limit: 5, format:'json'});
}
}
@@ -28,7 +28,7 @@
modalInstance.result.then(function (idBook) {
var newSlide = {
book: idBook,
- idInventory: $scope.results.hits[index].metas_dict.inventorynumber
+ id_inventory: $scope.results.hits[index].metas_dict.inventorynumber
};
Slide.save(newSlide);
});