skypher/weblocks — pull request #15 by woudshoo (2012-11-09 11:45:26+00:00)
Title: Fixed nested selector behaviour

The get-widget-for-tokens function did not handle default panes very well:

1 - If the default pane was specified in the selector with nil token,
Still a token was popped of the uri-stack, (when it was found in the cache)
2 - If you have a selector with a default pane set with nil token, but
there are tokens available for sub menus.
It would default to the first pane (not the default pane.)
3 - If no pane was found for the token, the first pane would be used,
but stored in the cache under the token from the uri stack.
4 - probably some more small issues.

I changed the behaviour such that:

A - The uri stack is modified in accordance to the selected pane:
- only a token is popped if that token was actually used to select the pane.
- If a default pane was selected without consuming a token, but a token
should actually have been required (e.g. no nil token pane, so the first pane was selected.)
this token is pushed on the 'consumed' part of the uri stack.
RATIONALE: If there are sub selectors, they need to have their base url
set correctly, otherwise selecting a sub item will create a
url which does not take into account the 'token' which should be consumed
by this (the parent) selector.
Similarly if you have:

Selector --- A --> Page containing two Sub selectors (not nested)

Selecting the second sub selector might also get a url which is odd.

HOWEVER: The design with NIL token being the default can break in subtle ways
if you are not carefull.
But that was already the case.

B - The other small fix is to store the pane in the cache with the actual key of the pane,
NOT the token that was on top of the uri-stack