Deleting/undeleting series event from list view now asks series or exception

This commit is contained in:
Nathan Gray 2013-01-16 22:44:01 +00:00
parent 022f9eb479
commit 7104001693
4 changed files with 131 additions and 9 deletions

View File

@ -559,7 +559,7 @@ class calendar_uilist extends calendar_ui
{
$timesheet_bo = new timesheet_bo();
}
foreach($checked as $id)
foreach($checked as &$id)
{
$recur_date = $app = $app_id = null;
if(is_array($id) && $id['id'])
@ -580,9 +580,26 @@ class calendar_uilist extends calendar_ui
{
case 'delete':
$action_msg = lang('deleted');
if($settings == 'series')
{
// Delete the whole thing
$recur_date = 0;
}
if ($id && $this->bo->delete($id, $recur_date,false,$skip_notification))
{
$success++;
if(!$recur_date && $settings == 'series')
{
// If there are multiple events in a series selected, the next one could purge
foreach($checked as $key => $c_id)
{
list($c_id,$recur_date) = explode(':',$c_id);
if($c_id == $id)
{
unset($checked[$key]);
}
}
}
}
else
{
@ -591,6 +608,11 @@ class calendar_uilist extends calendar_ui
break;
case 'undelete':
$action_msg = lang('recovered');
if($settings == 'series')
{
// unDelete the whole thing
$recur_date = 0;
}
if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(EGW_ACL_EDIT,$id) &&
is_array($event) && $event['deleted'])
{
@ -834,6 +856,7 @@ class calendar_uilist extends calendar_ui
'caption' => 'Delete',
'confirm' => 'Delete this event',
'confirm_multiple' => 'Delete these entries',
'onExecute' => 'javaScript:cal_delete',
'group' => $group,
'disableClass' => 'rowNoDelete',
);
@ -842,6 +865,7 @@ class calendar_uilist extends calendar_ui
{
$actions['undelete'] = array(
'caption' => 'Un-delete',
'onExecute' => 'javaScript:cal_delete',
'icon' => 'revert',
'hint' => 'Recover this event',
'group' => $group,

View File

@ -82,4 +82,66 @@ function cal_open(_action, _senders)
nm_action(_action, _senders);
_action.data = backup; // restore url, width, height, nm_action
}
}
/**
* Delete calendar entry, asking if you want to delete series or exception
*
*
* @param _action
* @param _senders
*/
function cal_delete(_action, _senders)
{
var backup = _action.data;
var matches = false;
// Loop so we ask if any of the selected entries is part of a series
for(var i = 0; i < _senders.length; i++)
{
var id = _senders[i].id;
if(!matches)
{
matches = id.match(/^(?:calendar::)?([0-9]+):([0-9]+)$/);
}
}
if (matches)
{
var id = matches[1];
var date = matches[2];
var popup = jQuery(document.getElementById(_action.getManager().etemplate_var_prefix + '[' + _action.id + '_popup]'));
var row = null;
// Cancel normal confirm
delete _action.data.confirm;
delete _action.data.confirm_multiple;
// nm action - show popup
nm_open_popup(_action,_senders);
if(!popup)
{
return;
}
if (row = jQuery("#"+id+"\\:"+date)) {
// Open at row
popup.css({
position: "absolute",
top: row.position().top + row.height() -popup.height()/2,
left: $j(window).width()/2-popup.width()/2
});
} else {
// Open popup in the middle
popup.css({
position: "absolute",
top: $j(window).height()/2-popup.height()/2,
left: $j(window).width()/2-popup.width()/2
});
}
return;
}
console.log(_action);
nm_action(_action, _senders, null, {ids: []});
_action.data = backup; // restore url, width, height, nm_action
}

View File

@ -2,7 +2,7 @@
/**
* EGroupware - eTemplates for Application calendar
* http://www.egroupware.org
* generated by soetemplate::dump4setup() 2012-10-17 10:28
* generated by soetemplate::dump4setup() 2013-01-14 10:19
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package calendar
@ -55,7 +55,7 @@ $templ_data[] = array('name' => 'calendar.freetimesearch.rows','template' => '',
$templ_data[] = array('name' => 'calendar.import','template' => '','lang' => '','group' => '0','version' => '1.0.1.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:5:{i:0;a:0:{}i:1;a:2:{s:1:"A";a:5:{s:4:"type";s:5:"label";s:4:"span";s:13:"all,redItalic";s:4:"name";s:3:"msg";s:7:"no_lang";s:1:"1";s:5:"align";s:6:"center";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:9:"iCal file";}s:1:"B";a:3:{s:4:"type";s:4:"file";s:4:"name";s:9:"ical_file";s:6:"needed";s:1:"1";}}i:3;a:2:{s:1:"A";a:1:{s:4:"type";s:5:"label";}s:1:"B";a:3:{s:4:"type";s:6:"button";s:5:"label";s:6:"Import";s:4:"name";s:6:"import";}}i:4;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:4:"span";s:3:"all";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:4;s:4:"cols";i:2;s:5:"align";s:6:"center";s:7:"options";a:0:{}}}','size' => '','style' => '','modified' => '1131469789',);
$templ_data[] = array('name' => 'calendar.list','template' => '','lang' => '','group' => '0','version' => '1.9.002','data' => 'a:1:{i:0;a:5:{s:4:"type";s:4:"grid";s:4:"data";a:5:{i:0;a:5:{s:2:"h2";s:6:",!@msg";s:2:"h1";s:6:",!@css";s:2:"c4";s:7:"noPrint";s:1:"B";s:3:"30%";s:2:"h4";s:34:",!@nm[selectcols]=/legacy_actions/";}i:1;a:2:{s:1:"A";a:1:{s:4:"type";s:5:"label";}s:1:"B";a:3:{s:4:"type";s:4:"html";s:4:"span";s:3:"all";s:4:"name";s:3:"css";}}i:2;a:2:{s:1:"A";a:5:{s:5:"align";s:6:"center";s:7:"no_lang";s:1:"1";s:4:"name";s:3:"msg";s:4:"type";s:5:"label";s:4:"span";s:13:"all,redItalic";}s:1:"B";a:5:{s:5:"align";s:6:"center";s:7:"no_lang";s:1:"1";s:4:"name";s:3:"msg";s:4:"type";s:5:"label";s:4:"span";s:10:",redItalic";}}i:3;a:2:{s:1:"A";a:4:{s:4:"name";s:2:"nm";s:4:"size";s:18:"calendar.list.rows";s:4:"type";s:9:"nextmatch";s:4:"span";s:3:"all";}s:1:"B";a:3:{s:4:"name";s:2:"nm";s:4:"size";s:18:"calendar.list.rows";s:4:"type";s:9:"nextmatch";}}i:4;a:2:{s:1:"A";a:1:{s:4:"type";s:5:"label";}s:1:"B";a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:5:{s:5:"label";s:13:"Select action";s:7:"onclick";s:183:"if (!egw_globalObjectManager.getObjectById(\'calendar.list.rows\').executeActionImplementation(this, \'popup\')) alert(egw::lang(\'You need to select some entries first!\')); return false;;";s:4:"name";s:14:"legacy_actions";s:4:"type";s:10:"buttononly";s:4:"help";s:13:"Select action";}i:2;a:8:{s:5:"label";s:9:"Check all";s:7:"onclick";s:94:"egw_globalObjectManager.getObjectById(\'calendar.list.rows\').toggleAllSelected(); return false;";s:6:"needed";s:1:"1";s:4:"name";s:9:"check_all";s:4:"type";s:6:"button";s:4:"size";s:9:"arrow_ltr";s:4:"help";s:9:"Check all";s:4:"span";s:14:",checkAllArrow";}s:5:"align";s:5:"right";}}}s:4:"cols";i:2;s:4:"rows";i:4;s:4:"size";s:4:"100%";}}','size' => '100%','style' => '.noWrap { white-space: nowrap; }
$templ_data[] = array('name' => 'calendar.list','template' => '','lang' => '','group' => '0','version' => '1.9.003','data' => 'a:1:{i:0;a:5:{s:4:"type";s:4:"grid";s:4:"data";a:7:{i:0;a:5:{s:2:"h2";s:6:",!@msg";s:2:"h1";s:6:",!@css";s:2:"c4";s:7:"noPrint";s:1:"B";s:3:"30%";s:2:"h4";s:34:",!@nm[selectcols]=/legacy_actions/";}i:1;a:2:{s:1:"A";a:1:{s:4:"type";s:5:"label";}s:1:"B";a:3:{s:4:"type";s:4:"html";s:4:"span";s:3:"all";s:4:"name";s:3:"css";}}i:2;a:2:{s:1:"A";a:5:{s:5:"align";s:6:"center";s:7:"no_lang";s:1:"1";s:4:"name";s:3:"msg";s:4:"type";s:5:"label";s:4:"span";s:13:"all,redItalic";}s:1:"B";a:5:{s:5:"align";s:6:"center";s:7:"no_lang";s:1:"1";s:4:"name";s:3:"msg";s:4:"type";s:5:"label";s:4:"span";s:10:",redItalic";}}i:3;a:2:{s:1:"A";a:4:{s:4:"name";s:2:"nm";s:4:"size";s:18:"calendar.list.rows";s:4:"type";s:9:"nextmatch";s:4:"span";s:3:"all";}s:1:"B";a:3:{s:4:"name";s:2:"nm";s:4:"size";s:18:"calendar.list.rows";s:4:"type";s:9:"nextmatch";}}i:4;a:2:{s:1:"A";a:1:{s:4:"type";s:5:"label";}s:1:"B";a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:5:{s:5:"label";s:13:"Select action";s:7:"onclick";s:183:"if (!egw_globalObjectManager.getObjectById(\'calendar.list.rows\').executeActionImplementation(this, \'popup\')) alert(egw::lang(\'You need to select some entries first!\')); return false;;";s:4:"name";s:14:"legacy_actions";s:4:"type";s:10:"buttononly";s:4:"help";s:13:"Select action";}i:2;a:8:{s:5:"label";s:9:"Check all";s:7:"onclick";s:94:"egw_globalObjectManager.getObjectById(\'calendar.list.rows\').toggleAllSelected(); return false;";s:6:"needed";s:1:"1";s:4:"name";s:9:"check_all";s:4:"type";s:6:"button";s:4:"size";s:9:"arrow_ltr";s:4:"help";s:9:"Check all";s:4:"span";s:14:",checkAllArrow";}s:5:"align";s:5:"right";}}i:5;a:2:{s:1:"A";a:6:{s:5:"class";s:12:"action_popup";s:4:"name";s:12:"delete_popup";s:4:"type";s:3:"box";s:4:"size";s:1:"1";i:1;a:6:{s:5:"class";s:6:"prompt";s:4:"type";s:4:"vbox";s:4:"size";s:1:"3";i:1;a:3:{s:4:"type";s:5:"label";s:5:"label";s:6:"Delete";s:4:"span";s:13:",promptheader";}i:2;a:2:{s:4:"type";s:5:"label";s:5:"label";s:77:"Do you want to delete this event as an exception, or delete the whole series?";}i:3;a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";i:1;a:4:{s:5:"label";s:16:"Delete exception";s:7:"onclick";s:36:"nm_submit_popup(this); return false;";s:4:"name";s:6:"delete";s:4:"type";s:6:"button";}i:2;a:4:{s:5:"label";s:13:"Delete series";s:7:"onclick";s:74:"nm_popup_action.id = \'delete_series\'; nm_submit_popup(this); return false;";s:4:"name";s:13:"delete_series";s:4:"type";s:6:"button";}i:3;a:3:{s:5:"label";s:6:"Cancel";s:7:"onclick";s:35:"nm_hide_popup(this,\'delete_popup\');";s:4:"type";s:10:"buttononly";}}}s:4:"span";s:20:",action_popup prompt";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:6;a:2:{s:1:"A";a:6:{s:5:"class";s:12:"action_popup";s:4:"name";s:14:"undelete_popup";s:4:"type";s:3:"box";s:4:"size";s:1:"1";i:1;a:6:{s:5:"class";s:6:"prompt";s:4:"type";s:4:"vbox";s:4:"size";s:1:"3";i:1;a:3:{s:4:"type";s:5:"label";s:5:"label";s:9:"Un-delete";s:4:"span";s:13:",promptheader";}i:2;a:2:{s:4:"type";s:5:"label";s:5:"label";s:83:"Do you want to Un-delete this event as an exception, or un-delete the whole series?";}i:3;a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";i:1;a:4:{s:5:"label";s:19:"Un-delete exception";s:7:"onclick";s:36:"nm_submit_popup(this); return false;";s:4:"name";s:8:"undelete";s:4:"type";s:6:"button";}i:2;a:4:{s:5:"label";s:16:"Un-delete series";s:7:"onclick";s:76:"nm_popup_action.id = \'undelete_series\'; nm_submit_popup(this); return false;";s:4:"name";s:15:"undelete_series";s:4:"type";s:6:"button";}i:3;a:3:{s:5:"label";s:6:"Cancel";s:7:"onclick";s:37:"nm_hide_popup(this,\'undelete_popup\');";s:4:"type";s:10:"buttononly";}}}s:4:"span";s:20:",action_popup prompt";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"cols";i:2;s:4:"rows";i:6;s:4:"size";s:4:"100%";}}','size' => '100%','style' => '.noWrap { white-space: nowrap; }
.image16 img {
height: 16px;
@ -63,7 +63,11 @@ $templ_data[] = array('name' => 'calendar.list','template' => '','lang' => '','g
.listVbox {
width: 100%;
}','modified' => '1299691693',);
}
.action_popup {
display:none;
}','modified' => '1357766044',);
$templ_data[] = array('name' => 'calendar.list.dates','template' => '','lang' => '','group' => '0','version' => '1.3.001','data' => 'a:1:{i:0;a:10:{s:4:"type";s:4:"hbox";s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:1;s:4:"cols";i:1;s:4:"size";s:1:"4";i:1;a:2:{s:4:"type";s:5:"label";s:5:"label";s:5:"Start";}i:2;a:2:{s:4:"type";s:4:"date";s:4:"name";s:9:"startdate";}i:3;a:2:{s:4:"type";s:5:"label";s:5:"label";s:3:"End";}i:4;a:2:{s:4:"type";s:4:"date";s:4:"name";s:7:"enddate";}s:4:"span";s:12:",custom_hide";}}','size' => '','style' => '.custom_hide { visibility: hidden; }','modified' => '1173420675',);

View File

@ -57,8 +57,8 @@
</vbox>
<vbox class="listVbox">
<hbox no_lang="1" readonly="true">
<description id="${row}[title]" no_lang="1" readonly="true" options="b"/>
<description align="right" value="#%s" id="${row}[id]" options="b"/>
<description id="${row}[title]" no_lang="1" readonly="true" font_style="b"/>
<description align="right" value="#%s" id="${row}[id]" font_style="b"/>
</hbox>
<box no_lang="1" class="listDescription">
<description id="${row}[description]" no_lang="1"/>
@ -67,7 +67,7 @@
</vbox>
<hbox>
<description id="${row}[title]"/>
<description align="right" value="#%s" id="${row}[id]" options="b"/>
<description align="right" value="#%s" id="${row}[id]" font_style="b"/>
</hbox>
<description id="${row}[description]" no_lang="1"/>
<description id="${row}[recure]"/>
@ -110,7 +110,7 @@
</rows>
</grid>
</template>
<template id="calendar.list" template="" lang="" group="0" version="1.9.002">
<template id="calendar.list" template="" lang="" group="0" version="1.9.003">
<grid width="100%">
<columns>
<column/>
@ -135,6 +135,34 @@
<button statustext="Check all" label="Check all" id="check_all" needed="1" onclick="egw_globalObjectManager.getObjectById('calendar.list.rows').toggleAllSelected(); return false;" image="arrow_ltr" class="checkAllArrow"/>
</hbox>
</row>
<row>
<box class="action_popup prompt" id="delete_popup">
<vbox class="prompt">
<description value="Delete" class="promptheader"/>
<description value="Do you want to delete this event as an exception, or delete the whole series?"/>
<hbox>
<button label="Delete exception" id="delete" onclick="nm_submit_popup(this); return false;"/>
<button label="Delete series" id="delete_series" onclick="nm_popup_action.id = 'delete_series'; nm_submit_popup(this); return false;"/>
<buttononly label="Cancel" onclick="nm_hide_popup(this,'delete_popup');"/>
</hbox>
</vbox>
</box>
<description/>
</row>
<row>
<box class="action_popup prompt" id="undelete_popup">
<vbox class="prompt">
<description value="Un-delete" class="promptheader"/>
<description value="Do you want to Un-delete this event as an exception, or un-delete the whole series?"/>
<hbox>
<button label="Un-delete exception" id="undelete" onclick="nm_submit_popup(this); return false;"/>
<button label="Un-delete series" id="undelete_series" onclick="nm_popup_action.id = 'undelete_series'; nm_submit_popup(this); return false;"/>
<buttononly label="Cancel" onclick="nm_hide_popup(this,'undelete_popup');"/>
</hbox>
</vbox>
</box>
<description/>
</row>
</rows>
</grid>
<styles>
@ -147,6 +175,10 @@
.listVbox {
width: 100%;
}
.action_popup {
display:none;
}
</styles>
</template>
</overlay>