OSDN Git Service

allow add notes without the field value. refs #35392
authorakrstjp <akrst@users.osdn.me>
Sun, 27 Mar 2016 14:01:39 +0000 (23:01 +0900)
committerakrstjp <akrst@users.osdn.me>
Sun, 27 Mar 2016 14:01:39 +0000 (23:01 +0900)
app/controllers/quick_edit_issues_controller.rb
app/helpers/application_helper.rb
app/views/hooks/_quick_edit_context.html.erb
app/views/quick_edit_issues/_input_dialog.html.erb

index 8e2de37..974182e 100644 (file)
@@ -88,6 +88,11 @@ private
     else
       @custom_field_id = ""
     end
+
+    if @attribute_name == :notes
+      return
+    end
+
     unless @issue.safe_attribute_names.include?(@attribute_name)
       logger.warn "### quick edit ### no safe attribute. target_specifier=" + @target_specifier
       render_404
index 28f630e..615f05d 100644 (file)
@@ -29,7 +29,7 @@ module ApplicationHelper
     end
   end
 
-  def quick_edit_link_to(issue_ids, caption, attribute_name, additional_index, back_url, disabled)
+  def quick_edit_link_to(issue_ids, caption, attribute_name, additional_index, back_url, disabled, icon=%s{icon-edit})
      target_specifier = build_target_specifier(attribute_name, additional_index)
 
      ajax_url = quick_edit_issues_edit_path(:ids => issue_ids, :target_specifier => target_specifier, :back_url => back_url)
@@ -41,7 +41,7 @@ module ApplicationHelper
         context_menu_link(
            h(caption),
            ajax_url,
-           :class => 'quick_edit icon-edit',
+           :class => "quick_edit #{icon}",
            :disabled => disabled,
            :remote => true
         )
@@ -49,12 +49,20 @@ module ApplicationHelper
   end   
 
   def build_target_specifier(attribute_name, additional_index)
+    if  attribute_name == :notes
+       return "notes"
+    end
+
     target = "issue[#{attribute_name}]"
     target += "[#{additional_index}]" unless additional_index.nil?
     target
   end
 
   def parse_target_specifier(target_specifier)
+    if target_specifier == "notes"
+      return [:notes]
+    end
+
     /^issue\[(.+?)\].*/ =~ target_specifier
     if Regexp.last_match.nil?
       return nil
@@ -88,6 +96,8 @@ module ApplicationHelper
         l(:field_due_date)
      when :estimated_hours
         l(:field_estimated_hours)
+     when :notes
+        l(:field_notes)
      end
   end
 
@@ -106,6 +116,8 @@ module ApplicationHelper
         :date
      when :estimated_hours
         :float
+     when :notes
+        :text
      end
   end
 
index 9031ef2..9a65f20 100644 (file)
@@ -51,6 +51,8 @@
       <%= quick_edit_link_to(@issue_ids, f.name, 'custom_field_values', f.id, back_url, !editable_custom_field(f,@can,readonly_fields)) %>
       <% end %>
 
+      <%= quick_edit_link_to(@issue_ids, get_attribute_caption(:notes), :notes, nil, back_url, false, %s{icon-comment}) %>
+
       <% if @issues.size <= 2  %>
         <% if User.current.allowed_to?(:manage_issue_relations, @project) %>
         <hr>
index bd746f5..7b485f5 100644 (file)
@@ -4,6 +4,7 @@
   dialog_size[1] += 130 if @dialog_params[:field_type] == :text
   dialog_size[1] += 160 # for notes
   dialog_size[1] += 25 if @dialog_params[:attribute_name]==:description
+  dialog_size[1] -= 160 if @dialog_params[:attribute_name].to_sym == :notes
   dialog_size[1] += 50 unless @dialog_params[:description].nil?
 
   textarea_size = parse_size(Setting.plugin_quick_edit['textarea_size'], 10...256, 80, 10...256, 10)
 
       <%= form_tag({:controller=>'issues', :action=>:bulk_update}) do %>
       <div class="box" style="overflow: auto">
-        <span><%= @dialog_params[:caption] %>:</span>
-        <% case @dialog_params[:field_type] %>
-        <% when :date %>
-        <input id="new_value"
-               type="text" 
-               size="15"
-               value="<%= @dialog_params[:default_value] %>"></input>
-        <%= calendar_for('new_value') %>
-        <% when :int, :float %>
-        <input id="new_value"
-               type="text" 
-               size="15"
-               value="<%= @dialog_params[:default_value] %>"></input>
-          <% if @dialog_params[:target_specifier] == "issue[parent_issue_id]" %>
-          <%= javascript_tag "observeAutocompleteField('new_value', '#{escape_javascript auto_complete_issues_path(:project_id => @issue.project, :scope => (Setting.cross_project_issue_relations? ? 'all' : nil))}')" %>
-          <%= javascript_tag "setPredecessorFieldsVisibility();" %>
-          <% end %>
-        <% when :text %>
-        <textarea id="new_value"
-               class="full_width"
-               cols="<%= textarea_size[0] %>"
-               rows="<%= textarea_size[1] %>"
-               style="vertical-align:middle;"><%= @dialog_params[:default_value] %></textarea>
-        <% if @dialog_params[:attribute_name].to_sym == :description %>
-        <%= wikitoolbar_for 'new_value' %>
-        <% end %>
-        <% else %>
-        <input id="new_value"
-               type="text"
-               class="full_width"
-               size="80"
-               value="<%= @dialog_params[:default_value] %>"></input>
-             <% end %>
-        <% unless @dialog_params[:clear_pseudo_value].nil? %>
-          <input id="clear" name="clear" type="checkbox" value="<%= @dialog_params[:clear_pseudo_value] %>" data-disables="#new_value"><%= l(:button_clear) %></input>
-        <% end %>
-
-        <% if !@dialog_params[:description].nil? %>
-        <pre style="border: 1px solid #e0e0e0; padding: 3px; overflow:auto; height: 2.8em; margin-top: 10px; margin-bottom: 0px;"><%= @dialog_params[:description] %></pre>
-        <% end %>
-
-        <fieldset style="margin-top: 10px;">
-          <legend><%= l(:field_notes) %></legend>
-          <textarea id="notes_for_edit"
-                    name="notes"
+        <% if @dialog_params[:attribute_name].to_sym == :notes %>
+          <span><%= @dialog_params[:caption] %>(Add only):</span>
+          <textarea id="new_value"
+                    name="new_value"
                     class="full_width"
                     rows="5"
                     style="vertical-align:middle"></textarea>
-          <%= wikitoolbar_for :notes_for_edit %>
-          <input id="issue_private_notes_for_edit"
+          <%= wikitoolbar_for :new_value %>
+          <input id="issue_private_notes"
                  name="issue[private_notes]"
                  type="checkbox"
                  value="1"/>
-          <label for="issue_private_notes_for_edit"><%= l(:field_private_notes) %></label>
-        </fieldset>
+          <label for="issue_private_notes"><%= l(:field_private_notes) %></label>
+        <% else %>
+          <span><%= @dialog_params[:caption] %>:</span>
+          <% case @dialog_params[:field_type] %>
+          <% when :date %>
+          <input id="new_value"
+                 type="text" 
+                 size="15"
+                 value="<%= @dialog_params[:default_value] %>"></input>
+          <%= calendar_for('new_value') %>
+          <% when :int, :float %>
+          <input id="new_value"
+                 type="text" 
+                 size="15"
+                 value="<%= @dialog_params[:default_value] %>"></input>
+            <% if @dialog_params[:target_specifier] == "issue[parent_issue_id]" %>
+            <%= javascript_tag "observeAutocompleteField('new_value', '#{escape_javascript auto_complete_issues_path(:project_id => @issue.project, :scope => (Setting.cross_project_issue_relations? ? 'all' : nil))}')" %>
+            <%= javascript_tag "setPredecessorFieldsVisibility();" %>
+            <% end %>
+          <% when :text %>
+          <textarea id="new_value"
+                 class="full_width"
+                 cols="<%= textarea_size[0] %>"
+                 rows="<%= textarea_size[1] %>"
+                 style="vertical-align:middle;"><%= @dialog_params[:default_value] %></textarea>
+          <% if @dialog_params[:attribute_name].to_sym == :description %>
+          <%= wikitoolbar_for 'new_value' %>
+          <% end %>
+          <% else %>
+          <input id="new_value"
+                 type="text"
+                 class="full_width"
+                 size="80"
+                 value="<%= @dialog_params[:default_value] %>"></input>
+               <% end %>
+          <% unless @dialog_params[:clear_pseudo_value].nil? %>
+            <input id="clear" name="clear" type="checkbox" value="<%= @dialog_params[:clear_pseudo_value] %>" data-disables="#new_value"><%= l(:button_clear) %></input>
+          <% end %>
+
+          <% if !@dialog_params[:description].nil? %>
+          <pre style="border: 1px solid #e0e0e0; padding: 3px; overflow:auto; height: 2.8em; margin-top: 10px; margin-bottom: 0px;"><%= @dialog_params[:description] %></pre>
+          <% end %>
+
+          <fieldset style="margin-top: 10px;">
+            <legend><%= l(:field_notes) %></legend>
+            <textarea id="notes_for_edit"
+                      name="notes"
+                      class="full_width"
+                      rows="5"
+                      style="vertical-align:middle"></textarea>
+            <%= wikitoolbar_for :notes_for_edit %>
+            <input id="issue_private_notes_for_edit"
+                   name="issue[private_notes]"
+                   type="checkbox"
+                   value="1"/>
+            <label for="issue_private_notes_for_edit"><%= l(:field_private_notes) %></label>
+          </fieldset>
+        <% end %>
         <% @dialog_params[:issue_ids].each do |id| %>
         <input id="ids" name="ids[]" type="hidden" value="<%= id %>"></input>
         <% end %>