[MA] labaled options

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

[MA] labaled options

Thomas Fischer
Hi list,
contains Magritte the functionality to define options with different values and labels
via MASingleOptionDescription? Like:
    #('de' => 'Germany' 'gb' => 'Great Britain' )

salute
Thomas
Reply | Threaded
Open this post in threaded view
|

Re: labaled options

Damien Cassou-3
Hi Thomas,

2007/4/12, Thomas Fischer <[hidden email]>:
> contains Magritte the functionality to define options with different values
> and labels
> via MASingleOptionDescription? Like:
>     #('de' => 'Germany' 'gb' => 'Great Britain' )

this were not easily possible. In fact, the reference of your
description was converting the object to a string.

Now, I've just add #labelBlock: which will help you do that kind of thing:

(MASingleOptionDescription    auto: 'country' label: 'Country' priority: 1)
  reference: MANumberDescription new;
  options: {1. 2. 3. 4};
  default: 1;
  labelBlock: [:value :reference | (value + 10) printString];
  beRequired;
  yourself

Here, elements are 1, 2, 3 or 4 and they are printed 11, 12, 13, 14.

To solve your problem, you may want to use a dictionary:

| dict |
dict := Dictionary new
  at: 'de' put: 'Germany';
  at: 'gb' put: 'Great Britain';
  yourself.

^ (MASingleOptionDescription    auto: 'country' label: 'Country' priority: 1)
  reference: MAStringDescription  new;
  options: dict keys;
  default: dict keys anyOne;
  labelBlock: [:value :reference | dict at: value];
  beRequired;
  componentClass: MASelectListComponent ;
  yourself

This has been implemented in Magritte-Model-dc.253 and Magritte-Seaside-dc.218.

Lukas: I will now comment the changes

--
Damien Cassou

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

Re: labaled options

Damien Cassou-3
Lukas told me is never a good idea to add blocks to descriptions. So,
you may prefer not to use that solution. I'm trying to implement
another idea from Lukas. Please wait.

--
Damien Cassou

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

Re: labaled options

Damien Cassou-3
Hi again,

Lukas and I solved the problem. You must use the last version and do
something like:

descriptionCountry
  ^ (MASingleOptionDescription auto: 'country' label: 'Country')
  optionsAndLabels: {#fr->'France'. #gb->'Great Britain'};
  default: #fr;
  beRequired;
  yourself

This work with multiple option descriptions too:

descriptionCountry
  ^ (MAMultipleOptionDescription auto: 'country' label: 'Country')
  optionsAndLabels: {#fr->'France'. #gb->'Great Britain'};
  default: {};
  beRequired;
  yourself

--
Damien Cassou

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

Re: labaled options

tblanchard
What about more dynamic selectors?

Consider that I have an option selector that is addable - there are a  
set set of options, plus the user can add his own.  I'll have to do a  
database query to come up with the available set of options and it  
will vary.  How will this work?

-Todd Blanchard

On Apr 12, 2007, at 11:57 AM, Damien Cassou wrote:

> Hi again,
>
> Lukas and I solved the problem. You must use the last version and do
> something like:
>
> descriptionCountry
>   ^ (MASingleOptionDescription auto: 'country' label: 'Country')
>   optionsAndLabels: {#fr->'France'. #gb->'Great Britain'};
>   default: #fr;
>   beRequired;
>   yourself
>
> This work with multiple option descriptions too:
>
> descriptionCountry
>   ^ (MAMultipleOptionDescription auto: 'country' label: 'Country')
>   optionsAndLabels: {#fr->'France'. #gb->'Great Britain'};
>   default: {};
>   beRequired;
>   yourself
>
> --
> Damien Cassou
>
> _______________________________________________
> SmallWiki, Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki


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

Re: labaled options

Lukas Renggli-2
> Consider that I have an option selector that is addable - there are a
> set set of options, plus the user can add his own.  I'll have to do a
> database query to come up with the available set of options and it
> will vary.  How will this work?

Create (or update) your description dynamically on the instance side:

Address>>description
        ^ super description copy
                add: ((MASingleOptionDescription auto: 'country' label: 'Country')
  optionsAndLabels: self superComplicatedQuery;
                        default: #fr;
                        beRequired;
    yourself);
                yourself

Lukas

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



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

Re: labaled options

Thomas Fischer
In reply to this post by Damien Cassou-3
Damien Cassou schrieb:
> Lukas and I solved the problem. ...

Thanks a lot, a very fast help   :-)

salute
Thomas

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