-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(forms): prevent form elements deletion when they are used by conditions #19219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(forms): prevent form elements deletion when they are used by conditions #19219
Conversation
c24e35b
to
4e576b8
Compare
… openConditionEditor in e2e tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, can you also take into account the form destinations conditions ?
Note that form destination data doesn't exist in the form editor so you will probably need to include it in some hidden inputs.
# http://glpi-project.org | ||
# | ||
# @copyright 2015-2025 Teclib' and contributors. | ||
# @copyright 2003-2014 by the INDEPNET Development Team. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# @copyright 2003-2014 by the INDEPNET Development Team. |
* @param {jQuery} block The block element to check | ||
* @returns {boolean} True if the block can be deleted, false otherwise | ||
*/ | ||
#checkBlockConditionDependencies(type, block) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small distinction here but aren't block only questions and comments ?
If this is also used on sections, which are block, the name should be more generic (checkItemConditionDependencies
?)
@@ -1460,4 +1460,188 @@ describe ('Conditions', () => { | |||
'First section', | |||
]); | |||
}); | |||
|
|||
it('can delete a question used in conditions', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it('can delete a question used in conditions', () => { | |
it("can't delete a question used in conditions", () => { |
cy.findByRole('dialog', {'name': 'Block has conditions and cannot be deleted'}).should('not.exist'); | ||
}); | ||
|
||
it('can delete a comment used in conditions', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it('can delete a comment used in conditions', () => { | |
it("can't delete a comment used in conditions", () => { |
cy.findByRole('dialog', {'name': 'Block has conditions and cannot be deleted'}).should('not.exist'); | ||
}); | ||
|
||
it('can delete a section used in conditions', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it('can delete a section used in conditions', () => { | |
it("can't delete a section used in conditions", () => { |
Checklist before requesting a review
Please delete options that are not relevant.
Description
#19204 must be merged before
Prevent the deletion of a question, section or comment if it is used as a condition.
Add a modal to display which elements have conditions that use the element you wish to delete.
Screenshots (if appropriate):