What is the correct way to add actions to my asComponent form?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

What is the correct way to add actions to my asComponent form?

Danie Roux-5
Dear list,

I am trying out Magritte on an existing app. I have this scenario
working, but I had to follow the same hack as
PRChangeCommand>>applyButton.

One of the screens have three buttons: Save, Cancel and SomeMoreStuffToAdd

If I click on "SomeMoreStuffToAdd", I want to some more stuff to
happen. For this, I override #asComponent on my model and add the
button and the selector myself:

asComponent
       ^ super asComponent
               addValidatedForm: (Array
                               with: #save -> 'Save'
                               with: #cancel -> 'Cancel'
                               with: #someMore -> 'Some More Stuff')

The very hackish part, I now need to add this to MAContainerComponent
for it to work:

someMore
        self call: (AnotherComponent new)

Is there a cleaner way? A bunch of Monticello extensions
on MAContainerComponent hardly seems like the best way to extend
MAContainerComponent's to have more actions!

--
Danie Roux *shuffle* Adore Unix - http://danieroux.com

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: What is the correct way to add actions to my asComponent form?

Lukas Renggli-2
> The very hackish part, I now need to add this to MAContainerComponent
> for it to work:
>
> someMore
>        self call: (AnotherComponent new)
>
> Is there a cleaner way? A bunch of Monticello extensions
> on MAContainerComponent hardly seems like the best way to extend
> MAContainerComponent's to have more actions!

Sure, this is ment to be used like this. If you don't like this, you  
can create your own form decoration that has a different behavior.

I would not override #asComponent thought. #asComponent is ment to  
just return the component, without any decorations added. Like this  
the user can choose itself what he wants to add. If you have a lot of  
code like the one you posted, you might want to create your own custom  
converter:

asMyFormComponent
        ^ self asComponent
               addValidatedForm: (Array
                               with: #save -> 'Save'
                               with: #cancel -> 'Cancel'
                               with: #someMore -> 'Some More Stuff')

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki