[Seaside] RE: [ADD] WASelectTag>>enablementBlock

Boris Popov boris at deepcovelabs.com
Tue Mar 27 20:24:55 UTC 2007


One additional improvement to follow up is the change that makes sure
that single-selection lists don't try to render multiple 'selected'
options (in my case, top 15 countries where we ship appear as duplicates
in a separate group on top of the list, but are repeated again further
down for consistency),

I bet Outlook will mess up the format big time, my apologies,

optionsOn: html
	| brush registeredSelection |
	self isOptional
		ifTrue:
			[brush := (html option)
				selected: selected isNil;
				yourself.
			self hasCallback ifTrue: [brush callback:
[callbackBlock value: nil]].
			brush with: optionalLabel].
	registeredSelection := false.
	list
		do:
			[:each | 
			brush := html option.
			(self isDisabled: each) ifTrue: [brush
disabled].
			((self isMultiple or: [registeredSelection not])
and: [self isSelected: each])
				ifTrue:
					[brush selected: true.
					registeredSelection := true].
			self hasCallback
				ifTrue:
					[brush
						callback:
							[self isMultiple
								ifTrue:
[selected add: each]
								ifFalse:
[callbackBlock value: each]]].
			brush with: (self labelForOption: each)]

Cheers!

-Boris

-- 
+1.604.689.0322
DeepCove Labs Ltd.
4th floor 595 Howe Street
Vancouver, Canada V6C 2T5
http://tinyurl.com/r7uw4

boris at deepcovelabs.com

CONFIDENTIALITY NOTICE

This email is intended only for the persons named in the message
header. Unless otherwise indicated, it contains information that is
private and confidential. If you have received it in error, please
notify the sender and delete the entire message including any
attachments.

Thank you.

> -----Original Message-----
> From: Boris Popov
> Sent: Monday, March 26, 2007 5:27 PM
> To: 'Seaside - general discussion'
> Subject: [ADD] WASelectTag>>enablementBlock
> 
> If you ever needed to build a list with certain elements that aren't
> supposed to be selectable, here's a change that lets you do the
following,
> 
> (html select)
>  list: self countyChoices;
>  selected: self country;
>  enablementBlock: [:ea | ea notNil];
>  labels: [:ea | ea
>                  ifNil: ['-----------------------------']
>                  ifNotNil: [ea description]];
>  callback: [:value | self country: value]
> 
> where #countryChoices returns a collection of countries separated by
nil
> into section with most popular countries and the rest underneath.
> 
> Changes,
> 
> WASelectTag>>enablementBlock: aBlock
>  enablementBlock := aBlock
> 
> WASelectTag>>isDisabled: option
>  ^enablementBlock notNil and: [(enablementBlock value: option) not]
> 
> WASelectTag>>optionsOn: html
>  ...
>  brush := (html option)
> 		disabled: (self isDisabled: each);
> 		selected: (self isSelected: each);
> 		yourself.
>  ...
> 
> Hope this gets integrated at some point :)
> 
> Cheers!
> 
> -Boris
> 
> --
> +1.604.689.0322
> DeepCove Labs Ltd.
> 4th floor 595 Howe Street
> Vancouver, Canada V6C 2T5
> http://tinyurl.com/r7uw4
> 
> boris at deepcovelabs.com
> 
> CONFIDENTIALITY NOTICE
> 
> This email is intended only for the persons named in the message
> header. Unless otherwise indicated, it contains information that is
> private and confidential. If you have received it in error, please
> notify the sender and delete the entire message including any
> attachments.
> 
> Thank you.



More information about the seaside mailing list