|
1
|
|
|
/* |
|
2
|
|
|
* @copyright Copyright (c) 2016 Julius Härtl <[email protected]> |
|
3
|
|
|
* |
|
4
|
|
|
* @author Julius Härtl <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* @license GNU AGPL version 3 or any later version |
|
7
|
|
|
* |
|
8
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
9
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
10
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
11
|
|
|
* License, or (at your option) any later version. |
|
12
|
|
|
* |
|
13
|
|
|
* This program is distributed in the hope that it will be useful, |
|
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16
|
|
|
* GNU Affero General Public License for more details. |
|
17
|
|
|
* |
|
18
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
19
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20
|
|
|
* |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
app.factory('CardService', function(ApiService, $http, $q){ |
|
24
|
|
|
var CardService = function($http, ep, $q) { |
|
25
|
|
|
ApiService.call(this, $http, ep, $q); |
|
26
|
|
|
}; |
|
27
|
|
|
CardService.prototype = angular.copy(ApiService.prototype); |
|
28
|
|
|
|
|
29
|
|
|
CardService.prototype.reorder = function(card, order) { |
|
30
|
|
|
var deferred = $q.defer(); |
|
31
|
|
|
var self = this; |
|
32
|
|
|
$http.put(this.baseUrl + '/' + card.id + '/reorder', {cardId: card.id, order: order, stackId: card.stackId}).then(function (response) { |
|
33
|
|
|
deferred.resolve(response.data); |
|
34
|
|
|
}, function (error) { |
|
|
|
|
|
|
35
|
|
|
deferred.reject('Error while update ' + self.endpoint); |
|
36
|
|
|
}); |
|
37
|
|
|
return deferred.promise; |
|
38
|
|
|
}; |
|
39
|
|
|
|
|
40
|
|
|
CardService.prototype.rename = function(card) { |
|
41
|
|
|
var deferred = $q.defer(); |
|
42
|
|
|
var self = this; |
|
43
|
|
|
$http.put(this.baseUrl + '/' + card.id + '/rename', {cardId: card.id, title: card.title}).then(function (response) { |
|
44
|
|
|
self.data[card.id].title = card.title; |
|
45
|
|
|
deferred.resolve(response.data); |
|
46
|
|
|
}, function (error) { |
|
|
|
|
|
|
47
|
|
|
deferred.reject('Error while renaming ' + self.endpoint); |
|
48
|
|
|
}); |
|
49
|
|
|
return deferred.promise; |
|
50
|
|
|
}; |
|
51
|
|
|
|
|
52
|
|
|
CardService.prototype.assignLabel = function(card, label) { |
|
53
|
|
|
var url = this.baseUrl + '/' + card + '/label/' + label; |
|
54
|
|
|
var deferred = $q.defer(); |
|
55
|
|
|
var self = this; |
|
56
|
|
|
$http.post(url).then(function (response) { |
|
57
|
|
|
deferred.resolve(response.data); |
|
58
|
|
|
}, function (error) { |
|
|
|
|
|
|
59
|
|
|
deferred.reject('Error while update ' + self.endpoint); |
|
60
|
|
|
}); |
|
61
|
|
|
return deferred.promise; |
|
62
|
|
|
}; |
|
63
|
|
|
CardService.prototype.removeLabel = function(card, label) { |
|
64
|
|
|
var url = this.baseUrl + '/' + card + '/label/' + label; |
|
65
|
|
|
var deferred = $q.defer(); |
|
66
|
|
|
var self = this; |
|
67
|
|
|
$http.delete(url).then(function (response) { |
|
68
|
|
|
deferred.resolve(response.data); |
|
69
|
|
|
}, function (error) { |
|
|
|
|
|
|
70
|
|
|
deferred.reject('Error while update ' + self.endpoint); |
|
71
|
|
|
}); |
|
72
|
|
|
return deferred.promise; |
|
73
|
|
|
}; |
|
74
|
|
|
|
|
75
|
|
|
CardService.prototype.archive = function (card) { |
|
76
|
|
|
var deferred = $q.defer(); |
|
77
|
|
|
var self = this; |
|
78
|
|
|
$http.put(this.baseUrl + '/' + card.id + '/archive', {}).then(function (response) { |
|
79
|
|
|
deferred.resolve(response.data); |
|
80
|
|
|
}, function (error) { |
|
|
|
|
|
|
81
|
|
|
deferred.reject('Error while update ' + self.endpoint); |
|
82
|
|
|
}); |
|
83
|
|
|
return deferred.promise; |
|
84
|
|
|
|
|
85
|
|
|
}; |
|
86
|
|
|
|
|
87
|
|
|
CardService.prototype.unarchive = function (card) { |
|
88
|
|
|
var deferred = $q.defer(); |
|
89
|
|
|
var self = this; |
|
90
|
|
|
$http.put(this.baseUrl + '/' + card.id + '/unarchive', {}).then(function (response) { |
|
91
|
|
|
deferred.resolve(response.data); |
|
92
|
|
|
}, function (error) { |
|
|
|
|
|
|
93
|
|
|
deferred.reject('Error while update ' + self.endpoint); |
|
94
|
|
|
}); |
|
95
|
|
|
return deferred.promise; |
|
96
|
|
|
|
|
97
|
|
|
}; |
|
98
|
|
|
|
|
99
|
|
|
service = new CardService($http, 'cards', $q); |
|
|
|
|
|
|
100
|
|
|
return service; |
|
101
|
|
|
}); |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.