##// END OF EJS Templates
set default issue start/due datepicker from due/start date (#14024)...
Toshi MARUYAMA -
r11653:0e20ec697b82
parent child
Show More
@@ -0,0 +1,16
1 function beforeShowDatePicker(input, inst) {
2 var default_date = null;
3 switch ($(input).attr("id")) {
4 case "issue_start_date" :
5 if ($("#issue_due_date").size() > 0) {
6 default_date = $("#issue_due_date").val();
7 }
8 break;
9 case "issue_due_date" :
10 if ($("#issue_start_date").size() > 0) {
11 default_date = $("#issue_start_date").val();
12 }
13 break;
14 }
15 $(input).datepicker("option", "defaultDate", default_date);
16 }
@@ -1075,6 +1075,7 module ApplicationHelper
1075
1075
1076 def include_calendar_headers_tags
1076 def include_calendar_headers_tags
1077 unless @calendar_headers_tags_included
1077 unless @calendar_headers_tags_included
1078 tags = javascript_include_tag("datepicker")
1078 @calendar_headers_tags_included = true
1079 @calendar_headers_tags_included = true
1079 content_for :header_tags do
1080 content_for :header_tags do
1080 start_of_week = Setting.start_of_week
1081 start_of_week = Setting.start_of_week
@@ -1082,12 +1083,13 module ApplicationHelper
1082 # Redmine uses 1..7 (monday..sunday) in settings and locales
1083 # Redmine uses 1..7 (monday..sunday) in settings and locales
1083 # JQuery uses 0..6 (sunday..saturday), 7 needs to be changed to 0
1084 # JQuery uses 0..6 (sunday..saturday), 7 needs to be changed to 0
1084 start_of_week = start_of_week.to_i % 7
1085 start_of_week = start_of_week.to_i % 7
1085
1086 tags << javascript_tag(
1086 tags = javascript_tag(
1087 "var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: #{start_of_week}, " +
1087 "var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: #{start_of_week}, " +
1088 "showOn: 'button', buttonImageOnly: true, buttonImage: '" +
1088 "showOn: 'button', buttonImageOnly: true, buttonImage: '" +
1089 path_to_image('/images/calendar.png') +
1089 path_to_image('/images/calendar.png') +
1090 "', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true, changeMonth: true, changeYear: true};")
1090 "', showButtonPanel: true, showWeek: true, showOtherMonths: true, " +
1091 "selectOtherMonths: true, changeMonth: true, changeYear: true, " +
1092 "beforeShow: beforeShowDatePicker};")
1091 jquery_locale = l('jquery.locale', :default => current_language.to_s)
1093 jquery_locale = l('jquery.locale', :default => current_language.to_s)
1092 unless jquery_locale == 'en'
1094 unless jquery_locale == 'en'
1093 tags << javascript_include_tag("i18n/jquery.ui.datepicker-#{jquery_locale}.js")
1095 tags << javascript_include_tag("i18n/jquery.ui.datepicker-#{jquery_locale}.js")
@@ -147,6 +147,22 class Redmine::UiTest::IssuesTest < Redmine::UiTest::Base
147 end
147 end
148 end
148 end
149
149
150 def test_create_issue_start_due_date_default
151 log_user('jsmith', 'jsmith')
152 visit '/projects/ecookbook/issues/new'
153 fill_in 'Start date', :with => '2012-04-01'
154 fill_in 'Due date', :with => ''
155 page.first('p#due_date_area img').click
156 page.first("td.ui-datepicker-days-cell-over a").click
157 assert_equal '2012-04-01', page.find('input#issue_due_date').value
158
159 fill_in 'Start date', :with => ''
160 fill_in 'Due date', :with => '2012-04-01'
161 page.first('p#start_date_area img').click
162 page.first("td.ui-datepicker-days-cell-over a").click
163 assert_equal '2012-04-01', page.find('input#issue_start_date').value
164 end
165
150 def test_preview_issue_description
166 def test_preview_issue_description
151 log_user('jsmith', 'jsmith')
167 log_user('jsmith', 'jsmith')
152 visit '/projects/ecookbook/issues/new'
168 visit '/projects/ecookbook/issues/new'
General Comments 0
You need to be logged in to leave comments. Login now