-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add visibility conditions to forms #18496
Open
AdrienClairembault
wants to merge
5
commits into
glpi-project:main
Choose a base branch
from
AdrienClairembault:questions-conditions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add visibility conditions to forms #18496
AdrienClairembault
wants to merge
5
commits into
glpi-project:main
from
AdrienClairembault:questions-conditions
+2,493
−63
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AdrienClairembault
force-pushed
the
questions-conditions
branch
from
December 6, 2024 15:40
2d111f3
to
ac7e901
Compare
AdrienClairembault
changed the title
Add visibility conditions to questions
Add visibility conditions to forms
Dec 9, 2024
AdrienClairembault
force-pushed
the
questions-conditions
branch
from
December 9, 2024 14:04
8730ae0
to
bc6fada
Compare
trasher
requested changes
Dec 13, 2024
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.
See comment
trasher
approved these changes
Jan 13, 2025
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.
LGTM. Please rebase to solve conflicts and see if tests are still ok now.
AdrienClairembault
force-pushed
the
questions-conditions
branch
from
January 13, 2025 15:51
e62ab09
to
a66b962
Compare
trasher
approved these changes
Jan 14, 2025
orthagh
approved these changes
Jan 14, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist before requesting a review
Video
Description
"Minimum" implementation of the visibility condition editor (still a lot of code was required).
Features
Always visible
,Visible if...
orHidden if
).Visible if...
orHidden if
, the condition editor is displayed.And
orOr
, not available on the first condition)Short answer
questions are selectable here but all questions will be in the future, as well as sections and comments)Is equals to
,Is not equals to
,Contains
andDo not contains
forShort answer
questions).<input type="text">
forShort answer
questions).Note that conditions are not yet applied when the form is rendered for an end user.
UI
The condition editor is available using a small dropdown that is only shown when the question is selected.
The name of the dropdown reflect the current visibility strategy, allowing users to quickly see which questions have conditions.
In the editor, inputs are grouped by color to help visualize the conditions:
Technical constraints
The difficult part here is to always display a valid editor when the dropdown is opened.
Indeed, the editor contains references to some forms items like questions, which may be modified or deleted at any time.
New questions may also be added and should be available in the editor.
We can't rely on the server state to display the editor (as the client state may be modified and not yet saved) and we also can't rely on the client to render the content as we don't use vue here.
The simplest way to handle this is to send the state to the server each time the editor is opened, which will return the rendered content that we can then insert into the DOM (kinda a simplified homemade "live component") .
Any action on the editor that impact the rendering (picking an item or deleting a condition) will also trigger the same re-render behavior.