Save collapsed state of tasks; don't re-append already placed task nodes to parent
This commit is contained in:
parent
d02e5b6964
commit
6176b6d428
2 changed files with 24 additions and 2 deletions
|
@ -227,6 +227,7 @@ function rcube_tasklist_ui(settings)
|
|||
rec.collapsed = !rec.collapsed;
|
||||
li.children('.childtasks:first').toggle();
|
||||
$(e.target).toggleClass('collapsed').html(rec.collapsed ? '▶' : '▼');
|
||||
rcmail.http_post('tasks/task', { action:'collapse', t:{ id:rec.id, list:rec.list }, collapsed:rec.collapsed?1:0 });
|
||||
break;
|
||||
|
||||
case 'complete':
|
||||
|
@ -620,10 +621,11 @@ function rcube_tasklist_ui(settings)
|
|||
if ((rec.mask & FILTER_MASK_OVERDUE))
|
||||
div.addClass('overdue');
|
||||
|
||||
var li, parent = rec.parent_id ? $('li[rel="'+rec.parent_id+'"] > ul.childtasks', rcmail.gui_objects.resultlist) : null;
|
||||
var li, inplace = false, parent = rec.parent_id ? $('li[rel="'+rec.parent_id+'"] > ul.childtasks', rcmail.gui_objects.resultlist) : null;
|
||||
if (replace && (li = $('li[rel="'+replace+'"]', rcmail.gui_objects.resultlist)) && li.length) {
|
||||
li.children('div.taskhead').first().replaceWith(div);
|
||||
li.attr('rel', rec.id);
|
||||
inplace = true;
|
||||
}
|
||||
else {
|
||||
li = $('<li>')
|
||||
|
@ -637,7 +639,7 @@ function rcube_tasklist_ui(settings)
|
|||
li.appendTo(rcmail.gui_objects.resultlist);
|
||||
}
|
||||
|
||||
if (parent && parent.length)
|
||||
if (!inplace && parent && parent.length)
|
||||
li.appendTo(parent);
|
||||
|
||||
if (replace) {
|
||||
|
|
|
@ -53,6 +53,8 @@ class tasklist extends rcube_plugin
|
|||
public $timezone;
|
||||
public $ui;
|
||||
|
||||
private $collapsed_tasks = array();
|
||||
|
||||
|
||||
/**
|
||||
* Plugin initialization.
|
||||
|
@ -87,6 +89,8 @@ class tasklist extends rcube_plugin
|
|||
$this->register_action('mail2task', array($this, 'mail_message2task'));
|
||||
$this->register_action('get-attachment', array($this, 'attachment_get'));
|
||||
$this->register_action('upload', array($this, 'attachment_upload'));
|
||||
|
||||
$this->collapsed_tasks = array_filter(explode(',', $this->rc->config->get('tasklist_collapsed_tasks', '')));
|
||||
}
|
||||
else if ($this->rc->task == 'mail') {
|
||||
// TODO: register hooks to catch ical/vtodo email attachments
|
||||
|
@ -202,6 +206,19 @@ class tasklist extends rcube_plugin
|
|||
if ($success = $this->driver->undelete_task($rec))
|
||||
$refresh = $this->driver->get_task($rec);
|
||||
break;
|
||||
|
||||
case 'collapse':
|
||||
if ($collapsed = intval(get_input_value('collapsed', RCUBE_INPUT_GPC))) {
|
||||
$this->collapsed_tasks[] = $rec['id'];
|
||||
}
|
||||
else {
|
||||
$i = array_search($rec['id'], $this->collapsed_tasks);
|
||||
if ($i !== false)
|
||||
unset($this->collapsed_tasks[$i]);
|
||||
}
|
||||
|
||||
$this->rc->user->save_prefs(array('tasklist_collapsed_tasks' => join(',', array_unique($this->collapsed_tasks))));
|
||||
return; // avoid further actions
|
||||
}
|
||||
|
||||
if ($success) {
|
||||
|
@ -544,6 +561,9 @@ class tasklist extends rcube_plugin
|
|||
$rec['attachments'][$k]['classname'] = rcmail_filetype2classname($attachment['mimetype'], $attachment['name']);
|
||||
}
|
||||
|
||||
if (in_array($rec['id'], $this->collapsed_tasks))
|
||||
$rec['collapsed'] = true;
|
||||
|
||||
$this->task_titles[$rec['id']] = $rec['title'];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue