udate add fonction from a research and add a modal to select the book we want to add the slide
authorrougeronj
Tue, 31 Mar 2015 12:24:05 +0200
changeset 47 dd750778535c
parent 46 f909e7f2917d
child 48 c17f2b37b032
udate add fonction from a research and add a modal to select the book we want to add the slide
client/app/app.js
client/app/search/modal.html
client/app/search/search.css
client/app/search/search.html
client/app/search/search_controller.js
--- 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&nbsp;:</strong> {{ h.metas_dict.name }}</p>
-	      <p><strong>Description&nbsp;:</strong> {{ h.metas_dict.description }}</p>
-	      <div ng-show="h.imgbig">
-		      <p><small><strong>Classification&nbsp;:</strong> {{ h.metas_dict.classification }}</small></p>
-		      <p><small><strong>Propriétaire actuel&nbsp;:</strong> {{ h.metas_dict.currentcustody }}</small></p>
-		      <p><small><strong>Ancien propriétaire&nbsp;:</strong> {{ h.metas_dict.formercustody }}</small></p>
-		      <p><small><strong>Mesures&nbsp;:</strong> {{ h.metas_dict.measures }}</small></p>
-		      <p><small><strong>Acteurs&nbsp;:</strong> {{ h.metas_dict.actors }}</small></p>
-		      <p><small><strong>Lieux&nbsp;:</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&nbsp;:</strong> {{ h.metas_dict.name }}
+			</p>
+			<p>
+				<strong>Description&nbsp;:</strong> {{ h.metas_dict.description }}
+			</p>
+			<div ng-show="h.imgbig">
+				<p>
+					<small><strong>Classification&nbsp;:</strong> {{ h.metas_dict.classification }}</small>
+				</p>
+				<p>
+					<small><strong>Propriétaire actuel&nbsp;:</strong> {{ h.metas_dict.currentcustody }}</small>
+				</p>
+				<p>
+					<small><strong>Ancien propriétaire&nbsp;:</strong> {{ h.metas_dict.formercustody }}</small>
+				</p>
+				<p>
+					<small><strong>Mesures&nbsp;:</strong> {{ h.metas_dict.measures }}</small>
+				</p>
+				<p>
+					<small><strong>Acteurs&nbsp;:</strong> {{ h.metas_dict.actors }}</small>
+				</p>
+				<p>
+					<small><strong>Lieux&nbsp;:</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');
+		};
+	});
 })();