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 [hidden email] 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. _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
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 [hidden email] 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 > 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 > > [hidden email] > > 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. _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Boris --
This sounds like something I was dealing with a while back and did some ugly hacks to deal with.. In my case I had several drop-downs with the initial selected item being something like "select one" -- but, I didn't want that one item actually selected.. This code sounds like it might work in this manner.. I'll check it out -- keeps the hacks away! Thanks! -- Rick Boris Popov wrote: > 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 > _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Not sure what your scenario was exactly, but here I have a list that
goes, Canada US ---- (disabled) Armenia ... Canada ... US ... Zimbabwe in which case 'selected' <option> came up twice during rendering phase if you'd selected one of the duplicated countries on top and most browsers would assume it's the latter one you want, so by correcting it I fix two issues: semantically single list should only have one 'selected' option, but practically if you pick Canada, I want the list to highlight Canada in the top portion, not the lower one. Hope this helps, -Boris -- +1.604.689.0322 DeepCove Labs Ltd. 4th floor 595 Howe Street Vancouver, Canada V6C 2T5 http://tinyurl.com/r7uw4 [hidden email] 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: [hidden email] [mailto:seaside- > [hidden email]] On Behalf Of Rick Flower > Sent: Tuesday, March 27, 2007 1:39 PM > To: Seaside - general discussion > Subject: Re: [Seaside] RE: [ADD] WASelectTag>>enablementBlock > > Boris -- > > This sounds like something I was dealing with a while back and did > ugly hacks to deal with.. In my case I had several drop-downs with the > initial selected item being something like "select one" -- but, I didn't > want that one item actually selected.. This code sounds like it might > work in this manner.. I'll check it out -- keeps the hacks away! > > Thanks! > > -- Rick > > Boris Popov wrote: > > 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 > > > > _______________________________________________ > Seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Boris Popov wrote:
> Not sure what your scenario was exactly, but here I have a list that > goes, > > Canada > US > ---- (disabled) > Armenia > ... > Canada > ... > US > ... > Zimbabwe > > in which case 'selected' <option> came up twice during rendering phase > if you'd selected one of the duplicated countries on top and most > browsers would assume it's the latter one you want, so by correcting it > I fix two issues: semantically single list should only have one > 'selected' option, but practically if you pick Canada, I want the list > to highlight Canada in the top portion, not the lower one. your usage scenario is different than mine is certainly, but I think this will work in my case as well.. When I try it out, I'll let you know.. One of my hacks was putting dummy records in my database as placeholders (major hack).. I ultimately wanted a cleaner way to do it and this may be it.. However, I may not be able to try it out for a week or so as I've got to get my taxes done first.. (8-< Thanks Boris! _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |