:date: 2016-07-01

====================
Friday, July 1, 2016
====================

Surf
====

I read the Wikipedia article about `Meteor
<https://en.wikipedia.org/wiki/Meteor_(web_framework)>`_ and read the
first page of the `Todo App
<https://www.meteor.com/tutorials/blaze/creating-an-app>`_ tutorial.
Yes, overwhelming.  Is Meteor going to replace Django, and should I
stop working on Lino and `become a Meteor partner
<https://www.meteor.com/become-a-partner>`_?  The answer is probably
"no".  But it might be inspiring to invest a week of work just for
fun into a Meteor project. Ticket :ticket:`1009`.



ExtJS 6
=======

Hamza continued on :ticket:`1001` while I was sleeping.  He wrote: "I
have get page navigation works but records are net refreshing after I
change a page."  Now I merged `his work
<https://gitlab.com/lino-framework/lino_extjs6/commit/4c4642a8b0612b000bd2ef3ffd9422ccc521824f>`_
into master and continue on my turn.

Side effects:

- After having meditated about what I wrote yesterday, I now did
  :ticket:`1010` (see :attr:`lino.core.plugin.Plugin.disables_plugins`).
        
  I still didn't set :mod:`lino_extjs6.extjs6` as `default_ui` in
  :mod:`lino_noi.projects.team.settings.demo` because that would break
  the tests on Travis or Drone (as long as I don't want to include
  :mod:`lino_extjs6` as a required package).

- The list of countries didn't show, it caused a `ValueError: invalid
  literal for int() with base 10: 'BE'`. This was because
  :mod:`lino_xl.lib.stars` called the :func:`gfk2lookup
  <lino.core.utils.gfk2lookup>` to add the :guilabel:`☆`/:guilabel:`★`
  actions. These actions don't work on countries because their primary
  key is a CharField (Country is actually the only model with a
  non-integer primary key). See also :ref:`book.specs.gfks`.

My `first commit to lino_extjs6
<https://gitlab.com/lino-framework/lino_extjs6/commit/4f2fe2e5925a7a14890c7b5592f38cb482f357d0>`_
is just a few theoretic changes.

Yes, the paging toolbar now displays the correct number of pages and
lets me navigate between them, but the list of rows is always the
same.

When clicking for page 2, the request URL is:

  http://127.0.0.1:8000/api/tickets/Tickets?_dc=1467349247151&fmt=json&rp=ext-comp-1159&limit=7&start=0&page=2

In Extjs 3 it was:

  http://127.0.0.1:8000/api/tickets/Tickets?_dc=1467349311775&start=5&limit=5&fmt=json&rp=ext-comp-1154&pv=&pv=&pv=&pv=&pv=&pv=&pv=&pv=&pv=&pv=&pv=&pv=

`page` is obviously a new HTTP parameter generated by the ExtJS paging
toolbar.  I think that we can ignore it. 

The problem is that `start` is 0. Why?
Did they remove it? No, because `the docs
<http://docs.sencha.com/extjs/6.2.0-classic/Ext.data.Store.html#method-loadPage>`_
still say that loadPage "Internally this just causes a normal load
operation, passing in calculated 'start' and 'limit' params.".

The `pageSize` is now on the store, and no longer on the grid panel.

The `load` event has changed between `3
<http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.data.Store-event-load>`__
and `6
<http://docs.sencha.com/extjs/6.2.0-classic/Ext.data.Store.html#event-load>`__.

Debugger observation: the `options` object passed to the
:meth:`GridStore.load` method is not correct.  The `start` and `limit`
attributes must be in `options.params`, not at root.

  options = Object {page: 2, start: 7, limit: 7, addRecords: false}

I cannot see any relevant change for the API between `3
<http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.data.Store-method-load>`_
and `6
<http://docs.sencha.com/extjs/6.2.0-classic/Ext.data.ProxyStore.html#method-load>`_.


Explanation: ExtJS now expects start and limit to be at the top-level,
and it will forward them somehow to the AJAX call later. We did not
find the exact place where this happens, but it seems obvious.


The following was (AFAICS) an obvious typo bug::

    Ext.define('Lino.FormPanel', {
        extend : 'Ext.form.FormPanel',

It must be::

    Ext.define('Lino.FormPanel', {
        extend : 'Ext.form.Panel',

(though I didn't investigate why we didn't see this earlier).


Another problem is that the parameter panel is not there at
all. That's why the ``pv=`` are missing.

.. Yes, the old `Ext.PagingToolbar
   <http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.PagingToolbar>`_
   communicated with its `store` using two parameters `start` and
   `limit` (which corresponded to the SQL clauses OFFSET and LIMIT)
   while the new `Ext.toolbar.Paging
   <http://docs.sencha.com/extjs/6.2.0-classic/Ext.toolbar.Paging.html#cfg-store>`_
   seems to just


Note: why did we replace lines like this one::

        for (k in p) store.setBaseParam(k,p[k]);

by this one?

::

        for (k in p) store.getProxy().setExtraParam(k,p[k]);

Answer: because there is no method :meth:`setBaseParam` any more.

Above is my summary of the day, including a shared session with Hamza
in the evening.