Skip to content
This repository has been archived by the owner on Jan 10, 2022. It is now read-only.

Menu Library / API Refactor #120

Open
cliftonc opened this issue Oct 1, 2011 · 0 comments
Open

Menu Library / API Refactor #120

cliftonc opened this issue Oct 1, 2011 · 0 comments

Comments

@cliftonc
Copy link
Owner

cliftonc commented Oct 1, 2011

Ok, the menu library really isn't very great at the moment - I think we need another crack at making it actually useful.

Issues:

  • At the moment menus are defined in calipso.js, hence not configurable.
  • They are decoupled from routes (may be good or bad!) and so require you to configure routes and corresponding menu links yourself.
  • Menu generation is then not very configurable as it is pretty much 'give me the whole menu tree for this menu please' and thats it.

So, my thoughts (this is discussion so please add):

Definitions

Menus should be added via route configuration, so where currently we have

 res.menu.admin.addMenuItem({name:'Administration',path:'admin',url:'/admin',description:'Calipso administration ...',security:[]});

// Core Administration dashboard
module.router.addRoute('GET /admin', showAdmin, {
  template: 'admin',
  block: 'admin.show',
  admin: true
}, this.parallel());

We would instead have something like:

// Core Administration dashboard
module.router.addRoute('GET /admin', showAdmin, {
  template: 'admin',
  block: 'admin.show',
  menu:'admin:admin',
  label:'Administration',
  description:'Calipso administration ...',
  security:['admin'] // to be implemented
}, this.parallel());

Where, the menu option will be of the following format:

 menuname:parent/child/menu

The prefix of menuname allows you to specify which menu it should be added to, while the path allows it to be generated in relation to all other menu items.

Menu generation would then be something like:

calipso.menu.render = function(req, menuName, startAt, depth) // req is required for security vs current user

And exposed via a helper:

getMenu('admin','',-1);

Also, we could later add an 'alias' type module that enables other menu items and aliases to be matched to existing routes ... need to give that thought in a separate thread.

It would be created via the module router, but there would be a single, central menu object that spans all modules via calipso.menu.

Thoughts?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant