The 1000 steps program to MDriven Chapter 6

This is chapter 6 of the training material - if you want to start from the top: The_1000_steps_program_to_MDriven, chapter 5

Here is the video for Chapter 6: https://youtu.be/ezJiIIyEy7g

And here are the steps as text:

Chapter 6

183 Person ViewModel - The Button CarsIUsedToOwn - this does not do anything and can be removed - but let me explain where it came from: When we Adopted the AutoPersonForm and named it Person it first worked since it pointed to the AutoFormPersonCarsIUsedToOwnMultiLink - that show the content of CarsIUsedToOwnMultiLink - but since then we have regenerated the AutoForms - and this action lost its form - and new form was created - that this action is not connected to. Remove the Button, remove the viewmodel action MultiLinkCarsIUsedToOwn

184 Add a ViewModelColumn - mark as IsAction - see that it turns into a Button

185 Name it AddACarIUsedToOwn

186 Create a ViewModelAction name this AddACarIUsedToOwnAction

187 Hook up the Button AddACarIUsedToOwn to the action AddACarIUsedToOwnAction by selecting it in the picker next to IsAction checkbox

188 Press the NewEditor button in the top of the ViewModelEditor - in the new window find the AutoFormCarSeeker

189 Adopt the AutoFormCarSeeker to make it your own - name it CarSeeker

190 Back to the AddACarIUsedToOwnAction - set BringUpViewModel to CarSeeker. Save Test web

191 When we in the web try to add a new car I have owned we see that the seeker for cars comes up - but we rather just want to show it on top - of the Person form.

192 Go back to the AddACarIUsedToOwnAction - find the check box IsModal - check it - save - test web

193 A modal dialog OK-button has an enable expression - this must be made true for user to press ok - set it to true (by typing the ocl constant true in the box) - save test web

194 But we really want to have the user to Search and select cars prior to returning - so open the enableExpressionForModelOk ocl editor on the three dots. Find  vSeekerResult->notempty in the expression helper tree - make sure that the expression is entered- save test web

195 Now the Ok button is only enabled if there is a row selected in the search result - works for you? Try to search for cars , select first, then search for some nonses AAAAAAAAA - empty search result - not Ok

196 The AddACarIUsedToOwnAction also has an Action expression ActionAfterModalOk - this is where we can act on the user wishes once the user press ok - this will not be performed on the Cancel/close box in the modal

197 Go into ocl editor for ActionAfterModalOk on the AddACarIUsedToOwnAction - and type in the expression: vCurrent_Person.CarsIUsedToOwn.Add(vModalResult_vCurrent_Car) , if you manage to find the words in the three one at the time you see of the tree updates to reduce the options to what fits best

198 vCurrent_Person is the root of the view we are in - its an object of class Person.

vCurrent_Person.CarsIUsedToOwn is that persons CarsIUsedToOwn

vCurrent_Person.CarsIUsedToOwn.Add(argument) is an list operation to add a reference to an association

vModalResult_vCurrent_Car is the Car object that the user chose in the Modal CarSeeker.

Make sure your expression is vCurrent_Person.CarsIUsedToOwn.Add(vModalResult_vCurrent_Car) and save test web

199 Operations can be canceled or saved - unsaved things can also be undone and re-done in multiple steps by the user - try that

200 Bring up another browser form - Navigate to PersonSeeker - we are going to quickly fix a problem I see with the PersonSeeker: When you seek with a blank input you get nothing - when you probably should get all.

201 Open up ViewModel PersonSeeker, Add another Search Expression, change Criteria, set it to Person.allinstances, set its Active expression to vSeekParam->isnullorempty - this way this Criteria will kick in only when search box is blank. Save Test Web

202 Bring up person SomeOtherDude in browser win 2 - what happens when he Picks a CarIUsedToOwn that your browser win 1 person already picked?

203 We want want it to be possible to have had mutliple Previous owners , change the cardinality from 0..1 to 0..* on PreviousOwner

204 Save and See errors - many are from AutoForms - so Refresh AutoForms, save

205 Now repeat step 202 - How does it work now?

206 Make it possible to take multiple cars at a time - using vSelected: vModalResult_vSelected_Car->collect(pc| vCurrent_Person.CarsIUsedToOwn.Add(pc))

207 Working with many to many relationsships it is very common to want an association class

Create a new Class in the diagram call it HistoricOwnership

208 Click the association-class-connection-tool - click HistoricOwnership class, drag and hold, let mouse go when over the many-many relation between person and car - you should get a dotted line

209 Add an attribute DateSold of type DateTime? to the class HistoricOwnership

210 set innerlink names to Car for navigtion to Car and Person for navigation to Person

211 In the ViewModel Person  we add another grid-table that shows the link objects, add nested ViewModelClass multilinks - find  HistoricOwnership

212 Test on web, verify that the 2 lists are maintained automatically

213 Remove the CarIUsedToOwn grid - since the other link-class-grid has the same and more information. This is almost always the case - if you have an association class you want to show that instead of the end objects. This is due the increased precision that the link-object has - pointing out the exakt pair of associated objects

214 On the nesting HistoricOwnership, set the "ActAs"ForActions to self.Car

Chapter 7 The_1000_steps_program_to_MDriven_Chapter_7

This page was edited 57 days ago on 02/01/2024. What links here