File tree Expand file tree Collapse file tree 3 files changed +57
-5
lines changed
main/java/io/jenkins/plugins/datatables
test/java/io/jenkins/plugins/datatables Expand file tree Collapse file tree 3 files changed +57
-5
lines changed Original file line number Diff line number Diff line change 66import com .fasterxml .jackson .core .JsonProcessingException ;
77import com .fasterxml .jackson .databind .ObjectMapper ;
88import com .fasterxml .jackson .databind .annotation .JsonSerialize ;
9+ import io .jenkins .plugins .datatables .options .SelectStyle ;
910
1011/**
1112 * Provides a configuration for the whole DataTable. This is merged with a default configuration in table.js.
@@ -105,15 +106,15 @@ public boolean isUseButtons() {
105106 /**
106107 * Enable selection.
107108 *
108- * @param selectionStyle
109- * The <a href="https://datatables.net/reference/option/select.style">select.style</a> option
109+ * @param selectStyle
110+ * The {@link SelectStyle selection style}
110111 *
111112 * @return this {@link TableConfiguration} for chaining methods
112113 *
113114 * @see <a href="https://datatables.net/reference/option/select">https://datatables.net/reference/option/select</a>
114115 */
115- public TableConfiguration select (final String selectionStyle ) {
116- configuration .put ("select" , selectionStyle );
116+ public TableConfiguration select (final SelectStyle selectStyle ) {
117+ configuration .put ("select" , selectStyle . getStyle () );
117118 useSelect = true ;
118119 return this ;
119120 }
Original file line number Diff line number Diff line change 1+ package io .jenkins .plugins .datatables .options ;
2+
3+ /**
4+ * The possible values of the <a href="https://datatables.net/reference/option/select.style">select.style</a> option,
5+ * which is used for enabling the selection for datatables and setting its style (the default is {@link #OS}.
6+ *
7+ * @author Florian Orendi
8+ */
9+ public enum SelectStyle {
10+
11+ /**
12+ * Selection can only be performed via the API.
13+ */
14+ API ("api" ),
15+
16+ /**
17+ * Only a single item can be selected, any other selected items will be automatically
18+ * deselected when a new item is selected.
19+ */
20+ SINGLE ("single" ),
21+
22+ /**
23+ * Multiple items can be selected. Selection is performed by simply clicking on the items to be selected.
24+ */
25+ MULTI ("multi" ),
26+
27+ /**
28+ * Operating System (OS) style selection.
29+ * This is the most comprehensive option and provides complex behaviours such as ctrl/cmd clicking
30+ * to select / deselect individual items, shift clicking to select ranges
31+ * and an unmodified click to select a single item.
32+ */
33+ OS ("os" ),
34+
35+ /**
36+ * A hybrid between the {@link #OS} style and {@link #MULTI},
37+ * allowing easy multi-row selection without immediate de-selection when clicking on a row.
38+ */
39+ MULTI_SHIFT ("multi+shift" );
40+
41+ private final String style ;
42+
43+ SelectStyle (final String style ) {
44+ this .style = style ;
45+ }
46+
47+ public String getStyle () {
48+ return style ;
49+ }
50+ }
Original file line number Diff line number Diff line change 11package io .jenkins .plugins .datatables ;
22
3+ import io .jenkins .plugins .datatables .options .SelectStyle ;
34import org .junit .jupiter .api .Test ;
45
56import static io .jenkins .plugins .datatables .TableConfigurationAssert .*;
@@ -34,7 +35,7 @@ void shouldCreateResponsiveConfiguration() {
3435
3536 @ Test
3637 void shouldCreateSelectConfiguration () {
37- TableConfiguration configuration = new TableConfiguration ().select ("single" );
38+ TableConfiguration configuration = new TableConfiguration ().select (SelectStyle . SINGLE );
3839
3940 assertThat (configuration ).hasConfiguration ("{\" select\" :\" single\" }" );
4041 assertThat (configuration ).isNotUseButtons ();
You can’t perform that action at this time.
0 commit comments