udate add fonction from a research and add a modal to select the book we want to add the slide
--- a/client/app/app.js Tue Mar 31 12:22:00 2015 +0200
+++ b/client/app/app.js Tue Mar 31 12:24:05 2015 +0200
@@ -16,6 +16,10 @@
controller: 'bookCtrl',
templateUrl: 'books/book.html'
}).
+ when('/books/:idBook/add/:searched', {
+ controller: 'booksCtrl',
+ templateUrl: 'books/book.html'
+ }).
when('/slide/:idSlide', {
controller: 'slidesCtrl',
templateUrl: 'slides/slides.html'
@@ -92,14 +96,13 @@
}
});
};
- this.listBooks = $resource(context.urls.ammicoUrl+'/books/');
- this.book = $resource(context.urls.ammicoUrl+'/books/:idBook/', {idBook:'@idBook'});
- this.booksSlides = $resource(context.urls.ammicoUrl+'/books/:idBook/slides/', {idBook:'@idBook'});
- this.listSlides= $resource(context.urls.ammicoUrl+'/slides/');
- this.slide = $resource(context.urls.ammicoUrl+'/slides/:idSlide/', {idSlide:'@idSlide'});
+ this.listBooks = $resource(context.urls.ammicoUrl+'/books');
+ this.book = $resource(context.urls.ammicoUrl+'/books/:idBook', {idBook:'@idBook'});
+ this.order = $resource(context.urls.ammicoUrl+'/books/:idBook/order', {idBook:'@idBook'});
+ this.booksSlides = $resource(context.urls.ammicoUrl+'/books/:idBook/slides', {idBook:'@idBook'});
+ this.listSlides= $resource(context.urls.ammicoUrl+'/slides');
+ this.slide = $resource(context.urls.ammicoUrl+'/slides/:idSlide', {idSlide:'@idSlide'});
this.sanitizeUrls = function(data){
- console.log('heyr there !');
- console.log(data);
data.details.audio = $sce.trustAsResourceUrl(data.details.audio);
data.details.video = $sce.trustAsResourceUrl(data.details.video);
data.audio = $sce.trustAsResourceUrl(data.audio);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/client/app/search/modal.html Tue Mar 31 12:24:05 2015 +0200
@@ -0,0 +1,11 @@
+<div class="listBooks">
+ <p>A quel Book boulez vous ajoutez cet element ?</p>
+
+ <ul class="row ">
+ <li class="" ng-repeat="i in books">
+ <div>
+ <a class="visite" ng-click="addToBook(i.id)">{{ i.title }}</a>
+ </div>
+ </li>
+ </ul>
+</div>
\ No newline at end of file
--- a/client/app/search/search.css Tue Mar 31 12:22:00 2015 +0200
+++ b/client/app/search/search.css Tue Mar 31 12:24:05 2015 +0200
@@ -15,11 +15,12 @@
.search-item p, .search-item a.btn {
margin: 0 0 5px;
}
-
-
.subtitle {
border-top: 1px solid #000;
border-bottom: 1px dotted #000;
margin-top: 20px;
padding: 6px 0 10px;
}
+.listBooks a{
+ cursor: pointer;
+}
\ No newline at end of file
--- a/client/app/search/search.html Tue Mar 31 12:22:00 2015 +0200
+++ b/client/app/search/search.html Tue Mar 31 12:24:05 2015 +0200
@@ -1,25 +1,45 @@
-<h1>Recherche <span ng-if="q !='' "> : {{ q }}</span></h1>
+<h1>
+ Recherche <span ng-if="q !='' "> : {{ q }}</span>
+</h1>
<h4 class="subtitle" ng-if="results.nhits>0">{{ results.nhits }} résultat(s)</h4>
+
<div ng-if="results.nhits>0">
- <div class="row search-item" ng-repeat="h in results.hits" ng-init="h.imgbig=false">
- <div ng-class="{'col-md-5': h.imgbig, 'col-md-3': !h.imgbig}">
- <img ng-src="{{ h.metas_dict.images }}" ng-class="{'search-img-max': !h.imgbig}" ng-click="h.imgbig=!h.imgbig"/>
- </div>
- <div ng-class="{'col-md-5': h.imgbig, 'col-md-7': !h.imgbig}">
- <p><strong>Nom :</strong> {{ h.metas_dict.name }}</p>
- <p><strong>Description :</strong> {{ h.metas_dict.description }}</p>
- <div ng-show="h.imgbig">
- <p><small><strong>Classification :</strong> {{ h.metas_dict.classification }}</small></p>
- <p><small><strong>Propriétaire actuel :</strong> {{ h.metas_dict.currentcustody }}</small></p>
- <p><small><strong>Ancien propriétaire :</strong> {{ h.metas_dict.formercustody }}</small></p>
- <p><small><strong>Mesures :</strong> {{ h.metas_dict.measures }}</small></p>
- <p><small><strong>Acteurs :</strong> {{ h.metas_dict.actors }}</small></p>
- <p><small><strong>Lieux :</strong> {{ h.metas_dict.places }}</small></p>
- </div>
- </div>
- <div class="col-md-1">
- <a class="btn btn-default" href="#/slideshow/add/{{q}},{{$index}}"><span class="glyphicon glyphicon-plus"></span></a>
- <a class="btn btn-default" ng-click="h.imgbig=!h.imgbig"><span class="glyphicon glyphicon-eye-open"></span></a>
- </div>
- </div>
+ <div class="row search-item" ng-repeat="h in results.hits"
+ ng-init="h.imgbig=false">
+ <div ng-class="{'col-md-5': h.imgbig, 'col-md-3': !h.imgbig}">
+ <img ng-src="{{ h.metas_dict.images }}" ng-class="{'search-img-max': !h.imgbig}" ng-click="h.imgbig=!h.imgbig" />
+ </div>
+ <div ng-class="{'col-md-5': h.imgbig, 'col-md-7': !h.imgbig}">
+ <p>
+ <strong>Nom :</strong> {{ h.metas_dict.name }}
+ </p>
+ <p>
+ <strong>Description :</strong> {{ h.metas_dict.description }}
+ </p>
+ <div ng-show="h.imgbig">
+ <p>
+ <small><strong>Classification :</strong> {{ h.metas_dict.classification }}</small>
+ </p>
+ <p>
+ <small><strong>Propriétaire actuel :</strong> {{ h.metas_dict.currentcustody }}</small>
+ </p>
+ <p>
+ <small><strong>Ancien propriétaire :</strong> {{ h.metas_dict.formercustody }}</small>
+ </p>
+ <p>
+ <small><strong>Mesures :</strong> {{ h.metas_dict.measures }}</small>
+ </p>
+ <p>
+ <small><strong>Acteurs :</strong> {{ h.metas_dict.actors }}</small>
+ </p>
+ <p>
+ <small><strong>Lieux :</strong> {{ h.metas_dict.places }}</small>
+ </p>
+ </div>
+ </div>
+ <div class="col-md-1">
+ <a popover-placement="right" popover-trigger="click" class="btn btn-default" ng-click="toggleModal($index)"><span class="glyphicon glyphicon-plus"></span></a>
+ <a class="btn btn-default" ng-click="h.imgbig=!h.imgbig"><span class="glyphicon glyphicon-eye-open"></span></a>
+ </div>
+ </div>
</div>
--- a/client/app/search/search_controller.js Tue Mar 31 12:22:00 2015 +0200
+++ b/client/app/search/search_controller.js Tue Mar 31 12:24:05 2015 +0200
@@ -1,18 +1,44 @@
(function(){
- 'use strict';
+ 'use strict';
+
+ angular.module('ammicoSearch',['ngResource', 'ngRoute', 'ui.bootstrap'])
+ .config(function ($routeProvider) {
+ $routeProvider
+ .when('/', {
+ templateUrl: 'search/search.html',
+ controller: 'searchCtrl'
+ });
+ })
+ .controller('searchCtrl', function($scope, $location, $routeParams, searchApi, $modal){
+ $scope.q = $routeParams.q || '';
+ $scope.results = searchApi.searchResource({q:$scope.q, of: 'json', synthesis: 'false', nresults:'10', callback: 'JSON_CALLBACK'}).getJsonp();
+
+ $scope.toggleModal = function (index) {
- angular.module('ammicoSearch',['ngResource', 'ngRoute'])
- .config(function ($routeProvider) {
- $routeProvider
- .when('/', {
- templateUrl: 'search/search.html',
- controller: 'searchCtrl'
- });
- })
- .controller('searchCtrl', function($scope, $location, $routeParams, searchApi){
- console.log('search 6',$scope, $location, $routeParams);
- $scope.q = $routeParams.q || '';
- $scope.results = searchApi.searchResource({q:$scope.q, of: 'json', synthesis: 'false', nresults:'50', callback: 'JSON_CALLBACK'}).getJsonp();
- });
+ var modalInstance = $modal.open({
+ templateUrl: 'search/modal.html',
+ controller: 'ModalInstanceCtrl',
+ size: 'sm'
+ });
+ modalInstance.result.then(function (idBook) {
+ var newSlide = {
+ book: idBook,
+ idInventory: $scope.results.hits[index].metas_dict.inventorynumber
+ };
+ searchApi.listSlides.save(newSlide);
+ });
+ };
+ })
+ .controller('ModalInstanceCtrl', function ($scope, searchApi, $modalInstance) {
+ $scope.books = searchApi.listBooks.query({format:'json'});
+
+ $scope.addToBook = function(idBook){
+ $modalInstance.close(idBook);
+ };
+
+ $scope.cancel = function () {
+ $modalInstance.dismiss('cancel');
+ };
+ });
})();