MVC separating concerns when nesting views (2 examples)
===

Introduction: I'm only speaking about the client side of the application, which is using qooxdoo (it's a javascript framework).

Target: separate concerns in controllers, views and models without adding too much complexity.

Problem 1: I have a view named loginView which has a controller to loginController. loginView dispatches the 'login button clicked' event and loginController listen on it and then make a query to the database to login.

Then I have another view named managerView which adds the loginView

    |---------------|
    |   loginView   |   <-- this whole thing
    | other ui stuff|   <-- is the manager View
    |---------------|
   
As you can see the loginView coexist with other ui elements.
When the user is not logged in the 'other ui stuff' is disabled.
Therefore there is a need to listen on the loginView to dispatch the 'login', but that's not so logical, because the view doesn't have to dispatch that event. Therefore the managerView would listen on the loginController?!?! that's bad. No. Maybe the managerController listens on the loginController? Nope. This would tightening the controllers. Well, maybe the managerController must listen on a model? - Well, this seems a great idea, but how I set up all this thing?

Problem 2: I have 2 tables with, each with a different table model. Both table represent some Jobs, but the filters are different from one to the other. When a table is selected or activated, the selected job in that table will be shown in the MainScreen, which is view that just shows some info and allow some actions to perform on the Job.

How I've done: when the table changes selection the main controller (which has access to various views, including the 2 tables and the MainScreen) set the selected job on the MainScreen. The MainScreen then updates itself in order to show the current job. Based on the job attributes some actions are enabled or not. When a user click on an action then the main controller knows about it and refresh the 2 tables (sometimes a job jumps from a table to the other).

How I think should be done: have a model that contains the current job, wherever this is changed update the MainScreen. The main controller just listen on the 2 tables and then change the current job model. As it also have a listener on it, this will make the MainScreen to update itself.