Jasig/uPortal — pull request #362 by apetro (2014-06-25 11:54:17+00:00)
Title: UP-3896 Un-favoriting the last favorite return to VIEW mode.

Without this change, un-favoriting the last favorite leaves you in edit mode with nothing to edit.

With this change, instead, un-favoriting the last favorite returns you to view mode.

Editing that last favorite:

![](http://cl.ly/image/2E0o0z2z0l36/Image%202014-06-25%20at%206.34.13%20AM.png)

After removing the last favorite, with this change:

![](http://cl.ly/image/3i2v112E3s2G/Image%202014-06-25%20at%206.34.31%20AM.png)

Implementation notes:
----------------------------

### Did not include remove confirmation in view mode.

Considered the you have no favorites messaging and experience as sufficient confirmation that the item to be removed was removed. This is questionable user experience design -- it might be better to echo back to the user a notification of exactly what was removed. Maybe revisit this when implementing undo control on those notifications such that those notifications are more valuable.

### There's still an edit_zero view

While the user now goes right back to view mode when deleting that last favorite, they can still get back to edit mode e.g. through the portal chrome. So, that view is still there and still needs to be maintained even though removing the last favorite no longer immediately goes there.

### No JIRA for this feature specifically

Since Favorites is not yet in any actual released version of uPortal, tracked this under auspices of the overall Favorites feature JIRA rather than creating another issue to track this feature specifically.

### Static stateless helper vs richer domain model

Continued using the FavoritesUtils static stateless helper, which is cute and all, but maybe Favorites methods should be added to the `IUserLayout` interface itself so as to have a richer domain model and call `layout.hasFavorites()` rather than `FavoritesUitls.hasFavorites(layout)`. Perhaps a refactor to make for a uPortal 4.2 release where Favorites will have more miles on the tires and have become a more established uPortal feature.

### No unit tests

Would be good to have 'em. Layouts are complicated to test, but that's not a great excuse.