Skip to content
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

feat(forms): Adding radio and checkbox categories and related sub question type #16928

Merged
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
7 changes: 7 additions & 0 deletions css/includes/components/form/_form-editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@
height: 70px !important;
}

.glpi-form-editor-drag-question-option-placeholder {
border: 2px dashed var(--tblr-primary);
background: rgba(var(--tblr-primary), 0.1);
opacity: 0.5;
height: 40px !important;
}

.glpi-form-editor-drag-section-placeholder {
border: 2px dashed var(--tblr-primary);
background: rgba(var(--tblr-primary), 0.1);
Expand Down
18 changes: 9 additions & 9 deletions js/form_editor_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class GlpiFormEditorController
// Compute state before submitting the form
$(this.#target).on('submit', (event) => {
try {
this.#computeState();
this.computeState();
} catch (e) {
// Do not submit the form if the state isn't computed
event.preventDefault();
Expand Down Expand Up @@ -359,7 +359,7 @@ class GlpiFormEditorController
* Compute the state of the form editor (= inputs names and values).
* Must be executed after each actions.
*/
#computeState() {
computeState() {
let global_q_index = 0;

// Find all sections
Expand Down Expand Up @@ -404,7 +404,7 @@ class GlpiFormEditorController
}

/**
* Must not be called directly, use #computeState() instead.
* Must not be called directly, use computeState() instead.
*
* Inputs names of questions and sections must be formatted to match the
* expected format, which is:
Expand Down Expand Up @@ -451,9 +451,9 @@ class GlpiFormEditorController

// Update input name
let postfix = "";
if (field.endsWith("[]")) {
field = field.slice(0, -2);
postfix = "[]";
if (typeof field === 'string' && field.match(/\[([\w[\]]*)\]$/g)) {
postfix = field.match(/\[([\w[\]]*)\]$/g);
field = field.replace(postfix, "");
}

$(input).attr(
Expand All @@ -464,7 +464,7 @@ class GlpiFormEditorController
}

/**
* Must not be called directly, use #computeState() instead.
* Must not be called directly, use computeState() instead.
*
* Set the rank of the given item
*
Expand All @@ -476,7 +476,7 @@ class GlpiFormEditorController
}

/**
* Must not be called directly, use #computeState() instead.
* Must not be called directly, use computeState() instead.
*
* Generate a UUID for each newly created questions and sections.
* This UUID will be used by the backend to handle updates for news items.
Expand All @@ -494,7 +494,7 @@ class GlpiFormEditorController
}

/**
* Must not be called directly, use #computeState() instead.
* Must not be called directly, use computeState() instead.
*
* Set the parent section of the given question.
*
Expand Down
Loading