Board display work - pull tasks out to own component
This commit is contained in:
parent
efd366b265
commit
b5fc471f61
@ -47,6 +47,7 @@ class Boards extends BaseController {
|
||||
return $this->jsonResponse($response, 403);
|
||||
}
|
||||
|
||||
$this->cleanBoard($board);
|
||||
$this->apiJson->setSuccess();
|
||||
$this->apiJson->addData(R::exportAll($board));
|
||||
|
||||
@ -192,10 +193,7 @@ class Boards extends BaseController {
|
||||
if (count($boardBeans)) {
|
||||
foreach ($boardBeans as $bean) {
|
||||
if (Auth::HasBoardAccess($request, $bean->id)) {
|
||||
foreach ($bean->sharedUserList as $user) {
|
||||
$user = $this->cleanUser($user);
|
||||
}
|
||||
|
||||
$this->cleanBoard($bean);
|
||||
$boards[] = $bean;
|
||||
}
|
||||
}
|
||||
@ -204,6 +202,20 @@ class Boards extends BaseController {
|
||||
return R::exportAll($boards);
|
||||
}
|
||||
|
||||
private function cleanBoard(&$board) {
|
||||
foreach ($board->sharedUserList as $user) {
|
||||
$user = $this->cleanUser($user);
|
||||
}
|
||||
|
||||
foreach ($board->xownColumnList as $column) {
|
||||
foreach ($column->xownTaskList as $task) {
|
||||
foreach ($task->sharedUserList as $user) {
|
||||
$user = $this->cleanUser($user);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function cleanUser($user) {
|
||||
unset($user->password_hash);
|
||||
unset($user->active_token);
|
||||
|
@ -66,6 +66,7 @@ class Tasks extends BaseController {
|
||||
$this->apiJson->setSuccess();
|
||||
$this->apiJson->addAlert('success', 'Task ' .
|
||||
$task->title . ' added.');
|
||||
$this->apiJson->addData(R::exportAll($task));
|
||||
|
||||
return $this->jsonResponse($response);
|
||||
}
|
||||
|
@ -45,20 +45,24 @@ class BeanLoader {
|
||||
$board->name = isset($data->name) ? $data->name : '';
|
||||
$board->is_active = isset($data->is_active) ? $data->is_active : '';
|
||||
|
||||
if (isset($data->categories)) {
|
||||
self::updateObjectList('category', 'LoadCategory',
|
||||
$board->xownCategoryList, $data->categories);
|
||||
}
|
||||
try {
|
||||
if (isset($data->categories)) {
|
||||
self::updateObjectList('category', 'LoadCategory',
|
||||
$board->xownCategoryList, $data->categories);
|
||||
}
|
||||
|
||||
if (isset($data->columns)) {
|
||||
self::updateObjectList('column', 'LoadColumn',
|
||||
$board->xownColumnList, $data->columns);
|
||||
}
|
||||
if (isset($data->issue_trackers)) {
|
||||
self::updateObjectList('issuetracker', 'LoadIssueTracker',
|
||||
$board->xownIssueTrackerList,
|
||||
$data->issue_trackers);
|
||||
}
|
||||
|
||||
if (isset($data->issue_trackers)) {
|
||||
self::updateObjectList('issuetracker', 'LoadIssueTracker',
|
||||
$board->xownIssueTrackerList,
|
||||
$data->issue_trackers);
|
||||
if (isset($data->columns)) {
|
||||
self::updateObjectList('column', 'LoadColumn',
|
||||
$board->xownColumnList, $data->columns);
|
||||
}
|
||||
} catch(Exception $ex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Users do not get deleted when removed from a board
|
||||
@ -68,7 +72,7 @@ class BeanLoader {
|
||||
foreach ($data->users as $userData) {
|
||||
$user = R::load('user', $userData->id);
|
||||
|
||||
if ((int)$user->id > 0) {
|
||||
if ((int)$user->id) {
|
||||
$board->sharedUserList[] = $user;
|
||||
}
|
||||
}
|
||||
@ -163,22 +167,36 @@ class BeanLoader {
|
||||
|
||||
if (isset($data->comments)) {
|
||||
self::updateObjectList('comment', 'LoadComment',
|
||||
$column->xownCommentList, $data->comments);
|
||||
$task->xownCommentList, $data->comments);
|
||||
}
|
||||
|
||||
if (isset($data->attachments)) {
|
||||
self::updateObjectList('attachment', 'LoadAttachment',
|
||||
$column->xownAttachmentList, $data->attachments);
|
||||
$task->xownAttachmentList, $data->attachments);
|
||||
}
|
||||
|
||||
if (isset($data->assignees)) {
|
||||
self::updateObjectList('user', 'LoadUser',
|
||||
$column->xownAssigneeList, $data->assignees);
|
||||
$task->sharedUserList = [];
|
||||
|
||||
foreach ($data->assignees as $assignee) {
|
||||
$user = R::load('user', $assignee->id);
|
||||
|
||||
if((int) $user->id) {
|
||||
$task->sharedUserList[] = $user;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data->categories)) {
|
||||
self::updateObjectList('category', 'LoadCategory',
|
||||
$column->xownCategoryList, $data->categories);
|
||||
$task->sharedCategoryList = [];
|
||||
|
||||
foreach ($data->categories as $category) {
|
||||
$cat = R::load('category', $category->id);
|
||||
|
||||
if ((int)$cat->id) {
|
||||
$task->sharedCategoryList[] = $cat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($data->title) || !isset($data->position) ||
|
||||
|
@ -4,7 +4,8 @@ import { AuthGuard } from './shared/index';
|
||||
import { Login } from './login/login.component';
|
||||
import {
|
||||
BoardDisplay,
|
||||
ColumnDisplay
|
||||
ColumnDisplay,
|
||||
TaskDisplay
|
||||
} from './board/index';
|
||||
import {
|
||||
Settings,
|
||||
@ -49,6 +50,7 @@ export const ROUTE_COMPONENTS = [
|
||||
Calendar,
|
||||
Charts,
|
||||
ColumnDisplay,
|
||||
TaskDisplay,
|
||||
Dashboard,
|
||||
Login,
|
||||
Settings,
|
||||
|
@ -11,7 +11,7 @@
|
||||
{{ columnData.name }}
|
||||
|
||||
<span class="badge" title="Tasks in Column">
|
||||
{{ tasks.length }}
|
||||
{{ columnData.ownTask.length }}
|
||||
</span>
|
||||
|
||||
<span class="icon icon-angle-double-up"
|
||||
@ -28,48 +28,14 @@
|
||||
</div>
|
||||
|
||||
<div class="tasks">
|
||||
<div class="task" [ngClass]="{ 'compact': collapseTasks }">
|
||||
<h4>
|
||||
<span class="icon"
|
||||
[ngClass]="{ 'icon-minus-squared-alt': !collapseTasks,
|
||||
'icon-plus-squared-alt': collapseTasks }"
|
||||
title="Collapse Task"></span>
|
||||
Column Data
|
||||
<span class="badge right" title="Points">1</span>
|
||||
</h4>
|
||||
<div class="description">
|
||||
<pre style="margin: 0">{{ columnData | json }}</pre>
|
||||
</div>
|
||||
<div class="stats">
|
||||
Assigned To: admin
|
||||
<span class="right">
|
||||
<span class="icon icon-chat-empty" title="4 Comments"></span>
|
||||
<span class="icon icon-attach" title="2 Attachments"></span>
|
||||
<span class="category" title="Category">Front End</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="task" [ngClass]="{ 'compact': collapseTasks }">
|
||||
<h4>
|
||||
<span class="icon"
|
||||
[ngClass]="{ 'icon-minus-squared-alt': !collapseTasks,
|
||||
'icon-plus-squared-alt': collapseTasks }"
|
||||
title="Collapse Task"></span>
|
||||
Something to Get Done
|
||||
<span class="badge right" title="Points">3</span>
|
||||
</h4>
|
||||
<div class="description">
|
||||
<p>This is the thing that needs to get done.</p>
|
||||
</div>
|
||||
<div class="stats">
|
||||
Assigned To: admin
|
||||
<span class="right">
|
||||
<span class="icon icon-chat-empty" title="4 Comments"></span>
|
||||
<span class="icon icon-attach" title="2 Attachments"></span>
|
||||
<span class="category" title="Category"></span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<tb-task *ngFor="let task of columnData.ownTask"
|
||||
class="task"
|
||||
[task]="task"></tb-task>
|
||||
<!--<div *ngFor="let task of columnData.ownTask"-->
|
||||
<!-- class="task" [ngClass]="{ 'compact': collapseTasks }"-->
|
||||
<!-- [style.backgroundColor]="task.color"-->
|
||||
<!-- [style.color]="getTextColor(task.color)">-->
|
||||
<!--</div>-->
|
||||
</div>
|
||||
|
||||
<!--<tb-modal modal-title="Confirm Task Removal" blocking="true">-->
|
||||
|
@ -38,7 +38,6 @@ export class ColumnDisplay implements OnInit {
|
||||
private modalProps: Task;
|
||||
|
||||
@Input('column') columnData: Column;
|
||||
@Input('show-add-modal') showAddModal: any;
|
||||
|
||||
constructor(private elRef: ElementRef,
|
||||
private auth: AuthService,
|
||||
|
@ -1,3 +1,4 @@
|
||||
export * from './column/column.component';
|
||||
export * from './board.component';
|
||||
export * from './task/task.component';
|
||||
|
||||
|
44
src/app/board/task/task.component.html
Normal file
44
src/app/board/task/task.component.html
Normal file
@ -0,0 +1,44 @@
|
||||
<div [style.backgroundColor]="taskData.color"
|
||||
[style.color]="getTextColor(taskData.color)">
|
||||
<h4>
|
||||
<span class="icon"
|
||||
[style.color]="getTextColor(taskData.color)"
|
||||
[ngClass]="{ 'icon-minus-squared-alt': !collapseTasks,
|
||||
'icon-plus-squared-alt': collapseTasks }"
|
||||
title="Collapse Task"></span>
|
||||
{{ taskData.title }}
|
||||
<span *ngIf="taskData.points > 0" class="badge right" title="Points">
|
||||
{{ taskData.points }}</span>
|
||||
</h4>
|
||||
<div class="description">
|
||||
{{ taskData.description }}
|
||||
</div>
|
||||
<div class="hidden">
|
||||
<pre>{{ taskData | json }}</pre>
|
||||
</div>
|
||||
<div class="stats">
|
||||
<span *ngIf="userOptions.show_assignee">
|
||||
Assigned To:
|
||||
<span *ngFor="let assignee of taskData.sharedUser">
|
||||
{{ assignee.username }}
|
||||
</span>
|
||||
<span *ngIf="!taskData.sharedUser || !taskData.sharedUser.length">
|
||||
Unassigned
|
||||
</span>
|
||||
</span>
|
||||
<span class="right">
|
||||
<span *ngIf="taskData.due_date">
|
||||
Due: {{ taskData.due_date }}
|
||||
</span>
|
||||
<span *ngIf="taskData.comments" class="icon icon-chat-empty"
|
||||
title="{{ taskData.comments.length }} Comments"></span>
|
||||
<span *ngIf="taskData.attachments" class="icon icon-attach"
|
||||
title="{{ taskData.attachments.length }} Attachments"></span>
|
||||
<span *ngFor="let category of taskData.sharedCategory"
|
||||
class="category" title="Category">
|
||||
{{ category.name }}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
34
src/app/board/task/task.component.ts
Normal file
34
src/app/board/task/task.component.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
|
||||
import {
|
||||
Task,
|
||||
UserOptions,
|
||||
AuthService
|
||||
} from '../../shared/index';
|
||||
|
||||
@Component({
|
||||
selector: 'tb-task',
|
||||
templateUrl: 'app/board/task/task.component.html'
|
||||
})
|
||||
export class TaskDisplay {
|
||||
private userOptions: UserOptions;
|
||||
|
||||
@Input('task') taskData: Task;
|
||||
|
||||
constructor(auth: AuthService) {
|
||||
auth.userChanged.subscribe(() => {
|
||||
this.userOptions = auth.userOptions;
|
||||
});
|
||||
}
|
||||
|
||||
// Expects a color in full HEX with leading #, e.g. #ffffe0
|
||||
getTextColor(color: string): string {
|
||||
let r = parseInt(color.substr(1, 2), 16),
|
||||
g = parseInt(color.substr(3, 2), 16),
|
||||
b = parseInt(color.substr(5, 2), 16),
|
||||
yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000;
|
||||
|
||||
return yiq >= 130 ? '#333333' : '#efefef';
|
||||
}
|
||||
}
|
||||
|
@ -210,6 +210,7 @@ class BoardsTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
$board = $this->getBoardData();
|
||||
$board->id = 3;
|
||||
unset($board->columns[0]->board_id);
|
||||
unset($board->categories[0]->board_id);
|
||||
unset($board->issue_trackers[0]->board_id);
|
||||
|
||||
@ -351,10 +352,19 @@ class BoardsTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
private function createBoard() {
|
||||
$board = R::dispense('board');
|
||||
$column = R::dispense('column');
|
||||
$task = R::dispense('task');
|
||||
|
||||
$task->sharedUserList[] = R::load('user', 1);
|
||||
|
||||
$column->name = 'test';
|
||||
$column->position = 0;
|
||||
$column->xownTaskList[] = $task;
|
||||
|
||||
$board->name = 'test';
|
||||
$board->is_active = true;
|
||||
$board->sharedUserList[] = R::load('user', 1);
|
||||
$board->xownColumnList[] = $column;
|
||||
|
||||
R::store($board);
|
||||
}
|
||||
|
@ -76,6 +76,14 @@ class TasksTest extends PHPUnit_Framework_TestCase {
|
||||
$this->createTask();
|
||||
$data = $this->getTaskData();
|
||||
|
||||
$assignee = R::load('user', 1);
|
||||
$data->assignees[] = $assignee;
|
||||
|
||||
$category = R::load('category', 1);
|
||||
$category->name = 'Front End';
|
||||
R::store($category);
|
||||
$data->categories[] = $category;
|
||||
|
||||
$request = new RequestMock();
|
||||
$request->header = [DataMock::GetJwt()];
|
||||
$request->payload = $data;
|
||||
|
Reference in New Issue
Block a user