* Calendar/Alarm: Move calendar Alarm from Alarm tab to Details tab and make it more user friendly to add alarm

This commit is contained in:
Hadi Nategh 2014-05-27 15:02:56 +00:00
parent eaccfdfe1d
commit 706c69ed90
6 changed files with 130 additions and 102 deletions

View File

@ -201,7 +201,7 @@ class calendar_uiforms extends calendar_ui
$exception['recurrence'] != $content['recur_exception'][$key]) continue; $exception['recurrence'] != $content['recur_exception'][$key]) continue;
$exception['uid'] = common::generate_uid('calendar', $id); $exception['uid'] = common::generate_uid('calendar', $id);
$exception['reference'] = $exception['recurrence'] = 0; $exception['reference'] = $exception['recurrence'] = 0;
$this->bo->update($exception, true, true,false,true,$message,$content['no_notifications']); $this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']);
break; break;
} }
unset($content['recur_exception'][$key]); unset($content['recur_exception'][$key]);
@ -281,6 +281,7 @@ class calendar_uiforms extends calendar_ui
case 'add': case 'add':
// email or rfc822 addresse (eg. "Ralf Becker <ralf@domain.com>") in the search field // email or rfc822 addresse (eg. "Ralf Becker <ralf@domain.com>") in the search field
// ToDo: get eTemplate to return that field // ToDo: get eTemplate to return that field
$matches = array();
if (($email = $_POST['exec']['participants']['resource']['query']) && if (($email = $_POST['exec']['participants']['resource']['query']) &&
(preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$email,$matches))) (preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$email,$matches)))
{ {
@ -322,7 +323,10 @@ class calendar_uiforms extends calendar_ui
{ {
list($app,$id) = explode(':',$data); list($app,$id) = explode(':',$data);
} }
foreach($this->bo->resources as $type => $data) if ($data['app'] == $app) break; foreach($this->bo->resources as $type => $data)
{
if ($data['app'] == $app) break;
}
$uid = $this->bo->resources[$type]['app'] == $app ? $type.$id : false; $uid = $this->bo->resources[$type]['app'] == $app ? $type.$id : false;
if ($app == 'home-accounts') if ($app == 'home-accounts')
{ {
@ -886,8 +890,8 @@ class calendar_uiforms extends calendar_ui
case 'add_alarm': case 'add_alarm':
$time = ($content['actual_date'] ? $content['actual_date'] : $content['start']); $time = ($content['actual_date'] ? $content['actual_date'] : $content['start']);
$offset = DAY_s * $content['new_alarm']['days'] + HOUR_s * $content['new_alarm']['hours'] + 60 * $content['new_alarm']['mins']; $offset = $time - $content['new_alarm']['date'];
if($content['before_after']) $offset *= -1;
if ($event['recur_type'] != MCAL_RECUR_NONE && if ($event['recur_type'] != MCAL_RECUR_NONE &&
($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) && ($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) &&
$time < $next_occurrence['start']) $time < $next_occurrence['start'])
@ -898,7 +902,7 @@ class calendar_uiforms extends calendar_ui
{ {
$alarm = array( $alarm = array(
'offset' => $offset, 'offset' => $offset,
'time' => $time - $offset, 'time' => $content['new_alarm']['date'],
'all' => !$content['new_alarm']['owner'], 'all' => !$content['new_alarm']['owner'],
'owner' => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user, 'owner' => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user,
); );
@ -1105,14 +1109,14 @@ class calendar_uiforms extends calendar_ui
/** /**
* Edit a calendar event * Edit a calendar event
* *
* @param array $event=null Event to edit, if not $_GET['cal_id'] contains the event-id * @param array $event Event to edit, if not $_GET['cal_id'] contains the event-id
* @param array $perserv=null following keys: * @param array $preserv following keys:
* view boolean view-mode, if no edit-access we automatic fallback to view-mode * view boolean view-mode, if no edit-access we automatic fallback to view-mode
* hide_delete boolean hide delete button * hide_delete boolean hide delete button
* no_popup boolean use a popup or not * no_popup boolean use a popup or not
* edit_single int timestamp of single event edited, unset/null otherwise * edit_single int timestamp of single event edited, unset/null otherwise
* @param string $msg='' msg to display * @param string $msg msg to display
* @param mixed $link_to_id='' $content from or for the link-widget * @param mixed $li$link_to_idontent from or for the link-widget
*/ */
function edit($event=null,$preserv=null,$msg='',$link_to_id='') function edit($event=null,$preserv=null,$msg='',$link_to_id='')
{ {
@ -1121,6 +1125,8 @@ class calendar_uiforms extends calendar_ui
'status' => $this->bo->verbose_status, 'status' => $this->bo->verbose_status,
'duration' => $this->durations, 'duration' => $this->durations,
'role' => $this->bo->roles, 'role' => $this->bo->roles,
'new_alarm[options]' =>array(300 => lang('5 Minutes'), 600 => lang('10 Minutes'), 900 => lang('15 Minutes'), 1800 => lang('30 Minutes'), 3600 => lang('1 Hour'), 7200 => lang('2 Hours'),
43200 => lang('12 Hours'), 86400 => lang('1 Day'), 172800 => lang('2 Days'), 604800 => lang('1 Week'), 0 => lang('Custom')),
'before_after'=>array(0 => lang('Before'), 1 => lang('After')), 'before_after'=>array(0 => lang('Before'), 1 => lang('After')),
'action' => array( 'action' => array(
'copy' => array('label' => 'Copy', 'title' => 'Copy this event'), 'copy' => array('label' => 'Copy', 'title' => 'Copy this event'),
@ -1445,14 +1451,9 @@ class calendar_uiforms extends calendar_ui
} }
else else
{ {
// hide the alarm tab for newly created exceptions
$readonlys['tabs']['alarms'] = true;
// disable the alarm tab functionality // disable the alarm tab functionality
$readonlys['button[add_alarm]'] = true; $readonlys['button[add_alarm]'] = true;
$readonlys['new_alarm[days]'] = true; $readonlys['new_alarm[options]'] = true;
$readonlys['new_alarm[hours]'] = true;
$readonlys['new_alarm[mins]'] = true;
$readonlys['new_alarm[owner]'] = true; $readonlys['new_alarm[owner]'] = true;
} }
if (count($content['alarm']) == 1) if (count($content['alarm']) == 1)
@ -1471,7 +1472,7 @@ class calendar_uiforms extends calendar_ui
$readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false $readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false
$readonlys['alarm'] = $readonlys['button[cancel]'] = $readonlys['action'] = $readonlys['alarm'] = $readonlys['button[cancel]'] = $readonlys['action'] =
$readonlys['before_after'] = $readonlys['button[add_alarm]'] = $readonlys['new_alarm[owner]'] = $readonlys['before_after'] = $readonlys['button[add_alarm]'] = $readonlys['new_alarm[owner]'] =
$readonlys['new_alarm[days]'] = $readonlys['new_alarm[hours]'] = $readonlys['new_alarm[mins]'] = false; $readonlys['new_alarm[options]'] = false;
$content['participants']['no_add'] = true; $content['participants']['no_add'] = true;
@ -2143,8 +2144,8 @@ class calendar_uiforms extends calendar_ui
/** /**
* Export events as vCalendar version 2.0 files (iCal) * Export events as vCalendar version 2.0 files (iCal)
* *
* @param int|array $content=0 numeric cal_id or submitted content from etempalte::exec * @param int|array $content numeric cal_id or submitted content from etempalte::exec
* @param boolean $return_error=false should an error-msg be returned or a regular page with it generated (default) * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default)
* @return string error-msg if $return_error * @return string error-msg if $return_error
*/ */
function export($content=0,$return_error=false) function export($content=0,$return_error=false)
@ -2209,7 +2210,7 @@ class calendar_uiforms extends calendar_ui
/** /**
* Import events as vCalendar version 2.0 files (iCal) * Import events as vCalendar version 2.0 files (iCal)
* *
* @param array $content=null submitted content from etempalte::exec * @param array $content submitted content from etempalte::exec
*/ */
function import($content=null) function import($content=null)
{ {
@ -2250,7 +2251,7 @@ class calendar_uiforms extends calendar_ui
/** /**
* Edit category ACL (admin only) * Edit category ACL (admin only)
* *
* @param array $content=null * @param array $content
*/ */
function cat_acl(array $content=null) function cat_acl(array $content=null)
{ {
@ -2377,7 +2378,7 @@ class calendar_uiforms extends calendar_ui
/** /**
* moves an event to another date/time * moves an event to another date/time
* *
* @param string $eventID id of the event which has to be moved * @param string $eventId id of the event which has to be moved
* @param string $calendarOwner the owner of the calendar the event is in * @param string $calendarOwner the owner of the calendar the event is in
* @param string $targetDateTime the datetime where the event should be moved to, format: YYYYMMDD * @param string $targetDateTime the datetime where the event should be moved to, format: YYYYMMDD
* @param string $targetOwner the owner of the target calendar * @param string $targetOwner the owner of the target calendar

View File

@ -111,6 +111,7 @@ app.classes.calendar = AppJS.extend(
, [content.data['id'],content.data['lock_token']],null,true,null,null).sendRequest(true); , [content.data['id'],content.data['lock_token']],null,true,null,null).sendRequest(true);
}; };
} }
this.alarm_custom_date();
break; break;
case 'calendar.freetimesearch': case 'calendar.freetimesearch':
@ -1164,4 +1165,36 @@ app.classes.calendar = AppJS.extend(
return false; return false;
}, },
/**
* Enable/Disable custom Date-time for set Alarm
*
* @param {egw object} _egw
* @param {widget object} _widget new_alarm[options] selectbox
*/
alarm_custom_date: function (_egw,_widget)
{
var alarm_date = this.et2.getWidgetById('new_alarm[date]');
var alarm_options = _widget || this.et2.getWidgetById('new_alarm[options]');
var start = this.et2.getWidgetById('start');
var date = 0;
if (alarm_date && alarm_options
&& start)
{
if (alarm_options.get_value() != '0')
{
alarm_date.set_class('calendar_alarm_date_display');
}
else
{
alarm_date.set_class('');
}
var startDate = start.get_value();
if (startDate)
{
date = startDate - parseInt(alarm_options.get_value());
alarm_date.set_value(date);
}
}
}
}); });

View File

@ -222,7 +222,11 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget
.calendar_calViewUserNameFirst:after { .calendar_calViewUserNameFirst:after {
content: ", "; content: ", ";
} }
/* alarm_date widget disabled class
*/
.calendar_alarm_date_display {
display: none;
}
/* header of the time-grid, eg. for the weeks in the month-view (leftmost of the day-col-headers) /* header of the time-grid, eg. for the weeks in the month-view (leftmost of the day-col-headers)
*/ */
.calendar_calGridHeader{ .calendar_calGridHeader{

View File

@ -3,9 +3,9 @@
<overlay> <overlay>
<template id="calendar.edit.details" template="" lang="" group="0" version="1.9.001"> <template id="calendar.edit.details" template="" lang="" group="0" version="1.9.001">
<hbox options="0,0"> <hbox options="0,0">
<grid height="250" width="500"> <grid height="250" width="445">
<columns> <columns>
<column width="85"/> <column width="80px"/>
<column/> <column/>
</columns> </columns>
<rows> <rows>
@ -21,16 +21,71 @@
</row> </row>
<row> <row>
<description value="Options"/> <description value="Options"/>
<hbox>
<checkbox statustext="A non blocking event will not conflict with other events" label="non blocking" id="non_blocking" options="1,0, ,disable"/> <checkbox statustext="A non blocking event will not conflict with other events" label="non blocking" id="non_blocking" options="1,0, ,disable"/>
<checkbox label="Private" id="public" options="0,1"/>
</hbox>
</row> </row>
<row> <row>
<description/> <grid width="445" height="250">
<checkbox label="Private" id="public" options="0,1"/> <columns>
<column width="80px" height="30px"/>
<column/>
</columns>
<rows>
<row class="th" disabled="@view" height="28">
<description value="Add new alarm" span="all"/>
</row>
<row class="row add_alarm_action" height="50" disabled="@no_add_alarm">
<hbox span="all">
<description value="Set at"/>
<menulist>
<menupopup type="select-number" statustext="" id="new_alarm[options]" onchange="app.calendar.alarm_custom_date"/>
</menulist>
<date-time id="new_alarm[date]" class="calendar_alarm_date_display"/>
<menulist>
<menupopup statustext="Select who should get the alarm" label="for" id="new_alarm[owner]" no_lang="1"/>
</menulist>
<button label="Add" id="button[add_alarm]" image="add" background_image="1"/>
</hbox>
</row>
<row valign="top" disabled="!@alarm">
<grid id="alarm" width="100%" class="egwGridView_grid">
<columns>
<column/>
<column/>
<column/>
<column/>
<column/>
</columns>
<rows>
<row class="th">
<description value="Time"/>
<description value="before the event"/>
<description value="All participants"/>
<description value="Owner"/>
<description value="Action"/>
</row>
<row>
<date-time id="${row}[time]" readonly="true"/>
<description id="${row}[offset]" no_lang="1"/>
<checkbox align="center" id="${row}[all]" readonly="true"/>
<menulist>
<menupopup type="select-account" id="${row}[owner]" readonly="true"/>
</menulist>
<button align="center" statustext="Delete this alarm" label="Delete" id="delete_alarm[$row_cont[id]]" onclick="et2_dialog.confirm(widget,'Delete this alarm','Delete')" image="delete"/>
</row>
</rows>
</grid>
</row>
</rows>
</grid>
</row> </row>
</rows> </rows>
</grid> </grid>
<vbox align="right" options="0,0" class="calendar_category_details"> <vbox align="right" options="0,0" class="calendar_category_details">
<description height="25"/> <description/>
<description for="category" value="Categories" class="row_on"/> <description for="category" value="Categories" class="row_on"/>
<listbox type="select-cat" id="category" rows="9" /> <listbox type="select-cat" id="category" rows="9" />
</vbox> </vbox>
@ -186,72 +241,6 @@
</rows> </rows>
</grid> </grid>
</template> </template>
<template id="calendar.edit.alarms" template="" lang="" group="0" version="1.9.001">
<grid width="100%" height="250" overflow="auto">
<columns>
<column width="120px" height="30px"/>
<column/>
</columns>
<rows>
<row class="th gray" disabled="@view" height="28">
<description value="Add new alarm" span="all"/>
</row>
<row class="row add_alarm_action" height="50" disabled="@no_add_alarm">
<menulist>
<menupopup label="%s the event" id="before_after"/>
</menulist>
<hbox>
<menulist>
<menupopup type="select-number" statustext="days" id="new_alarm[days]" options=",0,7"/>
</menulist>
<description for="new_alarm[days]" value="days"/>
<menulist>
<menupopup type="select-number" statustext="hours" id="new_alarm[hours]" options=",0,23"/>
</menulist>
<description for="new_alarm[hours]" value="hours"/>
<menulist>
<menupopup type="select-number" statustext="Minutes" id="new_alarm[mins]" options=",0,55,5"/>
</menulist>
<description for="new_alarm[mins]" value="Minutes"/>
<menulist>
<menupopup statustext="Select who should get the alarm" label="for" id="new_alarm[owner]" no_lang="1"/>
</menulist>
<button label="Add alarm" id="button[add_alarm]" image="add" background_image="1"/>
</hbox>
</row>
<row valign="top" disabled="!@alarm">
<description value="Alarms"/>
<grid id="alarm">
<columns>
<column/>
<column/>
<column/>
<column/>
<column/>
</columns>
<rows>
<row class="th">
<description value="Time"/>
<description value="before the event"/>
<description value="All participants"/>
<description value="Owner"/>
<description value="Action"/>
</row>
<row>
<date-time id="${row}[time]" readonly="true"/>
<description id="${row}[offset]" no_lang="1"/>
<checkbox align="center" id="${row}[all]" readonly="true"/>
<menulist>
<menupopup type="select-account" id="${row}[owner]" readonly="true"/>
</menulist>
<button align="center" statustext="Delete this alarm" label="Delete" id="delete_alarm[$row_cont[id]]" onclick="et2_dialog.confirm(widget,'Delete this alarm','Delete')" image="delete"/>
</row>
</rows>
</grid>
</row>
</rows>
</grid>
</template>
<template id="calendar.edit.history" template="" lang="" group="0" version="1.7.002"> <template id="calendar.edit.history" template="" lang="" group="0" version="1.7.002">
<grid width="100%" height="250" overflow="auto"> <grid width="100%" height="250" overflow="auto">
<columns> <columns>
@ -319,7 +308,6 @@
<tab id="recurrence" label="Recurrence" statustext="Repeating Event Information"/> <tab id="recurrence" label="Recurrence" statustext="Repeating Event Information"/>
<tab id="custom" label="Custom" statustext="Custom fields"/> <tab id="custom" label="Custom" statustext="Custom fields"/>
<tab id="links" label="Links" statustext="Links, Attachments"/> <tab id="links" label="Links" statustext="Links, Attachments"/>
<tab id="alarms" label="Alarms" statustext="Alarm management"/>
<tab id="history" label="History" statustext="Change history"/> <tab id="history" label="History" statustext="Change history"/>
</tabs> </tabs>
<tabpanels> <tabpanels>
@ -329,7 +317,6 @@
<template id="calendar.edit.recurrence"/> <template id="calendar.edit.recurrence"/>
<template id="calendar.edit.custom"/> <template id="calendar.edit.custom"/>
<template id="calendar.edit.links"/> <template id="calendar.edit.links"/>
<template id="calendar.edit.alarms"/>
<template id="calendar.edit.history"/> <template id="calendar.edit.history"/>
</tabpanels> </tabpanels>
</tabbox> </tabbox>

View File

@ -238,6 +238,11 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget
.calendar_calViewUserNameFirst:after { .calendar_calViewUserNameFirst:after {
content: ", "; content: ", ";
} }
/* alarm_date widget disabled class
*/
.calendar_alarm_date_display {
display: none;
}
/* header of the time-grid, eg. for the weeks in the month-view (leftmost of the day-col-headers) /* header of the time-grid, eg. for the weeks in the month-view (leftmost of the day-col-headers)
*/ */
.calendar_calGridHeader { .calendar_calGridHeader {
@ -1029,7 +1034,7 @@ div#calendar-edit #calendar-edit_calendar-edit-details {
div#calendar-edit #calendar-edit_calendar-edit-details table.et2_grid { div#calendar-edit #calendar-edit_calendar-edit-details table.et2_grid {
/*background-color: yellow;*/ /*background-color: yellow;*/
line-height: 20px; line-height: 20px;
width: 60% !important; width: 60%;
} }
div#calendar-edit #calendar-edit_calendar-edit-details .calendar_category_details { div#calendar-edit #calendar-edit_calendar-edit-details .calendar_category_details {
margin: 0 1em; margin: 0 1em;

View File

@ -468,9 +468,7 @@ div#calendar-edit{
table.et2_grid{ table.et2_grid{
/*background-color: yellow;*/ /*background-color: yellow;*/
line-height: 20px; line-height: 20px;
width: 60% !important; width: 60%;
} }