mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-15 09:11:07 +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-device.js' => 'a205cf28',
|
||||||
'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '6d49590e',
|
'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '6d49590e',
|
||||||
'rsrc/js/core/behavior-error-log.js' => '6882e80a',
|
'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-file-tree.js' => '88236f00',
|
||||||
'rsrc/js/core/behavior-form.js' => '5c54cbf3',
|
'rsrc/js/core/behavior-form.js' => '5c54cbf3',
|
||||||
'rsrc/js/core/behavior-gesture.js' => '3ab51e2c',
|
'rsrc/js/core/behavior-gesture.js' => '3ab51e2c',
|
||||||
|
@ -579,7 +579,7 @@ return array(
|
||||||
'javelin-behavior-durable-column' => 'c72aa091',
|
'javelin-behavior-durable-column' => 'c72aa091',
|
||||||
'javelin-behavior-error-log' => '6882e80a',
|
'javelin-behavior-error-log' => '6882e80a',
|
||||||
'javelin-behavior-event-all-day' => '38dcf3c8',
|
'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-global-drag-and-drop' => 'c8e57404',
|
||||||
'javelin-behavior-herald-rule-editor' => '7ebaeed3',
|
'javelin-behavior-herald-rule-editor' => '7ebaeed3',
|
||||||
'javelin-behavior-high-security-warning' => 'a464fe03',
|
'javelin-behavior-high-security-warning' => 'a464fe03',
|
||||||
|
@ -1279,6 +1279,13 @@ return array(
|
||||||
'javelin-workflow',
|
'javelin-workflow',
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
),
|
),
|
||||||
|
'665cf6ac' => array(
|
||||||
|
'javelin-behavior',
|
||||||
|
'javelin-util',
|
||||||
|
'javelin-dom',
|
||||||
|
'javelin-stratcom',
|
||||||
|
'javelin-vector',
|
||||||
|
),
|
||||||
'6882e80a' => array(
|
'6882e80a' => array(
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
),
|
),
|
||||||
|
@ -1909,13 +1916,6 @@ return array(
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
'phabricator-draggable-list',
|
'phabricator-draggable-list',
|
||||||
),
|
),
|
||||||
'ea5cec5d' => array(
|
|
||||||
'javelin-behavior',
|
|
||||||
'javelin-util',
|
|
||||||
'javelin-dom',
|
|
||||||
'javelin-stratcom',
|
|
||||||
'javelin-vector',
|
|
||||||
),
|
|
||||||
'ea681761' => array(
|
'ea681761' => array(
|
||||||
'javelin-behavior',
|
'javelin-behavior',
|
||||||
'javelin-aphlict',
|
'javelin-aphlict',
|
||||||
|
|
|
@ -259,8 +259,13 @@ final class AphrontFormDateControl extends AphrontFormControl {
|
||||||
),
|
),
|
||||||
$time_sel);
|
$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(
|
Javelin::initBehavior('fancy-datepicker', array(
|
||||||
'format' => $this->getDateFormat(),
|
'format' => $this->getDateFormat(),
|
||||||
|
'weekStart' => $week_start,
|
||||||
));
|
));
|
||||||
|
|
||||||
$classes = array();
|
$classes = array();
|
||||||
|
|
|
@ -46,6 +46,16 @@ JX.behavior('fancy-datepicker', function(config, statics) {
|
||||||
return format;
|
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) {
|
var onopen = function(e) {
|
||||||
e.kill();
|
e.kill();
|
||||||
|
|
||||||
|
@ -277,9 +287,12 @@ JX.behavior('fancy-datepicker', function(config, statics) {
|
||||||
// First, render the weekday names.
|
// First, render the weekday names.
|
||||||
var weekdays = 'SMTWTFS';
|
var weekdays = 'SMTWTFS';
|
||||||
var weekday_names = [];
|
var weekday_names = [];
|
||||||
var ii;
|
var week_start = parseInt(get_week_start(), 10);
|
||||||
for (ii = 0; ii < weekdays.length; ii++) {
|
var week_end = weekdays.length + week_start;
|
||||||
weekday_names.push(cell(weekdays.charAt(ii), null, false, 'day-name'));
|
|
||||||
|
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));
|
weeks.push(JX.$N('tr', {}, weekday_names));
|
||||||
|
|
||||||
|
@ -290,7 +303,7 @@ JX.behavior('fancy-datepicker', function(config, statics) {
|
||||||
var start = new Date(
|
var start = new Date(
|
||||||
valid_date.getYear() + 1900,
|
valid_date.getYear() + 1900,
|
||||||
valid_date.getMonth(),
|
valid_date.getMonth(),
|
||||||
1).getDay();
|
1).getDay() - week_start;
|
||||||
|
|
||||||
while (start--) {
|
while (start--) {
|
||||||
days.push(cell('', null, false, 'day-placeholder'));
|
days.push(cell('', null, false, 'day-placeholder'));
|
||||||
|
|
Loading…
Reference in a new issue