Skip to content

Commit

Permalink
Integrate wall entry context menu for task on details and list pages
Browse files Browse the repository at this point in the history
  • Loading branch information
yurabakhtin committed Feb 2, 2024
1 parent 393fec1 commit 075b852
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 140 deletions.
5 changes: 2 additions & 3 deletions controllers/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,8 @@ public function actionView($id)
throw new HttpException(403);
}

return $this->render("task", [
'task' => $task,
'contentContainer' => $this->contentContainer
return $this->render('task', [
'task' => $task
]);
}

Expand Down
2 changes: 1 addition & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog
1.8.5 (Unreleased)
-------------------------
- Fix #249: Fix replaced method `friendship\Module::isEnabled()`
- Enh #241: Permalinks in tasks overview
- Enh #241: Integrate wall entry context menu for task on details and list pages

1.8.4 (December 21, 2023)
-------------------------
Expand Down
2 changes: 1 addition & 1 deletion resources/css/task.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/css/task.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion resources/css/task.less
Original file line number Diff line number Diff line change
Expand Up @@ -706,4 +706,13 @@
.wall-entry-task h1 {
font-size: 14px;
font-weight: 500;
}
}

.nav-pills.task-preferences {
position: inherit;
top: 0;
left: 0;
.dropdown .dropdown-toggle i {
font-weight: normal;
}
}
17 changes: 7 additions & 10 deletions views/task/task.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
*/

use humhub\modules\tasks\assets\Assets;
use humhub\modules\tasks\models\Task;
use humhub\modules\tasks\widgets\lists\TaskListDetails;
use humhub\modules\tasks\widgets\TaskHeader;
use humhub\modules\tasks\widgets\TaskSubMenu;
use humhub\modules\ui\view\components\View;

/* @var $this \humhub\modules\ui\view\components\View */
/* @var $task \humhub\modules\tasks\models\Task */
/* @var $contentContainer \humhub\modules\content\components\ContentContainerActiveRecord */
/* @var $this View */
/* @var $task Task */

Assets::register($this);

Expand All @@ -27,15 +28,11 @@
<?= TaskSubMenu::widget() ?>
<div id="task-container" class="panel panel-default task-details">

<?= $this->render('task_header', [
'canEdit' => $task->content->canEdit(),
'contentContainer' => $contentContainer,
'task' => $task
]); ?>
<?= $this->render('task_header', ['task' => $task]) ?>

<div class="panel-body task-list-items">
<div class="cleafix task-list-item">
<?= TaskListDetails::widget(['task' => $task])?>
<?= TaskListDetails::widget(['task' => $task]) ?>
</div>
</div>
</div>
</div>
13 changes: 6 additions & 7 deletions views/task/task_header.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,24 @@
use humhub\modules\tasks\widgets\TaskUserList;
use humhub\modules\ui\icon\widgets\Icon;

/* @var $contentContainer \humhub\modules\content\components\ContentContainerActiveRecord */
/* @var $task \humhub\modules\tasks\models\Task */
/* @var $canEdit boolean */
/* @var $collapse boolean */
/* @var $task Task */

$icon = 'fa-tasks';
$participantStyle = 'display:inline-block;';
$color = $task->getColor() ? $task->getColor() : $this->theme->variable('info');

?>
<div class="panel-heading clearfix">
<div class="pull-right">
<?= TaskContextMenu::widget(['task' => $task]) ?>
</div>

<div class="task-head">
<div>
<strong><?= Icon::get($icon)->color($color)?> <?= Html::encode($task->title) ?></strong>
</div>
</div>

<?= TaskContextMenu::widget(['task' => $task, 'contentContainer' => $contentContainer]) ?>

<div class="row clearfix">
<div class="col-sm-12 media">
<div class="media-body clearfix">
Expand Down Expand Up @@ -96,4 +95,4 @@
</div>
</div>
</div>
</div>
</div>
113 changes: 89 additions & 24 deletions widgets/TaskContextMenu.php
Original file line number Diff line number Diff line change
@@ -1,58 +1,123 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2018 HumHub GmbH & Co. KG
* @copyright Copyright (c) HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*
*/

namespace humhub\modules\tasks\widgets;

use humhub\libs\Html;
use humhub\modules\content\widgets\WallEntryControls;
use humhub\modules\tasks\helpers\TaskUrl;
use humhub\modules\tasks\models\Task;
use yii\base\Widget;
use humhub\modules\ui\menu\MenuLink;
use humhub\widgets\Link;
use Yii;

/**
* Widget for rendering the menue buttons for a Task.
* Widget for rendering the menu buttons for a Task.
* @author davidborn
*/
class TaskContextMenu extends Widget
class TaskContextMenu extends WallEntryControls
{
/**
* @inheritdoc
* Use this plugin for methods like `makePublicLink`, `lockComments`, `pin`, etc.
*/
public $jsWidget = 'stream.StreamEntry';

/**
* @var Task
* @inheritdoc
*/
public $task;
public $template = 'taskContextMenu';

public ?Task $task = null;

public string $mode = 'details';

public ?string $align = null;

/**
* @var \humhub\modules\content\components\ContentContainerActiveRecord Current content container.
* @inheritdoc
*/
public $contentContainer;
public function beforeRun()
{
return parent::beforeRun() && $this->task->content->canEdit();
}

/**
* @var boolean Determines if the user has write permissions.
* @inheritdoc
*/
public $canEdit;
public function init()
{
$this->object = $this->task;
$this->wallEntryWidget = new WallEntry(['model' => $this->task]);

parent::init();
}

/**
* @inheritdoc
*/
public function run()
public function getAttributes()
{
if(!$this->task->content->canEdit()) {
return '';
$attrs = parent::getAttributes();
Html::addCssClass($attrs, 'task-preferences');
return $attrs;
}

/**
* @inheritdoc
*/
protected function getViewParams()
{
$params = parent::getViewParams();
$params['toggler'] = $this->getToggler();
return $params;
}

public function initControls()
{
$this->renderOptions->disableControlsEntryEdit();
$this->renderOptions->disableControlsEntryDelete();

if ($this->task->content->canEdit()) {
$this->addEntry(new MenuLink([
'label' => Yii::t('TasksModule.base', 'Edit'),
'url' => '#',
'icon' => 'pencil',
'sortOrder' => 100,
'htmlOptions' => [
'data-action-click' => 'ui.modal.post',
'data-action-click-url' => TaskUrl::editTask($this->task),
],
]));

$this->addEntry(new MenuLink([
'label' => Yii::t('TasksModule.base', 'Delete'),
'url' => '#',
'icon' => 'trash',
'sortOrder' => 300,
'htmlOptions' => [
'data-action-click' => 'ui.modal.post',
'data-action-click-url' => TaskUrl::deleteTask($this->task),
'data-action-confirm-header' => Yii::t('TasksModule.base', '<strong>Confirm</strong> task deletion'),
'data-action-confirm' => Yii::t('TasksModule.base', 'Do you really want to delete this task?'),
'data-action-confirm-text' => Yii::t('TasksModule.base', 'Delete')
],
]));
}

return $this->render('taskMenuDropdown', [
'deleteUrl' => TaskUrl::deleteTask($this->task, null, 1),
'editUrl' => TaskUrl::editTask($this->task, null, 1),
'task' => $this->task,
'extensionRequestUrl' => TaskUrl::requestExtension($this->task),
'resetUrl' => TaskUrl::resetTask($this->task),
'canEdit' => $this->task->content->canEdit(),
'canRequestExtension' => ( $this->task->schedule->canRequestExtension()),
'canReset' => $this->task->canResetTask()
]);
parent::initControls();
}

private function getToggler(): Link
{
if ($this->mode === 'details') {
return Link::asLink('<span class="caret"></span>')->icon('cog');
}

return Link::asLink()->icon('ellipsis-v');
}
}
53 changes: 7 additions & 46 deletions widgets/lists/views/taskListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@

use humhub\modules\comment\models\Comment;

use humhub\modules\tasks\helpers\TaskUrl;
use humhub\modules\tasks\widgets\lists\TaskListDetails;
use humhub\modules\tasks\widgets\TaskBadge;
use humhub\modules\tasks\widgets\TaskContextMenu;
use humhub\modules\tasks\widgets\TaskUserList;
use humhub\widgets\Link;
use humhub\widgets\Button;
use humhub\modules\tasks\models\Task;
use humhub\modules\content\widgets\MoveContentLink;
use humhub\modules\ui\view\components\View;
use yii\helpers\Html;

/* @var $this \humhub\modules\ui\view\components\View */
/* @var $task \humhub\modules\tasks\models\Task */
/* @var $this View */
/* @var $task Task */
/* @var $options array */
/* @var $details boolean */
/* @var $canManage boolean */
/* @var $contentContainer \humhub\modules\content\components\ContentActiveRecord */

$checkUrl = $task->state->getCheckUrl();

Expand Down Expand Up @@ -53,45 +50,9 @@

</span>

<?php if ($task->content->canEdit()) : ?>
<div class="task-controls end pull-right">
<div class="btn-group">
<?= Link::none()->icon('fa-ellipsis-v')
->cssClass('dropdown-toggle')
->options([
'data-toggle' => 'dropdown',
'haspopup' => 'true',
'aria-expanded' => 'false'
])->sm()->loader(false) ?>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu pull-right">
<li>
<?= Button::asLink(Yii::t('TasksModule.base', 'Permalink'))
->options(['data' => [
'action-click' => 'content.permalink',
'content-permalink' => TaskUrl::viewTask($task, true)]])
->icon('link') ?>
</li>
<li>
<?= Button::asLink(Yii::t('TasksModule.base', 'Edit task'))
->action('ui.modal.load', TaskUrl::editTask($task))
->icon('fa-pencil'); ?>
</li>
<li>
<?= MoveContentLink::widget(['model' => $task]) ?>
</li>
<li>
<?= Button::asLink(Yii::t('TasksModule.base', 'Delete task'))
->action('task.deleteTask', TaskUrl::deleteTask($task))
->icon('fa-trash')->confirm(); ?>
</li>
</ul>
</div>


</div>
<?php endif; ?>
<div class="task-controls end pull-right">
<?= TaskContextMenu::widget(['task' => $task, 'mode' => 'list']) ?>
</div>

<div class="task-controls pull-right toggleTaskDetails hidden-xs"
style="<?= (!$task->content->canEdit()) ? 'border-right:0;margin-right:0' : '' ?>">
Expand Down
Loading

0 comments on commit 075b852

Please sign in to comment.