Commit 218a1029 authored by Fabian Schneider's avatar Fabian Schneider Committed by Toon Claes

Add helpers for first day of the week

parent 8e81fac5
...@@ -43,18 +43,21 @@ module PreferencesHelper ...@@ -43,18 +43,21 @@ module PreferencesHelper
] ]
end end
def default_first_day_of_week
Date::DAYNAMES[Gitlab::CurrentSettings.default_first_day_of_week]
end
def first_day_of_week_choices def first_day_of_week_choices
[ [
["System Default (#{default_first_day_of_week})", nil], [_('Sunday'), 0],
['Sunday', 0], [_('Monday'), 1]
['Monday', 1]
] ]
end end
def default_first_day_of_week
first_day_of_week_choices.rassoc(Gitlab::CurrentSettings.default_first_day_of_week).first
end
def first_day_of_week_choices_with_default
first_day_of_week_choices.unshift([_('System Default (%{default})') % { default: default_first_day_of_week }, nil])
end
def user_application_theme def user_application_theme
@user_application_theme ||= Gitlab::Themes.for_user(current_user).css_class @user_application_theme ||= Gitlab::Themes.for_user(current_user).css_class
end end
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
%fieldset %fieldset
.form-group .form-group
= f.label :default_first_day_of_week, _('Default first day of the week'), class: 'label-bold' = f.label :default_first_day_of_week, _('Default first day of the week'), class: 'label-bold'
= f.select :default_first_day_of_week, options_for_select({_('Sunday') => 0, _('Monday') => 1}, @application_setting.default_first_day_of_week), {}, class: 'form-control' = f.select :default_first_day_of_week, first_day_of_week_choices, {}, class: 'form-control'
.form-text.text-muted .form-text.text-muted
Default first day of the week in calendars and date pickers. = _('Default first day of the week in calendars and date pickers.')
= f.submit 'Save changes', class: "btn btn-success" = f.submit _('Save changes'), class: "btn btn-success"
...@@ -66,17 +66,17 @@ ...@@ -66,17 +66,17 @@
.col-lg-4.profile-settings-sidebar .col-lg-4.profile-settings-sidebar
%h4.prepend-top-0 %h4.prepend-top-0
Localization = _('Localization')
%p %p
Customize language and region related settings. = _('Customize language and region related settings.')
= succeed '.' do = succeed '.' do
= link_to 'Learn more', help_page_path('user/profile/preferences', anchor: 'localization'), target: '_blank' = link_to _('Learn more'), help_page_path('user/profile/preferences', anchor: 'localization'), target: '_blank'
.col-lg-8 .col-lg-8
.form-group .form-group
= f.label :first_day_of_week, class: 'label-bold' do = f.label :first_day_of_week, class: 'label-bold' do
First day of the week = _('First day of the week')
= f.select :first_day_of_week, first_day_of_week_choices, {}, class: 'form-control' = f.select :first_day_of_week, first_day_of_week_choices_with_default, {}, class: 'form-control'
.form-text.text-muted .form-text.text-muted
Choose on what day the week should start. = _('Choose on what day the week should start.')
.form-group .form-group
= f.submit 'Save changes', class: 'btn btn-success' = f.submit _('Save changes'), class: 'btn btn-success'
...@@ -97,5 +97,5 @@ This following setting allows you to customize calendar layouts. ...@@ -97,5 +97,5 @@ This following setting allows you to customize calendar layouts.
### First day of the week ### First day of the week
You can choose between **Default**, **Sunday** and **Monday** for the first day of the week. If you select **Default**, the system-wide default setting will be used. You can choose between **System Default**, **Sunday** and **Monday** for the first day of the week. If you select **System Default**, the system-wide default setting will be used.
This preference will be used for all calendar views and datepickers. This preference will be used for all calendar views and datepickers.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment