Skip to content

Commit dd358db

Browse files
ccaillycedric-anne
authored andcommitted
fix(forms): ensure question or comment can be moved between sections
1 parent f75f412 commit dd358db

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

js/modules/Forms/EditorController.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,28 +2044,38 @@ export class GlpiFormEditorController
20442044
*/
20452045
#enableSortable(sections) {
20462046
// 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]");
20512050

2052-
sortable(blocks_container, {
2051+
blocks_container.each((index, container) => {
2052+
const $container = $(container);
2053+
2054+
// Common sortable configuration
2055+
const sortableConfig = {
20532056
// Drag and drop handle selector
20542057
handle: '[data-glpi-form-editor-question-handle]',
20552058

20562059
// Restrict sortable items
20572060
items: '[data-glpi-form-editor-block], [data-glpi-form-editor-horizontal-block-placeholder]',
20582061

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-
20622062
// Accept from others sections
20632063
acceptFrom: '[data-glpi-form-editor-section-blocks], [data-glpi-form-editor-horizontal-blocks]',
20642064

20652065
// Placeholder class
20662066
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);
20682077
});
2078+
});
20692079

20702080
// Keep track on unsaved changes if the sort order was updated
20712081
sections

0 commit comments

Comments
 (0)