mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
entity render: options, html classes, corrections
note: span.chill-entity tag is replaced by section.chill-entity tag. because some cases are not valid html : * span.chill-entity > div * span.badge > div.chill-entity
This commit is contained in:
parent
df3d32c653
commit
57a8b49f49
@ -28,11 +28,11 @@ abstract class AbstractChillEntityRender implements ChillEntityRenderInterface
|
||||
{
|
||||
protected function getDefaultOpeningBox($classSuffix): string
|
||||
{
|
||||
return '<span class="chill-entity chill-entity__'.$classSuffix.'">';
|
||||
return '<section class="chill-entity entity-'.$classSuffix.'">';
|
||||
}
|
||||
|
||||
protected function getDefaultClosingBox(): string
|
||||
{
|
||||
return '</span>';
|
||||
return '</section>';
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
div.chill-entity {
|
||||
&.person {
|
||||
&.label {
|
||||
h3.denomination {
|
||||
font-size: 1.3em;
|
||||
font-weight: 700;
|
||||
section.chill-entity {
|
||||
// have no effect for render label, row, bloc
|
||||
display: inline;
|
||||
|
||||
&.entity-person {
|
||||
div.entity-label {
|
||||
div.denomination {
|
||||
&.h3 {
|
||||
font-size: 1.3em;
|
||||
font-weight: 700;
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
@ -14,7 +19,7 @@ div.chill-entity {
|
||||
}
|
||||
p.moreinfo {}
|
||||
}
|
||||
&.row {}
|
||||
&.bloc {}
|
||||
div.entity-row {}
|
||||
div.entity-bloc {}
|
||||
}
|
||||
}
|
||||
|
@ -226,22 +226,30 @@
|
||||
{% else %}
|
||||
<div class="flex-bloc">
|
||||
{% for r in accompanyingCourse.resources %}
|
||||
<div class="item-bloc">
|
||||
{% if r.person %}
|
||||
|
||||
{{ r.person|chill_entity_render_box({
|
||||
'display': 'bloc', 'addLink': true, 'addEntity': true, 'addInfo': true
|
||||
}) }}
|
||||
{# TEST
|
||||
{{ r.person|chill_entity_render_box({
|
||||
'render': 'label', 'addLink': true, 'addInfo': true, 'hLevel': '1'
|
||||
}) }}
|
||||
|
||||
{% endif %}
|
||||
{% if r.thirdParty %}
|
||||
<span class="badge bg-primary">
|
||||
{{ r.person|chill_entity_render_box({'render': 'raw'}) }}
|
||||
</span>
|
||||
#}
|
||||
|
||||
{{ r.thirdParty|chill_entity_render_box({
|
||||
'display': 'bloc', 'addLink': true, 'addEntity': true, 'addInfo': true
|
||||
}) }}
|
||||
<div class="item-bloc">
|
||||
{% if r.person %}
|
||||
{{ r.person|chill_entity_render_box({
|
||||
'render': 'bloc', 'addLink': true, 'addEntity': true, 'addInfo': true
|
||||
}) }}
|
||||
{% endif %}
|
||||
{% if r.thirdParty %}
|
||||
{{ r.thirdParty|chill_entity_render_box({
|
||||
'render': 'bloc', 'addLink': true, 'addEntity': true, 'addInfo': true
|
||||
}) }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
@ -1,56 +1,53 @@
|
||||
{#
|
||||
Template to render a person
|
||||
* render [raw|label|row|bloc]
|
||||
OPTIONS
|
||||
* display [raw|label|row|bloc]
|
||||
* addAltNames bool
|
||||
* addLink bool
|
||||
* addEntity bool
|
||||
* addInfo bool
|
||||
* hLevel integer
|
||||
#}
|
||||
{% macro raw(person, addAltNames) %}
|
||||
{% macro raw(person, options) %}
|
||||
<span class="firstname">{{ person.firstName }}</span>
|
||||
<span class="lastname">{{ person.lastName }}</span>
|
||||
{%- if addAltNames -%}
|
||||
{%- if options['addAltNames'] -%}
|
||||
{%- for n in person.altNames -%}
|
||||
{%- if loop.first -%}({% else %} {%- endif -%}
|
||||
<span class="altname altname-{{ n.key }}">
|
||||
{{- n.label -}}
|
||||
</span>
|
||||
<span class="altname altname-{{ n.key }}">
|
||||
{{- n.label -}}
|
||||
</span>
|
||||
{%- if loop.last -%}){%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- endif -%}
|
||||
{% endmacro raw %}
|
||||
|
||||
{% macro label(person, addLink, addAltNames, addEntity, addInfo) %}
|
||||
<div class="chill-entity person label">
|
||||
<h3 class="denomination">
|
||||
{%- if addLink and is_granted('CHILL_PERSON_SEE', person) -%}
|
||||
{% macro label(person, options) %}
|
||||
<div class="entity-label">
|
||||
|
||||
<div class="denomination {{ 'h' ~ options['hLevel'] }}">
|
||||
{%- if options['addLink'] and is_granted('CHILL_PERSON_SEE', person) -%}
|
||||
<a href="{{ chill_path_add_return_path('chill_person_view', { 'person_id': person.id }) }}">
|
||||
{{ _self.raw(person, addAltNames) }}
|
||||
{{ _self.raw(person, options) }}
|
||||
</a>
|
||||
{%- else -%}
|
||||
{{ _self.raw(person, addAltNames) }}
|
||||
{{ _self.raw(person, options) }}
|
||||
{%- endif -%}
|
||||
{%- if addEntity -%}
|
||||
{%- if options['addEntity'] -%}
|
||||
<span class="badge rounded-pill bg-secondary">{{ 'Person'|trans }}</span>
|
||||
{%- endif -%}
|
||||
</h3>
|
||||
{%- if addInfo -%}
|
||||
{% set born = (person.gender == 'woman') ? 'née le ': 'né le ' %}
|
||||
</div>
|
||||
{%- if options['addInfo'] -%}
|
||||
{% set gender = (person.gender == 'woman') ? 'fa-venus' :
|
||||
(person.gender == 'man') ? 'fa-mars' : 'fa-neuter' %}
|
||||
{% set genderTitle = (person.gender == 'woman') ? 'woman' :
|
||||
(person.gender == 'man') ? 'man' : 'neuter' %}
|
||||
<p class="moreinfo">
|
||||
<i class="fa fa-fw {{ gender }}" title="{{ genderTitle|trans }}"></i>
|
||||
{{ born|trans }}
|
||||
<time datetime="{{ person.birthdate|date('Y-m-d') }}">
|
||||
{{ person.birthdate|format_date('medium') }}
|
||||
<time datetime="{{ person.birthdate|date('Y-m-d') }}" title="{{ 'Birthdate'|trans }}">
|
||||
{{ 'Born the date'|trans({'gender': person.gender,
|
||||
'birthdate': person.birthdate|format_date("medium") }) }}
|
||||
</time>
|
||||
{# TODO
|
||||
{{ 'Born the %date%'|transchoice(person.genderNumeric, {
|
||||
'%date%': person.birthdate|format_date("medium") }) }}
|
||||
#}
|
||||
</p>
|
||||
{%- endif -%}
|
||||
{#- tricks to remove easily whitespace after template -#}
|
||||
@ -58,25 +55,25 @@
|
||||
{% endmacro label %}
|
||||
|
||||
|
||||
{%- if display == 'raw' -%}
|
||||
{{ _self.raw(person, addAltNames) }}
|
||||
{%- if render == 'raw' -%}
|
||||
{{ _self.raw(person, options) }}
|
||||
{%- endif -%}
|
||||
|
||||
{%- if display == 'label' -%}
|
||||
{{ _self.label(person, addLink, addAltNames, addEntity, addInfo) }}
|
||||
{%- if render == 'label' -%}
|
||||
{{ _self.label(person, options) }}
|
||||
{%- endif -%}
|
||||
|
||||
{%- if display == 'row' -%}
|
||||
<div class="chill-entity person row">
|
||||
{{ _self.label(person, addLink, addAltNames, addEntity, addInfo) }}
|
||||
{%- if render == 'row' -%}
|
||||
<div class="entity-row">
|
||||
{{ _self.label(person, options) }}
|
||||
</div>
|
||||
{%- endif -%}
|
||||
|
||||
{%- if display == 'bloc' -%}
|
||||
<div class="chill-entity person bloc">
|
||||
{%- if render == 'bloc' -%}
|
||||
<div class="entity-bloc">
|
||||
<div class="item-row">
|
||||
<div class="item-col">
|
||||
{{ _self.label(person, addLink, addAltNames, addEntity, addInfo) }}
|
||||
{{ _self.label(person, options) }}
|
||||
</div>
|
||||
<div class="item-col">
|
||||
<ul class="list-content fa-ul">
|
||||
|
@ -46,7 +46,7 @@
|
||||
<div class="item-col box-person">
|
||||
<div>
|
||||
{{ person|chill_entity_render_box({
|
||||
'display': 'label', 'addLink': true, 'addInfo': true
|
||||
'render': 'label', 'addLink': true, 'addInfo': true
|
||||
}) }}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -52,16 +52,22 @@ class PersonRender extends AbstractChillEntityRender
|
||||
*/
|
||||
public function renderBox($person, array $options): string
|
||||
{
|
||||
return $this->engine->render('@ChillPerson/Entity/person.html.twig',
|
||||
[
|
||||
$params = [
|
||||
'addAltNames' => $this->configAltNamesHelper->hasAltNames(),
|
||||
'addLink' => $options['addLink'] ?? false,
|
||||
'addEntity' => $options['addEntity'] ?? false,
|
||||
'addInfo' => $options['addInfo'] ?? false,
|
||||
'hLevel' => $options['hLevel'] ?? 3,
|
||||
];
|
||||
dump($params);
|
||||
return
|
||||
$this->getDefaultOpeningBox('person') .
|
||||
$this->engine->render('@ChillPerson/Entity/person.html.twig', [
|
||||
'person' => $person,
|
||||
'addAltNames' => $this->configAltNamesHelper->hasAltNames(),
|
||||
'addLink' => $options['addLink'] ?? false,
|
||||
'addEntity' => $options['addEntity'] ?? false,
|
||||
'addInfo' => $options['addInfo'] ?? false,
|
||||
'display' => $options['display'] ?? 'raw'
|
||||
]
|
||||
);
|
||||
'render' => $options['render'] ?? 'raw',
|
||||
'options' => $params
|
||||
]) .
|
||||
$this->getDefaultClosingBox();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,9 +1,11 @@
|
||||
div.chill-entity {
|
||||
&.thirdparty {
|
||||
&.label {
|
||||
h3.denomination {
|
||||
font-size: 1.3em;
|
||||
font-weight: 700;
|
||||
section.chill-entity {
|
||||
&.entity-thirdparty {
|
||||
div.entity-label {
|
||||
div.denomination {
|
||||
&.h3 {
|
||||
font-size: 1.3em;
|
||||
font-weight: 700;
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
@ -12,10 +14,12 @@ div.chill-entity {
|
||||
margin-left: 0.3em;
|
||||
}
|
||||
}
|
||||
p.moreinfo {}
|
||||
p.moreinfo {
|
||||
span.company, span.acronym {}
|
||||
}
|
||||
}
|
||||
&.row {}
|
||||
&.bloc {}
|
||||
div.entity-row {}
|
||||
div.entity-bloc {}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -1,36 +1,44 @@
|
||||
{#
|
||||
Template to render a thirdparty
|
||||
* render [raw|label|row|bloc]
|
||||
OPTIONS
|
||||
* display [raw|label|row|bloc]
|
||||
* with_valid_from bool
|
||||
* addAltNames bool
|
||||
* addLink bool
|
||||
* addEntity bool
|
||||
* addInfo bool
|
||||
* hLevel integer
|
||||
#}
|
||||
{% macro raw(thirdparty) %}
|
||||
{% macro raw(thirdparty, options) %}
|
||||
<span class="name">{{ thirdparty.name }}</span>
|
||||
{% endmacro raw %}
|
||||
|
||||
{% macro label(thirdparty, addLink, addEntity, addInfo, options) %}
|
||||
<div class="chill-entity thirdparty label">
|
||||
{% macro label(thirdparty, options) %}
|
||||
<div class="entity-label">
|
||||
|
||||
<h3 class="denomination">
|
||||
{%- if addLink and is_granted('CHILL_3PARTY_3PARTY_SHOW', thirdparty) -%}
|
||||
<div class="denomination {{ 'h' ~ options['hLevel'] }}">
|
||||
{%- if options['addLink'] and is_granted('CHILL_3PARTY_3PARTY_SHOW', thirdparty) -%}
|
||||
<a href="{{ chill_path_add_return_path('chill_3party_3party_show', { 'thirdparty_id': thirdparty.id }) }}">
|
||||
{{ _self.raw(thirdparty) }}
|
||||
{{ _self.raw(thirdparty, options) }}
|
||||
</a>
|
||||
{%- else -%}
|
||||
{{ _self.raw(thirdparty) }}
|
||||
{{ _self.raw(thirdparty, options) }}
|
||||
{%- endif -%}
|
||||
{%- if addEntity -%}
|
||||
{%- if options['addEntity'] -%}
|
||||
<span class="badge rounded-pill bg-secondary">{{ 'Third party'|trans }}</span>
|
||||
{%- endif -%}
|
||||
</h3>
|
||||
</div>
|
||||
{%- if options['addInfo'] -%}
|
||||
<p class="moreinfo">{#
|
||||
<span class="company">{{ thirdparty.nameCompany }}</span>
|
||||
<span class="acronym">{{ thirdparty.acronym }}</span>
|
||||
#} plus d'infos
|
||||
</p>
|
||||
{%- endif -%}
|
||||
|
||||
{# AVANT
|
||||
<div class="name">
|
||||
{{ _self.raw(thirdparty) }}
|
||||
{{ _self.raw(thirdparty, options) }}
|
||||
</div>
|
||||
<div class="category">
|
||||
{% for type in thirdparty.type %}
|
||||
@ -77,25 +85,25 @@
|
||||
{%- if true -%}</div>{%- endif -%}
|
||||
{% endmacro label %}
|
||||
|
||||
{%- if display == 'raw' -%}
|
||||
{{ _self.raw(thirdparty) }}
|
||||
{%- if render == 'raw' -%}
|
||||
{{ _self.raw(thirdparty, options) }}
|
||||
{%- endif -%}
|
||||
|
||||
{%- if display == 'label' -%}
|
||||
{{ _self.label(thirdparty, addLink, addEntity, addInfo, options) }}
|
||||
{%- if render == 'label' -%}
|
||||
{{ _self.label(thirdparty, options) }}
|
||||
{%- endif -%}
|
||||
|
||||
{%- if display == 'row' -%}
|
||||
<div class="chill-entity thirdparty row">
|
||||
{{ _self.label(thirdparty, addLink, addEntity, addInfo, options) }}
|
||||
{%- if render == 'row' -%}
|
||||
<div class="entity-row">
|
||||
{{ _self.label(thirdparty, options) }}
|
||||
</div>
|
||||
{%- endif -%}
|
||||
|
||||
{%- if display == 'bloc' -%}
|
||||
<div class="chill-entity thirdparty bloc">
|
||||
{%- if render == 'bloc' -%}
|
||||
<div class="entity-bloc">
|
||||
<div class="item-row">
|
||||
<div class="item-col">
|
||||
{{ _self.label(thirdparty, addLink, addEntity, addInfo, options) }}
|
||||
{{ _self.label(thirdparty, options) }}
|
||||
</div>
|
||||
<div class="item-col">
|
||||
<ul class="list-content fa-ul">
|
||||
|
@ -22,7 +22,7 @@ namespace Chill\ThirdPartyBundle\Templating\Entity;
|
||||
|
||||
use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Symfony\Bridge\Twig\TwigEngine;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -30,15 +30,12 @@ use Symfony\Bridge\Twig\TwigEngine;
|
||||
*/
|
||||
class ThirdPartyRender extends AbstractChillEntityRender
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var TwigEngine
|
||||
*/
|
||||
protected $templating;
|
||||
|
||||
public function __construct(TwigEngine $templating)
|
||||
protected EngineInterface $engine;
|
||||
|
||||
public function __construct(EngineInterface $engine)
|
||||
{
|
||||
$this->templating = $templating;
|
||||
$this->engine = $engine;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,17 +46,21 @@ class ThirdPartyRender extends AbstractChillEntityRender
|
||||
*/
|
||||
public function renderBox($entity, array $options): string
|
||||
{
|
||||
$params = [
|
||||
'with_valid_from' => $options['with_valid_from'] ?? true,
|
||||
'addLink' => $options['addLink'] ?? false,
|
||||
'addEntity' => $options['addEntity'] ?? false,
|
||||
'addInfo' => $options['addInfo'] ?? false,
|
||||
'hLevel' => $options['hLevel'] ?? 3,
|
||||
];
|
||||
|
||||
return
|
||||
$this->getDefaultOpeningBox('_3party').
|
||||
$this->templating->render('@ChillThirdParty/Entity/thirdparty.html.twig', [
|
||||
$this->getDefaultOpeningBox('thirdparty') .
|
||||
$this->engine->render('@ChillThirdParty/Entity/thirdparty.html.twig', [
|
||||
'thirdparty' => $entity,
|
||||
'with_valid_from' => $options['with_valid_from'] ?? true,
|
||||
'addLink' => $options['addLink'] ?? false,
|
||||
'addEntity' => $options['addEntity'] ?? false,
|
||||
'addInfo' => $options['addInfo'] ?? false,
|
||||
'display' => $options['display'] ?? 'raw',
|
||||
'options' => $options
|
||||
]).
|
||||
'render' => $options['render'] ?? 'raw',
|
||||
'options' => $params
|
||||
]) .
|
||||
$this->getDefaultClosingBox();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user