mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-14 16:51:08 +01:00
Popup datepicker should respect user preferred week start day
Summary: Fixes T8605, Popup datepicker should respect user preferred week start day Test Plan: Edit event, open datepicker, calendar weeks should start on Sunday by default, and another day, if specified in User Preferences. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T8605 Differential Revision: https://secure.phabricator.com/D13419
This commit is contained in:
parent
2536febed3
commit
109fa94011
3 changed files with 31 additions and 13 deletions
|
@ -445,7 +445,7 @@ return array(
|
|||
'rsrc/js/core/behavior-device.js' => 'a205cf28',
|
||||
'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '6d49590e',
|
||||
'rsrc/js/core/behavior-error-log.js' => '6882e80a',
|
||||
'rsrc/js/core/behavior-fancy-datepicker.js' => 'ea5cec5d',
|
||||
'rsrc/js/core/behavior-fancy-datepicker.js' => '665cf6ac',
|
||||
'rsrc/js/core/behavior-file-tree.js' => '88236f00',
|
||||
'rsrc/js/core/behavior-form.js' => '5c54cbf3',
|
||||
'rsrc/js/core/behavior-gesture.js' => '3ab51e2c',
|
||||
|
@ -579,7 +579,7 @@ return array(
|
|||
'javelin-behavior-durable-column' => 'c72aa091',
|
||||
'javelin-behavior-error-log' => '6882e80a',
|
||||
'javelin-behavior-event-all-day' => '38dcf3c8',
|
||||
'javelin-behavior-fancy-datepicker' => 'ea5cec5d',
|
||||
'javelin-behavior-fancy-datepicker' => '665cf6ac',
|
||||
'javelin-behavior-global-drag-and-drop' => 'c8e57404',
|
||||
'javelin-behavior-herald-rule-editor' => '7ebaeed3',
|
||||
'javelin-behavior-high-security-warning' => 'a464fe03',
|
||||
|
@ -1279,6 +1279,13 @@ return array(
|
|||
'javelin-workflow',
|
||||
'javelin-dom',
|
||||
),
|
||||
'665cf6ac' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-util',
|
||||
'javelin-dom',
|
||||
'javelin-stratcom',
|
||||
'javelin-vector',
|
||||
),
|
||||
'6882e80a' => array(
|
||||
'javelin-dom',
|
||||
),
|
||||
|
@ -1909,13 +1916,6 @@ return array(
|
|||
'javelin-dom',
|
||||
'phabricator-draggable-list',
|
||||
),
|
||||
'ea5cec5d' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-util',
|
||||
'javelin-dom',
|
||||
'javelin-stratcom',
|
||||
'javelin-vector',
|
||||
),
|
||||
'ea681761' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-aphlict',
|
||||
|
|
|
@ -259,8 +259,13 @@ final class AphrontFormDateControl extends AphrontFormControl {
|
|||
),
|
||||
$time_sel);
|
||||
|
||||
$preferences = $this->user->loadPreferences();
|
||||
$pref_week_start = PhabricatorUserPreferences::PREFERENCE_WEEK_START_DAY;
|
||||
$week_start = $preferences->getPreference($pref_week_start, 0);
|
||||
|
||||
Javelin::initBehavior('fancy-datepicker', array(
|
||||
'format' => $this->getDateFormat(),
|
||||
'weekStart' => $week_start,
|
||||
));
|
||||
|
||||
$classes = array();
|
||||
|
|
|
@ -46,6 +46,16 @@ JX.behavior('fancy-datepicker', function(config, statics) {
|
|||
return format;
|
||||
};
|
||||
|
||||
var get_week_start = function() {
|
||||
var week_start = config.weekStart;
|
||||
|
||||
if (week_start === null) {
|
||||
week_start = 0;
|
||||
}
|
||||
|
||||
return week_start;
|
||||
};
|
||||
|
||||
var onopen = function(e) {
|
||||
e.kill();
|
||||
|
||||
|
@ -277,9 +287,12 @@ JX.behavior('fancy-datepicker', function(config, statics) {
|
|||
// First, render the weekday names.
|
||||
var weekdays = 'SMTWTFS';
|
||||
var weekday_names = [];
|
||||
var ii;
|
||||
for (ii = 0; ii < weekdays.length; ii++) {
|
||||
weekday_names.push(cell(weekdays.charAt(ii), null, false, 'day-name'));
|
||||
var week_start = parseInt(get_week_start(), 10);
|
||||
var week_end = weekdays.length + week_start;
|
||||
|
||||
for (var ii = week_start; ii < week_end; ii++) {
|
||||
var index = ii%7;
|
||||
weekday_names.push(cell(weekdays.charAt(index), null, false, 'day-name'));
|
||||
}
|
||||
weeks.push(JX.$N('tr', {}, weekday_names));
|
||||
|
||||
|
@ -290,7 +303,7 @@ JX.behavior('fancy-datepicker', function(config, statics) {
|
|||
var start = new Date(
|
||||
valid_date.getYear() + 1900,
|
||||
valid_date.getMonth(),
|
||||
1).getDay();
|
||||
1).getDay() - week_start;
|
||||
|
||||
while (start--) {
|
||||
days.push(cell('', null, false, 'day-placeholder'));
|
||||
|
|
Loading…
Reference in a new issue