improve dynamic task element creation

This commit is contained in:
Dennis Eichhorn 2020-06-11 10:02:43 +02:00
parent 60efa2c35d
commit 1f504da3f6
2 changed files with 21 additions and 23 deletions

View File

@ -58,7 +58,7 @@ echo $this->getData('nav')->render(); ?>
<div class="portlet-head"> <div class="portlet-head">
<div class="row middle-xs"> <div class="row middle-xs">
<span class="col-xs-0"> <span class="col-xs-0">
<img class="profile-image" alt="<?= $this->getHtml('User', '0', '0'); ?>" data-lazyload="<?= $this->getAccountImage($task->getCreatedBy()); ?>"> <img class="profile-image" alt="<?= $this->getHtml('User', '0', '0'); ?>" data-lazyload="<?= $this->getAccountImage($task->getCreatedBy()->getId()); ?>">
</span> </span>
<span> <span>
<?= $this->printHtml($task->getCreatedBy()->getName1()); ?> - <?= $this->printHtml($task->getCreatedAt()->format('Y/m/d H:i')); ?> <?= $this->printHtml($task->getCreatedBy()->getName1()); ?> - <?= $this->printHtml($task->getCreatedAt()->format('Y/m/d H:i')); ?>
@ -115,42 +115,40 @@ echo $this->getData('nav')->render(); ?>
<div id="elements"> <div id="elements">
<template id="elementTpl"> <template id="elementTpl">
<section id="taskelmenet-0" class="box wf-100 taskElement" <section id="taskelmenet-0" class="portlet taskElement"
data-update-content="#elements" data-update-content="#elements"
data-update-element=".taskElement .taskElement-content" data-update-element=".taskElement .taskElement-content"
data-tag="form" data-tag="form"
data-method="POST" data-method="POST"
data-uri="<?= UriFactory::build('{/api}task/element?id={?id}&csrf={$CSRF}'); ?>"> data-uri="<?= UriFactory::build('{/api}task/element?id={?id}&csrf={$CSRF}'); ?>">
<div class="inner pAlignTable"> <div class="portlet-head">
<div class="vC wf-100"> <div class="row middle-xs">
<span data-tpl-text="{/base}/api/task/element?id={$id}" data-tpl-text-path="/0/response/createdBy/name/0"></span> <span class="col-xs-0">
- <img class="profile-image" alt="<?= $this->getHtml('User', '0', '0'); ?>" src="<?= $this->getAccountImage($this->request->getHeader()->getAccount()); ?>">
<span data-tpl-text="{/base}/api/task/element?id={$id}" data-tpl-text-path="/0/response/createdAt/date"></span> </span>
<span class="col-xs">
<span data-tpl-text="{/base}/api/task/element?id={$id}" data-tpl-text-path="/0/response/createdBy/name/0"></span>
- <span data-tpl-text="{/base}/api/task/element?id={$id}" data-tpl-text-path="/0/response/createdAt/date"></span>
</span>
</div> </div>
<span class="vC tag task-status-0">
<!-- status-->
</span>
</div> </div>
<div class="inner taskElement-content"> <div class="portlet-body">
<article data-tpl-text="{/base}/api/task/element?id={$id}" data-tpl-text-path="/0/response/description" data-value=""></article> <article class="taskElement-content" data-tpl-text="{/base}/api/task/element?id={$id}" data-tpl-text-path="/0/response/description" data-value=""></article>
</div> </div>
<div class="inner"> <div class="portlet-foot row middle-xs">
<!-- media here --> <div class="nobreak">
</div>
<div class="inner pAlignTable" style="background: #efefef; border-top: 1px solid #dfdfdf;">
<div class="vC wf-100 nobreak">
<!-- due / priority --> <!-- due / priority -->
</div> </div>
<div class="vC"> <div class="col-xs end-xs plain-grid">
<input type="hidden" value="" name="id"> <input type="hidden" value="" name="id">
<button class="save hidden"><?= $this->getHtml('Save', '0', '0') ?></button> <button class="save hidden"><?= $this->getHtml('Save', '0', '0') ?></button>
<button class="cancel hidden"><?= $this->getHtml('Cancel', '0', '0') ?></button> <button class="cancel hidden"><?= $this->getHtml('Cancel', '0', '0') ?></button>
<button class="update"><?= $this->getHtml('Edit', '0', '0') ?></button> <button class="update"><?= $this->getHtml('Edit', '0', '0') ?></button>
</div> </div>
</div>
</section> </section>
</template> </template>
<?php if ($task->isEditable()) : ?> <?php if ($task->isEditable()) : ?>
@ -198,7 +196,7 @@ echo $this->getData('nav')->render(); ?>
<div class="portlet-head"> <div class="portlet-head">
<div class="row middle-xs"> <div class="row middle-xs">
<span class="col-xs-0"> <span class="col-xs-0">
<img class="profile-image" alt="<?= $this->getHtml('User', '0', '0'); ?>" data-lazyload="<?= $this->getAccountImage($element->getCreatedBy()); ?>"> <img class="profile-image" alt="<?= $this->getHtml('User', '0', '0'); ?>" data-lazyload="<?= $this->getAccountImage($element->getCreatedBy()->getId()); ?>">
</span> </span>
<span class="col-xs"> <span class="col-xs">
<?= $this->printHtml($element->getCreatedBy()->getName1()); ?> - <?= $this->printHtml($element->getCreatedAt()->format('Y-m-d H:i')); ?> <?= $this->printHtml($element->getCreatedBy()->getName1()); ?> - <?= $this->printHtml($element->getCreatedAt()->format('Y-m-d H:i')); ?>

View File

@ -35,15 +35,15 @@ class TaskView extends View
* *
* If the profile doesn't have an image a random default image is used * If the profile doesn't have an image a random default image is used
* *
* @param Account $account Account * @param int $account Account
* *
* @return string * @return string
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function getAccountImage(Account $account) : string public function getAccountImage(int $account) : string
{ {
$profile = ProfileMapper::getFor($account->getId(), 'account'); $profile = ProfileMapper::getFor($account, 'account');
if ($profile === null || $profile->getImage()->getPath() === '') { if ($profile === null || $profile->getImage()->getPath() === '') {
return UriFactory::build('Web/Backend/img/user_default_' . \mt_rand(1, 6) . '.png'); return UriFactory::build('Web/Backend/img/user_default_' . \mt_rand(1, 6) . '.png');