Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/14.1' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ulferts committed May 14, 2024
2 parents d823b56 + 493121f commit 8ce2356
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 23 deletions.
28 changes: 13 additions & 15 deletions app/components/projects/configure_view_modal_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Hack to give the draggable autcompleter (ng-select) bound to the dialog
# enough height to display all options.
# This is necessary as long as ng-select does not support popovers.
style: "min-height: 430px")) do |d| %>
style: "min-height: 480px")) do |d| %>
<% d.with_header(variant: :large, mb: 3) %>
<%= render(Primer::Alpha::Dialog::Body.new) do %>
<%= primer_form_with(
Expand All @@ -20,20 +20,18 @@
<% tab_panel.with_tab(selected: true, id: "tab-selects") do |tab| %>
<% tab.with_text { I18n.t("label_columns") } %>
<% tab.with_panel do %>
<div id="op-draggable-autocomplete-container">
<%= helpers.angular_component_tag 'opce-draggable-autocompleter',
inputs: {
options: helpers.projects_columns_options,
selected: selected_columns,
protected: helpers.protected_projects_columns_options,
name: COLUMN_HTML_NAME,
id: 'columns-select',
inputLabel: I18n.t(:'queries.configure_view.columns.input_label'),
inputPlaceholder: I18n.t(:'queries.configure_view.columns.input_placeholder'),
dragAreaLabel: I18n.t(:'queries.configure_view.columns.drag_area_label'),
appendToComponent: true
}%>
</div>
<%= helpers.angular_component_tag 'opce-draggable-autocompleter',
inputs: {
options: helpers.projects_columns_options,
selected: selected_columns,
protected: helpers.protected_projects_columns_options,
name: COLUMN_HTML_NAME,
id: 'columns-select',
inputLabel: I18n.t(:'queries.configure_view.columns.input_label'),
inputPlaceholder: I18n.t(:'queries.configure_view.columns.input_placeholder'),
dragAreaLabel: I18n.t(:'queries.configure_view.columns.drag_area_label'),
appendToComponent: true
}%>
<% end %>
<% end %>
<% tab_panel.with_tab(id: "tab-selects") do |tab| %>
Expand Down
18 changes: 16 additions & 2 deletions app/models/work_package/pdf_export/gantt/gantt_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

module WorkPackage::PDFExport::Gantt
class GanttBuilder
include Redmine::I18n
BAR_CELL_PADDING = 5.to_f
TEXT_CELL_PADDING_H = 3.to_f
TEXT_CELL_PADDING_V = 1.to_f
Expand Down Expand Up @@ -89,6 +90,7 @@ def init_defaults
@nr_columns = (@pdf.bounds.width / @column_width).floor
end

# distribute empty spaces
def adjust_to_pages
# distribute empty space right to the default column widths
distribute_to_next_page_column
Expand Down Expand Up @@ -720,14 +722,26 @@ def build_row_text_lines_group_row(entry, left, right, top)
def build_row_text_lines_wp_info(entry, left, right, top)
text_top = top + TEXT_CELL_PADDING_V
text_bottom = text_top + 8
GanttDataText.new(work_package_info_line(entry.work_package), left, right, text_top, text_bottom, 8)
GanttDataText.new(work_package_info_line(entry.work_package), left, right, text_top, text_bottom, 6)
end

# Returns the info text line for the given work package
# @param [WorkPackage] work_package
# @return [String]
def work_package_info_line(work_package)
"#{work_package.type} ##{work_package.id}"
"#{work_package.type} ##{work_package.id}#{work_package.status}#{work_package_info_line_date work_package}"
end

def work_package_info_line_date(work_package)
if work_package.start_date == work_package.due_date
format_pdf_date(work_package.start_date)
else
"#{format_pdf_date(work_package.start_date)} - #{format_pdf_date(work_package.due_date)}"
end
end

def format_pdf_date(date)
date.nil? ? "" : format_date(date)
end

# Builds the shape for the given work package
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def respond_to?(*)
RSpec.describe WorkPackage::PDFExport::WorkPackageListToPdf do
include Redmine::I18n
include PDFExportSpecUtils
let!(:status_new) { create(:status, name: "New", is_default: true) }
let(:type_standard) { create(:type_standard, name: "Standard", color: create(:color, hexcode: "#FFFF00")) }
let(:type_bug) { create(:type_bug, name: "Bug", color: create(:color, hexcode: "#00FFFF")) }
let!(:type_milestone) { create(:type, name: "Milestone", is_milestone: true, color: create(:color, hexcode: "#FF0000")) }
Expand Down Expand Up @@ -110,6 +111,7 @@ def respond_to?(*)
let(:work_package_task) do
create(:work_package,
project:,
status: status_new,
type: type_standard,
subject: "Work package 1",
start_date: work_package_task_start,
Expand All @@ -119,6 +121,7 @@ def respond_to?(*)
create(:work_package,
project:,
type: type_milestone,
status: status_new,
subject: "Work package 2",
start_date: work_package_milestone_start,
due_date: work_package_milestone_due)
Expand All @@ -127,6 +130,7 @@ def respond_to?(*)
Array.new(50) do
create(:work_package,
project:,
status: status_new,
subject: "Work package Filler",
start_date: work_package_task_start,
due_date: work_package_task_due,
Expand All @@ -147,8 +151,16 @@ def show_calls
pp pdf[:calls]
end

def wp_title_dates(work_package)
if work_package.start_date == work_package.due_date
format_date(work_package.start_date)
else
"#{format_date(work_package.start_date)} - #{format_date(work_package.due_date)}"
end
end

def wp_title_column(work_package)
"#{work_package.type} ##{work_package.id} #{work_package.subject}"
"#{work_package.type} ##{work_package.id} #{work_package.status}#{wp_title_dates work_package} #{work_package.subject}"
end

subject(:pdf) do
Expand All @@ -173,7 +185,7 @@ def include_calls?(calls_to_find, all_calls)
expect(pdf[:strings]).to eq [query.name, "2024 Apr 21 22 23", # header columns
wp_title_column(work_package_task),
wp_title_column(work_package_milestone),
"1/1", export_time_formatted, query.name].join(" ")
"1/1", export_time_formatted, query.name].join(" ").squeeze(" ")

# if one of these expect fails you can output the actual pdf calls uncommenting the following line
# show_calls
Expand Down Expand Up @@ -207,7 +219,7 @@ def include_calls?(calls_to_find, all_calls)
wp_title_column(work_package_milestone),
"1/2", export_time_formatted, query.name,
"2024 May 6 7 8", # header columns
"2/2", export_time_formatted, query.name].join(" ")
"2/2", export_time_formatted, query.name].join(" ").squeeze(" ")

# if one of these expect fails you can output the actual pdf calls uncommenting the following line
# show_calls
Expand Down Expand Up @@ -261,7 +273,7 @@ def include_calls?(calls_to_find, all_calls)

"2024 May 6 7 8", # header columns
"6/6", export_time_formatted, query.name
].flatten.join(" ")
].flatten.join(" ").squeeze(" ")
end

it "contains correct data" do
Expand Down Expand Up @@ -313,7 +325,7 @@ def include_calls?(calls_to_find, all_calls)
filler_work_packages.slice(35, 15).map { |wp| wp_title_column(wp) },
wp_title_column(work_package_milestone),
"3/3", export_time_formatted, query.name
].flatten.join(" ")
].flatten.join(" ").squeeze(" ")
end

it "contains correct data" do
Expand Down Expand Up @@ -352,7 +364,7 @@ def include_calls?(calls_to_find, all_calls)
wp_title_column(work_package_milestone),
type_standard.name,
wp_title_column(work_package_task),
"1/1", export_time_formatted, query.name].join(" ")
"1/1", export_time_formatted, query.name].join(" ").squeeze(" ")

# if one of these expect fails you can output the actual pdf calls uncommenting the following line
# show_calls
Expand Down

0 comments on commit 8ce2356

Please sign in to comment.