--- a/client/app/components/app_service.js Wed Dec 02 11:41:53 2015 +0100
+++ b/client/app/components/app_service.js Wed Dec 02 18:07:42 2015 +0100
@@ -1,7 +1,7 @@
(function(){
'use strict';
-
+
angular.module('ammicoCommon', ['ngRoute'])
.factory('Book', function($resource, context) {
var books = $resource(context.urls.ammicoUrl+'books/:idBook', {idBook:'@id', idExpo: context.idExpo}, {update: { method: 'PUT'}});
@@ -9,7 +9,7 @@
})
.factory('Slide', function($resource, context, $modal) {
var slides = $resource(context.urls.ammicoUrl+'slides/:idSlide', {idSlide:'@id'}, {update: { method: 'PUT'}});
-
+
angular.extend(slides.prototype, {
toggleFavorite: function () {
@@ -51,7 +51,7 @@
}
}
});
-
+
return slides;
})
.factory('Order', function($resource, context) {
@@ -74,7 +74,7 @@
})
.service('searchApi', function($resource, context) {
this.searchResource = function(params){
- return $resource(context.urls.searchUrl,
+ return $resource(context.urls.searchUrl,
{
callback: 'JSON_CALLBACK'
},
@@ -84,35 +84,20 @@
params: params,
isArray: false,
transformResponse: function(data){
- var i, j;
- // Transform meta list into meta dict
- if (typeof data.hits !== 'undefined'){
- var nb = data.hits.length;
- for(i=0;i<nb;i++){
- var nb_metas = data.hits[i].metas.length;
- data.hits[i].metas_dict = {};
- for(j=0;j<nb_metas;j++){
- if(typeof data.hits[i].metas[j].images==='undefined'){
- data.hits[i].metas_dict[data.hits[i].metas[j].name] = data.hits[i].metas[j].value;
- }
- else{
- data.hits[i].metas_dict.images = data.hits[i].metas[j].images[0].value;
- }
- }
- }
- return data;
+ if (data.success){
+ data = data.response[0];
+ for (var i=0; i<data.count; i++){
+ data.collect[i].name = data.collect[i].name || data.collect[i].title_stop || '';
+ data.collect[i].description = data.collect[i].description_record || data.collect[i].description_stop || '';
+ data.collect[i].url = data.collect[i].url_cnhi || '';
+ data.collect[i].date = data.collect[i].displaydates || '';
+ data.collect[i].id_stop = data.collect[i].id_stop || '';
+ data.collect[i].inventorynumber = data.collect[i].inventorynumber || '';
+ data.collect[i].tags = data.collect[i].tags_stop || [];
+ data.collect[i].images = data.collect[i].images || [];
}
- if (typeof data.response !== 'undefined'){
- var result = [];
-
- angular.forEach(data.response[0].collect, function(value) {
- var temp = {};
- angular.forEach(value, function(value2, key2) {
- temp[key2]= value2;
- });
- result.push(temp);
- });
- }
+ }
+ return data;
}
}
});
@@ -136,5 +121,5 @@
}
};
});
-
+
})();
--- a/client/app/search/search.css Wed Dec 02 11:41:53 2015 +0100
+++ b/client/app/search/search.css Wed Dec 02 18:07:42 2015 +0100
@@ -1,14 +1,20 @@
.search-item {
- min-height: 250px;
+ min-height: 150px;
border-bottom: 1px solid #000;
padding-bottom: 10px;
}
.search-item:not(:first-child){
padding-top: 10px;
}
+.search-item .img-wrap{
+ text-align: center;
+}
.search-item img {
max-width: 100%;
}
+.search-item img.no-img {
+ max-height: 150px;
+}
.search-img-max {
max-height: 230px;
}
@@ -23,4 +29,4 @@
}
.modal-body a{
cursor: pointer;
-}
\ No newline at end of file
+}
--- a/client/app/search/search.html Wed Dec 02 11:41:53 2015 +0100
+++ b/client/app/search/search.html Wed Dec 02 18:07:42 2015 +0100
@@ -1,45 +1,45 @@
<h1>
Recherche <span ng-if="q !='' "> : {{ q }}</span>
</h1>
-<h4 class="subtitle" ng-if="results.nhits>0">{{ results.nhits }} résultat(s)</h4>
+<h4 class="subtitle" ng-if="results.count>0">{{ results.count }} 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 ng-if="results.count>0">
+ <div class="row search-item" ng-repeat="h in results.collect"
+ ng-init="h.imgbig=false; h.seemore=false">
+ <div ng-class="{'col-md-5': h.imgbig, 'col-md-3': !h.imgbig, 'img-wrap': true }">
+ <img ng-src="{{ h.images[0] || 'img/no_img.jpg' }}" ng-class="{'search-img-max': (h.images[0] && !h.imgbig), 'no-img': !h.images[0]}" ng-click="h.imgbig=(h.images[0] && !h.imgbig)" />
</div>
<div ng-class="{'col-md-5': h.imgbig, 'col-md-7': !h.imgbig}">
<p>
- <strong>Nom :</strong> {{ h.metas_dict.name }}
+ <strong>Nom :</strong> {{ h.name }}
</p>
<p>
- <strong>Description :</strong> {{ h.metas_dict.description }}
+ <strong>Description :</strong> {{ h.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 ng-if="h.url">
+ <strong>Url :</strong> <a href="{{ h.url }}" target="_blank">{{ h.url }}</a>
+ </p>
+ <div ng-show="h.seemore">
+ <p ng-if="h.date">
+ <small><strong>Date :</strong> {{ h.date }}</small>
</p>
- <p>
- <small><strong>Ancien propriétaire :</strong> {{ h.metas_dict.formercustody }}</small>
+ <p ng-if="h.inventorynumber">
+ <small><strong>Numéro d'inventaire :</strong> {{ h.inventorynumber }}</small>
</p>
- <p>
- <small><strong>Mesures :</strong> {{ h.metas_dict.measures }}</small>
+ <p ng-if="h.classification">
+ <small><strong>Classification :</strong> {{ h.classification }}</small>
</p>
- <p>
- <small><strong>Acteurs :</strong> {{ h.metas_dict.actors }}</small>
+ <p ng-if="h.country">
+ <small><strong>Pays :</strong> {{ h.country }}</small>
</p>
- <p>
- <small><strong>Lieux :</strong> {{ h.metas_dict.places }}</small>
+ <p ng-if="h.tags.length>0">
+ <small><strong>Mots Clefs :</strong> {{ h.tags }}</small>
</p>
</div>
</div>
<div class="col-md-1">
<a 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>
+ <a class="btn btn-default" ng-click="h.imgbig=(h.images[0] && !h.imgbig); h.seemore=!h.seemore"><span class="glyphicon glyphicon-eye-open"></span></a>
+ </div>
</div>
</div>
--- a/client/app/search/search_controller.js Wed Dec 02 11:41:53 2015 +0100
+++ b/client/app/search/search_controller.js Wed Dec 02 18:07:42 2015 +0100
@@ -12,9 +12,9 @@
.controller('searchCtrl', function($scope, $location, $routeParams, searchApi, $modal, Slide){
$scope.q = $routeParams.q || '';
if ($scope.q !== ''){
- $scope.results_ = searchApi.searchResource({q:$scope.q, of: 'json', synthesis: 'false', nresults:'10', callback: 'JSON_CALLBACK'}).getJsonp();
+ $scope.results = searchApi.searchResource({q:$scope.q, of: 'json', synthesis: 'false', nresults:'10', callback: 'JSON_CALLBACK'}).getJsonp();
}
-
+
$scope.toggleModal = function (index) {
var modalInstance = $modal.open({
@@ -34,7 +34,7 @@
})
.controller('ModalInstanceCtrl', function ($scope, $modalInstance, Book) {
$scope.books = Book.query({format:'json'});
-
+
$scope.addToBook = function(idBook){
$modalInstance.close(idBook);
};