| author | rougeronj |
| Wed, 27 May 2015 18:59:55 +0200 | |
| changeset 97 | 0afdaa004ee1 |
| parent 82 | 6a5e84bf859c |
| child 146 | c6fa8ee3f562 |
| 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 |
}) |
|
12 |
.controller('searchCtrl', function($scope, $location, $routeParams, searchApi, $modal, Slide){ |
|
13 |
$scope.q = $routeParams.q || ''; |
|
14 |
$scope.results = searchApi.searchResource({q:$scope.q, of: 'json', synthesis: 'false', nresults:'10', callback: 'JSON_CALLBACK'}).getJsonp(); |
|
15 |
|
|
16 |
$scope.toggleModal = function (index) { |
|
| 1 | 17 |
|
| 97 | 18 |
var modalInstance = $modal.open({ |
19 |
templateUrl: 'search/modal.html', |
|
20 |
controller: 'ModalInstanceCtrl', |
|
21 |
size: 'sm' |
|
22 |
}); |
|
| 1 | 23 |
|
| 97 | 24 |
modalInstance.result.then(function (idBook) { |
25 |
var newSlide = { |
|
26 |
book: idBook, |
|
27 |
idInventory: $scope.results.hits[index].metas_dict.inventorynumber |
|
28 |
}; |
|
29 |
Slide.save(newSlide); |
|
30 |
}); |
|
31 |
}; |
|
32 |
}) |
|
33 |
.controller('ModalInstanceCtrl', function ($scope, $modalInstance, Book) { |
|
34 |
$scope.books = Book.query({format:'json'}); |
|
35 |
|
|
36 |
$scope.addToBook = function(idBook){ |
|
37 |
$modalInstance.close(idBook); |
|
38 |
}; |
|
|
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
|
39 |
|
| 97 | 40 |
$scope.cancel = function () { |
41 |
$modalInstance.dismiss('cancel'); |
|
42 |
}; |
|
43 |
}); |
|
| 1 | 44 |
})(); |