[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

example[spec] Add a new coordinator template

" add a template to MobileApplication and use it "
" self is a MobileApplication "
| jsObject templates dates datesJson currentThread coordinator |
dates := (
  (#class -> #MobileEditor ),
  (#configuration -> ( 
    (#listeners -> ( (#needsTitle -> [:coordinator | #Dates] ) ) ),
    (#widgets -> ( 
      (#information -> (
        (#class -> #MobileSelector ),
        (#configuration -> (
          (#order -> 1),
          (#listeners -> (
            (#needsTitle -> [:coordinator | 'Dates for - ',coordinator model class name ]),
            (#needsItems -> [:coordinator | Array
              with: #( 'Earliest Date' #earliestDate )
              with: #( 'Latest Date' #latestDate )
              with: #( 'Planned Date' #plannedDate ) ]),
            (#configureCell:for:in:coordinator: -> [:cell :item :aList :coordinator |
              coordinator
              configure: cell title: item first
              detail: item second ] )
          ))
        ))
      )) 
    ))
  ))
).

jsObject := self basicAt: #spec. 
templates := (JS @ jsObject) @ #templates. 

datesJson := dates json.

" add the template to the spec "
(JS @ templates) handleAt: #dates put: datesJson.

" update MobileApplication templates "
self templates
	at: #dates
	put: (MobileCoordinatorTemplate fromJSon: datesJson).

" refresh rendered UI "
self open. 

" use the template "
currentThread := self current.
coordinator := currentThread coordinator.
currentThread next: ((coordinator newTemplateAt: #dates) model: coordinator model;yourself)