Skip to content

Commit 2c72dda

Browse files
authored
Merge pull request #124 from itk-dev/feature/4717-published-info
Add info on unpublished content
2 parents e4eda20 + 40aa365 commit 2c72dda

5 files changed

Lines changed: 27 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning].
77

88
## [Unreleased]
99

10+
- [PR-124](https://github.com/itk-dev/ai-screening/pull/124)
11+
Added info badge on unpublished content
1012
- [PR-123](https://github.com/itk-dev/ai-screening/pull/123)
1113
Replaced "bortfald" with "ændring" in select places
1214
- [PR-118](https://github.com/itk-dev/ai-screening/pull/118)

config/sync/language/da/views.view.projects.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ display:
1414
title:
1515
label: Navn
1616
alter:
17-
text: "<h4>{{ title }}</h4>\r\n{{ field_description }}"
17+
text: "<div class=\"inline-flex items-center\">\r\n{% include '@itkdev_project_theme/components/badge.html.twig' with { label: status != '1' ? 'Not published'|trans, additional_class_names: 'mr-3' } %}\r\n<h4>{{ title }}</h4>\r\n</div>\r\n{{ field_description }}"
1818
separator: ", "
1919
field_project_state:
2020
label: Tilstand

config/sync/views.view.projects.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ display:
242242
exclude: false
243243
alter:
244244
alter_text: true
245-
text: "<h4>{{ title }}</h4>\r\n{# @todo Do we want to show this?\r\n{% if status != '1' %}<div class=\"project-status not-published\">{{ 'Not published'|trans }}</div>{% endif %}\r\n#}\r\n{{ field_description }}"
245+
text: "<div class=\"inline-flex items-center\">\r\n{% include '@itkdev_project_theme/components/badge.html.twig' with { label: status != '1' ? 'Not published'|trans, additional_class_names: 'mr-3' } %}\r\n<h4>{{ title }}</h4>\r\n</div>\r\n{{ field_description }}"
246246
make_link: false
247247
path: ""
248248
absolute: false
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{% if label is not empty %}
2+
{# https://tailwindcss.com/plus/ui-blocks/application-ui/elements/badges light theme v3.4 #}
3+
{% set class_names = {
4+
gray: 'inline-flex items-center rounded-md bg-gray-50 px-2 py-1 text-xs font-medium text-gray-600 ring-1 ring-inset ring-gray-500/10',
5+
red: 'inline-flex items-center rounded-md bg-red-50 px-2 py-1 text-xs font-medium text-red-700 ring-1 ring-inset ring-red-600/10',
6+
yellow: 'inline-flex items-center rounded-md bg-yellow-50 px-2 py-1 text-xs font-medium text-yellow-800 ring-1 ring-inset ring-yellow-600/20',
7+
green: 'inline-flex items-center rounded-md bg-green-50 px-2 py-1 text-xs font-medium text-green-700 ring-1 ring-inset ring-green-600/20',
8+
blue: 'inline-flex items-center rounded-md bg-blue-50 px-2 py-1 text-xs font-medium text-blue-700 ring-1 ring-inset ring-blue-700/10',
9+
indigo: 'inline-flex items-center rounded-md bg-indigo-50 px-2 py-1 text-xs font-medium text-indigo-700 ring-1 ring-inset ring-indigo-700/10',
10+
purple: 'inline-flex items-center rounded-md bg-purple-50 px-2 py-1 text-xs font-medium text-purple-700 ring-1 ring-inset ring-purple-700/10',
11+
pink: 'inline-flex items-center rounded-md bg-pink-50 px-2 py-1 text-xs font-medium text-pink-700 ring-1 ring-inset ring-pink-700/10',
12+
} %}
13+
{# Add some sensible names for the classes #}
14+
{% set class_names = class_names|merge({
15+
info: class_names['gray'],
16+
}) %}
17+
{# make sure that type is valid, i.e. defined in class_names #}
18+
{% set type = (type and class_names[type] is defined) ? type : 'info' %}
19+
<div class="badge badge-{{ type }} {{ class_names[type] }} {{ additional_class_names }}">
20+
{{ label }}
21+
</div>
22+
{% endif %}

web/themes/custom/itkdev/itkdev_project_theme/templates/node--project.html.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
{% block title %}
1919
<div class="inline-flex items-center">
20+
{{ include('@itkdev_project_theme/components/badge.html.twig', {label: node.status.value != '1' ? 'Not published'|trans, additional_class_names: 'mr-3'}) }}
2021
<h1 class="dark:text-white inline-block">{{ label }}</h1>
2122
{% if node.access('update') %}
2223
<a href="{{ path('entity.node.edit_form', {node: node.id}) }}" class="inline-block mx-3 btn-icon bg-black text-white hover:bg-stone-700"><i class="fa-solid fa-pencil"></i></a>

0 commit comments

Comments
 (0)