Skip to content

Commit

Permalink
Merge pull request #2042 from tf/non-content-element-packs
Browse files Browse the repository at this point in the history
Allow additional frontend packs without content element types
  • Loading branch information
tf authored Dec 20, 2023
2 parents c1e5483 + ca81630 commit b1ff559
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def scrolled_editor_javascript_packs_tag(entry)

def scrolled_frontend_packs(entry, widget_scope:)
['pageflow-scrolled-frontend'] +
scrolled_frontend_content_element_packs(entry, widget_scope) +
scrolled_additional_frontend_packs(entry, widget_scope) +
scrolled_frontend_widget_type_packs(entry, widget_scope)
end

Expand All @@ -36,7 +36,7 @@ def scrolled_editor_packs(entry)

private

def scrolled_frontend_content_element_packs(entry, widget_scope)
def scrolled_additional_frontend_packs(entry, widget_scope)
additional_packs = Pageflow.config_for(entry).additional_frontend_packs
return additional_packs.paths if widget_scope == :editor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def paths
# @api private
def paths_for_content_element_types(type_names)
@packs.reject { |pack|
(pack.content_element_type_names & type_names).empty?
pack.content_element_type_names.present? &&
(pack.content_element_type_names & type_names).empty?
}.map(&:path)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,40 @@ module PageflowScrolled
end

it 'includes additional frontend packs in editor' do
pageflow_configure do |config|
config.for_entry_type(PageflowScrolled.entry_type) do |entry_type_config|
entry_type_config.additional_frontend_packs.register(
'pageflow-scrolled/contentElements/extra'
)
end
end

entry = create(:published_entry, type_name: 'scrolled')

result = helper.scrolled_frontend_packs(entry,
widget_scope: :editor)

expect(result).to include('pageflow-scrolled/contentElements/extra')
end

it 'includes additional frontend packs of used content elements outside of editor' do
pageflow_configure do |config|
config.for_entry_type(PageflowScrolled.entry_type) do |entry_type_config|
entry_type_config.additional_frontend_packs.register(
'pageflow-scrolled/contentElements/extra'
)
end
end

entry = create(:published_entry, type_name: 'scrolled')

result = helper.scrolled_frontend_packs(entry,
widget_scope: :published)

expect(result).to include('pageflow-scrolled/contentElements/extra')
end

it 'includes additional frontend packs of unused content elements in editor' do
pageflow_configure do |config|
config.for_entry_type(PageflowScrolled.entry_type) do |entry_type_config|
entry_type_config.additional_frontend_packs.register(
Expand Down

0 comments on commit b1ff559

Please sign in to comment.