Add plain/raw descriptions

This commit is contained in:
Dennis Eichhorn 2017-12-18 20:22:00 +01:00
parent cebe98be2a
commit ff23a66f93
6 changed files with 55 additions and 2 deletions

View File

@ -47,6 +47,7 @@ class Installer extends InstallerAbstract
`task_id` int(11) NOT NULL AUTO_INCREMENT,
`task_title` varchar(255) DEFAULT NULL,
`task_desc` text NOT NULL,
`task_desc_raw` text NOT NULL,
`task_type` tinyint(1) NOT NULL,
`task_status` tinyint(1) NOT NULL,
`task_closable` tinyint(1) NOT NULL,
@ -109,6 +110,7 @@ class Installer extends InstallerAbstract
'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'task_element` (
`task_element_id` int(11) NOT NULL AUTO_INCREMENT,
`task_element_desc` text NOT NULL,
`task_element_desc_raw` text NOT NULL,
`task_element_task` int(11) NOT NULL,
`task_element_created_by` int(11) NOT NULL,
`task_element_status` tinyint(1) NOT NULL,

View File

@ -27,6 +27,7 @@ use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\WebInterface;
use phpOMS\Utils\Parser\Markdown\Markdown;
use phpOMS\Views\View;
use phpOMS\Account\PermissionType;
use phpOMS\DataStorage\Database\RelationType;
@ -294,7 +295,8 @@ class Controller extends ModuleAbstract implements WebInterface
{
$task = new Task();
$task->setTitle((string) ($request->getData('title') ?? ''));
$task->setDescription((string) ($request->getData('description') ?? ''));
$task->setDescription(Markdown::parse((string) ($request->getData('description') ?? '')));
$task->setDescriptionRaw((string) ($request->getData('description') ?? ''));
$task->setCreatedBy($request->getHeader()->getAccount());
$task->setDue(new \DateTime((string) ($request->getData('due') ?? 'now')));
$task->setStatus(TaskStatus::OPEN);
@ -365,7 +367,8 @@ class Controller extends ModuleAbstract implements WebInterface
$element->setDue(new \DateTime((string) ($request->getData('due') ?? 'now')));
$element->setStatus((int) ($request->getData('status')));
$element->setTask((int) ($request->getData('task')));
$element->setDescription((string) ($request->getData('description')));
$element->setDescription(Markdown::parse((string) ($request->getData('description'))));
$element->setDescriptionRaw((string) ($request->getData('description')));
return $element;
}

View File

@ -68,6 +68,8 @@ class Task implements \JsonSerializable
*/
protected $description = '';
protected $descriptionRaw = '';
/**
* Type.
*
@ -277,6 +279,26 @@ class Task implements \JsonSerializable
$this->description = $description;
}
/**
* @return string
*
* @since 1.0.0
*/
public function getDescriptionRaw() : string
{
return $this->descriptionRaw;
}
/**
* @param string $description
*
* @since 1.0.0
*/
public function setDescriptionRaw(string $description)
{
$this->descriptionRaw = $description;
}
/**
* @return \DateTime
*

View File

@ -43,6 +43,8 @@ class TaskElement implements \JsonSerializable
*/
private $description = '';
private $descriptionRaw = '';
/**
* Task.
*
@ -179,6 +181,28 @@ class TaskElement implements \JsonSerializable
$this->description = $description;
}
/**
* @return string
*
* @since 1.0.0
*/
public function getDescriptionRaw() : string
{
return $this->descriptionRaw;
}
/**
* @param string $description
*
* @return void
*
* @since 1.0.0
*/
public function setDescriptionRaw(string $description)
{
$this->descriptionRaw = $description;
}
/**
* @return \DateTime
*

View File

@ -40,6 +40,7 @@ class TaskElementMapper extends DataMapperAbstract
protected static $columns = [
'task_element_id' => ['name' => 'task_element_id', 'type' => 'int', 'internal' => 'id'],
'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_due' => ['name' => 'task_element_due', 'type' => 'DateTime', 'internal' => 'due'],
'task_element_forwarded' => ['name' => 'task_element_forwarded', 'type' => 'int', 'internal' => 'forwarded'],

View File

@ -45,6 +45,7 @@ class TaskMapper extends DataMapperAbstract
'task_id' => ['name' => 'task_id', 'type' => 'int', 'internal' => 'id'],
'task_title' => ['name' => 'task_title', 'type' => 'string', 'internal' => 'title'],
'task_desc' => ['name' => 'task_desc', 'type' => 'string', 'internal' => 'description'],
'task_desc_raw' => ['name' => 'task_desc_raw', 'type' => 'string', 'internal' => 'descriptionRaw'],
'task_type' => ['name' => 'task_type', 'type' => 'int', 'internal' => 'type'],
'task_status' => ['name' => 'task_status', 'type' => 'int', 'internal' => 'status'],
'task_closable' => ['name' => 'task_closable', 'type' => 'bool', 'internal' => 'isClosable'],