You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2026/05/07 16:00:03 UTC
(myfaces-tobago) branch main updated: feat: shuttle ordering (#7303)
This is an automated email from the ASF dual-hosted git repository.
lofwyr14 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
The following commit(s) were added to refs/heads/main by this push:
new 292121f571 feat: shuttle ordering (#7303)
292121f571 is described below
commit 292121f571a9b00ea8d25a870ae3f4d86dfb46cc
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Thu May 7 17:59:57 2026 +0200
feat: shuttle ordering (#7303)
* feat: shuttle ordering
SelectManyShuttle: selected list should be sortable by the user
"remove" and "removeAll" should put the unselected option back in the list at the original place/order.
issue: TOBAGO-2486
* feat: shuttle ordering
SelectManyShuttle: selected list should be sortable by the user
"remove" and "removeAll" should put the unselected option back in the list at the original place/order.
issue: TOBAGO-2486
* feat: shuttle ordering
SelectManyShuttle: selected list should be sortable by the user
"remove" and "removeAll" should put the unselected option back in the list at the original place/order.
issue: TOBAGO-2486
---
.../myfaces/tobago/component/Attributes.java | 1 +
.../component/AbstractUISelectManyShuttle.java | 2 +
.../renderer/SelectManyShuttleRenderer.java | 65 ++++++++-
.../component/SelectManyShuttleTagDeclaration.java | 13 +-
.../myfaces/tobago/renderkit/RendererBase.java | 6 +-
.../apache/myfaces/tobago/renderkit/css/Icons.java | 4 +
.../myfaces/tobago/renderkit/css/TobagoClass.java | 3 +-
.../tobago/renderkit/html/DataAttributes.java | 2 +
.../SelectManyShuttleRendererUnitTest.java | 17 +++
.../renderer/selectManyShuttle/disabled.html | 4 +-
.../renderer/selectManyShuttle/error-message.html | 4 +-
.../resources/renderer/selectManyShuttle/help.html | 4 +-
.../renderer/selectManyShuttle/label.html | 4 +-
.../{selected.html => orderable.html} | 16 +-
.../renderer/selectManyShuttle/readonly.html | 4 +-
.../renderer/selectManyShuttle/selected.html | 4 +-
.../renderer/selectManyShuttle/simple.html | 4 +-
.../example/demo/SelectManyShuttleController.java | 31 ++--
.../test/SelectManyShuttleOrderableController.java | 33 +++--
.../030-select/70-selectManyShuttle/Shuttle.xhtml | 17 ++-
.../selectManyShuttle/SelectManyShuttle.xhtml | 2 +-
...ttle.xhtml => SelectManyShuttleOrderable.xhtml} | 7 +-
.../src/test/typescript/selectManyShuttle.test.ts | 5 +-
....test.ts => selectManyShuttleOrderable.test.ts} | 40 ++---
tobago-theme/src/main/scss/_tobago.scss | 4 +
.../src/main/css/tobago.css.map | 2 +-
.../src/main/css/tobago.css.map | 2 +-
.../src/main/css/tobago.css.map | 2 +-
.../src/main/css/tobago.css.map | 2 +-
.../src/main/css/tobago.css.map | 2 +-
.../tobago-theme-standard/src/main/js/tobago.js | 8 +-
.../src/main/js/tobago.js.map | 2 +-
.../src/main/ts/tobago-select-many-shuttle.ts | 161 +++++++++++++++++++--
33 files changed, 367 insertions(+), 110 deletions(-)
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
index 7cc2605233..c166b1fe3e 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
@@ -310,6 +310,7 @@ public enum Attributes {
@Deprecated(since = "3.0.0", forRemoval = true)
onchange,
open,
+ orderable,
orderBy,
orientation,
outcome,
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectManyShuttle.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectManyShuttle.java
index 71bbe10a80..bca3eac1fd 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectManyShuttle.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectManyShuttle.java
@@ -33,4 +33,6 @@ public boolean hasLabel() {
}
public abstract Integer getSize();
+
+ public abstract boolean isOrderable();
}
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyShuttleRenderer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyShuttleRenderer.java
index 5743fc0767..51dbc98c06 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyShuttleRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyShuttleRenderer.java
@@ -22,10 +22,12 @@
import org.apache.myfaces.tobago.context.Markup;
import org.apache.myfaces.tobago.internal.component.AbstractUISelectManyShuttle;
import org.apache.myfaces.tobago.internal.util.HtmlRendererUtils;
+import org.apache.myfaces.tobago.internal.util.JsonUtils;
import org.apache.myfaces.tobago.internal.util.SelectItemUtils;
import org.apache.myfaces.tobago.renderkit.css.BootstrapClass;
import org.apache.myfaces.tobago.renderkit.css.Icons;
import org.apache.myfaces.tobago.renderkit.css.TobagoClass;
+import org.apache.myfaces.tobago.renderkit.html.DataAttributes;
import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
import org.apache.myfaces.tobago.renderkit.html.HtmlButtonTypes;
import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
@@ -39,7 +41,6 @@
import jakarta.faces.model.SelectItem;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
-import java.util.Arrays;
import java.util.List;
public class SelectManyShuttleRenderer<T extends AbstractUISelectManyShuttle> extends SelectManyRendererBase<T> {
@@ -78,7 +79,7 @@ public void encodeBeginField(final FacesContext facesContext, final T component)
final Integer[] orderList = new Integer[length];
writer.startElement(HtmlElements.SELECT);
- writer.writeClassAttribute(BootstrapClass.D_NONE);
+ writer.writeClassAttribute(BootstrapClass.D_NONE, TobagoClass.VALUE);
final String hiddenClientId = clientId + ComponentUtils.SUB_SEPARATOR + "hidden";
writer.writeIdAttribute(hiddenClientId);
writer.writeNameAttribute(clientId);
@@ -88,10 +89,6 @@ public void encodeBeginField(final FacesContext facesContext, final T component)
component, null, items, values, submittedValues, null, writer, facesContext, orderList, 0);
writer.endElement(HtmlElements.SELECT);
- if (LOG.isDebugEnabled()) {
- LOG.debug("orderList={}", Arrays.toString(orderList));
- }
-
writer.startElement(HtmlElements.DIV);
writer.writeClassAttribute(TobagoClass.UNSELECTED__CONTAINER);
@@ -148,7 +145,7 @@ public void encodeBeginField(final FacesContext facesContext, final T component)
writer.startElement(HtmlElements.SELECT);
final String selectedClientId = clientId + ComponentUtils.SUB_SEPARATOR + "selected";
writer.writeIdAttribute(selectedClientId);
-
+ writer.writeAttribute(DataAttributes.ORDER, JsonUtils.encode(orderList), false);
writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
writer.writeAttribute(HtmlAttributes.READONLY, readonly);
writer.writeAttribute(HtmlAttributes.TABINDEX, component.getTabIndex());
@@ -162,6 +159,60 @@ public void encodeBeginField(final FacesContext facesContext, final T component)
writer.writeAttribute(HtmlAttributes.SIZE, size);
writer.endElement(HtmlElements.SELECT);
writer.endElement(HtmlElements.DIV);
+
+ if (component.isOrderable()) {
+ writer.startElement(HtmlElements.DIV);
+ writer.writeClassAttribute(TobagoClass.CONTROLS);
+ writer.startElement(HtmlElements.DIV);
+ writer.writeClassAttribute(BootstrapClass.BTN_GROUP_VERTICAL);
+
+ writer.startElement(HtmlElements.BUTTON);
+ writer.writeAttribute(HtmlAttributes.TYPE, HtmlButtonTypes.BUTTON);
+ writer.writeClassAttribute(BootstrapClass.BTN, BootstrapClass.BTN_SECONDARY);
+ writer.writeIdAttribute(component.getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + "top");
+ writer.writeAttribute(DataAttributes.ACTION, "top", false);
+ writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
+ writer.startElement(HtmlElements.I);
+ writer.writeClassAttribute(Icons.CHEVRON_DOUBLE_UP);
+ writer.endElement(HtmlElements.I);
+ writer.endElement(HtmlElements.BUTTON);
+
+ writer.startElement(HtmlElements.BUTTON);
+ writer.writeAttribute(HtmlAttributes.TYPE, HtmlButtonTypes.BUTTON);
+ writer.writeClassAttribute(BootstrapClass.BTN, BootstrapClass.BTN_SECONDARY);
+ writer.writeIdAttribute(component.getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + "up");
+ writer.writeAttribute(DataAttributes.ACTION, "up", false);
+ writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
+ writer.startElement(HtmlElements.I);
+ writer.writeClassAttribute(Icons.CHEVRON_UP);
+ writer.endElement(HtmlElements.I);
+ writer.endElement(HtmlElements.BUTTON);
+
+ writer.startElement(HtmlElements.BUTTON);
+ writer.writeAttribute(HtmlAttributes.TYPE, HtmlButtonTypes.BUTTON);
+ writer.writeClassAttribute(BootstrapClass.BTN, BootstrapClass.BTN_SECONDARY);
+ writer.writeIdAttribute(component.getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + "down");
+ writer.writeAttribute(DataAttributes.ACTION, "down", false);
+ writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
+ writer.startElement(HtmlElements.I);
+ writer.writeClassAttribute(Icons.CHEVRON_DOWN);
+ writer.endElement(HtmlElements.I);
+ writer.endElement(HtmlElements.BUTTON);
+
+ writer.startElement(HtmlElements.BUTTON);
+ writer.writeAttribute(HtmlAttributes.TYPE, HtmlButtonTypes.BUTTON);
+ writer.writeClassAttribute(BootstrapClass.BTN, BootstrapClass.BTN_SECONDARY);
+ writer.writeIdAttribute(component.getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + "bottom");
+ writer.writeAttribute(DataAttributes.ACTION, "bottom", false);
+ writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
+ writer.startElement(HtmlElements.I);
+ writer.writeClassAttribute(Icons.CHEVRON_DOUBLE_DOWN);
+ writer.endElement(HtmlElements.I);
+ writer.endElement(HtmlElements.BUTTON);
+
+ writer.endElement(HtmlElements.DIV);
+ writer.endElement(HtmlElements.DIV);
+ }
}
@Override
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectManyShuttleTagDeclaration.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectManyShuttleTagDeclaration.java
index b975c334b1..1b2eae50d1 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectManyShuttleTagDeclaration.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectManyShuttleTagDeclaration.java
@@ -92,23 +92,30 @@ public interface SelectManyShuttleTagDeclaration extends
HasAutoSpacing, HasDecorationPosition {
/**
- * The value of the multi select.
+ * The value of the multi-select.
*/
@TagAttribute
@UIComponentTagAttribute(type = {"java.lang.Object[]", "java.util.List"})
void setValue(String value);
/**
- * A localized user presentable label for the left select box.
+ * A localized user-presentable label for the left select box.
*/
@TagAttribute
@UIComponentTagAttribute()
void setUnselectedLabel(String label);
/**
- * A localized user presentable label for the right select box.
+ * A localized user-presentable label for the right select box.
*/
@TagAttribute
@UIComponentTagAttribute()
void setSelectedLabel(String label);
+
+ /**
+ * Can the list of selected items be ordered?
+ */
+ @TagAttribute
+ @UIComponentTagAttribute(type = "boolean", defaultValue = "false")
+ void setOrderable(String orderable);
}
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/RendererBase.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/RendererBase.java
index 7c455e3213..c3e0cd18c9 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/RendererBase.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/RendererBase.java
@@ -447,9 +447,9 @@ protected int renderSelectItemsAndGetOrder(
final UIInput component, final TobagoClass optionClass,
final Iterable<SelectItem> items, final Object[] values, final String[] submittedValues,
final Boolean onlySelected, final TobagoResponseWriter writer, final FacesContext facesContext,
- Integer[] orderList, int givenIndex)
+ final Integer[] orderList, final int startIndex)
throws IOException {
- int index = givenIndex; //TODO make this less ugly
+ int index = startIndex;
if (LOG.isDebugEnabled()) {
LOG.debug("component id = '{}'", component.getId());
@@ -464,7 +464,7 @@ protected int renderSelectItemsAndGetOrder(
writer.writeAttribute(HtmlAttributes.DISABLED, true);
}
final SelectItem[] selectItems = ((SelectItemGroup) item).getSelectItems();
- index = renderSelectItemsAndGetOrder(component, optionClass, Arrays.asList(selectItems), values,
+ index = renderSelectItemsAndGetOrder(component, optionClass, Arrays.asList(selectItems), values,
submittedValues, onlySelected, writer, facesContext, orderList, index);
writer.endElement(HtmlElements.OPTGROUP);
} else {
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Icons.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Icons.java
index f99fb8765e..5c6eac3f05 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Icons.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Icons.java
@@ -32,10 +32,14 @@
public enum Icons implements CssItem {
ARROW_DOWN,
+ CHEVRON_DOUBLE_DOWN,
CHEVRON_DOUBLE_LEFT,
CHEVRON_DOUBLE_RIGHT,
+ CHEVRON_DOUBLE_UP,
+ CHEVRON_DOWN,
CHEVRON_LEFT,
CHEVRON_RIGHT,
+ CHEVRON_UP,
CARET_LEFT,
CALENDAR3,
CLOCK,
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/TobagoClass.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/TobagoClass.java
index d0ee7c388b..ed4cdda2b7 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/TobagoClass.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/TobagoClass.java
@@ -128,7 +128,8 @@ public enum TobagoClass implements CssItem {
TOGGLE("tobago-toggle"),
TOOLTIP("tobago-tooltip"),
UNSELECTED("tobago-unselected"),
- UNSELECTED__CONTAINER("tobago-unselected-container");
+ UNSELECTED__CONTAINER("tobago-unselected-container"),
+ VALUE("tobago-value");
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
index 20b6e8dff3..3a85fe76b5 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
@@ -136,6 +136,8 @@ public enum DataAttributes implements MarkupLanguageAttributes {
OPTIONS("data-tobago-options"),
+ ORDER("data-tobago-order"),
+
PARTIAL_IDS("data-tobago-partial-ids"),
PARTIAL_ACTION("data-tobago-partial-action"),
diff --git a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyShuttleRendererUnitTest.java b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyShuttleRendererUnitTest.java
index 5db5dd29bc..debed551e0 100644
--- a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyShuttleRendererUnitTest.java
+++ b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyShuttleRendererUnitTest.java
@@ -134,6 +134,23 @@ public void selected() throws IOException {
Assertions.assertEquals(loadHtml("renderer/selectManyShuttle/selected.html"), formattedResult());
}
+ @Test
+ public void orderable() throws IOException {
+ final UISelectManyShuttle c = (UISelectManyShuttle) ComponentUtils.createComponent(
+ facesContext, Tags.selectManyShuttle.componentType(), RendererTypes.SelectManyShuttle, "id");
+
+ addSelectItem("i1", "Value 1", "1", c);
+ addSelectItem("i2", "Value 2", "2", c);
+ addSelectItem("i3", "Value 3", "3", c);
+ addSelectItem("i4", "Value 4", "4", c);
+ addSelectItem("i5", "Value 5", "5", c);
+ addSelectItem("i6", "Value 6", "6", c);
+
+ c.encodeAll(facesContext);
+
+ Assertions.assertEquals(loadHtml("renderer/selectManyShuttle/orderable.html"), formattedResult());
+ }
+
private void addSelectItem(String id, String itemLabel, String itemValue, UISelectManyShuttle shuttle) {
final UISelectItem selectItem = (UISelectItem) ComponentUtils.createComponent(
facesContext, Tags.selectItem.componentType(), null, id);
diff --git a/tobago-core/src/test/resources/renderer/selectManyShuttle/disabled.html b/tobago-core/src/test/resources/renderer/selectManyShuttle/disabled.html
index 49e865a1b2..18bcb61068 100644
--- a/tobago-core/src/test/resources/renderer/selectManyShuttle/disabled.html
+++ b/tobago-core/src/test/resources/renderer/selectManyShuttle/disabled.html
@@ -17,7 +17,7 @@
<tobago-select-many-shuttle id='id' class='tobago-auto-spacing'>
<div class='tobago-body'>
-<select class='d-none' id='id::hidden' name='id' multiple='multiple'>
+<select class='d-none tobago-value' id='id::hidden' name='id' multiple='multiple'>
<option value=''>Value 1</option>
<option value=''>Value 2</option></select>
<div class='tobago-unselected-container'>
@@ -29,4 +29,4 @@
<button type='button' class='btn btn-secondary' id='id::remove' disabled='disabled'><i class='bi-chevron-left'></i></button>
<button type='button' class='btn btn-secondary' id='id::removeAll' disabled='disabled'><i class='bi-chevron-double-left'></i></button></div></div>
<div class='tobago-selected-container'>
-<select id='id::selected' disabled='disabled' class='tobago-selected form-select' multiple='multiple' size='2'></select></div></div></tobago-select-many-shuttle>
+<select id='id::selected' data-tobago-order='[]' disabled='disabled' class='tobago-selected form-select' multiple='multiple' size='2'></select></div></div></tobago-select-many-shuttle>
diff --git a/tobago-core/src/test/resources/renderer/selectManyShuttle/error-message.html b/tobago-core/src/test/resources/renderer/selectManyShuttle/error-message.html
index f3e9adbd18..cd3e1d975d 100644
--- a/tobago-core/src/test/resources/renderer/selectManyShuttle/error-message.html
+++ b/tobago-core/src/test/resources/renderer/selectManyShuttle/error-message.html
@@ -18,7 +18,7 @@
<tobago-select-many-shuttle id='id' class='tobago-auto-spacing'>
<div class='tobago-messages-container tobago-button-right' data-tobago-faces-message='a test'>
<div class='tobago-body' title='a test'>
-<select class='d-none' id='id::hidden' name='id' multiple='multiple'>
+<select class='d-none tobago-value' id='id::hidden' name='id' multiple='multiple'>
<option value=''>Value 1</option>
<option value=''>Value 2</option></select>
<div class='tobago-unselected-container'>
@@ -30,6 +30,6 @@
<button type='button' class='btn btn-secondary' id='id::remove'><i class='bi-chevron-left'></i></button>
<button type='button' class='btn btn-secondary' id='id::removeAll'><i class='bi-chevron-double-left'></i></button></div></div>
<div class='tobago-selected-container'>
-<select id='id::selected' class='tobago-selected is-error form-select' multiple='multiple' size='2'></select></div></div>
+<select id='id::selected' data-tobago-order='[]' class='tobago-selected is-error form-select' multiple='multiple' size='2'></select></div></div>
<tobago-popover label='Error' value='a test'>
<a tabindex='0' role='button' class='btn btn-danger'><i class='bi-exclamation-lg'></i></a></tobago-popover></div></tobago-select-many-shuttle>
diff --git a/tobago-core/src/test/resources/renderer/selectManyShuttle/help.html b/tobago-core/src/test/resources/renderer/selectManyShuttle/help.html
index 9713866eaa..9ea0b831f2 100644
--- a/tobago-core/src/test/resources/renderer/selectManyShuttle/help.html
+++ b/tobago-core/src/test/resources/renderer/selectManyShuttle/help.html
@@ -18,7 +18,7 @@
<tobago-select-many-shuttle id='id' class='tobago-auto-spacing'>
<div class='tobago-help-container tobago-button-right' data-tobago-help='Help!'>
<div class='tobago-body'>
-<select class='d-none' id='id::hidden' name='id' multiple='multiple'>
+<select class='d-none tobago-value' id='id::hidden' name='id' multiple='multiple'>
<option value=''>Value 1</option>
<option value=''>Value 2</option></select>
<div class='tobago-unselected-container'>
@@ -30,6 +30,6 @@
<button type='button' class='btn btn-secondary' id='id::remove'><i class='bi-chevron-left'></i></button>
<button type='button' class='btn btn-secondary' id='id::removeAll'><i class='bi-chevron-double-left'></i></button></div></div>
<div class='tobago-selected-container'>
-<select id='id::selected' class='tobago-selected form-select' multiple='multiple' size='2'></select></div></div>
+<select id='id::selected' data-tobago-order='[]' class='tobago-selected form-select' multiple='multiple' size='2'></select></div></div>
<tobago-popover label='Help' value='Help!'>
<a tabindex='0' role='button' class='btn btn-outline-info'><i class='bi-question-lg'></i></a></tobago-popover></div></tobago-select-many-shuttle>
diff --git a/tobago-core/src/test/resources/renderer/selectManyShuttle/label.html b/tobago-core/src/test/resources/renderer/selectManyShuttle/label.html
index b61509b0d3..83e77b511b 100644
--- a/tobago-core/src/test/resources/renderer/selectManyShuttle/label.html
+++ b/tobago-core/src/test/resources/renderer/selectManyShuttle/label.html
@@ -18,7 +18,7 @@
<tobago-select-many-shuttle id='id' class='tobago-label-container tobago-auto-spacing'>
<label for='id::unselected' class='col-form-label'>label</label>
<div class='tobago-body'>
-<select class='d-none' id='id::hidden' name='id' multiple='multiple'>
+<select class='d-none tobago-value' id='id::hidden' name='id' multiple='multiple'>
<option value=''>Value 1</option>
<option value=''>Value 2</option></select>
<div class='tobago-unselected-container'>
@@ -30,4 +30,4 @@
<button type='button' class='btn btn-secondary' id='id::remove'><i class='bi-chevron-left'></i></button>
<button type='button' class='btn btn-secondary' id='id::removeAll'><i class='bi-chevron-double-left'></i></button></div></div>
<div class='tobago-selected-container'>
-<select id='id::selected' class='tobago-selected form-select' multiple='multiple' size='2'></select></div></div></tobago-select-many-shuttle>
+<select id='id::selected' data-tobago-order='[]' class='tobago-selected form-select' multiple='multiple' size='2'></select></div></div></tobago-select-many-shuttle>
diff --git a/tobago-core/src/test/resources/renderer/selectManyShuttle/selected.html b/tobago-core/src/test/resources/renderer/selectManyShuttle/orderable.html
similarity index 75%
copy from tobago-core/src/test/resources/renderer/selectManyShuttle/selected.html
copy to tobago-core/src/test/resources/renderer/selectManyShuttle/orderable.html
index 42238e3468..f026181f43 100644
--- a/tobago-core/src/test/resources/renderer/selectManyShuttle/selected.html
+++ b/tobago-core/src/test/resources/renderer/selectManyShuttle/orderable.html
@@ -17,13 +17,15 @@
<tobago-select-many-shuttle id='id' class='tobago-auto-spacing'>
<div class='tobago-body'>
-<select class='d-none' id='id::hidden' name='id' multiple='multiple'>
-<option value='v1'>Value 1</option>
-<option value='v2' selected='selected'>Value 2</option>
-<option value='v3'>Value 3</option>
-<option value='v4' selected='selected'>Value 4</option></select>
+<select class='d-none tobago-value' id='id::hidden' name='id' multiple='multiple'>
+<option value='1'>Value 1</option>
+<option value='2'>Value 2</option>
+<option value='3'>Value 3</option>
+<option value='4'>Value 4</option>
+<option value='5'>Value 5</option>
+<option value='6'>Value 6</option></select>
<div class='tobago-unselected-container'>
-<select id='id::unselected' class='tobago-unselected form-select' multiple='multiple' size='4'></select></div>
+<select id='id::unselected' class='tobago-unselected form-select' multiple='multiple' size='6'></select></div>
<div class='tobago-controls'>
<div class='btn-group-vertical'>
<button type='button' class='btn btn-secondary' id='id::addAll'><i class='bi-chevron-double-right'></i></button>
@@ -31,4 +33,4 @@
<button type='button' class='btn btn-secondary' id='id::remove'><i class='bi-chevron-left'></i></button>
<button type='button' class='btn btn-secondary' id='id::removeAll'><i class='bi-chevron-double-left'></i></button></div></div>
<div class='tobago-selected-container'>
-<select id='id::selected' class='tobago-selected form-select' multiple='multiple' size='4'></select></div></div></tobago-select-many-shuttle>
+<select id='id::selected' data-tobago-order='[]' class='tobago-selected form-select' multiple='multiple' size='6'></select></div></div></tobago-select-many-shuttle>
diff --git a/tobago-core/src/test/resources/renderer/selectManyShuttle/readonly.html b/tobago-core/src/test/resources/renderer/selectManyShuttle/readonly.html
index 2ca0ccec22..fe2cfa4236 100644
--- a/tobago-core/src/test/resources/renderer/selectManyShuttle/readonly.html
+++ b/tobago-core/src/test/resources/renderer/selectManyShuttle/readonly.html
@@ -17,7 +17,7 @@
<tobago-select-many-shuttle id='id' class='tobago-auto-spacing'>
<div class='tobago-body'>
-<select class='d-none' id='id::hidden' name='id' multiple='multiple'>
+<select class='d-none tobago-value' id='id::hidden' name='id' multiple='multiple'>
<option value=''>Value 1</option>
<option value=''>Value 2</option></select>
<div class='tobago-unselected-container'>
@@ -29,4 +29,4 @@
<button type='button' class='btn btn-secondary' id='id::remove' disabled='disabled'><i class='bi-chevron-left'></i></button>
<button type='button' class='btn btn-secondary' id='id::removeAll' disabled='disabled'><i class='bi-chevron-double-left'></i></button></div></div>
<div class='tobago-selected-container'>
-<select id='id::selected' disabled='disabled' readonly='readonly' class='tobago-selected form-select' multiple='multiple' size='2'></select></div></div></tobago-select-many-shuttle>
+<select id='id::selected' data-tobago-order='[]' disabled='disabled' readonly='readonly' class='tobago-selected form-select' multiple='multiple' size='2'></select></div></div></tobago-select-many-shuttle>
diff --git a/tobago-core/src/test/resources/renderer/selectManyShuttle/selected.html b/tobago-core/src/test/resources/renderer/selectManyShuttle/selected.html
index 42238e3468..484cfb2c31 100644
--- a/tobago-core/src/test/resources/renderer/selectManyShuttle/selected.html
+++ b/tobago-core/src/test/resources/renderer/selectManyShuttle/selected.html
@@ -17,7 +17,7 @@
<tobago-select-many-shuttle id='id' class='tobago-auto-spacing'>
<div class='tobago-body'>
-<select class='d-none' id='id::hidden' name='id' multiple='multiple'>
+<select class='d-none tobago-value' id='id::hidden' name='id' multiple='multiple'>
<option value='v1'>Value 1</option>
<option value='v2' selected='selected'>Value 2</option>
<option value='v3'>Value 3</option>
@@ -31,4 +31,4 @@
<button type='button' class='btn btn-secondary' id='id::remove'><i class='bi-chevron-left'></i></button>
<button type='button' class='btn btn-secondary' id='id::removeAll'><i class='bi-chevron-double-left'></i></button></div></div>
<div class='tobago-selected-container'>
-<select id='id::selected' class='tobago-selected form-select' multiple='multiple' size='4'></select></div></div></tobago-select-many-shuttle>
+<select id='id::selected' data-tobago-order='[1,3]' class='tobago-selected form-select' multiple='multiple' size='4'></select></div></div></tobago-select-many-shuttle>
diff --git a/tobago-core/src/test/resources/renderer/selectManyShuttle/simple.html b/tobago-core/src/test/resources/renderer/selectManyShuttle/simple.html
index 57b736f104..e000d596f8 100644
--- a/tobago-core/src/test/resources/renderer/selectManyShuttle/simple.html
+++ b/tobago-core/src/test/resources/renderer/selectManyShuttle/simple.html
@@ -17,7 +17,7 @@
<tobago-select-many-shuttle id='id' class='tobago-auto-spacing'>
<div class='tobago-body'>
-<select class='d-none' id='id::hidden' name='id' multiple='multiple'>
+<select class='d-none tobago-value' id='id::hidden' name='id' multiple='multiple'>
<option value=''>Value 1</option>
<option value=''>Value 2</option></select>
<div class='tobago-unselected-container'>
@@ -29,4 +29,4 @@
<button type='button' class='btn btn-secondary' id='id::remove'><i class='bi-chevron-left'></i></button>
<button type='button' class='btn btn-secondary' id='id::removeAll'><i class='bi-chevron-double-left'></i></button></div></div>
<div class='tobago-selected-container'>
-<select id='id::selected' class='tobago-selected form-select' multiple='multiple' size='2'></select></div></div></tobago-select-many-shuttle>
+<select id='id::selected' data-tobago-order='[]' class='tobago-selected form-select' multiple='multiple' size='2'></select></div></div></tobago-select-many-shuttle>
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/SelectManyShuttleController.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/SelectManyShuttleController.java
index 4e246621db..b6c4fb9675 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/SelectManyShuttleController.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/SelectManyShuttleController.java
@@ -19,12 +19,16 @@
package org.apache.myfaces.tobago.example.demo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.SessionScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import java.io.Serializable;
+import java.lang.invoke.MethodHandles;
import java.util.Arrays;
import java.util.List;
@@ -32,14 +36,16 @@
@Named
public class SelectManyShuttleController implements Serializable {
+ private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
@Inject
private AstroData astroData;
- private List<String> selectedItems;
private List<SolarObject> planets;
private SolarObject[] selectedPlanets = new SolarObject[0];
- private List<String> stars = Arrays.asList("Proxima Centauri", "Alpha Centauri", "Wolf 359", "Sirius");
+ private final List<String> stars = Arrays.asList("Proxima Centauri", "Alpha Centauri", "Wolf 359", "Sirius");
private String[] selectedStars = new String[0];
+ private SolarObject[] orderedItems = new SolarObject[0];
private int countPageReload = 0;
@PostConstruct
@@ -47,14 +53,6 @@ public void init() {
planets = astroData.getSatellites("Sun");
}
- public List<String> getSelectedItems() {
- return selectedItems;
- }
-
- public void setSelectedItems(List<String> selectedItems) {
- this.selectedItems = selectedItems;
- }
-
public List<SolarObject> getPlanets() {
return planets;
}
@@ -87,6 +85,19 @@ public String getSelectedStarsAsString() {
return Arrays.toString(selectedStars);
}
+ public SolarObject[] getOrderedItems() {
+ return orderedItems;
+ }
+
+ public void setOrderedItems(SolarObject[] orderedItems) {
+ LOG.info(orderedItems.length + " items selected: " + Arrays.toString(orderedItems));
+ this.orderedItems = orderedItems;
+ }
+
+ public String getFavoriteAsString() {
+ return Arrays.toString(orderedItems);
+ }
+
public int getCountPageReload() {
return countPageReload++;
}
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectManyShuttle.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/test/SelectManyShuttleOrderableController.java
similarity index 53%
copy from tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectManyShuttle.java
copy to tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/test/SelectManyShuttleOrderableController.java
index 71bbe10a80..ee990f6028 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectManyShuttle.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/test/SelectManyShuttleOrderableController.java
@@ -17,20 +17,33 @@
* under the License.
*/
-package org.apache.myfaces.tobago.internal.component;
+package org.apache.myfaces.tobago.example.demo.test;
-/**
- * {@link org.apache.myfaces.tobago.internal.taglib.component.SelectManyShuttleTagDeclaration}
- */
-public abstract class AbstractUISelectManyShuttle extends AbstractUISelectManyBase {
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import jakarta.enterprise.context.SessionScoped;
+import jakarta.inject.Named;
+import java.io.Serializable;
+import java.lang.invoke.MethodHandles;
+import java.util.List;
+
+@SessionScoped
+@Named
+public class SelectManyShuttleOrderableController implements Serializable {
- public abstract String getSelectedLabel();
+ private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- public abstract String getUnselectedLabel();
+ private List<String> selected;
- public boolean hasLabel() {
- return getSelectedLabel() != null || getUnselectedLabel() != null;
+ public List<String> getSelected() {
+ return selected;
}
- public abstract Integer getSize();
+ public void setSelected(List<String> selected) {
+ LOG.debug("setSelected: {}", selected);
+ this.selected = selected;
+ }
+
+
}
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/030-select/70-selectManyShuttle/Shuttle.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/030-select/70-selectManyShuttle/Shuttle.xhtml
index c921371dbb..0ab53217a1 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/030-select/70-selectManyShuttle/Shuttle.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/030-select/70-selectManyShuttle/Shuttle.xhtml
@@ -132,7 +132,8 @@
<tc:selectItems value="#{selectManyShuttleController.planets}"
var="planet" itemLabel="#{planet.name}" itemValue="#{planet}"/>
</tc:selectManyShuttle>
- <tc:out id="submitExampleOutput" label="Selected Planets" value="#{selectManyShuttleController.selectedPlanetsAsString}"/>
+ <tc:out id="submitExampleOutput" label="Selected Planets"
+ value="#{selectManyShuttleController.selectedPlanetsAsString}"/>
<tc:button id="submitButton" label="Submit"/>
</tc:section>
@@ -142,11 +143,23 @@
<code class="language-markup"><tc:selectManyShuttle .../></code> contain
<code class="language-markup"><f:ajax render="outputStars"/></code>. Every time, the value in the shuttle list
change, the output field is rerendered.</p>
- <tc:selectManyShuttle id="ajaxExample" label="Stars" labelLayout="top" value="#{selectManyShuttleController.selectedStars}">
+ <tc:selectManyShuttle id="ajaxExample" label="Stars" labelLayout="top"
+ value="#{selectManyShuttleController.selectedStars}">
<tc:selectItems value="#{selectManyShuttleController.stars}"/>
<f:ajax render="outputStars"/>
</tc:selectManyShuttle>
<tc:out id="outputStars" label="Selected Stars" value="#{selectManyShuttleController.selectedStarsAsString}"/>
</tc:section>
+ <tc:section label="Orderable Selection">
+ <p>... todo ...</p>
+ <tc:selectManyShuttle id="favoriteExample" orderable="true"
+ value="#{selectManyShuttleController.orderedItems}">
+ <tc:selectItems value="#{selectManyShuttleController.planets}"
+ var="p" itemLabel="#{p.name}" itemValue="#{p}"/>
+ </tc:selectManyShuttle>
+ <tc:out id="favoriteOutput" label="Favorite Planets" value="#{selectManyShuttleController.favoriteAsString}"/>
+ <tc:button label="Submit"/>
+ </tc:section>
+
</ui:composition>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/selectManyShuttle/SelectManyShuttle.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/selectManyShuttle/SelectManyShuttle.xhtml
index 150165a44d..2a06a31d50 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/selectManyShuttle/SelectManyShuttle.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/selectManyShuttle/SelectManyShuttle.xhtml
@@ -21,7 +21,7 @@
xmlns="http://www.w3.org/1999/xhtml"
xmlns:tc="http://myfaces.apache.org/tobago/component"
xmlns:ui="jakarta.faces.facelets">
- <tc:selectManyShuttle id="shuttle">
+ <tc:selectManyShuttle id="shuttle" value="#{selectManyShuttleOrderableController}">
<tc:selectItem itemValue="Item1"/>
<tc:selectItem itemValue="Item2"/>
<tc:selectItem itemValue="Item3"/>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/selectManyShuttle/SelectManyShuttle.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/selectManyShuttle/SelectManyShuttleOrderable.xhtml
similarity index 86%
copy from tobago-example/tobago-example-demo/src/main/webapp/content/900-test/selectManyShuttle/SelectManyShuttle.xhtml
copy to tobago-example/tobago-example-demo/src/main/webapp/content/900-test/selectManyShuttle/SelectManyShuttleOrderable.xhtml
index 150165a44d..157122623d 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/selectManyShuttle/SelectManyShuttle.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/selectManyShuttle/SelectManyShuttleOrderable.xhtml
@@ -21,7 +21,7 @@
xmlns="http://www.w3.org/1999/xhtml"
xmlns:tc="http://myfaces.apache.org/tobago/component"
xmlns:ui="jakarta.faces.facelets">
- <tc:selectManyShuttle id="shuttle">
+ <tc:selectManyShuttle id="shuttle" orderable="true" value="#{selectManyShuttleOrderableController.selected}">
<tc:selectItem itemValue="Item1"/>
<tc:selectItem itemValue="Item2"/>
<tc:selectItem itemValue="Item3"/>
@@ -32,4 +32,9 @@
<tc:selectItem itemValue="Item8"/>
<tc:selectItem itemValue="Item9"/>
</tc:selectManyShuttle>
+
+ <tc:button label="Submit"/>
+
+ <tc:out label="on-server:" value="#{selectManyShuttleOrderableController.selected}"/>
+
</ui:composition>
diff --git a/tobago-example/tobago-example-demo/src/test/typescript/selectManyShuttle.test.ts b/tobago-example/tobago-example-demo/src/test/typescript/selectManyShuttle.test.ts
index 060a53de0d..cd7b132d31 100644
--- a/tobago-example/tobago-example-demo/src/test/typescript/selectManyShuttle.test.ts
+++ b/tobago-example/tobago-example-demo/src/test/typescript/selectManyShuttle.test.ts
@@ -27,6 +27,7 @@ test.describe("900-test/selectManyShuttle/SelectManyShuttle.xhtml", () => {
test("JavaScript 'change' event", async ({page}) => {
const shuttle = page.locator("tobago-select-many-shuttle[id='page:mainForm:shuttle']");
+ await expect(shuttle).toBeVisible();
const unselect = shuttle.locator(".tobago-unselected");
const select = shuttle.locator(".tobago-selected");
const addAll = shuttle.locator("button[id='page:mainForm:shuttle::addAll']");
@@ -58,7 +59,7 @@ test.describe("900-test/selectManyShuttle/SelectManyShuttle.xhtml", () => {
expect(detail.added).toEqual(["Item1", "Item2", "Item3", "Item4", "Item6", "Item7", "Item8", "Item9"]);
expect(detail.removed).toBeNull();
expect(detail.unselected).toEqual([]);
- expect(detail.selected).toEqual(["Item1", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7", "Item8", "Item9"]);
+ expect(detail.selected).toEqual(["Item5", "Item1", "Item2", "Item3", "Item4", "Item6", "Item7", "Item8", "Item9"]);
promise = eventPromise();
await select.selectOption("Item8");
@@ -67,7 +68,7 @@ test.describe("900-test/selectManyShuttle/SelectManyShuttle.xhtml", () => {
expect(detail.added).toBeNull();
expect(detail.removed).toEqual(["Item8"]);
expect(detail.unselected).toEqual(["Item8"]);
- expect(detail.selected).toEqual(["Item1", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7", "Item9"]);
+ expect(detail.selected).toEqual(["Item5", "Item1", "Item2", "Item3", "Item4", "Item6", "Item7", "Item9"]);
promise = eventPromise();
await removeAll.click();
diff --git a/tobago-example/tobago-example-demo/src/test/typescript/selectManyShuttle.test.ts b/tobago-example/tobago-example-demo/src/test/typescript/selectManyShuttleOrderable.test.ts
similarity index 67%
copy from tobago-example/tobago-example-demo/src/test/typescript/selectManyShuttle.test.ts
copy to tobago-example/tobago-example-demo/src/test/typescript/selectManyShuttleOrderable.test.ts
index 060a53de0d..b043a96ca5 100644
--- a/tobago-example/tobago-example-demo/src/test/typescript/selectManyShuttle.test.ts
+++ b/tobago-example/tobago-example-demo/src/test/typescript/selectManyShuttleOrderable.test.ts
@@ -19,20 +19,25 @@
import {expect, test} from "@playwright/test";
-test.describe("900-test/selectManyShuttle/SelectManyShuttle.xhtml", () => {
+test.describe("900-test/selectManyShuttle/SelectManyShuttleOrderable.xhtml", () => {
test.beforeEach(async ({page}, testInfo) => {
- await page.goto("/content/900-test/selectManyShuttle/SelectManyShuttle.xhtml");
+ await page.goto("/content/900-test/selectManyShuttle/SelectManyShuttleOrderable.xhtml");
});
test("JavaScript 'change' event", async ({page}) => {
const shuttle = page.locator("tobago-select-many-shuttle[id='page:mainForm:shuttle']");
+ await expect(shuttle).toBeVisible();
const unselect = shuttle.locator(".tobago-unselected");
const select = shuttle.locator(".tobago-selected");
const addAll = shuttle.locator("button[id='page:mainForm:shuttle::addAll']");
const add = shuttle.locator("button[id='page:mainForm:shuttle::add']");
const remove = shuttle.locator("button[id='page:mainForm:shuttle::remove']");
const removeAll = shuttle.locator("button[id='page:mainForm:shuttle::removeAll']");
+ const top = shuttle.locator("button[id='page:mainForm:shuttle::top']");
+ const up = shuttle.locator("button[id='page:mainForm:shuttle::up']");
+ const down = shuttle.locator("button[id='page:mainForm:shuttle::down']");
+ const bottom = shuttle.locator("button[id='page:mainForm:shuttle::bottom']");
const eventPromise = () => page.evaluate(() => {
return new Promise(resolve => {
@@ -44,37 +49,20 @@ test.describe("900-test/selectManyShuttle/SelectManyShuttle.xhtml", () => {
}) as Promise<any>;
let promise = eventPromise();
- await unselect.selectOption("Item5");
- await add.click();
- let detail = await promise;
- expect(detail.added).toEqual(["Item5"]);
- expect(detail.removed).toBeNull();
- expect(detail.unselected).toEqual(["Item1", "Item2", "Item3", "Item4", "Item6", "Item7", "Item8", "Item9"]);
- expect(detail.selected).toEqual(["Item5"]);
-
- promise = eventPromise();
await addAll.click();
- detail = await promise;
- expect(detail.added).toEqual(["Item1", "Item2", "Item3", "Item4", "Item6", "Item7", "Item8", "Item9"]);
+ let detail = await promise;
+ expect(detail.added).toEqual(["Item1", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7", "Item8", "Item9"]);
expect(detail.removed).toBeNull();
expect(detail.unselected).toEqual([]);
expect(detail.selected).toEqual(["Item1", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7", "Item8", "Item9"]);
promise = eventPromise();
- await select.selectOption("Item8");
- await remove.click();
+ await top.click();
detail = await promise;
- expect(detail.added).toBeNull();
- expect(detail.removed).toEqual(["Item8"]);
- expect(detail.unselected).toEqual(["Item8"]);
- expect(detail.selected).toEqual(["Item1", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7", "Item9"]);
+ expect(detail.added).toEqual([]);
+ expect(detail.removed).toBeNull();
+ expect(detail.unselected).toEqual([]);
+ expect(detail.selected).toEqual(["Item5", "Item1", "Item2", "Item3", "Item4", "Item6", "Item7", "Item8", "Item9"]);
- promise = eventPromise();
- await removeAll.click();
- detail = await promise;
- expect(detail.added).toBeNull();
- expect(detail.removed).toEqual(["Item5", "Item1", "Item2", "Item3", "Item4", "Item6", "Item7", "Item9"]);
- expect(detail.unselected).toEqual(["Item1", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7", "Item8", "Item9"]);
- expect(detail.selected).toEqual([]);
});
});
diff --git a/tobago-theme/src/main/scss/_tobago.scss b/tobago-theme/src/main/scss/_tobago.scss
index 2211b07074..f447a6d751 100644
--- a/tobago-theme/src/main/scss/_tobago.scss
+++ b/tobago-theme/src/main/scss/_tobago.scss
@@ -1983,6 +1983,10 @@ tobago-tree-listbox {
tobago-scroll {
}
+/* value --------------------------------------------------------- */
+.tobago-value {
+}
+
/* config --------------------------------------------------------- */
tobago-config {
display: none;
diff --git a/tobago-theme/tobago-theme-charlotteville/src/main/css/tobago.css.map b/tobago-theme/tobago-theme-charlotteville/src/main/css/tobago.css.map
index 2348038619..6474db297e 100644
--- a/tobago-theme/tobago-theme-charlotteville/src/main/css/tobago.css.map
+++ b/tobago-theme/tobago-theme-charlotteville/src/main/css/tobago.css.map
@@ -1 +1 @@
-{"version":3,"mappings":";;;;;;;;;;;;;;;;AAgDA;;;;AAGA;;;;AAIA;;;;;AAIA;;;;;AAIA;;;;AAGA;;;;;AAKA;;;;AAIA;;;;AAIA;;;;;AAIA;;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAgBA;;;;AAIA;;;;AAGA;;;;AAIA;;;;;AAQA;;;;;;;;;;AASA;;;;AAKA;;;;AAKA;;;;AAGA;;;;AAIA;;;;;AAKA;;;;;AAMA;;;;;AAOA;;;;AAAA;;;;AAAA;;;;AAIA;;;;;AAMA;;;;;AAKA;;;;AAIA;;;;AAKA;;;;;;AAKA;;;;AAIA;;;;;;;AAOA;;;;;AAKA;;;;;;AAMA;;;;;;AASA;;;;;;AAWA;;;;;AAKA;;;;AAGA;;;;AAIA;;;;;;;AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; [...]
\ No newline at end of file
+{"version":3,"mappings":";;;;;;;;;;;;;;;;AAgDA;;;;AAGA;;;;AAIA;;;;;AAIA;;;;;AAIA;;;;AAGA;;;;;AAKA;;;;AAIA;;;;AAIA;;;;;AAIA;;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAgBA;;;;AAIA;;;;AAGA;;;;AAIA;;;;;AAQA;;;;;;;;;;AASA;;;;AAKA;;;;AAKA;;;;AAGA;;;;AAIA;;;;;AAKA;;;;;AAMA;;;;;AAOA;;;;AAAA;;;;AAAA;;;;AAIA;;;;;AAMA;;;;;AAKA;;;;AAIA;;;;AAKA;;;;;;AAKA;;;;AAIA;;;;;;;AAOA;;;;;AAKA;;;;;;AAMA;;;;;;AASA;;;;;;AAWA;;;;;AAKA;;;;AAGA;;;;AAIA;;;;;;;AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; [...]
\ No newline at end of file
diff --git a/tobago-theme/tobago-theme-roxborough/src/main/css/tobago.css.map b/tobago-theme/tobago-theme-roxborough/src/main/css/tobago.css.map
index 0d14b1b29b..01214d8fb4 100644
--- a/tobago-theme/tobago-theme-roxborough/src/main/css/tobago.css.map
+++ b/tobago-theme/tobago-theme-roxborough/src/main/css/tobago.css.map
@@ -1 +1 @@
-{"version":3,"mappings":";;;;;;;;;;;;;;;;AAgCA;;;;;;;AAMA;;;;;;;AAMA;;;;;;AAKA;;;;;;;AAMA;;;;AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyHA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA;;;;AAMA;EACE;;;;;AAKF;;;;;;;;;;;;;AAaA;;;;;;;;AAQA;;;;;;;;AAQA;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAIA;;;;AAIA;;;;;AAKA;;;;;;;;AAMA;;;;;;AAMA;;;;AAKA; [...]
\ No newline at end of file
+{"version":3,"mappings":";;;;;;;;;;;;;;;;AAgCA;;;;;;;AAMA;;;;;;;AAMA;;;;;;AAKA;;;;;;;AAMA;;;;AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyHA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA;;;;AAMA;EACE;;;;;AAKF;;;;;;;;;;;;;AAaA;;;;;;;;AAQA;;;;;;;;AAQA;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAIA;;;;AAIA;;;;;AAKA;;;;;;;;AAMA;;;;;;AAMA;;;;AAKA; [...]
\ No newline at end of file
diff --git a/tobago-theme/tobago-theme-scarborough/src/main/css/tobago.css.map b/tobago-theme/tobago-theme-scarborough/src/main/css/tobago.css.map
index 619e84ff82..2b341f1fa2 100644
--- a/tobago-theme/tobago-theme-scarborough/src/main/css/tobago.css.map
+++ b/tobago-theme/tobago-theme-scarborough/src/main/css/tobago.css.map
@@ -1 +1 @@
-{"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyHA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA;;;;AAMA;EACE;;;;;AAKF;;;;;;;;;;;;;AAaA;;;;;;;;AAQA;;;;;;;;AAQA;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAIA;;;;AAIA;;;;;AAKA;;;;;;;;AAMA;;;;;;AAMA;;;;AAKA;;;;;AAOA;;;;AAOA;;;;AAIA;;;; [...]
\ No newline at end of file
+{"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyHA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA;;;;AAMA;EACE;;;;;AAKF;;;;;;;;;;;;;AAaA;;;;;;;;AAQA;;;;;;;;AAQA;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAIA;;;;AAIA;;;;;AAKA;;;;;;;;AAMA;;;;;;AAMA;;;;AAKA;;;;;AAOA;;;;AAOA;;;;AAIA;;;; [...]
\ No newline at end of file
diff --git a/tobago-theme/tobago-theme-speyside/src/main/css/tobago.css.map b/tobago-theme/tobago-theme-speyside/src/main/css/tobago.css.map
index 4e7ecbf79d..1973f10bf2 100644
--- a/tobago-theme/tobago-theme-speyside/src/main/css/tobago.css.map
+++ b/tobago-theme/tobago-theme-speyside/src/main/css/tobago.css.map
@@ -1 +1 @@
-{"version":3,"mappings":";;;;;;;;;;;;;;;;AAqCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2HA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA;;;;AAMA;;;;AAGA;EACE;;;;;AAKF;;;;;;;;;;;;;AAaA;;;;;;;;AAQA;;;;;;;;AAQA;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAIA;;;;AAQA;;;;;AAKA;;;;;;;;AAMA;;;;;;AAMA;;;;AAKA;;;;;AAOA;;;;AAOA;;;;AAIA;;;;;AAKA;;;;AAIA;;;;AAKA;;;;AAIA;;;;;; [...]
\ No newline at end of file
+{"version":3,"mappings":";;;;;;;;;;;;;;;;AAqCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2HA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA;;;;AAMA;;;;AAGA;EACE;;;;;AAKF;;;;;;;;;;;;;AAaA;;;;;;;;AAQA;;;;;;;;AAQA;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAIA;;;;AAQA;;;;;AAKA;;;;;;;;AAMA;;;;;;AAMA;;;;AAKA;;;;;AAOA;;;;AAOA;;;;AAIA;;;;;AAKA;;;;AAIA;;;;AAKA;;;;AAIA;;;;;; [...]
\ No newline at end of file
diff --git a/tobago-theme/tobago-theme-standard/src/main/css/tobago.css.map b/tobago-theme/tobago-theme-standard/src/main/css/tobago.css.map
index e3ad06162d..d6f1bc4481 100644
--- a/tobago-theme/tobago-theme-standard/src/main/css/tobago.css.map
+++ b/tobago-theme/tobago-theme-standard/src/main/css/tobago.css.map
@@ -1 +1 @@
-{"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyHA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA;;;;AAMA;EACE;;;;;AAKF;;;;;;;;;;;;;AAaA;;;;;;;;AAQA;;;;;;;;AAQA;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAIA;;;;AAIA;;;;;AAKA;;;;;;;;AAMA;;;;;;AAMA;;;;AAKA;;;;;AAOA;;;;AAOA;;;;AAIA;;;;;AAKA;;;;AAIA;;;;A [...]
\ No newline at end of file
+{"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyHA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA;;;;AAMA;EACE;;;;;AAKF;;;;;;;;;;;;;AAaA;;;;;;;;AAQA;;;;;;;;AAQA;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAGA;EACE;;;;;AAKF;;;;AAIA;;;;AAIA;;;;;AAKA;;;;;;;;AAMA;;;;;;AAMA;;;;AAKA;;;;;AAOA;;;;AAOA;;;;AAIA;;;;;AAKA;;;;AAIA;;;;A [...]
\ No newline at end of file
diff --git a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js
index fd9c0cd8ef..8d10d80f37 100644
--- a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js
+++ b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js
@@ -2,19 +2,19 @@
/*!
* tabbable 6.4.0
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
- */var u=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:n [...]
+ */var u=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:n [...]
/*!
* Bootstrap v5.3.8 (https://getbootstrap.com/)
* Copyright 2011-2025 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
-const wt=new Map,Et={set(e,t,s){wt.has(e)||wt.set(e,new Map);const i=wt.get(e);i.has(t)||0===i.size?i.set(t,s):console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(i.keys())[0]}.`)},get:(e,t)=>wt.has(e)&&wt.get(e).get(t)||null,remove(e,t){if(!wt.has(e))return;const s=wt.get(e);s.delete(t),0===s.size&&wt.delete(e)}},_t="transitionend",St=e=>(e&&window.CSS&&window.CSS.escape&&(e=e.replace(/#([^\s"#']+)/g,(e,t)=>`#${CSS.escape(t)}`)),e),At= [...]
+const wt=new Map,Et={set(e,t,s){wt.has(e)||wt.set(e,new Map);const i=wt.get(e);i.has(t)||0===i.size?i.set(t,s):console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(i.keys())[0]}.`)},get:(e,t)=>wt.has(e)&&wt.get(e).get(t)||null,remove(e,t){if(!wt.has(e))return;const s=wt.get(e);s.delete(t),0===s.size&&wt.delete(e)}},_t="transitionend",St=e=>(e&&window.CSS&&window.CSS.escape&&(e=e.replace(/#([^\s"#']+)/g,(e,t)=>`#${CSS.escape(t)}`)),e),At= [...]
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
-const Lr=globalThis,Cr=e=>e,Ir=Lr.trustedTypes,Nr=Ir?Ir.createPolicy("lit-html",{createHTML:e=>e}):void 0,kr="$lit$",Mr=`lit$${Math.random().toFixed(9).slice(2)}$`,Dr="?"+Mr,Rr=`<${Dr}>`,Pr=document,$r=()=>Pr.createComment(""),Br=e=>null===e||"object"!=typeof e&&"function"!=typeof e,Hr=Array.isArray,Fr="[ \t\n\f\r]",qr=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Wr=/-->/g,jr=/>/g,zr=RegExp(`>|${Fr}(?:([^\\s"'>=/]+)(${Fr}*=${Fr}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Gr=/'/g,U [...]
+const Lr=globalThis,Cr=e=>e,Ir=Lr.trustedTypes,Nr=Ir?Ir.createPolicy("lit-html",{createHTML:e=>e}):void 0,kr="$lit$",Mr=`lit$${Math.random().toFixed(9).slice(2)}$`,Dr="?"+Mr,Rr=`<${Dr}>`,Pr=document,$r=()=>Pr.createComment(""),Br=e=>null===e||"object"!=typeof e&&"function"!=typeof e,Hr=Array.isArray,Fr="[ \t\n\f\r]",qr=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Wr=/-->/g,jr=/>/g,zr=RegExp(`>|${Fr}(?:([^\\s"'>=/]+)(${Fr}*=${Fr}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Gr=/'/g,U [...]
${this.iconTemplate(t)}${e}</tobago-badge>`:Yr`<tobago-badge class="badge text-bg-primary btn">
${this.iconTemplate(t)}${e}</tobago-badge>
<button type='button'
@@ -22,5 +22,5 @@ const Lr=globalThis,Cr=e=>e,Ir=Lr.trustedTypes,Nr=Ir?Ir.createPolicy("lit-html",
${i>0?" tabindex='"+String(i)+"'":""}
@click="${this.removeBadge.bind(this)}"
@focus="${this.focusEvent.bind(this)}"
- @blur="${this.blurEvent.bind(this)}"><i class='bi-x-lg'></i></button>`}removeBadge(e){const t=e.target.closest(".btn-group").dataset.tobagoValue,s=this.hiddenSelect.querySelector(`[value="${t}"]`);s.selected=!1;const i=this.badges.querySelector(`[data-tobago-value="${t}"]`),n=this.getPreviousEnabledBadge(i),o=this.getNextEnabledBadge(i);n?n.querySelector("button.btn.badge").focus():o?o.querySelector("button.btn.badge").focus():(this.filterInput.disabled=!1,this.filterInput.focus()) [...]
+ @blur="${this.blurEvent.bind(this)}"><i class='bi-x-lg'></i></button>`}removeBadge(e){const t=e.target.closest(".btn-group").dataset.tobagoValue,s=this.hiddenSelect.querySelector(`[value="${t}"]`);s.selected=!1;const i=this.badges.querySelector(`[data-tobago-value="${t}"]`),n=this.getPreviousEnabledBadge(i),o=this.getNextEnabledBadge(i);n?n.querySelector("button.btn.badge").focus():o?o.querySelector("button.btn.badge").focus():(this.filterInput.disabled=!1,this.filterInput.focus()) [...]
//# sourceMappingURL=tobago.js.map
diff --git a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map
index fe5f042c9e..d473748927 100644
--- a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map
+++ b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map
@@ -1 +1 @@
-{"version":3,"file":"tobago.js","sources":["../ts/tobago-css.ts","../ts/tobago-key.ts","../ts/tobago-client-behaviors.ts","../ts/tobago-dropdown-menu.ts","../ts/ts/util/EventListenerStore.ts","../ts/tobago-bar.ts","../ts/tobago-date.ts","../ts/tobago-dropdown-item-factory.ts","../ts/tobago-dropdown-item.ts","../ts/ts/dropdown/DropdownMenuStatic.ts","../../../../node_modules/tabbable/dist/index.esm.js","../ts/tobago-dropdown.ts","../ts/tobago-overlay-type.ts","../ts/tobago-suggest-filter. [...]
\ No newline at end of file
+{"version":3,"file":"tobago.js","sources":["../ts/tobago-css.ts","../ts/tobago-key.ts","../ts/tobago-client-behaviors.ts","../ts/tobago-dropdown-menu.ts","../ts/ts/util/EventListenerStore.ts","../ts/tobago-bar.ts","../ts/tobago-date.ts","../ts/tobago-dropdown-item-factory.ts","../ts/tobago-dropdown-item.ts","../ts/ts/dropdown/DropdownMenuStatic.ts","../../../../node_modules/tabbable/dist/index.esm.js","../ts/tobago-dropdown.ts","../ts/tobago-overlay-type.ts","../ts/tobago-suggest-filter. [...]
\ No newline at end of file
diff --git a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-many-shuttle.ts b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-many-shuttle.ts
index 898085c53d..70b6120f9c 100644
--- a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-many-shuttle.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-many-shuttle.ts
@@ -32,17 +32,26 @@ class SelectManyShuttle extends HTMLElement {
connectedCallback(): void {
+ const tobagoOrder = JSON.parse(this.selectedSelect.dataset.tobagoOrder) as number[];
+
const options = this.hiddenSelect.options;
+
+ for (let i = 0; i < options.length; i++) {
+ options[i].dataset.tobagoIndex = "" + i;
+ }
+
+ for (const i of tobagoOrder.reverse()) {
+ const option= this.hiddenSelect.querySelector(`[data-tobago-index="${i}"]`);
+ this.hiddenSelect.insertBefore(option, this.hiddenSelect.firstChild);
+ }
+
for (let i = 0; i < options.length; i++) {
- const option: HTMLOptionElement = options[i];
+ const option: HTMLOptionElement = options.item(i);
const clone = option.cloneNode(true) as HTMLOptionElement;
- clone.dataset.tobagoIndex = "" + i;
if (clone.selected) {
- // console.info("adding selected: " + i);
- this.selectedSelect.add(clone);
clone.selected = false; // unselect, because it's in the selected list
+ this.selectedSelect.add(clone);
} else {
- // console.info("adding unselected: " + i);
this.unselectedSelect.add(clone);
}
}
@@ -80,6 +89,22 @@ class SelectManyShuttle extends HTMLElement {
if (!this.removeAllButton.disabled) {
this.removeAllButton.addEventListener("click", this.removeAllItems.bind(this));
}
+
+ if (this.topButton && !this.topButton.disabled) {
+ this.topButton.addEventListener("click", this.top.bind(this));
+ }
+
+ if (this.upButton && !this.upButton.disabled) {
+ this.upButton.addEventListener("click", this.up.bind(this));
+ }
+
+ if (this.downButton && !this.downButton.disabled) {
+ this.downButton.addEventListener("click", this.down.bind(this));
+ }
+
+ if (this.bottomButton && !this.bottomButton.disabled) {
+ this.bottomButton.addEventListener("click", this.bottom.bind(this));
+ }
}
private addAllItems(event: MouseEvent): void {
@@ -98,39 +123,132 @@ class SelectManyShuttle extends HTMLElement {
this.removeItems(this.selectedSelect.querySelectorAll("option:not(:disabled)"));
}
+ private top(event: MouseEvent): void {
+
+ const select = this.selectedSelect as HTMLSelectElement;
+ const options = select.options;
+ const hidden = this.hiddenSelect as HTMLSelectElement;
+
+ const firstUnselected: HTMLOptionElement = select.querySelector("option:not(:checked)");
+ if (firstUnselected == null) {
+ return; // noting to do
+ }
+
+ Array.from(select.querySelectorAll("option:checked")).forEach((current: HTMLOptionElement) => {
+ this.syncedInsertBefore(select, hidden, current, firstUnselected);
+ });
+ }
+
+ private up(event: MouseEvent): void {
+
+ const select = this.selectedSelect as HTMLSelectElement;
+ const options = select.options;
+ const hidden = this.hiddenSelect as HTMLSelectElement;
+
+ for (let i = 1; i < options.length; i++) {
+ const previous = options.item(i - 1)!;
+ const current = options.item(i);
+
+ if (current.selected && !previous.selected) {
+ this.syncedInsertBefore(select, hidden, current, previous);
+ }
+ }
+ }
+
+ private down(event: MouseEvent): void {
+
+ const select = this.selectedSelect as HTMLSelectElement;
+ const options = select.options;
+ const hidden = this.hiddenSelect as HTMLSelectElement;
+
+ for (let i = options.length - 2; i >= 0 ; i--) {
+ const current = options.item(i);
+ const next = options.item(i + 1)!;
+
+ if (current.selected && !next.selected) {
+ this.syncedInsertBefore(select, hidden, next, current);
+ }
+ }
+ }
+
+ private bottom(event: MouseEvent): void {
+
+ const select = this.selectedSelect as HTMLSelectElement;
+ const options = select.options;
+ const hidden = this.hiddenSelect as HTMLSelectElement;
+
+ const allUnselected: NodeListOf<HTMLOptionElement> = select.querySelectorAll("option:not(:checked)");
+ const lastUnselected: HTMLOptionElement = allUnselected[allUnselected.length - 1];
+ if (lastUnselected == null) {
+ return; // noting to do
+ }
+
+ Array.from(select.querySelectorAll("option:checked")).reverse().forEach((current: HTMLOptionElement) => {
+ this.syncedInsertAfter(select, hidden, current, lastUnselected);
+ });
+ }
+
+ private syncedInsertBefore(
+ parent: HTMLSelectElement, hidden: HTMLSelectElement, a: HTMLOptionElement, b: HTMLOptionElement) {
+ parent.insertBefore(a, b);
+ const hiddenA = hidden.querySelector(`option[value='${a.value}']`);
+ const hiddenB = hidden.querySelector(`option[value='${b.value}']`);
+ hidden.insertBefore(hiddenA, hiddenB);
+ }
+
+ private syncedInsertAfter(
+ parent: HTMLSelectElement, hidden: HTMLSelectElement, a: HTMLOptionElement, b: HTMLOptionElement) {
+ b.after(a);
+ const hiddenA = hidden.querySelector(`option[value='${a.value}']`);
+ const hiddenB = hidden.querySelector(`option[value='${b.value}']`);
+ hiddenB.after(hiddenA);
+ }
+
private addItems(options: NodeListOf<HTMLOptionElement>): void {
+ const hiddenSelect = this.hiddenSelect;
for (const option of options) {
this.selectedSelect.add(option);
- this.changeHiddenOption(option, true);
+ this.changeHiddenOption(hiddenSelect, option, true);
}
this.fireChangeEvent(options, null);
}
private removeItems(options: NodeListOf<HTMLOptionElement>): void {
+ const hiddenSelect = this.hiddenSelect;
for (const option of options) {
const index = Number(option.dataset.tobagoIndex);
let nextOption: HTMLOptionElement = null;
for (const option of this.unselectedSelect.options) {
- // console.info("checking: " + option.dataset.tobagoIndex + " > " + index);
if (Number(option.dataset.tobagoIndex) > index) {
nextOption = option;
break;
}
}
- console.info("removing: " + index + " -> " + nextOption?.dataset.tobagoIndex + " (" + nextOption?.value + ")");
if (nextOption != null) {
this.unselectedSelect.add(option, nextOption);
} else {
this.unselectedSelect.appendChild(option);
}
- this.changeHiddenOption(option, false);
+ this.changeHiddenOption(hiddenSelect, option, false);
}
this.fireChangeEvent(null, options);
}
- private changeHiddenOption(option: HTMLOptionElement, select: boolean): void {
- const hiddenOption: HTMLOptionElement = this.hiddenSelect.querySelector(`option[value='${option.value}']`);
- hiddenOption.selected = select;
+ private changeHiddenOption(hiddenSelect: HTMLSelectElement, option: HTMLOptionElement, selected: boolean) {
+ const hiddenOption: HTMLOptionElement = hiddenSelect.querySelector(`option[value='${option.value}']`);
+ const firstUnselectedHiddenOption: HTMLOptionElement = hiddenSelect.querySelector("option:not(:checked)");
+ if (selected) {
+ hiddenSelect.insertBefore(hiddenOption, firstUnselectedHiddenOption);
+ } else {
+ const index = Number(hiddenOption.dataset.tobagoIndex);
+ const after = hiddenSelect.querySelector(`option[data-tobago-index="${index + 1}"]`);
+ if (after) {
+ hiddenSelect.insertBefore(hiddenOption, after);
+ } else {
+ hiddenSelect.appendChild(hiddenOption);
+ }
+ }
+ hiddenOption.selected = selected;
}
private fireChangeEvent(added: NodeListOf<HTMLOptionElement>, removed: NodeListOf<HTMLOptionElement>): void {
@@ -157,7 +275,7 @@ class SelectManyShuttle extends HTMLElement {
}
get hiddenSelect(): HTMLSelectElement {
- return this.querySelector("select.d-none");
+ return this.querySelector(".tobago-value");
}
get addAllButton(): HTMLButtonElement {
@@ -175,6 +293,23 @@ class SelectManyShuttle extends HTMLElement {
get removeAllButton(): HTMLButtonElement {
return this.querySelector(".btn-group-vertical button:nth-child(4)");
}
+
+ get topButton(): HTMLButtonElement {
+ return this.querySelector("[data-tobago-action=top]");
+ }
+
+ get upButton(): HTMLButtonElement {
+ return this.querySelector("[data-tobago-action=up]");
+ }
+
+ get downButton(): HTMLButtonElement {
+ return this.querySelector("[data-tobago-action=down]");
+ }
+
+ get bottomButton(): HTMLButtonElement {
+ return this.querySelector("[data-tobago-action=bottom]");
+ }
+
}
document.addEventListener("tobago.init", function (event: Event): void {