| author | ymh <ymh.work@gmail.com> |
| Wed, 08 Jan 2020 17:49:53 +0100 | |
| changeset 205 | 147583c43f0d |
| parent 170 | 533a98367f99 |
| permissions | -rw-r--r-- |
| 91 | 1 |
(function(){ |
|
99
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
2 |
'use strict'; |
| 91 | 3 |
|
|
99
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
4 |
angular.module('ammicoMyvisit',['ngRoute', 'ui.sortable']) |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
5 |
.controller('my_visitCtrl', function($scope, $location, $modal, Book, Slide){ |
| 91 | 6 |
|
|
99
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
7 |
//get list book |
|
170
533a98367f99
filter book in the request through 'type' parameter instead of filtering on client side
rougeronj
parents:
146
diff
changeset
|
8 |
Book.query({type: 'visit', format:'json'}, function(data){ |
|
99
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
9 |
data.sort(function (a, b) { |
|
170
533a98367f99
filter book in the request through 'type' parameter instead of filtering on client side
rougeronj
parents:
146
diff
changeset
|
10 |
return a.date > b.date; |
|
99
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
11 |
}); |
|
170
533a98367f99
filter book in the request through 'type' parameter instead of filtering on client side
rougeronj
parents:
146
diff
changeset
|
12 |
if (data.length >= 1){ |
|
533a98367f99
filter book in the request through 'type' parameter instead of filtering on client side
rougeronj
parents:
146
diff
changeset
|
13 |
$scope.last_visit = data[0]; |
|
533a98367f99
filter book in the request through 'type' parameter instead of filtering on client side
rougeronj
parents:
146
diff
changeset
|
14 |
$scope.last_visit.slides = Slide.query({idBook:data[0].id, format:'json'}); |
|
533a98367f99
filter book in the request through 'type' parameter instead of filtering on client side
rougeronj
parents:
146
diff
changeset
|
15 |
} |
|
99
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
16 |
}); |
| 91 | 17 |
|
|
99
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
18 |
$scope.addBook = function (idParent) { |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
19 |
$modal.open({ |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
20 |
templateUrl: 'my_visit/add_modal_my_visit.html', |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
21 |
controller: 'ModalAddMyvisitCtrl' |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
22 |
}).result.then(function (title) { |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
23 |
//add book with the title written in the modal |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
24 |
Book.save({idParent:idParent, title: title}, function(newBook){ |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
25 |
$scope.books.push(newBook); |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
26 |
}); |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
27 |
}); |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
28 |
}; |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
29 |
}) |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
30 |
.controller('ModalAddMyvisitCtrl', function ($scope, $modalInstance) { |
| 91 | 31 |
|
|
99
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
32 |
$scope.add = function(){ |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
33 |
$modalInstance.close($scope.title); |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
34 |
}; |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
35 |
$scope.cancel = function () { |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
36 |
$modalInstance.dismiss('cancel'); |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
37 |
}; |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
38 |
$scope.share = function () { |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
39 |
$modalInstance($scope.book); |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
40 |
}; |
|
c7c424e9eed5
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources
rougeronj
parents:
91
diff
changeset
|
41 |
}); |
| 91 | 42 |
})(); |
43 |