 <h1 translate>Import agenda items</h1>

<div id="submenu">
  <a ui-sref="agenda.item.list" class="btn btn-sm btn-default">
    <i class="fa fa-angle-double-left fa-lg"></i>
    <translate>Back to overview</translate>
  </a>
</div>

<h2 translate>Import by copy/paste</h2>
<p translate>Copy and paste your agenda item titles in this textbox.
Keep each item in a single line.</p>

<div class="row">
  <div class="form-group col-sm-6">
    <textarea ng-model="itemlist" rows="5" class="form-control" ng-list="/\n/"></textarea>
  </div>
</div>

<div class="clearfix">
  <button ng-click="importByLine()" class="btn btn-primary pull-left" translate>Import</button>
  <div class="col-xs-5" ng-if="items">
    <progressbar animate="false" type="success" max="items.length" value="importcounter">
      <i>{{ importcounter }} / {{ items.length }} {{ "imported" | translate }}</i>
    </progressbar>
  </div>
</div>

<hr>

<h2 translate>Import by CSV file</h2>
<p translate>Select a CSV file to import agenda items!

<p translate>Please note:</p>
<ul><!--TODO: utf-8 encoding still required with angular-csv? -->
    <li><translate>Required comma separated values</translate>:<br>
        <code translate>'title, text, duration'</code>
    <li translate>Text and duration are optional and may be empty.
    <li translate>The header in first line is required.
    <li translate>Required CSV file encoding is UTF-8.
    <li><a href="https://github.com/OpenSlides/OpenSlides/wiki/CSV-Import" translate>
          Use the CSV example file from OpenSlides Wiki.
        </a>
</ul>

<ng-csv-import
  content="csv.content"
  class="import"
  header="csv.header"
  separator="csv.separator"
  result="csv.result"></ng-csv-import>

<div ng-if="csv.result" class="col-sm-6 well">
  <h3 translate>Preview</h3>
  <table class="table table-striped table-bordered table-condensed">
    <thead>
      <tr>
        <th>#
        <th translate>Title
        <th translate>Text
        <th translate>Duration
    <tbody ng-repeat="item in csv.result">
      <tr>
        <td>{{ $index+1 }}
        <td>{{ item.title }}
        <td>{{ item.text }}
        <td>{{ item.duration }}
  </table>

<div class="clearfix">
  <button ng-if="!csvimporting" ng-click="importByCSV(csv.result)" class="btn btn-primary pull-left" translate>Import</button>
  <div ng-if="csvimporting">
    <progressbar animate="false"  type="success" max="csvlines" value="csvimportcounter">
      <i>{{ csvimportcounter }} / {{ csvlines }} {{ "imported" | translate }}</i>
    </progressbar>
  </div>
  <a ng-if="csvimported" ui-sref="agenda.item.list" class="btn btn-sm btn-default">
    <i class="fa fa-angle-double-left fa-lg"></i>
    <translate>Back to agenda overview</translate>
  </a>
</div>
  <p>
    <div class="form-group">
      <button ng-if="!csvimporting" ng-click="clear()" class="btn btn-default" translate>
        Clear
      </button>
    </div>
</div>
