These are chat archives for jdubray/sam

27th
Apr 2016
brusand
@brusand
Apr 27 2016 20:13
i have a liitle question about sam views container. per example a generic dialog box with a default ok desactivated button. inside the dialogbox a custom form .
when the custom form is valid its valid its parent dialog form and the parent form container have to validate the ok button. Till here no problemner, with sam except in the view ctihow to partialy update to active only the ok button vithout refresh the child view inside the container ?
brusand
@brusand
Apr 27 2016 20:20
may modify the dom element in the container actions side or in the view side ?
or watch on modified id view update ?
brusand
@brusand
Apr 27 2016 20:27
to visualise better the use case it is a wizard container with n steps, inside each step, different custom forms, when each custom form are valide, they call the parent actions.valid_next and the wizard container have to activate only the next button, but how to ?
both wizard container and customs form are SAM designed of course ;-)
Jean-Jacques Dubray
@jdubray
Apr 27 2016 20:32
So in SAM there is no notion that the view would stay in place and you'd start manipulating its elements
brusand
@brusand
Apr 27 2016 20:34
i know so each custom form have to manage their own step button ?
Jean-Jacques Dubray
@jdubray
Apr 27 2016 20:34
the form component will be re-rendered either by itself or as part of a block. The "state" of the form to be rendered will be represented in the model with property values such as okEnabled = true. If data was captured in the previous step, the values of the next step form rendering will be adjusted to look like they had been provided
It really depends how you decompose the S() function
some people like to have many components, you could still render a "page" if you like
there is no particular guideline as to what is the granularity of a component
Modals should not be dealt with by SAM
I would try to avoid modals if possible.
brusand
@brusand
Apr 27 2016 20:38
just try use generic container
Jean-Jacques Dubray
@jdubray
Apr 27 2016 20:38
I would not create multiple components for the wizard, for me that's one component which expects from the model properties like:
  • currentStep
  • okEnables
  • ...
Based on these property values the form will render
If latency is an issue when rendering the next step, that's when a virtual-dom library would be used
brusand
@brusand
Apr 27 2016 20:40
si have several different strories with different model but each have to run in the same generic wizard container
Jean-Jacques Dubray
@jdubray
Apr 27 2016 20:42
You could still decompose the wizard further but from the state function perspective if calls somewhere something that looks like:
wizard(model)
or more exactly a projection of the model into the wizard's arguments
brusand
@brusand
Apr 27 2016 20:42
the simplest way is each storie specialise the abstract wizard
but each model has his dedicaded views
brusand
@brusand
Apr 27 2016 20:50
<wizard id=uc1 steps=4 step=1/>
<uc1 step='step' next=& />
</wizard>
may be it is the wrong way to do that
brusand
@brusand
Apr 27 2016 20:56
better code a sam minimal component <wizard steps=n /> and uc1 extends wizard with custum view (like oo ? lol)
i ll told you
brusand
@brusand
Apr 27 2016 21:18
sam is too awersome, you could watch representation, if represention contain {representation:"<buton class active>", element-id:"next"} you could update element id only with the representation
update all representation otherwise
Jean-Jacques Dubray
@jdubray
Apr 27 2016 21:21
yes, SAM does not impose a particular relationship between the display and the state, the state function could return an array of HTML fragments that the display will mount accordingly
I'd be careful in fragmenting the model too much, but as long as there are no interdependencies between partial models there is no reason to keep them together
When you fragment the model you run into issues as to which order in which they update, which you really want to avoid
brusand
@brusand
Apr 27 2016 21:24
the container keep care of the navigation and inside each view manage their model
i agree with you if i can avoid fragmentation it is better
Jean-Jacques Dubray
@jdubray
Apr 27 2016 21:26
You can certainly compose SAM but you'd have to decide the cost/benefit. It's often preferable to keep the model in one place (time travel, allowed actions,...)
brusand
@brusand
Apr 27 2016 21:28
it is more simple to fragment views with super.top-panel and super.bottom.panel than compose models
Jean-Jacques Dubray
@jdubray
Apr 27 2016 21:31
yes, exactly
In SAM the view works like a mini code generator and it's best if the code generator, S(), starts with a single state tree.
brusand
@brusand
Apr 27 2016 21:34
thx jj it is clearer to me
sam le nouveau sous marin franco australien du front lolllll
brusand
@brusand
Apr 27 2016 21:45
(sam the new front french australian submarin )