Skip to content

Commit

Permalink
feat(forms): Adding radio and checkbox category and related sub quest…
Browse files Browse the repository at this point in the history
…ion type

fix: JS lint

chore: refactor js files to improve code quality

chore: split data validation and preparation into separate methods

fix: JS lint

fix: adding missing abstract methods for urgency question type
  • Loading branch information
ccailly committed Apr 26, 2024
1 parent aaedd26 commit 3f6f26d
Show file tree
Hide file tree
Showing 16 changed files with 895 additions and 17 deletions.
7 changes: 7 additions & 0 deletions css/includes/components/form/_form-editor.scss
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
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

0 comments on commit 3f6f26d

Please sign in to comment.