Skip to content

Commit

Permalink
Add visibility conditions to questions
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienClairembault committed Dec 9, 2024
1 parent 6497d73 commit bc6fada
Show file tree
Hide file tree
Showing 35 changed files with 2,375 additions and 29 deletions.
10 changes: 10 additions & 0 deletions css/includes/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,16 @@ body pre {
}
}

// Missing class from tabler, probably need to update it ?
.btn-check:checked+.btn {
color : var(--tblr-btn-hover-color) !important;
background-color: var(--tblr-btn-active-bg) !important;
}

.w-fit-content {
width: fit-content;
}

.accordion-button:hover, .accordion-button:focus {
z-index: unset;
}
36 changes: 36 additions & 0 deletions css/includes/components/form/_form-editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,39 @@
}
}
}

.logic-operator-selector .select2-selection {
border: 0 !important;
background-color: var(--tblr-pink-lt) !important;

// Fix some border conflicts with tabler/select2
border-top-right-radius: var(--tblr-border-radius) !important;
border-bottom-right-radius: var(--tblr-border-radius) !important;
}

.question-selector .select2-selection {
border: 0 !important;
background-color: var(--tblr-indigo-lt) !important;

// Fix some border conflicts with tabler/select2
border-top-right-radius: var(--tblr-border-radius) !important;
border-bottom-right-radius: var(--tblr-border-radius) !important;
}

.value-operator-selector .select2-selection {
border: 0 !important;
background-color: var(--tblr-teal-lt) !important;

// Fix some border conflicts with tabler/select2
border-top-right-radius: var(--tblr-border-radius) !important;
border-bottom-right-radius: var(--tblr-border-radius) !important;
}

.value-selector {
border: 0 !important;
background-color: var(--tblr-yellow-lt) !important;
}

.visibility-dropdown-card {
width: 600px;
}
4 changes: 4 additions & 0 deletions dependency_injection/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
$services->load('Glpi\Http\\', $projectDir . '/src/Glpi/Http');
$services->load('Glpi\DependencyInjection\\', $projectDir . '/src/Glpi/DependencyInjection');
$services->load('Glpi\Progress\\', $projectDir . '/src/Glpi/Progress')->exclude($projectDir . '/src/Glpi/Progress/SessionProgress.php');
$services->load(
'Glpi\Form\ConditionalVisiblity\\',
$projectDir . '/src/Glpi/Form/ConditionalVisiblity/*Manager.php'
);

/**
* Override Symfony's logger.
Expand Down
13 changes: 13 additions & 0 deletions install/migrations/update_10.0.x_to_11.0.0/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
`name` varchar(255) NOT NULL DEFAULT '',
`description` longtext,
`rank` int NOT NULL DEFAULT '0',
`visibility_strategy` varchar(30) NOT NULL DEFAULT '',
`conditions` JSON NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uuid` (`uuid`),
KEY `name` (`name`),
Expand All @@ -124,6 +126,8 @@
`description` longtext,
`default_value` text COMMENT 'JSON - The default value type may not be the same for all questions type',
`extra_data` text COMMENT 'JSON - Extra configuration field(s) depending on the questions type',
`visibility_strategy` varchar(30) NOT NULL DEFAULT '',
`conditions` JSON NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uuid` (`uuid`),
KEY `name` (`name`),
Expand All @@ -142,6 +146,8 @@
`name` varchar(255) NOT NULL DEFAULT '',
`description` longtext,
`rank` int NOT NULL DEFAULT '0',
`visibility_strategy` varchar(30) NOT NULL DEFAULT '',
`conditions` JSON NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uuid` (`uuid`),
KEY `name` (`name`),
Expand Down Expand Up @@ -329,6 +335,13 @@
$migration->addField("glpi_forms_comments", "forms_sections_uuid", "string");
$migration->addKey("glpi_forms_comments", "uuid", type: 'UNIQUE');
$migration->addKey("glpi_forms_comments", "forms_sections_uuid");

$migration->addField("glpi_forms_questions", "visibility_strategy", "string");
$migration->addField("glpi_forms_questions", "conditions", "json");
$migration->addField("glpi_forms_sections", "visibility_strategy", "string");
$migration->addField("glpi_forms_sections", "conditions", "json");
$migration->addField("glpi_forms_comments", "visibility_strategy", "string");
$migration->addField("glpi_forms_comments", "conditions", "json");
}

CronTask::register('Glpi\Form\Form', 'purgedraftforms', DAY_TIMESTAMP, [
Expand Down
6 changes: 6 additions & 0 deletions install/mysql/glpi-empty.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9504,6 +9504,8 @@ CREATE TABLE `glpi_forms_sections` (
`name` varchar(255) NOT NULL DEFAULT '',
`description` longtext,
`rank` int NOT NULL DEFAULT '0',
`visibility_strategy` varchar(30) NOT NULL DEFAULT '',
`conditions` JSON NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uuid` (`uuid`),
KEY `name` (`name`),
Expand All @@ -9523,6 +9525,8 @@ CREATE TABLE `glpi_forms_questions` (
`description` longtext,
`default_value` text COMMENT 'JSON - The default value type may not be the same for all questions type',
`extra_data` text COMMENT 'JSON - Extra configuration field(s) depending on the questions type',
`visibility_strategy` varchar(30) NOT NULL DEFAULT '',
`conditions` JSON NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uuid` (`uuid`),
KEY `name` (`name`),
Expand All @@ -9539,6 +9543,8 @@ CREATE TABLE `glpi_forms_comments` (
`name` varchar(255) NOT NULL DEFAULT '',
`description` longtext,
`rank` int NOT NULL DEFAULT '0',
`visibility_strategy` varchar(30) NOT NULL DEFAULT '',
`conditions` JSON NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uuid` (`uuid`),
KEY `name` (`name`),
Expand Down
Loading

0 comments on commit bc6fada

Please sign in to comment.