ILSelectField and multiple: true

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

ILSelectField and multiple: true

zecke-2
Dear Nicolas,

ILSelectField>>#fieldContents can only add elements but never remove
them. This means that unselecting an item on configuration is not
possible at all. I am using the below patch.


diff --git a/More/Formula/ILSelectField.st b/More/Formula/
ILSelectField.st
index e5e7b1e..2afa002 100644
--- a/More/Formula/ILSelectField.st
+++ b/More/Formula/ILSelectField.st
@@ -60,14 +60,17 @@ ILOptionField subclass: ILSelectField [

     fieldContents [
        <category: 'building'>
-       ^[:e |
+       ^[:e | | val |
            e select build: [:select |
+               val := self value.
                self isMultiple ifTrue: [
+                   self value: OrderedCollection new.
                    select beMultiple].
+
                self options do: [:each |
                    select option
                        selected: (self isMultiple
-                           ifTrue: [self value includes: each]
+                           ifTrue: [val includes: each]
                            ifFalse: [self value = each]);
                        text: (self optionLabelBlock value: each);
                        action: [self isMultiple

Reply | Threaded
Open this post in threaded view
|

Re: ILSelectField and multiple: true

Nicolas Petton

I'm not sure I understand. Does your patch fix the issue?

Nico

zecke <[hidden email]> writes:

> Dear Nicolas,
>
> ILSelectField>>#fieldContents can only add elements but never remove
> them. This means that unselecting an item on configuration is not
> possible at all. I am using the below patch.
>
>
> diff --git a/More/Formula/ILSelectField.st b/More/Formula/
> ILSelectField.st
> index e5e7b1e..2afa002 100644
> --- a/More/Formula/ILSelectField.st
> +++ b/More/Formula/ILSelectField.st
> @@ -60,14 +60,17 @@ ILOptionField subclass: ILSelectField [
>
>      fieldContents [
>         <category: 'building'>
> -       ^[:e |
> +       ^[:e | | val |
>             e select build: [:select |
> +               val := self value.
>                 self isMultiple ifTrue: [
> +                   self value: OrderedCollection new.
>                     select beMultiple].
> +
>                 self options do: [:each |
>                     select option
>                         selected: (self isMultiple
> -                           ifTrue: [self value includes: each]
> +                           ifTrue: [val includes: each]
>                             ifFalse: [self value = each]);
>                         text: (self optionLabelBlock value: each);
>                         action: [self isMultiple
>

--
Nicolas Petton
http://nicolas-petton.fr
Reply | Threaded
Open this post in threaded view
|

Re: ILSelectField and multiple: true

zecke-2
On Jan 7, 2:27 pm, Nicolas Petton <[hidden email]> wrote:
> I'm not sure I understand. Does your patch fix the issue?

Well, as far as I can see it is fixing my issue and it kind of makes
sense to me as well. We should start with an empty list before we get
all the callbacks that result in adding to the list. I just wonder if
something like ILField>>#beforeSave would make sense to allow other
fields to reset the state as well.

holger