{# Generic renderer for boxes / portlets #}

{%- set color_map = dict(blue="info", green="success", orange="warning", red="danger",
                         primary="primary", info="info", success="success",
                         warning="warning", danger="danger", cls="") %}

{%- macro m_box(title, color="info", href=None, icon_class="") %}
<!-- begin box "{{ title }}" -->
  <div class="panel panel-{{ color_map.get(color, 'default') }} {{ cls }}">
    {%- if title %}
      <div class="panel-heading">
        <h5 class="panel-title">
          {%- if href %}<a href="{{ href }}">{%- endif %}
          {%- if icon_class -%}<span class="{{ icon_class}}"></span>{% endif %}
          {{ title }}
          {%- if href %}</a>{%- endif %}
        </h5>
      </div>
    {%- endif %}

    <div class="panel-body">
        {{ caller() }}
    </div>
  </div>
<!-- end box "{{ title }}" -->
{%- endmacro %}

{%- macro m_box_menu(title=None, color="green", omit_body=False) %}
<!-- begin menu box "{{ title }}" -->
  <div class="panel panel-{{ color_map.get(color, 'default') }}">
    <div class="panel-heading">
      <h5 class="panel-title">{{ title or _('Menu') }}</h5>
    </div>

    {%- if not omit_body %}
    <div class="panel-body">
    {%- endif %}
      {{ caller() }}
    {%- if not omit_body %}
    </div>
    {%- endif %}
  </div>
<!-- end menu box "{{ title }}" -->
{%- endmacro %}

{%- macro m_box_content(title=None, color="blue") %}
<!-- begin box "{{ title }}" -->
  <div class="panel panel-{{ color_map.get(color, 'default') }}">
    {%- if title %}
      <div class="panel-heading">
        <h5 class="panel-title">{{ title }}</h5>
      </div>
    {%- endif %}

    <div class="panel-body">
      {{ caller() }}
    </div>
  </div>
  <div class="clearfix"></div>
<!-- end box "{{ title }}" -->
{%- endmacro %}
