Class ::xowiki::formfield::candidate_box_select (public)
::xotcl::Class ::xowiki::formfield::candidate_box_select \ [ -as_box as_box ] [ -keep_order keep_order ] [ -dnd dnd ]
Defined in /var/www/openacs.org/packages/xowiki/tcl/form-field-procs.tcl
XOTcl class for selecting a subset from a list of candidates.
- Switches:
- -as_box (optional)
- makes something like in info box in wikipedia (right floated)
- -keep_order (optional)
- when set, the user provided order is preserved, otherwise the order from the candidates is used.
- -dnd (optional)
- allow drag and drop
- Testcases:
- No testcase defined.
Source code: namespace eval ::xowiki::formfield {} ::nsf::object::alloc ::xotcl::Class ::xowiki::formfield::candidate_box_select {set :__default_metaclass ::xotcl::Class set :__default_superclass ::xotcl::Object set :abstract 1} ::xowiki::formfield::candidate_box_select instproc add_drag_handler {-id:required -event:required} { template::add_event_listener -id $id -event $event -preventdefault=false -script "selection_area_${event}_handler(event);" } ::xowiki::formfield::candidate_box_select instproc add_bulk_handler {-id:required -event:required -operation:required} { template::add_event_listener -id $id -event $event -preventdefault=false -script "selection_area_bulk_operation_handler(event,'$operation');" } ::xowiki::formfield::candidate_box_select instproc render_input {} { #:msg "mul ${:multiple} dnd ${:dnd}" # makes only sense currently for multiple selects if {${:multiple} && ${:dnd}} { if {[:is_disabled]} { html::t -disableOutputEscaping [:pretty_value [:value]] } else { ::xo::Page requireJS "/resources/xowiki/selection-area.js" set count 0 set selected {} set candidates {} foreach o ${:options} { lassign $o label rep if {$rep in ${:value}} { lappend selected $rep } else { lappend candidates $rep } dict set labels $rep label $label #dict set labels $rep label $rep dict set labels $rep serial [incr count] } if {${:keep_order}} { set selected [lmap v ${:value} { if {$v ni $selected} { continue } set _ $v }] } html::div -class candidate-selection -id ${:id} { # # Internal representation # ::html::textarea -id ${:id}.text -name ${:name} { ::html::t [join ${:value} \n] } # # Selections # ::html::div -class "workarea selected" { ::html::h3 { ::html::t "#xowiki.Selection# ([llength $selected])"} # TODO what todo with DISABLED? if {${:bulk_operation}} { ::html::div -id ${:id}.bulk_remove -role "button" -class "text-center bulk-remove" { ::html::t ">>" :add_bulk_handler -id ${:id}.bulk_remove -event click -operation bulk_remove } } ::html::ul -class "region selected" -id ${:id}.selected { foreach v $selected { set id ${:id}.selected.[dict get $labels $v serial] ::html::li -class "selection list-group-item" -draggable true -id $id -data-value $v { ::html::t [dict get $labels $v label] } :add_drag_handler -id $id -event dragstart } } :add_drag_handler -id ${:id}.selected -event drop :add_drag_handler -id ${:id}.selected -event dragover } # # Candidates # ::html::div -class "workarea candidates" { ::html::h3 { ::html::t "#xowiki.Candidates# ([llength $candidates])"} if {${:bulk_operation}} { ::html::div -id ${:id}.bulk_add -role "button" -class "text-center bulk-add" { ::html::t "<<" :add_bulk_handler -id ${:id}.bulk_add -event click -operation bulk_add } } ::html::ul -id ${:id}.candidates -class region { foreach v $candidates { set id ${:id}.[dict get $labels $v serial] ::html::li -class "candidates list-group-item" -draggable true -id $id -data-value $v { ::html::t [dict get $labels $v label] } :add_drag_handler -id $id -event dragstart } } :add_drag_handler -id ${:id}.candidates -event drop :add_drag_handler -id ${:id}.candidates -event dragover } } ::html::div -class visual-clear { ;# this space is left intentionally blank } } } else { next } } ::xowiki::formfield::candidate_box_select instparametercmd keep_order ::xowiki::formfield::candidate_box_select instparametercmd as_box ::xowiki::formfield::candidate_box_select instparametercmd dnd ::xowiki::formfield::candidate_box_select instparametercmd bulk_operation ::nsf::relation::set ::xowiki::formfield::candidate_box_select superclass ::xowiki::formfield::select ::nx::slotObj -container slot ::xowiki::formfield::candidate_box_select ::xowiki::formfield::candidate_box_select::slot eval {set :__parameter { {as_box:boolean false} {keep_order:boolean false} {dnd:boolean true} {bulk_operation:boolean false} }} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::formfield::candidate_box_select::slot::as_box {set :accessor public set :configurable true set :convert false set :default false set :defaultmethods {} set :disposition alias set :domain ::xowiki::formfield::candidate_box_select set :incremental 0 set :manager ::xowiki::formfield::candidate_box_select::slot::as_box set :methodname as_box set :multiplicity 1..1 set :name as_box set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none set :type boolean : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::formfield::candidate_box_select::slot::keep_order {set :accessor public set :configurable true set :convert false set :default false set :defaultmethods {} set :disposition alias set :domain ::xowiki::formfield::candidate_box_select set :incremental 0 set :manager ::xowiki::formfield::candidate_box_select::slot::keep_order set :methodname keep_order set :multiplicity 1..1 set :name keep_order set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none set :type boolean : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::formfield::candidate_box_select::slot::bulk_operation {set :accessor public set :configurable true set :convert false set :default false set :defaultmethods {} set :disposition alias set :domain ::xowiki::formfield::candidate_box_select set :incremental 0 set :manager ::xowiki::formfield::candidate_box_select::slot::bulk_operation set :methodname bulk_operation set :multiplicity 1..1 set :name bulk_operation set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none set :type boolean : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::formfield::candidate_box_select::slot::dnd {set :accessor public set :configurable true set :convert false set :default true set :defaultmethods {} set :disposition alias set :domain ::xowiki::formfield::candidate_box_select set :incremental 0 set :manager ::xowiki::formfield::candidate_box_select::slot::dnd set :methodname dnd set :multiplicity 1..1 set :name dnd set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none set :type boolean : init}XQL Not present: Generic, PostgreSQL, Oracle