Project

General

Profile

Feature #3143 » add_notes_button_v3.patch

Marius BĂLTEANU, 2016-10-02 15:30

View differences:

app/views/issues/show.html.erb
<div style="clear: both;"></div>
<%= render :partial => 'action_menu' %>
<% if @issue.editable? || User.current.allowed_to?(:add_issue_notes, @project) %>
<%= render :partial => 'journals/notes_new_form' %>
<% end %>
<div style="clear: both;"></div>
<% if @issue.editable? %>
app/views/journals/_notes_new_form.html.erb
<div id="quick-note">
<%= link_to l('button_add_notes'), {}, :id => "add-note", :class => "icon icon-comment", :onclick => "showAddNotesForm(); return false;"%>
<div style="clear: both"></div>
<%= labelled_form_for @issue, :html => {:id => 'journal-new-form', :multipart => true} do |f| %>
<div class="box" id="a">
<fieldset>
<legend><%= l(:field_notes) %></legend>
<%= f.text_area :notes, :id => "journal_new_notes", :class => 'wiki-edit', :rows => 10, :no_label => true %>
<% if @issue.safe_attribute? 'private_notes' %>
<%= f.check_box :private_notes, :no_label => true %>
<label for="issue_private_notes"><%= l(:field_private_notes) %> </label>
<% end %>
<%= call_hook(:view_issues_edit_notes_bottom, { :issue => @issue, :notes => @notes, :form => f }) %>
<p><%= render :partial => 'attachments/form', :locals => {:container => @issue} %></p>
</fieldset>
</div>
<p><%= submit_tag l(:button_submit) %>
<%= preview_link preview_edit_issue_path(:project_id => @project, :id => @issue),
"journal-new-form",
"journal_new_preview" %> |
<%= link_to l(:button_cancel), '#', :onclick => "hideAddNotesForm(); return false;" %></p>
<div id="journal_new_preview" class="wiki"></div>
<% end %>
<%= wikitoolbar_for "journal_new_notes" %>
</div>
config/locales/en.yml
button_reopen: Reopen
button_import: Import
button_filter: Filter
button_add_notes: Add notes
status_active: active
status_registered: registered
public/javascripts/application.js
$('input[data-disables], input[data-enables], input[data-shows]').each(toggleDisabledOnChange);
}
function showAddNotesForm(){
$('#journal-new-form').show().find('#journal_new_notes').focus();
$("a#add-note").hide();
}
function hideAddNotesForm(){
$('#journal-new-form').hide();
$('#add-note').show();
}
function toggleNewObjectDropdown() {
var dropdown = $('#new-object + ul.menu-children');
if(dropdown.hasClass('visible')){
public/javascripts/attachments.js
/* Redmine - project management software
Copyright (C) 2006-2016 Jean-Philippe Lang */
function addFile(inputEl, file, eagerUpload) {
if ($('#attachments_fields').children().length < 10) {
var attachmentsField = $(inputEl).parents('form').find('#attachments_fields')
if (attachmentsField.children().length < 10) {
var attachmentId = addFile.nextAttachmentId++;
......
$('<input>', { type: 'text', 'class': 'filename readonly', name: 'attachments[' + attachmentId + '][filename]', readonly: 'readonly'} ).val(file.name),
$('<input>', { type: 'text', 'class': 'description', name: 'attachments[' + attachmentId + '][description]', maxlength: 255, placeholder: $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload),
$('<a>&nbsp</a>').attr({ href: "#", 'class': 'remove-upload' }).click(removeFile).toggle(!eagerUpload)
).appendTo('#attachments_fields');
).appendTo(attachmentsField);
if(eagerUpload) {
ajaxUpload(file, attachmentId, fileSpan, inputEl);
......
contentType: 'application/octet-stream',
beforeSend: function(jqXhr, settings) {
jqXhr.setRequestHeader('Accept', 'application/js');
// attach proper File object
// attach proper File object
settings.data = blob;
},
xhr: function() {
......
function addInputFiles(inputEl) {
var clearedFileInput = $(inputEl).clone().val('');
var attachmentsField = $(inputEl).parents('from').find('#attachments_fields')
if ($.ajaxSettings.xhr().upload && inputEl.files) {
// upload files using ajax
......
}
}
clearedFileInput.insertAfter('#attachments_fields');
clearedFileInput.insertAfter(attachmentsField);
}
function uploadAndAttachFiles(files, inputEl) {
var maxFileSize = $(inputEl).data('max-file-size');
var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
......
}
function handleFileDropEvent(e) {
$(this).removeClass('fileover');
blockEventPropagation(e);
if ($.inArray('Files', e.dataTransfer.types) > -1) {
uploadAndAttachFiles(e.dataTransfer.files, $('input:file.file_selector'));
uploadAndAttachFiles(e.dataTransfer.files, $(this).find('input:file.file_selector'));
}
}
......
if (window.File && window.FileList && window.ProgressEvent && window.FormData) {
$.event.fixHooks.drop = { props: [ 'dataTransfer' ] };
$('form div.box').has('input:file').each(function() {
$(this).on({
$(this).off().on({
dragover: dragOverHandler,
dragleave: dragOutHandler,
drop: handleFileDropEvent
public/stylesheets/application.css
#issue_tree td.checkbox, #relations td.checkbox {display:none;}
#relations td.buttons {padding:0;}
#quick-note {margin-top: 5px; line-height: 1.4em;}
#quick-note fieldset {margin-top: 5px; background-color: #f6f6f6;}
#quick-note #journal-new-form {display: none;}
fieldset.collapsible {border-width: 1px 0 0 0;}
fieldset.collapsible>legend { padding-left: 16px; background: url(../images/arrow_expanded.png) no-repeat 0% 40%; cursor:pointer; }
fieldset.collapsible.collapsed>legend { background-image: url(../images/arrow_collapsed.png); }
(4-4/14)