Commit cf4bbd4f authored by haghighi_ahmad's avatar haghighi_ahmad

Add Saturday to first day of the week

fix #58023

docs for adding Saturday for first day of the week
add related settings for Saturday as first day of the week
firstDayOfWeek: Use enumeration, replace day's numbers with corresponding names
make some variables lowercase (follow camelCase)
add CHANGELOG entry

Author:    haghighi_ahmad <haghighi.ahmad@gmail.com>

modified:   app/assets/javascripts/pages/users/activity_calendar.js
modified:   app/helpers/preferences_helper.rb
new file:   changelogs/unreleased/58023-add-Saturday-to-localization-first-day-of-the-week.yml
modified:   doc/api/settings.md
modified:   doc/user/profile/preferences.md
modified:   locale/gitlab.pot
modified:   spec/helpers/preferences_helper_spec.rb
parent 7f3a1030
...@@ -10,6 +10,12 @@ import { __ } from '~/locale'; ...@@ -10,6 +10,12 @@ import { __ } from '~/locale';
const d3 = { select, scaleLinear, scaleThreshold }; const d3 = { select, scaleLinear, scaleThreshold };
const firstDayOfWeekChoices = Object.freeze({
sunday: 0,
monday: 1,
saturday: 6,
});
const LOADING_HTML = ` const LOADING_HTML = `
<div class="text-center"> <div class="text-center">
<i class="fa fa-spinner fa-spin user-calendar-activities-loading"></i> <i class="fa fa-spinner fa-spin user-calendar-activities-loading"></i>
...@@ -49,7 +55,7 @@ export default class ActivityCalendar { ...@@ -49,7 +55,7 @@ export default class ActivityCalendar {
timestamps, timestamps,
calendarActivitiesPath, calendarActivitiesPath,
utcOffset = 0, utcOffset = 0,
firstDayOfWeek = 0, firstDayOfWeek = firstDayOfWeekChoices.sunday,
monthsAgo = 12, monthsAgo = 12,
) { ) {
this.calendarActivitiesPath = calendarActivitiesPath; this.calendarActivitiesPath = calendarActivitiesPath;
...@@ -206,11 +212,16 @@ export default class ActivityCalendar { ...@@ -206,11 +212,16 @@ export default class ActivityCalendar {
}, },
]; ];
if (this.firstDayOfWeek === 1) { if (this.firstDayOfWeek === firstDayOfWeekChoices.monday) {
days.push({ days.push({
text: 'S', text: 'S',
y: 29 + this.dayYPos(7), y: 29 + this.dayYPos(7),
}); });
} else if (this.firstDayOfWeek === firstDayOfWeekChoices.saturday) {
days.push({
text: 'S',
y: 29 + this.dayYPos(6),
});
} }
this.svg this.svg
......
...@@ -46,7 +46,8 @@ module PreferencesHelper ...@@ -46,7 +46,8 @@ module PreferencesHelper
def first_day_of_week_choices def first_day_of_week_choices
[ [
[_('Sunday'), 0], [_('Sunday'), 0],
[_('Monday'), 1] [_('Monday'), 1],
[_('Saturday'), 6]
] ]
end end
......
---
title: Add Saturday to Localization first day of the week
merge_request: 25509
author: Ahmad Haghighi
type: added
...@@ -161,7 +161,7 @@ are listed in the descriptions of the relevant settings. ...@@ -161,7 +161,7 @@ are listed in the descriptions of the relevant settings.
| `email_author_in_body` | boolean | no | Some email servers do not support overriding the email sender name. Enable this option to include the name of the author of the issue, merge request or comment in the email body instead. | | `email_author_in_body` | boolean | no | Some email servers do not support overriding the email sender name. Enable this option to include the name of the author of the issue, merge request or comment in the email body instead. |
| `enabled_git_access_protocol` | string | no | Enabled protocols for Git access. Allowed values are: `ssh`, `http`, and `nil` to allow both protocols. | | `enabled_git_access_protocol` | string | no | Enabled protocols for Git access. Allowed values are: `ssh`, `http`, and `nil` to allow both protocols. |
| `enforce_terms` | boolean | no | (**If enabled, requires:** `terms`) Enforce application ToS to all users. | | `enforce_terms` | boolean | no | (**If enabled, requires:** `terms`) Enforce application ToS to all users. |
| `first_day_of_week` | integer | no | Start day of the week for calendar views and date pickers. Valid values are `0` (default) for Sunday and `1` for Monday. | | `first_day_of_week` | integer | no | Start day of the week for calendar views and date pickers. Valid values are `0` (default) for Sunday, `1` for Monday, and `6` for Saturday. |
| `gitaly_timeout_default` | integer | no | Default Gitaly timeout, in seconds. This timeout is not enforced for git fetch/push operations or Sidekiq jobs. Set to `0` to disable timeouts. | | `gitaly_timeout_default` | integer | no | Default Gitaly timeout, in seconds. This timeout is not enforced for git fetch/push operations or Sidekiq jobs. Set to `0` to disable timeouts. |
| `gitaly_timeout_fast` | integer | no | Gitaly fast operation timeout, in seconds. Some Gitaly operations are expected to be fast. If they exceed this threshold, there may be a problem with a storage shard and 'failing fast' can help maintain the stability of the GitLab instance. Set to `0` to disable timeouts. | | `gitaly_timeout_fast` | integer | no | Gitaly fast operation timeout, in seconds. Some Gitaly operations are expected to be fast. If they exceed this threshold, there may be a problem with a storage shard and 'failing fast' can help maintain the stability of the GitLab instance. Set to `0` to disable timeouts. |
| `gitaly_timeout_medium` | integer | no | Medium Gitaly timeout, in seconds. This should be a value between the Fast and the Default timeout. Set to `0` to disable timeouts. | | `gitaly_timeout_medium` | integer | no | Medium Gitaly timeout, in seconds. This should be a value between the Fast and the Default timeout. Set to `0` to disable timeouts. |
......
...@@ -103,4 +103,10 @@ Select your preferred language from a list of supported languages. ...@@ -103,4 +103,10 @@ Select your preferred language from a list of supported languages.
The first day of the week can be customised for calendar views and date pickers. The first day of the week can be customised for calendar views and date pickers.
You can choose **Sunday** or **Monday** as the first day of the week. If you select **System Default**, the system-wide default setting will be used. You can choose one of the following options as the first day of the week:
- Saturday
- Sunday
- Monday
If you select **System Default**, the system-wide default setting will be used.
...@@ -6464,6 +6464,9 @@ msgstr "" ...@@ -6464,6 +6464,9 @@ msgstr ""
msgid "SSL Verification" msgid "SSL Verification"
msgstr "" msgstr ""
msgid "Saturday"
msgstr ""
msgid "Save" msgid "Save"
msgstr "" msgstr ""
......
...@@ -36,10 +36,11 @@ describe PreferencesHelper do ...@@ -36,10 +36,11 @@ describe PreferencesHelper do
end end
describe '#first_day_of_week_choices' do describe '#first_day_of_week_choices' do
it 'returns Sunday and Monday as choices' do it 'returns Saturday, Sunday and Monday as choices' do
expect(helper.first_day_of_week_choices).to eq [ expect(helper.first_day_of_week_choices).to eq [
['Sunday', 0], ['Sunday', 0],
['Monday', 1] ['Monday', 1],
['Saturday', 6]
] ]
end end
end end
...@@ -47,14 +48,21 @@ describe PreferencesHelper do ...@@ -47,14 +48,21 @@ describe PreferencesHelper do
describe '#first_day_of_week_choices_with_default' do describe '#first_day_of_week_choices_with_default' do
it 'returns choices including system default' do it 'returns choices including system default' do
expect(helper.first_day_of_week_choices_with_default).to eq [ expect(helper.first_day_of_week_choices_with_default).to eq [
['System default (Sunday)', nil], ['Sunday', 0], ['Monday', 1] ['System default (Sunday)', nil], ['Sunday', 0], ['Monday', 1], ['Saturday', 6]
] ]
end end
it 'returns choices including system default set to Monday' do it 'returns choices including system default set to Monday' do
stub_application_setting(first_day_of_week: 1) stub_application_setting(first_day_of_week: 1)
expect(helper.first_day_of_week_choices_with_default).to eq [ expect(helper.first_day_of_week_choices_with_default).to eq [
['System default (Monday)', nil], ['Sunday', 0], ['Monday', 1] ['System default (Monday)', nil], ['Sunday', 0], ['Monday', 1], ['Saturday', 6]
]
end
it 'returns choices including system default set to Saturday' do
stub_application_setting(first_day_of_week: 6)
expect(helper.first_day_of_week_choices_with_default).to eq [
['System default (Saturday)', nil], ['Sunday', 0], ['Monday', 1], ['Saturday', 6]
] ]
end end
end end
......
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