Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 17ebfcccd9 | |||
| 95561e5565 |
94
Asset/js/enhance-recurrence.js
Normal file
94
Asset/js/enhance-recurrence.js
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* OrganonTweaks -- enhance Kanboard's native "Edit recurrence" dialog.
|
||||||
|
*
|
||||||
|
* That template (task_recurrence/edit.php) has no hook, so we transform the form in JS when
|
||||||
|
* the modal opens:
|
||||||
|
* 1. Replace the "Generate recurrent task" Yes/No dropdown with two radio buttons (one
|
||||||
|
* click instead of open + select). The original <select> is kept, hidden, and stays in
|
||||||
|
* sync, so the form still submits recurrence_status normally.
|
||||||
|
* 2. Add a small [+7] button next to the "Factor" input that adds 7 (a week of days).
|
||||||
|
*
|
||||||
|
* Detection: the modal is injected into #modal-box dynamically, so we watch the document for
|
||||||
|
* an un-enhanced recurrence form appearing. Loaded only when the setting is enabled.
|
||||||
|
*/
|
||||||
|
(function () {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
function enhanceStatus(select) {
|
||||||
|
var group = document.createElement("span");
|
||||||
|
group.className = "ot-recurrence-status";
|
||||||
|
|
||||||
|
for (var i = 0; i < select.options.length; i++) {
|
||||||
|
var opt = select.options[i];
|
||||||
|
|
||||||
|
var label = document.createElement("label");
|
||||||
|
label.style.marginRight = "14px";
|
||||||
|
label.style.cursor = "pointer";
|
||||||
|
|
||||||
|
var radio = document.createElement("input");
|
||||||
|
radio.type = "radio";
|
||||||
|
radio.name = "ot-recurrence-status";
|
||||||
|
radio.value = opt.value;
|
||||||
|
radio.checked = opt.value === select.value;
|
||||||
|
radio.style.marginRight = "4px";
|
||||||
|
radio.addEventListener("change", function () {
|
||||||
|
if (this.checked) {
|
||||||
|
select.value = this.value;
|
||||||
|
select.dispatchEvent(new Event("change", { bubbles: true }));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
label.appendChild(radio);
|
||||||
|
label.appendChild(document.createTextNode(opt.text));
|
||||||
|
group.appendChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
select.style.display = "none";
|
||||||
|
select.parentNode.insertBefore(group, select.nextSibling);
|
||||||
|
}
|
||||||
|
|
||||||
|
function enhanceFactor(input) {
|
||||||
|
var btn = document.createElement("button");
|
||||||
|
btn.type = "button";
|
||||||
|
btn.className = "btn";
|
||||||
|
btn.textContent = "+7";
|
||||||
|
btn.title = "Add 7 (one week of days)";
|
||||||
|
btn.style.marginLeft = "6px";
|
||||||
|
btn.addEventListener("click", function () {
|
||||||
|
input.value = (parseInt(input.value, 10) || 0) + 7;
|
||||||
|
input.dispatchEvent(new Event("change", { bubbles: true }));
|
||||||
|
});
|
||||||
|
|
||||||
|
input.parentNode.insertBefore(btn, input.nextSibling);
|
||||||
|
}
|
||||||
|
|
||||||
|
function enhance() {
|
||||||
|
var select = document.querySelector('select[name="recurrence_status"]:not([data-ot-recurrence])');
|
||||||
|
if (!select) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
select.setAttribute("data-ot-recurrence", "1");
|
||||||
|
enhanceStatus(select);
|
||||||
|
|
||||||
|
var factor = document.querySelector('input[name="recurrence_factor"]:not([data-ot-recurrence])');
|
||||||
|
if (factor) {
|
||||||
|
factor.setAttribute("data-ot-recurrence", "1");
|
||||||
|
enhanceFactor(factor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
enhance();
|
||||||
|
|
||||||
|
if (window.MutationObserver) {
|
||||||
|
new MutationObserver(enhance).observe(document.body, { childList: true, subtree: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.readyState === "loading") {
|
||||||
|
document.addEventListener("DOMContentLoaded", init);
|
||||||
|
} else {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
})();
|
||||||
@@ -17,6 +17,7 @@ class ConfigController extends BaseController
|
|||||||
'organon_tweaks_always_comment_icon' => (int) $this->configModel->get('organon_tweaks_always_comment_icon', 1),
|
'organon_tweaks_always_comment_icon' => (int) $this->configModel->get('organon_tweaks_always_comment_icon', 1),
|
||||||
'organon_tweaks_keep_scroll' => (int) $this->configModel->get('organon_tweaks_keep_scroll', 1),
|
'organon_tweaks_keep_scroll' => (int) $this->configModel->get('organon_tweaks_keep_scroll', 1),
|
||||||
'organon_tweaks_quick_click_only' => (int) $this->configModel->get('organon_tweaks_quick_click_only', 1),
|
'organon_tweaks_quick_click_only' => (int) $this->configModel->get('organon_tweaks_quick_click_only', 1),
|
||||||
|
'organon_tweaks_enhance_recurrence' => (int) $this->configModel->get('organon_tweaks_enhance_recurrence', 1),
|
||||||
),
|
),
|
||||||
'errors' => array(),
|
'errors' => array(),
|
||||||
)));
|
)));
|
||||||
|
|||||||
10
Plugin.php
10
Plugin.php
@@ -42,6 +42,14 @@ class Plugin extends Base
|
|||||||
'template' => 'plugins/OrganonTweaks/Asset/js/click-guard.js',
|
'template' => 'plugins/OrganonTweaks/Asset/js/click-guard.js',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tweak: enhance the native "Edit recurrence" dialog (Yes/No radios + a [+7] button
|
||||||
|
// on the factor). No template hook there, so it is done in JS.
|
||||||
|
if ((int) $this->configModel->get('organon_tweaks_enhance_recurrence', 1) === 1) {
|
||||||
|
$this->hook->on('template:layout:js', array(
|
||||||
|
'template' => 'plugins/OrganonTweaks/Asset/js/enhance-recurrence.js',
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHelpers()
|
public function getHelpers()
|
||||||
@@ -68,7 +76,7 @@ class Plugin extends Base
|
|||||||
|
|
||||||
public function getPluginVersion()
|
public function getPluginVersion()
|
||||||
{
|
{
|
||||||
return '1.2.1';
|
return '1.3.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginHomepage()
|
public function getPluginHomepage()
|
||||||
|
|||||||
14
README.md
14
README.md
@@ -58,6 +58,19 @@ clicks (well under 100 ms) still open cards as usual. The 100 ms threshold is fi
|
|||||||
|
|
||||||
- **On by default.** Toggle it under "Settings -> Organon Tweaks".
|
- **On by default.** Toggle it under "Settings -> Organon Tweaks".
|
||||||
|
|
||||||
|
### Enhance the recurrence dialog
|
||||||
|
|
||||||
|
Kanboard's native "Edit recurrence" dialog is a plain form. This makes two small usability
|
||||||
|
edits when it opens (there is no template hook, so it is done in JS,
|
||||||
|
`Asset/js/enhance-recurrence.js`):
|
||||||
|
|
||||||
|
- the "Generate recurrent task" **Yes/No dropdown** becomes two **radio buttons** (one click
|
||||||
|
to set, instead of open + select). The original select is kept hidden and stays in sync, so
|
||||||
|
the form submits exactly as before.
|
||||||
|
- a small **[+7]** button next to the "Factor" input adds 7 to it (one week of days).
|
||||||
|
|
||||||
|
- **On by default.** Toggle it under "Settings -> Organon Tweaks".
|
||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
|
|
||||||
Global (per Kanboard instance) and admin-only, under "Settings -> Organon Tweaks":
|
Global (per Kanboard instance) and admin-only, under "Settings -> Organon Tweaks":
|
||||||
@@ -65,6 +78,7 @@ Global (per Kanboard instance) and admin-only, under "Settings -> Organon Tweaks
|
|||||||
- **Always show the comment icon on board cards** -- default on.
|
- **Always show the comment icon on board cards** -- default on.
|
||||||
- **Keep the board scroll position across refreshes** -- default on.
|
- **Keep the board scroll position across refreshes** -- default on.
|
||||||
- **Open a card only on a quick click** -- default on.
|
- **Open a card only on a quick click** -- default on.
|
||||||
|
- **Enhance the recurrence dialog** -- default on.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,13 @@
|
|||||||
</p>
|
</p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<?= $this->form->checkbox('organon_tweaks_enhance_recurrence', t('Enhance the recurrence dialog'), 1, isset($values['organon_tweaks_enhance_recurrence']) && $values['organon_tweaks_enhance_recurrence'] == 1) ?>
|
||||||
|
<p class="form-help">
|
||||||
|
<?= t('In the native "Edit recurrence" dialog, replace the Generate recurrent task dropdown with Yes/No radio buttons (one click), and add a [+7] button next to the factor that adds 7 (one week of days).') ?>
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
|
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user