Skip to content

Commit

Permalink
Display nullable booleans as null values
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Sep 21, 2023
1 parent 12cc0e9 commit 626bbaf
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 9 deletions.
5 changes: 5 additions & 0 deletions assets/css/easyadmin-theme/badges.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,8 @@
box-shadow: var(--badge-dark-box-shadow);
color: var(--badge-dark-color);
}
.badge.badge-outline {
background-color: transparent;
box-shadow: var(--badge-outline-box-shadow);
color: var(--badge-outline-color);
}
4 changes: 4 additions & 0 deletions assets/css/easyadmin-theme/variables-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@
--badge-dark-bg: var(--gray-900);
--badge-dark-box-shadow: none;
--badge-dark-color: var(--gray-50);
--badge-outline-box-shadow: inset 0 0 0 1px var(--gray-300);
--badge-outline-color: var(--datalist-value-color);
--alert-primary-bg: var(--indigo-100);
--alert-primary-color: var(--indigo-800);
--alert-primary-border-color: var(--indigo-200);
Expand Down Expand Up @@ -531,6 +533,8 @@
--badge-dark-bg: rgba(0, 0, 0, 0.18);
--badge-dark-box-shadow: inset 0 0 0 1px rgba(153, 153, 153, 0.3);
--badge-dark-color: rgb(153, 153, 153);
--badge-outline-box-shadow: inset 0 0 0 1px var(--true-gray-500);
--badge-outline-color: var(--datalist-value-color);
--alert-primary-bg: var(--indigo-900);
--alert-primary-color: var(--indigo-100);
--alert-primary-border-color: var(--indigo-800);
Expand Down
3 changes: 1 addition & 2 deletions src/Field/Configurator/CommonPostConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,11 @@ private function buildFormattedValueOption($value, FieldDto $field, EntityDto $e
private function updateFieldTemplate(FieldDto $field): void
{
$usesEasyAdminTemplate = u($field->getTemplatePath())->startsWith('@EasyAdmin/');
$isBooleanField = BooleanField::class === $field->getFieldFqcn();
$isNullValue = null === $field->getFormattedValue();
$isEmpty = is_countable($field->getFormattedValue()) && 0 === \count($field->getFormattedValue());

$adminContext = $this->adminContextProvider->getContext();
if ($usesEasyAdminTemplate && $isNullValue && !$isBooleanField) {
if ($usesEasyAdminTemplate && $isNullValue) {
$field->setTemplatePath($adminContext->getTemplatePath('label/null'));
}

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Resources/public/entrypoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"entrypoints": {
"app": {
"css": [
"/app.8c5cbeb6.css",
"/app.8c5cbeb6.rtl.css"
"/app.fb3c9cb7.css",
"/app.fb3c9cb7.rtl.css"
],
"js": [
"/app.914bb6ba.js"
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"app.css": "app.8c5cbeb6.css",
"app.rtl.css": "app.8c5cbeb6.rtl.css",
"app.css": "app.fb3c9cb7.css",
"app.rtl.css": "app.fb3c9cb7.rtl.css",
"app.js": "app.914bb6ba.js",
"form.js": "form.fc39362b.js",
"page-layout.js": "page-layout.3347892e.js",
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/label/null.html.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{% if not (ea.crud.areNullValuesHidden ?? false) %}
<span class="badge badge-secondary">{{ 'label.null'|trans(domain = 'EasyAdminBundle') }}</span>
<span class="badge badge-outline">{{ 'label.null'|trans(domain = 'EasyAdminBundle') }}</span>
{% endif %}

0 comments on commit 626bbaf

Please sign in to comment.