| author | rougeronj |
| Thu, 01 Oct 2015 17:55:23 +0200 | |
| changeset 184 | 4d01c2d04359 |
| parent 146 | c6fa8ee3f562 |
| child 188 | fd75c66c8e30 |
| 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 |
}) |
|
|
184
4d01c2d04359
update client version to handle "musée de l'immigration"
rougeronj
parents:
146
diff
changeset
|
12 |
.controller('searchCtrl', function($scope, $location, $routeParams, searchApi, searchApi2, $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 !== ''){ |
|
4d01c2d04359
update client version to handle "musée de l'immigration"
rougeronj
parents:
146
diff
changeset
|
15 |
$scope.results_ = searchApi.searchResource({q:$scope.q, of: 'json', synthesis: 'false', nresults:'10', callback: 'JSON_CALLBACK'}).getJsonp(); |
|
4d01c2d04359
update client version to handle "musée de l'immigration"
rougeronj
parents:
146
diff
changeset
|
16 |
$scope.results = searchApi2.searchResource({q:$scope.q, of: 'json', synthesis: 'false', nresults:'10', callback: 'JSON_CALLBACK'}).getJsonp(); |
|
4d01c2d04359
update client version to handle "musée de l'immigration"
rougeronj
parents:
146
diff
changeset
|
17 |
} |
| 97 | 18 |
|
19 |
$scope.toggleModal = function (index) { |
|
| 1 | 20 |
|
| 97 | 21 |
var modalInstance = $modal.open({ |
22 |
templateUrl: 'search/modal.html', |
|
23 |
controller: 'ModalInstanceCtrl', |
|
24 |
size: 'sm' |
|
25 |
}); |
|
| 1 | 26 |
|
| 97 | 27 |
modalInstance.result.then(function (idBook) { |
28 |
var newSlide = { |
|
29 |
book: idBook, |
|
|
184
4d01c2d04359
update client version to handle "musée de l'immigration"
rougeronj
parents:
146
diff
changeset
|
30 |
research_id: $scope.results.hits[index].metas_dict.inventorynumber |
| 97 | 31 |
}; |
32 |
Slide.save(newSlide); |
|
33 |
}); |
|
34 |
}; |
|
35 |
}) |
|
36 |
.controller('ModalInstanceCtrl', function ($scope, $modalInstance, Book) { |
|
37 |
$scope.books = Book.query({format:'json'}); |
|
38 |
|
|
39 |
$scope.addToBook = function(idBook){ |
|
40 |
$modalInstance.close(idBook); |
|
41 |
}; |
|
|
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
|
42 |
|
| 97 | 43 |
$scope.cancel = function () { |
44 |
$modalInstance.dismiss('cancel'); |
|
45 |
}; |
|
46 |
}); |
|
| 1 | 47 |
})(); |