Commit 6003f6ea authored by Alfredo Sumaran's avatar Alfredo Sumaran

Merge branch 'fix-timezone-due-date-picker' into 'master'

Fix timezone due date picker

Closes #24253

See merge request !8081
parents 81dfb1aa 55fe57eb
......@@ -80,9 +80,12 @@
}
parseSelectedDate() {
this.rawSelectedDate = $("input[name='" + this.fieldName + "']").val();
this.rawSelectedDate = $(`input[name='${this.fieldName}']`).val();
if (this.rawSelectedDate.length) {
let dateObj = new Date(this.rawSelectedDate);
// Construct Date object manually to avoid buggy dateString support within Date constructor
const dateArray = this.rawSelectedDate.split('-').map(v => parseInt(v, 10));
const dateObj = new Date(dateArray[0], dateArray[1] - 1, dateArray[2]);
this.displayedDate = $.datepicker.formatDate('M d, yy', dateObj);
} else {
this.displayedDate = 'No due date';
......
......@@ -97,7 +97,7 @@
remove due date
- if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
.selectbox.hide-collapsed
= f.hidden_field :due_date, value: issuable.due_date
= f.hidden_field :due_date, value: issuable.due_date.try(:strftime, 'yy-mm-dd')
.dropdown
%button.dropdown-menu-toggle.js-due-date-select{ type: 'button', data: { toggle: 'dropdown', field_name: "#{issuable.to_ability_name}[due_date]", ability_name: issuable.to_ability_name, issue_update: issuable_json_path(issuable) } }
%span.dropdown-toggle-text Due date
......
---
title: Fix date inconsistency on due date picker
merge_request: 7422
author: Giuliano Varriale
......@@ -619,14 +619,18 @@ describe 'Issues', feature: true do
end
it 'adds due date to issue' do
date = Date.today.at_beginning_of_month + 2.days
page.within '.due_date' do
click_link 'Edit'
page.within '.ui-datepicker-calendar' do
first('.ui-state-default').click
click_link date.day
end
expect(page).to have_no_content 'None'
wait_for_ajax
expect(find('.value').text).to have_content date.strftime('%b %-d, %Y')
end
end
......@@ -638,6 +642,8 @@ describe 'Issues', feature: true do
first('.ui-state-default').click
end
wait_for_ajax
expect(page).to have_no_content 'No due date'
click_link 'remove due date'
......
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