On Fri, Dec 06, 2019 at 11:55:14PM -0800, C K Kashyap wrote:
> I see!!! ... Is +E/R restricted to making bi-directional connection with
> the *ID only?

In fact +E/R does not know about *ID. *ID is only a vehicle to pass the object
to the page during GET (so just for a moment). After that it is invalid, as it
may be changed by other GET transactions in other browser tabs or windows.
Therefore 'idForm' stores *ID immediately into the form's 'obj' property.

And +E/R also does not know about that 'obj' property either. It expects a
relation specification, which is often (var : home obj) though. But you can pass
any cons pair with a property key in the CAR and an expression evaluating to a
DB object in the CDR.


> My task.l looks like this now and I've +E/R to wire up the
> 'ttl rel of Task

OK, fine.

> but I was not sure if I could do the same with the 'tgs
> rel as well - full code is here -
> https://github.com/ckkashyap/picolispAppPractice/tree/master/step04

The typical GUI for a object-list relation like

   (rel tgs (+List +Joint) tsk (+Tag))

is a chart. It is most general, and allows any kind of operation on the data
(CRUD). It would be somethiny like

   (gui '(+E/R +Chart) '(tgs : home obj) 4
      '((This) (list NIL This))
      cadr )
   (<table> 'chart ,"Tags"
      '((btn) (NIL ,"Tags"))
      (do 6
         (<row> (alternating)
            (choTag 1)
            (gui 2 '(+ObjView +TextField) '(: nm))
            (gui 3 '(+DelRowButton))
            (gui 4 '(+BubbleButton)) ) ) )
   (scroll 6 T)

That is indeed a little overkill for simple +Tag objects.

But a function like

   (de updateTags (L)
      (for I (get *ID 'tgs)
         (lose!> I) )
      (for I L
         (put!> *ID 'tgs
            (new! '(+Tag)
               'tsk *ID
               'nm
               (or
                  (db 'nm '+TagNm I)
                  (new! '+TagNm 'nm I) ) ) ) )
      L )

is EXTREME overkill! You basically rewrite all task objects several times
during any primitive GUI operation like key presses and refreshes.

So this code

   (gui '(+Init +Set +ListTextField)
      (extract
         '((Tg) (get (get Tg 'nm) 'nm))
         (get *ID 'tgs) )
      '((L) (updateTags L))
      '(","," ")
      40 )

is not recommended (also in regard of our previous discussion of +Init where
+E/R is meant.

   Side note:
      '((Tg) (get (get Tg 'nm) 'nm))
   would better be
      '((This) (: nm nm))


You could experiment with something like

   (gui '(+E/R +Fmt +ListTextField)
      '(tgs : home obj)
      '((This) (: nm))  # Set function
      '((Nm) (request! '(+Tag) 'nm Nm))  # Val function
      '(","," ")
      40 )

'+Fmt' is basically the same as '+Set +Val'.

'request!' fetches the object, or creates it if not found.

(Not tested! ;)

☺/ A!ex

-- 
UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe

Reply via email to