fix reporter tpl form, task display

This commit is contained in:
Dennis Eichhorn 2018-10-27 20:42:24 +02:00
parent d18adb0b90
commit ece1f87d95
9 changed files with 84 additions and 9 deletions

View File

@ -114,6 +114,7 @@ class Installer extends InstallerAbstract
`task_element_task` int(11) NOT NULL,
`task_element_created_by` int(11) NOT NULL,
`task_element_status` tinyint(1) NOT NULL,
`task_element_priority` tinyint(1) NOT NULL,
`task_element_due` datetime NOT NULL,
`task_element_forwarded` int(11) DEFAULT NULL,
`task_element_created_at` datetime NOT NULL,

View File

@ -92,7 +92,12 @@ class ApiController extends Controller
$task = $this->createTaskFromRequest($request);
TaskMapper::create($task);
$response->set($request->getUri()->__toString(), $task->jsonSerialize());
$response->set($request->getUri()->__toString(), [
'status' => NotificationLevel::OK,
'title' => 'Task',
'message' => 'Task successfully created.',
'response' => $task->jsonSerialize()
]);
}
/**
@ -114,12 +119,13 @@ class ApiController extends Controller
$task->setDue(new \DateTime((string) ($request->getData('due') ?? 'now')));
$task->setStatus(TaskStatus::OPEN);
$task->setType(TaskType::SINGLE);
$task->setPriority(TaskPriority::NONE);
$task->setPriority((int) $request->getData('priority'));
$element = new TaskElement();
$element->setForwarded((int) ($request->getData('forward') ?? $request->getHeader()->getAccount()));
$element->setCreatedBy($task->getCreatedBy());
$element->setDue($task->getDue());
$element->setPriority($task->getPriority());
$element->setStatus(TaskStatus::OPEN);
$task->addElement($element);

View File

@ -146,7 +146,7 @@ class Task implements \JsonSerializable
* @var int
* @since 1.0.0
*/
protected $priority = TaskPriority::MEDIUM;
protected $priority = TaskPriority::NONE;
/**
* Media files

View File

@ -91,6 +91,14 @@ class TaskElement implements \JsonSerializable
*/
private $due = null;
/**
* Priority
*
* @var int
* @since 1.0.0
*/
protected $priority = TaskPriority::NONE;
/**
* Forwarded to.
*
@ -260,6 +268,38 @@ class TaskElement implements \JsonSerializable
$this->due = $due;
}
/**
* Get priority
*
* @return int
*
* @since 1.0.0
*/
public function getPriority() : int
{
return $this->priority;
}
/**
* Set priority
*
* @param int $priority Task priority
*
* @return void
*
* @throws InvalidEnumValue
*
* @since 1.0.0
*/
public function setPriority(int $priority) : void
{
if (!TaskPriority::isValidValue($priority)) {
throw new InvalidEnumValue((string) $priority);
}
$this->priority = $priority;
}
/**
* Get forwarded
*

View File

@ -41,6 +41,7 @@ class TaskElementMapper extends DataMapperAbstract
'task_element_desc' => ['name' => 'task_element_desc', 'type' => 'string', 'internal' => 'description'],
'task_element_desc_raw' => ['name' => 'task_element_desc_raw', 'type' => 'string', 'internal' => 'descriptionRaw'],
'task_element_status' => ['name' => 'task_element_status', 'type' => 'int', 'internal' => 'status'],
'task_element_priority' => ['name' => 'task_element_priority', 'type' => 'int', 'internal' => 'priority'],
'task_element_due' => ['name' => 'task_element_due', 'type' => 'DateTime', 'internal' => 'due'],
'task_element_forwarded' => ['name' => 'task_element_forwarded', 'type' => 'int', 'internal' => 'forwarded'],
'task_element_task' => ['name' => 'task_element_task', 'type' => 'int', 'internal' => 'task'],

View File

@ -2,7 +2,7 @@
<caption><?= $this->getHtml('Tasks', 'Tasks') ?></caption>
<thead>
<td><?= $this->getHtml('Status', 'Tasks') ?>
<td><?= $this->getHtml('Due', 'Tasks') ?>
<td><?= $this->getHtml('Due/Priority', 'Tasks') ?>
<td class="full"><?= $this->getHtml('Title', 'Tasks') ?>
<tfoot>
<tbody>
@ -16,7 +16,13 @@
elseif ($task->getStatus() === \Modules\Tasks\Models\TaskStatus::SUSPENDED) { $color = 'yellow'; } ;?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><span class="tag <?= $this->printHtml($color); ?>"><?= $this->getHtml('S' . $task->getStatus(), 'Tasks') ?></span></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($task->getDue()->format('Y-m-d H:i')); ?></a>
<td><a href="<?= $url; ?>">
<?php if ($task->getPriority() === \Modules\Tasks\Models\TaskPriority::NONE) : ?>
<?= $this->printHtml($task->getDue()->format('Y-m-d H:i')); ?>
<?php else : ?>
<?= $this->getHtml('P' . $task->getPriority()); ?>
<?php endif; ?>
</a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($task->getTitle()); ?></a>
<?php endforeach; if ($c == 0) : ?>
<tr><td colspan="6" class="empty"><?= $this->getHtml('Empty', 0, 0); ?>

View File

@ -22,6 +22,7 @@ return ['Tasks' => [
'Default' => 'Default',
'Day' => 'Day',
'Due' => 'Due',
'Due/Priority' => 'Due/Priority',
'Forward' => 'Forward',
'Forwarded' => 'Forwarded',
'From' => 'From',

View File

@ -27,7 +27,7 @@ echo $this->getData('nav')->render(); ?>
<caption><?= $this->getHtml('Tasks') ?></caption>
<thead>
<td><?= $this->getHtml('Status') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Due') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Due/Priority') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td class="full"><?= $this->getHtml('Title') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Creator') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Created') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
@ -43,7 +43,14 @@ echo $this->getData('nav')->render(); ?>
elseif ($task->getStatus() === TaskStatus::SUSPENDED) { $color = 'yellow'; } ?>
<tr data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('Status') ?>"><a href="<?= $url; ?>"><span class="tag <?= $this->printHtml($color); ?>"><?= $this->getHtml('S' . $task->getStatus()) ?></span></a>
<td data-label="<?= $this->getHtml('Due') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($task->getDue()->format('Y-m-d H:i')); ?></a>
<td data-label="<?= $this->getHtml('Due/Priority') ?>">
<a href="<?= $url; ?>">
<?php if ($task->getPriority() === \Modules\Tasks\Models\TaskPriority::NONE) : ?>
<?= $this->printHtml($task->getDue()->format('Y-m-d H:i')); ?>
<?php else : ?>
<?= $this->getHtml('P' . $task->getPriority()); ?>
<?php endif; ?>
</a>
<td data-label="<?= $this->getHtml('Title') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($task->getTitle()); ?></a>
<td data-label="<?= $this->getHtml('Creator') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($task->getCreatedBy()->getName1()); ?></a>
<td data-label="<?= $this->getHtml('Created') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($task->getCreatedAt()->format('Y-m-d H:i')); ?></a>

View File

@ -12,6 +12,7 @@
*/
use \Modules\Tasks\Models\TaskStatus;
use \Modules\Tasks\Models\TaskPriority;
/**
* @var \phpOMS\Views\View $this
@ -30,7 +31,13 @@ echo $this->getData('nav')->render(); ?>
<div class="col-xs-12">
<section class="box wf-100">
<div class="inner">
<div class="floatRight">Due <?= $this->printHtml($task->getDue()->format('Y/m/d H:i')); ?></div>
<div class="floatRight">
<?php if ($task->getPriority() === TaskPriority::NONE) : ?>
Due: <?= $this->printHtml($task->getDue()->format('Y/m/d H:i')); ?>
<?php else : ?>
Priority: <?= $this->getHtml('P' . $task->getPriority()) ?>
<?php endif; ?>
</div>
<div>Created <?= $this->printHtml($task->getCreatedAt()->format('Y/m/d H:i')); ?></div>
</div>
<header><h1><?= $this->printHtml($task->getTitle()); ?></h1></header>
@ -111,7 +118,13 @@ echo $this->getData('nav')->render(); ?>
$element->getStatus() !== TaskStatus::DONE ||
$element->getStatus() !== TaskStatus::SUSPENDED || $c != $cElements
) : ?>
<div class="vCenterTable nobreak">Due <?= $this->printHtml($element->getDue()->format('Y-m-d H:i')); ?></div>
<div class="vCenterTable nobreak">
<?php if ($element->getPriority() === TaskPriority::NONE) : ?>
Due: <?= $this->printHtml($element->getDue()->format('Y/m/d H:i')); ?>
<?php else : ?>
Priority: <?= $this->getHtml('P' . $element->getPriority()) ?>
<?php endif; ?>
</div>
<?php endif; ?>
</section>
<?php endforeach; ?>