committed by
Julius Härtl
parent
47b51c512d
commit
afec4f211c
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
|
|
||||||
module.exports = function(grunt) {
|
module.exports = function(grunt) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
grunt.loadNpmTasks('grunt-contrib-concat');
|
grunt.loadNpmTasks('grunt-contrib-concat');
|
||||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||||
@@ -37,13 +37,13 @@ module.exports = function(grunt) {
|
|||||||
pkg: grunt.file.readJSON('package.json'),
|
pkg: grunt.file.readJSON('package.json'),
|
||||||
version: '<%= meta.pkg.version %>',
|
version: '<%= meta.pkg.version %>',
|
||||||
configJS: 'config/',
|
configJS: 'config/',
|
||||||
buildJS: [
|
buildJS: [
|
||||||
'app/**/*.js',
|
'app/**/*.js',
|
||||||
'controller/**/*.js',
|
'controller/**/*.js',
|
||||||
'filters/**/*.js',
|
'filters/**/*.js',
|
||||||
'directive/**/*.js',
|
'directive/**/*.js',
|
||||||
'service/**/*.js'
|
'service/**/*.js'
|
||||||
],
|
],
|
||||||
productionJS: 'public/',
|
productionJS: 'public/',
|
||||||
testsJS: '../tests/js/'
|
testsJS: '../tests/js/'
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** global: OC, oc_defaults, Snap */
|
/* global Snap */
|
||||||
app.run(function ($document, $rootScope, $transitions, BoardService) {
|
app.run(function ($document, $rootScope, $transitions, BoardService) {
|
||||||
'use strict';
|
'use strict';
|
||||||
$document.click(function (event) {
|
$document.click(function (event) {
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ app.controller('BoardController', function ($rootScope, $scope, $stateParams, St
|
|||||||
// filter cards here, as ng-sortable will not work nicely with html-inline filters
|
// filter cards here, as ng-sortable will not work nicely with html-inline filters
|
||||||
$scope.filterData = function (order, text) {
|
$scope.filterData = function (order, text) {
|
||||||
if ($scope.stacks === undefined)
|
if ($scope.stacks === undefined)
|
||||||
return;
|
{return;}
|
||||||
angular.copy(StackService.getData(), $scope.stacks);
|
angular.copy(StackService.getData(), $scope.stacks);
|
||||||
$scope.stacks = $filter('orderBy')($scope.stacks, 'order');
|
$scope.stacks = $filter('orderBy')($scope.stacks, 'order');
|
||||||
angular.forEach($scope.stacks, function (value, key) {
|
angular.forEach($scope.stacks, function (value, key) {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ app.controller('CardController', function ($scope, $rootScope, $routeParams, $lo
|
|||||||
|
|
||||||
$scope.cardRenameShow = function () {
|
$scope.cardRenameShow = function () {
|
||||||
if ($scope.archived || !BoardService.canEdit())
|
if ($scope.archived || !BoardService.canEdit())
|
||||||
return false;
|
{return false;}
|
||||||
else {
|
else {
|
||||||
$scope.status.cardRename = true;
|
$scope.status.cardRename = true;
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ app.controller('CardController', function ($scope, $rootScope, $routeParams, $lo
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.labelRemove = function (element, model) {
|
$scope.labelRemove = function (element, model) {
|
||||||
CardService.removeLabel($scope.cardId, element.id)
|
CardService.removeLabel($scope.cardId, element.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.setDuedate = function (duedate) {
|
$scope.setDuedate = function (duedate) {
|
||||||
|
|||||||
@@ -23,26 +23,26 @@
|
|||||||
/* global app angular */
|
/* global app angular */
|
||||||
|
|
||||||
app.controller('ListController', function ($scope, $location, $filter, BoardService, $element, $timeout, $stateParams, $state) {
|
app.controller('ListController', function ($scope, $location, $filter, BoardService, $element, $timeout, $stateParams, $state) {
|
||||||
function calculateNewColor() {
|
function calculateNewColor() {
|
||||||
var boards = BoardService.getAll();
|
var boards = BoardService.getAll();
|
||||||
var boardKeys = Object.keys(boards);
|
var boardKeys = Object.keys(boards);
|
||||||
var colorOccurrences = [];
|
var colorOccurrences = [];
|
||||||
|
|
||||||
for (var i = 0; i < $scope.colors.length; i++) {
|
for (var i = 0; i < $scope.colors.length; i++) {
|
||||||
colorOccurrences.push(0);
|
colorOccurrences.push(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var j = 0; j < boardKeys.length; j++) {
|
for (var j = 0; j < boardKeys.length; j++) {
|
||||||
var key = boardKeys[j];
|
var key = boardKeys[j];
|
||||||
var board = boards[key];
|
var board = boards[key];
|
||||||
|
|
||||||
if (board && $scope.colors.indexOf(board.color) !== -1) {
|
if (board && $scope.colors.indexOf(board.color) !== -1) {
|
||||||
colorOccurrences[$scope.colors.indexOf(board.color)]++;
|
colorOccurrences[$scope.colors.indexOf(board.color)]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $scope.colors[colorOccurrences.indexOf(Math.min.apply(Math, colorOccurrences))];
|
return $scope.colors[colorOccurrences.indexOf(Math.min.apply(Math, colorOccurrences))];
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.boards = [];
|
$scope.boards = [];
|
||||||
$scope.newBoard = {};
|
$scope.newBoard = {};
|
||||||
|
|||||||
@@ -21,29 +21,29 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
app.directive('appPopoverMenuUtils', function () {
|
app.directive('appPopoverMenuUtils', function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
return {
|
return {
|
||||||
restrict: 'C',
|
restrict: 'C',
|
||||||
link: function (scope, elm) {
|
link: function (scope, elm) {
|
||||||
var menu = elm.find('.popovermenu');
|
var menu = elm.find('.popovermenu');
|
||||||
var button = elm.find('button');
|
var button = elm.find('button');
|
||||||
button.click(function (e) {
|
button.click(function (e) {
|
||||||
$('.popovermenu').addClass('hidden');
|
$('.popovermenu').addClass('hidden');
|
||||||
menu.toggleClass('hidden');
|
menu.toggleClass('hidden');
|
||||||
if(!menu.hasClass('hidden')) {
|
if(!menu.hasClass('hidden')) {
|
||||||
button.css('display','block');
|
button.css('display','block');
|
||||||
} else {
|
} else {
|
||||||
button.css('display','');
|
button.css('display','');
|
||||||
}
|
}
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
scope.$on('documentClicked', function (scope, event) {
|
scope.$on('documentClicked', function (scope, event) {
|
||||||
/* prevent closing popover if target has no-close class */
|
/* prevent closing popover if target has no-close class */
|
||||||
if (event.target !== button && !$(event.target).hasClass('no-close')) {
|
if (event.target !== button && !$(event.target).hasClass('no-close')) {
|
||||||
menu.addClass('hidden');
|
menu.addClass('hidden');
|
||||||
}
|
}
|
||||||
button.css('display','');
|
button.css('display','');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,24 +23,24 @@
|
|||||||
// OwnCloud Click Handling
|
// OwnCloud Click Handling
|
||||||
// https://doc.owncloud.org/server/8.0/developer_manual/app/css.html
|
// https://doc.owncloud.org/server/8.0/developer_manual/app/css.html
|
||||||
app.directive('appNavigationEntryUtils', function () {
|
app.directive('appNavigationEntryUtils', function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
return {
|
return {
|
||||||
restrict: 'C',
|
restrict: 'C',
|
||||||
link: function (scope, elm) {
|
link: function (scope, elm) {
|
||||||
|
|
||||||
var menu = elm.siblings('.app-navigation-entry-menu');
|
var menu = elm.siblings('.app-navigation-entry-menu');
|
||||||
var button = $(elm)
|
var button = $(elm)
|
||||||
.find('.app-navigation-entry-utils-menu-button button');
|
.find('.app-navigation-entry-utils-menu-button button');
|
||||||
|
|
||||||
button.click(function () {
|
button.click(function () {
|
||||||
menu.toggleClass('open');
|
menu.toggleClass('open');
|
||||||
});
|
});
|
||||||
scope.$on('documentClicked', function (scope, event) {
|
scope.$on('documentClicked', function (scope, event) {
|
||||||
if (event.target !== button[0]) {
|
if (event.target !== button[0]) {
|
||||||
menu.removeClass('open');
|
menu.removeClass('open');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
app.directive('autofocusOnInsert', function () {
|
app.directive('autofocusOnInsert', function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
return function (scope, elm) {
|
return function (scope, elm) {
|
||||||
elm.focus();
|
elm.focus();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
app.filter('boardFilterAcl', function() {
|
app.filter('boardFilterAcl', function() {
|
||||||
return function(boards) {
|
return function(boards) {
|
||||||
var _result = [];
|
var _result = [];
|
||||||
angular.forEach(boards, function(board){
|
angular.forEach(boards, function(board){
|
||||||
if(board.acl !== null && Object.keys(board.acl).length > 0) {
|
if(board.acl !== null && Object.keys(board.acl).length > 0) {
|
||||||
@@ -29,5 +29,5 @@ app.filter('boardFilterAcl', function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return _result;
|
return _result;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
// usage | cardFilter({ member: 'admin'})
|
// usage | cardFilter({ member: 'admin'})
|
||||||
|
|
||||||
app.filter('cardFilter', function() {
|
app.filter('cardFilter', function() {
|
||||||
return function(cards, rules) {
|
return function(cards, rules) {
|
||||||
var _result = [];
|
var _result = [];
|
||||||
angular.forEach(cards, function(card){
|
angular.forEach(cards, function(card){
|
||||||
var _card = card;
|
var _card = card;
|
||||||
@@ -35,5 +35,5 @@ app.filter('cardFilter', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
return _result;
|
return _result;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -27,19 +27,19 @@
|
|||||||
app.filter('relativeDateFilter', function() {
|
app.filter('relativeDateFilter', function() {
|
||||||
return function (timestamp) {
|
return function (timestamp) {
|
||||||
return OC.Util.relativeModifiedDate(timestamp*1000);
|
return OC.Util.relativeModifiedDate(timestamp*1000);
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
app.filter('relativeDateFilterString', function() {
|
app.filter('relativeDateFilterString', function() {
|
||||||
return function (date) {
|
return function (date) {
|
||||||
return OC.Util.relativeModifiedDate(Date.parse(date));
|
return OC.Util.relativeModifiedDate(Date.parse(date));
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
app.filter('dateToTimestamp', function() {
|
app.filter('dateToTimestamp', function() {
|
||||||
return function (date) {
|
return function (date) {
|
||||||
return Date.parse(date);
|
return Date.parse(date);
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
app.filter('parseDate', function() {
|
app.filter('parseDate', function() {
|
||||||
@@ -48,7 +48,7 @@ app.filter('parseDate', function() {
|
|||||||
return moment(date).format('YYYY-MM-DD');
|
return moment(date).format('YYYY-MM-DD');
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
app.filter('parseTime', function() {
|
app.filter('parseTime', function() {
|
||||||
@@ -57,5 +57,5 @@ app.filter('parseTime', function() {
|
|||||||
return moment(date).format('HH:mm');
|
return moment(date).format('HH:mm');
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
@@ -39,21 +39,21 @@ app.filter('iconWhiteFilter', function () {
|
|||||||
var max = Math.max(r, g, b), min = Math.min(r, g, b);
|
var max = Math.max(r, g, b), min = Math.min(r, g, b);
|
||||||
var h, s, l = (max + min) / 2;
|
var h, s, l = (max + min) / 2;
|
||||||
|
|
||||||
if (max == min) {
|
if (max === min) {
|
||||||
h = s = 0; // achromatic
|
h = s = 0; // achromatic
|
||||||
} else {
|
} else {
|
||||||
var d = max - min;
|
var d = max - min;
|
||||||
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
||||||
switch (max) {
|
switch (max) {
|
||||||
case r:
|
case r:
|
||||||
h = (g - b) / d + (g < b ? 6 : 0);
|
h = (g - b) / d + (g < b ? 6 : 0);
|
||||||
break;
|
break;
|
||||||
case g:
|
case g:
|
||||||
h = (b - r) / d + 2;
|
h = (b - r) / d + 2;
|
||||||
break;
|
break;
|
||||||
case b:
|
case b:
|
||||||
h = (r - g) / d + 4;
|
h = (r - g) / d + 4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
h /= 6;
|
h /= 6;
|
||||||
}
|
}
|
||||||
@@ -62,5 +62,5 @@ app.filter('iconWhiteFilter', function () {
|
|||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -33,5 +33,5 @@ app.filter('lightenColorFilter', function() {
|
|||||||
} else {
|
} else {
|
||||||
return "#" + hex;
|
return "#" + hex;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
app.filter('orderObjectBy', function(){
|
app.filter('orderObjectBy', function(){
|
||||||
return function(input, attribute) {
|
return function(input, attribute) {
|
||||||
if (!angular.isObject(input)) return input;
|
if (!angular.isObject(input)) {return input;}
|
||||||
var array = [];
|
var array = [];
|
||||||
for(var objectKey in input) {
|
for(var objectKey in input) {
|
||||||
array.push(input[objectKey]);
|
array.push(input[objectKey]);
|
||||||
@@ -34,5 +34,5 @@ app.filter('orderObjectBy', function(){
|
|||||||
return a < b;
|
return a < b;
|
||||||
});
|
});
|
||||||
return array;
|
return array;
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
@@ -43,15 +43,15 @@ app.filter('textColorFilter', function () {
|
|||||||
var d = max - min;
|
var d = max - min;
|
||||||
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
||||||
switch (max) {
|
switch (max) {
|
||||||
case r:
|
case r:
|
||||||
h = (g - b) / d + (g < b ? 6 : 0);
|
h = (g - b) / d + (g < b ? 6 : 0);
|
||||||
break;
|
break;
|
||||||
case g:
|
case g:
|
||||||
h = (b - r) / d + 2;
|
h = (b - r) / d + 2;
|
||||||
break;
|
break;
|
||||||
case b:
|
case b:
|
||||||
h = (r - g) / d + 4;
|
h = (r - g) / d + 4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
h /= 6;
|
h /= 6;
|
||||||
}
|
}
|
||||||
@@ -64,5 +64,5 @@ app.filter('textColorFilter', function () {
|
|||||||
return "#000000";
|
return "#000000";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ app.factory('BoardService', function (ApiService, $http, $q) {
|
|||||||
permissionManage: true,
|
permissionManage: true,
|
||||||
permissionShare: true,
|
permissionShare: true,
|
||||||
type: type
|
type: type
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
BoardService.prototype.addAcl = function (acl) {
|
BoardService.prototype.addAcl = function (acl) {
|
||||||
|
|||||||
@@ -20,80 +20,87 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
app.factory('CardService', function(ApiService, $http, $q){
|
app.factory('CardService', function (ApiService, $http, $q) {
|
||||||
var CardService = function($http, ep, $q) {
|
var CardService = function ($http, ep, $q) {
|
||||||
ApiService.call(this, $http, ep, $q);
|
ApiService.call(this, $http, ep, $q);
|
||||||
};
|
};
|
||||||
CardService.prototype = angular.copy(ApiService.prototype);
|
CardService.prototype = angular.copy(ApiService.prototype);
|
||||||
|
|
||||||
CardService.prototype.reorder = function(card, order) {
|
CardService.prototype.reorder = function (card, order) {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
var self = this;
|
var self = this;
|
||||||
$http.put(this.baseUrl + '/' + card.id + '/reorder', {cardId: card.id, order: order, stackId: card.stackId}).then(function (response) {
|
$http.put(this.baseUrl + '/' + card.id + '/reorder', {
|
||||||
deferred.resolve(response.data);
|
cardId: card.id,
|
||||||
}, function (error) {
|
order: order,
|
||||||
deferred.reject('Error while update ' + self.endpoint);
|
stackId: card.stackId
|
||||||
});
|
}).then(function (response) {
|
||||||
return deferred.promise;
|
deferred.resolve(response.data);
|
||||||
};
|
}, function (error) {
|
||||||
|
deferred.reject('Error while update ' + self.endpoint);
|
||||||
|
});
|
||||||
|
return deferred.promise;
|
||||||
|
};
|
||||||
|
|
||||||
CardService.prototype.rename = function(card) {
|
CardService.prototype.rename = function (card) {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
var self = this;
|
var self = this;
|
||||||
$http.put(this.baseUrl + '/' + card.id + '/rename', {cardId: card.id, title: card.title}).then(function (response) {
|
$http.put(this.baseUrl + '/' + card.id + '/rename', {
|
||||||
self.data[card.id].title = card.title;
|
cardId: card.id,
|
||||||
deferred.resolve(response.data);
|
title: card.title
|
||||||
}, function (error) {
|
}).then(function (response) {
|
||||||
deferred.reject('Error while renaming ' + self.endpoint);
|
self.data[card.id].title = card.title;
|
||||||
});
|
deferred.resolve(response.data);
|
||||||
return deferred.promise;
|
}, function (error) {
|
||||||
};
|
deferred.reject('Error while renaming ' + self.endpoint);
|
||||||
|
});
|
||||||
|
return deferred.promise;
|
||||||
|
};
|
||||||
|
|
||||||
CardService.prototype.assignLabel = function(card, label) {
|
CardService.prototype.assignLabel = function (card, label) {
|
||||||
var url = this.baseUrl + '/' + card + '/label/' + label;
|
var url = this.baseUrl + '/' + card + '/label/' + label;
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
var self = this;
|
var self = this;
|
||||||
$http.post(url).then(function (response) {
|
$http.post(url).then(function (response) {
|
||||||
deferred.resolve(response.data);
|
deferred.resolve(response.data);
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
deferred.reject('Error while update ' + self.endpoint);
|
deferred.reject('Error while update ' + self.endpoint);
|
||||||
});
|
});
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
CardService.prototype.removeLabel = function(card, label) {
|
CardService.prototype.removeLabel = function (card, label) {
|
||||||
var url = this.baseUrl + '/' + card + '/label/' + label;
|
var url = this.baseUrl + '/' + card + '/label/' + label;
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
var self = this;
|
var self = this;
|
||||||
$http.delete(url).then(function (response) {
|
$http.delete(url).then(function (response) {
|
||||||
deferred.resolve(response.data);
|
deferred.resolve(response.data);
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
deferred.reject('Error while update ' + self.endpoint);
|
deferred.reject('Error while update ' + self.endpoint);
|
||||||
});
|
});
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
CardService.prototype.archive = function (card) {
|
CardService.prototype.archive = function (card) {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
var self = this;
|
var self = this;
|
||||||
$http.put(this.baseUrl + '/' + card.id + '/archive', {}).then(function (response) {
|
$http.put(this.baseUrl + '/' + card.id + '/archive', {}).then(function (response) {
|
||||||
deferred.resolve(response.data);
|
deferred.resolve(response.data);
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
deferred.reject('Error while update ' + self.endpoint);
|
deferred.reject('Error while update ' + self.endpoint);
|
||||||
});
|
});
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CardService.prototype.unarchive = function (card) {
|
CardService.prototype.unarchive = function (card) {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
var self = this;
|
var self = this;
|
||||||
$http.put(this.baseUrl + '/' + card.id + '/unarchive', {}).then(function (response) {
|
$http.put(this.baseUrl + '/' + card.id + '/unarchive', {}).then(function (response) {
|
||||||
deferred.resolve(response.data);
|
deferred.resolve(response.data);
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
deferred.reject('Error while update ' + self.endpoint);
|
deferred.reject('Error while update ' + self.endpoint);
|
||||||
});
|
});
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
CardService.prototype.assignUser = function (card, user) {
|
CardService.prototype.assignUser = function (card, user) {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
@@ -115,7 +122,7 @@ app.factory('CardService', function(ApiService, $http, $q){
|
|||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
var self = this;
|
var self = this;
|
||||||
$http.delete(this.baseUrl + '/' + card.id + '/assign/' + user, {}).then(function (response) {
|
$http.delete(this.baseUrl + '/' + card.id + '/assign/' + user, {}).then(function (response) {
|
||||||
self.getCurrent().assignedUsers = self.getCurrent().assignedUsers.filter(function( obj ) {
|
self.getCurrent().assignedUsers = self.getCurrent().assignedUsers.filter(function (obj) {
|
||||||
return obj.participant.uid !== user;
|
return obj.participant.uid !== user;
|
||||||
});
|
});
|
||||||
deferred.resolve(response.data);
|
deferred.resolve(response.data);
|
||||||
@@ -125,6 +132,6 @@ app.factory('CardService', function(ApiService, $http, $q){
|
|||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
service = new CardService($http, 'cards', $q);
|
service = new CardService($http, 'cards', $q);
|
||||||
return service;
|
return service;
|
||||||
});
|
});
|
||||||
@@ -20,48 +20,51 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
app.factory('StackService', function(ApiService, $http, $q){
|
app.factory('StackService', function (ApiService, $http, $q) {
|
||||||
var StackService = function($http, ep, $q) {
|
var StackService = function ($http, ep, $q) {
|
||||||
ApiService.call(this, $http, ep, $q);
|
ApiService.call(this, $http, ep, $q);
|
||||||
};
|
};
|
||||||
StackService.prototype = angular.copy(ApiService.prototype);
|
StackService.prototype = angular.copy(ApiService.prototype);
|
||||||
StackService.prototype.fetchAll = function(boardId) {
|
StackService.prototype.fetchAll = function (boardId) {
|
||||||
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) {
|
|
||||||
if(!this.data[entity.stackId].cards) {
|
|
||||||
this.data[entity.stackId].cards = [];
|
|
||||||
}
|
|
||||||
this.data[entity.stackId].cards.push(entity);
|
|
||||||
};
|
|
||||||
|
|
||||||
StackService.prototype.reorder = function(stack, order) {
|
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
var self = this;
|
var self = this;
|
||||||
$http.put(this.baseUrl + '/' + stack.id + '/reorder', {stackId: stack.id, order: order}).then(function (response) {
|
$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) {
|
||||||
|
if (!this.data[entity.stackId].cards) {
|
||||||
|
this.data[entity.stackId].cards = [];
|
||||||
|
}
|
||||||
|
this.data[entity.stackId].cards.push(entity);
|
||||||
|
};
|
||||||
|
|
||||||
|
StackService.prototype.reorder = function (stack, order) {
|
||||||
|
var deferred = $q.defer();
|
||||||
|
var self = this;
|
||||||
|
$http.put(this.baseUrl + '/' + stack.id + '/reorder', {
|
||||||
|
stackId: stack.id,
|
||||||
|
order: order
|
||||||
|
}).then(function (response) {
|
||||||
angular.forEach(response.data, function (value, key) {
|
angular.forEach(response.data, function (value, key) {
|
||||||
var id = value.id;
|
var id = value.id;
|
||||||
self.data[id].order = value.order;
|
self.data[id].order = value.order;
|
||||||
@@ -73,49 +76,49 @@ app.factory('StackService', function(ApiService, $http, $q){
|
|||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
StackService.prototype.reorderCard = function(entity, order) {
|
StackService.prototype.reorderCard = function (entity, order) {
|
||||||
// assign new order
|
// assign new order
|
||||||
for(var i=0, j=0;i<this.data[entity.stackId].cards.length;i++) {
|
for (var i = 0, j = 0; i < this.data[entity.stackId].cards.length; i++) {
|
||||||
if(this.data[entity.stackId].cards[i].id === entity.id) {
|
if (this.data[entity.stackId].cards[i].id === entity.id) {
|
||||||
this.data[entity.stackId].cards[i].order = order;
|
this.data[entity.stackId].cards[i].order = order;
|
||||||
}
|
}
|
||||||
if(j === order) {
|
if (j === order) {
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
if(this.data[entity.stackId].cards[i].id !== entity.id) {
|
if (this.data[entity.stackId].cards[i].id !== entity.id) {
|
||||||
this.data[entity.stackId].cards[i].order = j++;
|
this.data[entity.stackId].cards[i].order = j++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// sort array by order
|
// sort array by order
|
||||||
this.data[entity.stackId].cards.sort(function(a,b) {
|
this.data[entity.stackId].cards.sort(function (a, b) {
|
||||||
if (a.order < b.order)
|
if (a.order < b.order)
|
||||||
return -1;
|
{return -1;}
|
||||||
if (a.order > b.order)
|
if (a.order > b.order)
|
||||||
return 1;
|
{return 1;}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
StackService.prototype.updateCard = function(entity) {
|
StackService.prototype.updateCard = function (entity) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var cards = this.data[entity.stackId].cards;
|
var cards = this.data[entity.stackId].cards;
|
||||||
for(var i=0;i<cards.length;i++) {
|
for (var i = 0; i < cards.length; i++) {
|
||||||
if(cards[i].id == entity.id) {
|
if (cards[i].id == entity.id) {
|
||||||
cards[i] = entity;
|
cards[i] = entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
StackService.prototype.removeCard = function(entity) {
|
StackService.prototype.removeCard = function (entity) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var cards = this.data[entity.stackId].cards;
|
var cards = this.data[entity.stackId].cards;
|
||||||
for(var i=0;i<cards.length;i++) {
|
for (var i = 0; i < cards.length; i++) {
|
||||||
if(cards[i].id == entity.id) {
|
if (cards[i].id == entity.id) {
|
||||||
cards.splice(i, 1);
|
cards.splice(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
service = new StackService($http, 'stacks', $q);
|
service = new StackService($http, 'stacks', $q);
|
||||||
return service;
|
return service;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -20,58 +20,58 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
app.factory('StatusService', function(){
|
app.factory('StatusService', function () {
|
||||||
// Status Helper
|
// Status Helper
|
||||||
var StatusService = function() {
|
var StatusService = function () {
|
||||||
this.active = true;
|
this.active = true;
|
||||||
this.icon = 'loading';
|
this.icon = 'loading';
|
||||||
this.title = '';
|
this.title = '';
|
||||||
this.text = '';
|
this.text = '';
|
||||||
this.counter = 0;
|
this.counter = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
StatusService.prototype.setStatus = function($icon, $title, $text) {
|
StatusService.prototype.setStatus = function ($icon, $title, $text) {
|
||||||
this.active = true;
|
this.active = true;
|
||||||
this.icon = $icon;
|
this.icon = $icon;
|
||||||
this.title = $title;
|
this.title = $title;
|
||||||
this.text = $text;
|
this.text = $text;
|
||||||
};
|
};
|
||||||
|
|
||||||
StatusService.prototype.setError = function($title, $text) {
|
StatusService.prototype.setError = function ($title, $text) {
|
||||||
this.active = true;
|
this.active = true;
|
||||||
this.icon = 'error';
|
this.icon = 'error';
|
||||||
this.title = $title;
|
this.title = $title;
|
||||||
this.text = $text;
|
this.text = $text;
|
||||||
this.counter = 0;
|
this.counter = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
StatusService.prototype.releaseWaiting = function() {
|
StatusService.prototype.releaseWaiting = function () {
|
||||||
if(this.counter>0)
|
if (this.counter > 0)
|
||||||
this.counter--;
|
{this.counter--;}
|
||||||
if(this.counter<=0) {
|
if (this.counter <= 0) {
|
||||||
this.active = false;
|
this.active = false;
|
||||||
this.counter = 0;
|
this.counter = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
StatusService.prototype.retainWaiting = function() {
|
StatusService.prototype.retainWaiting = function () {
|
||||||
this.active = true;
|
this.active = true;
|
||||||
this.icon = 'loading';
|
this.icon = 'loading';
|
||||||
this.title = '';
|
this.title = '';
|
||||||
this.text = '';
|
this.text = '';
|
||||||
this.counter++;
|
this.counter++;
|
||||||
};
|
};
|
||||||
|
|
||||||
StatusService.prototype.unsetStatus = function() {
|
StatusService.prototype.unsetStatus = function () {
|
||||||
this.active = false;
|
this.active = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getInstance: function() {
|
getInstance: function () {
|
||||||
return new StatusService();
|
return new StatusService();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user