Index: openacs-4/packages/xowiki/tcl/form-field-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/form-field-procs.tcl,v diff -u -N -r1.284.2.224 -r1.284.2.225 --- openacs-4/packages/xowiki/tcl/form-field-procs.tcl 6 Oct 2022 17:27:48 -0000 1.284.2.224 +++ openacs-4/packages/xowiki/tcl/form-field-procs.tcl 18 Oct 2022 12:58:57 -0000 1.284.2.225 @@ -5060,6 +5060,7 @@ {as_box:boolean false} {keep_order:boolean false} {dnd:boolean true} + {bulk_operation:boolean false} } -ad_doc { Class for selecting a subset from a list of candidates. @param as_box makes something like in info box in wikipedia (right floated) @@ -5080,6 +5081,18 @@ -script "selection_area_${event}_handler(event);" } + 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');" + } + candidate_box_select instproc render_input {} { #:msg "mul ${:multiple} dnd ${:dnd}" # makes only sense currently for multiple selects @@ -5129,6 +5142,12 @@ ::html::div -class workarea { ::html::h3 { ::html::t "#xowiki.Selection#"} # 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 { @@ -5148,6 +5167,12 @@ # ::html::div -class workarea { ::html::h3 { ::html::t "#xowiki.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] Index: openacs-4/packages/xowiki/www/resources/selection-area.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/www/resources/Attic/selection-area.js,v diff -u -N -r1.1.2.4 -r1.1.2.5 --- openacs-4/packages/xowiki/www/resources/selection-area.js 13 Aug 2019 07:27:02 -0000 1.1.2.4 +++ openacs-4/packages/xowiki/www/resources/selection-area.js 18 Oct 2022 12:58:57 -0000 1.1.2.5 @@ -47,9 +47,13 @@ // Reparent the dropped item ul.appendChild(sourceElement); + var id = ul.parentElement.parentElement.id; + selection_area_update_internal_representation(id); +} + +function selection_area_update_internal_representation (id) { // Update the internal representation based on the data-element of // the list items. - var id = ul.parentElement.parentElement.id; var textarea = document.getElementById(id + ".text"); var items = document.getElementById(id + ".selected").getElementsByTagName('LI'); var internalRep = ""; @@ -61,6 +65,28 @@ textarea.value = internalRep; } +function selection_area_bulk_operation_handler(ev, operation) { + if (operation == 'bulk_add') { + var source_class = '.candidates'; + var destination_class = '.selected'; + } else { + // bulk_remove operation + var source_class = '.selected'; + var destination_class = '.candidates'; + } + + var id = ev.target.previousSibling.parentElement.parentElement.id; + var source = document.getElementById(id + source_class).getElementsByTagName('LI'); + var destination = document.getElementById(id + destination_class); + + // Reparent all source items + while(source.length > 0) { + destination.appendChild(source[0]); + } + + selection_area_update_internal_representation(id); +} + /* * Local variables: * mode: JavaScript