mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 17:18:54 +01:00
Calendar display:
- Better handling of planner group by categories to handle events with multiple categories and events from other apps - No time indicator line on planner headers - Events from other apps now show colors from other app's categories
This commit is contained in:
parent
7a79c9e088
commit
8671fdc837
@ -172,6 +172,19 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
|
|||||||
|
|
||||||
this.set_id('event_' + (eventId || event.id));
|
this.set_id('event_' + (eventId || event.id));
|
||||||
|
|
||||||
|
// Make sure category stuff is there
|
||||||
|
// Fake it to use the cache / call - if already there, these will return
|
||||||
|
// immediately.
|
||||||
|
var im = this.getInstanceManager();
|
||||||
|
et2_selectbox.cat_options({
|
||||||
|
_type:'select-cat',
|
||||||
|
getInstanceManager: function() {return im}
|
||||||
|
}, {application:event.app||'calendar'});
|
||||||
|
|
||||||
|
// Get CSS too
|
||||||
|
egw.includeCSS('/phpgwapi/categories.php?app='+event.app);
|
||||||
|
|
||||||
|
// DOM nodes
|
||||||
this.div
|
this.div
|
||||||
// Empty & re-append to make sure dnd helpers are gone
|
// Empty & re-append to make sure dnd helpers are gone
|
||||||
.empty()
|
.empty()
|
||||||
|
@ -252,6 +252,12 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
.on('mousemove', function(event) {
|
.on('mousemove', function(event) {
|
||||||
|
// Not when over header
|
||||||
|
if($j(event.target).closest('.calendar_eventRows').length == 0)
|
||||||
|
{
|
||||||
|
planner.vertical_bar.hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Position bar by mouse
|
// Position bar by mouse
|
||||||
planner.vertical_bar.position({
|
planner.vertical_bar.position({
|
||||||
my: 'right-1',
|
my: 'right-1',
|
||||||
@ -273,11 +279,14 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
|
|||||||
if(time)
|
if(time)
|
||||||
{
|
{
|
||||||
var formatDate = new Date(time.valueOf() + time.getTimezoneOffset() * 60 * 1000);
|
var formatDate = new Date(time.valueOf() + time.getTimezoneOffset() * 60 * 1000);
|
||||||
planner.vertical_bar.html('<span>'+date(egw.preference('timeformat','calendar') == 12 ? 'h:ia' : 'H:i',formatDate)+'</span>');
|
planner.vertical_bar
|
||||||
|
.html('<span>'+date(egw.preference('timeformat','calendar') == 12 ? 'h:ia' : 'H:i',formatDate)+'</span>')
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
planner.vertical_bar.text('');
|
// No (valid) time, just hide
|
||||||
|
planner.vertical_bar.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -547,38 +556,56 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
|
|||||||
return [{id:'',label: egw.lang('none'), data: {}}];
|
return [{id:'',label: egw.lang('none'), data: {}}];
|
||||||
},
|
},
|
||||||
group: function(labels, rows, event) {
|
group: function(labels, rows, event) {
|
||||||
var label_index = false;
|
var cats = event.category;
|
||||||
for(var i = 0; i < labels.length; i++)
|
if(typeof event.category === 'string')
|
||||||
{
|
{
|
||||||
if(labels[i].id == event.category)
|
cats = cats.split(',');
|
||||||
{
|
|
||||||
label_index = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(label_index === false)
|
for(var cat = 0; cat < cats.length; cat++)
|
||||||
{
|
{
|
||||||
label_index = labels.length;
|
var label_index = false;
|
||||||
labels.push({id: event.category, label: '', data: {cat_id:event.category}});
|
var category = cats[cat];
|
||||||
var im = this.getInstanceManager();
|
if(category == '0' || !category) category = '';
|
||||||
// Fake it to use the cache / call
|
for(var i = 0; i < labels.length; i++)
|
||||||
var categories = et2_selectbox.cat_options({
|
|
||||||
_type:'select-cat',
|
|
||||||
getInstanceManager: function() {return im;}
|
|
||||||
}, {application: 'calendar'});
|
|
||||||
for(var i in categories )
|
|
||||||
{
|
{
|
||||||
if(parseInt(categories[i].value) === parseInt(event.category))
|
if(labels[i].id == category)
|
||||||
{
|
{
|
||||||
labels[labels.length-1].label = categories[i].label;
|
label_index = i;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(label_index === false)
|
||||||
|
{
|
||||||
|
label_index = labels.length;
|
||||||
|
labels.push({id: category, label: '', data: {cat_id:category}});
|
||||||
|
var im = this.getInstanceManager();
|
||||||
|
// Fake it to use the cache / call
|
||||||
|
var categories = et2_selectbox.cat_options({
|
||||||
|
_type:'select-cat',
|
||||||
|
getInstanceManager: function() {return im;}
|
||||||
|
}, {application:event.app||'calendar'});
|
||||||
|
if(categories && !categories.length)
|
||||||
|
{
|
||||||
|
// Categories not loaded. They've started, but it's too late now
|
||||||
|
// Try again once they're all loaded
|
||||||
|
this.invalidate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(var i in categories )
|
||||||
|
{
|
||||||
|
if(parseInt(categories[i].value) === parseInt(category))
|
||||||
|
{
|
||||||
|
labels[labels.length-1].label = categories[i].label;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(typeof rows[label_index] === 'undefined')
|
||||||
|
{
|
||||||
|
rows[label_index] = [];
|
||||||
|
}
|
||||||
|
rows[label_index].push(event);
|
||||||
}
|
}
|
||||||
if(typeof rows[label_index] === 'undefined')
|
|
||||||
{
|
|
||||||
rows[label_index] = [];
|
|
||||||
}
|
|
||||||
rows[label_index].push(event);
|
|
||||||
},
|
},
|
||||||
draw_row: function(sort_key, label, events) {
|
draw_row: function(sort_key, label, events) {
|
||||||
return this._drawRow(sort_key, label,events,this.options.start_date, this.options.end_date);
|
return this._drawRow(sort_key, label,events,this.options.start_date, this.options.end_date);
|
||||||
@ -597,7 +624,7 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
|
|||||||
invalidate: function(trigger) {
|
invalidate: function(trigger) {
|
||||||
|
|
||||||
// Busy
|
// Busy
|
||||||
if(!this.doInvalidate && this.update_timer) return;
|
if(!this.doInvalidate || this.update_timer) return;
|
||||||
|
|
||||||
// Wait a bit to see if anything else changes, then re-draw the days
|
// Wait a bit to see if anything else changes, then re-draw the days
|
||||||
if(this.update_timer !== null)
|
if(this.update_timer !== null)
|
||||||
@ -1479,6 +1506,24 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
|
|||||||
egw.dataRegisterUID(cache_id, function(data) {
|
egw.dataRegisterUID(cache_id, function(data) {
|
||||||
if(data && data.length)
|
if(data && data.length)
|
||||||
{
|
{
|
||||||
|
// If displaying by category, we need the infolog (or other app) categories too
|
||||||
|
var im = this.getInstanceManager();
|
||||||
|
for(var i = 0; i < data.length && this.options.group_by == 'category'; i++)
|
||||||
|
{
|
||||||
|
var event = egw.dataGetUIDdata('calendar::'+data[i]);
|
||||||
|
if(event && event.data && event.data.app)
|
||||||
|
{
|
||||||
|
// Fake it to use the cache / call
|
||||||
|
et2_selectbox.cat_options({
|
||||||
|
_type:'select-cat',
|
||||||
|
getInstanceManager: function() {return im;}
|
||||||
|
}, {application:event.data.app||'calendar'});
|
||||||
|
|
||||||
|
// Get CSS too
|
||||||
|
egw.includeCSS('/phpgwapi/categories.php?app='+event.data.app);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.invalidate(false);
|
this.invalidate(false);
|
||||||
}
|
}
|
||||||
}, this, this.getInstanceManager().execId,this.id);
|
}, this, this.getInstanceManager().execId,this.id);
|
||||||
@ -1767,7 +1812,8 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
|
|||||||
{
|
{
|
||||||
var date = this._get_time_from_position(_ev.offsetX, _ev.offsetY);
|
var date = this._get_time_from_position(_ev.offsetX, _ev.offsetY);
|
||||||
}
|
}
|
||||||
var data = $j(_ev.target).closest('.calendar_plannerRowWidget')[0].dataset || {};
|
var row = $j(_ev.target).closest('.calendar_plannerRowWidget');
|
||||||
|
var data = row.length ? row[0].dataset : {};
|
||||||
this.egw().open(null, 'calendar', 'add', jQuery.extend({
|
this.egw().open(null, 'calendar', 'add', jQuery.extend({
|
||||||
start: date.toJSON(),
|
start: date.toJSON(),
|
||||||
hour: date.getUTCHours(),
|
hour: date.getUTCHours(),
|
||||||
@ -1781,7 +1827,7 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
|
|||||||
{
|
{
|
||||||
// Click on a header, we can go there
|
// Click on a header, we can go there
|
||||||
_ev.data = jQuery.extend({},_ev.target.parentNode.dataset, _ev.target.dataset);
|
_ev.data = jQuery.extend({},_ev.target.parentNode.dataset, _ev.target.dataset);
|
||||||
|
|
||||||
// Handle it locally
|
// Handle it locally
|
||||||
var old_start = this.options.start_date;
|
var old_start = this.options.start_date;
|
||||||
if(_ev.data.date)
|
if(_ev.data.date)
|
||||||
@ -1798,7 +1844,7 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
|
|||||||
this.set_end_date(d);
|
this.set_end_date(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (old_start !== this.options.start_date)
|
||||||
{
|
{
|
||||||
var diff = Math.round((new Date(this.options.start_date) - new Date(old_start)) / (1000 * 3600 * 24));
|
var diff = Math.round((new Date(this.options.start_date) - new Date(old_start)) / (1000 * 3600 * 24));
|
||||||
var end = new Date(this.options.end_date);
|
var end = new Date(this.options.end_date);
|
||||||
@ -1883,6 +1929,8 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(rel_time < 0) return false;
|
||||||
|
|
||||||
var interval = egw.preference('interval','calendar') || 30;
|
var interval = egw.preference('interval','calendar') || 30;
|
||||||
this.date_helper.set_minutes(Math.round(rel_time / (60 * interval))*interval);
|
this.date_helper.set_minutes(Math.round(rel_time / (60 * interval))*interval);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user