Toggle IMAP subscriptions directly from the calendars/folders list (#3042)
This commit is contained in:
parent
8d09b78eb1
commit
857078428b
10 changed files with 87 additions and 28 deletions
|
@ -725,7 +725,7 @@ class calendar extends rcube_plugin
|
|||
$this->rc->output->command('plugin.destroy_source', array('id' => $cal['id']));
|
||||
break;
|
||||
case "subscribe":
|
||||
if (!$this->driver->subscribe_calendar($cal, intval(get_input_value('perm', RCUBE_INPUT_GPC))))
|
||||
if (!$this->driver->subscribe_calendar($cal))
|
||||
$this->rc->output->show_message($this->gettext('errorsaving'), 'error');
|
||||
return;
|
||||
case "search":
|
||||
|
|
|
@ -2697,9 +2697,14 @@ function rcube_calendar_ui(settings)
|
|||
me.calendars[id].color = color;
|
||||
}
|
||||
|
||||
if (fc && cal.active) {
|
||||
fc.fullCalendar('addEventSource', me.calendars[id]);
|
||||
rcmail.http_post('calendar', { action:'subscribe', c:{ id:id, active:cal.active?1:0 } });
|
||||
if (fc && (cal.active || cal.subscribed)) {
|
||||
if (cal.active)
|
||||
fc.fullCalendar('addEventSource', me.calendars[id]);
|
||||
|
||||
var submit = { id: id, active: cal.active ? 1 : 0 };
|
||||
if (cal.subscribed !== undefined)
|
||||
submit.permanent = cal.subscribed ? 1 : 0;
|
||||
rcmail.http_post('calendar', { action:'subscribe', c:submit });
|
||||
}
|
||||
|
||||
// insert to #calendar-select options if writeable
|
||||
|
@ -2761,6 +2766,13 @@ function rcube_calendar_ui(settings)
|
|||
}
|
||||
}
|
||||
});
|
||||
calendars_list.addEventListener('subscribe', function(p) {
|
||||
var cal;
|
||||
if ((cal = me.calendars[p.id])) {
|
||||
cal.subscribed = p.subscribed || false;
|
||||
rcmail.http_post('calendar', { action:'subscribe', c:{ id:p.id, active:cal.active?1:0, permanent:cal.subscribed?1:0 } });
|
||||
}
|
||||
});
|
||||
|
||||
// init (delegate) event handler on calendar list checkboxes
|
||||
$(rcmail.gui_objects.calendarslist).on('click', 'input[type=checkbox]', function(e){
|
||||
|
|
|
@ -30,6 +30,7 @@ class kolab_calendar extends kolab_storage_folder_api
|
|||
public $readonly = true;
|
||||
public $attachments = true;
|
||||
public $alarms = false;
|
||||
public $subscriptions = true;
|
||||
public $categories = array();
|
||||
public $storage;
|
||||
|
||||
|
@ -102,19 +103,6 @@ class kolab_calendar extends kolab_storage_folder_api
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Getter for a nice and human readable name for this calendar
|
||||
* See http://wiki.kolab.org/UI-Concepts/Folder-Listing for reference
|
||||
*
|
||||
* @return string Name of this calendar
|
||||
*/
|
||||
public function get_name()
|
||||
{
|
||||
$folder = kolab_storage::object_name($this->name, $this->namespace);
|
||||
return $folder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Getter for the IMAP folder name
|
||||
*
|
||||
|
|
|
@ -180,6 +180,10 @@ class kolab_driver extends calendar_driver
|
|||
'caldavurl' => $cal->get_caldav_url(),
|
||||
);
|
||||
}
|
||||
|
||||
if ($cal->subscriptions) {
|
||||
$calendars[$cal->id]['subscribed'] = (bool)$cal->is_subscribed();
|
||||
}
|
||||
}
|
||||
|
||||
// append the virtual birthdays calendar
|
||||
|
@ -258,7 +262,6 @@ class kolab_driver extends calendar_driver
|
|||
// create calendar object if necesary
|
||||
if (!$this->calendars[$id] && $id !== self::BIRTHDAY_CALENDAR_ID) {
|
||||
$calendar = kolab_calendar::factory($id, $this->cal);
|
||||
console($id, $calendar->id, $calendar->ready);
|
||||
if ($calendar->ready)
|
||||
$this->calendars[$calendar->id] = $calendar;
|
||||
}
|
||||
|
@ -342,11 +345,15 @@ class kolab_driver extends calendar_driver
|
|||
*
|
||||
* @see calendar_driver::subscribe_calendar()
|
||||
*/
|
||||
public function subscribe_calendar($prop, $permanent = false)
|
||||
public function subscribe_calendar($prop)
|
||||
{
|
||||
if ($prop['id'] && ($cal = $this->get_calendar($prop['id']))) {
|
||||
if ($permanent) $cal->storage->subscribe($prop['active']);
|
||||
return $cal->storage->activate($prop['active']);
|
||||
$ret = false;
|
||||
if (isset($prop['permanent']))
|
||||
$ret |= $cal->storage->subscribe($prop['permanent']);
|
||||
if (isset($prop['active']))
|
||||
$ret |= $cal->storage->activate($prop['active']);
|
||||
return $ret;
|
||||
}
|
||||
else {
|
||||
// save state in local prefs
|
||||
|
|
|
@ -27,6 +27,7 @@ class kolab_user_calendar extends kolab_calendar
|
|||
public $ready = false;
|
||||
public $readonly = true;
|
||||
public $attachments = false;
|
||||
public $subscriptions = false;
|
||||
|
||||
protected $userdata = array();
|
||||
|
||||
|
|
|
@ -296,6 +296,8 @@ class calendar_ui
|
|||
$class = 'folder virtual';
|
||||
else if ($prop['readonly'])
|
||||
$class .= ' readonly';
|
||||
if ($prop['subscribed'])
|
||||
$class .= ' subscribed';
|
||||
if ($prop['class_name'])
|
||||
$class .= ' '.$prop['class_name'];
|
||||
|
||||
|
@ -303,8 +305,11 @@ class calendar_ui
|
|||
if (!$attrib['activeonly'] || $prop['active']) {
|
||||
$content = html::div($class,
|
||||
html::span(array('class' => 'calname', 'title' => $title), $prop['editname'] ? Q($prop['editname']) : $prop['listname']) .
|
||||
($prop['virtual'] ? '' : html::tag('input', array('type' => 'checkbox', 'name' => '_cal[]', 'value' => $id, 'checked' => $prop['active']), '') .
|
||||
html::span(array('class' => 'handle', 'style' => "background-color: #" . ($prop['color'] ?: 'f00')), ' '))
|
||||
($prop['virtual'] ? '' :
|
||||
html::tag('input', array('type' => 'checkbox', 'name' => '_cal[]', 'value' => $id, 'checked' => $prop['active']), '') .
|
||||
(isset($prop['subscribed']) ? html::a(array('href' => '#', 'class' => 'subscribed', 'title' => $this->cal->gettext('calendarsubscribe')), $this->cal->gettext('subscribed')) : '') .
|
||||
html::span(array('class' => 'handle', 'style' => "background-color: #" . ($prop['color'] ?: 'f00')), ' ')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ $labels['showurl'] = 'Show calendar URL';
|
|||
$labels['showurldescription'] = 'Use the following address to access (read only) your calendar from other applications. You can copy and paste this into any calendar software that supports the iCal format.';
|
||||
$labels['caldavurldescription'] = 'Copy this address to a <a href="http://en.wikipedia.org/wiki/CalDAV" target="_blank">CalDAV</a> client application (e.g. Evolution or Mozilla Thunderbird) to fully synchronize this specific calendar with your computer or mobile device.';
|
||||
$labels['calsearchresults'] = 'Available Calendars';
|
||||
$labels['calendarsubscribe'] = 'Listed permanently';
|
||||
|
||||
// agenda view
|
||||
$labels['listrange'] = 'Range to display:';
|
||||
|
|
|
@ -190,7 +190,7 @@ pre {
|
|||
position: absolute;
|
||||
top: 7px;
|
||||
left: 38px;
|
||||
right: 22px;
|
||||
right: 40px;
|
||||
cursor: default;
|
||||
background: url(images/calendars.png) right 20px no-repeat;
|
||||
overflow: hidden;
|
||||
|
@ -207,6 +207,7 @@ pre {
|
|||
|
||||
#calendars .treelist.flat li span.calname {
|
||||
left: 24px;
|
||||
right: 22px;
|
||||
}
|
||||
|
||||
#calendars .treelist li span.handle {
|
||||
|
@ -225,6 +226,28 @@ pre {
|
|||
box-shadow: inset 0px 0 1px 1px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
#calendars .treelist li a.subscribed {
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
top: 7px;
|
||||
right: 24px;
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
padding: 0;
|
||||
background: url(images/calendars.png) -100px 0 no-repeat;
|
||||
overflow: hidden;
|
||||
text-indent: -5000px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#calendars .treelist div:hover > a.subscribed {
|
||||
background-position: 1px -110px;
|
||||
}
|
||||
|
||||
#calendars .treelist div.subscribed a.subscribed {
|
||||
background-position: -15px -110px;
|
||||
}
|
||||
|
||||
#calendars .treelist li input {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.9 KiB |
|
@ -57,20 +57,29 @@ function kolab_folderlist(node, p)
|
|||
// register click handler on search result's checkboxes to select the given item for listing
|
||||
search_results_widget.container
|
||||
.appendTo(search_results_container)
|
||||
.on('click', 'input[type=checkbox]', function(e) {
|
||||
if (!this.checked)
|
||||
return;
|
||||
|
||||
.on('click', 'input[type=checkbox], a.subscribed', function(e) {
|
||||
var li = $(this).closest('li'),
|
||||
id = li.attr('id').replace(new RegExp('^'+p.id_prefix), '')
|
||||
node = search_results_widget.get_node(id),
|
||||
has_children = node.children && node.children.length;
|
||||
|
||||
// activate + subscribe
|
||||
if ($(e.target).hasClass('subscribed')) {
|
||||
search_results[id].subscribed = true;
|
||||
li.children().first()
|
||||
.toggleClass('subscribed')
|
||||
.find('input[type=checkbox]').get(0).checked = true;
|
||||
}
|
||||
else if (!this.checked) {
|
||||
return;
|
||||
}
|
||||
|
||||
// copy item to the main list
|
||||
add_result2list(id, li, true);
|
||||
|
||||
if (has_children) {
|
||||
li.find('input[type=checkbox]').first().prop('disabled', true).get(0).checked = true;
|
||||
li.find('a.subscribed').first().hide();
|
||||
}
|
||||
else {
|
||||
li.remove();
|
||||
|
@ -93,6 +102,7 @@ function kolab_folderlist(node, p)
|
|||
// disable checkbox if item already exists in main list
|
||||
if (me.get_node(prop.id) && !me.get_node(prop.id).virtual) {
|
||||
item.find('input[type=checkbox]').first().prop('disabled', true).get(0).checked = true;
|
||||
item.find('a.subscribed').hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,6 +178,18 @@ function kolab_folderlist(node, p)
|
|||
}
|
||||
});
|
||||
|
||||
this.container.on('click', 'a.subscribed', function(e){
|
||||
var li = $(this).closest('li'),
|
||||
id = li.attr('id').replace(new RegExp('^'+p.id_prefix), ''),
|
||||
div = li.children().first();
|
||||
|
||||
div.toggleClass('subscribed');
|
||||
me.triggerEvent('subscribe', { id: id, subscribed: div.hasClass('subscribed'), item: li });
|
||||
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// link prototype from base class
|
||||
|
|
Loading…
Add table
Reference in a new issue