Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions js/modules/Forms/EditorController.js
Original file line number Diff line number Diff line change
Expand Up @@ -1279,26 +1279,37 @@ export class GlpiFormEditorController
const elementsWithConditions = [];

// Process form elements (questions and sections)
const already_reported_items = [];
conditionsUsingItem.each((_index, element) => {
// Check if condition is in a question
const parentItem = $(element).closest('[data-glpi-form-editor-block]');
if (parentItem.length > 0) {
const uuid = this.#getItemInput(parentItem, "uuid");
if (already_reported_items.indexOf(uuid) != -1) {
return;
}
elementsWithConditions.push({
name: this.#getItemInput(parentItem, "name"),
uuid: this.#getItemInput(parentItem, "uuid"),
uuid: uuid,
type: 'question',
element: parentItem
});
already_reported_items.push(uuid);
} else {
// Check if condition is in a section
const parentSection = $(element).closest('[data-glpi-form-editor-section]');
if (parentSection.length > 0) {
const uuid = this.#getItemInput(parentSection, "uuid");
if (already_reported_items.indexOf(uuid) != -1) {
return;
}
elementsWithConditions.push({
name: this.#getItemInput(parentSection, "name"),
uuid: this.#getItemInput(parentSection, "uuid"),
uuid: uuid,
type: 'section',
element: parentSection
});
already_reported_items.push(uuid);
}
}
});
Expand Down
10 changes: 10 additions & 0 deletions tests/cypress/e2e/form/editor/conditions.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2524,6 +2524,8 @@ describe ('Conditions', () => {
initVisibilityConfiguration();
setConditionStrategy('Visible if...');
fillCondition(0, null, 'My first question', 'Contains', 'GLPI is great');
addNewEmptyCondition();
fillCondition(1, null, 'My first question', 'Contains', 'GLPI is great');
});
saveAndReload();

Expand All @@ -2549,6 +2551,13 @@ describe ('Conditions', () => {
'Contains',
'GLPI is great',
);
checkThatConditionExist(
1,
null,
'Questions - My first question',
'Contains',
'GLPI is great',
);
});

// Delete the first question and check that the conditions are still there
Expand All @@ -2567,6 +2576,7 @@ describe ('Conditions', () => {
getAndFocusQuestion('My second question').within(() => {
openConditionEditor();
deleteCondition(0);
deleteCondition(1);
});

// Delete the first question
Expand Down
Loading