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
cost query - filter by cf value but return id
ulferts90a53a0aad8d
diff --git a/modules/reporting/app/models/cost_query/custom_field_mixin.rb b/modules/reporting/app/models/cost_query/custom_field_mixin.rbindex a0e34d72542..117f37852cf 100644--- a/modules/reporting/app/models/cost_query/custom_field_mixin.rb+++ b/modules/reporting/app/models/cost_query/custom_field_mixin.rb@@ -122,7 +122,8 @@ module CostQuery::CustomFieldMixin-- BEGIN Custom Field Join: #{cf_name}LEFT OUTER JOIN (SELECT- CAST(co.value AS #{cast_as}) AS #{cf_name},+ co.id AS #{cf_name},+ co.value,cv.customized_type,cv.custom_field_id,cv.customized_iddiff --git a/modules/reporting/app/models/cost_query/filter/custom_field_entries.rb b/modules/reporting/app/models/cost_query/filter/custom_field_entries.rbindex f75bcd5c70d..e30f71103b7 100644--- a/modules/reporting/app/models/cost_query/filter/custom_field_entries.rb+++ b/modules/reporting/app/models/cost_query/filter/custom_field_entries.rb@@ -45,6 +45,21 @@ class CostQuery::Filter::CustomFieldEntries < Report::Filter::Baseendend+ def self.field+ # There is a special treatment for how list custom values are retrieved as those+ # are not taken directly from the custom_values but from the custom_options table.+ # But the value still has to be the id of the option which is later on mapped to the+ # human readable value.+ # Mapping to the human readable value is done for all custom values (e.g. users, versions)+ # following the same pattern of code, so simply making the exception here to use the value+ # would complicated the code later on.+ if custom_field.field_format == 'list'+ "#{db_field}.value"+ else+ super+ end+ end+def self.available_values(*)@possible_values || get_possible_valuesenddiff --git a/modules/reporting/spec/features/custom_fields_spec.rb b/modules/reporting/spec/features/custom_fields_spec.rbindex be44dc04195..13c1e97ab3c 100644--- a/modules/reporting/spec/features/custom_fields_spec.rb+++ b/modules/reporting/spec/features/custom_fields_spec.rb@@ -105,7 +105,7 @@ describe 'Custom fields reporting', type: :feature, js: true do# Expect empty result tablewithin('#result-table') do- expect(page).to have_no_selector('.top.result', text: '12.50 hours')+ expect(page).not_to have_selector('.top.result', text: '12.50 hours')endexpect(page).to have_selector('.generic-table--no-results-title')@@ -132,8 +132,9 @@ describe 'Custom fields reporting', type: :feature, js: true do# Expect row of work packagewithin('#result-table') doexpect(page).to have_selector('a.work_package', text: "#{work_package.type} ##{work_package.id}")- expect(page).to have_selector('th.inner', text: 'First option')- expect(page).to have_no_selector('th.inner', text: 'Second option')+ # There used to be additional and unwanted text after the option name being rendered.+ expect(page).to have_selector('th.inner', text: /^First option$/)+ expect(page).not_to have_selector('th.inner', text: 'Second option')# Only first option should have content for the work packageexpect(page).to have_selector('table.report tbody tr', count: 1)@@ -195,7 +196,7 @@ describe 'Custom fields reporting', type: :feature, js: true dowithin('#result-table') doexpect(page).to have_selector('a.work_package', text: "#{work_package.type} ##{work_package.id}")expect(page).to have_selector('th.inner', text: '1')- expect(page).to have_no_selector('th.inner', text: 'invalid!')+ expect(page).not_to have_selector('th.inner', text: 'invalid!')endendend@@ -228,7 +229,7 @@ describe 'Custom fields reporting', type: :feature, js: true dowithin('#result-table') doexpect(page).to have_selector('a.work_package', text: "#{work_package.type} ##{work_package.id}")expect(page).to have_selector('th.inner', text: 'foo')- expect(page).to have_no_selector('th.inner', text: 'None')+ expect(page).not_to have_selector('th.inner', text: 'None')# Only first option should have content for the work packageexpect(page).to have_selector('table.report tbody tr', count: 1)