Skip to content

Commit

Permalink
Added GtMagritteViewModelExamples>>#dynamicPersonViewModel
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvc committed Oct 4, 2024
1 parent de114ce commit 353d78b
Showing 1 changed file with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,52 @@ GtMagritteViewModelExamples >> basicAsyncViewModel [
^ aViewModel
]

{ #category : #'examples - dynamic' }
GtMagritteViewModelExamples >> dynamicPersonViewModel [
<gtExample>

| model description viewModel |

(model := Dictionary new)
at: #firstName put: 'John';
at: #lastName put: 'Doe'.

(description := MAContainer new)
add: (MAStringDescription new
accessor: (MADictionaryAccessor key: #firstName);
comment: 'First name';
yourself);
add: (MAStringDescription new
accessor: (MADictionaryAccessor key: #lastName);
comment: 'Last name';
yourself).

viewModel := model asGtMagritteViewModelWithDescription: description.

viewModel
ignoreImplicitActions;
addAction: (MAActionDescription new
priority: 20;
label: 'Accept & inspect';
isLabelVisible: false;
blocIcon: BrGlamorousVectorIcons inspect;
action: [ :aModel :aButton :aMemento :aDescription |
aMemento commit.
aButton phlow spawnObject: aModel ] asGtMagritteCallback;
beToolbarAction);
addAction: (MAActionDescription new
priority: 25;
label: 'Cancel';
isLabelVisible: false;
blocIcon: BrGlamorousVectorIcons cancel;
action: [ :aModel :aButton :aMemento :aDescription |
aMemento reset ] asGtMagritteCallback;
beEnabledAndChangedAndInactiveOverallStatus;
beToolbarAction).

^ viewModel
]

{ #category : #'examples - person with two addresses' }
GtMagritteViewModelExamples >> elementWithPersonObjectWithTwoAddresses [

Expand Down

0 comments on commit 353d78b

Please sign in to comment.