Build a tag cloud from task categories
This commit is contained in:
parent
1809ed09f1
commit
a0999aae17
5 changed files with 57 additions and 6 deletions
|
@ -34,7 +34,7 @@
|
|||
width: 15px;
|
||||
}
|
||||
|
||||
#selectorbox {
|
||||
#tagsbox {
|
||||
position: absolute;
|
||||
top: 42px;
|
||||
left: 0;
|
||||
|
@ -42,6 +42,19 @@
|
|||
height: 242px;
|
||||
}
|
||||
|
||||
#tagslist {
|
||||
padding: 0;
|
||||
margin: 6px 8px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
#tagslist li {
|
||||
display: inline-block;
|
||||
color: #004458;
|
||||
padding: 0.2em 1em 0.2em 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#tasklistsbox {
|
||||
position: absolute;
|
||||
top: 300px;
|
||||
|
|
|
@ -14,9 +14,10 @@
|
|||
<roundcube:container name="toolbar" id="taskstoolbar" />
|
||||
</div>
|
||||
|
||||
<div id="selectorbox" class="uibox listbox">
|
||||
<div id="tagsbox" class="uibox listbox">
|
||||
<h2 class="boxtitle"><roundcube:label name="tasklist.tags" id="taglist" /></h2>
|
||||
<div class="scroller">
|
||||
<h2 class="boxtitle"><roundcube:label name="tasklist.tags" /></h2>
|
||||
<roundcube:object name="plugin.tagslist" id="tagslist" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ function rcube_tasklist(settings)
|
|||
var ui_loading;
|
||||
var taskcounts = {};
|
||||
var listdata = {};
|
||||
var tags = [];
|
||||
var draghelper;
|
||||
var completeness_slider;
|
||||
var search_request;
|
||||
|
@ -140,7 +141,18 @@ function rcube_tasklist(settings)
|
|||
this.reset();
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
// click-handler on tags list
|
||||
$(rcmail.gui_objects.tagslist).click(function(e){
|
||||
if (e.target.nodeName != 'LI')
|
||||
return;
|
||||
|
||||
var item = $(e.target),
|
||||
tag = item.data('value');
|
||||
|
||||
alert(tag);
|
||||
});
|
||||
|
||||
// click-handler on task list items (delegate)
|
||||
$(rcmail.gui_objects.resultlist).click(function(e){
|
||||
var item = $(e.target);
|
||||
|
@ -316,6 +328,20 @@ function rcube_tasklist(settings)
|
|||
listdata[response.data[i].id] = response.data[i];
|
||||
}
|
||||
|
||||
// find new tags
|
||||
var newtags = [];
|
||||
for (var i=0; i < response.tags.length; i++) {
|
||||
if (tags.indexOf(response.tags[i]) < 0)
|
||||
newtags.push(response.tags[i]);
|
||||
}
|
||||
tags = tags.concat(newtags);
|
||||
|
||||
// append new tags to tag cloud
|
||||
var taglist = $(rcmail.gui_objects.tagslist);
|
||||
$.each(newtags, function(i, tag){
|
||||
$('<li>').attr('rel', tag).data('value', tag).html(Q(tag)).appendTo(taglist);
|
||||
});
|
||||
|
||||
render_tasklist();
|
||||
rcmail.set_busy(false, 'loading', ui_loading);
|
||||
}
|
||||
|
|
|
@ -372,12 +372,14 @@ class tasklist extends rcube_plugin
|
|||
|
||||
}
|
||||
|
||||
$data = $this->task_tree = $this->task_titles = array();
|
||||
$data = $tags = $this->task_tree = $this->task_titles = array();
|
||||
foreach ($this->driver->list_tasks($filter, $lists) as $rec) {
|
||||
if ($rec['parent_id']) {
|
||||
$this->task_tree[$rec['id']] = $rec['parent_id'];
|
||||
}
|
||||
$this->encode_task($rec);
|
||||
if (!empty($rec['categories']))
|
||||
$tags = array_merge($tags, (array)$rec['categories']);
|
||||
|
||||
// apply filter; don't trust the driver on this :-)
|
||||
if ((!$f && $rec['complete'] < 1.0) || ($rec['mask'] & $f))
|
||||
|
@ -387,7 +389,7 @@ class tasklist extends rcube_plugin
|
|||
// sort tasks according to their hierarchy level and due date
|
||||
usort($data, array($this, 'task_sort_cmp'));
|
||||
|
||||
$this->rc->output->command('plugin.data_ready', array('filter' => $f, 'lists' => $lists, 'data' => $data));
|
||||
$this->rc->output->command('plugin.data_ready', array('filter' => $f, 'lists' => $lists, 'data' => $data, 'tags' => array_unique($tags)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -68,6 +68,7 @@ class tasklist_ui
|
|||
$this->plugin->register_handler('plugin.quickaddform', array($this, 'quickadd_form'));
|
||||
$this->plugin->register_handler('plugin.tasklist_editform', array($this, 'tasklist_editform'));
|
||||
$this->plugin->register_handler('plugin.tasks', array($this, 'tasks_resultview'));
|
||||
$this->plugin->register_handler('plugin.tagslist', array($this, 'tagslist'));
|
||||
|
||||
$this->plugin->include_script('tasklist.js');
|
||||
|
||||
|
@ -206,5 +207,13 @@ class tasklist_ui
|
|||
return html::tag('ul', $attrib, '');
|
||||
}
|
||||
|
||||
function tagslist($attrib)
|
||||
{
|
||||
$attrib += array('id' => 'rcmtagslist');
|
||||
unset($attrib['name']);
|
||||
|
||||
$this->rc->output->add_gui_object('tagslist', $attrib['id']);
|
||||
return html::tag('ul', $attrib, '');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue