Skip to content

Commit

Permalink
Dev (kiswa#284)
Browse files Browse the repository at this point in the history
* Added a default color for each board category to be used over the def…

* board.js fix for previous commit

* Feature for integration with Issue Tracking systems loosely based on TortoiseSVN Bugtraq.
  • Loading branch information
ZM-git authored and kiswa committed May 16, 2016
1 parent ef90f2a commit fedd17a
Show file tree
Hide file tree
Showing 13 changed files with 269 additions and 19 deletions.
1 change: 1 addition & 0 deletions api/boardRoutes.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
R::trashAll($board->xownLane);
R::trashAll($board->xownCategory);
R::trashAll($board->xownAutoaction);
R::trashAll($board->xownTracker);
R::trash($board);
R::exec('DELETE from board_user WHERE board_id = ?', array($data->boardId));
$jsonResponse->addAlert('success', 'Removed board ' . $board->name . '.');
Expand Down
17 changes: 17 additions & 0 deletions api/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ function loadBoardData($board, $data) {
foreach($data->categories as $item) {
$category = R::load('category', $item->id);
$category->name = $item->name;
$category->color = $item->color;

// New category, add it to the board.
if (!$category->id) {
Expand All @@ -224,6 +225,22 @@ function loadBoardData($board, $data) {
R::store($category);
}

$removeIds = getIdsToRemove($board->xownTracker, $data->trackers);
foreach($removeIds as $id) {
unset($board->xownTracker[$id]);
}
foreach($data->trackers as $item) {
$tracker = R::load('tracker', $item->id);
$tracker->name = $item->name;
$tracker->bugexpr = $item->bugexpr;

// New issue tracker, add it to the board.
if (!$tracker->id) {
$board->xownTracker[] = $tracker;
}
R::store($tracker);
}

// Add or remove users as selected.
for($i = 1; $i < count($data->users); $i++) {
$user = R::load('user', $i);
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<script src="lib/angular-route.js"></script>
<script src="lib/angular-sanitize.js"></script>
<script src="lib/ng-context-menu.min.js"></script>
<script src="lib/hyperlink.js"></script>
<script src="lib/marked.min.js"></script>
<script src="lib/prefixfree.min.js"></script>
<script src="lib/spectrum.js"></script>
Expand Down
11 changes: 9 additions & 2 deletions js/controllers/boards.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function ($scope, $routeParams, $location, $interval, $window,
$scope.alerts = AlertService;
$scope.marked = function(text) {
if (text) {
return $window.marked(text);
return $window.marked(hyperlink(text, $scope.trackers));
} else {
return '';
}
Expand Down Expand Up @@ -111,6 +111,7 @@ function ($scope, $routeParams, $location, $interval, $window,
$scope.userNames = [];
$scope.laneNames = [];
$scope.categories = [];
$scope.trackers = [];
$scope.currentBoard = {
loading: true,
name: 'Kanban Board App'
Expand Down Expand Up @@ -189,12 +190,18 @@ function ($scope, $routeParams, $location, $interval, $window,
});

if (board.ownCategory) {
board.ownCategory.unshift({ id: 0, name: 'Uncategorized' });
board.ownCategory.unshift({ id: 0, name: 'Uncategorized', color: '#ffffe0' });
board.ownCategory.forEach(function(category) {
$scope.categories[category.id] = category.name;
});
}

if (board.ownTracker) {
board.ownTracker.forEach(function(tracker) {
$scope.trackers[tracker.id] = [tracker.name, tracker.bugexpr];
});
}

$scope.currentBoard = board;
$scope.boardNames.current = board.id;
boardFound = true;
Expand Down
12 changes: 12 additions & 0 deletions js/controllers/boardsItemView.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ function ($scope, $window, BoardService) {
convertDates($scope.viewItem.ownActivity);
};

$scope.setColor = function(item) {
var color = item.color;
if (item.color != $scope.currentBoard.ownCategory[0].color)
return item.color;
$scope.currentBoard.ownCategory.forEach(function(cat) {
if(cat.id == item.category) {
color = cat.color;
}
});
return color;
}

$scope.openItem = function(item, openModal) {
if (undefined === openModal) {
openModal = true;
Expand Down
5 changes: 3 additions & 2 deletions js/controllers/settingsAutoActions.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
taskBoardControllers.controller('AutomaticActionsCtrl',
['$scope', '$interval', 'BoardService',
function ($scope, $interval, BoardService) {
var defaultColor = '#ffffe0';
$scope.loadingActions = true;
$scope.actions = [];

$scope.secondarySelection = [];
$scope.boardCategories = [{ id: 0, name: 'Uncategorized' }];
$scope.boardCategories = [{ id: 0, name: 'Uncategorized', color: defaultColor }];
$scope.userList = [{ id: 0, name: 'Unassigned', username: 'Unassigned' }];

$scope.actionData = {
Expand Down Expand Up @@ -79,7 +80,7 @@ function ($scope, $interval, BoardService) {
},

getCategories = function(boardData) {
var categories = [{ id: '0', name: 'Uncategorized' }];
var categories = [{ id: '0', name: 'Uncategorized', color: defaultColor }];

if (boardData && boardData.ownCategory) {
boardData.ownCategory.forEach(function(category) {
Expand Down
131 changes: 122 additions & 9 deletions js/controllers/settingsBoardForm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
taskBoardControllers.controller('BoardFormSettingsCtrl',
['$scope', 'BoardService',
function ($scope, BoardService) {
var defaultColor = '#ffffe0';

$scope.boardFormData = {
setFocus: false,
boardId: 0,
Expand All @@ -10,10 +12,15 @@ function ($scope, BoardService) {
laneName: '',
categories: [],
categoryName: '',
color: defaultColor,
users: [],
nameError: false,
lanesError: false,
categoriesError: false,
trackers: [],
trackerName: '',
bugexpr: '',
trackersError: false,
isSaving: false,
updateLanesSorting: function() {
var that = this;
Expand Down Expand Up @@ -52,7 +59,17 @@ function ($scope, BoardService) {
board.ownCategory.forEach(function(cat) {
that.categories.push({
id: cat.id,
name: cat.name
name: cat.name,
color: cat.color
});
});
}
if (undefined !== board.ownTracker) {
board.ownTracker.forEach(function(trac) {
that.trackers.push({
id: trac.id,
name: trac.name,
bugexpr: trac.bugexpr
});
});
}
Expand All @@ -67,14 +84,14 @@ function ($scope, BoardService) {
addLane: function() {
this.lanesError = false;
if (this.laneName === '') {
this.setAlert(false, true, false, 'Column name cannot be empty.');
this.setAlert(false, true, false, false, 'Column name cannot be empty.');
return;
}

var that = this;
this.lanes.forEach(function(lane) {
if (that.laneName == lane.name) {
that.setAlert(false, true, false, 'That column name has already been added.');
that.setAlert(false, true, false, false, 'That column name has already been added.');
that.lanesError = true;
}
});
Expand Down Expand Up @@ -103,22 +120,23 @@ function ($scope, BoardService) {
addCategory: function() {
this.categoriesError = false;
if (this.categoryName === '') {
this.setAlert(false, false, true, 'Category name cannot be empty.');
this.setAlert(false, false, true, false, 'Category name cannot be empty.');
return;
}

var that = this;
this.categories.forEach(function(category) {
if (that.categoryName == category) {
this.setAlert(false, false, true, 'That category name has already been added.');
this.setAlert(false, false, true, false, 'That category name has already been added.');
}
});

// Add the new category (if no error) and reset the input.
if (!this.categoriesError) {
this.categories.push({
id: 0,
name: this.categoryName
name: this.categoryName,
color: this.color
});
}
this.categoryName = '';
Expand All @@ -127,16 +145,50 @@ function ($scope, BoardService) {
if (this.isSaving) { return; }
this.categories.splice(this.categories.indexOf(category), 1);
},
addTracker: function() {
this.trackersError = false;
if (this.trackerName === '') {
this.setAlert(false, false, false, true, 'Issue Tracker URL cannot be empty.');
return;
}
if (this.bugexpr === '') {
this.setAlert(false, false, false, true, 'Bug ID regular expression cannot be empty.');
return;
}
var that = this;
this.trackers.forEach(function(tracker) {
if (that.trackerName == tracker) {
this.setAlert(false, false, false, true, 'That Issue Tracker URL has already been added.');
}
});

// Add the new issue tracker (if no error) and reset the input.
if (!this.trackersError) {
this.trackers.push({
id: 0,
name: this.trackerName,
bugexpr: this.bugexpr
});
}
this.trackerName = '';
this.bugexpr = '';
},
removeTracker: function(tracker) {
if (this.isSaving) { return; }
this.trackers.splice(this.trackers.indexOf(tracker), 1);
},
setForSaving: function() {
this.nameError = false;
this.lanesError = false;
this.categoriesError = false;
this.trackersError = false;
this.isSaving = true;
},
setAlert: function(name, lane, cat, message) {
setAlert: function(name, lane, cat, trac, message) {
this.nameError = name;
this.lanesError = lane;
this.categoriesError = cat;
this.trackersError = trac;
this.isSaving = false;
$scope.alerts.showAlert({ 'type': 'error', 'text': message });
},
Expand All @@ -149,15 +201,24 @@ function ($scope, BoardService) {
this.laneName = '';
this.categories = [];
this.categoryName = '';
this.color = defaultColor;
$('#spectrum').spectrum('enable');
$scope.spectrum(defaultColor);
this.users = [];
this.nameError = false;
this.lanesError = false;
this.categoriesError = false;
this.trackers = [];
this.trackerName = '';
this.bugexpr = '';
this.trackersError = false;
this.isSaving = false;
},
// Uses jQuery to close modal and reset form data.
cancel: function() {
$('.boardModal').modal('hide');
$('#spectrum').spectrum('hide');
$('#spectrum').spectrum('enable');
var that = this;
$('.boardModal').on('hidden.bs.modal', function (e) {
that.reset();
Expand All @@ -166,8 +227,24 @@ function ($scope, BoardService) {
};
$scope.$parent.boardFormData = $scope.boardFormData;

$scope.spectrum = function(color) {
color = color || defaultColor;
$('#spectrum').spectrum({
color: color,
allowEmpty: false,
localStorageKey: 'taskboard.colorPalette',
showPalette: true,
palette: [ ['#fff', '#ececec', '#ffffe0', '#ffe0fa', '#bee7f4', '#c3f4b5', '#debee8', '#ffdea9', '#ffbaba'] ],
showSelectionPalette: true,
showButtons: false,
showInput: true,
preferredFormat: 'hex3',
});
};
$scope.addBoard = function(boardFormData) {
boardFormData.setForSaving();
$('#spectrum').spectrum('disable');

if (!checkFormInputs(boardFormData)) {
return;
}
Expand All @@ -186,6 +263,8 @@ function ($scope, BoardService) {

$scope.editBoard = function(boardFormData) {
boardFormData.setForSaving();
$('#spectrum').spectrum('disable');

if (!checkFormInputs(boardFormData)) {
return;
}
Expand All @@ -202,14 +281,48 @@ function ($scope, BoardService) {
});
};

$scope.editedCategory = {};
$scope.editColor = function(category) {
if ($scope.editedCategory.id === undefined)
{
$scope.editedCategory.id = category.id;
$scope.editedCategory.name = category.name;

$scope.editedCategory.color = $scope.boardFormData.color;
$scope.spectrum(category.color);
}
else if (($scope.editedCategory.id != category.id) &&
($scope.editedCategory.name != category.name))
{
$scope.spectrum()
$scope.editedCategory = {};
}
};
$scope.storeColor = function(e) {
if (e.which === 13) { // Enter key
$scope.boardFormData.categories.forEach(function(cat){
if ((cat.id == $scope.editedCategory.id) &&
(cat.name == $scope.editedCategory.name))
cat.color = $scope.boardFormData.color;
});
$scope.spectrum();
$scope.editedCategory = {};
}
else if (e.which === 27) { // Escape key
$scope.spectrum();
$scope.editedCategory = {};
}
};


var checkFormInputs = function(boardFormData) {
if ('' === boardFormData.name) {
boardFormData.setAlert(true, false, false, 'Board name cannot be empty.');
boardFormData.setAlert(true, false, false, false, 'Board name cannot be empty.');
return false;
}

if (0 === boardFormData.lanes.length) {
boardFormData.setAlert(false, true, false, 'At least one lane is required.');
boardFormData.setAlert(false, true, false, false, 'At least one lane is required.');
return false;
}

Expand Down
2 changes: 2 additions & 0 deletions js/services/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function($http) {
name: boardData.name,
lanes: boardData.lanes,
categories: boardData.categories,
trackers: boardData.trackers,
users: boardData.users
});
},
Expand All @@ -27,6 +28,7 @@ function($http) {
name: boardData.name,
lanes: boardData.lanes,
categories: boardData.categories,
trackers: boardData.trackers,
users: boardData.users
});
},
Expand Down
Loading

0 comments on commit fedd17a

Please sign in to comment.