mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +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:
@@ -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();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user