From 66ec9a820e564c2754b3ff17af24746bac520bdd Mon Sep 17 00:00:00 2001 From: Akira Saito Date: Sun, 7 Jun 2015 21:56:33 +0900 Subject: [PATCH] add clear option --- app/controllers/quick_edit_issues_controller.rb | 9 +++-- app/views/hooks/_quick_edit_base_bottom.html.erb | 38 +++++++++++++++------- app/views/quick_edit_issues/_input_dialog.html.erb | 12 ++++--- 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/app/controllers/quick_edit_issues_controller.rb b/app/controllers/quick_edit_issues_controller.rb index 31ff85f..080e00b 100644 --- a/app/controllers/quick_edit_issues_controller.rb +++ b/app/controllers/quick_edit_issues_controller.rb @@ -59,6 +59,9 @@ private default_value = "" if default_value.nil? validation_pattern = get_field_validation_pattern(field_type) help_message = get_field_help_message(field_type) + clear_pseudo_value = nil + clear_pseudo_value = 'none' if %w(parent_issue_id start_date due_date estimated_hours).include?(attribute_name) + ret = { :attribute_name => attribute_name.to_sym, :caption => caption, @@ -66,7 +69,8 @@ private :field_type => field_type, :default_value => default_value, :validation_pattern => validation_pattern, - :help_message => help_message + :help_message => help_message, + :clear_pseudo_value => clear_pseudo_value } end @@ -87,7 +91,8 @@ private :field_type => field_type, :default_value => default_value, :validation_pattern => validation_pattern, - :help_message => help_message + :help_message => help_message, + :clear_pseudo_value => '__none__' } end diff --git a/app/views/hooks/_quick_edit_base_bottom.html.erb b/app/views/hooks/_quick_edit_base_bottom.html.erb index d7f473f..79d29b9 100644 --- a/app/views/hooks/_quick_edit_base_bottom.html.erb +++ b/app/views/hooks/_quick_edit_base_bottom.html.erb @@ -111,22 +111,38 @@ function quick_edit_input_dialog_cancel(){ $("#quick_edit_input_dialog").dialog("close"); } -function quick_edit_input_dialog_submit(){ - var new_value = $("#quick_edit_input_dialog #new_value").val(); - if(new_value === null) return; - console.log ("new:" + new_value); +function quick_edit_clear(){ +} - var pattern = new RegExp($("#quick_edit_input_dialog > form > div > #validation_pattern").val()); +function quick_edit_input_dialog_submit(){ + var target_specifier = $("#quick_edit_input_dialog #target_specifier").val(); + var new_value_element = $("#quick_edit_input_dialog #new_value"); + var clr_value_element = $("#quick_edit_input_dialog #clear"); - if(new_value == "") { - alert('<%=l(:text_is_required)%>'); - return; + if ($("#quick_edit_input_dialog #clear:checked").length > 0){ + new_value_element.attr("name", "_quick_edit_tmp"); + clr_value_element.attr("name", target_specifier); } else { + new_value_element.attr("name", target_specifier); + clr_value_element.attr("name", "_quick_edit_tmp"); + + var new_value = $("#quick_edit_input_dialog #new_value").val(); + if(new_value === null) return; + console.log ("new:" + new_value); - if(pattern && !pattern.test(new_value)){ - alert('<%=l(:text_invalid_format)%>'); - return; + var pattern = new RegExp($("#quick_edit_input_dialog > form > div > #validation_pattern").val()); + + if(new_value == "") { + alert('<%=l(:text_is_required)%>'); + return; + + } else { + + if(pattern && !pattern.test(new_value)){ + alert('<%=l(:text_invalid_format)%>'); + return; + } } } diff --git a/app/views/quick_edit_issues/_input_dialog.html.erb b/app/views/quick_edit_issues/_input_dialog.html.erb index dfd484b..ef12077 100644 --- a/app/views/quick_edit_issues/_input_dialog.html.erb +++ b/app/views/quick_edit_issues/_input_dialog.html.erb @@ -18,14 +18,12 @@ <% case @dialog_params[:field_type] %> <% when :date %> <%= calendar_for('new_value') %> <% when :int, :float %> @@ -35,7 +33,6 @@ <% end %> <% when :text %> @@ -44,10 +41,12 @@ <% end %> <% else %> + <% end %> + <% unless @dialog_params[:clear_pseudo_value].nil? %> + Clear <% end %> <% if !@dialog_params[:description].nil? %>
<%= @dialog_params[:description] %>
@@ -55,6 +54,7 @@ <% @dialog_params[:issue_ids].each do |id| %> <% end %> + @@ -66,6 +66,10 @@