<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/macros/master"
      xml:lang="en"
      i18n:domain="ploneintranet"
>
  <body>
    <metal:body fill-slot="body"
                tal:define="
                  portal_url context/portal_url;
                  publisher nocall:view/app/@@publisher;
                  news_app_view nocall:view/app/@@view;
                  view_name here/view_name|nothing;
                  content_helper_view nocall:here/content_helper_view;
                "
    >
      <fieldset class="vertical">
        <fieldset class="group">
          <legend i18n:translate="">Title and description</legend>
          <label>
            <input autofocus="autofocus"
                   name="title"
                   placeholder="Section title"
                   type="text"
                   value="${context/title}"
                   i18n:attributes="placeholder"
            />
          </label>
          <label>
            <textarea name="description"
                      placeholder="Section description (Optional)"
                      rows="6"
                      i18n:attributes="placeholder"
            >${context/description}</textarea>
          </label>
          <fieldset class="pat-checklist">
            <label>
              <input name="section-description-visible"
                     type="checkbox"
                     tal:attributes="
                       checked context/description_visible|nothing;
                     "
              />
              <tal:i18n i18n:translate="label_newssection_description_visible">
                Show section description on section page
              </tal:i18n>
            </label>
          </fieldset>
        </fieldset>
        <fieldset class="vertical"
                  tal:condition="python:publisher.is_syndicated(here)"
        >
          <label>
            <tal:i18n i18n:translate="">
              RSS or ATOM address
            </tal:i18n>
            <input name="feed_url"
                   placeholder="RSS or ATOM address"
                   type="text"
                   value="${context/feed_url}"
                   i18n:attributes="placeholder"
            />
          </label>
          <label>
            <tal:i18n i18n:translate="">
              The user that will create the the news when the feed is consumed
            </tal:i18n>
            <input class="pat-autosuggest users"
                   name="news_from_feed_creator"
                   placeholder="Enter text"
                   type="text"
                   value="${request/news_from_feed_creator|context/news_from_feed_creator}"
                   data-pat-autosuggest="allow-new-words: false; ajax-data-type: json; prefill-json: ${python:content_helper_view.safe_member_prefill(context, 'news_from_feed_creator')}; ajax-url: ${here/portal_url}/@@allusers.json; maximum-selection-size: 1"
                   i18n:attributes="placeholder"
            />
          </label>
        </fieldset>
        <fieldset class="group"
                  tal:condition="python:publisher.is_smart_section(here) and not publisher.is_syndicated(here) "
        >
          <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 selected="${python:(view_name == '@@trending') and 'selected' or None}"
                      value="@@trending"
                      i18n:translate=""
              >
                        Trending news items
              </option>
              <option selected="${python:(view_name == '@@mygroups') and 'selected' or None}"
                      value="@@mygroups"
                      i18n:translate=""
              >
                        Department news
              </option>
              <option selected="${python:(view_name == '@@events-as-news') and 'selected' or None}"
                      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);
                 "
          >
            <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>
        <fieldset class="pat-checklist radio">
          <legend i18n:translate="">Navigation</legend>
          <label>
            <input name="navigation"
                   type="radio"
                   value="main"
                   tal:attributes="
                     checked python:context.navigation == 'main';
                   "
            />
            <tal:i18n i18n:translate="label_newssection_visible">Show in the main news navigation</tal:i18n>
          </label>
          <label>
            <input name="navigation"
                   type="radio"
                   value="other"
                   tal:attributes="
                     checked python:context.navigation == '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:attributes="
                     checked python:context.navigation == '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 name="show_descriptions"
                     type="checkbox"
                     tal:attributes="
                       checked context/show_descriptions|nothing;
                     "
              />
              <tal:i18n i18n:translate="">Show article descriptions</tal:i18n>
            </label>
            <label>
              <input checked="checked"
                     name="show_images"
                     type="checkbox"
                     tal:attributes="
                       checked context/show_images|nothing;
                     "
              />
              <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, '');
                       selected_color context/color;
                     "
              >
                <input name="color"
                       type="radio"
                       value="${color}"
                       tal:attributes="
                         checked python:'checked' if color == selected_color else '';
                       "
                />
                ${color_title}
              </label>
            </tal:colors>
          </fieldset>
        </fieldset>
        <fieldset class="pat-checklist radio">
          <legend i18n:translate="">Section may be maintained by</legend>
          <label>
            <input checked="${python:'checked' if not context.maintainer_group_list else None}"
                   name="maintenance"
                   type="radio"
                   value="none"
            /><tal:i18n i18n:translate="">No additional maintainer</tal:i18n>
          </label>
          <label>
            <input checked="${python:'checked' if context.maintainer_group_list else None}"
                   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; prefill: ${python:','.join(context.maintainer_group_list)}"
          />
        </label>

        <fieldset class="pat-checklist radio">
          <legend i18n:translate="">News items may be contributed by</legend>
          <label>
            <input checked="${python:'checked' if not context.contributor_group_list else None}"
                   name="contribution"
                   type="radio"
                   value="none"
            /><tal:i18n i18n:translate="">No additional contributor</tal:i18n>
          </label>
          <label>
            <input checked="${python:'checked' if context.contributor_group_list and 'All Intranet Users' in context.contributor_group_list else None}"
                   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 checked="${python:'checked' if context.contributor_group_list and 'All Intranet Users' not in context.contributor_group_list else None}"
                   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; prefill: ${python:','.join(context.contributor_group_list.difference(set(['All Intranet Users'])))}"
          />
        </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="${python:'checked' if not context.nav_visible_group_list else None}"
                   name="visibility"
                   type="radio"
                   value="all"
            />
            <tal:i18n i18n:translate="">All users</tal:i18n>
          </label>
          <label>
            <input checked="${python:'checked' if context.nav_visible_group_list else None}"
                   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; prefill: ${python:','.join(context.nav_visible_group_list)}"
          />
        </label>

      </fieldset>

    </metal:body>
    <metal:buttons fill-slot="buttons">
      <button class="pat-button default close-panel icon-ok-circle"
              type="submit"
              i18n:translate=""
      >Save</button>
    </metal:buttons>
  </body>
</html>
