symfony-cmf / menu-bundle

Extends the KnpMenuBundle to work with PHPCR ODM
https://cmf.symfony.com
32 stars 48 forks source link

Menu Documents - improving the admin interface #55

Closed dantleech closed 11 years ago

dantleech commented 11 years ago

Would it make sense to distinguish between the root node (the menu) and the menu nodes?

Doing so would enable us to list the actual "Menus" in the system in the admin interface:

-> Main Menu
-> Side Menu
-> Footer Menu

And perhaps then we can provide a dedicated interface for each menu (i.e. with drag+drop menu placement maybe) instead of a big list of nodes from all menus.

Currently the only way to reorder menu nodes is through the tree browser.

dbu commented 11 years ago

it would totally make sense to have an edit interface for a whole menu.

in fact, making the root nodes a special menu node (maybe simply extend the normal menu node document?) is the easiest way to achieve that with sonata admin. then besides the infos on the root menu node, we can simply show the subtree and the user can click to edit in an overlay, drag + drop to move and right-click to add nodes. something along

    if($this->sonataAdminMode !== $this::CREATE_MODE){
        // only render children when in edit mode (overlay needs existing parent id)
        $formMapper
            ->with('Menu')
                ->add('children', 'doctrine_phpcr_odm_tree_manager', array('mapped' => false, 'root' => $this->getSubject()->getPath()))
            ->end();
    }

(not sure if this is even documented anywhere already)

i think it make sense to allow the menu root nodes to be MenuNodes themselves (see our discussion in #15)

dantleech commented 11 years ago

Yeah I agree, so if we make a root menu node, called simply Menu, that extends the MenuNode and then the admin interface as you suggest.

Will be a chunk of work, but I think I will tag it provisionally 1.0.

dbu commented 11 years ago

yep, sounds good. its kind of "nice to have" for 1.0 but would be nice indeed.

dantleech commented 11 years ago

Closing this as there is a PR, although looking at your suggestion now I have a few questions:

dbu commented 11 years ago

the mapped = false is to avoid the form layer trying to do anything with that field as the changes to the tree are handled in overlays

the CREATE_MODE was a thing from the controller where i copied the example, sorry. we did this to know if we create a new object or edit an existing:

$this->sonataAdminMode = $this->getSubject()->getPath() ? $this::EDIT_MODE : $this::CREATE_MODE;