T4241: Add option to show/hide week numbers in datepicker and calendar view (Bifrost#T156140)

Supported 'calendar_show_weekno' option values:
  -1: don't display week numbers
   0: in datepicker only (default)
   1: in both datepicker and calendar
This commit is contained in:
Aleksander Machniak 2018-11-28 12:41:29 +01:00
parent 089425e43b
commit e85ff38829
6 changed files with 42 additions and 6 deletions

View file

@ -544,6 +544,24 @@ class calendar extends rcube_plugin
);
}
if (!isset($no_override['calendar_show_weekno'])) {
if (!$p['current']) {
$p['blocks']['view']['content'] = true;
return $p;
}
$field_id = 'rcmfd_show_weekno';
$select = new html_select(array('name' => '_show_weekno', 'id' => $field_id));
$select->add($this->gettext('weeknonone'), -1);
$select->add($this->gettext('weeknodatepicker'), 0);
$select->add($this->gettext('weeknoall'), 1);
$p['blocks']['view']['options']['show_weekno'] = array(
'title' => html::label($field_id, rcube::Q($this->gettext('showweekno'))),
'content' => $select->show(intval($this->rc->config->get('calendar_show_weekno'))),
);
}
$p['blocks']['itip']['name'] = $this->gettext('itipoptions');
// Invitations handling
@ -745,6 +763,7 @@ class calendar extends rcube_plugin
'calendar_first_hour' => intval(rcube_utils::get_input_value('_first_hour', rcube_utils::INPUT_POST)),
'calendar_work_start' => intval(rcube_utils::get_input_value('_work_start', rcube_utils::INPUT_POST)),
'calendar_work_end' => intval(rcube_utils::get_input_value('_work_end', rcube_utils::INPUT_POST)),
'calendar_show_weekno' => intval(rcube_utils::get_input_value('_show_weekno', rcube_utils::INPUT_POST)),
'calendar_event_coloring' => intval(rcube_utils::get_input_value('_event_coloring', rcube_utils::INPUT_POST)),
'calendar_default_alarm_type' => rcube_utils::get_input_value('_alarm_type', rcube_utils::INPUT_POST),
'calendar_default_alarm_offset' => $default_alarm,
@ -1762,6 +1781,7 @@ class calendar extends rcube_plugin
$settings['invite_shared'] = (int)$this->rc->config->get('calendar_allow_invite_shared', $this->defaults['calendar_allow_invite_shared']);
$settings['invitation_calendars'] = (bool)$this->rc->config->get('kolab_invitation_calendars', false);
$settings['itip_notify'] = (int)$this->rc->config->get('calendar_itip_send_option', $this->defaults['calendar_itip_send_option']);
$settings['show_weekno'] = (int)$this->rc->config->get('calendar_show_weekno', $this->defaults['calendar_show_weekno']);
// get user identity to create default attendee
if ($this->ui->screen == 'calendar') {

View file

@ -79,6 +79,7 @@ function rcube_calendar_ui(settings)
monthNames: settings.months,
monthNamesShort: settings.months,
changeMonth: false,
showWeek: settings.show_weekno >= 0,
showOtherMonths: true,
selectOtherMonths: true
};
@ -119,6 +120,8 @@ function rcube_calendar_ui(settings)
tableCols: ['handle', 'date', 'time', 'title', 'location'],
defaultView: rcmail.env.view || settings.default_view,
allDayText: rcmail.gettext('all-day', 'calendar'),
weekNumbers: settings.show_weekno > 0,
weekNumberTitle: rcmail.gettext('weekshort', 'calendar') + ' ',
buttonText: {
prev: ' ◄ ',
next: ' ► ',
@ -3901,7 +3904,6 @@ function rcube_calendar_ui(settings)
// initialize small calendar widget using jQuery UI datepicker
minical = $('#datepicker').datepicker($.extend(datepicker_settings, {
inline: true,
showWeek: true,
changeMonth: true,
changeYear: true,
onSelect: function(dateText, inst) {

View file

@ -82,6 +82,12 @@ $config['calendar_work_end'] = 18;
// show line at current time of the day
$config['calendar_time_indicator'] = true;
// Display week numbers:
// -1: don't display week numbers
// 0: in datepicker only (default)
// 1: in both datepicker and calendar
$config['calendar_show_weekno'] = 0;
// default alarm settings for new events.
// this is only a preset when a new event dialog opens
// possible values are <empty>, DISPLAY, EMAIL

View file

@ -32,6 +32,10 @@ $labels['afterflagdeleted'] = 'Flag as deleted';
$labels['aftermoveto'] = 'Move to...';
$labels['itipoptions'] = 'Event Invitations';
$labels['afteraction'] = 'After an invitation or update message is processed';
$labels['showweekno'] = 'Display week numbers';
$labels['weeknonone'] = 'never';
$labels['weeknodatepicker'] = 'in datepicker only';
$labels['weeknoall'] = 'in datepicker and calendar view';
// calendar
$labels['calendar'] = 'Calendar';
@ -130,6 +134,7 @@ $labels['invitationsdeclined'] = 'Declined invitations';
$labels['changepartstat'] = 'Change participant status';
$labels['rsvpcomment'] = 'Invitation text';
$labels['eventstartsync'] = 'Move the event start date to the first occurrence';
$labels['weekshort'] = 'Wk';
// agenda view
$labels['listrange'] = 'Range to display:';

View file

@ -392,7 +392,7 @@ table.fc-border-separate {
.fc .fc-week-number {
width: 22px;
text-align: center;
text-align: center !important;
}
.fc .fc-week-number div {

View file

@ -215,6 +215,7 @@ body.quickview-active .fc-content {
// Fullcalendar styles
@color-calendar-border: @color-layout-border;
@color-calendar-free-bg: fadeout(@color-black-shade-text, 97%);
.fc {
flex: auto !important;
@ -441,8 +442,10 @@ body.quickview-active .fc-content {
// Month View, Basic Week View, Basic Day View
.fc-week-number {
width: 22px;
text-align: center;
width: 1%;
color: tint(@color-black-shade-text, 50%) !important;
border-left: 0;
font-size: .9rem;
div {
padding: 0 2px;
@ -523,7 +526,7 @@ body.quickview-active .fc-content {
width: 50px;
padding: 0 4px;
vertical-align: middle;
text-align: right;
text-align: center;
white-space: nowrap;
font-weight: normal;
font-size: .9rem;
@ -873,7 +876,7 @@ body.quickview-active .fc-content {
}
.fc-sat, .fc-sun {
background-color: fadeout(@color-black-shade-text, 97%);
background-color: @color-calendar-free-bg;
}
// remove redundant borders