forked from extern/egroupware
* Calendar: fixed freetime search to correctly read and set times from edit window
- fixed et2_date.set_value() to understand nummeric timestamps in usertime used on server-side (needed timezone offset) - added new parameter-type for et2_date.set_value() string starting with + or - to add or subtract given number of seconds from current time (to not have to code that in applications)
This commit is contained in:
parent
dc6f9428bf
commit
35f63b35d5
@ -1920,6 +1920,16 @@ class calendar_uiforms extends calendar_ui
|
||||
$response = egw_json_response::get();
|
||||
//$response->addAlert(__METHOD__.'('.array2string($edit_content).')');
|
||||
|
||||
// convert start/end date-time values to timestamps
|
||||
foreach(array('start', 'end') as $name)
|
||||
{
|
||||
if (!empty($edit_content[$name]))
|
||||
{
|
||||
$date = new egw_time($edit_content[$name]);
|
||||
$edit_content[$name] = $date->format('ts');
|
||||
}
|
||||
}
|
||||
|
||||
if ($edit_content['duration'])
|
||||
{
|
||||
$edit_content['end'] = $edit_content['start'] + $edit_content['duration'];
|
||||
|
@ -838,14 +838,8 @@ app.classes.calendar = AppJS.extend(
|
||||
|
||||
var sTime = this.et2.getWidgetById(selectedId+'start');
|
||||
|
||||
var eTime = this.et2.getWidgetById(selectedId+'[end]');
|
||||
//Catches the start time from freetime content
|
||||
var str = sTime.get_value();
|
||||
|
||||
var end = parseInt(str) + parseInt(content['duration']);
|
||||
|
||||
//check the parent window is still open before to try to access it
|
||||
if (window.opener)
|
||||
if (window.opener && sTime)
|
||||
{
|
||||
var editWindowObj = window.opener.etemplate2.getByApplication('calendar')[0];
|
||||
if (typeof editWindowObj != "undefined")
|
||||
@ -854,8 +848,9 @@ app.classes.calendar = AppJS.extend(
|
||||
var endTime = editWindowObj.widgetContainer.getWidgetById('end');
|
||||
if (startTime && endTime)
|
||||
{
|
||||
startTime.set_value(str);
|
||||
endTime.set_value(end);
|
||||
startTime.set_value(sTime.get_value());
|
||||
endTime.set_value(sTime.get_value());
|
||||
endTime.set_value('+'+content['duration']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,6 +106,15 @@ var et2_date = et2_inputWidget.extend(
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Setting date
|
||||
*
|
||||
* @param {string|number|Date} _value supported are the following formats:
|
||||
* - Date object with usertime as UTC value
|
||||
* - string like Date.toJSON()
|
||||
* - string or number with timestamp in usertime like server-side uses it
|
||||
* - string starting with + or - to add/substract given number of seconds from current value, "+600" to add 10 minutes
|
||||
*/
|
||||
set_value: function(_value) {
|
||||
var old_value = this._oldValue;
|
||||
if(_value === null || _value === "" || _value === undefined ||
|
||||
@ -211,9 +220,17 @@ var et2_date = et2_inputWidget.extend(
|
||||
} else if (typeof _value == 'object' && _value.valueOf) {
|
||||
this.date = _value;
|
||||
} else if (typeof _value == 'number' || !isNaN(_value)) {
|
||||
// Timestamp
|
||||
// JS dates use milliseconds
|
||||
this.date.setTime(parseInt(_value)*1000);
|
||||
// string starting with + or - --> add/substract number of seconds from current value
|
||||
if (typeof _value == 'string' && (_value[0] == '+' || _value[0] == '-'))
|
||||
{
|
||||
this.date.setTime(this.date.getTime()+1000*parseInt(_value));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Timestamp in usertime need to be corrected with timezoneoffset as we internally use UTC for egw usertime
|
||||
// JS dates use milliseconds
|
||||
this.date.setTime(1000*(parseInt(_value)-60*this.date.getTimezoneOffset()));
|
||||
}
|
||||
}
|
||||
|
||||
// Update input - popups do, but framework doesn't
|
||||
|
Loading…
Reference in New Issue
Block a user