Compare commits
2 Commits
a905079abc
...
ac8e3b9544
| Author | SHA1 | Date | |
|---|---|---|---|
| ac8e3b9544 | |||
| 717095848b |
@@ -1,11 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
* OrganonTweaks -- clicking a task title opens the edit modal instead of the read-only card view,
|
* OrganonTweaks -- clicking a task title opens the edit modal instead of the read-only card view,
|
||||||
* reusing Kanboard's own modal opener (KB.modal.open). Board part: the title is a link, and a hidden
|
* reusing Kanboard's own modal opener (KB.modal.open).
|
||||||
* marker rendered next to it (only when the user may edit) carries the server-generated edit URL.
|
* - Board: the title is a link, and a hidden marker rendered next to it (only when the user may
|
||||||
|
* edit) carries the server-generated edit URL.
|
||||||
|
* - Card view: the title (#task-summary > h2) opens the same modal via #task-view's data-edit-url,
|
||||||
|
* but only when the user may edit -- detected by the presence of the sidebar "Edit" action.
|
||||||
*
|
*
|
||||||
* A capture-phase delegated click is used so it (a) runs before Kanboard's own bubble-phase handlers,
|
* A capture-phase delegated click runs before Kanboard's own handlers, survives the board's AJAX
|
||||||
* (b) survives the board's AJAX re-renders without re-binding, and (c) stops both the link navigation
|
* re-renders, and stops both the link navigation and the card's own click.
|
||||||
* and the card's own click.
|
|
||||||
*/
|
*/
|
||||||
(function () {
|
(function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
@@ -16,6 +18,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The sidebar "Edit the task" action (fa-edit) only renders when the current user may edit.
|
||||||
|
function canEdit() {
|
||||||
|
return !!document.querySelector(".sidebar a i.fa-edit");
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener("click", function (e) {
|
document.addEventListener("click", function (e) {
|
||||||
if (!e.target || !e.target.closest) {
|
if (!e.target || !e.target.closest) {
|
||||||
return;
|
return;
|
||||||
@@ -31,6 +38,30 @@
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
openEdit(marker.getAttribute("data-url"));
|
openEdit(marker.getAttribute("data-url"));
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Card-view title -> open the same edit modal (#task-view carries the edit URL).
|
||||||
|
var title = e.target.closest("#task-summary > h2");
|
||||||
|
if (title && canEdit()) {
|
||||||
|
var taskView = document.querySelector("#task-view");
|
||||||
|
if (taskView && taskView.getAttribute("data-edit-url")) {
|
||||||
|
openEdit(taskView.getAttribute("data-edit-url"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
// Make the card-view title look clickable (the board title is already a link).
|
||||||
|
function markTitle() {
|
||||||
|
var title = document.querySelector("#task-summary > h2");
|
||||||
|
if (title && canEdit()) {
|
||||||
|
title.style.cursor = "pointer";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.readyState !== "loading") {
|
||||||
|
markTitle();
|
||||||
|
} else {
|
||||||
|
document.addEventListener("DOMContentLoaded", markTitle);
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class ConfigController extends BaseController
|
|||||||
'organon_tweaks_recurring_filters' => (int) $this->configModel->get('organon_tweaks_recurring_filters', 1),
|
'organon_tweaks_recurring_filters' => (int) $this->configModel->get('organon_tweaks_recurring_filters', 1),
|
||||||
'organon_tweaks_shortcut_labels' => (int) $this->configModel->get('organon_tweaks_shortcut_labels', 1),
|
'organon_tweaks_shortcut_labels' => (int) $this->configModel->get('organon_tweaks_shortcut_labels', 1),
|
||||||
'organon_tweaks_title_click_edit' => (int) $this->configModel->get('organon_tweaks_title_click_edit', 1),
|
'organon_tweaks_title_click_edit' => (int) $this->configModel->get('organon_tweaks_title_click_edit', 1),
|
||||||
|
'organon_tweaks_save_close_button' => (int) $this->configModel->get('organon_tweaks_save_close_button', 1),
|
||||||
),
|
),
|
||||||
'errors' => array(),
|
'errors' => array(),
|
||||||
)));
|
)));
|
||||||
@@ -43,6 +44,7 @@ class ConfigController extends BaseController
|
|||||||
$recurringFilters = isset($values['organon_tweaks_recurring_filters']) ? 1 : 0;
|
$recurringFilters = isset($values['organon_tweaks_recurring_filters']) ? 1 : 0;
|
||||||
$shortcutLabels = isset($values['organon_tweaks_shortcut_labels']) ? 1 : 0;
|
$shortcutLabels = isset($values['organon_tweaks_shortcut_labels']) ? 1 : 0;
|
||||||
$titleClickEdit = isset($values['organon_tweaks_title_click_edit']) ? 1 : 0;
|
$titleClickEdit = isset($values['organon_tweaks_title_click_edit']) ? 1 : 0;
|
||||||
|
$saveCloseButton = isset($values['organon_tweaks_save_close_button']) ? 1 : 0;
|
||||||
|
|
||||||
if ($this->configModel->save(array(
|
if ($this->configModel->save(array(
|
||||||
'organon_tweaks_always_comment_icon' => $alwaysCommentIcon,
|
'organon_tweaks_always_comment_icon' => $alwaysCommentIcon,
|
||||||
@@ -55,6 +57,7 @@ class ConfigController extends BaseController
|
|||||||
'organon_tweaks_recurring_filters' => $recurringFilters,
|
'organon_tweaks_recurring_filters' => $recurringFilters,
|
||||||
'organon_tweaks_shortcut_labels' => $shortcutLabels,
|
'organon_tweaks_shortcut_labels' => $shortcutLabels,
|
||||||
'organon_tweaks_title_click_edit' => $titleClickEdit,
|
'organon_tweaks_title_click_edit' => $titleClickEdit,
|
||||||
|
'organon_tweaks_save_close_button' => $saveCloseButton,
|
||||||
))) {
|
))) {
|
||||||
$this->flash->success(t('Settings saved successfully.'));
|
$this->flash->success(t('Settings saved successfully.'));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
13
Plugin.php
13
Plugin.php
@@ -77,6 +77,17 @@ class Plugin extends Base
|
|||||||
$this->template->hook->attach('template:board:private:task:before-title', 'organonTweaks:board/title_edit');
|
$this->template->hook->attach('template:board:private:task:before-title', 'organonTweaks:board/title_edit');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tweak: a "Save & Close" button on the task edit form that saves and returns to the board
|
||||||
|
// (core only reopens the card view). The button posts to a small plugin controller that
|
||||||
|
// reuses core's update and changes only the redirect; the JS repoints the form action, so
|
||||||
|
// Kanboard's modal still owns the submit, CSRF, and error re-render.
|
||||||
|
if ((int) $this->configModel->get('organon_tweaks_save_close_button', 1) === 1) {
|
||||||
|
$this->template->hook->attach('template:task:form:bottom-before-buttons', 'organonTweaks:task_form/save_close_button');
|
||||||
|
$this->hook->on('template:layout:js', array(
|
||||||
|
'template' => 'plugins/OrganonTweaks/Asset/js/save-close.js',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
// Auto-managed shared custom filters (v1.5 "Show all tasks", v1.6 month filters, v1.7
|
// Auto-managed shared custom filters (v1.5 "Show all tasks", v1.6 month filters, v1.7
|
||||||
// recurring filters). Ensured lazily whenever a project header renders (covers old + new
|
// recurring filters). Ensured lazily whenever a project header renders (covers old + new
|
||||||
// boards); each group is gated by its own config toggle inside
|
// boards); each group is gated by its own config toggle inside
|
||||||
@@ -128,7 +139,7 @@ class Plugin extends Base
|
|||||||
|
|
||||||
public function getPluginVersion()
|
public function getPluginVersion()
|
||||||
{
|
{
|
||||||
return '1.7.2';
|
return '1.8.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginHomepage()
|
public function getPluginHomepage()
|
||||||
|
|||||||
@@ -57,6 +57,9 @@
|
|||||||
|
|
||||||
<?= $this->form->checkbox('organon_tweaks_title_click_edit', t('Clicking a task title opens the edit form'), 1, isset($values['organon_tweaks_title_click_edit']) && $values['organon_tweaks_title_click_edit'] == 1) ?>
|
<?= $this->form->checkbox('organon_tweaks_title_click_edit', t('Clicking a task title opens the edit form'), 1, isset($values['organon_tweaks_title_click_edit']) && $values['organon_tweaks_title_click_edit'] == 1) ?>
|
||||||
<p class="form-help"><?= t('On the board and the card view, click the title to open the edit modal (only where you may edit).') ?></p>
|
<p class="form-help"><?= t('On the board and the card view, click the title to open the edit modal (only where you may edit).') ?></p>
|
||||||
|
|
||||||
|
<?= $this->form->checkbox('organon_tweaks_save_close_button', t('Add a "Save & Close" button to the task edit form'), 1, isset($values['organon_tweaks_save_close_button']) && $values['organon_tweaks_save_close_button'] == 1) ?>
|
||||||
|
<p class="form-help"><?= t('Saves the task and returns to the board, instead of reopening the card view.') ?></p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
|
|||||||
Reference in New Issue
Block a user