<tal:comment condition="nothing">

  This template's master macro should be used to render tabbed forms.

  The view class should inherit from ploneintranet.layout.browser.base.BasePanel
  and should provide a list of tabs.

  Tabs are objects that should have a traversable:

  - id (usually in proto called sheet-something)
  - css_class
  - label

  The template invoking the master macro
  should define:

  - a macro for each tab id
    (usually containing what in proto matches form#sheet-something:children)
  - a macro called buttons
    (usually containing what in proto matches form#sheet-something.button-bar:children
    with the exception of the cancel button)

</tal:comment>

<metal:page define-macro="master">

  <metal:master use-macro="here/main_template/macros/master">

    <metal:slot fill-slot="portal-content" />

    <metal:content fill-slot="content">
      <div class="modal"
           id="content"
           tal:define="
             panel_size view/panel_size|nothing;
             panel_style view/panel_style|nothing;
             panel_instance view/panel_instance|nothing;
             form_action view/form_action|nothing;
             form_data_pat_inject view/form_data_pat_inject|nothing;
             form_data_pat_validation view/form_data_pat_validation|nothing;
             tabs view/tabs;
             tabs_make_sense python:len(tabs) &gt; 1;
             title view/title|nothing;
           "
      >
        <div class="pat-modal ${panel_size} ${panel_style} ${panel_instance}"
             id="document-content"
        >
          <h1 tal:condition="title">${title}</h1>
          <div class="panel-body">
            <div class="container">

              <div class="canvas-toolbar"
                   id="${panel_instance}-toolbar"
                   tal:condition="tabs_make_sense"
              >
                <div class="canvas-toolbar-section navigation">
                  <nav class="canvas-toolbar-subnav button-cluster pat-navigation">
                    <a class="${tab/css_class}"
                       href="#${tab/id}"
                       tal:repeat="tab tabs"
                    >${tab/label}</a>
                  </nav>
                </div>
              </div>


              <div class="pat-stacks">
                <metal:sheets define-slot="sheets">
                  <tal:sheets repeat="tab tabs">
                    <tal:tab tal:define="
                               tabid tab/id;
                               is_formless tab/is_formless|nothing;
                             ">
                      <form class="sheet-content pat-form ${python:form_data_pat_inject and 'pat-inject' or ''} panel-class-${panel_size} ${python:form_data_pat_validation and 'pat-validation' or ''}"
                            id="${tabid}"
                            action="${form_action}"
                            method="${view/form_method|string:post}"
                            data-pat-inject="${form_data_pat_inject}"
                            data-pat-validation="${form_data_pat_validation}"
                            tal:condition="not: is_formless"
                            tal:omit-tag="not: form_action"
                      >
                        <fieldset class="vertical">
                          <metal:fields use-macro="template/macros/?tabid" />
                        </fieldset>
                        <p class="button-bar">
                          <metal:fields use-macro="template/macros/buttons" />
                          <button class="pat-button close-panel icon-cancel-circle ${python:form_data_pat_validation and 'validate-ignore'}"
                                  type="button"
                                  tal:condition="view/show_default_cancel_button|nothing"
                                  i18n:translate=""
                          >Cancel</button>
                          <tal:token tal:condition="form_action"
                                     tal:replace="structure context/@@authenticator/authenticator"
                          />
                        </p>
                      </form>
                      <div class="sheet-content"
                           id="${tabid}"
                           tal:condition="is_formless"
                      >
                        <metal:fields use-macro="template/macros/?tabid" />
                      </div>
                    </tal:tab>
                  </tal:sheets>
                </metal:sheets>
              </div>
            </div>
          </div>
        </div>
      </div>
    </metal:content>

  </metal:master>

</metal:page>
