add_notes_button_v3.patch

Marius BALTEANU, 2016-10-02 15:30

Download (7.06 KB)

View differences:

app/views/issues/show.html.erb
128 128

  
129 129
<div style="clear: both;"></div>
130 130
<%= render :partial => 'action_menu' %>
131
<% if @issue.editable? || User.current.allowed_to?(:add_issue_notes, @project) %>
132
  <%= render :partial => 'journals/notes_new_form' %>
133
<% end %>
131 134

  
132 135
<div style="clear: both;"></div>
133 136
<% if @issue.editable? %>
app/views/journals/_notes_new_form.html.erb
1
<div id="quick-note">
2
  <%= link_to l('button_add_notes'), {}, :id => "add-note", :class => "icon icon-comment", :onclick => "showAddNotesForm(); return false;"%>
3

  
4
  <div style="clear: both"></div>
5
  <%= labelled_form_for @issue, :html => {:id => 'journal-new-form', :multipart => true} do |f| %>
6
    <div class="box" id="a">
7
      <fieldset>
8
      <legend><%= l(:field_notes) %></legend>
9
      <%= f.text_area :notes, :id => "journal_new_notes", :class => 'wiki-edit', :rows => 10, :no_label => true %>
10

  
11
      <% if @issue.safe_attribute? 'private_notes' %>
12
      <%= f.check_box :private_notes, :no_label => true %>
13
        <label for="issue_private_notes"><%= l(:field_private_notes) %>  </label>
14
      <% end %>
15
      <%= call_hook(:view_issues_edit_notes_bottom, { :issue => @issue, :notes => @notes, :form => f }) %>
16

  
17
      <p><%= render :partial => 'attachments/form', :locals => {:container => @issue} %></p>
18
      </fieldset>
19
    </div>
20
    <p><%= submit_tag l(:button_submit) %>
21
    <%= preview_link preview_edit_issue_path(:project_id => @project, :id => @issue),
22
                     "journal-new-form",
23
                     "journal_new_preview" %> |
24
    <%= link_to l(:button_cancel), '#', :onclick => "hideAddNotesForm(); return false;" %></p>
25

  
26
    <div id="journal_new_preview" class="wiki"></div>
27
<% end %>
28
<%= wikitoolbar_for "journal_new_notes" %>
29
</div>
config/locales/en.yml
1057 1057
  button_reopen: Reopen
1058 1058
  button_import: Import
1059 1059
  button_filter: Filter
1060
  button_add_notes: Add notes
1060 1061

  
1061 1062
  status_active: active
1062 1063
  status_registered: registered
public/javascripts/application.js
730 730
  $('input[data-disables], input[data-enables], input[data-shows]').each(toggleDisabledOnChange);
731 731
}
732 732

  
733
function showAddNotesForm(){
734
  $('#journal-new-form').show().find('#journal_new_notes').focus();
735
  $("a#add-note").hide();
736
}
737
function hideAddNotesForm(){
738
  $('#journal-new-form').hide();
739
  $('#add-note').show();
740
}
741

  
733 742
function toggleNewObjectDropdown() {
734 743
  var dropdown = $('#new-object + ul.menu-children');
735 744
  if(dropdown.hasClass('visible')){
public/javascripts/attachments.js
1 1
/* Redmine - project management software
2 2
   Copyright (C) 2006-2016  Jean-Philippe Lang */
3

  
4 3
function addFile(inputEl, file, eagerUpload) {
5

  
6
  if ($('#attachments_fields').children().length < 10) {
4
  var attachmentsField = $(inputEl).parents('form').find('#attachments_fields')
5
  if (attachmentsField.children().length < 10) {
7 6

  
8 7
    var attachmentId = addFile.nextAttachmentId++;
9 8

  
......
13 12
        $('<input>', { type: 'text', 'class': 'filename readonly', name: 'attachments[' + attachmentId + '][filename]', readonly: 'readonly'} ).val(file.name),
14 13
        $('<input>', { type: 'text', 'class': 'description', name: 'attachments[' + attachmentId + '][description]', maxlength: 255, placeholder: $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload),
15 14
        $('<a>&nbsp</a>').attr({ href: "#", 'class': 'remove-upload' }).click(removeFile).toggle(!eagerUpload)
16
    ).appendTo('#attachments_fields');
15
    ).appendTo(attachmentsField);
17 16

  
18 17
    if(eagerUpload) {
19 18
      ajaxUpload(file, attachmentId, fileSpan, inputEl);
......
102 101
    contentType: 'application/octet-stream',
103 102
    beforeSend: function(jqXhr, settings) {
104 103
      jqXhr.setRequestHeader('Accept', 'application/js');
105
      // attach proper File object 
104
      // attach proper File object
106 105
      settings.data = blob;
107 106
    },
108 107
    xhr: function() {
......
119 118

  
120 119
function addInputFiles(inputEl) {
121 120
  var clearedFileInput = $(inputEl).clone().val('');
121
  var attachmentsField = $(inputEl).parents('from').find('#attachments_fields')
122 122

  
123 123
  if ($.ajaxSettings.xhr().upload && inputEl.files) {
124 124
    // upload files using ajax
......
134 134
    }
135 135
  }
136 136

  
137
  clearedFileInput.insertAfter('#attachments_fields');
137
  clearedFileInput.insertAfter(attachmentsField);
138 138
}
139 139

  
140 140
function uploadAndAttachFiles(files, inputEl) {
141

  
142 141
  var maxFileSize = $(inputEl).data('max-file-size');
143 142
  var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
144 143

  
......
154 153
}
155 154

  
156 155
function handleFileDropEvent(e) {
157

  
158 156
  $(this).removeClass('fileover');
159 157
  blockEventPropagation(e);
160 158

  
161 159
  if ($.inArray('Files', e.dataTransfer.types) > -1) {
162
    uploadAndAttachFiles(e.dataTransfer.files, $('input:file.file_selector'));
160
    uploadAndAttachFiles(e.dataTransfer.files, $(this).find('input:file.file_selector'));
163 161
  }
164 162
}
165 163

  
......
177 175
  if (window.File && window.FileList && window.ProgressEvent && window.FormData) {
178 176

  
179 177
    $.event.fixHooks.drop = { props: [ 'dataTransfer' ] };
180

  
181 178
    $('form div.box').has('input:file').each(function() {
182
      $(this).on({
179
      $(this).off().on({
183 180
          dragover: dragOverHandler,
184 181
          dragleave: dragOutHandler,
185 182
          drop: handleFileDropEvent
public/stylesheets/application.css
404 404
#issue_tree td.checkbox, #relations td.checkbox {display:none;}
405 405
#relations td.buttons {padding:0;}
406 406

  
407
#quick-note {margin-top: 5px; line-height: 1.4em;}
408
#quick-note fieldset {margin-top: 5px; background-color: #f6f6f6;}
409
#quick-note #journal-new-form {display: none;}
410

  
407 411
fieldset.collapsible {border-width: 1px 0 0 0;}
408 412
fieldset.collapsible>legend { padding-left: 16px; background: url(../images/arrow_expanded.png) no-repeat 0% 40%; cursor:pointer; }
409 413
fieldset.collapsible.collapsed>legend { background-image: url(../images/arrow_collapsed.png); }