client/app/search/search_controller.js
author rougeronj
Wed, 08 Apr 2015 00:36:37 +0200
changeset 77 ee963d1c409b
parent 55 10fd23382e76
child 82 6a5e84bf859c
permissions -rw-r--r--
Add new serializer for the data send by Orpheo. We receive XML so we parse it to json. Then we parse some html to get the proper data of each attribute. Add xmlToJson parser module to requirements.txt
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
74bbdd739878 views, path, search...
cavaliet
parents:
diff changeset
     1
(function(){
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
     2
	'use strict';
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
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
     4
	angular.module('ammicoSearch',['ngResource', 'ngRoute', 'ui.bootstrap'])
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
     5
	.config(function ($routeProvider) {
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
     6
		$routeProvider
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
     7
		.when('/', {
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
     8
			templateUrl: 'search/search.html',
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
     9
			controller: 'searchCtrl'
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
    10
		});
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
    11
	})
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
    12
	.controller('searchCtrl', function($scope, $location, $routeParams, searchApi, $modal){
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
    13
		$scope.q = $routeParams.q || '';
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
    14
		$scope.results = searchApi.searchResource({q:$scope.q, of: 'json', synthesis: 'false', nresults:'10', callback: 'JSON_CALLBACK'}).getJsonp();
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
    15
		
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
    16
		$scope.toggleModal = function (index) {
1
74bbdd739878 views, path, search...
cavaliet
parents:
diff changeset
    17
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
    18
			var modalInstance = $modal.open({
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
    19
				templateUrl: 'search/modal.html',
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
    20
				controller: 'ModalInstanceCtrl',
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
    21
				size: 'sm'
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
    22
			});
1
74bbdd739878 views, path, search...
cavaliet
parents:
diff changeset
    23
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
    24
			modalInstance.result.then(function (idBook) {
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
    25
				var newSlide = {
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
    26
					book: idBook,
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
    27
					idInventory: $scope.results.hits[index].metas_dict.inventorynumber
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
    28
				};
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
    29
				searchApi.listSlides.save(newSlide);
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
    30
			});
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
    31
		};
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
    32
	})
55
10fd23382e76 split ammico $resource to a new .Service
rougeronj
parents: 47
diff changeset
    33
	.controller('ModalInstanceCtrl', function ($scope, ammicoApi, $modalInstance) {
10fd23382e76 split ammico $resource to a new .Service
rougeronj
parents: 47
diff changeset
    34
		$scope.books = ammicoApi.listBooks.query({format:'json'});
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
    35
		
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
    36
		$scope.addToBook = function(idBook){
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
    37
			$modalInstance.close(idBook);
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
    38
		};
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
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
    40
		$scope.cancel = function () {
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
			$modalInstance.dismiss('cancel');
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
		};
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
    43
	});
1
74bbdd739878 views, path, search...
cavaliet
parents:
diff changeset
    44
})();