Project

General

Profile

Defect #7280 » gantt_subject_truncation_updated.patch

Anonymous, 2011-02-17 14:28

View differences:

app/views/gantts/show.html.erb
60 60
# Width of the entire chart    
61 61
g_width = (@gantt.date_to - @gantt.date_from + 1)*zoom
62 62

  
63
@gantt.render(:top => headers_height + 8, :zoom => zoom, :g_width => g_width)
63
@gantt.render(:top => headers_height + 8, :zoom => zoom, :g_width => g_width, :subject_width => subject_width)
64 64

  
65 65
g_height = [(20 * (@gantt.number_of_rows + 6))+150, 206].max
66 66
t_height = g_height + headers_height
lib/redmine/helpers/gantt.rb
263 263
      def subject_for_project(project, options)
264 264
        case options[:format]
265 265
        when :html
266
          subject = "<span class='icon icon-projects #{project.overdue? ? 'project-overdue' : ''}'>"
266
          text_style = "width:#{options[:subject_width]-options[:indent]-20}px;" if options[:subject_width]
267

  
268
          subject = "<span class=\"gantt_subject-text icon icon-projects #{project.overdue? ? 'project-overdue' : ''}\""
269
          subject << " style=\"#{text_style}\"" if text_style
270
          subject << '>'
267 271
          subject << view.link_to_project(project)
268 272
          subject << '</span>'
269 273
          html_subject(options, subject, :css => "project-name")
......
301 305
      def subject_for_version(version, options)
302 306
        case options[:format]
303 307
        when :html
304
          subject = "<span class='icon icon-package #{version.behind_schedule? ? 'version-behind-schedule' : ''} #{version.overdue? ? 'version-overdue' : ''}'>"
308
          text_style = "width:#{options[:subject_width]-options[:indent]-20}px;" if options[:subject_width]
309

  
310
          subject = "<span class=\"gantt_subject-text icon icon-package #{version.behind_schedule? ? 'version-behind-schedule' : ''} #{version.overdue? ? 'version-overdue' : ''}\""
311
          subject << " style=\"#{text_style}\"" if text_style
312
          subject << '>'
305 313
          subject << view.link_to_version(version)
306 314
          subject << '</span>'
307 315
          html_subject(options, subject, :css => "version-name")
......
345 353
          
346 354
        output = case options[:format]
347 355
        when :html
348
          css_classes = ''
356

  
357
          css_classes = 'gantt_subject-text'
349 358
          css_classes << ' issue-overdue' if issue.overdue?
350 359
          css_classes << ' issue-behind-schedule' if issue.behind_schedule?
351
          css_classes << ' icon icon-issue' unless Setting.gravatar_enabled? && issue.assigned_to
352
          
353
          subject = "<span class='#{css_classes}'>"
354
          if issue.assigned_to.present?
360

  
361
          if Setting.gravatar_enabled? && issue.assigned_to.present?
355 362
            assigned_string = l(:field_assigned_to) + ": " + issue.assigned_to.name
356
            subject << view.avatar(issue.assigned_to, :class => 'gravatar icon-gravatar', :size => 10, :title => assigned_string)
363
            subject = view.avatar(issue.assigned_to, :class => 'gravatar icon-gravatar', :size => 10, :title => assigned_string)
364
            text_style = 'left:20px;'
365
          else
366
            css_classes << ' icon icon-issue'
367
            subject = ''
368
            text_style = ''
357 369
          end
370

  
371
          text_style += "width:#{options[:subject_width]-options[:indent]-20}px;" if options[:subject_width]
372

  
373
          subject << "<span class=\"#{css_classes}\""
374
          subject << " style=\"#{text_style}\"" if text_style
375
          subject <<  '>'
358 376
          subject << view.link_to_issue(issue)
359 377
          subject << '</span>'
360
          html_subject(options, subject, :css => "issue-subject") + "\n"
378
          html_subject(options, subject, :css => 'issue-subject') + "\n"
361 379
        when :image
362 380
          image_subject(options, issue.subject)
363 381
        when :pdf
......
369 387
          @issue_ancestors << issue
370 388
          options[:indent] += options[:indent_increment]
371 389
        end
372
        
390

  
373 391
        output
374 392
      end
375 393

  
......
709 727
      end
710 728
      
711 729
      def html_subject(params, subject, options={})
712
        output = "<div class=' #{options[:css] }' style='position: absolute;line-height:1.2em;height:16px;top:#{params[:top]}px;left:#{params[:indent]}px;overflow:hidden;'>"
730
        output = "<div class=\"gantt_subject #{options[:css] }\" style=\"top:#{params[:top]}px;left:#{params[:indent]}px;\">"
713 731
        output << subject
714 732
        output << "</div>"
715 733
        @subjects << output
public/stylesheets/application.css
783 783
}
784 784

  
785 785
.gantt_subjects { font-size: 0.8em; }
786
.gantt_subject { position: absolute; height: 16px; line-height: 1.2em; }
787
.gantt_subject-text { position: absolute; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
786 788

  
787 789
.task {
788 790
  position: absolute;
......
924 926

  
925 927
/* Used on 12px Gravatar img tags without the icon background */
926 928
.icon-gravatar {
927
  float: left;
928 929
  margin-right: 4px;
929 930
}
930 931

  
test/unit/lib/redmine/helpers/gantt_test.rb
283 283
    end
284 284
    
285 285
    context ":html format" do
286
      should "add an absolute positioned div" do
287
        @response.body = @gantt.subject_for_project(@project, {:format => :html})
288
        assert_select "div[style*=absolute]"
289
      end
290

  
291 286
      should "use the indent option to move the div to the right" do
292 287
        @response.body = @gantt.subject_for_project(@project, {:format => :html, :indent => 40})
293 288
        assert_select "div[style*=left:40]"
......
449 444
    end
450 445

  
451 446
    context ":html format" do
452
      should "add an absolute positioned div" do
453
        @response.body = @gantt.subject_for_version(@version, {:format => :html})
454
        assert_select "div[style*=absolute]"
455
      end
456

  
457 447
      should "use the indent option to move the div to the right" do
458 448
        @response.body = @gantt.subject_for_version(@version, {:format => :html, :indent => 40})
459 449
        assert_select "div[style*=left:40]"
......
615 605
    end
616 606

  
617 607
    context ":html format" do
618
      should "add an absolute positioned div" do
619
        @response.body = @gantt.subject_for_issue(@issue, {:format => :html})
620
        assert_select "div[style*=absolute]"
621
      end
622

  
623 608
      should "use the indent option to move the div to the right" do
624 609
        @response.body = @gantt.subject_for_issue(@issue, {:format => :html, :indent => 40})
625 610
        assert_select "div[style*=left:40]"
(5-5/6)