Problem/Motivation

Would like the ability to filter by section versus template in the import from section library screen.

Also want to improve code quality and compatibility with both layout builder modal and layout builder iframe modal.

Section Library Filters

Steps to reproduce

Proposed resolution

  • Click "Import section from Library" and see a new dropdown to filter by section versus template
  • Install either layout builder modal or layout builder iframe modal and be able to import from the library

Note: when using layout builder iframe modal, it needs to be configured to add itself to the section library routes. On /admin/config/content/layout_builder_iframe_modal add the following to the Custom routes textarea:

  • section_library.add_section_to_library
  • section_library.add_template_to_library
  • section_library.choose_template_from_library
  • section_library.import_section_from_library

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

AaronChristian created an issue. See original summary.

aaronchristian’s picture

Status: Active » Needs work
jastraat’s picture

I'm attaching a patch that integrates the MR's changes with the latest dev of section_library. Unfortunately I could not make changes to the MR directly. This also does not resolve the two last issues.

jastraat’s picture

Updated patch that pre-filters template type based on the import link clicked. Still haven't figured out how to get the ajax modal to close after adding a template.

jastraat’s picture

Status: Needs work » Needs review
StatusFileSize
new27.53 KB

And finally figured out the dialog closing issue. This latest patch addresses both of the outstanding issues mentioned in #3.
I also fixed the failing test.

jastraat’s picture

Sorry - that earlier patch included some changes from another section_library patch I have applied.
Here's a clean one.

aaronchristian’s picture

Status: Needs review » Needs work

Thanks @jastraat for picking this up so long after the creation of this issue!

I did try to test the patch but received some errors in doing so;

TypeError: Drupal\section_library\Form\AddSectionToLibraryForm::__construct(): Argument #4 ($module_handler) must be of type Drupal\Core\Extension\ModuleHandler, Drupal\hook_event_dispatcher\HookEventDispatcherModuleHandler given, called in /var/www/web/modules/contrib/section_library/src/Form/AddSectionToLibraryForm.php on line 99 in Drupal\section_library\Form\AddSectionToLibraryForm->__construct() (line 88 of /var/www/web/modules/contrib/section_library/src/Form/AddSectionToLibraryForm.php).

Wondering if maybe there is still some of the other patch being caught up in the mix here.

I also tried to apply patch #5 but got the same error.

Going to mark this as "Needs work" for the time being.

If you manage to sort things out feel free to post back and I'll give it another test.

Thanks again!!!

jastraat’s picture

Hey @AaronChristian thank you for testing! Just to make sure, did you fully clear the Drupal cache after applying the patch? This injects a new service to check for layout_builder_modal.

dmundra’s picture

@jastraat would the patch benefit from a update hook to clear the cache?

jastraat’s picture

Status: Needs work » Needs review
StatusFileSize
new26.34 KB

Adding a patch with a post-update hook to automatically clear the cache and pick up the updated form dependencies.

jastraat’s picture

I'm afraid my last few patches were corrupted. Here's a new patch with the changes from patch 7 + a post update hook to clear the cache and prevent the error @AaronChristian saw.

jastraat’s picture

Version: 1.0.x-dev » 1.2.x-dev
jastraat’s picture

Title: Allow filtering between "Section" & "Template" within offcanvas & modal screen » Allow filtering between "Section" & "Template" and improve layout builder iframe modal compatibility
jastraat’s picture

Issue summary: View changes
jastraat’s picture

Assigned: aaronchristian » jastraat
jastraat’s picture

StatusFileSize
new185.19 KB

I adjusted the scope of this issue so that the solution could be supported by layout builder with no modal, layout builder modal, and layout builder iframe modal.

The MR now adds a select to allow filtering by "Section" versus "Template", removes the sass directory since CSS now supports nesting and all the node packages were really out of date, improves the module's compatibility with layout builder iframe modal, removes the dependency on jquery, and fixes a few warning errors from the pipeline. Also refactored to take into account the fixes from #3217647: Adding stuff to library doesn't close dialog if dialog opens in popup.

It also addresses the problem with access checking and the core navigation module outlined in #3241715: Access check problems on add_to_template link and #3480604: Error with core navigation module.

Please test creating and importing templates with no modal modules, with layout builder modal, and with layout builder iframe modal. Also test enabling the core navigation module and visiting /admin/config/user-interface/navigation-block

Please confirm that you can filter by section versus template when choosing a template to import and that it combines with the label search that was already there.

terracoders’s picture

Status: Needs review » Reviewed & tested by the community

Tested as working per all criteria established in comment #20. Patch is working great!

mahmoud-zayed’s picture

Looks good to me, css will be much simpler!

  • jastraat committed 3c5cb1a0 on 1.2.x
    Issue #3195007 by jastraat, aaronchristian, dmundra, terracoders, rajab...
jastraat’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.