Skip to content

Commit

Permalink
fix responsible
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Eichhorn committed Feb 5, 2024
1 parent 854cad4 commit f524e49
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
3 changes: 3 additions & 0 deletions Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ public function viewTaskDashboard(RequestAbstract $request, ResponseAbstract $re
->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)
Expand Down
25 changes: 25 additions & 0 deletions Models/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,31 @@ public function getTaskElement(int $id) : TaskElement
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}
*/
Expand Down
20 changes: 7 additions & 13 deletions Theme/Backend/task-dashboard.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,24 +161,18 @@
</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>
Expand Down

0 comments on commit f524e49

Please sign in to comment.