OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#48649] Only show the attributes in the pdf export enabled for the work package type
as-ope797bfcd38a1
diff --git a/app/models/work_package/pdf_export/work_package_detail.rb b/app/models/work_package/pdf_export/work_package_detail.rbindex 57c961c684f..75945e963d8 100644--- a/app/models/work_package/pdf_export/work_package_detail.rb+++ b/app/models/work_package/pdf_export/work_package_detail.rb@@ -74,11 +74,7 @@ module WorkPackage::PDFExport::WorkPackageDetailenddef write_attributes_table!(work_package)- rows = if respond_to?(:column_objects)- build_columns_table_rows(work_package)- else- build_attributes_table_rows(work_package)- end+ rows = attribute_table_rows(work_package)with_margin(styles.wp_attributes_table_margins) dopdf.table(rows,@@ -95,54 +91,49 @@ module WorkPackage::PDFExport::WorkPackageDetailwidths.map { |w| w * ratio }end- def build_columns_table_rows(work_package)- list = column_objects.reject { |column| column.name == :subject }+ def attribute_table_rows(work_package)+ list = if respond_to?(:column_objects)+ attributes_list_by_columns(work_package)+ else+ attributes_list_by_wp(work_package)+ end0.step(list.length - 1, 2).map do |i|build_columns_table_cells(list[i], work_package) +build_columns_table_cells(list[i + 1], work_package)endend- def build_attributes_table_rows(work_package)- # get work package attribute table rows data [[label, value, label, value]]- attrs = %i[+ def attributes_list_by_columns(_work_package)+ column_objects+ .reject { |column| column.name == :subject }+ .map { |column| [column.caption || '', column.name] }+ end++ def attributes_list_by_wp(_work_package)+ col_names = %i[idupdated_attypecreated_atstatusdue_date- version- priorityduration- work- category+ priorityassigned_to+ responsible]- 0.step(attrs.length - 1, 2).map do |i|- build_attributes_table_cells(attrs[i], work_package) +- build_attributes_table_cells(attrs[i + 1], work_package)+ col_names.map do |col_name|+ [WorkPackage.human_attribute_name(col_name), col_name]endend- def build_attributes_table_cells(attribute, work_package)- # get work package attribute table cell data: [label, value]- return ['', ''] if attribute.nil?-- build_attributes_row(WorkPackage.human_attribute_name(attribute) || '', attribute.to_sym, work_package)- end-- def build_columns_table_cells(column, work_package)- return ['', ''] if column.nil?-- build_attributes_row(column.caption || '', column.name, work_package)- end+ def build_columns_table_cells(title_name_array, work_package)+ return ['', ''] if title_name_array.nil?- def build_attributes_row(label, col_name, work_package)# get work package attribute table cell data: [label, value][- pdf.make_cell(label.upcase, styles.wp_attributes_table_label_cell),- get_column_value_cell(work_package, col_name)+ pdf.make_cell(title_name_array[0].upcase, styles.wp_attributes_table_label_cell),+ get_column_value_cell(work_package, title_name_array[1])]end