Merge pull request #374 from kiswa/dev

Dev
This commit is contained in:
Matthew Ross 2017-07-13 07:14:51 -04:00 committed by GitHub
commit 60242f5fe3
25 changed files with 381 additions and 79 deletions

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2014 Matthew Ross
Copyright (c) 2014-2016 Matthew Ross
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -76,8 +76,10 @@ $app->post('/boards/remove', function() use($app, $jsonResponse) {
}
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 = ?', [$data->boardId]);
R::exec('DELETE from board_user WHERE board_id = ?', array($data->boardId));
$jsonResponse->addAlert('success', 'Removed board ' . $board->name . '.');
$actor = getUser();
logAction($actor->username . ' removed board ' . $board->name, $before, null);
@ -138,7 +140,7 @@ $app->post('/lanes/:laneId/toggle', function($laneId) use($app, $jsonResponse) {
if (validateToken()) {
$user = getUser();
$lane = R::load('lane', $laneId);
$collapsed = R::findOne('collapsed', ' user_id = ? AND lane_id = ? ', [$user->id, $laneId]);
$collapsed = R::findOne('collapsed', ' user_id = ? AND lane_id = ? ', array($user->id, $laneId));
if (null != $collapsed) {
R::trash($collapsed);
@ -154,7 +156,7 @@ $app->post('/lanes/:laneId/toggle', function($laneId) use($app, $jsonResponse) {
$jsonResponse->addBeans(getBoards());
}
$app->response->setBody($jsonResponse->asJson());
})->conditions(['laneId' => '\d+']); // Numbers only.
})->conditions(array('laneId' => '\d+')); // Numbers only.
$app->post('/boards/:boardId/toggleActive', function($boardId) use($app, $jsonResponse) {
if (validateToken()) {
@ -174,4 +176,4 @@ $app->post('/boards/:boardId/toggleActive', function($boardId) use($app, $jsonRe
}
}
$app->response->setBody($jsonResponse->asJson());
})->conditions(['boardId' => '\d+']); // Numbers only.
})->conditions(array('boardId' => '\d+')); // Numbers only.

View File

@ -40,7 +40,7 @@ function setUserToken($user, $expires) {
$dbToken->token = $token;
if (null == $user->ownToken) {
$user->ownToken = [];
$user->ownToken = array();
}
$user->ownToken[] = $dbToken;
@ -50,9 +50,9 @@ function setUserToken($user, $expires) {
// Get the user making the current request.
function getUser() {
global $jsonResponse;
if (isset(getallheaders()['Authorization'])) {
$hash = getallheaders()['Authorization'];
$gah = getallheaders();
if (isset($gah['Authorization'])) {
$hash = $gah['Authorization'];
try {
$payload = JWT::decode($hash, getJwtKey());
$user = R::load('user', $payload->uid);
@ -94,7 +94,8 @@ function getLaneByID($id) {
// Get all users.
function getUsers($sanitize = true) {
try {
$hash = getallheaders()['Authorization'];
$gah = getallheaders();
$hash = $gah['Authorization'];
$payload = JWT::decode($hash, getJwtKey());
$users = R::findAll('user');
@ -153,7 +154,7 @@ function getBoards() {
if ($user->isAdmin) {
return $boards;
} else {
$filteredBoards = [];
$filteredBoards = array();
foreach($boards as $board) {
foreach($board->sharedUser as $boardUser) {
if ($user->username == $boardUser->username) {
@ -167,7 +168,7 @@ function getBoards() {
// Finds the removed IDs for updating a board.
function getIdsToRemove($boardList, $dataList) {
$retVal = [];
$retVal = array();
foreach($boardList as $item) {
$remove = true;
foreach($dataList as $newItem) {
@ -199,7 +200,7 @@ function loadBoardData($board, $data) {
$lane->position = intval($item->position);
if (null == $lane->ownItems) {
$lane->ownItems = [];
$lane->ownItems = array();
}
// New lane, add it to the board
if (!$lane->id) {
@ -215,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) {
@ -223,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);
@ -246,14 +264,14 @@ function loadBoardData($board, $data) {
// Clean a user bean for return to front-end.
function sanitize($user) {
$user['salt'] = null;
$user->ownToken = [];
$user->ownToken = array();
$user['password'] = null;
}
// Change username if available.
function updateUsername($user, $data) {
global $jsonResponse;
$nameTaken = R::findOne('user', ' username = ?', [$data->newUsername]);
$nameTaken = R::findOne('user', ' username = ?', array($data->newUsername));
if (null != $user && null == $nameTaken) {
$user->username = $data->newUsername;
@ -268,7 +286,7 @@ function updateUsername($user, $data) {
// Change email if available.
function updateEmail($user, $data) {
global $jsonResponse;
$emailTaken = R::findOne('user', ' username = ?', [$data->newEmail]);
$emailTaken = R::findOne('user', ' username = ?', array($data->newEmail));
if (null != $user && null == $emailTaken) {
$user->email = $data->newEmail;
@ -311,8 +329,9 @@ function checkDbToken() {
$isValid = false;
if (null != $user) {
if (isset(getallheaders()['Authorization'])) {
$hash = getallheaders()['Authorization'];
$gah = getallheaders();
if (isset($gah['Authorization'])) {
$hash = $gah['Authorization'];
foreach ($user->ownToken as $token) {
if ($hash == $token->token) {
@ -328,15 +347,16 @@ function checkDbToken() {
// Clear a user's token from the DB.
function clearDbToken() {
$payload = null;
$gah = getallheaders();
try {
$payload = JWT::decode(getallheaders()['Authorization'], getJwtKey());
$payload = JWT::decode($gah['Authorization'], getJwtKey());
} catch (Exception $e) {}
if (null != $payload) {
$user = R::load('user', $payload->uid);
if (0 != $user->id) {
$hash = getallheaders()['Authorization'];
$hash = $gah['Authorization'];
foreach ($user->ownToken as $token) {
if ($hash == $token->token) {

View File

@ -59,7 +59,7 @@ $app->post('/boards/:id/items', function($id) use($app, $jsonResponse) {
}
}
$app->response->setBody($jsonResponse->asJson());
})->conditions(['id' => '\d+']); // Numbers only.
})->conditions(array('id' => '\d+')); // Numbers only.
//Update existing item
$app->post('/items/:itemId', function($itemId) use ($app, $jsonResponse) {
@ -121,7 +121,7 @@ $app->post('/items/:itemId', function($itemId) use ($app, $jsonResponse) {
}
}
$app->response->setBody($jsonResponse->asJson());
})->conditions(['itemId' => '\d+']);
})->conditions(array('itemId' => '\d+'));
// Update item positions
$app->post('/items/positions', function() use ($app, $jsonResponse) {
@ -201,7 +201,7 @@ $app->post('/items/:itemId/comment', function($itemId) use ($app, $jsonResponse)
}
}
$app->response->setBody($jsonResponse->asJson());
})->conditions(['itemId' => '\d+']);
})->conditions(array('itemId' => '\d+'));
// Update an existing comment
$app->post('/comments/:commentId', function($commentId) use ($app, $jsonResponse) {
@ -242,7 +242,7 @@ $app->post('/comments/:commentId', function($commentId) use ($app, $jsonResponse
}
}
$app->response->setBody($jsonResponse->asJson());
})->conditions(['commentId' => '\d+']);
})->conditions(array('commentId' => '\d+'));
// Remove a comment from an item.
$app->post('/items/:itemId/comment/remove', function($itemId) use ($app, $jsonResponse) {
@ -262,7 +262,7 @@ $app->post('/items/:itemId/comment/remove', function($itemId) use ($app, $jsonRe
}
}
$app->response->setBody($jsonResponse->asJson());
})->conditions(['itemId' => '\d+']);
})->conditions(array('itemId' => '\d+'));
// Add an attachment to an item.
$app->post('/items/:itemId/upload', function($itemId) use ($app, $jsonResponse) {
@ -294,7 +294,7 @@ $app->post('/items/:itemId/upload', function($itemId) use ($app, $jsonResponse)
$jsonResponse->addBeans($item);
}
$app->response->setBody($jsonResponse->asJson());
})->conditions(['itemId' => '\d+']);
})->conditions(array('itemId' => '\d+'));
// Get an item attachment's information.
$app->get('/items/:itemId/upload/:attachmentId', function($itemId, $attachmentId) use ($app, $jsonResponse) {
@ -311,7 +311,7 @@ $app->get('/items/:itemId/upload/:attachmentId', function($itemId, $attachmentId
}
}
$app->response->setBody($jsonResponse->asJson());
})->conditions(['itemId' => '\d+', 'attachmentId' => '\d+']);
})->conditions(array('itemId' => '\d+', 'attachmentId' => '\d+'));
// Remove an attachment from an item.
$app->post('/items/:itemId/upload/remove', function($itemId) use ($app, $jsonResponse) {
@ -337,7 +337,7 @@ $app->post('/items/:itemId/upload/remove', function($itemId) use ($app, $jsonRes
}
}
$app->response->setBody($jsonResponse->asJson());
})->conditions(['itemId' => '\d+']);
})->conditions(array('itemId' => '\d+'));
// Remove an item.
$app->post('/items/remove', function() use ($app, $jsonResponse) {

View File

@ -17,6 +17,6 @@ class JsonResponse {
}
function addAlert($type, $text) {
$this->alerts[] = ['type' => $type, 'text' => $text];
$this->alerts[] = array('type' => $type, 'text' => $text);
}
}

View File

@ -8,7 +8,7 @@ $app->post('/login', function() use ($app, $jsonResponse) {
? (2 * 7 * 24 * 60 * 60) /* Two weeks */
: (1.5 * 60 * 60) /* One and a half hours */;
$lookup = R::findOne('user', ' username = ? ', [$data->username]);
$lookup = R::findOne('user', ' username = ? ', array($data->username));
$jsonResponse->message = 'Invalid username or password.';
$app->response->setStatus(401);
@ -27,7 +27,7 @@ $app->post('/login', function() use ($app, $jsonResponse) {
logAction($lookup->username . ' logged in.', null, null);
$jsonResponse->message = 'Login successful.';
$jsonResponse->data = R::findOne('token', ' user_id = ? ORDER BY id DESC ', [$lookup->id])->token;
$jsonResponse->data = R::findOne('token', ' user_id = ? ORDER BY id DESC ', array($lookup->id))->token;
$app->response->setStatus(200);
}
}
@ -139,19 +139,19 @@ $app->get('/users/current', function() use($app, $jsonResponse) {
$user = getUser();
if (null != $user) {
$userOptions = R::exportAll($user->xownOptionList);
$options = [
$options = array(
'tasksOrder' => $userOptions[0]['tasks_order'],
'showAssignee' => $userOptions[0]['show_assignee'] == 1,
'showAnimations' => $userOptions[0]['show_animations'] == 1
];
$jsonResponse->data = [
);
$jsonResponse->data = array(
'userId' => $user->id,
'username' => $user->username,
'isAdmin' => $user->isAdmin,
'email' => $user->email,
'defaultBoard' => $user->defaultBoard,
'options' => $options
];
);
}
}
$app->response->setBody($jsonResponse->asJson());
@ -186,7 +186,7 @@ $app->post('/users', function() use($app, $jsonResponse) {
$data = json_decode($app->environment['slim.input']);
if (validateToken(true)) {
$nameTaken = R::findOne('user', ' username = ?', [$data->username]);
$nameTaken = R::findOne('user', ' username = ?', array($data->username));
if (null != $nameTaken) {
$jsonResponse->addAlert('error', 'Username already in use.');
@ -268,7 +268,7 @@ $app->post('/users/remove', function() use($app, $jsonResponse) {
if ($user->id == $data->userId && $actor->isAdmin) {
$before = $user->export();
R::trash($user);
R::exec('DELETE from board_user WHERE user_id = ?', [$data->userId]);
R::exec('DELETE from board_user WHERE user_id = ?', array($data->userId));
logAction($actor->username . ' removed user ' . $before['username'], $before, null);
$jsonResponse->addAlert('success', 'Removed user ' . $user->username . '.');

View File

@ -4,7 +4,7 @@ FROM ubuntu:trusty
MAINTAINER Alex van den Hoogen <alex.van.den.hoogen@geodan.nl>
RUN apt-get update && \
apt-get install -yq --no-install-recommends git wget nginx php5-fpm php5-sqlite sqlite3 ca-certificates pwgen && \
apt-get install -yq --no-install-recommends git wget nginx php5-fpm php5-sqlite sqlite3 ca-certificates pwgen php5-cli && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
@ -15,8 +15,11 @@ RUN echo "cgi.fix_pathinfo = 0;" >> /etc/php5/fpm/php.ini && \
RUN git clone https://github.com/kiswa/TaskBoard.git /var/www && \
chmod 777 $(find /var/www -type d)
RUN cd /var/www/ && ./build/composer.phar install
ADD nginx.conf /etc/nginx/sites-available/default
EXPOSE 80
CMD service php5-fpm start && nginx

27
build/Vagrantfile vendored Normal file
View File

@ -0,0 +1,27 @@
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty32"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.synced_folder "../", "/taskboard"
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install -y curl php5 php5-cli php5-sqlite sqlite3 apache2 libapache2-mod-php5
sudo apt-get clean
sudo a2enmod rewrite
sudo a2enmod expires
echo "<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /taskboard
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
<Directory /taskboard>
AllowOverride All
Options All
Require all granted
</Directory>
</VirtualHost>" > /etc/apache2/sites-enabled/000-default.conf
sudo service apache2 restart
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
cd /taskboard && composer install
SHELL
end

View File

@ -19,7 +19,7 @@ cat bootstrap.min.css > combined.css
cat font-awesome.min.css >> combined.css
cat jquery-ui.min.css >> combined.css
cat spectrum.css >> combined.css
curl -X POST -s --data-urlencode 'input@combined.css' http://cssminifier.com/raw > combined.min.css
curl -X POST -s --data-urlencode 'input@combined.css' https://cssminifier.com/raw?input= > combined.min.css
rm combined.css
cd ../../build/
@ -28,7 +28,7 @@ echo ' Compiling app JS files...'
echo ' Minifying app CSS files...'
cd ../css/
curl -X POST -s --data-urlencode 'input@styles.css' http://cssminifier.com/raw > styles.min.css
curl -X POST -s --data-urlencode 'input@styles.css' https://cssminifier.com/raw?input= > styles.min.css
cd ../build/
echo ' Updating index.html...'

Binary file not shown.

View File

@ -1,10 +1,10 @@
{
"name": "kiswa/taskboard",
"require": {
"slim/slim": "=2.6.1",
"firebase/php-jwt": "=1.0.0",
"slim/slim": "~2.6.1",
"firebase/php-jwt": "~1.0.0",
"ircmaxell/password-compat": "~1.0.3",
"gabordemooij/redbean": "=4.2.0",
"gabordemooij/redbean": "~4.2.0",
"phpmailer/phpmailer": "~5.2.9"
},
"license": "MIT",

25
composer.lock generated
View File

@ -4,8 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "bcd0d77c65d6fda9ece3a2600d80347c",
"content-hash": "99f3562842898771c354cfc411491902",
"hash": "00b50e5ebd2d03b90ef653c95854ecc3",
"packages": [
{
"name": "firebase/php-jwt",
@ -53,16 +52,16 @@
},
{
"name": "gabordemooij/redbean",
"version": "v4.2.0",
"version": "v4.2.1",
"source": {
"type": "git",
"url": "https://github.com/gabordemooij/redbean.git",
"reference": "840a2e0d856042e75a701453f37896c597c6fbc2"
"reference": "13610146620d7c0a66215dcaf0c8796bb03a04aa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/gabordemooij/redbean/zipball/840a2e0d856042e75a701453f37896c597c6fbc2",
"reference": "840a2e0d856042e75a701453f37896c597c6fbc2",
"url": "https://api.github.com/repos/gabordemooij/redbean/zipball/13610146620d7c0a66215dcaf0c8796bb03a04aa",
"reference": "13610146620d7c0a66215dcaf0c8796bb03a04aa",
"shasum": ""
},
"require": {
@ -90,7 +89,7 @@
"keywords": [
"orm"
],
"time": "2015-04-01 19:03:42"
"time": "2015-05-09 12:22:47"
},
{
"name": "ircmaxell/password-compat",
@ -171,7 +170,7 @@
"extras/ntlm_sasl_client.php"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1"
],
@ -197,16 +196,16 @@
},
{
"name": "slim/slim",
"version": "2.6.1",
"version": "2.6.2",
"source": {
"type": "git",
"url": "https://github.com/slimphp/Slim.git",
"reference": "365dbfa0c02a31e76888eaec693dacd9dca1c82a"
"reference": "20a02782f76830b67ae56a5c08eb1f563c351a37"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/slimphp/Slim/zipball/365dbfa0c02a31e76888eaec693dacd9dca1c82a",
"reference": "365dbfa0c02a31e76888eaec693dacd9dca1c82a",
"url": "https://api.github.com/repos/slimphp/Slim/zipball/20a02782f76830b67ae56a5c08eb1f563c351a37",
"reference": "20a02782f76830b67ae56a5c08eb1f563c351a37",
"shasum": ""
},
"require": {
@ -239,7 +238,7 @@
"rest",
"router"
],
"time": "2015-03-02 19:09:48"
"time": "2015-03-08 18:41:17"
}
],
"packages-dev": [],

View File

@ -315,6 +315,9 @@ textarea {
margin: 5px;
text-align: right;
}
.addItem input {
width: 80% !important;
}
.draggable-placeholder {
height: 80px;
box-shadow: inset 0px 0px 10px 0px rgba(51,51,51,.25);

View File

@ -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>

View File

@ -16,10 +16,14 @@ function ($scope, $routeParams, $location, $interval, $window,
$location.path(path);
}
$scope.quickAdd = {
title: []
};
$scope.alerts = AlertService;
$scope.marked = function(text) {
if (text) {
return $window.marked(text);
return $window.marked(hyperlink(text, $scope.trackers));
} else {
return '';
}
@ -107,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'
@ -185,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;

View File

@ -39,6 +39,17 @@ function ($scope, BoardService) {
$('.itemModal').on('hidden.bs.modal', function (e) {
that.reset();
});
if ($scope.quickAdd.title[laneId]) {
this.quickAddItem(laneId);
}
},
quickAddItem: function(laneId) {
$('.itemModal').on('show.bs.modal', function(e) {
e.stopPropogation();
});
this.title = $scope.quickAdd.title[laneId];
$scope.submitItem(this);
delete $scope.quickAdd.title[laneId];
},
loadItem: function(item) {
this.reset(item.lane_id);

View File

@ -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;

View File

@ -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 = {
@ -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) {

View File

@ -1,6 +1,8 @@
taskBoardControllers.controller('BoardFormSettingsCtrl',
['$scope', 'BoardService',
function ($scope, BoardService) {
var defaultColor = '#ffffe0';
$scope.boardFormData = {
setFocus: false,
boardId: 0,
@ -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;
@ -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
});
});
}
@ -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;
}
});
@ -103,14 +120,14 @@ 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.');
}
});
@ -118,7 +135,8 @@ function ($scope, BoardService) {
if (!this.categoriesError) {
this.categories.push({
id: 0,
name: this.categoryName
name: this.categoryName,
color: this.color
});
}
this.categoryName = '';
@ -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 });
},
@ -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();
@ -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;
}
@ -186,6 +263,8 @@ function ($scope, BoardService) {
$scope.editBoard = function(boardFormData) {
boardFormData.setForSaving();
$('#spectrum').spectrum('disable');
if (!checkFormInputs(boardFormData)) {
return;
}
@ -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;
}

View File

@ -17,6 +17,7 @@ function($http) {
name: boardData.name,
lanes: boardData.lanes,
categories: boardData.categories,
trackers: boardData.trackers,
users: boardData.users
});
},
@ -27,6 +28,7 @@ function($http) {
name: boardData.name,
lanes: boardData.lanes,
categories: boardData.categories,
trackers: boardData.trackers,
users: boardData.users
});
},

33
lib/hyperlink.js Normal file
View File

@ -0,0 +1,33 @@
hyperlink = function(item, trackers) {
var s = item;
var bugId = /%BUGID(?:\\(\d))?%/g;
if (trackers === undefined) return s;
for (i in trackers)
{
var tracker = trackers[i][0];
var bug = trackers[i][1];
if ((tracker == "") || (bug == "")) continue;
var bGroups = bugId.exec(tracker);
var bugEx = new RegExp(bug);
var regEx = new RegExp("(^|\\s|[^\\\\\\?\\/\\-\\[])(" + bug + ")(?=\\W|$)", "mg");
//s = s.replace(regEx, "\$1[\$2]("+tracker.replace(bugId,"\$2")+")");
s = s.replace(regEx, function(match,g1,g2,offset, text){
var m = bugEx.exec(g2);
var r = tracker.replace(bugId, function(match ,p1, offset, text) {
var idx = 0;
if (p1 !== undefined) idx = parseInt(p1);
return m[idx];
});
return g1+"["+g2+"]("+r+")";
});
}
return s;
}

View File

@ -56,11 +56,11 @@
data-ng-class="{'filtered': item.filtered, 'hidden': item.filtered && filter.hide}"
data-ng-repeat="item in lane.ownItem | orderBy:'position':false"
data-ng-dblclick="openItem(item)"
style="background-color: {{ item.color }}"
data-ng-style="{'background-color': setColor(item)}"
data-item-id="{{ item.id }}"
data-context-menu="onContextMenu(lane.id, item)" data-target="itemMenu">
<div class="itemHeader">
<h4>{{ item.title }}</h4>
<h4><span data-ng-bind-html="marked(item.title)"></span></h4>
<span class="badge" title="Points">{{ item.points }}</span>
</div>
<div class="description" data-ng-bind-html="marked(item.description)"></div>
@ -82,8 +82,9 @@
</span>
</p>
</div>
<div class="addItem">
<a role="button" class="btn btn-default fa fa-plus" data-toggle="modal"
<div class="addItem form-inline">
<input class="form-control" type="text" data-ng-model="quickAdd.title[lane.id]" placeholder="Quick Add Item Title - Leave Blank for Dialog">
<a role="button" class="btn btn-default fa fa-plus form-control" data-toggle="modal"
data-target=".itemModal" data-ng-click="itemFormData.reset(lane.id)" title="Add Item"></a>
</div>
<span data-on-load-callback="updateSortables"></span>

View File

@ -8,7 +8,8 @@
<span aria-hidden="true" class="fa fa-times"></span>
<span class="sr-only">Close</span>
</button>
<h3 class="modal-title" id="itemViewLabel">{{ viewItem.title }}
<h3 class="modal-title" id="itemViewLabel">
<span data-ng-bind-html="marked(viewItem.title)"></span>
<span data-ng-if="viewItem.points"> - {{ viewItem.points }}</span>
</h3>
</div>

View File

@ -44,23 +44,85 @@
<h5>Categories</h5>
<ul class="list-group editable">
<li class="list-group-item small" data-ng-class="{ disabled: boardFormData.isSaving }"
data-ng-repeat="category in boardFormData.categories | orderBy:'category':false">
data-ng-repeat="category in boardFormData.categories | orderBy:'category':false"
style="background-color: {{ category.color }}">
<span class="item-text">{{ category.name }}</span>
<span class="links">
<a class="fa fa-trash-o pull-right" title="Remove"
data-ng-click="boardFormData.removeCategory(category)"></a>
<span data-click-to-edit="category.name"
data-ng-click="editColor(category)"
data-ng-keydown="storeColor($event)"
data-ng-disabled="boardFormData.isSaving"></span>
</span>
</li>
</ul>
<input class="form-control wide" type="text" placeholder="Category Name"
<input class="form-control half-width" style="width: 85%;" type="text" placeholder="Category Name"
data-ng-model="boardFormData.categoryName" data-ng-disabled="boardFormData.isSaving">
<input class="form-control half-width" type="text" id="spectrum" data-ng-model="boardFormData.color"
data-on-load-callback="spectrum">
<button type="submit" id="modalAddCategory" class="btn btn-default fa fa-plus"
data-ng-disabled="boardFormData.isSaving"></button>
</form>
</div>
<div class="clearfix"></div>
<div class="form-group short-top" data-ng-class="{ 'has-error': boardFormData.trackersError }">
<form role="form" class="form form-inline" data-ng-submit="boardFormData.addTracker()">
<h5>Issue Trackers</h5>
<p class="small clearfix short-top" data-ng-if="!boardFormData.trackers.length">
<em>
Idea based on <a href="https://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-bugtracker.html">TortoiseSVN bugtracker</a>.<br/>
The %BUGID% can have a format of %BUGID\[1-9]% to further specify which group from Bug-ID regular expression is used (whole match is used as a default).<br/><br/>
Example URL: https://github.com/kiswa/TaskBoard/issues/%BUGID\1%<br/>
Example Bug-ID: (?:Issue)?#(\d+)<br/>
Replaces all Bug-ID matched strings within all board's items with hyperlinks to the Issue Tracker's issue.<br/>
#1 -> <a href="https://github.com/kiswa/TaskBoard/issues/1">#1</a> (link to https://github.com/kiswa/TaskBoard/issues/1)<br/>
Issue#2 -> <a href="https://github.com/kiswa/TaskBoard/issues/2">Issue#2</a> (link to https://github.com/kiswa/TaskBoard/issues/2)
</em>
</p>
<ul class="list-group editable">
<li class="list-group-item small" data-ng-class="{ disabled: boardFormData.isSaving }"
data-ng-repeat="tracker in boardFormData.trackers | orderBy:'tracker':false">
<table style="width: 100%;table-layout:fixed;">
<tr>
<td style="width:70%;padding:0px 15px 0px 15px;">
<span class="item-text">{{ tracker.name }}</span>
<span class="links">
<span data-click-to-edit="tracker.name"
data-ng-disabled="boardFormData.isSaving"></span>
</span>
</td>
<td style="padding:0px 15px 0px 15px;border-left: 1px solid lightgray;">
<span class="item-text">{{ tracker.bugexpr }}</span>
<span class="links">
<span data-click-to-edit="tracker.bugexpr"
data-ng-disabled="boardFormData.isSaving"></span>
</span>
</td>
<td style="width:25px;padding:0px 5px 0px 5px;border-left: 1px solid lightgray;">
<span class="links">
<a class="fa fa-trash-o pull-right" title="Remove"
data-ng-click="boardFormData.removeTracker(tracker)"></a>
</span>
</td>
</tr>
</table>
</li>
</ul>
<input class="form-control half-width" style="width: 70%;" type="text" placeholder="Issue Tracker URL. Use %BUGID% as placeholder"
title="Idea based on [https://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-bugtracker.html].
The %BUGID% can have a format of %BUGID\[1-9]% to specify which group from BUG-ID regular expression is used (whole match is used as a default).
Example: https://github.com/kiswa/TaskBoard/issues/%BUGID\1%."
data-ng-model="boardFormData.trackerName" data-ng-disabled="boardFormData.isSaving">
<input class="form-control wide" style="width: 25%;" type="text" placeholder="Bug-ID expression"
title="Regular expression to be replaced by Issue Tracker url within the item text.
Example: (?:Issue)?#(\d+)"
data-ng-model="boardFormData.bugexpr" data-ng-disabled="boardFormData.isSaving">
<button type="submit" id="modalAddTracker" class="btn btn-default fa fa-plus"
data-ng-disabled="boardFormData.isSaving"></button>
</form>
</div>
<div class="clearfix"></div>
<div class="form-group short-top">
<h5>Select Users</h5>
<div class="half-width" data-ng-repeat="user in users">

View File

@ -43,7 +43,7 @@
</td>
<td>
<ul class="list-group">
<li class="list-group-item" data-ng-repeat="category in board.ownCategory | orderBy:'name':false">{{ category.name }}</li>
<li class="list-group-item" data-ng-repeat="category in board.ownCategory | orderBy:'name':false" style="background-color:{{ category.color }}">{{ category.name }}</li>
</ul>
</td>
<td>