Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asynchronous population of dform entries #24

Open
smithfarm opened this issue Oct 16, 2017 · 1 comment
Open

Asynchronous population of dform entries #24

smithfarm opened this issue Oct 16, 2017 · 1 comment
Assignees
Labels

Comments

@smithfarm
Copy link
Owner

The new feature would hinge on the presence of dform entries with a "populate" property.

When a dform is run on an object, the following newly happens:

  1. entries without "populate" properties are displayed
  2. an array of the "populate" entries is constructed
  3. the populate function of the first entry is run, with the array from 2 as its argument

The populate functions expect to take a form object and an array of entries. When called, they shift their entry off the front of the array, asynchronously populate the form input, and run the next populate function, sending it as arguments the form object and the array containing the remaining entries.

In this way, the "populate" entries are asynchronously populated in sequence, one after another. The dform would be fashioned so that the entries are listed in order of dependency - i.e. if entry X depends on entries A, B, and C, it would be listed after A, B, and C.

For example, a dform to generate a "last interval plus offset" interval would look like this:

  • date
  • aid
  • long_desc
  • remark
  • sid (populate)
  • schedule intervals (populate)
  • existing intervals (populate)
  • interval start (populate)
  • interval end (populate)

The "sid" entry populate function would look up the SID (Schedule ID) of the current employee.

The "schedule intervals" populate function would look up the schedule intervals for that day.

The "existing intervals" populate function would look up existing attendance intervals for that day.

The "interval start" populate function would derive the interval start time from the schedule intervals and the existing intervals.

The "interval end" populate function would compute the interval end time by adding the offset to the interval start time.

@smithfarm smithfarm self-assigned this Oct 16, 2017
@smithfarm
Copy link
Owner Author

smithfarm commented Oct 19, 2017

This is now done, via a combination of:

  1. a populate module/function has been added in App::MFILE::WWW core
  2. the dform code in start.js has been modified to construct an array of the populate functions associated with the dform's entries and run "populate" on it
  3. an idiom for writing the populate functions has been developed

For the idiom, see the populate properties of the dform entries in https://github.com/smithfarm/dochazka-www/blob/0.155/share/js/dochazka-www/entries.js and the populate* functions in https://github.com/smithfarm/dochazka-www/blob/0.155/share/js/dochazka-www/caches.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant