<div class="header">
  <div class="title">
    <div class="submenu">
      <a ng-click="openDialog()" os-perms="motions.can_create" class="btn btn-primary btn-sm">
        <i class="fa fa-plus fa-lg"></i>
        <translate>New</translate>
      </a>
      <a ui-sref="motions.category.list" os-perms="motions.can_manage" class="btn btn-default btn-sm">
        <i class="fa fa-sitemap fa-lg"></i>
        <translate>Categories</translate>
      </a>
      <a ui-sref="motions.motionBlock.list" os-perms="motions.can_manage" class="btn btn-default btn-sm">
        <i class="fa fa-th-large fa-lg"></i>
        <translate>Motion blocks</translate>
      </a>
      <a ui-sref="core.tag.list" os-perms="core.can_manage_tags" class="btn btn-default btn-sm">
        <i class="fa fa-tags fa-lg"></i>
        <translate>Tags</translate>
      </a>
      <a ui-sref="motions.motion.import" os-perms="motions.can_manage" class="btn btn-default btn-sm">
        <i class="fa fa-download fa-lg"></i>
        <translate>Import</translate>
      </a>
    </div>
    <h1 translate>Motions</h1>
  </div>
</div>

<div class="details">
  <div class="row">
    <div class="col-sm-12">
      <!-- select mode -->
      <button os-perms="motions.can_manage" class="btn btn-sm"
          ng-class="$parent.isSelectMode ? 'btn-primary' : 'btn-default'"
          ng-click="$parent.isSelectMode = !$parent.isSelectMode; uncheckAll()">
        <i class="fa fa-check-square-o"></i>
        <translate>Select ...</translate>
      </button>
      <!-- Export dropdown -->
      <div class="dropdown pull-right" uib-dropdown>
        <button type="button" class="btn btn-default btn-sm" id="dropdownExport" uib-dropdown-toggle>
          <i class="fa fa-upload"></i>
          <span ng-if="motionsFiltered.length == motions.length" translate>
            Export all
          </span>
          <span ng-if="motionsFiltered.length != motions.length" translate>
            Export filtered
          </span>
          <span class="caret"></span>
        </button>
        <ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownExport">
          <!-- PDF export -->
          <li>
            <a href="" ng-click="pdfExport()">
              <i class="fa fa-file-pdf-o"></i>
              PDF
            </a>
          </li>
          <!-- CSV export -->
          <li os-perms="motions.can_manage">
            <a href="" id="downloadLinkCSV"
              ng-click="csvExport()">
              <i class="fa fa-file-text-o"></i>
              CSV
            </a>
          </li>
          <!-- DOCX export -->
          <li os-perms="motions.can_manage">
            <a href="" ng-click="docxExport()">
              <i class="fa fa-file-word-o"></i>
              DOCX
            </a>
          </li>
        </ul>
      </div>
    </div>
  </div>

  <div uib-collapse="!isSelectMode" class="row spacer">
    <div class="col-sm-12 text-left form-inline" ng-show="isSelectMode" os-perms="motions.can_manage">
      <!-- actions -->
      <select ng-model="selectedAction" class="form-control input-sm">
        <option value="" translate>--- Select action ---</option>
        <option value="delete" translate>Delete</option>
        <option value="setStatus" translate>Set status</option>
        <option value="setCategory" ng-if="categories.length" translate>Set category</option>
        <option value="setMotionBlock" ng-if="motionBlocks.length" translate>Set motion block</option>
      </select>
      <!-- state select -->
      <select ng-show="selectedAction == 'setStatus'" ng-model="selectedState" class="form-control input-sm">
        <option value="" translate>--- Select state ---</option>
        <option ng-repeat="state in states" ng-disabled="state.workflowHeader" value="{{ state.id }}">
          {{ (state.workflowHeader ? state.headername : state.name) | translate }}
        </option>
      </select>
      <!-- set state button -->
      <a ng-show="selectedAction == 'setStatus' && selectedState"
          ng-click="setStatusMultiple(selectedState)" class="btn btn-default btn-sm">
        <translate>Set status</translate>
      </a>
      <!-- category select -->
      <select ng-show="selectedAction == 'setCategory'" ng-model="selectedCategory" class="form-control input-sm">
        <option value="" translate>--- Select category ---</option>
        <option ng-repeat="category in categories" value="{{ category.id }}">
          {{ category.name }}
        </option>
        <option value="no_category_selected" translate>No category</option>
      </select>
      <!-- set category button -->
      <a ng-show="selectedAction == 'setCategory' && selectedCategory"
          ng-click="setCategoryMultiple(selectedCategory)" class="btn btn-default btn-sm">
        <translate>Set category</translate>
      </a>
      <!-- motionBlock select -->
      <select ng-show="selectedAction == 'setMotionBlock'" ng-model="selectedMotionBlock" class="form-control input-sm">
        <option value="" translate>--- Select motion block ---</option>
        <option ng-repeat="motionBlock in motionBlocks" value="{{ motionBlock.id }}">
          {{ motionBlock.title }}
        </option>
        <option value="no_motionBlock_selected" translate>No motion block</option>
      </select>
      <!-- set motion block button -->
      <a ng-show="selectedAction == 'setMotionBlock' && selectedMotionBlock"
         ng-click="setMotionBlockMultiple(selectedMotionBlock)" class="btn btn-default btn-sm">
        <translate>Set motion block</translate>
      </a>
      <!-- delete button -->
      <a ng-show="selectedAction == 'delete'"
        ng-bootbox-confirm="{{ 'Are you sure you want to delete all selected motions?' | translate }}"
        ng-bootbox-confirm-action="deleteMultiple()"
        class="btn btn-default btn-sm btn-danger">
        <i class="fa fa-trash fa-lg"></i>
        <translate>Delete selected motions</translate>
      </a>
    </div>
  </div>

  <div class="spacer-top-lg italic">
    {{ motionsFiltered.length }} /
    {{ motions.length }} {{ "motions" | translate }}<span ng-if="(motions|filter:{selected:true}).length > 0">,
    {{(motions|filter:{selected:true}).length}} {{ "selected" | translate }}</span>
  </div>

  <div class="os-table container-fluid">
    <div class="row header-row">
      <div class="col-xs-1 centered" ng-show="isSelectMode">
        <i class="fa text-danger pointer" ng-class=" selectedAll ? 'fa-check-square-o' : 'fa-square-o'"
          ng-click="checkAll()"></i>
      </div>
      <div class="col-xs-11 main-header">
        <span class="form-inline text-right pull-right">
          <!-- clear all filters -->
          <span class="sort-spacer pointer" ng-click="resetFilters()"
            ng-if="filter.areFiltersSet()" ng-disabled="isSelectMode"
            ng-class="{'disabled': isSelectMode}">
            <i class="fa fa-times-circle"></i>
            <translate>Filter</translate>
          </span>
          <!-- State filter -->
          <span uib-dropdown>
            <span class="pointer" id="dropdownState" uib-dropdown-toggle
              ng-class="{'bold': filter.multiselectFilters.state.length > 0, 'disabled': isSelectMode}"
              ng-disabled="isSelectMode">
              <translate>State</translate>
              <span class="caret"></span>
            </span>
            <ul class="dropdown-menu dropdown-menu-left" aria-labelledby="dropdownState">
              <li ng-repeat="state in states" ng-class="state.workflowHeader ? 'dropdown-header' : ''">
                <a ng-if="state.workflowHeader">
                  {{ state.headername | translate }}
                </a>
                <a href ng-if="!state.workflowHeader"
                  ng-click="operateStateFilter(state.id, isSelectMode)">
                  <i class="fa fa-check" ng-if="filter.multiselectFilters.state.indexOf(state.id) > -1"></i>
                  {{ state.name | translate }}
                </a>
              </li>
              <li class="divider"></li>
              <li>
                <a href ng-click="operateStateFilter(-1, isSelectMode)">
                  <i class="fa fa-check" ng-if="filter.multiselectFilters.category.indexOf(-1) > -1"></i>
                  <translate>done</translate>
                </a>
              </li>
            </ul>
          </span>
          <!-- recommendation filter -->
          <span uib-dropdown ng-if="config('motions_recommendations_by') != ''">
            <span class="pointer" id="dropdownRecommendation" uib-dropdown-toggle
              ng-class="{'bold': filter.multiselectFilters.recommendation.length > 0, 'disabled': isSelectMode}"
              ng-disabled="isSelectMode">
              <translate>Recommendation</translate>
              <span class="caret"></span>
            </span>
            <ul class="dropdown-menu dropdown-menu-left" aria-labelledby="dropdownRecommentation">
              <li ng-repeat="recommendation in recommendations" ng-class="recommendation.workflowHeader ? 'dropdown-header' : ''">
                <a ng-if="recommendation.workflowHeader">
                  {{ recommendation.headername | translate }}
                </a>
                <a href ng-if="!recommendation.workflowHeader"
                  ng-click="filter.operateMultiselectFilter('recommendation', recommendation.id, isSelectMode)">
                  <i class="fa fa-check" ng-if="filter.multiselectFilters.recommendation.indexOf(recommendation.id) > -1"></i>
                  {{ recommendation.recommendation_label | translate }}
                </a>
              </li>
              <li class="divider"></li>
              <li>
                <a href ng-click="filter.operateMultiselectFilter('recommendation', -1, isSelectMode)">
                  <i class="fa fa-check" ng-if="filter.multiselectFilters.recommendation.indexOf(-1) > -1"></i>
                  <translate>No recommendation set</translate>
                </a>
              </li>
            </ul>
          </span>
          <!-- Category filter -->
          <span uib-dropdown ng-if="categories.length > 0">
            <span class="pointer" id="dropdownCategory" uib-dropdown-toggle
              ng-class="{'bold': filter.multiselectFilters.category.length > 0, 'disabled': isSelectMode}"
              ng-disabled="isSelectMode">
              <translate>Category</translate>
              <span class="caret"></span>
            </span>
            <ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownCategory">
              <li ng-repeat="category in categories">
                <a href ng-click="filter.operateMultiselectFilter('category', category.id, isSelectMode)">
                  <i class="fa fa-check" ng-if="filter.multiselectFilters.category.indexOf(category.id) > -1"></i>
                  {{ category.name }}
                </a>
              </li>
              <li class="divider"></li>
              <li>
                <a href ng-click="filter.operateMultiselectFilter('category', -1, isSelectMode)">
                  <i class="fa fa-check" ng-if="filter.multiselectFilters.category.indexOf(-1) > -1"></i>
                  <translate>No category set</translate>
                </a>
              </li>
            </ul>
          </span>
          <!-- Motion block filter -->
          <span uib-dropdown ng-if="motionBlocks.length > 0">
            <span class="pointer" id="dropdownBlock" uib-dropdown-toggle
              ng-class="{'bold': filter.multiselectFilters.motionBlock.length > 0, 'disabled': isSelectMode}"
              ng-disabled="isSelectMode">
              <translate>Motion block</translate>
              <span class="caret"></span>
            </span>
            <ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownBlock">
              <li ng-repeat="block in motionBlocks">
                <a href ng-click="filter.operateMultiselectFilter('motionBlock', block.id, isSelectMode)">
                  <i class="fa fa-check" ng-if="filter.multiselectFilters.motionBlock.indexOf(block.id) > -1"></i>
                  {{ block.title }}
                </a>
              </li>
              <li class="divider"></li>
              <li>
                <a href ng-click="filter.operateMultiselectFilter('motionBlock', -1, isSelectMode)">
                  <i class="fa fa-check" ng-if="filter.multiselectFilters.motionBlock.indexOf(-1) > -1"></i>
                  <translate>No motion block set</translate>
                </a>
              </li>
            </ul>
          </span>
          <!-- Tag filter -->
          <span uib-dropdown ng-if="tags.length > 0">
            <span class="pointer" id="dropdownTag" uib-dropdown-toggle
              ng-class="{'bold': filter.multiselectFilters.tag.length > 0, 'disabled': isSelectMode}"
              ng-disabled="isSelectMode">
              <translate>Tag</translate>
              <span class="caret"></span>
            </span>
            <ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownTag">
              <li ng-repeat="tag in tags">
                <a href ng-click="filter.operateMultiselectFilter('tag', tag.id, isSelectMode)">
                  <i class="fa fa-check" ng-if="filter.multiselectFilters.tag.indexOf(tag.id) > -1"></i>
                  {{ tag.name }}
                </a>
              </li>
              <li class="divider"></li>
              <li>
                <a href ng-click="filter.operateMultiselectFilter('tag', -1, isSelectMode)">
                  <i class="fa fa-check" ng-if="filter.multiselectFilters.tag.indexOf(-1) > -1"></i>
                  <translate>No tag set</translate>
                </a>
              </li>
            </ul>
          </span>
          <!-- dropdown sort -->
          <span uib-dropdown>
            <span class="pointer" id="dropdownSort" uib-dropdown-toggle
              ng-class="{'disabled': isSelectMode}"
              ng-disabled="isSelectMode">
              <translate>Sort</translate>
              <span class="caret"></span>
            </span>
            <ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownSort">
              <!-- item -->
              <li>
                <a href ng-click="sort.toggle('agenda_item.getItemNumberWithAncestors()')">
                  <translate translate-comment="short form of agenda item">Item</translate>
                  <span class="spacer-right pull-right"></span>
                  <i class="pull-right fa"
                    ng-style="{'visibility': sort.column === 'agenda_item.getItemNumberWithAncestors()' ? 'visible' : 'hidden'}"
                    ng-class="sort.reverse ? 'fa-sort-desc' : 'fa-sort-asc'">
                  </i>
                </a>
              </li>
              <!-- all other sortOptions -->
              <li ng-repeat="option in sortOptions">
                <a href ng-click="sort.toggle(option.name)">
                {{ option.display_name | translate }}
                <span class="spacer-right pull-right"></span>
                  <i class="pull-right fa"
                    ng-style="{'visibility': sort.column === option.name ? 'visible' : 'hidden'}"
                    ng-class="sort.reverse ? 'fa-sort-desc' : 'fa-sort-asc'">
                  </i>
                </a>
              </li>
            </ul>
          </span>
          <!-- search field -->
          <span class="form-group">
            <span class="input-group">
              <span class="input-group-addon"><i class="fa fa-search"></i></span>
              <input type="text" ng-model="filter.filterString" class="form-control"
                 placeholder="{{ 'Search' | translate}}" ng-disabled="isSelectMode"
                 ng-change="filter.save()">
            </span>
          </span>
        </span>
        <!-- show all selected multiselectoptions -->
        <span>
          <!-- state -->
          <span ng-repeat="state in states" class="pointer spacer-left-lg"
            ng-if="!state.workflowHeader && filter.multiselectFilters.state.indexOf(state.id) > -1"
            ng-click="operateStateFilter(state.id, isSelectMode)"
            ng-class="{'disabled': isSelectMode}">
            <span class="nobr">
              <i class="fa fa-times-circle"></i>
              {{ state.name | translate }}
            </span>
          </span>
          <span ng-if="filter.multiselectFilters.state.indexOf(-1) > -1" class="pointer spacer-left-lg"
            ng-click="operateStateFilter(-1, isSelectMode)"
            ng-class="{'disabled': isSelectMode}">
            <i class="fa fa-times-circle"></i>
            <translate>done</translate>
          </span>
          <!-- category -->
          <span ng-repeat="category in categories" class="pointer spacer-left-lg"
            ng-if="filter.multiselectFilters.category.indexOf(category.id) > -1"
            ng-click="filter.operateMultiselectFilter('category', category.id, isSelectMode)"
            ng-class="{'disabled': isSelectMode}">
            <span class="nobr">
              <i class="fa fa-times-circle"></i>
              {{ category.name }}
            </span>
          </span>
          <span ng-if="filter.multiselectFilters.category.indexOf(-1) > -1" class="pointer spacer-left-lg"
            ng-click="filter.operateMultiselectFilter('category', -1, isSelectMode)"
            ng-class="{'disabled': isSelectMode}">
            <i class="fa fa-times-circle"></i>
            <translate>No category set</translate>
          </span>
          <!-- motion block -->
          <span ng-repeat="motionBlock in motionBlocks" class="pointer spacer-left-lg"
            ng-if="filter.multiselectFilters.motionBlock.indexOf(motionBlock.id) > -1"
            ng-click="filter.operateMultiselectFilter('motionBlock', motionBlock.id, isSelectMode)"
            ng-class="{'disabled': isSelectMode}">
            <span class="nobr">
              <i class="fa fa-times-circle"></i>
              {{ motionBlock.title }}
            </span>
          </span>
          <!-- recommendation -->
          <span ng-repeat="recommendation in recommendations" class="pointer spacer-left-lg"
            ng-if="filter.multiselectFilters.recommendation.indexOf(recommendation.id) > -1"
            ng-click="filter.operateMultiselectFilter('recommendation', recommendation.id, isSelectMode)"
            ng-class="{'disabled': isSelectMode}">
            <span class="nobr">
              <i class="fa fa-times-circle"></i>
              {{ recommendation.recommendation_label | translate }}
            </span>
          </span>
          <span ng-if="filter.multiselectFilters.motionBlock.indexOf(-1) > -1" class="pointer spacer-left-lg"
            ng-click="filter.operateMultiselectFilter('motionBlock', -1, isSelectMode)"
            ng-class="{'disabled': isSelectMode}">
            <i class="fa fa-times-circle"></i>
            <translate>No motion block set</translate>
          </span>
          <!-- tags -->
          <span ng-repeat="tag in tags" class="pointer spacer-left-lg"
            ng-if="filter.multiselectFilters.tag.indexOf(tag.id) > -1"
            ng-click="filter.operateMultiselectFilter('tag', tag.id, isSelectMode)"
            ng-class="{'disabled': isSelectMode}">
            <span class="nobr">
              <i class="fa fa-times-circle"></i>
              {{ tag.name }}
            </span>
          </span>
          <span ng-if="filter.multiselectFilters.tag.indexOf(-1) > -1" class="pointer spacer-left-lg"
            ng-click="filter.operateMultiselectFilter('tag', -1, isSelectMode)"
            ng-class="{'disabled': isSelectMode}">
            <i class="fa fa-times-circle"></i>
            <translate>No tag set</translate>
          </span>
        </span>
      </div>
    </div>

    <!-- main table -->
    <div class="row data-row" ng-mouseover="motion.hover=true"
      ng-mouseleave="motion.hover=false"
      ng-class="{'projected': motion.isProjected().length}"
      ng-repeat="motion in motionsFiltered = (motions
        | osFilter: filter.filterString : filter.getObjectQueryString
        | MultiselectFilter: stateFilter : getItemId.state
        | MultiselectFilter: filter.multiselectFilters.category : getItemId.category
        | MultiselectFilter: filter.multiselectFilters.motionBlock : getItemId.motionBlock
        | MultiselectFilter: filter.multiselectFilters.recommendation : getItemId.recommendation
        | MultiselectFilter: filter.multiselectFilters.tag : getItemId.tag
        | toArray
        | orderBy: sort.column : sort.reverse)
        | limitTo : itemsPerPage : limitBegin">

      <!-- select column -->
      <div ng-show="isSelectMode" os-perms="motions.can_manage" class="col-xs-1 centered">
        <i class="fa text-danger pointer" ng-click="motion.selected=!motion.selected"
        ng-class="motion.selected ? 'fa-check-square-o' : 'fa-square-o'"></i>
      </div>
      <!-- projector column -->
      <div class="col-xs-1 centered projector" os-perms="core.can_manage_projector">
        <projector-button model="motion" default-projector-id="defaultProjectorId">
        </projector-button>
      </div>
      <div class="no-projector-spacer" os-perms="!core.can_manage_projector"></div>
      <!-- main content column -->
      <div class="col-xs-6 content">
        <div class="id-col">
          <span ng-show="motion.identifier">
            {{ motion.identifier }}
          </span>
        </div>
        <div class="id-col-space">
          <!-- ID and title -->
          <div>
              <a class="title" ui-sref="motions.motion.detail({id: motion.id})">{{ motion.getTitle() }}</a>
            <i class="fa fa-paperclip" ng-if="motion.attachments_id.length > 0"></i>
          </div>
          <!-- state -->
          <div>
            <span ng-mouseover="motion.stateHover=true" ng-mouseleave="motion.stateHover=false"
                class="dropdown-hover-space">
              <span class="label" ng-class="'label-'+motion.state.css_class">
                {{ motion.getStateName() }}
              </span>
              <span os-perms="motions.can_manage" ng-class="{'hiddenDiv': !motion.stateHover}" uib-dropdown>
                <i class="fa fa-cog pointer" uib-dropdown-toggle id="stateDropdown{{ motion.id }}"></i>
                <ul class="dropdown-menu" aria-labelledby="stateDropdown{{ motion.id }}">
                  <li ng-repeat="state in motion.state.getNextStates()">
                    <a href ng-click="updateState(motion, state.id)">{{ state.action_word | translate }}</a>
                  </li>
                  <li class="divider" ng-if="motion.state.getNextStates().length"></li>
                  <li>
                    <a href ng-if="motion.isAllowed('reset_state')" ng-click="resetState(motion)">
                      <i class="fa fa-exclamation-triangle"></i>
                      <translate>Reset state</translate>
                    </a>
                  </li>
                </ul>
              </span>
            </span>
          </div>
          <!-- recommendation -->
          <div ng-if="motion.recommendation">
            <span ng-mouseover="motion.recommendationHover=true" ng-mouseleave="motion.recommendationHover=false"
                class="dropdown-hover-space">
              <span class="label" ng-class="'label-'+motion.recommendation.css_class" uib-tooltip="{{ config('motions_recommendations_by') }}">
                {{ motion.getRecommendationName() }}
              </span>
              <span os-perms="motions.can_manage" ng-class="{'hiddenDiv': !motion.recommendationHover}" uib-dropdown>
                <i class="fa fa-cog pointer" uib-dropdown-toggle id="recommendationDropdown{{ motion.id }}"></i>
                <ul class="dropdown-menu" aria-labelledby="recommendationDropdown{{ motion.id }}">
                  <li ng-repeat="recommendation in motion.state.getRecommendations()">
                    <a href ng-click="updateRecommendation(motion, recommendation.id)">
                      {{ recommendation.recommendation_label | translate }}
                    </a>
                  </li>
                  <li class="divider" ng-if="motion.state.getRecommendations().length && motion.recommendation"></li>
                  <li ng-if="motion.recommendation">
                    <a href ng-click="resetRecommendation(motion)">
                      <i class="fa fa-exclamation-triangle"></i>
                      <translate>Reset recommendation</translate>
                    </a>
                  </li>
                </ul>
              </span>
            </span>
          </div>
          <!-- Submitters -->
          <div ng-if="motion.submitters.length">
            <small>
              <span class="optional" translate>by</span>
              <span class="optional" ng-repeat="submitter in motion.submitters | limitTo:1">
                {{ submitter.get_full_name() }}<span ng-if="!$last">,</span></span><span ng-if="motion.submitters.length > 1">,
                ... [+{{ motion.submitters.length - 1 }}]</span>
              <!-- sorry for merging them together, but otherwise there would be a whitespace because of the new line -->
            </small>
          </div>
          <!-- hover menu -->
          <div ng-if="motion.isAllowed('update')" ng-class="{'hiddenDiv': !motion.hover}">
            <small>
              <span ng-if="motion.isAllowed('update')">
                <a href="" ng-click="openDialog(motion)" translate>Edit</a>
              </span>
              <span ng-if="motion.isAllowed('delete')"> &middot;
                <a href="" class="text-danger"
                    ng-bootbox-confirm="{{ 'Are you sure you want to delete this entry?' | translate }}<br><b>{{ motion.getTitle() }}</b>"
                    ng-bootbox-confirm-action="delete(motion)" translate>Delete</a>
              </span>
            </small>
          </div>

        </div>
      </div>
      <!-- additional content column -->
      <div class="col-xs-4 content" ng-style="{'width': isSelectMode ? 'calc(50% - 120px)' : 'calc(50% - 70px)'}">
        <div style="width: 60%;" class="optional">
          <small>
            <!-- Category dropdown for manage user -->
            <div os-perms="motions.can_manage" ng-show="categories.length > 0"
                ng-mouseover="motion.categoryHover=true"
                ng-mouseleave="motion.categoryHover=false">
              <span uib-dropdown>
                <span id="dropdownCategory{{ motion.id }}" class="pointer"
                  uib-dropdown-toggle uib-tooltip="{{ 'Set a category' | translate }}"
                  tooltip-class="nobr">
                  <span ng-if="motion.category == null" ng-show="motion.hover">
                    <i class="fa fa-sitemap"></i>
                    <i class="fa fa-plus"></i>
                  </span>
                  <span ng-if="motion.category != null">
                    <i class="fa fa-sitemap spacer-right"></i>
                    {{ motion.category.name }}
                    <i class="fa fa-cog fa-lg spacer-left" ng-show="motion.categoryHover"></i>
                  </span>
                </span>
                <ul class="dropdown-menu" aria-labelledby="dropdownCategory{{ motion.id }}">
                  <li ng-repeat="category in categories">
                    <a href ng-click="toggleCategory(motion, category)">
                      <i class="fa fa-check" ng-if="category.id == motion.category.id"></i>
                      {{ category.name }}
                    </a>
                  </li>
                </ul>
              </span>
            </div>
            <!-- Category string for normal user -->
            <div os-perms="!motions.can_manage" ng-show="motion.category != null">
              <i class="fa fa-sitemap spacer-right"></i>
              {{ motion.category.name }}
            </div>

            <!-- Motion block dropdown for manage user -->
            <div os-perms="motions.can_manage" ng-show="motionBlocks.length > 0"
                ng-mouseover="motion.motionBlockHover=true"
                ng-mouseleave="motion.motionBlockHover=false">
              <span uib-dropdown>
                <span id="dropdownMotionBlock{{ motion.id }}" class="pointer"
                  uib-dropdown-toggle uib-tooltip="{{ 'Set a motion block' | translate }}"
                  tooltip-class="nobr">
                  <span ng-if="motion.motionBlock == null" ng-show="motion.hover">
                    <i class="fa fa-th-large"></i>
                    <i class="fa fa-plus"></i>
                  </span>
                  <span ng-if="motion.motionBlock != null">
                    <i class="fa fa-th-large spacer-right"></i>
                    {{ motion.motionBlock.title }}
                    <i class="fa fa-cog fa-lg spacer-left" ng-show="motion.motionBlockHover"></i>
                  </span>
                </span>
                <ul class="dropdown-menu" aria-labelledby="dropdownMotionBlock{{ motion.id }}">
                  <li ng-repeat="motionBlock in motionBlocks">
                    <a href ng-click="toggleMotionBlock(motion, motionBlock)">
                      <i class="fa fa-check" ng-if="motionBlock.id == motion.motionBlock.id"></i>
                      {{ motionBlock.title }}
                    </a>
                  </li>
                </ul>
              </span>
            </div>
            <!-- Motion block string for normal user -->
            <div os-perms="!motions.can_manage" ng-show="motion.motionBlock != null">
              <i class="fa fa-th-large spacer-right"></i>
              {{ motion.motionBlock.title }}
            </div>

            <!-- Tag dropdown for manage user -->
            <div os-perms="motions.can_manage" ng-show="tags.length > 0"
                ng-mouseover="motion.tagHover=true"
                ng-mouseleave="motion.tagHover=false">
              <span uib-dropdown>
                <span id="dropdownTags{{ motion.id }}" class="pointer"
                  uib-dropdown-toggle uib-tooltip="{{ 'Add a tag' | translate }}"
                  tooltip-class="nobr">
                  <span ng-if="motion.tags.length == 0" ng-show="motion.hover">
                    <i class="fa fa-tags"></i>
                    <i class="fa fa-plus"></i>
                  </span>
                  <span ng-if="motion.tags.length > 0">
                    <i class="fa fa-tags spacer-right"></i>
                    <span ng-repeat="tag in motion.tags">
                      {{ tag.name }}<span ng-if="!$last">,</span>
                    </span>
                    <i class="fa fa-cog fa-lg spacer-left" ng-show="motion.tagHover"></i>
                  </span>
                </span>
                <ul class="dropdown-menu" aria-labelledby="dropdownTags{{ motion.id }}">
                  <li ng-repeat="tag in tags">
                    <a href ng-click="toggleTag(motion, tag)">
                      <i class="fa fa-check" ng-if="hasTag(motion, tag)"></i>
                      {{ tag.name }}
                    </a>
                  </li>
                </ul>
              </span>
            </div>
            <!-- Tag string for normal user -->
            <div os-perms="!motions.can_manage" ng-show="motion.tags.length > 0">
              <i class="fa fa-tags spacer-right"></i>
              <span ng-repeat="tag in motion.tags">
                {{ tag.name }}<span ng-if="!$last">,</span>
              </span>
            </div>

            <!-- Origin -->
            <div ng-if="motion.origin">
              <i class="fa fa-share spacer-right" uib-tooltip="{{ 'Origin' | translate }}"></i>
                <div class="popover-wrapper">
                  <span editable-text="motion.origin" onaftersave="save(motion)">
                    {{ motion.origin | limitTo:25 }}{{ motion.origin.length > 25 ? '...' : '' }}
                  </span>
                </div>
            </div>
          </small>
        </div>
        <div style="width: 10%;" class="pull-right optional">
          <div class="centered" ng-if="config('motions_min_supporters') != 0"
            uib-tooltip="{{ motion.supporters.length }} {{ 'Supporters' | translate }}
            {{ (config('motions_min_supporters') - motion.supporters.length) > 0 ? '(' +  (config('motions_min_supporters') - motion.supporters.length) + ' ' + ('needed' | translate) + ')': '' }}"
            tooltip-class="nobr">
            <span class="badge"
              ng-class="{'badge-info': motion.supporters.length < config('motions_min_supporters')}">
              {{ motion.supporters.length }}
            </span>
          </div>
        </div>
        <div style="width: 30%;" class="pull-right">
          <div class="centered">{{ motion.agenda_item.getItemNumberWithAncestors() }}</div>
        </div>
      </div>
    </div> <!-- data row -->

    <ul uib-pagination
        ng-show="motionsFiltered.length > itemsPerPage"
        total-items="motionsFiltered.length"
        items-per-page="itemsPerPage"
        ng-model="currentPage"
        ng-change="pageChanged()"
        class="pagination-sm"
        direction-links="false"
        boundary-links="true"
        first-text="&laquo;"
        last-text="&raquo;">
    </ul>

  </div> <!-- container -->
</div> <!-- details -->
