<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      lang="en"
      metal:use-macro="context/panel_template_tabbed/macros/master"
      xml:lang="en"
      tal:define="
        publisher nocall:here/@@publisher;
      "
      i18n:domain="ploneintranet"
>

  <metal:fields define-macro="sheet-article">
    <input name="type"
           type="hidden"
           value="item"
    />
    <fieldset class="group">
      <label>
        <input autofocus="autofocus"
               name="title"
               placeholder="Title"
               required="required"
               type="text"
               i18n:attributes="placeholder"
        />
      </label>
      <label>
        <textarea name="item_description"
                  placeholder="Item summary (Optional)"
                  rows="6"
                  i18n:attributes="placeholder"
        ></textarea>
      </label>
      <legend i18n:translate="label_news_section">Section</legend>
      <label pat-select="pat-select">
        <select name="section">
          <option value="${section/id}"
                  tal:repeat="section publisher/get_target_sections"
          >
              ${section/title}
          </option>
        </select>
      </label>
    </fieldset>
  </metal:fields>

  <metal:fields define-macro="sheet-section"
                tal:define="
                  my_type my_type|string:section;
                "
  >
    <input name="type"
           type="hidden"
           value="${my_type}"
    />
    <fieldset class="group">
      <label>
        <input autofocus="autofocus"
               name="title"
               placeholder="Title"
               required="${python:my_type=='section' and 'required' or None}"
               type="text"
               i18n:attributes="placeholder"
        />
      </label>
      <label>
        <textarea name="section_description"
                  placeholder="Section description (Optional)"
                  rows="6"
                  i18n:attributes="placeholder"
        ></textarea>
      </label>

      <fieldset class="pat-checklist">
        <label>
          <input checked="checked"
                 name="section-description-visible"
                 type="checkbox"
          />
          <span tal:omit-tag=""
                i18n:translate="label_newssection_description_visible"
          >Show section description on section page</span>
        </label>
      </fieldset>

      <metal:extra_fields define-slot="smartsection_fields" />
      <metal:extra_fields define-slot="syndication_fields" />

      <fieldset class="pat-checklist radio">
        <legend i18n:translate="">Navigation</legend>
        <label>
          <input checked
                 name="navigation"
                 type="radio"
                 value="main"
          />
          <tal:i18n i18n:translate="">Show in the main news navigation</tal:i18n>
        </label>
        <label>
          <input name="navigation"
                 type="radio"
                 value="other"
          />
          <tal:i18n i18n:translate="">Show in 'other' drop down of the news navigation</tal:i18n>
        </label>
        <label>
          <input name="navigation"
                 type="radio"
                 value="exclude"
          />
          <tal:i18n i18n:translate="">Don't show in the news navigation</tal:i18n>
        </label>
      </fieldset>
      <fieldset class="group">
        <legend i18n:translate="">Article teasers</legend>
        <fieldset class="pat-checklist">
          <label>
            <input checked="checked"
                   name="show_descriptions"
                   type="checkbox"
            />
            <tal:i18n i18n:translate="">Show article descriptions</tal:i18n>
          </label>
          <label>
            <input checked="checked"
                   name="show_images"
                   type="checkbox"
            />
            <tal:i18n i18n:translate="">Show article images</tal:i18n>
          </label>
        </fieldset>
      </fieldset>
      <fieldset>
        <legend i18n:translate="">Section page layout and background colour</legend>
        <fieldset class="pat-checklist free-form layout-thumbs"
                  tal:define="
                    selected_grid context/grid;
                    grid_list python:['3', '2', '1', '1-3', '2-3'];
                  "
        >
          <label class="layout-${grid}"
                 tal:repeat="grid grid_list"
          >
            <input name="grid"
                   type="radio"
                   value="${grid}"
                   tal:attributes="
                     checked python:'checked' if selected_grid == grid else '';
                   "
            />
            <img alt="Layout ${grid}"
                 src="${portal_url}/++theme++ploneintranet.theme/generated/assets/quaive/placeholders/placeholder-4x3.png"
            />
          </label>
        </fieldset>
        <fieldset class="pat-checklist radio free-form colour-selector">
          <label class="default-colour">
            <input checked="checked"
                   name="color"
                   type="radio"
            />
            <tal:i18n i18n:translate="">Default colour</tal:i18n>
          </label>
          <tal:colors repeat="color view/colors">
            <label style="background-color: ${color}"
                   tal:define="
                     color_title python:view.colors.get(color, '');
                   "
            >
              <input name="color"
                     type="radio"
                     value="${color}"
              />
                ${color_title}
            </label>
          </tal:colors>
        </fieldset>
      </fieldset>
      <fieldset class="pat-checklist radio">
        <legend i18n:translate="">Section may be maintained by</legend>
        <label>
          <input checked="checked"
                 name="maintenance"
                 type="radio"
                 value="all"
          /><tal:i18n i18n:translate="">No additional maintainer</tal:i18n>
        </label>
        <label>
          <input name="maintenance"
                 type="radio"
                 value="groups"
          />
          <tal:i18n i18n:translate="">Specific groups may maintain this news section</tal:i18n>
        </label>
      </fieldset>

      <label class="pat-depends"
             data-pat-depends="maintenance=groups"
      >
        <input class="pat-autosuggest"
               autofocus
               name="maintainer_group_list"
               placeholder="Select user groups"
               data-pat-autosuggest="allow-new-words: false; ajax-search-index: text; ajax-url: ${context/portal_url}/@@allgroups.json;"
        />
      </label>

      <fieldset class="pat-checklist radio">
        <legend i18n:translate="">News items may be contributed by</legend>
        <label>
          <input checked="checked"
                 name="contribution"
                 type="radio"
                 value="none"
          /><tal:i18n i18n:translate="">No additional contributor</tal:i18n>
        </label>
        <label>
          <input name="contribution"
                 type="radio"
                 value="all"
          />
          <tal:i18n i18n:translate="">All users may contribute news items to this news section</tal:i18n>
        </label>
        <label>
          <input name="contribution"
                 type="radio"
                 value="groups"
          />
          <tal:i18n i18n:translate="">Specific groups may contribute news items to this news section</tal:i18n>
        </label>
      </fieldset>

      <label class="pat-depends"
             data-pat-depends="contribution=groups"
      >
        <input class="pat-autosuggest"
               autofocus
               name="contributor_group_list"
               placeholder="Select user groups"
               data-pat-autosuggest="allow-new-words: false; ajax-search-index: text; ajax-url: ${context/portal_url}/@@allgroups.json;"
        />
      </label>

      <fieldset class="pat-depends pat-checklist radio"
                data-pat-depends="condition: not navigation=exclude; transition: slide"
      >
        <legend i18n:translate="">Section appears in the navigation for</legend>
        <label>
          <input checked="checked"
                 name="visibility"
                 type="radio"
                 value="all"
          />
          <tal:i18n i18n:translate="">All users</tal:i18n>
        </label>
        <label>
          <input name="visibility"
                 type="radio"
                 value="groups"
          />
          <tal:i18n i18n:translate="">Specific user groups</tal:i18n>
        </label>
      </fieldset>

      <label class="pat-depends"
             data-pat-depends="visibility=groups"
      >
        <input class="pat-autosuggest"
               autofocus
               name="nav_visible_group_list"
               placeholder="Select user groups"
               data-pat-autosuggest="allow-new-words: false; ajax-search-index: text; ajax-url: ${context/portal_url}/@@allgroups.json;"
        />
      </label>

    </fieldset>
  </metal:fields>

  <metal:fields define-macro="sheet-syndication"
                tal:define="
                  my_type string:syndication;
                "
  >
    <metal:sheet use-macro="here/panel-create-news.html/macros/sheet-section">
      <metal:syndication fill-slot="syndication_fields">
        <fieldset class="group">
          <label>
            <input name="feed_url"
                   placeholder="RSS or ATOM address"
                   required="required"
                   type="text"
                   i18n:attributes="placeholder"
            />
          </label>
        </fieldset>
      </metal:syndication>
    </metal:sheet>
  </metal:fields>

  <metal:fields define-macro="sheet-smartsection"
                tal:define="
                  my_type string:section;
                "
  >
    <metal:sheet use-macro="here/panel-create-news.html/macros/sheet-section">
      <metal:smartsection fill-slot="smartsection_fields">
        <fieldset class="group">
          <label>
            <tal:i18n i18n:translate="">Type of smart section</tal:i18n>
            <select name="view_name">
              <option value="all"
                      tal:replace="nothing"
                      i18n:translate=""
              >
                        All news
              </option>
              <option value="@@trending"
                      i18n:translate=""
              >
                        Trending news items
              </option>
              <option value="@@mygroups"
                      i18n:translate=""
              >
                        Department news
              </option>
              <option value="@@events-as-news"
                      i18n:translate=""
              >
                        Events
              </option>
            </select>
          </label>

          <label class="pat-depends"
                 data-pat-depends="condition: view_name='@@events-as-news'; transition: slide"
                 tal:define="
                   current_value python:getattr(context, 'calendar', None);
                   current_value python:current_value and current_value.to_object and current_value.to_object.UID();
                 "
          >
            <tal:i18n i18n:translate="">Calendar that will feed the events page</tal:i18n>
            <select name="calendar">
              <option value=""
                      i18n:translate=""
              >
                        All central calendars (except personal calendars)
              </option>
              <option selected="${python:(calendar.UID == current_value) and 'selected' or None}"
                      value="${calendar/UID}"
                      tal:repeat="calendar view/central_calendars"
              >
                        ${calendar/Title}
              </option>
            </select>
            <input name="calendar-empty-marker"
                   type="hidden"
                   value="1"
            />
          </label>

          <p class="pat-message notice pat-depends"
             data-pat-depends="condition: view_name=all; transition: slide"
             i18n:translate=""
          >
                An aggreation of the latest news items of all channels that a viewer is able to see combined in anti chronological order.
          </p>
          <p class="pat-message notice pat-depends"
             data-pat-depends="condition: view_name='@@trending'; transition: slide"
             i18n:translate=""
          >
                The news items that are currently the most popular by readers.
          </p>
          <p class="pat-message notice pat-depends"
             data-pat-depends="condition: view_name='@@mygroups'; transition: slide"
             i18n:translate=""
          >
                News of the department the viewer works for.
          </p>
          <p class="pat-message notice pat-depends"
             data-pat-depends="condition: view_name='@@events-as-news'; transition: slide"
             i18n:translate=""
          >
                Events, as those that may be found in the calendar app. Each event is promoted on its own, attractively designed page.
          </p>
        </fieldset>
      </metal:smartsection>
    </metal:sheet>
  </metal:fields>

  <metal:buttons define-macro="buttons">
    <input name="form.id"
           type="hidden"
           value="create"
    />
    <button class="pat-button default icon-ok-circle focus close-panel"
            id="form-buttons-create"
            name="form.buttons.create"
            type="submit"
            value="Create"
            i18n:translate=""
    >Create</button>
  </metal:buttons>
</html>
