diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-04-11 16:26:45 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-04-11 16:26:45 -0400 |
commit | d3727e92a6000a01fb962e559f8e6b936def1fb9 (patch) | |
tree | 23a12c7c7db5644f0a938eb0d4bed2c81d811a61 | |
parent | 52bc2efc65af690b075d58dcff23eac97d1a0495 (diff) |
Add category description (merge and modify pull-request #692)
-rw-r--r-- | app/Controller/Board.php | 20 | ||||
-rw-r--r-- | app/Model/Category.php | 32 | ||||
-rw-r--r-- | app/Schema/Mysql.php | 7 | ||||
-rw-r--r-- | app/Schema/Postgres.php | 7 | ||||
-rw-r--r-- | app/Schema/Sqlite.php | 7 | ||||
-rw-r--r-- | app/Template/board/index.php | 5 | ||||
-rw-r--r-- | app/Template/board/public.php | 3 | ||||
-rw-r--r-- | app/Template/board/show.php | 3 | ||||
-rw-r--r-- | app/Template/board/swimlane.php | 3 | ||||
-rw-r--r-- | app/Template/board/task_footer.php | 24 | ||||
-rw-r--r-- | app/Template/board/task_private.php | 7 | ||||
-rw-r--r-- | app/Template/board/task_public.php | 7 | ||||
-rw-r--r-- | app/Template/category/edit.php | 20 |
13 files changed, 121 insertions, 24 deletions
diff --git a/app/Controller/Board.php b/app/Controller/Board.php index fa22226e..47248fa2 100644 --- a/app/Controller/Board.php +++ b/app/Controller/Board.php @@ -121,11 +121,14 @@ class Board extends Base $this->forbidden(true); } + list($categories_listing, $categories_description) = $this->category->getBoardCategories($project['id']); + // Display the board with a specific layout $this->response->html($this->template->layout('board/public', array( 'project' => $project, 'swimlanes' => $this->board->getBoard($project['id']), - 'categories' => $this->category->getList($project['id'], false), + 'categories_listing' => $categories_listing, + 'categories_description' => $categories_description, 'title' => $project['name'], 'description' => $project['description'], 'no_layout' => true, @@ -181,12 +184,15 @@ class Board extends Base $this->userSession->storeLastSeenProjectId($project['id']); + list($categories_listing, $categories_description) = $this->category->getBoardCategories($project['id']); + $this->response->html($this->template->layout('board/index', array( 'users' => $this->projectPermission->getMemberList($project['id'], true, true), 'projects' => $projects, 'project' => $project, 'swimlanes' => $this->board->getBoard($project['id']), - 'categories' => $this->category->getList($project['id'], true, true), + 'categories_listing' => $categories_listing, + 'categories_description' => $categories_description, 'title' => $project['name'], 'description' => $project['description'], 'board_selector' => $board_selector, @@ -358,11 +364,14 @@ class Board extends Base return $this->response->status(400); } + list($categories_listing, $categories_description) = $this->category->getBoardCategories($project_id); + $this->response->html( $this->template->render('board/show', array( 'project' => $this->project->getById($project_id), 'swimlanes' => $this->board->getBoard($project_id), - 'categories' => $this->category->getList($project_id, false), + 'categories_listing' => $categories_listing, + 'categories_description' => $categories_description, 'board_private_refresh_interval' => $this->config->get('board_private_refresh_interval'), 'board_highlight_period' => $this->config->get('board_highlight_period'), )), @@ -392,11 +401,14 @@ class Board extends Base return $this->response->status(304); } + list($categories_listing, $categories_description) = $this->category->getBoardCategories($project_id); + $this->response->html( $this->template->render('board/show', array( 'project' => $this->project->getById($project_id), 'swimlanes' => $this->board->getBoard($project_id), - 'categories' => $this->category->getList($project_id, false), + 'categories_listing' => $categories_listing, + 'categories_description' => $categories_description, 'board_private_refresh_interval' => $this->config->get('board_private_refresh_interval'), 'board_highlight_period' => $this->config->get('board_highlight_period'), )) diff --git a/app/Model/Category.php b/app/Model/Category.php index 1c8ba96f..c8ba7251 100644 --- a/app/Model/Category.php +++ b/app/Model/Category.php @@ -74,6 +74,38 @@ class Category extends Base } /** + * Prepare categories to be displayed on the board + * + * @access public + * @param integer $project_id + * @return array + */ + public function getBoardCategories($project_id) + { + $descriptions = array(); + + $listing = array( + -1 => t('All categories'), + 0 => t('No category'), + ); + + $categories = $this->db->table(self::TABLE) + ->eq('project_id', $project_id) + ->asc('name') + ->findAll(); + + foreach ($categories as $category) { + $listing[$category['id']] = $category['name']; + $descriptions[$category['id']] = $category['description']; + } + + return array( + $listing, + $descriptions, + ); + } + + /** * Return the list of all categories * * @access public diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php index 91e744a4..c2bfc97a 100644 --- a/app/Schema/Mysql.php +++ b/app/Schema/Mysql.php @@ -6,7 +6,12 @@ use PDO; use Core\Security; use Model\Link; -const VERSION = 62; +const VERSION = 63; + +function version_63($pdo) +{ + $pdo->exec('ALTER TABLE project_has_categories ADD COLUMN description TEXT'); +} function version_62($pdo) { diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php index 0c4c4829..80f29219 100644 --- a/app/Schema/Postgres.php +++ b/app/Schema/Postgres.php @@ -6,7 +6,12 @@ use PDO; use Core\Security; use Model\Link; -const VERSION = 43; +const VERSION = 44; + +function version_44($pdo) +{ + $pdo->exec('ALTER TABLE project_has_categories ADD COLUMN description TEXT'); +} function version_43($pdo) { diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php index 4ea1f875..d244cd89 100644 --- a/app/Schema/Sqlite.php +++ b/app/Schema/Sqlite.php @@ -6,7 +6,12 @@ use Core\Security; use PDO; use Model\Link; -const VERSION = 61; +const VERSION = 62; + +function version_62($pdo) +{ + $pdo->exec('ALTER TABLE project_has_categories ADD COLUMN description TEXT'); +} function version_61($pdo) { diff --git a/app/Template/board/index.php b/app/Template/board/index.php index 78537085..f87e0077 100644 --- a/app/Template/board/index.php +++ b/app/Template/board/index.php @@ -1,7 +1,7 @@ <section id="main"> <?= $this->render('board/filters', array( - 'categories' => $categories, + 'categories' => $categories_listing, 'users' => $users, 'project' => $project, )) ?> @@ -9,7 +9,8 @@ <?= $this->render('board/show', array( 'project' => $project, 'swimlanes' => $swimlanes, - 'categories' => $categories, + 'categories_listing' => $categories_listing, + 'categories_description' => $categories_description, 'board_private_refresh_interval' => $board_private_refresh_interval, 'board_highlight_period' => $board_highlight_period, )) ?> diff --git a/app/Template/board/public.php b/app/Template/board/public.php index 8eb6415d..9e5360ce 100644 --- a/app/Template/board/public.php +++ b/app/Template/board/public.php @@ -3,7 +3,8 @@ <?= $this->render('board/show', array( 'project' => $project, 'swimlanes' => $swimlanes, - 'categories' => $categories, + 'categories_listing' => $categories_listing, + 'categories_description' => $categories_description, 'board_private_refresh_interval' => $board_private_refresh_interval, 'board_highlight_period' => $board_highlight_period, 'not_editable' => true, diff --git a/app/Template/board/show.php b/app/Template/board/show.php index 6f81fe2e..8ee7861b 100644 --- a/app/Template/board/show.php +++ b/app/Template/board/show.php @@ -21,7 +21,8 @@ 'project' => $project, 'swimlane' => $swimlane, 'board_highlight_period' => $board_highlight_period, - 'categories' => $categories, + 'categories_listing' => $categories_listing, + 'categories_description' => $categories_description, 'hide_swimlane' => count($swimlanes) === 1, 'not_editable' => isset($not_editable), )) ?> diff --git a/app/Template/board/swimlane.php b/app/Template/board/swimlane.php index b73febb6..8bcd9542 100644 --- a/app/Template/board/swimlane.php +++ b/app/Template/board/swimlane.php @@ -74,7 +74,8 @@ <?= $this->render($not_editable ? 'board/task_public' : 'board/task_private', array( 'project' => $project, 'task' => $task, - 'categories' => $categories, + 'categories_listing' => $categories_listing, + 'categories_description' => $categories_description, 'board_highlight_period' => $board_highlight_period, 'not_editable' => $not_editable, )) ?> diff --git a/app/Template/board/task_footer.php b/app/Template/board/task_footer.php index 635ed31f..36ed2684 100644 --- a/app/Template/board/task_footer.php +++ b/app/Template/board/task_footer.php @@ -1,15 +1,19 @@ -<?php if ($task['category_id']): ?> +<?php if (! empty($task['category_id'])): ?> <div class="task-board-category-container"> <span class="task-board-category"> - <?= $this->a( - $this->inList($task['category_id'], $categories), - 'board', - 'changeCategory', - array('task_id' => $task['id'], 'project_id' => $task['project_id']), - false, - 'task-board-popover', - t('Change category') - ) ?> + <?php if ($not_editable): ?> + <?= $this->inList($task['category_id'], $categories_listing) ?> + <?php else: ?> + <?= $this->a( + $this->inList($task['category_id'], $categories_listing), + 'board', + 'changeCategory', + array('task_id' => $task['id'], 'project_id' => $task['project_id']), + false, + 'task-board-popover' . (isset($categories_description[$task['category_id']]) ? ' column-tooltip' : ''), + isset($categories_description[$task['category_id']]) ? $this->markdown($categories_description[$task['category_id']]) : t('Change category') + ) ?> + <?php endif ?> </span> </div> <?php endif ?> diff --git a/app/Template/board/task_private.php b/app/Template/board/task_private.php index 9e7358f0..d82b96e8 100644 --- a/app/Template/board/task_private.php +++ b/app/Template/board/task_private.php @@ -40,6 +40,11 @@ <?= $this->a($this->e($task['title']), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, '', t('View this task')) ?> </div> - <?= $this->render('board/task_footer', array('task' => $task, 'categories' => $categories)) ?> + <?= $this->render('board/task_footer', array( + 'task' => $task, + 'categories_listing' => $categories_listing, + 'categories_description' => $categories_description, + 'not_editable' => $not_editable, + )) ?> </div> </div> diff --git a/app/Template/board/task_public.php b/app/Template/board/task_public.php index 4e3ad18c..1ab2b3aa 100644 --- a/app/Template/board/task_public.php +++ b/app/Template/board/task_public.php @@ -22,5 +22,10 @@ <?= $this->a($this->e($task['title']), 'task', 'readonly', array('task_id' => $task['id'], 'token' => $project['token'])) ?> </div> - <?= $this->render('board/task_footer', array('task' => $task, 'categories' => $categories)) ?> + <?= $this->render('board/task_footer', array( + 'task' => $task, + 'categories_listing' => $categories_listing, + 'categories_description' => $categories_description, + 'not_editable' => $not_editable, + )) ?> </div>
\ No newline at end of file diff --git a/app/Template/category/edit.php b/app/Template/category/edit.php index 46d47782..0d4b0f6f 100644 --- a/app/Template/category/edit.php +++ b/app/Template/category/edit.php @@ -12,6 +12,26 @@ <?= $this->formLabel(t('Category Name'), 'name') ?> <?= $this->formText('name', $values, $errors, array('autofocus', 'required', 'maxlength="50"')) ?> + <?= $this->formLabel(t('Description'), 'description') ?> + + <div class="form-tabs"> + <div class="write-area"> + <?= $this->formTextarea('description', $values, $errors) ?> + </div> + <div class="preview-area"> + <div class="markdown"></div> + </div> + <ul class="form-tabs-nav"> + <li class="form-tab form-tab-selected"> + <i class="fa fa-pencil-square-o fa-fw"></i><a id="markdown-write" href="#"><?= t('Write') ?></a> + </li> + <li class="form-tab"> + <a id="markdown-preview" href="#"><i class="fa fa-eye fa-fw"></i><?= t('Preview') ?></a> + </li> + </ul> + </div> + <div class="form-help"><a href="http://kanboard.net/documentation/syntax-guide" target="_blank" rel="noreferrer"><?= t('Write your text in Markdown') ?></a></div> + <div class="form-actions"> <input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/> </div> |