Reload task view after renaming folders

This commit is contained in:
Thomas Bruederli 2014-04-09 12:05:56 +02:00
parent f6f7b710b3
commit 85014df70b
4 changed files with 27 additions and 8 deletions

View file

@ -103,7 +103,7 @@ class tasklist_database_driver extends tasklist_driver
* @return mixed ID of the new list on success, False on error * @return mixed ID of the new list on success, False on error
* @see tasklist_driver::create_list() * @see tasklist_driver::create_list()
*/ */
public function create_list($prop) public function create_list(&$prop)
{ {
$result = $this->rc->db->query( $result = $this->rc->db->query(
"INSERT INTO " . $this->db_lists . " "INSERT INTO " . $this->db_lists . "
@ -128,7 +128,7 @@ class tasklist_database_driver extends tasklist_driver
* @return boolean True on success, Fales on failure * @return boolean True on success, Fales on failure
* @see tasklist_driver::edit_list() * @see tasklist_driver::edit_list()
*/ */
public function edit_list($prop) public function edit_list(&$prop)
{ {
$query = $this->rc->db->query( $query = $this->rc->db->query(
"UPDATE " . $this->db_lists . " "UPDATE " . $this->db_lists . "

View file

@ -173,7 +173,7 @@ class tasklist_kolab_driver extends tasklist_driver
* showalarms: True if alarms are enabled * showalarms: True if alarms are enabled
* @return mixed ID of the new list on success, False on error * @return mixed ID of the new list on success, False on error
*/ */
public function create_list($prop) public function create_list(&$prop)
{ {
$prop['type'] = 'task' . ($prop['default'] ? '.default' : ''); $prop['type'] = 'task' . ($prop['default'] ? '.default' : '');
$prop['active'] = true; // activate folder by default $prop['active'] = true; // activate folder by default
@ -196,6 +196,10 @@ class tasklist_kolab_driver extends tasklist_driver
if ($prefs['kolab_tasklists'][$id]) if ($prefs['kolab_tasklists'][$id])
$this->rc->user->save_prefs($prefs); $this->rc->user->save_prefs($prefs);
// force page reload to properly render folder hierarchy
if (!empty($prop['parent']))
$prop['_reload'] = true;
return $id; return $id;
} }
@ -209,7 +213,7 @@ class tasklist_kolab_driver extends tasklist_driver
* showalarms: True if alarms are enabled (if supported) * showalarms: True if alarms are enabled (if supported)
* @return boolean True on success, Fales on failure * @return boolean True on success, Fales on failure
*/ */
public function edit_list($prop) public function edit_list(&$prop)
{ {
if ($prop['id'] && ($folder = $this->folders[$prop['id']])) { if ($prop['id'] && ($folder = $this->folders[$prop['id']])) {
$prop['oldname'] = $folder->name; $prop['oldname'] = $folder->name;
@ -234,6 +238,10 @@ class tasklist_kolab_driver extends tasklist_driver
if ($prefs['kolab_tasklists'][$id]) if ($prefs['kolab_tasklists'][$id])
$this->rc->user->save_prefs($prefs); $this->rc->user->save_prefs($prefs);
// force page reload if folder name/hierarchy changed
if ($newfolder != $prop['oldname'])
$prop['_reload'] = true;
return $id; return $id;
} }

View file

@ -75,7 +75,7 @@ abstract class tasklist_driver
* showalarms: True if alarms are enabled * showalarms: True if alarms are enabled
* @return mixed ID of the new list on success, False on error * @return mixed ID of the new list on success, False on error
*/ */
abstract function create_list($prop); abstract function create_list(&$prop);
/** /**
* Update properties of an existing tasklist * Update properties of an existing tasklist
@ -87,7 +87,7 @@ abstract class tasklist_driver
* showalarms: True if alarms are enabled (if supported) * showalarms: True if alarms are enabled (if supported)
* @return boolean True on success, Fales on failure * @return boolean True on success, Fales on failure
*/ */
abstract function edit_list($prop); abstract function edit_list(&$prop);
/** /**
* Set active/subscribed state of a list * Set active/subscribed state of a list

View file

@ -1749,6 +1749,11 @@ function rcube_tasklist_ui(settings)
*/ */
function insert_list(prop) function insert_list(prop)
{ {
if (prop._reload) {
rcmail.redirect(rcmail.url(''));
return;
}
var li = $('<li>').attr('id', 'rcmlitasklist'+prop.id) var li = $('<li>').attr('id', 'rcmlitasklist'+prop.id)
.append('<input type="checkbox" name="_list[]" value="'+prop.id+'" checked="checked" />') .append('<input type="checkbox" name="_list[]" value="'+prop.id+'" checked="checked" />')
.append('<span class="handle">&nbsp;</span>') .append('<span class="handle">&nbsp;</span>')
@ -1766,11 +1771,17 @@ function rcube_tasklist_ui(settings)
var id = prop.oldid || prop.id, var id = prop.oldid || prop.id,
li = rcmail.get_folder_li(id, 'rcmlitasklist'); li = rcmail.get_folder_li(id, 'rcmlitasklist');
if (prop._reload) {
rcmail.redirect(rcmail.url(''));
return;
}
if (me.tasklists[id] && li) { if (me.tasklists[id] && li) {
delete me.tasklists[id]; delete me.tasklists[id];
me.tasklists[prop.id] = prop; me.tasklists[prop.id] = prop;
$(li).data('id', prop.id); $(li).data('id', prop.id)
$('#'+li.id+' input').data('id', prop.id); .attr('id', 'rcmlitasklist'+prop.id)
.find('input').data('id', prop.id);
$('.listname', li).html(Q(prop.name)); $('.listname', li).html(Q(prop.name));
} }
} }