Skip to content

Commit

Permalink
Merge pull request #263 from humhub/fix/js-fixes
Browse files Browse the repository at this point in the history
Js Fixes
  • Loading branch information
luke- authored Dec 3, 2024
2 parents fb34aa4 + 02f8dd7 commit 3ec964d
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 15 deletions.
9 changes: 9 additions & 0 deletions assets/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use humhub\components\assets\AssetBundle;
use humhub\modules\tasks\controllers\ListController;
use humhub\modules\tasks\controllers\SearchController;
use Yii;

class Assets extends AssetBundle
{
Expand Down Expand Up @@ -49,6 +50,14 @@ public static function register($view)
. '.task-overview #task-filter-nav .task-bottom-panel .filterInput[data-filter-type=checkbox] .fa.fa-check-square-o{border-color:var(--info);background:var(--info)}');
}

$view->registerJsConfig([
'task' => [
'text' => [
'success.delete' => Yii::t('base', 'Deleted'),
],
],
]);

return parent::register($view);
}
}
14 changes: 3 additions & 11 deletions controllers/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function actionEdit($id = null, $cal = false, $redirect = false, $listId
$taskForm->createNew($this->contentContainer);
} else {
$taskForm = new TaskForm([
'task' => Task::find()->contentContainer($this->contentContainer)->where(['task.id' => $id])->one(),
'task' => $this->getTaskById($id),
'cal' => $cal,
'redirect' => $redirect,
'wall' => $wall,
Expand Down Expand Up @@ -162,11 +162,7 @@ public function actionTaskResponsiblePicker($keyword = '')

public function actionView($id)
{
$task = Task::find()->contentContainer($this->contentContainer)->where(['task.id' => $id])->one();

if (!$task) {
throw new HttpException(404);
}
$task = $this->getTaskById($id);

if (!$task->content->canView()) {
throw new HttpException(403);
Expand All @@ -179,11 +175,7 @@ public function actionView($id)

public function actionLoadAjaxTask($id)
{
$task = Task::find()->contentContainer($this->contentContainer)->where(['task.id' => $id])->one();

if (!$task) {
throw new HttpException(404);
}
$task = $this->getTaskById($id);

if (!$task->content->canView()) {
throw new HttpException(403);
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changelog
- Enh #258: By default, enabled "Mobile" notification types for those enabled for "Web"
- Enh #259: Replace theme variables with CSS variables
- Enh #260: Use PHP CS Fixer
- Fix #263: Fixed deleted tasks visibility, reload after deletion, reload after state change

1.8.5 (March 14, 2024)
----------------------
Expand Down
15 changes: 15 additions & 0 deletions resources/js/humhub.task.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,20 @@ humhub.module('task', function (module, require, $) {
});
};

var deleteTaskFromContext = function(evt) {
var widget = Widget.closest(evt.$trigger);
widget.$.fadeOut('fast');

client.post(evt).then(function() {
event.trigger('task.afterDelete');
$('#task-space-menu').find('a:first').click();
module.log.success(module.text('success.delete'));
}).catch(function(e) {
widget.$.fadeIn('fast');
module.log.error(e, true);
});
};

/**
* @param evt
*/
Expand Down Expand Up @@ -255,6 +269,7 @@ humhub.module('task', function (module, require, $) {
init: init,
Form: Form,
deleteTask: deleteTask,
deleteTaskFromContext: deleteTaskFromContext,
changeState: changeState,
extensionrequest:extensionrequest
});
Expand Down
4 changes: 2 additions & 2 deletions resources/js/humhub.task.list.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,9 @@ humhub.module('task.list', function (module, require, $) {
that.$.find('.task-list-task-details').hide();
}

if (that.isCompleted()) {
if (that.isCompleted() && that.parent()) {
that.parent().prependCompleted(that);
} else if(that.$.closest('.tasks-completed')) {
} else if(that.$.closest('.tasks-completed') && that.parent()) {
that.parent().prependPending(that);
} else {
that.$.fadeIn();
Expand Down
2 changes: 1 addition & 1 deletion widgets/TaskContextMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function initControls()
'icon' => 'trash',
'sortOrder' => 300,
'htmlOptions' => [
'data-action-click' => 'ui.modal.post',
'data-action-click' => 'task.deleteTaskFromContext',
'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?'),
Expand Down
51 changes: 51 additions & 0 deletions widgets/TaskHeader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2022 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/

namespace humhub\modules\tasks\widgets;

use humhub\modules\content\components\ContentContainerActiveRecord;
use humhub\modules\tasks\helpers\TaskListUrl;
use humhub\modules\tasks\models\Task;
use humhub\modules\tasks\permissions\CreateTask;
use yii\base\Widget;

/**
* Widget for rendering the Tasks header.
*/
class TaskHeader extends Widget
{
/**
* @var null|ContentContainerActiveRecord
*/
public $contentContainer;

/**
* @var bool
*/
public $displayAddTask = false;

/**
* @inheritdoc
*/
public function run()
{
return $this->render('taskHeader', [
'addTaskUrl' => $this->getAddTaskUrl(),
]);
}

private function getAddTaskUrl(): ?string
{
if ($this->displayAddTask && (new Task($this->contentContainer))->content->canEdit()) {
return TaskListUrl::addTaskListTask(null, $this->contentContainer);
}

return null;
}

}
10 changes: 9 additions & 1 deletion widgets/checklist/views/taskChecklistItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@

<div class="task-item-content">

<?= Html::checkBox('item[' . $item->id . ']', $item->completed, ['label' => $item->title, 'itemId' => $item->id, 'data-action-change' => 'check', 'disabled' => $disabled]); ?>
<?= Html::checkBox('item[' . $item->id . ']', $item->completed, [
'label' => $item->title,
'itemId' => $item->id,
'data-action-change' => 'check',
'disabled' => $disabled,
'labelOptions' => [
'class' => $item->completed ? 'item-finished' : '',
]
]); ?>

<span class="task-drag-icon tt" title="<?= Yii::t('TasksModule.base', 'Drag entry')?>" style="display:none">
<i class="fa fa-arrows"></i>&nbsp;
Expand Down

0 comments on commit 3ec964d

Please sign in to comment.