Calendar et2 conversion bugs:

- Home favorites were missing data
- View selectbox did not show Planner when you clicked the button
- Weekend toggle did not affect multi-week view
- Refresh lost the event if it changed day
This commit is contained in:
Nathan Gray 2015-08-06 17:14:20 +00:00
parent 68f778f163
commit 47813048ab
7 changed files with 78 additions and 14 deletions

View File

@ -246,14 +246,14 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
/**
* Set the owner of this day
*
* @param {number} _owner Account ID
* @param {number|number[]} _owner Account ID
*/
set_owner: function(_owner) {
if(_owner !== this.options.owner)
{
egw.dataUnregisterUID(app.classes.calendar._daywise_cache_id+(this.options.date,this.options.owner),false,this);
this.options.owner = parseInt(_owner);
this.options.owner = _owner;
this.div.attr('data-sortable-id', this.options.owner);
// Register for updates on events for this day

View File

@ -99,7 +99,9 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
// Register for updates
var app_id = this.options.value.app_id ? this.options.value.app_id : this.options.value.id + (this.options.value.recur_type ? ':'+this.options.value.recur_date : '');
egw.dataRegisterUID('calendar::'+app_id, function(event) {
if(this._parent && this.options.value.date && event.date != this.options.value.date)
// Check for changing days in the grid view
if(this._parent && this._parent.instanceOf(et2_calendar_daycol) &&
this.options.value.date && event.date != this.options.value.date)
{
// Date changed, reparent
var new_parent = this._parent._parent.getWidgetById(event.date);
@ -112,8 +114,8 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
// Could not find the right date
this._parent.removeChild(this);
this.destroy();
return;
}
return;
}
// Copy to avoid changes, which may cause nm problems
this.options.value = jQuery.extend({},event);

View File

@ -591,7 +591,7 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
*/
_header_months: function(start, days)
{
var content = '<div class="calendar_plannerScale">';
var content = '<div class="calendar_plannerScale" data-planner_days="0" data-last="">';
var days_in_month = 0;
var day_width = 100 / days;
for(var t = new Date(start),left = 0,i = 0; i < days; t.setUTCDate(t.getUTCDate() + days_in_month),left += days_in_month*day_width,i += days_in_month)
@ -741,6 +741,8 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
{
var next = new Date(t);
next.setUTCDate(next.getUTCDate() + 1);
next.setUTCHours(0);
next.setUTCMinutes(0);
title += this._scroll_button('right',next.toJSON());
}
}
@ -772,7 +774,7 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
var hours = days * 24;
if (days === 1) // for a single day we calculate the hours of a days, to take into account daylight saving changes (23 or 25 hours)
{
var t = new Date(start.getUTCFullYear(),start.getUTCMonth(),start.getUTCDate());
var t = new Date(start.getUTCFullYear(),start.getUTCMonth(),start.getUTCDate(),-start.getTimezoneOffset()/60);
var s = new Date(start);
s.setUTCHours(23);
s.setUTCMinutes(59);
@ -789,7 +791,7 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
{
var title = date(egw.preference('timeformat','calendar') == 12 ? 'ha' : 'H',t);
content += '<div class="calendar_plannerHourScale" style="left: '+left+'%; width: '+(cell_width)+'%;">'+title+"</div>";
content += '<div class="calendar_plannerHourScale" data-date="' + t.toJSON() +'" style="left: '+left+'%; width: '+(cell_width)+'%;">'+title+"</div>";
t.setHours(t.getHours()+decr);
}
content += "</div>"; // end of plannerScale
@ -1033,6 +1035,7 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
_fetch_data: function()
{
var value = [];
var fetch = false;
// Remember previous day to avoid multi-days duplicating
var last_data = [];
@ -1060,9 +1063,23 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
}
last_data = c.data;
}
else
{
fetch = true;
}
t.setUTCDate(t.getUTCDate() + 1);
}
while(t < end);
// Need to get some more from the server
if(fetch && app.calendar)
{
app.calendar._fetch_data({
first: this.options.start_date,
last: this.options.end_date,
owner: this.options.owner,
filter: this.options.filter
}, this.getInstanceManager());
}
return value;
},
@ -1327,6 +1344,31 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
// Click on a header, we can go there
_ev.data = jQuery.extend({},_ev.target.parentNode.dataset, _ev.target.dataset);
debugger;
// Handle it locally
var old_start = this.options.start_date;
if(_ev.data.date)
{
this.set_start_date(_ev.data.date);
}
if(_ev.data.planner_days)
{
_ev.data.planner_days = parseInt(_ev.data.planner_days);
if(_ev.data.planner_days)
{
var d = new Date(this.options.start_date);
d.setUTCDate(d.getUTCDate() +_ev.data.planner_days-1);
this.set_end_date(d);
}
}
else
{
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);
end.setUTCDate(end.getUTCDate() + diff)
this.set_end_date(end);
}
// Notify anyone who's interested
this.change(_ev);
}
else

View File

@ -354,6 +354,7 @@ var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM],
if(this._parent.options.group_by !== 'month')
{
// Daywise scaling
/* Needs hourly scales that consider working hours
var start_date = new Date(start.getUTCFullYear(), start.getUTCMonth(),start.getUTCDate());
var end_date = new Date(end.getUTCFullYear(), end.getUTCMonth(),end.getUTCDate());
var t_date = new Date(t.getUTCFullYear(), t.getUTCMonth(),t.getUTCDate());
@ -378,7 +379,7 @@ var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM],
}
pos += day_percentage / days;
}
*/
}
pos = 100 * pos;

View File

@ -320,8 +320,9 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
// Leave the helper there until the update is done
var loading = ui.helper.clone().appendTo(ui.helper.parent());
loading.addClass('loading');
// and add a loading icon so user knows something is happening
$j('.calendar_timeDemo',loading).after('<div class="loading"></div>');
event_widget.recur_prompt(function(button_id) {
if(button_id === 'cancel' || !button_id) return;
//Get infologID if in case if it's an integrated infolog event
@ -543,12 +544,12 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
if(typeof this.value[this.day_list[i]] === 'undefined')
{
var ids = (egw.dataGetUIDdata(app.classes.calendar._daywise_cache_id(this.day_list[i],this.options.owner))||{data:[]});
for(var j = 0; j < ids.length; j++)
for(var j = 0; j < ids.data.length; j++)
{
this.value[this.day_list[i]] = [];
if(egw.dataHasUID('calendar::'+ids[j]))
if(egw.dataHasUID('calendar::'+ids.data[j]))
{
this.value[this.day_list[i]].push(egw.dataGetUIDdata('calendar::'+ids[j]).data);
this.value[this.day_list[i]].push(egw.dataGetUIDdata('calendar::'+ids.data[j]).data);
}
}
}
@ -561,6 +562,9 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
// Position
$j(day.getDOMNode()).css('left', ((100/this.day_list.length).toFixed(2) * i) + '%');
}
// Don't hold on to value any longer, use the data cache for best info
this.value = {};
// TODO: Figure out how to do this with detached nodes
/*

View File

@ -701,6 +701,14 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget
font-weight: bold;
text-align: center;
}
.calendar_d-n-d_timeCounter .loading
{
width: 16px;
height: 16px;
position: absolute;
bottom: 0px;
right: 0px;
}
#calendar-edit_action {
width: 10em;

View File

@ -11,7 +11,7 @@
* @package calendar
* @version $Id$
*/
/* $Id: app.css 53038 2015-07-02 19:31:52Z nathangray $ */
/* $Id: app.css 53111 2015-07-15 16:29:10Z nathangray $ */
/*Media print classes*/
@media print {
.th td,
@ -701,6 +701,13 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget
font-weight: bold;
text-align: center;
}
.calendar_d-n-d_timeCounter .loading {
width: 16px;
height: 16px;
position: absolute;
bottom: 0px;
right: 0px;
}
#calendar-edit_action {
width: 10em;
padding-left: 10px;