Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2fff0af063 | |||
| e1e4c36180 |
18
Asset/css/qualkard.css
Normal file
18
Asset/css/qualkard.css
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/* QualKard mastery badge (under the card title on the board). */
|
||||||
|
.qk-line {
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.qk-badge {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0 6px;
|
||||||
|
border-radius: 3px;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 0.85em;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.qk-new { background: #e6b800; } /* unread */
|
||||||
|
.qk-low { background: #c0392b; } /* < 50% */
|
||||||
|
.qk-mid { background: #27ae60; } /* 50-89% */
|
||||||
|
.qk-high { background: #2980b9; } /* >= 90% */
|
||||||
@@ -193,4 +193,18 @@ class QualKardHelper extends Base
|
|||||||
));
|
));
|
||||||
$this->db->table(TaskModel::TABLE)->eq('id', $task_id)->update(array('date_due' => $due));
|
$this->db->table(TaskModel::TABLE)->eq('id', $task_id)->update(array('date_due' => $due));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The mastery badge (label + CSS class) for a card, from its stored average.
|
||||||
|
*
|
||||||
|
* @param int $task_id
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function cardBadge($task_id)
|
||||||
|
{
|
||||||
|
$raw = $this->taskMetadataModel->get($task_id, 'qualkard_avg', '');
|
||||||
|
$avg = ($raw === '' || $raw === null) ? null : (float) $raw;
|
||||||
|
|
||||||
|
return self::badge($avg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,13 @@ class Plugin extends Base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Mastery badge under the card title on the board, plus its stylesheet.
|
||||||
|
$this->template->hook->attach('template:board:private:task:after-title', 'qualKard:board/badge');
|
||||||
|
$this->template->hook->attach('template:board:public:task:after-title', 'qualKard:board/badge');
|
||||||
|
$this->hook->on('template:layout:css', array(
|
||||||
|
'template' => 'plugins/QualKard/Asset/css/qualkard.css',
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHelpers()
|
public function getHelpers()
|
||||||
@@ -74,7 +81,7 @@ class Plugin extends Base
|
|||||||
|
|
||||||
public function getPluginVersion()
|
public function getPluginVersion()
|
||||||
{
|
{
|
||||||
return '0.4.0';
|
return '0.5.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginHomepage()
|
public function getPluginHomepage()
|
||||||
|
|||||||
12
Template/board/badge.php
Normal file
12
Template/board/badge.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
// Mastery badge under the card title on a QualKard board. Server-rendered (survives board refresh).
|
||||||
|
// Yellow "new" for an unread card; otherwise a percent of 5, red (<50) / green (<90) / blue (>=90).
|
||||||
|
if (empty($task['project_id']) || ! $this->QualKardHelper->isEnabled($task['project_id'])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$b = $this->QualKardHelper->cardBadge($task['id']);
|
||||||
|
?>
|
||||||
|
<div class="qk-line">
|
||||||
|
<span class="qk-badge <?= $b['class'] ?>"><?= $this->text->e($b['label']) ?></span>
|
||||||
|
</div>
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
<h3><i class="fa fa-graduation-cap fa-fw" aria-hidden="true"></i> <?= t('QualKard') ?></h3>
|
<h3><i class="fa fa-graduation-cap fa-fw" aria-hidden="true"></i> <?= t('QualKard') ?></h3>
|
||||||
<div class="listing">
|
<div class="listing">
|
||||||
<?php if (! $this->helper->QualKardHelper->hasRecoReco()): ?>
|
<?php if (! $this->QualKardHelper->hasRecoReco()): ?>
|
||||||
|
|
||||||
<p class="form-help"><?= t('QualKard needs the RecoReco plugin (its move engine). Install RecoReco to use QualKard.') ?></p>
|
<p class="form-help"><?= t('QualKard needs the RecoReco plugin (its move engine). Install RecoReco to use QualKard.') ?></p>
|
||||||
|
|
||||||
<?php elseif (! $this->helper->QualKardHelper->isEnabled($project['id'])): ?>
|
<?php elseif (! $this->QualKardHelper->isEnabled($project['id'])): ?>
|
||||||
|
|
||||||
<p class="form-help"><?= t('Turn this project into a spaced-repetition study board. This restructures the columns to Drafts | Study | Hairy | Hard | Medium | Easy | Done and moves every card to Drafts.') ?></p>
|
<p class="form-help"><?= t('Turn this project into a spaced-repetition study board. This restructures the columns to Drafts | Study | Hairy | Hard | Medium | Easy | Done and moves every card to Drafts.') ?></p>
|
||||||
<form method="post" action="<?= $this->url->href('QualKardController', 'setup', array('plugin' => 'QualKard', 'project_id' => $project['id'])) ?>" onsubmit="return confirm('<?= t('This restructures the board and moves all cards to Drafts. Continue?') ?>');">
|
<form method="post" action="<?= $this->url->href('QualKardController', 'setup', array('plugin' => 'QualKard', 'project_id' => $project['id'])) ?>" onsubmit="return confirm('<?= t('This restructures the board and moves all cards to Drafts. Continue?') ?>');">
|
||||||
|
|||||||
Reference in New Issue
Block a user