| author | nowmad@23.1.168.192.in-addr.arpa |
| Wed, 02 Dec 2015 18:07:42 +0100 | |
| changeset 197 | 8b87432acffc |
| parent 188 | fd75c66c8e30 |
| child 201 | 5f54f408cc44 |
| permissions | -rw-r--r-- |
| 1 | 1 |
(function(){ |
| 97 | 2 |
'use strict'; |
|
47
dd750778535c
udate add fonction from a research and add a modal to select the book we want to add the slide
rougeronj
parents:
8
diff
changeset
|
3 |
|
| 97 | 4 |
angular.module('ammicoSearch',['ngResource', 'ngRoute', 'ui.bootstrap']) |
5 |
.config(function ($routeProvider) { |
|
6 |
$routeProvider |
|
7 |
.when('/', { |
|
8 |
templateUrl: 'search/search.html', |
|
9 |
controller: 'searchCtrl' |
|
10 |
}); |
|
11 |
}) |
|
| 188 | 12 |
.controller('searchCtrl', function($scope, $location, $routeParams, searchApi, $modal, Slide){ |
| 97 | 13 |
$scope.q = $routeParams.q || ''; |
|
184
4d01c2d04359
update client version to handle "musée de l'immigration"
rougeronj
parents:
146
diff
changeset
|
14 |
if ($scope.q !== ''){ |
|
197
8b87432acffc
Update search to match the new response from exalead
nowmad@23.1.168.192.in-addr.arpa
parents:
188
diff
changeset
|
15 |
$scope.results = searchApi.searchResource({q:$scope.q, of: 'json', synthesis: 'false', nresults:'10', callback: 'JSON_CALLBACK'}).getJsonp(); |
|
184
4d01c2d04359
update client version to handle "musée de l'immigration"
rougeronj
parents:
146
diff
changeset
|
16 |
} |
|
197
8b87432acffc
Update search to match the new response from exalead
nowmad@23.1.168.192.in-addr.arpa
parents:
188
diff
changeset
|
17 |
|
| 97 | 18 |
$scope.toggleModal = function (index) { |
| 1 | 19 |
|
| 97 | 20 |
var modalInstance = $modal.open({ |
21 |
templateUrl: 'search/modal.html', |
|
22 |
controller: 'ModalInstanceCtrl', |
|
23 |
size: 'sm' |
|
24 |
}); |
|
| 1 | 25 |
|
| 97 | 26 |
modalInstance.result.then(function (idBook) { |
27 |
var newSlide = { |
|
28 |
book: idBook, |
|
|
184
4d01c2d04359
update client version to handle "musée de l'immigration"
rougeronj
parents:
146
diff
changeset
|
29 |
research_id: $scope.results.hits[index].metas_dict.inventorynumber |
| 97 | 30 |
}; |
31 |
Slide.save(newSlide); |
|
32 |
}); |
|
33 |
}; |
|
34 |
}) |
|
35 |
.controller('ModalInstanceCtrl', function ($scope, $modalInstance, Book) { |
|
36 |
$scope.books = Book.query({format:'json'}); |
|
|
197
8b87432acffc
Update search to match the new response from exalead
nowmad@23.1.168.192.in-addr.arpa
parents:
188
diff
changeset
|
37 |
|
| 97 | 38 |
$scope.addToBook = function(idBook){ |
39 |
$modalInstance.close(idBook); |
|
40 |
}; |
|
|
47
dd750778535c
udate add fonction from a research and add a modal to select the book we want to add the slide
rougeronj
parents:
8
diff
changeset
|
41 |
|
| 97 | 42 |
$scope.cancel = function () { |
43 |
$modalInstance.dismiss('cancel'); |
|
44 |
}; |
|
45 |
}); |
|
| 1 | 46 |
})(); |