fix responsible

This commit is contained in:
Dennis Eichhorn 2024-02-05 01:07:27 +00:00
parent 854cad4c1d
commit f524e490f4
3 changed files with 35 additions and 13 deletions

View File

@ -136,6 +136,9 @@ final class BackendController extends Controller implements DashboardElementInte
->with('createdBy')
->with('tags')
->with('tags/title')
->with('taskElements')
->with('taskElements/accRelation')
->with('taskElements/accRelation/relation')
->where('tags/title/language', $response->header->l11n->language)
->where('type', TaskType::SINGLE)
->where('status', TaskStatus::OPEN)

View File

@ -428,6 +428,31 @@ class Task implements \JsonSerializable
return $this->taskElements[$id] ?? new NullTaskElement();
}
public function getResponsible() : array
{
$responsible = [];
foreach ($this->taskElements as $element) {
if (empty($element->accRelation)) {
continue;
}
$first = true;
foreach ($element->accRelation as $accRel) {
if ($accRel->duty === DutyType::TO) {
if ($first) {
$responsible = [];
}
$responsible[] = $accRel->relation;
$first = false;
}
}
}
return $responsible;
}
/**
* {@inheritdoc}
*/

View File

@ -161,24 +161,18 @@ echo $this->data['nav']->render(); ?>
</span>
</a>
<?php endforeach; ?>
<td data-label="<?= $this->getHtml('Creator'); ?>">
<a class="content" href="<?= UriFactory::build('{/base}/profile/view?{?}&for=' . $task->createdBy->id); ?>">
<?= $this->printHtml($this->renderUserName(
'%3$s %2$s %1$s',
[
$task->createdBy->name1,
$task->createdBy->name2,
$task->createdBy->name3,
$task->createdBy->login ?? '',
])
); ?>
</a>
<td><?php $responsibles = $task->getResponsible();
foreach ($responsibles as $responsible) : ?>
<a class="content" href="<?= UriFactory::build('{/base}/profile/view?for=' . $responsible->id); ?>">
<?= $this->printHtml($responsible->name1); ?> <?= $this->printHtml($responsible->name2); ?>
</a>
<?php endforeach; ?>
<td data-label="<?= $this->getHtml('Created'); ?>">
<a href="<?= $url; ?>"><?= $this->printHtml($task->createdAt->format('Y-m-d H:i')); ?></a>
<?php endforeach; if ($c == 0) : ?>
<tr><td colspan="7" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</table>
</div>
</div>
</div>