The 1000 steps program to MDriven Chapter 6
No edit summary
No edit summary
Line 43: Line 43:
And here are the steps as text:
And here are the steps as text:


=== Chapter 6, Modal dialog to pick values and return to caller to use picked values ===
=== Chapter 6: Modal Dialog to Pick Values and Return to Caller to Use Picked Values ===
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
183. The Person ViewModel - The button CarsIUsedToOwn - 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 worked at first, since it pointed to the AutoFormPersonCarsIUsedToOwnMultiLink, which shows the content of CarsIUsedToOwnMultiLink. We have regenerated the AutoForms since then so this action lost its form and a new form was created that the previous action is not connected to. Remove the Button and remove the ViewModel action MultiLinkCarsIUsedToOwn.


184 Add a ViewModelColumn - mark as IsAction - see that it turns into a Button
184. Add a ViewModelColumn and mark it as Is Action; see that it turns into a button.


185 Name it AddACarIUsedToOwn
185. Name it AddACarIUsedToOwn.


186 Create a ViewModelAction name this AddACarIUsedToOwnAction
186. Create a ViewModelAction. Name it AddACarIUsedToOwnAction.


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


188 Press the NewEditor button in the top of the ViewModelEditor - in the new window find the AutoFormCarSeeker
188. Press the NewEditor button at the top of the ViewModelEditor. In the new window, find the AutoFormCarSeeker.


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


190 Back to the AddACarIUsedToOwnAction - set BringUpViewModel to CarSeeker. Save Test web
190. Back to the AddACarIUsedToOwnAction, set BringUpViewModel to CarSeeker. Save. Test the 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.
191. When you are on the web, try AddANewCarIHaveOwned. We see that the seeker for cars comes up, but instead, we 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
192. Go back to the AddACarIUsedToOwnAction, find the check box Is Modal, check it and save. Test the 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
193. A modal dialog OK button has an enable expression. This must be made true for the user to press ok. Set it to true (by typing the OCL constant "true" in the box). Save and test the 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
194. We really want to enable the user to Search and select cars prior to returning. Open the enableExpressionForModelOk OCL editor on the three dots. Find vSeekerResult->notempty in the expression helper tree and make sure to enter the expression. Save and test the 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
195. 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 nonsense (like AAAAAAAAA). You'll get an 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
196. The AddACarIUsedToOwnAction also has an Action expression: ActionAfterModalOk. This is where we can act on the user's wishes once the user presses OK. It 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
197. Go into the 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 tree, you will see the tree updates reduce the options one at a time to what fits best.


198 vCurrent_Person is the root of the view we are in - its an object of class Person.
198. vCurrent_Person is the root of the view we are in. It is an object of the class Person.
* vCurrent_Person.CarsIUsedToOwn is that person's CarsIUsedToOwn.
* vCurrent_Person.CarsIUsedToOwn.Add(argument) is a 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 the web.


vCurrent_Person.CarsIUsedToOwn is that persons CarsIUsedToOwn
199. Operations can be canceled or saved. Unsaved things can also be undone and re-done in multiple steps by the user. Try it out.


vCurrent_Person.CarsIUsedToOwn.Add(argument) is an list operation to add a reference to an association
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 should probably get all.


vModalResult_vCurrent_Car is the Car object that the user chose in the Modal CarSeeker.
201. Open up ViewModel PersonSeeker, add another Search Expression and change the Criteria. Set it to Person.allinstances. Change its Active expression to vSeekParam->isnullorempty; this way, this Criteria will kick in only when the search box is blank. Save. Test the web.  


Make sure your expression is vCurrent_Person.CarsIUsedToOwn.Add(vModalResult_vCurrent_Car) and save test web
202. Bring up the person SomeOtherDude in the browser window 2. What happens when he picks a CarIUsedToOwn that your browser window 1 person already picked?


199 Operations can be canceled or saved - unsaved things can also be undone and re-done in multiple steps by the user - try that
203. We want it to be possible to have multiple previous owners. Change the cardinality from 0..1 to 0..* on PreviousOwner.


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.
204. Save and see errors. Many are from AutoForms, so Refresh AutoForms and save.


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
205. Now repeat step 202. How does it work now?


202 Bring up person SomeOtherDude in browser win 2 - what happens when he Picks a CarIUsedToOwn that your browser win 1 person already picked?
206. Make it possible to take multiple cars at a time using vSelected: vModalResult_vSelected_Car->collect(pc| vCurrent_Person.CarsIUsedToOwn.Add(pc)).


203 We want want it to be possible to have had mutliple Previous owners , change the cardinality from 0..1 to 0..* on PreviousOwner
207. While working with many-to-many relationships, it is very common to want an association class. Create a new Class in the diagram. Call it HistoricOwnership.  


204 Save and See errors - many are from AutoForms - so Refresh AutoForms, save
208. Click the association-class-connection-tool. Select the HistoricOwnership class, drag, and hold. Let the mouse go when over the many-to-many relation between person and car.  You should get a dotted line.


205 Now repeat step 202 - How does it work now?
209. Add an attribute, DateSold of type DateTime?, to the class HistoricOwnership.


206 Make it possible to take multiple cars at a time - using vSelected: vModalResult_vSelected_Car->collect(pc| vCurrent_Person.CarsIUsedToOwn.Add(pc))
210. Set innerlink names to Car for navigation to Car and Person for navigation to Person.


207 Working with many to many relationsships it is very common to want an association class
211. In the ViewModel Person, we add another grid table that shows the link objects. Add nested ViewModelClass multilinks. Find HistoricOwnership.


Create a new Class in the diagram call it HistoricOwnership
212. Test on the web. Verify that the two lists are maintained automatically.


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
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 to the increased precision that the link-object has, pointing out the exact pair of associated objects.


209 Add an attribute DateSold of type DateTime? to the class HistoricOwnership
214. On the nesting HistoricOwnership, set the "ActAs"ForActions to self.Car.


210 set innerlink names to Car for navigtion to Car and Person for navigation to Person
'''Chapter 7'''


211 In the ViewModel Person  we add another grid-table that shows the link objects, add nested ViewModelClass multilinks - find  HistoricOwnership
[[The_1000_steps_program_to_MDriven_Chapter_7]]
 
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]]
[[Category:1000 Steps Program]]
[[Category:1000 Steps Program]]

Revision as of 09:54, 18 January 2023

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

Video 6: MdrivenEducationVideo Steps 183 - 214:

Title Content Time(segment start)
Introduction Introduction 00.00
Creating actions Creating actions 00.52
Modal actions Modal actions, 08:53
Functionality in the webapplication Save, undo, redo and cancel in the webapplication 21:09
Fixing a problem Fixing a problem using search criteria and active expression 22:23
Changing cardinality Changing cardinality/multiplicity and cardinality 0 to many,

adding one list to another with a loop

25:53
Association class Connecting an association and a class, LinkRoleName, InnerLinkName, act as for actions 35:38

And here are the steps as text:

Chapter 6: Modal Dialog to Pick Values and Return to Caller to Use Picked Values

183. The Person ViewModel - The button CarsIUsedToOwn - 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 worked at first, since it pointed to the AutoFormPersonCarsIUsedToOwnMultiLink, which shows the content of CarsIUsedToOwnMultiLink. We have regenerated the AutoForms since then so this action lost its form and a new form was created that the previous action is not connected to. Remove the Button and remove the ViewModel action MultiLinkCarsIUsedToOwn.

184. Add a ViewModelColumn and mark it as Is Action; see that it turns into a button.

185. Name it AddACarIUsedToOwn.

186. Create a ViewModelAction. Name it AddACarIUsedToOwnAction.

187. Hook up the button AddACarIUsedToOwn to the action AddACarIUsedToOwnAction by selecting it in the picker next to the Is Action checkbox.

188. Press the NewEditor button at the top of the ViewModelEditor. In the new window, find the AutoFormCarSeeker.

189. Adopt the AutoFormCarSeeker to make it your own and name it CarSeeker.

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

191. When you are on the web, try AddANewCarIHaveOwned. We see that the seeker for cars comes up, but instead, we want to show it on top of the Person form.

192. Go back to the AddACarIUsedToOwnAction, find the check box Is Modal, check it and save. Test the web.

193. A modal dialog OK button has an enable expression. This must be made true for the user to press ok. Set it to true (by typing the OCL constant "true" in the box). Save and test the web.

194. We really want to enable the user to Search and select cars prior to returning. Open the enableExpressionForModelOk OCL editor on the three dots. Find vSeekerResult->notempty in the expression helper tree and make sure to enter the expression. Save and test the web.

195. 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 nonsense (like AAAAAAAAA). You'll get an empty search result - not OK.

196. The AddACarIUsedToOwnAction also has an Action expression: ActionAfterModalOk. This is where we can act on the user's wishes once the user presses OK. It will not be performed on the Cancel/close box in the modal.

197. Go into the 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 tree, you will see the tree updates reduce the options one at a time to what fits best.

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

  • vCurrent_Person.CarsIUsedToOwn is that person's CarsIUsedToOwn.
  • vCurrent_Person.CarsIUsedToOwn.Add(argument) is a 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 the web.

199. Operations can be canceled or saved. Unsaved things can also be undone and re-done in multiple steps by the user. Try it out.

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 should probably get all.

201. Open up ViewModel PersonSeeker, add another Search Expression and change the Criteria. Set it to Person.allinstances. Change its Active expression to vSeekParam->isnullorempty; this way, this Criteria will kick in only when the search box is blank. Save. Test the web.

202. Bring up the person SomeOtherDude in the browser window 2. What happens when he picks a CarIUsedToOwn that your browser window 1 person already picked?

203. We want it to be possible to have multiple previous owners. Change the cardinality from 0..1 to 0..* on PreviousOwner.

204. Save and see errors. Many are from AutoForms, so Refresh AutoForms and 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. While working with many-to-many relationships, 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. Select the HistoricOwnership class, drag, and hold. Let the mouse go when over the many-to-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 navigation 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 the web. Verify that the two 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 to the increased precision that the link-object has, pointing out the exact 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 35 days ago on 04/12/2024. What links here