forked from extern/egroupware
Set alarm's default value according to user preferences for both regular and wholeday events
This commit is contained in:
parent
960b50b83a
commit
b063901fde
@ -1125,7 +1125,6 @@ class calendar_uiforms extends calendar_ui
|
||||
'status' => $this->bo->verbose_status,
|
||||
'duration' => $this->durations,
|
||||
'role' => $this->bo->roles,
|
||||
'new_alarm[options]' => $this->bo->alarms+array(0 => lang('Custom')),
|
||||
'before_after'=>array(0 => lang('Before'), 1 => lang('After')),
|
||||
'action' => array(
|
||||
'copy' => array('label' => 'Copy', 'title' => 'Copy this event'),
|
||||
@ -1268,6 +1267,24 @@ class calendar_uiforms extends calendar_ui
|
||||
}
|
||||
}
|
||||
}
|
||||
// Set alarm sel_options
|
||||
$alarm_options = array();
|
||||
$default_alarm = $this->cal_prefs['default-alarm'];
|
||||
if (!empty($event['whole_day']) && $event['whole_day']) $default_alarm = $this->cal_prefs['default-alarm-wholeday'];
|
||||
if (!array_key_exists($default_alarm, $this->bo->alarms) && $default_alarm > 0)
|
||||
{
|
||||
$alarm_options = $this->bo->alarms + array($default_alarm => calendar_bo::secs2label ($default_alarm));
|
||||
}
|
||||
else
|
||||
{
|
||||
$alarm_options = $this->bo->alarms;
|
||||
}
|
||||
$sel_options += array(
|
||||
'new_alarm[options]' => $alarm_options + array(0 => lang('Custom'))
|
||||
);
|
||||
// set default preference value
|
||||
$event['new_alarm']['options'] = $default_alarm;
|
||||
|
||||
$etpl = new etemplate_new();
|
||||
if (!$etpl->read($preserv['template']))
|
||||
{
|
||||
@ -1415,7 +1432,7 @@ class calendar_uiforms extends calendar_ui
|
||||
}
|
||||
$content['participants']['status_date'] = $preserv['actual_date'];
|
||||
$preserv = array_merge($preserv,$content);
|
||||
|
||||
$event['new_alarm']['options'] = $content['new_alarm']['options'];
|
||||
if ($event['alarm'])
|
||||
{
|
||||
// makes keys of the alarm-array starting with 1
|
||||
|
@ -1196,5 +1196,64 @@ app.classes.calendar = AppJS.extend(
|
||||
alarm_date.set_value(date);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Set alarm options based on WD/Regular event user preferences
|
||||
* Gets fired by wholeday checkbox
|
||||
*
|
||||
* @param {egw object} _egw
|
||||
* @param {widget object} _widget whole_day checkbox
|
||||
*/
|
||||
set_alarmOptions_WD: function (_egw,_widget)
|
||||
{
|
||||
var alarm_options = this.et2.getWidgetById('new_alarm[options]');
|
||||
var sel_options = alarm_options.options.select_options;
|
||||
var def_wd = this.egw.preference('default-alarm-wholeday', 'calendar');
|
||||
var def_alarm = this.egw.preference('default-alarm', 'calendar');
|
||||
var self = this;
|
||||
// Search a needle inside an object. Return true if there's one, otherwise false
|
||||
var _is_in_options = function (_needle, _object)
|
||||
{
|
||||
for(var key in _object)
|
||||
{
|
||||
if (_needle == _object[key].value) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Convert a seconds of time to a translated label
|
||||
var _secs_to_label = function (_secs)
|
||||
{
|
||||
var label='';
|
||||
if (_secs <= 3600)
|
||||
{
|
||||
label = self.egw.lang('%1 minutes', _secs/60);
|
||||
}
|
||||
else if(_secs <= 86400)
|
||||
{
|
||||
label = self.egw.lang('%1 hours', _secs/3600);
|
||||
}
|
||||
else
|
||||
{
|
||||
label = self.egw.lang('%1 days', _secs/86400);
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
if (_widget.get_value() == "true")
|
||||
{
|
||||
if (!_is_in_options(def_wd, sel_options))
|
||||
{
|
||||
sel_options [sel_options.length] = {value:def_wd,label:_secs_to_label(def_wd)};
|
||||
alarm_options.set_select_options(sel_options);
|
||||
}
|
||||
alarm_options.set_value(def_wd);
|
||||
}
|
||||
else
|
||||
{
|
||||
sel_options = this.et2.getArrayMgr('sel_options').data.new_alarm.options;
|
||||
alarm_options.set_select_options(sel_options);
|
||||
alarm_options.set_value(def_alarm);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -287,7 +287,7 @@
|
||||
<row class="dialogHeader2" height="28">
|
||||
<description for="start" value="Start" width="88"/>
|
||||
<date-time id="start" needed="1" class="required"/>
|
||||
<checkbox statustext="Event will occupy the whole day" label="whole day" id="whole_day" options=",, ,disable" span="all"/>
|
||||
<checkbox statustext="Event will occupy the whole day" label="whole day" id="whole_day" options=",, ,disable" span="all" onchange="app.calendar.set_alarmOptions_WD"/>
|
||||
</row>
|
||||
<row class="dialogHeader2" height="28">
|
||||
<description for="duration" value="Duration" width="0" id="calendar_edit_duration" />
|
||||
|
Loading…
Reference in New Issue
Block a user