Implement list deletion + minor bugfixes
This commit is contained in:
parent
44635a867d
commit
192bd3942c
6 changed files with 84 additions and 10 deletions
|
@ -175,7 +175,27 @@ class tasklist_database_driver extends tasklist_driver
|
|||
*/
|
||||
public function remove_list($prop)
|
||||
{
|
||||
// TODO: implement this
|
||||
$list_id = $prop['id'];
|
||||
if ($this->lists[$list_id]) {
|
||||
// delete all tasks linked with this list
|
||||
$this->rc->db->query(
|
||||
"DELETE FROM " . $this->db_tasks . "
|
||||
WHERE tasklist_id=?",
|
||||
$lisr_id
|
||||
);
|
||||
|
||||
// delete list record
|
||||
$query = $this->rc->db->query(
|
||||
"DELETE FROM " . $this->db_lists . "
|
||||
WHERE tasklist_id=?
|
||||
AND user_id=?",
|
||||
$list_id,
|
||||
$this->rc->user->ID
|
||||
);
|
||||
|
||||
return $this->rc->db->affected_rows($query);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,3 +60,4 @@ $labels['savingdata'] = 'Daten werden gespeichert...';
|
|||
$labels['errorsaving'] = 'Fehler beim Speichern.';
|
||||
$labels['notasksfound'] = 'Für die aktuellen Kriterien wurden keine Aufgaben gefunden.';
|
||||
$labels['invalidstartduedates'] = 'Beginn der Aufgabe darf nicht grösser als das Enddatum sein.';
|
||||
$labels['deletelistconfirm'] = 'Möchten Sie diese Liste mit allen Aufgaben wirklich löschen?';
|
||||
|
|
|
@ -60,3 +60,4 @@ $labels['savingdata'] = 'Saving data...';
|
|||
$labels['errorsaving'] = 'Failed to save data.';
|
||||
$labels['notasksfound'] = 'No tasks found for the given criteria';
|
||||
$labels['invalidstartduedates'] = 'Start date must not be greater than due date.';
|
||||
$labels['deletelistconfirm'] = 'Do you really want to delete this list with all its tasks?';
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
<ul class="toolbarmenu">
|
||||
<li><roundcube:button command="list-edit" label="edit" classAct="active" /></li>
|
||||
<li><roundcube:button command="list-remove" label="delete" classAct="active" /></li>
|
||||
<li><roundcube:button command="list-import" label="tasklist.import" classAct="active" /></li>
|
||||
<!--<li><roundcube:button command="list-import" label="tasklist.import" classAct="active" /></li>-->
|
||||
<roundcube:if condition="env:tasklist_driver == 'kolab'" />
|
||||
<li><roundcube:button command="folders" task="settings" type="link" label="managefolders" classAct="active" /></li>
|
||||
<roundcube:endif />
|
||||
|
|
|
@ -130,6 +130,7 @@ function rcube_tasklist_ui(settings)
|
|||
rcmail.addEventListener('plugin.update_counts', update_counts);
|
||||
rcmail.addEventListener('plugin.insert_tasklist', insert_list);
|
||||
rcmail.addEventListener('plugin.update_tasklist', update_list);
|
||||
rcmail.addEventListener('plugin.destroy_tasklist', destroy_list);
|
||||
rcmail.addEventListener('plugin.reload_data', function(){ list_tasks(null); });
|
||||
rcmail.addEventListener('plugin.unlock_saving', unlock_saving);
|
||||
|
||||
|
@ -385,6 +386,24 @@ function rcube_tasklist_ui(settings)
|
|||
$('#taskselector li.'+selector).addClass('selected');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all tasks of the given list from the UI
|
||||
*/
|
||||
function remove_tasks(list_id)
|
||||
{
|
||||
// remove all tasks of the given list from index
|
||||
var newindex = $.grep(listindex, function(id, i){
|
||||
return listdata[id] && listdata[id].list != list_id;
|
||||
});
|
||||
|
||||
listindex = newindex;
|
||||
render_tasklist();
|
||||
|
||||
// avoid reloading
|
||||
me.tasklists[list_id].active = false;
|
||||
loadstate.lists = active_lists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback if task data from server is ready
|
||||
*/
|
||||
|
@ -430,6 +449,9 @@ function rcube_tasklist_ui(settings)
|
|||
msgbox.html(rcmail.gettext('notasksfound','tasklist')).show();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function append_tags(taglist)
|
||||
{
|
||||
// find new tags
|
||||
|
@ -699,9 +721,9 @@ function rcube_tasklist_ui(settings)
|
|||
drop_rec = listdata[drop_id];
|
||||
|
||||
// drop target is another list
|
||||
if ($(this).data('type') == 'tasklist') {
|
||||
if (drag_rec && $(this).data('type') == 'tasklist') {
|
||||
var drop_list = me.tasklists[drop_id],
|
||||
from_list = me.tasklists[drop_rec.list];
|
||||
from_list = me.tasklists[drag_rec.list];
|
||||
return drop_id != drag_rec.list && drop_list && drop_list.editable && from_list && from_list.editable;
|
||||
}
|
||||
|
||||
|
@ -1205,8 +1227,30 @@ function rcube_tasklist_ui(settings)
|
|||
function list_remove(id)
|
||||
{
|
||||
var list = me.tasklists[id];
|
||||
if (list && list.editable) {
|
||||
alert('To be implemented')
|
||||
if (list && list.editable && confirm(rcmail.gettext('deletelistconfirm', 'tasklist'))) {
|
||||
saving_lock = rcmail.set_busy(true, 'tasklist.savingdata');
|
||||
rcmail.http_post('tasklist', { action:'remove', l:{ id:list.id } });
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback from server to finally remove the given list
|
||||
*/
|
||||
function destroy_list(prop)
|
||||
{
|
||||
var list = me.tasklists[prop.id],
|
||||
li = rcmail.get_folder_li(prop.id, 'rcmlitasklist');
|
||||
|
||||
if (li) {
|
||||
$(li).remove();
|
||||
}
|
||||
if (list) {
|
||||
list.active = false;
|
||||
// delete me.tasklists[prop.id];
|
||||
unlock_saving();
|
||||
remove_tasks(list.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1220,8 +1264,8 @@ function rcube_tasklist_ui(settings)
|
|||
.append('<span class="handle"> </span>')
|
||||
.append('<span class="listname">'+Q(prop.name)+'</span>');
|
||||
$(rcmail.gui_objects.folderlist).append(li);
|
||||
init_tasklist_li(li.get(0), prop.id);
|
||||
me.tasklists[prop.id] = prop;
|
||||
init_tasklist_li(li.get(0), prop.id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1358,7 +1402,8 @@ function rcube_tasklist_ui(settings)
|
|||
if (me.tasklists[id]) { // add or remove event source on click
|
||||
me.tasklists[id].active = this.checked;
|
||||
fetch_counts();
|
||||
list_tasks(null);
|
||||
if (!this.checked) remove_tasks(id);
|
||||
else list_tasks(null);
|
||||
rcmail.http_post('tasklist', { action:'subscribe', l:{ id:id, active:me.tasklists[id].active?1:0 } });
|
||||
}
|
||||
}).data('id', id).get(0).checked = me.tasklists[id].active || false;
|
||||
|
@ -1366,7 +1411,7 @@ function rcube_tasklist_ui(settings)
|
|||
$(li).click(function(e){
|
||||
var id = $(this).data('id');
|
||||
rcmail.select_folder(id, 'rcmlitasklist');
|
||||
rcmail.enable_command('list-edit', 'list-remove', 'import', me.tasklists[id].editable);
|
||||
rcmail.enable_command('list-edit', 'list-remove', 'list-import', me.tasklists[id].editable);
|
||||
me.selected_list = id;
|
||||
})
|
||||
.dblclick(function(e){
|
||||
|
|
|
@ -143,6 +143,8 @@ class tasklist extends rcube_plugin
|
|||
$this->driver = new $driver_class($this);
|
||||
break;
|
||||
}
|
||||
|
||||
$this->rc->output->set_env('tasklist_driver', $driver_name);
|
||||
}
|
||||
|
||||
|
||||
|
@ -363,7 +365,7 @@ class tasklist extends rcube_plugin
|
|||
|
||||
switch ($action) {
|
||||
case 'new':
|
||||
$list += array('showalarms' => true, 'active' => true);
|
||||
$list += array('showalarms' => true, 'active' => true, 'editable' => true);
|
||||
if ($insert_id = $this->driver->create_list($list)) {
|
||||
$list['id'] = $insert_id;
|
||||
$this->rc->output->command('plugin.insert_tasklist', $list);
|
||||
|
@ -383,6 +385,11 @@ class tasklist extends rcube_plugin
|
|||
case 'subscribe':
|
||||
$success = $this->driver->subscribe_list($list);
|
||||
break;
|
||||
|
||||
case 'remove':
|
||||
if (($success = $this->driver->remove_list($list)))
|
||||
$this->rc->output->command('plugin.destroy_tasklist', $list);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($success)
|
||||
|
|
Loading…
Add table
Reference in a new issue