Thursday, October 10, 2024

I am working on #5777 (ParameterStore (…) on lino_xl.lib.contacts.models.Partners expects a list of 3 values but got 5), which requires me to dive into the NavigationControl.js and Base.ts files. This page contains my reading notes.

The localStorage read-only property of window allows you to access a Storage object for the Document‘s origin; the stored data is saved across browser sessions. localStorage is similar to sessionStorage, except that sessionStorage gets cleared when the page session ends — that is, when the page is closed. (Source: mozilla.org) that

Base.ts

The Base.ts file:

  • defines the DynDep() class, which adds dynamic dependency management to a class. The constructor() loads the modules specified by requiredModules and then calls prepare(), sets ready to true and finally calls onReady() (which subclasses can override).

  • it also defines a Component() class, which extends the bare React.Component() to use DynDep().

The file also defines two constants URLContextType and DataContextType, which are the two React contexts used by Lino. They are created using React.createContext() and their default value is an (empty) object.

I read https://react.dev/learn/passing-data-deeply-with-context

  • URLContextType is used by: GridFilter, LinoBbar, LinoBody, LinoLayout, LinoDialog, LinoPaginator, LinoParamsPanel, …

  • DataContextType is used by: GridElement, LinoComponents.UnknownElement

NavigationControl.js

The NavigationControl.js file:

  • defines the Context() class, which extends DynDep(). A Context is a controller for all navigation features. It as an attribute contextType, which contains one of the following values (defined in constants.js):

    CONTEXT_TYPE_SINGLE_ROW = "SingleRow";
    CONTEXT_TYPE_MULTI_ROW = "MultiRow";
    CONTEXT_TYPE_ACTION = "Action";
    
  • defines the History() class, with attributes like state (contains the “router state”, an instance of State()), and context (the context of its owner).

    History.pushPath()

  • defines Delegate()

  • defines State(), which represents a router state

The ActionHandler()

class ActionHandler()
ActionHandler.singleRow(event, pk, where, status)

Open a detail window on the given primary key pk in the current table.

The ActionHandler.singleRow() method is called by:

  • GridElement.showDetail() (which is called when you click on the first cell of a row)

  • when you click on the title of a LinoCards() item

class GridElement()

defines

DynDep.reflect()

RegisterImportPool(),