Merge pull request #134 from cosmocode/approve

Approve plugin in Page Attributes box
This commit is contained in:
Anna Dabrowska 2026-02-18 14:03:22 +01:00 committed by GitHub
commit 93e6d14cca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 101 additions and 36 deletions

View file

@ -1,7 +1,36 @@
/** /**
* This file provides styles for approve plugin * This file provides styles for approve plugin
*/ */
#plugin__approve {
position: static; .page-attributes > li #plugin__approve {
display: inline; display: none;
}
@media screen {
#plugin__approve {
display: none; // initial
padding: 2rem 1rem;
clear: both;
}
span.plugin_approve-icon.plugin__approve_draft {
background-color: #fdb1b1;
&:hover {
background-color: unset;
}
}
span.plugin_approve-icon.plugin__approve_ready {
background-color: #94bffb;
&:hover {
background-color: unset;
}
}
span.plugin_approve-icon.plugin__approve_approved {
background-color: #94fb94;
&:hover {
background-color: unset;
}
}
} }

View file

@ -557,3 +557,13 @@ form {
border: 1pt solid @border-dark-print; border: 1pt solid @border-dark-print;
} }
} }
/*
* Plugins
*/
/* * * * approve * * * */
#plugin__approve {
// we hide the banner with JS, make it visible again in print
display: block !important;
}

21
js/plugins/approve.js Normal file
View file

@ -0,0 +1,21 @@
/**
* Approve plugin banner
*/
jQuery(function () {
const $icon = jQuery('span.plugin_approve-icon');
const $metaBox = jQuery('#spr__meta-box');
const $banner = jQuery('#plugin__approve');
const title = $banner.find('strong').text();
$icon.addClass($banner.attr('class'));
$icon.attr('title', title);
// anchor to the sprintdoc meta box
$metaBox.after($banner);
$icon.click(function (e) {
e.preventDefault();
$banner.dw_toggle();
});
});

View file

@ -15,6 +15,9 @@ if (!defined('DOKU_INC')) die(); /* must be run from with
header('X-UA-Compatible: IE=edge,chrome=1'); header('X-UA-Compatible: IE=edge,chrome=1');
global $JSINFO; global $JSINFO;
global $conf;
global $lang;
if (empty($JSINFO['template'])) { if (empty($JSINFO['template'])) {
$JSINFO['template'] = array(); $JSINFO['template'] = array();
} }

View file

@ -1,3 +1,4 @@
/* DOKUWIKI:include js/plugins/approve.js */
/* DOKUWIKI:include js/plugins/do_tasks.js */ /* DOKUWIKI:include js/plugins/do_tasks.js */
/* DOKUWIKI:include js/plugins/qc.js */ /* DOKUWIKI:include js/plugins/qc.js */
/* DOKUWIKI:include js/plugins/bookcreator.js */ /* DOKUWIKI:include js/plugins/bookcreator.js */

View file

@ -1,4 +1,5 @@
<?php <?php
if (!defined('DOKU_INC')) die(); if (!defined('DOKU_INC')) die();
/** @var \helper_plugin_do $doPlugin */ /** @var \helper_plugin_do $doPlugin */
@ -12,24 +13,23 @@ $quickSubPlugin = plugin_load('helper', 'quicksubscribe');
/** @var \helper_plugin_approve_tpl $approvePlugin */ /** @var \helper_plugin_approve_tpl $approvePlugin */
$approvePlugin = plugin_load('helper', 'approve_tpl'); $approvePlugin = plugin_load('helper', 'approve_tpl');
if($doPlugin !== null || $qcPlugin !== null || $starredPlugin !== null) { $items = [];
echo '<ul class="page-attributes">';
}
if ($qcPlugin && $qcPlugin->shouldShow()) { if ($qcPlugin && $qcPlugin->shouldShow()) {
$qcPrefix = tpl_getLang('quality_trigger'); $qcPrefix = tpl_getLang('quality_trigger');
echo '<li class="plugin_qc"><strong class="sr-out">'.$qcPrefix.':</strong><a href="#"></a></li>'; // filled by javascript // filled by javascript
$items[] = '<li class="plugin_qc"><strong class="sr-out">' . hsc($qcPrefix) . ':</strong><a href="#"></a></li>';
} }
if ($doPlugin !== null) { if ($doPlugin !== null) {
$count = $doPlugin->getPageTaskCount(); $count = $doPlugin->getPageTaskCount();
$num = $count['count']; $num = (int) $count['count'];
$title = ""; $title = '';
if ($num == 0) { // no tasks - does not exist do in plug-in if ($num == 0) { // no tasks - does not exist do in plug-in
$class = "do_none"; $class = 'do_none';
$title = tpl_getLang('tasks_page_none'); $title = tpl_getLang('tasks_page_none');
} elseif ($count['undone'] == 0) { // all tasks done } elseif ($count['undone'] == 0) { // all tasks done
$class = 'do_done'; $class = 'do_done';
@ -42,31 +42,32 @@ if($doPlugin !== null) {
$title = sprintf(tpl_getLang('tasks_page_late'), $count['undone'], $count['late']); $title = sprintf(tpl_getLang('tasks_page_late'), $count['undone'], $count['late']);
} }
echo '<li class="plugin_do_pagetasks">'; $items[] = '<li class="plugin_do_pagetasks">' .
echo '<span title="'.$title.'" class="'.$class.'">'; '<span title="' . hsc($title) . '" class="' . $class . '">' .
echo inlineSVG(DOKU_PLUGIN . 'do/pix/clipboard-text.svg'); inlineSVG(DOKU_PLUGIN . 'do/pix/clipboard-text.svg') .
echo '</span>'; '</span>' .
echo '<span class="num">' . $count['undone'] . '</span>'; '<span class="num">' . (int) $count['undone'] . '</span>' .
echo '</li>'; '</li>';
} }
if ($starredPlugin !== null) { if ($starredPlugin !== null) {
echo '<li class="plugin_starred">'; $items[] = '<li class="plugin_starred">' . $starredPlugin->tpl_starred(false, false) . '</li>';
$starredPlugin->tpl_starred();
echo '</li>';
} }
if ($quickSubPlugin !== null) { if ($quickSubPlugin !== null) {
echo '<li class="plugin_quicksubscribe">'; $items[] = '<li class="plugin_quicksubscribe">' . $quickSubPlugin->tpl_subscribe() . '</li>';
echo $quickSubPlugin->tpl_subscribe();
echo '</li>';
} }
if($doPlugin !== null || $qcPlugin !== null || $starredPlugin !== null) { if ($approvePlugin !== null && $approvePlugin->shouldDisplay()) {
echo "</ul>";
}
if($approvePlugin !== null) {
global $ACT; global $ACT;
echo $approvePlugin->banner($ACT); $items[] = '<li class="plugin_approve">' .
'<span class="plugin_approve-icon">' . inlineSVG(DOKU_PLUGIN . 'approve/admin.svg') . '</span>' .
'<div class="plugin_approve-banner-content">' .
$approvePlugin->banner($ACT) .
'</div>' .
'</li>';
}
if (!empty($items)) {
echo '<ul class="page-attributes">' . implode('', $items) . '</ul>';
} }