<!-- $Id: create_list_request.tt2 12726 2016-03-09 04:01:24Z sikeda $ -->

<div class="block" id="create_switch">

<div id="list_create">
<h2><i class="fa fa-plus"></i> [%|loc%]Create list[%END%] <a  href="[% 'nomenu/help/admin' | url_rel %]#create_list" title="[%|loc%]Open in a new window[%END%]" onclick="window.open('','wws_help','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=400')" target="wws_help"><i class="fa fa-question-circle" title="[%|loc%]Help[%END%]"></i></a></h2>

<form action="[% path_cgi %]" method="post">
<fieldset>
  <label for="listname">[%|loc%]List name:[%END%]</label><input type="text" id="listname" name="listname" size="30" value="[% saved.listname %]" />
  <label for="owner">[%|loc%]Owner:[%END%]</label> <span>[% user.email %]</span>    
  <label for="list_type">[%|loc%]List type:[%END%]</label>
  <ul id="list_type">
  [%~ FOREACH tpl_info = list_list_tpl %]
    <li>
    <input type="radio" name="template" value="[% tpl_info.key %]"
      [% IF tpl_info.value.selected || loop.size == 1 %]
        checked="checked"
      [% END %]
      id="template.[% tpl_info.key %]"
    />
    <label for="template.[% tpl_info.key %]">
    [% IF tpl_info.value.title ~%]
      [% tpl_info.value.title %]
    [%~ ELSE ~%]
      [% tpl_info.key %]
    [%~ END %]
    </label>
    [%~ IF tpl_info.value.html_content ~%]
      [% TRY ~%]
        [% tpl_info.value.html_content | eval %]
      [%~ CATCH ~%]
        <!-- [% error | html %] -->
      [%~ END %]
    [%~ END %]
    </li>
  [%~ END %]
  </ul>

  <label for="subject">[%|loc%]Subject:[%END%]</label> <input type="text" name="subject" id="subject" size="60" value="[% saved.subject %]" />

[% SET single_topic = "other" %]
[% FOREACH topic = list_of_topics %]
  [% IF loop.size > 1 || (topic.key && topic.key != "other") %]
    [% SET single_topic = "" %]
    [% LAST %]
  [% ELSIF topic.value.sub %]
    [% FOREACH subtopic = topic.value.sub %]
      [% SET single_topic = "" %]
      [% LAST %]
    [% END %]
  [% END %]
[% END %]
[% IF single_topic != "" %]
  <input id="topics" name="topics" type="hidden" value="[% single_topic %]" />
[% ELSE %]
  <label for="topics">[%|loc%]Audience:[%END%]</label>
    <select id="topics" name="topics">
	<option value="">[%|loc%]-- Select an Audience --[%END%]</option>
	[% SET topic_other = 0 %]
	[% FOREACH topic = list_of_topics %]
	  [% IF topic.key == "other" %][% SET topic_other = 1 %][% END %]
	  <option value="[% topic.key %]"
	  [% IF topic.value.selected %]
	    selected="selected"
	  [% END %]
	  >[% topic.value.current_title %]</option>
	  [% IF topic.value.sub %]
	  [% FOREACH subtopic = topic.value.sub %]
	     <option value="[% topic.key %]/[% subtopic.key %]">[% topic.value.current_title %] / [% subtopic.value.current_title %]</option>
	  [% END %]
	  [% END %]
	[% END %]
	[% UNLESS topic_other %]
	<option value="other">[%|loc%]Other[%END%]</option>
	[% END %]
     </select>
   <br />
[% END %]

   <label for="info" class="align_top">[%|loc%]Description:[%END%]</label><textarea class="desc" id="info" name="info" rows="10" cols="80">[% saved.info %]</textarea>
   <input class="MainMenuLinks" type="submit" name="action_create_list" value="[%|loc%]Submit your creation request[%END%]" />
</fieldset>
</form>

</div>

[% IF all_lists.size > 0 %]
<div id="list_copy">
  <h2>[%|loc%]Copy an existing list.[%END%]</h2>
<br />

  [%|loc%]You can create a list, using an existing list as a template; the list configuration of the source list will be copied to create the new one. Note that neither list members, nor archives or shared documents are duplicated. The source lists you can use are limited to lists you own.[%END%]
  [%|loc%]After the list is created, you will be able to adjust it's configuration.[%END%] <br />
  <form action="[% path_cgi %]" method="post">
  <fieldset>
  <select name="list">
  [% FOREACH l = all_lists %]
     <option value="[% l.name %]">[% l.name %]</option>
  [% END %]
  </select>
  <label for="new_listname">[%|loc%]New list name:[%END%]</label> <input id="new_listname" name="new_listname" value="" />
  <input type="hidden" name="new_robot" value=[%robot%] />
  <input class="MainMenuLinks" type="submit" name="action_copy_list" value="[%|loc%]copy list configuration[%END%]" />
  </fieldset>
  </form>
</div>
[% END %]

</div>

[%# Initialize toggle. #%]
<script>
<!--
  $('#list_copy').hide();

  $('a[href="#list_copy"], a[href="#list_create"]').on('click', function(e) {
    e.stopPropagation();
    e.preventDefault();
    id = $(this).attr('href').substr(1);
    $('#list_copy, #list_create').hide();
    $('#' + id).show();
    return false;
  });
//-->
</script>

<!-- end create_list_request.tt2 -->
