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
[#66967] Enable custom fields in formula editor
Tobias Dillmann45ea2d038c0d
diff --git a/app/forms/custom_fields/calculated_values/details_form.rb b/app/forms/custom_fields/calculated_values/details_form.rbindex 3b81134a4aa..7d172c8df02 100644--- a/app/forms/custom_fields/calculated_values/details_form.rb+++ b/app/forms/custom_fields/calculated_values/details_form.rb@@ -86,11 +86,11 @@ module CustomFields.map do |op|# Insert operators as plain text nodes instead of tokens, since displaying them as tokens would result# in too much visual clutter. We still want to offer autocompletion for them.- { key: op, label: op, insert_as_text: true }+ { key: op, label: op, insert_as_text: true, enabled: true }endcustom_fields = model.usable_custom_field_references_for_formula.map do |cf|- { key: "cf_#{cf.id}", label: cf.name }+ { key: "cf_#{cf.id}", label: cf.name, enabled: true }end{diff --git a/spec/features/admin/custom_fields/projects/edit_spec.rb b/spec/features/admin/custom_fields/projects/edit_spec.rbindex f1fee9d9bc2..25f7efd2b67 100644--- a/spec/features/admin/custom_fields/projects/edit_spec.rb+++ b/spec/features/admin/custom_fields/projects/edit_spec.rb@@ -102,5 +102,50 @@ RSpec.describe "Edit project custom fields", :js doexpect(page).to have_css(".PageHeader-title", text: original_name)expect(boolean_project_custom_field.reload.name).to eq(original_name)end++ context "when editing a calculated value" do+ using CustomFieldFormulaReferencing++ let!(:calculated_from_int_project_custom_field) do+ create(+ :calculated_value_project_custom_field,+ :skip_validations,+ name: "Calculated field using int",+ formula: "#{integer_project_custom_field} * 2",+ project_custom_field_section: section_for_input_fields+ )+ end++ before do+ login_as(admin)+ visit edit_admin_settings_project_custom_field_path(calculated_from_int_project_custom_field)+ end++ it "allows editing the formula via pattern input component" do+ expect(page).to have_css(".PageHeader-title", text: calculated_from_int_project_custom_field.name)++ expect(page).to have_css("input#custom_field_formula[value='#{integer_project_custom_field} * 2']",+ visible: :hidden)++ # Suggestions drop down is hidden+ expect(page).to have_no_css(".op-pattern-input--suggestions-dropdown .ActionListItem")++ pattern_input = page.find(".op-pattern-input--text-field")+ pattern_input.click+ pattern_input.send_keys(" + ")+ expect(page).to have_no_css(".op-pattern-input--suggestions-dropdown .ActionListItem")++ # Open suggestion list+ pattern_input.send_keys("/")+ within ".op-pattern-input--suggestions-dropdown" do+ expect(page).to have_css(".ActionListItem", text: float_project_custom_field.name)+ click_on(float_project_custom_field.name)+ end++ click_on("Save")+ new_formula = calculated_from_int_project_custom_field.reload.formula_string+ expect(new_formula).to eq("#{integer_project_custom_field} * 2 + #{float_project_custom_field}")+ end+ endendend