Skip to content

Commit

Permalink
Tasks Module Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gevorgmansuryan committed Nov 26, 2024
1 parent d6065b7 commit 4ecfddb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 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
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 @@ -96,7 +96,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

0 comments on commit 4ecfddb

Please sign in to comment.