Friday, January 30, 2015

Submitting an ActionFormPanel no longer forwards param_values

Uff! Ticket #49 is fixed. Gerd and Melanie discovered yesterday how to reproduce it. The trick was to open the detail panel via the table view, not (as I usually do) by clicking on some client in the welcome page.

As expected, this was subtle and required several hours of debugging and a change in linoweb.js. I also wrote a new test case lino_welfare.projects.docs.tests.test_households which helped me to understand the problem.

Explanation: Lino.call_ajax_action also asked the requesting panel to add its base params to the parameters of the AJAX call:

Ext.apply(p, panel.get_base_params());

In our case (user clicks on one of the create_household links in the summary panel of MembersByPerson) the requesting panel is the detail window of the client. Which (when opened via the table view) included the parameter values (pv) of that view. But at least in our case we do not want to add these when sending the OK of the ActionFormPanel. I am not yet sure whether this is generally what we want because the current case is furthermore special: the create_household action is called from pcsw.Clients but defined on the contacts.Person model.

Commit and push.

And here is already a destructive side-effect of above solution. The following comes when I tried to assign a newcomer to a coach:

AttributeError 'NoneType' object has no attribute '__dict__'

TRACEBACK:
  ...
  File "welfare/lino_welfare/modlib/newcomers/models.py", line 453, in run_from_ui
    watcher = ChangeWatcher(client)
  File "lino/lino/core/utils.py", line 694, in __init__
    self.original_state = dict(watched.__dict__)

Okay the parameter values (pv) must maybe never go to the AJAX call, but the mt and mk are always needed. For example the AssignCoach action in AvailableCoachesByClient needs the master_instance.

Commit and push. Upgrade in ÖSHZ Eupen.

Remember the active tab when saving

And then another Javascript problem solved: #68. The problem was:

  • When I save a detail form for the first time, Lino switches back to the first tab even if I was in another tab when clicking the Save button.

Note that Lino did not forget to add the tab url parameter to the AJAX call. But the response did not return it back. Added new keyword argument active_tab to ar.set_response, changed Lino.handle_action_result() (in linolib.js) to handle this keyword, and changed ar.parse_req to detect the tab url parameter on incoming calls.

Commit and push.

Immersion trainings

I started to work on #72. It was almost done in less than 2 hours: a new module lino_welfare.modlib.trainings.

But the demo fixture took some more time. See tomorrow.