Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Load comments on-demand, todo: update tooltip

  • Loading branch information...
commit a9d32db64966f34c41819fb6a7cacdc92e1d633a 1 parent 9fe6a79
@den-plugins authored
View
34 app/controllers/task_boards_controller.rb
@@ -4,6 +4,8 @@ class TaskBoardsController < ApplicationController
layout 'base'
before_filter :get_project, :authorize, :only => [:index, :show]
before_filter :set_cache_buster
+ before_filter :get_issue, :only => [:update_issue_status, :update_issue, :add_comment, :get_comment]
+
def set_cache_buster
response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
response.headers["Pragma"] = "no-cache"
@@ -58,7 +60,7 @@ def show
@features = @features.select {|f| not f.custom_values.first(:conditions => "value = '#{@selected_team}'").nil? }
@tasks.reject!.each { |t| t if !@features.member? t.super_parent }
end
-
+
@tasks.reject!.each do |f|
if f.version_child?(@version)
p = f.parent.issue_from
@@ -111,7 +113,6 @@ def show
def update_issue_status
get_project
@status = IssueStatus.find(params[:status_id])
- @issue = Issue.find(params[:issue_id])
@issue.init_journal(User.current, "")
@selected_resource = params[:selected_resource] ? params[:selected_resource] : ""
@@ -147,8 +148,7 @@ def update_issue_status
def update_issue
#TODO Permissions trapping - view
- get_project
- @issue = Issue.find(params[:issue_id])
+ get_project
@issue.init_journal(User.current, '')
@issue.update_attributes(params[:issue])
@selected_resource = params[:selected_resource] ? params[:selected_resource] : ""
@@ -180,13 +180,13 @@ def update_issue
def add_comment
get_project
- @issue = Issue.find(params[:issue_id])
@issue.init_journal(User.current, params[:comment])
@issue.update_attributes(params[:issue])
- render :update do |page|
- page.replace_html "#{@issue.id}_discussion".to_sym, :partial => "discussion", :locals => {:issue => @issue}
- page.replace_html "#{@issue.id}_tip".to_sym, page.task_board_tooltip(@issue)
- end
+ render_comment
+ end
+
+ def get_comment
+ render_comment
end
private
@@ -198,10 +198,26 @@ def get_version
@version = Version.find params[:version_id]
end
+ def get_issue
+ @issue = Issue.find(params[:issue_id])
+ end
+
+ def get_journals(ticket)
+ ticket.journals.find(:all, :include => [:user, :journalized], :conditions => "notes <> ''", :order => "created_on DESC")
+ end
+
def ordered_keys(values)
values.keys.sort{|x,y| values[x][:order] <=> values[y][:order]}
end
+ def render_comment
+ @journals = get_journals(@issue)
+ render :update do |page|
+ page.replace_html "#{@issue.id}_discussion".to_sym, :partial => "discussion", :locals => {:issue => @issue}
+ page.replace_html "#{@issue.id}_tip".to_sym, page.task_board_tooltip(@issue)
+ end
+ end
+
def parented_sort(tasks)
psorted = tasks.sort_by {|t| -t.children.count }
sorted = psorted.select {|p| p.parent.nil? && p.children.any?}
View
18 app/helpers/task_boards_helper.rb
@@ -79,16 +79,16 @@ def task_board_tooltip(ticket)
"<strong>#{l(:field_assigned_to)}</strong>: #{ticket.assigned_to}<br />" +
((ticket.feature? or ticket.children.any?) ? "" : "<strong>#{l(:field_estimated_hours)}</strong>: #{ticket.estimated_hours ? ticket.estimated_hours : 0} #{l(:field_sp_hours)}<br />") +
((ticket.feature? or ticket.children.any?) ? "" : "<strong>#{l(:field_remaining_effort)}</strong>: #{ticket.remaining_effort ? ticket.remaining_effort : 0} #{l(:field_sp_hours)}<br />") +
- "<strong>#{l(:field_comments)}</strong>: <br /> <ul>"
- journals = get_journals(ticket).take(5)
- journals.reverse.each do |j|
- content += "<li style='padding-left: 4px; margin: 0;'>&raquo; #{j.notes}</li>"
+ "<strong>#{l(:field_comments)}</strong>: <br />"
+ if @journals
+ content += "<ul>"
+ @journals.take(5).reverse.each do |j|
+ content += "<li style='padding-left: 4px; margin: 0;'>&raquo; #{j.notes}</li>"
+ end
+ content += "</ul>"
+ else
+ content += "<span>Click #{image_tag 'talk.png', :plugin => 'scrum_task_board'} to load comments.</span>"
end
- content += "</ul>"
- end
-
- def get_journals(ticket)
- ticket.journals.find(:all, :include => [:user], :conditions => "notes <> ''", :order => "created_on DESC")
end
end
View
6 app/views/task_boards/_discussion.rhtml
@@ -1,7 +1,7 @@
-<% journals = get_journals(issue) %>
-<% journals.each do |journal| %>
+<% @journals.each do |journal| %>
<div class="comment">
- <h5><%= journal.user %><span class="time_ago"><%= time_tag journal.created_on %> ago</span></h5>
+ <h5><%= journal.user %><br/><span class="time_ago"><%= time_tag journal.created_on %> ago</span></h5>
<%= textilizable(journal, :notes) %>
</div>
<% end %>
+
View
3  app/views/task_boards/_feature.rhtml
@@ -10,7 +10,7 @@
<div class="initial_controls" style="display: none;">
<div class="edit" title="Edit">Edit</div>
<div class="toggle_details maximized" title="Show Details">Show Details</div>
- <div class="talk" title="Comment">Comment</div>
+ <div class="talk" title="Comment" id="<%= feature.id %>_talk">Comment</div>
</div>
<div class="current_data">
<p class="estimate" style="right: 2px;"><%= feature.remaining_effort ? feature.remaining_effort : '' %></p>
@@ -41,7 +41,6 @@
</div>
<div class="discussion">
<div id="<%= feature.id %>_discussion">
- <%= render :partial => "discussion", :locals => {:issue => feature} %>
</div>
</div>
</div>
View
9 app/views/task_boards/_issue.html.erb
@@ -22,7 +22,7 @@
<div class="initial_controls" style="display: none;">
<div class="edit" title="Edit">Edit</div>
<div class="toggle_details maximized" title="Show Details">Show Details</div>
- <div class="talk" title="Comment">Comment</div>
+ <div class="talk" title="Comment" id="<%= issue.id %>_talk">Comment</div>
</div>
<div class="current_data">
@@ -48,17 +48,14 @@
<div class="comment_form_panel">
<% remote_form_for :issue, issue, :url => {:action => "add_comment", :controller => "task_boards",
:id => @project, :issue_id => issue }, :html => {:id => "#{issue.id}_comment_form", :class => "comment_form"},
- :complete => "jQuery('#text_comment_#{issue.id}').val('Type your comment here...');
- var barheight = getbarHeight(jQuery('##{issue.id}_discussion'), 30);
- jQuery('.slimScrollBar').css({height: barheight + 'px'});
- " do |f| %>
+ :complete => "initTalk(#{issue.id});" do |f| %>
<%= text_area_tag "comment", nil, :id => "text_comment_#{issue.id}" %>
<%= f.submit "+", :class => "add" %><div class="clear"></div>
<% end %>
</div>
<div class="discussion">
<div id="<%= issue.id %>_discussion">
- <%= render :partial => "discussion", :locals => {:issue => issue} %>
+
</div>
</div>
</div>
View
46 assets/javascripts/sticky_note.js
@@ -1,5 +1,27 @@
j = jQuery.noConflict(); //This allows Prototype to go undisturbed
+function initTalk(id) {
+ jQuery("#text_comment_" + id).val('Type your comment here...');
+ var barheight = getbarHeight(jQuery("#"+ id + "_discussion"), 30);
+ jQuery('.slimScrollBar').css({height: barheight + 'px'});
+}
+
+
+function markLoaded(id) {
+ var jtextComment = jQuery("#text_comment_" + id);
+ var defaultText = "Type your comment here...";
+ jQuery("#" + id + "_discussion").slimScroll({ height: '150px'});
+ jtextComment.focusout(function(){
+ if(jQuery(this).val() == "") jQuery(this).val(defaultText);
+ });
+ jtextComment.focusin(function(){
+ if(jQuery(this).val() == defaultText) jQuery(this).val("");
+ });
+ jQuery("#issue_" + id + " .talk").addClass("comments_loaded");
+ jQuery("#issue_" + id + " .talk_here").show();
+ initTalk(id);
+}
+
function sticky_note(issue, assigned_to, status_id, issue_id, draggable)
{
jQuery("#" + issue + "").hover(
@@ -16,8 +38,20 @@ function sticky_note(issue, assigned_to, status_id, issue_id, draggable)
jQuery("#" + issue + " .talk").click(function(){
jQuery("#" + issue + " .current_data, #" + issue + " .initial_controls").hide();
- jQuery("#" + issue + " .talk_here").show();
- jQuery("#" + issue + " .talk_here textarea").val("Type your comment here...");
+ if(jQuery(this).hasClass("comments_loaded")) {
+ jQuery("#" + issue + " .talk_here").show();
+ jQuery("#" + issue + " .talk_here textarea").val("Type your comment here...");
+ }
+ else {
+ var id = jQuery(this).attr("id").split("_")[0];
+ console.log(jQuery(this).attr("id").split("_")[0]);
+ new Ajax.Request('/task_boards/get_comment', {
+ asynchronous :true,
+ evalScripts :true,
+ onComplete :function(request){markLoaded(id)},
+ parameters :'issue_id=' + id
+ });
+ }
});
jQuery("#" + issue + " .cancel").click(function(){
@@ -55,14 +89,6 @@ function sticky_note(issue, assigned_to, status_id, issue_id, draggable)
}
});
- jQuery("#" + issue_id + "_discussion").slimScroll({ height: '150px'});
- jQuery("#text_comment_" + issue_id).focusout(function(){
- if(jQuery(this).val() == "") jQuery(this).val("Type your comment here...");
- });
- jQuery("#text_comment_" + issue_id).focusin(function(){
- if(jQuery(this).val() == "Type your comment here...") jQuery(this).val("");
- });
-
if(draggable)
new Draggable(issue, {constraint:"horizontal", revert:"failure"});
}
View
29 assets/stylesheets/task_board.css
@@ -291,13 +291,18 @@
#task_board .talk_here .discussion {
/* overflow: auto;*/
height: 150px;
- background-color: #ccc;
+ background-color: #fafafa;
}
div.discussion .time_ago {
float: right;
}
+.discussion .comment {
+ padding: 0 10px 0 2px;
+ word-wrap: break-word;
+}
+
#task_board .issue_subject {
font-size: 11px;
}
@@ -325,14 +330,16 @@ div.discussion .time_ago {
}
div.tooltip span.tip{
-position: absolute; z-index: 1000;
-display: none;
-/*top:12px; left:24px;*/
-border:1px solid #555;
-background-color:#fff;
-padding: 4px; width:300px;
-font-size: 0.8em;
-color:#505050;
+ position: absolute;
+ z-index: 1000;
+ display: none;
+ /*top:12px; left:24px;*/
+ border:1px solid #555;
+ background-color:#fff;
+ padding: 4px; width:300px;
+ font-size: 0.8em;
+ color:#505050;
+ word-wrap: break-word;
}
.tooltip { display: inline; }
@@ -368,8 +375,9 @@ ul.condensed li {display: inline-block; margin-right: 1px; }
max-height: 45px;
margin-top: 0px;
margin-bottom: 0px;
- resize: none;
overflow: hidden;
+ font-family: Helvetica, Arial;
+ resize: none;
}
.comment_form .add {
@@ -382,6 +390,7 @@ ul.condensed li {display: inline-block; margin-right: 1px; }
vertical-align: center;
margin-right: 1px;
background-color: #82C3F2;
+ cursor: pointer;
}
.comment_form .add:hover {
Please sign in to comment.
Something went wrong with that request. Please try again.