add Save & Close button on the task edit form v1.8 t2

This commit is contained in:
2026-07-10 18:18:26 -03:00
parent ac8e3b9544
commit 269964d4cc
3 changed files with 80 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace Kanboard\Plugin\OrganonTweaks\Controller;
use Kanboard\Controller\TaskModificationController;
/**
* "Save & Close": the exact core task update, but on success it redirects to the BOARD instead of
* reopening the card view. The plugin's "Save & Close" button repoints the edit form here (via JS),
* so everything else -- validation, permission checks, CSRF, and the modal error re-render -- is
* inherited unchanged from core TaskModificationController. This mirrors core update() line for line
* except the one redirect target (kept in sync on Kanboard upgrades).
*/
class TaskSaveCloseController extends TaskModificationController
{
public function update()
{
$task = $this->getTask();
$values = $this->request->getValues();
$values['id'] = $task['id'];
$values['project_id'] = $task['project_id'];
list($valid, $errors) = $this->taskValidator->validateModification($values);
if ($valid && $this->updateTask($task, $values, $errors)) {
$this->flash->success(t('Task updated successfully.'));
$this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $task['project_id'])), true);
} else {
$this->flash->failure(t('Unable to update your task.'));
$this->edit($values, $errors);
}
}
}