diff --git a/CalendarUtils.php b/CalendarUtils.php index 5363c8a9..07ae0d81 100644 --- a/CalendarUtils.php +++ b/CalendarUtils.php @@ -1,4 +1,5 @@ registerJsConfig([ + 'task' => [ + 'text' => [ + 'success.delete' => Yii::t('base', 'Deleted'), + ], + ], + ]); + return parent::register($view); } } diff --git a/controllers/ConfigContainerController.php b/controllers/ConfigContainerController.php index 249e40c8..324558f7 100644 --- a/controllers/ConfigContainerController.php +++ b/controllers/ConfigContainerController.php @@ -1,4 +1,5 @@ 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, @@ -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); @@ -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); diff --git a/controllers/rest/TaskListController.php b/controllers/rest/TaskListController.php index aa6ef49d..98ac6341 100644 --- a/controllers/rest/TaskListController.php +++ b/controllers/rest/TaskListController.php @@ -1,4 +1,5 @@ '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', 'Confirm task deletion'), 'data-action-confirm' => Yii::t('TasksModule.base', 'Do you really want to delete this task?'), diff --git a/widgets/TaskDetails.php b/widgets/TaskDetails.php index b54649f4..4e8da9ce 100644 --- a/widgets/TaskDetails.php +++ b/widgets/TaskDetails.php @@ -1,4 +1,5 @@ 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; + } + +} diff --git a/widgets/TaskIcon.php b/widgets/TaskIcon.php index 9fb368b5..4827c4b4 100644 --- a/widgets/TaskIcon.php +++ b/widgets/TaskIcon.php @@ -1,4 +1,5 @@ - id . ']', $item->completed, ['label' => $item->title, 'itemId' => $item->id, 'data-action-change' => 'check', 'disabled' => $disabled]); ?> + id . ']', $item->completed, [ + 'label' => $item->title, + 'itemId' => $item->id, + 'data-action-change' => 'check', + 'disabled' => $disabled, + 'labelOptions' => [ + 'class' => $item->completed ? 'item-finished' : '', + ] + ]); ?>