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
feat[Op#50737]: Expand FrameComponent to allow explicit id with context
Kabiru Mwenjadad0c2420f31
diff --git a/app/components/op_turbo/frame_component.rb b/app/components/op_turbo/frame_component.rbindex 6f3876a84ad..4db96dd27a0 100644--- a/app/components/op_turbo/frame_component.rb+++ b/app/components/op_turbo/frame_component.rb@@ -29,7 +29,19 @@module OpTurboclass FrameComponent < ApplicationComponentdef turbo_frame_id+ optional_custom_id || turbo_frame_id_from_model+ end++ private++ def turbo_frame_id_from_modelActionView::RecordIdentifier.dom_id(model, options[:context])end++ def optional_custom_id+ return if options[:id].blank?++ options.values_at(:context, :id).compact.join("_")+ endendenddiff --git a/spec/components/op_turbo/frame_component_spec.rb b/spec/components/op_turbo/frame_component_spec.rbindex 9a056f96810..6cbd030a1df 100644--- a/spec/components/op_turbo/frame_component_spec.rb+++ b/spec/components/op_turbo/frame_component_spec.rb@@ -47,5 +47,21 @@ RSpec.describe OpTurbo::FrameComponent, type: :component doexpect(component.turbo_frame_id).to eq('storages_nextcloud_storage_1')endend++ context 'with `id:` option' do+ it 'returns the turbo frame id' do+ component = described_class.new(id: 'test_id')++ expect(component.turbo_frame_id).to eq('test_id')+ end+ end++ context 'with `id:` and `context:` option' do+ it 'returns the turbo frame id' do+ component = described_class.new(id: 'test_id', context: :general_info)++ expect(component.turbo_frame_id).to eq('general_info_test_id')+ end+ endendend