Render a menu to select the RSVP mode for recurring events instead of using radio buttons

This commit is contained in:
Thomas Bruederli 2015-02-16 15:36:25 +01:00
parent d7733e7879
commit fe64e05e48
5 changed files with 67 additions and 35 deletions

View file

@ -557,11 +557,11 @@ function rcube_calendar_ui(settings)
if (event.recurrence && event.id) { if (event.recurrence && event.id) {
var sel = event._savemode || (event.thisandfuture ? 'future' : (event.isexception ? 'current' : 'all')); var sel = event._savemode || (event.thisandfuture ? 'future' : (event.isexception ? 'current' : 'all'));
$('#event-rsvp input.rsvp-replymode[value="'+sel+'"]').prop('checked', true); $('#event-rsvp .rsvp-buttons').addClass('recurring');
$('#event-rsvp .rsvp-replymode-message').show(); }
else {
$('#event-rsvp .rsvp-buttons').removeClass('recurring');
} }
else
$('#event-rsvp .rsvp-replymode-message').hide();
} }
var buttons = []; var buttons = [];
@ -2378,14 +2378,31 @@ function rcube_calendar_ui(settings)
} }
// when the user accepts or declines an event invitation // when the user accepts or declines an event invitation
var event_rsvp = function(response, delegate) var event_rsvp = function(response, delegate, replymode)
{ {
var btn;
if (typeof response == 'object') {
btn = $(response);
response = btn.attr('rel')
}
else {
btn = $('#event-rsvp input.button[rel='+response+']');
}
// show menu to select rsvp reply mode (current or all)
if (me.selected_event && me.selected_event.recurrence && !replymode) {
rcube_libcalendaring.itip_rsvp_recurring(btn, function(resp, mode) {
event_rsvp(resp, null, mode);
});
return;
}
if (me.selected_event && me.selected_event.attendees && response) { if (me.selected_event && me.selected_event.attendees && response) {
// bring up delegation dialog // bring up delegation dialog
if (response == 'delegated' && !delegate) { if (response == 'delegated' && !delegate) {
rcube_libcalendaring.itip_delegate_dialog(function(data) { rcube_libcalendaring.itip_delegate_dialog(function(data) {
data.rsvp = data.rsvp ? 1 : ''; data.rsvp = data.rsvp ? 1 : '';
event_rsvp('delegated', data); event_rsvp('delegated', data, replymode);
}); });
return; return;
} }
@ -2419,7 +2436,7 @@ function rcube_calendar_ui(settings)
} }
// submit status change to server // submit status change to server
var submit_data = $.extend({}, me.selected_event, { source:null, comment:$('#reply-comment-event-rsvp').val(), _savemode: $('input.rsvp-replymode:checked').val() }, (delegate || {})), var submit_data = $.extend({}, me.selected_event, { source:null, comment:$('#reply-comment-event-rsvp').val(), _savemode: replymode || 'all' }, (delegate || {})),
noreply = $('#noreply-event-rsvp:checked').length ? 1 : 0; noreply = $('#noreply-event-rsvp:checked').length ? 1 : 0;
// import event from mail (temporary iTip event) // import event from mail (temporary iTip event)
@ -4163,7 +4180,7 @@ function rcube_calendar_ui(settings)
}); });
$('#event-rsvp input.button').click(function(e) { $('#event-rsvp input.button').click(function(e) {
event_rsvp($(this).attr('rel')) event_rsvp(this)
}); });
$('#eventedit input.edit-recurring-savemode').change(function(e) { $('#eventedit input.edit-recurring-savemode').change(function(e) {

View file

@ -1063,24 +1063,8 @@ td.topalign {
text-align: center; text-align: center;
} }
.event-dialog-message .rsvp-replymode-message { .libcal-rsvp-replymode li a {
margin-top: 0.8em; cursor: default;
margin-bottom: 0.6em;
}
.event-dialog-message .rsvp-replymode-message .replymode-select {
padding-left: 22px;
}
.event-dialog-message .rsvp-replymode-message label {
color: inherit;
margin-right: 0.4em;
white-space: nowrap;
min-width: 4em;
}
.event-dialog-message .rsvp-replymode-message input.rsvp-replymode {
margin-right: 0.4em;
} }
#event-rsvp, #event-rsvp,

View file

@ -677,20 +677,16 @@ class libcalendaring_itip
} }
} }
foreach (array('all','current','future') as $mode) {
$this->rc->output->command('add_label', "rsvpmode$mode", $this->gettext("rsvpmode$mode"));
}
$savemode_radio = new html_radiobutton(array('name' => '_rsvpmode', 'class' => 'rsvp-replymode')); $savemode_radio = new html_radiobutton(array('name' => '_rsvpmode', 'class' => 'rsvp-replymode'));
return html::div($attrib, return html::div($attrib,
html::div('label', $this->gettext('acceptinvitation')) . html::div('label', $this->gettext('acceptinvitation')) .
html::div('rsvp-buttons', html::div('rsvp-buttons',
$buttons . $buttons .
html::div(array('class' => 'rsvp-replymode-message', 'style' => 'display:none'),
html::div('message', html::span('ui-icon ui-icon-alert', '') . $this->gettext('rsvprecurringevent')) .
html::div('replymode-select',
html::label(null, $savemode_radio->show('all', array('value' => 'all')) . $this->gettext('allevents')) .
html::label(null, $savemode_radio->show(null, array('value' => 'current')) . $this->gettext('currentevent')) .
html::label(null, $savemode_radio->show(null, array('value' => 'future')) . $this->gettext('futurevents'))
)
) .
html::div('itip-reply-controls', $this->itip_rsvp_options_ui($attrib['id'])) html::div('itip-reply-controls', $this->itip_rsvp_options_ui($attrib['id']))
) )
); );

View file

@ -958,6 +958,39 @@ rcube_libcalendaring.itip_delegate_dialog = function(callback, selector)
return dialog; return dialog;
}; };
/**
* Show a menu for selecting the RSVP reply mode
*/
rcube_libcalendaring.itip_rsvp_recurring = function(btn, callback)
{
var mnu = $('<ul></ul>').addClass('popupmenu libcal-rsvp-replymode');
$.each(['all','current','future'], function(i, mode) {
$('<li><a>' + rcmail.get_label('rsvpmode'+mode, 'libcalendaring') + '</a>')
.attr('rel', mode)
.appendTo(mnu);
});
var action = btn.attr('rel');
// open the mennu
mnu.menu({
select: function(event, ui) {
callback(action, ui.item.attr('rel'));
}
})
.appendTo(document.body)
.position({ my: 'left top', at: 'left bottom+2', of: btn })
.data('action', action);
setTimeout(function() {
$(document).one('click', function() {
mnu.menu('destroy');
mnu.remove();
});
}, 100);
};
/** /**
* *
*/ */

View file

@ -108,7 +108,9 @@ $labels['acceptinvitation'] = 'Do you accept this invitation?';
$labels['acceptattendee'] = 'Accept participant'; $labels['acceptattendee'] = 'Accept participant';
$labels['declineattendee'] = 'Decline participant'; $labels['declineattendee'] = 'Decline participant';
$labels['declineattendeeconfirm'] = 'Enter a message to the declined participant (optional):'; $labels['declineattendeeconfirm'] = 'Enter a message to the declined participant (optional):';
$labels['rsvprecurringevent'] = 'This is a series of events! Does your response apply to all, this occurrence only or this and future occurrences?'; $labels['rsvpmodeall'] = 'The entire series';
$labels['rsvpmodecurrent'] = 'This occurrence';
$labels['rsvpmodefuture'] = 'This and future occurrences';
$labels['itipsingleoccurrence'] = 'This is a <em>single occurrence</em> out of a series of events'; $labels['itipsingleoccurrence'] = 'This is a <em>single occurrence</em> out of a series of events';
$labels['itipfutureoccurrence'] = 'Refers to <em>this and all future occurrences</em> of a series of events'; $labels['itipfutureoccurrence'] = 'Refers to <em>this and all future occurrences</em> of a series of events';