Hi!


I am facing a constant pattern where I need to update some data and
there I might have new or removed options (coming from SELECT elements
with MULTIPLE, INPUT elements of type CHECKBOX, etc.).

There's some JS code that I've used with the Select Shuttle (a
TurboGears widget that allows moving items from one SELECT of available
options to one SELECT of chosen options) and it implements something
that I think is a good interface, hence I'm writing to you -- great
experts ;-) -- to check it (for a newbie like me everything looks good
when it works!).

What it does is implementing six hidden fields:

     - available new
     - available added
     - available removed
     - selected new
     - selected added
     - selected removed

here, 'new' means all options in that state and is useful if you're
creating a new record because you just have to loop over values on this
field.

'added' and 'removed' are useful for updating existing information.

When one option is moved from the available list to the selected list
this API would:

     - remove its index or value (it depends on the element) from
       available new

     - if its value or index was not in available added then add its
       index or value to available removed

     - add its index or value to selected new

     - if its value or index was not in available added then add its
       index or value to selected added

When one option is moved from the selected list to the available list
this API would (kind of cut & pasted from above with reversed names):

     - remove its index or value (it depends on the element) from
       selected new

     - if its value or index was not in selected added then add its
       index or value to selected removed

     - add its index or value to available new

     - if its value or index was not in selected added then add its
       index or value to available added


With that in place I can say, on my backend:

     - When inserting new records, add all 'selected new' options to
       them

     - When updating existing records add all 'selected added' options
       and remove all 'available added' options from them  (I could also
       reverse the checks and use the 'removed' version of the lists...)


Do you think it is a good interface?  Do you have any recommendations on
how to make it better?  I'm willing to implement that for checkboxes and
selects.  Do you see any other element where this kind of interface
could be applied to?



Thanks for you opinions,
-- 
Jorge Godoy      <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to