change lot of stuff
This commit is contained in:
@@ -61,7 +61,7 @@ app.factory('ApiService', function($http, $q){
|
||||
ApiService.prototype.update = function (entity) {
|
||||
var deferred = $q.defer();
|
||||
var self = this;
|
||||
$http.put(this.baseUrl, entity).then(function (response) {
|
||||
$http.put(this.baseUrl + '/' + entity.id, entity).then(function (response) {
|
||||
self.add(response.data);
|
||||
deferred.resolve(response.data);
|
||||
}, function (error) {
|
||||
|
||||
@@ -23,7 +23,7 @@ app.factory('BoardService', function(ApiService, $http, $q){
|
||||
var deferred = $q.defer();
|
||||
var self = this;
|
||||
var _acl = acl;
|
||||
$http.post(this.baseUrl + '/acl', _acl).then(function (response) {
|
||||
$http.post(this.baseUrl + '/' + acl.boardId + '/acl', _acl).then(function (response) {
|
||||
if(!board.acl) {
|
||||
board.acl = {};
|
||||
}
|
||||
@@ -36,11 +36,11 @@ app.factory('BoardService', function(ApiService, $http, $q){
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
BoardService.prototype.deleteAcl = function(id) {
|
||||
BoardService.prototype.deleteAcl = function(acl) {
|
||||
var board = this.getCurrent();
|
||||
var deferred = $q.defer();
|
||||
var self = this;
|
||||
$http.delete(this.baseUrl + '/acl/' + id).then(function (response) {
|
||||
$http.delete(this.baseUrl + '/' + acl.boardId + '/acl/' + acl.id).then(function (response) {
|
||||
delete board.acl[response.data.id];
|
||||
deferred.resolve(response.data);
|
||||
}, function (error) {
|
||||
@@ -55,7 +55,7 @@ app.factory('BoardService', function(ApiService, $http, $q){
|
||||
var deferred = $q.defer();
|
||||
var self = this;
|
||||
var _acl = acl;
|
||||
$http.put(this.baseUrl + '/acl', _acl).then(function (response) {
|
||||
$http.put(this.baseUrl + '/' + acl.boardId + '/acl', _acl).then(function (response) {
|
||||
board.acl[_acl.id] = response.data;
|
||||
deferred.resolve(response.data);
|
||||
}, function (error) {
|
||||
|
||||
@@ -7,7 +7,7 @@ app.factory('CardService', function(ApiService, $http, $q){
|
||||
CardService.prototype.reorder = function(card, order) {
|
||||
var deferred = $q.defer();
|
||||
var self = this;
|
||||
$http.put(this.baseUrl + '/reorder', {cardId: card.id, order: order, stackId: card.stackId}).then(function (response) {
|
||||
$http.put(this.baseUrl + '/' + card.id + '/reorder', {cardId: card.id, order: order, stackId: card.stackId}).then(function (response) {
|
||||
card.order = order;
|
||||
deferred.resolve(response.data);
|
||||
}, function (error) {
|
||||
@@ -19,7 +19,7 @@ app.factory('CardService', function(ApiService, $http, $q){
|
||||
CardService.prototype.rename = function(card) {
|
||||
var deferred = $q.defer();
|
||||
var self = this;
|
||||
$http.put(this.baseUrl + '/rename', {cardId: card.id, title: card.title}).then(function (response) {
|
||||
$http.put(this.baseUrl + '/' + card.id + '/rename', {cardId: card.id, title: card.title}).then(function (response) {
|
||||
self.data[card.id].title = card.title;
|
||||
deferred.resolve(response.data);
|
||||
}, function (error) {
|
||||
@@ -29,7 +29,6 @@ app.factory('CardService', function(ApiService, $http, $q){
|
||||
}
|
||||
|
||||
CardService.prototype.assignLabel = function(card, label) {
|
||||
//['name' => 'card#assignLabel', 'url' => '/cards/{cardId}/label/{labelId}', 'verb' => 'POST'],
|
||||
var url = this.baseUrl + '/' + card + '/label/' + label;
|
||||
var deferred = $q.defer();
|
||||
var self = this;
|
||||
@@ -41,7 +40,6 @@ app.factory('CardService', function(ApiService, $http, $q){
|
||||
return deferred.promise;
|
||||
}
|
||||
CardService.prototype.removeLabel = function(card, label) {
|
||||
// ['name' => 'card#removeLabel', 'url' => '/cards/{cardId}/label/{labelId}', 'verb' => 'DELETE'],
|
||||
var url = this.baseUrl + '/' + card + '/label/' + label;
|
||||
var deferred = $q.defer();
|
||||
var self = this;
|
||||
@@ -53,6 +51,18 @@ app.factory('CardService', function(ApiService, $http, $q){
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
CardService.prototype.archive = function (card) {
|
||||
var deferred = $q.defer();
|
||||
var self = this;
|
||||
$http.put(this.baseUrl + '/' + card.id + '/archive').then(function (response) {
|
||||
deferred.resolve(response.data);
|
||||
}, function (error) {
|
||||
deferred.reject('Error while update ' + self.endpoint);
|
||||
});
|
||||
return deferred.promise;
|
||||
|
||||
};
|
||||
|
||||
service = new CardService($http, 'cards', $q)
|
||||
return service;
|
||||
});
|
||||
@@ -7,18 +7,31 @@ app.factory('StackService', function(ApiService, $http, $q){
|
||||
var deferred = $q.defer();
|
||||
var self=this;
|
||||
$http.get(this.baseUrl +'/'+boardId).then(function (response) {
|
||||
self.clear();
|
||||
self.addAll(response.data);
|
||||
deferred.resolve(self.data);
|
||||
}, function (error) {
|
||||
deferred.reject('Error while loading stacks');
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
}
|
||||
StackService.prototype.fetchArchived = function(boardId) {
|
||||
var deferred = $q.defer();
|
||||
var self=this;
|
||||
$http.get(this.baseUrl +'/'+boardId+'/archived').then(function (response) {
|
||||
self.clear();
|
||||
self.addAll(response.data);
|
||||
deferred.resolve(self.data);
|
||||
}, function (error) {
|
||||
deferred.reject('Error while loading stacks');
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
StackService.prototype.addCard = function(entity) {
|
||||
this.data[entity.stackId].cards.push(entity);
|
||||
}
|
||||
};
|
||||
StackService.prototype.updateCard = function(entity) {
|
||||
var self = this;
|
||||
var cards = this.data[entity.stackId].cards;
|
||||
@@ -27,7 +40,7 @@ app.factory('StackService', function(ApiService, $http, $q){
|
||||
cards[i] = entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
StackService.prototype.deleteCard = function(entity) {
|
||||
var self = this;
|
||||
var cards = this.data[entity.stackId].cards;
|
||||
@@ -36,7 +49,7 @@ app.factory('StackService', function(ApiService, $http, $q){
|
||||
cards.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
service = new StackService($http, 'stacks', $q);
|
||||
return service;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user