@@ -2044,28 +2044,38 @@ export class GlpiFormEditorController
2044
2044
*/
2045
2045
#enableSortable( sections ) {
2046
2046
// Sortable instance must be unique for each section
2047
- sections
2048
- . each ( ( index , section ) => {
2049
- const blocks_container = $ ( section )
2050
- . find ( "[data-glpi-form-editor-section-blocks], [data-glpi-form-editor-horizontal-blocks], [data-glpi-form-editor-question-drag-merge], [data-glpi-form-editor-horizontal-block-placeholder]" ) ;
2047
+ sections . each ( ( index , section ) => {
2048
+ const blocks_container = $ ( section )
2049
+ . find ( "[data-glpi-form-editor-section-blocks], [data-glpi-form-editor-horizontal-blocks], [data-glpi-form-editor-question-drag-merge], [data-glpi-form-editor-horizontal-block-placeholder]" ) ;
2051
2050
2052
- sortable ( blocks_container , {
2051
+ blocks_container . each ( ( index , container ) => {
2052
+ const $container = $ ( container ) ;
2053
+
2054
+ // Common sortable configuration
2055
+ const sortableConfig = {
2053
2056
// Drag and drop handle selector
2054
2057
handle : '[data-glpi-form-editor-question-handle]' ,
2055
2058
2056
2059
// Restrict sortable items
2057
2060
items : '[data-glpi-form-editor-block], [data-glpi-form-editor-horizontal-block-placeholder]' ,
2058
2061
2059
- // Limit the number of blocks in horizontal blocks
2060
- maxItems : blocks_container . attr ( "data-glpi-form-editor-horizontal-blocks" ) !== typeof undefined ? 4 : 0 ,
2061
-
2062
2062
// Accept from others sections
2063
2063
acceptFrom : '[data-glpi-form-editor-section-blocks], [data-glpi-form-editor-horizontal-blocks]' ,
2064
2064
2065
2065
// Placeholder class
2066
2066
placeholder : '<section class="glpi-form-editor-drag-question-placeholder"></section>' ,
2067
- } ) ;
2067
+ } ;
2068
+
2069
+
2070
+ // Add specific configuration based on container type
2071
+ if ( $container . is ( "[data-glpi-form-editor-horizontal-blocks]" ) ) {
2072
+ sortableConfig . maxItems = 4 ; // Limit the number of blocks in horizontal blocks
2073
+ }
2074
+
2075
+ // Initialize sortable with the configuration
2076
+ sortable ( $container , sortableConfig ) ;
2068
2077
} ) ;
2078
+ } ) ;
2069
2079
2070
2080
// Keep track on unsaved changes if the sort order was updated
2071
2081
sections
0 commit comments