nineskeletor/templates/Pagewidget/widget.twig

102 lines
4.5 KiB
Twig
Raw Normal View History

2023-01-23 09:46:34 +01:00
{% set widgethaveheader=entity.viewheader %}
2023-02-01 09:03:27 +01:00
{% if widgetname=="alert" and canupdate and alerts|length ==0 %}
{% set widgethaveheader=true %}
{% endif %}
{% if widgetname=="item" and canupdate and items|length==0 and withbookmark==1 %}
{% set widgethaveheader=true %}
{% endif %}
{% if widgetname=="bookmark" and canadd and bookmarks|length==0 %}
{% set widgethaveheader=true %}
{% endif %}
{% if widgetname=="editor" and canadd and html is empty %}
{% set widgethaveheader=true %}
{% endif %}
{% set viewwidget=true %}
{% if not widgethaveheader and widgetname=="alert" and not canupdate and alerts|length ==0 %}
{% set viewwidget=false %}
{% endif %}
{% if not widgethaveheader and widgetname=="item" and not canupdate and items|length ==0 and withbookmark==1 %}
{% set viewwidget=false %}
{% endif %}
{% if not widgethaveheader and widgetname=="bookmark" and not canadd and bookmarks|length ==0 %}
{% set viewwidget=false %}
{% endif %}
{% if not widgethaveheader and widgetname=="editor" and not canadd and html is empty %}
{% set viewwidget=false %}
{% endif %}
2023-01-23 09:46:34 +01:00
{%if widgethaveheader %}
{% set widgetstyle=(entity.colorheaderback ? "border-color:"~entity.colorheaderback~";" : "border-color:var(--colorbgbodydark);") %}
{% set widgetstylemenu=(entity.colorheaderback ? "background-color:"~entity.colorheaderback~";" : "background-color:var(--colorbgbodydark);")~(entity.colorheaderfont ? "color:"~entity.colorheaderfont~";" : "color:var(--colorfttitledark);") %}
{%else%}
2023-02-01 09:03:27 +01:00
{% set widgetstyle=(viewwidget ? "display:block;" : "display:none;")~(entity.colorbodyback ? "border-color:"~entity.colorbodyback~";" : "border-color:var(--colorbgbodydark);") %}
2023-01-23 09:46:34 +01:00
{% set widgetstylemenu="margin:-26px 0px 0px 0px; padding: 1px 10px; background-color:var(--colorbgbodydark); color: var(--colorfttitledark); border-radius: 5px;" %}
{%endif%}
{% set widgetstyleheader=(entity.colorheaderback ? "background-color:"~entity.colorheaderback~";" : "background-color:var(--colorbgbodydark);")~(entity.colorheaderfont ? "color:"~entity.colorheaderfont~";" : "color:var(--colorfttitledark);") %}
2023-02-01 09:03:27 +01:00
{% set widgetstylebody=(entity.colorbodyback ? "background-color:"~entity.colorbodyback~";" : "background-color:var(--colorbgbodylight);")~(entity.colorbodyfont ? "color:"~entity.colorbodyfont~";" : "color:var(--colorfttitlelight);")~(entity.isopened ? "display:block;" : "display:none;")~(widgetname=="url" ? "padding:0px;" : "")~(not widgethaveheader and not entity.border ? "padding-top: 0px;" : "")~(entity.autoajust ? "" : "height:"~entity.height~"px;") %}
2023-01-23 09:46:34 +01:00
{% set widgeicon= entity.icon ? path('app_minio_image',{file:entity.icon.label}) : path('app_minio_image',{file:"icon/icon_pin.png"}) %}
{% if modedesktop is defined %}
{% if modedesktop==0 %}
{% set itemsize="item-verysmall" %}
{% elseif modedesktop==1 %}
{% set itemsize="item-small" %}
{% elseif modedesktop==2 %}
{% set itemsize="item-medium" %}
{% elseif modedesktop==3 %}
{% set itemsize="item-large" %}
{% elseif modedesktop==4 %}
{% set itemsize="item-list" %}
{% endif %}
{% endif %}
{% if app.user %}
{% set username = app.user.username %}
{% else %}
{% set username = "" %}
{% endif %}
{% set colorbodyfont = "color: var(--colorfttitlelight)" %}
{% if entity.colorbodyfont is not null %}
{% set colorbodyfont = "color: " ~ entity.colorbodyfont %}
{% endif %}
<div class="widget widget-{{widgetname}} {%if entity.border %} widget-bordered {%else%} widget-notbordered {%endif%} " data-id="{{ entity.id }}" loc="{{ entity.loc }}" style="{{ widgetstyle }}">
<div class="widget-menu" style="{{ widgetstylemenu }}">
{% if canupdate and not widgethaveheader %}
<i class="widget-sortable fas fa-up-down-left-right" title="Déplacer le widget"></i>
{% endif %}
{% block widgetaction %}
{% endblock %}
{% if canupdate %}
<i class="fa fa-trash fa-fw" title="Supprimer le Widget" onClick="delWidget({{ entity.id }})" ></i>
<i class="fa fa-file fa-fw" title="Modifier le Widget" onClick="modWidget({{ entity.id }})"></i>
{% endif %}
</div>
{%if widgethaveheader %}
<div class="widget-header widget-sortable" style="{{ widgetstyleheader }}">
<img class="widget-logo" src="{{widgeicon}}" />
<span class="widget-title">{{ entity.name }}</span>
</div>
{%endif%}
2023-02-01 09:03:27 +01:00
<div class="widget-body {{ (entity.autoajust ? "widget-adjust" : "") }}" style="{{ widgetstylebody }};">
2023-01-23 09:46:34 +01:00
{% block widgetbody %}
{% endblock %}
</div>
</div>