Fix forward handling in tasks/task elements

This commit is contained in:
Dennis Eichhorn 2019-05-18 16:31:22 +02:00
parent fa8125d328
commit d3442d444c
5 changed files with 30 additions and 25 deletions

View File

@ -267,11 +267,11 @@ final class ApiController extends Controller
} }
foreach ($tos as $to) { foreach ($tos as $to) {
$element->addTo($to); $element->addTo((int) $to);
} }
foreach ($ccs as $cc) { foreach ($ccs as $cc) {
$element->addCC($cc); $element->addCC((int) $cc);
} }
return $element; return $element;

View File

@ -110,7 +110,7 @@ final class BackendController extends Controller
$head = $response->get('Content')->getData('head'); $head = $response->get('Content')->getData('head');
$head->addAsset(AssetType::CSS, '/Modules/Tasks/Theme/Backend/css/styles.css'); $head->addAsset(AssetType::CSS, '/Modules/Tasks/Theme/Backend/css/styles.css');
$task = TaskMapper::get((int) $request->getData('id')); $task = TaskMapper::get((int) $request->getData('id'), RelationType::ALL, null, 5);
$accountId = $request->getHeader()->getAccount(); $accountId = $request->getHeader()->getAccount();
if (!($task->getCreatedBy()->getId() === $accountId if (!($task->getCreatedBy()->getId() === $accountId

View File

@ -182,10 +182,6 @@ class TaskElement implements \JsonSerializable
public function setCreatedBy($creator) : void public function setCreatedBy($creator) : void
{ {
$this->createdBy = $creator; $this->createdBy = $creator;
if (empty($this->acc)) {
$this->addTo($this->createdBy);
}
} }
/** /**
@ -458,7 +454,7 @@ class TaskElement implements \JsonSerializable
{ {
if ($to instanceof Group) { if ($to instanceof Group) {
$this->addGroupTo($to); $this->addGroupTo($to);
} elseif(($to instanceof Account) || \is_int($to)) { } elseif (($to instanceof Account) || \is_int($to)) {
$this->addAccountTo($to); $this->addAccountTo($to);
} }
} }
@ -550,7 +546,7 @@ class TaskElement implements \JsonSerializable
{ {
if ($cc instanceof Group) { if ($cc instanceof Group) {
$this->addGroupCC($cc); $this->addGroupCC($cc);
} elseif(($cc instanceof Account) || \is_int($cc)) { } elseif (($cc instanceof Account) || \is_int($cc)) {
$this->addAccountCC($cc); $this->addAccountCC($cc);
} }
} }

View File

@ -26,6 +26,7 @@ return ['Tasks' => [
'Due/Priority' => 'Due/Priority', 'Due/Priority' => 'Due/Priority',
'Forward' => 'Forward', 'Forward' => 'Forward',
'Forwarded' => 'Forwarded', 'Forwarded' => 'Forwarded',
'ForwardedTo' => 'Forwarded to',
'From' => 'From', 'From' => 'From',
'Group' => 'Group', 'Group' => 'Group',
'History' => 'History', 'History' => 'History',

View File

@ -15,6 +15,8 @@ use \Modules\Admin\Models\Account;
use \Modules\Admin\Models\Group; use \Modules\Admin\Models\Group;
use \Modules\Tasks\Models\TaskPriority; use \Modules\Tasks\Models\TaskPriority;
use \Modules\Tasks\Models\TaskStatus; use \Modules\Tasks\Models\TaskStatus;
use \Modules\Tasks\Models\AccountRelation;
use \Modules\Tasks\Models\GroupRelation;
/** /**
* @var \phpOMS\Views\View $this * @var \phpOMS\Views\View $this
@ -99,21 +101,9 @@ echo $this->getData('nav')->render(); ?>
</section> </section>
<?php $c = 0; <?php $c = 0;
foreach ($elements as $key => $element) : $c++; ?> foreach ($elements as $key => $element) : $c++;
<?php $tos = $element->getTo(); if ($c > 1 && \count($tos) > 1) : ?> if ($element->getDescription() !== '') :
<section class="box wf-100"> ?>
<div class="inner">
<?= $this->getHtml('Forwarded') ?>
<?php foreach ($tos as $to) : ?>
<?php if ($to instanceof Account) : ?>
<?= $this->printHtml($to->getRelation()->getName1()); ?>
<?php elseif ($to instanceof Group) : ?>
<?= $this->printHtml($to->getRelation()->getName()); ?>
<?php endif; ?>
<?php endforeach; ?>
</div>
</section>
<?php endif; ?>
<section class="box wf-100"> <section class="box wf-100">
<div class="inner pAlignTable"> <div class="inner pAlignTable">
<div class="vC wf-100"> <div class="vC wf-100">
@ -153,6 +143,24 @@ echo $this->getData('nav')->render(); ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
</section> </section>
<?php endif; ?>
<?php
$tos = $element->getTo();
if ($c > 1 && \count($tos) > 0) : ?>
<section class="box wf-100">
<div class="inner">
<?= $this->getHtml('ForwardedTo') ?>
<?php foreach ($tos as $to) : ?>
<?php if ($to instanceof AccountRelation) : ?>
<?= $this->printHtml($to->getRelation()->getName1()); ?>
<?php elseif ($to instanceof GroupRelation) : ?>
<?= $this->printHtml($to->getRelation()->getName()); ?>
<?php endif; ?>
<?php endforeach; ?>
</div>
</section>
<?php endif; ?>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
@ -187,7 +195,7 @@ echo $this->getData('nav')->render(); ?>
<option value="<?= TaskStatus::DONE; ?>"<?= $task->getStatus() === TaskStatus::DONE ? ' selected' : ''?>><?= $this->getHtml('S5') ?> <option value="<?= TaskStatus::DONE; ?>"<?= $task->getStatus() === TaskStatus::DONE ? ' selected' : ''?>><?= $this->getHtml('S5') ?>
</select> </select>
<tr><td><label for="iReceiver"><?= $this->getHtml('To') ?></label> <tr><td><label for="iReceiver"><?= $this->getHtml('To') ?></label>
<tr><td><?= $this->getData('accGrpSelector')->render('iReceiver', 'forward', true); ?> <tr><td><?= $this->getData('accGrpSelector')->render('iReceiver', 'to', true); ?>
<tr><td><label for="iMedia"><?= $this->getHtml('Media') ?></label> <tr><td><label for="iMedia"><?= $this->getHtml('Media') ?></label>
<tr><td><div class="ipt-wrap"> <tr><td><div class="ipt-wrap">
<div class="ipt-first"><input type="text" id="iMedia" placeholder="&#xf15b; File"></div> <div class="ipt-first"><input type="text" id="iMedia" placeholder="&#xf15b; File"></div>