raytha icon indicating copy to clipboard operation
raytha copied to clipboard

Menus feature

Open apexdodge opened this issue 11 months ago • 0 comments

The purpose of this feature is so that menus throughout a Raytha site need not be hardcoded into templates. They can be generated dynamically and managed through a UI similar to WordPress.

Task:

"Navigation Menus" should be added to the left side navigation of the admin panel and only accessible if the logged in administrator belongs to a role with the "Manage Content Types" permission. Route should be /raytha/menus

The data model should be:

Menu:

  • Id
  • Label
  • Developer Name
  • IsMainMenu
  • List of Menu Items

We should be able to "Set as main menu" similar to what we do with home page.

image

The list of menu items should be a nav item on the right side following our pattern:

  • Edit menu
  • Menu items
  • Delete menu

image

MenuItem:

  • Id
  • Label
  • Url (can be a relative url)
  • IsDisabled
  • OpenInNewTab
  • CssClassName
  • Ordinal

It should follow the same pattern as a content type settings where you can add a menu item or reorder the menu items.

image

You cannot delete the main menu. There should always be 1 main menu.

Two built-in liquid functions should be added to Templates functionality.

  • get_main_menu()
  • get_menu(developerName)

The function should pull the respective menu and generate a tree structure (use recursion) to create an object that can be used to render the necessary HTML for the template creator.

The render object should render as:

  • Id
  • Label
  • DeveloperName
  • IsMainMenu
  • MenuItems

And this MenuItems should be the top-level menu items rendered as:

  • Id
  • Label
  • Url
  • IsDisabled
  • OpenInNewTab
  • CSS Class Name
  • Ordinal
  • IsFirstItem
  • IsLastItem
  • MenuItems

We need to update the:

  • InitialSetup - Create the first menu, set it as main menu, and add the first two items, Home and About.
  • DefaultTemplate should make use of get_main_menu() in its template to render the nav.
  • Templates > Insert Variable > the render models for Menu and MenuItem needs to appear here.
  • REST API / SWAGGER - new section called Navigation Menus.

GET Requests only:

  • /raytha/api/v1/menus
  • /raytha/api/v1/menus/{developerName}
  • /raytha/api/v1/menus/{developerName}/menu-items
  • /raytha/api/v1/menus/{developerName}/menu-items/{menuItemId}

apexdodge avatar Mar 24 '24 17:03 apexdodge