<!-- LIST PAGE -->
<div class="container" id="list-container">
    <div class="row">
        <div class="col-md-8">
            <div class="component">
                <div class="title">
                    <div class="btn-group btn-group-sm pull-right">
                        <div class="btn-group btn-group-sm">
                            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
                                    translate="GENERAL.ACTION.SHOW-RESULTS" translate-value-size="{{'GENERAL.RESULT-SIZES.' + filter.resultSize | translate}}">
                                &nbsp;
                                <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu">
                            	<li ng-repeat="resultSize in config.filter.resultSizes"><a href="" ng-click="filter.setResultSize(resultSize)">{{'GENERAL.RESULT-SIZES.' + resultSize.toString() | translate}}</a></li>
                            </ul>
                        </div>
                        <button type="button" class="btn btn-default" ng-click="filter.toggleOrder()">
                        	<i class="glyphicon" ng-class="{'glyphicon-sort-by-attributes': filter.order == 'asc', 'glyphicon-sort-by-attributes-alt': filter.order == 'desc'}"></i>
                        </button>
                    </div>
                    <div class="btn-group btn-group-sm pull-right">
                    	<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
                                translate="GENERAL.ACTION.SORT-BY" translate-value-sort="{{filter.sort.name | translate}}">
                            &nbsp;
                            <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu">
                           <li ng-repeat="sort in filter.sortObjects"><a href="" ng-click="filter.setSort(sort)">{{sort.name | translate}}</a></li>
                        </ul>
                    </div>
                    <div class="btn-group btn-group-sm pull-right">
                        <a class="btn btn-default" role="button"
                           title="{{'GENERAL.ACTION.REFRESH-LIST' | translate}}"
                           ng-click="filter.refresh();">
                            <i class="glyphicon glyphicon-refresh"></i>
                        </a>
                    </div>
                    <div class="pull-right loading" ng-show="filter.loading">
                    	<i class="glyphicon glyphicon-refresh"></i>
                    </div>

                    <h2 translate="CASE-INSTANCES.TITLE"></h2>
                </div>

                <div class="grid-wrapper" id="case-instances">
                    <div class="grid-message" ng-if="caseInstances.size > 0">
                         <span>{{'CASE-INSTANCES.LIST-MESSAGE' | translate:caseInstances}}</span>
                    </div>
                    <div class="grid-message" ng-if="caseInstances.size == 0">
                         <span>{{'CASE-INSTANCES.LIST-MESSAGE-EMPTY' | translate}}</span>
                    </div>
                    <div ng-grid="gridInstances" class="gridStyle" ng-if="gridInstances && caseInstances.data"/>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="component tip-left">
                <div class="title">
                    <div class="btn-group btn-group-sm pull-right" ng-show="filter.supportedProperties.length > 0">
                        <button type="button" class="btn btn-default" data-toggle="dropdown">
                            <i class="glyphicon glyphicon-plus"></i>
                        </button>
                        <ul class="dropdown-menu">
                            <li ng-repeat="prop in filter.supportedProperties"><a href="" ng-click="addFilterProperty(prop)">{{prop.name | translate}}</a></li>
                        </ul>
                    </div>
                    <div class="pull-right">
                        <a class="action" ng-click="clearFilters()" translate="GENERAL.ACTION.CLEAR-FILTERS"></a>
                    </div>
                    <h2 translate="GENERAL.TITLE.FILTERS"></h2>
                </div>
                <div class="section">
                    <div class="subtitle"><label translate="CASE-INSTANCES.FILTER.CASE-DEFINITION"></label> </div>
                    <div>
                        <select ui-select2
                                data-placeholder="{{'CASE-INSTANCES.FILTER.ALL-CASE-DEFINITIONS' | translate}}"
                         		ng-model="filter.caseDefinition"
                         		ng-change="caseDefinitionFilterChanged()"
                         		style="min-width:250px">
                            <option value=""></option>
                         	<option value="-1">{{'CASE-INSTANCES.FILTER.ALL-CASE-DEFINITIONS' | translate}}</option>
                         	<option ng-title="123" ng-repeat="caseDefinition in caseDefinitionsCache.data" value="{{caseDefinition.id}}">{{caseDefinition.name ? caseDefinition.name : caseDefinition.key}} (v{{caseDefinition.version}})</option>
                         </select>
                    </div>
                </div>
                <div class="section" ng-if="filter.properties.finished !== undefined">
                    <div class="subtitle"><label for="filter-finished" translate="CASE-INSTANCES.FILTER.STATUS"></label> </div>
                    <div class="input-group input-group-sm" id="filter-state">
                       <div class="btn-group btn-group-sm">
                        <button type="button" id="filter-finished" class="btn btn-default dropdown-toggle form-control" data-toggle="dropdown">
                            <span class="pull-right">
                                <span class="caret"></span>
                            </span>
                            {{filter.getLabelForOption('finished') | translate}}
                        </button>
                        <ul class="dropdown-menu">
                            <li ng-repeat="state in filter.options.finished"><a href="" ng-click="filter.selectOption('finished', state)">{{state.name | translate}}</a></li>
                        </ul>
                    </div>
                    </div>
                </div>
                <div class="section" ng-if="filter.properties.caseBusinessKey!== undefined">
                    <div class="subtitle"><label for="filter-caseBusinessKey" translate="CASE-INSTANCES.FILTER.BUSINESS-KEY"></label> </div>
                    <div class="input-group input-group-sm">
                        <input id="filter-caseBusinessKey" type="text" class="form-control" value="" ng-model="filter.properties.caseBusinessKey" ng-change="filter.refreshDelayed()">
                    </div>
                </div>
                <div class="section" ng-if="filter.properties.startedBefore !== undefined">
                  <div class="subtitle"><label for="filter-startedBefore" translate="CASE-INSTANCES.FILTER.STARTED-BEFORE"></label> </div>
               	  <div class="input-group input-group-sm">
               	  	<span class="input-group-addon"><span class="glyphicon glyphicon-time"></span></span>
	              	<input id="filter-startedBefore" type="text" class="form-control" ng-model="filter.properties.startedBefore"
                           ng-change="filter.refreshDelayed()"
                           datepicker-popup="dd/MM/yyyy"
                           is-open="startedBeforePicker.isOpen" ng-click="startedBeforePicker.isOpen=true"/>
	              </div>
	            </div>
                <div class="section" ng-if="filter.properties.startedAfter !== undefined">
	              <div class="subtitle"><label for="filter-startedAfter" translate="CASE-INSTANCES.FILTER.STARTED-AFTER"></label> </div>
               	  <div class="input-group input-group-sm">
               	  	<span class="input-group-addon"><span class="glyphicon glyphicon-time"></span></span>
	              	<input id="filter-startedAfter" type="text" class="form-control" ng-model="filter.properties.startedAfter"
                           ng-change="filter.refreshDelayed()"
                           datepicker-popup="dd/MM/yyyy"
                           is-open="startedAfterPicker.isOpen" ng-click="startedAfterPicker.isOpen=true"/>
	              </div>
	            </div>
	            <div class="section" ng-if="filter.properties.finishedBefore !== undefined">
                  <div class="subtitle"><label for="filter-finishedBefore" translate="CASE-INSTANCES.FILTER.ENDED-BEFORE"></label> </div>
               	  <div class="input-group input-group-sm">
               	  	<span class="input-group-addon"><span class="glyphicon glyphicon-time"></span></span>
	              	<input id="filter-finishedBefore" type="text" class="form-control" ng-model="filter.properties.finishedBefore"
                           ng-change="filter.refreshDelayed()"
                           datepicker-popup="dd/MM/yyyy"
                           is-open="finishedBeforePicker.isOpen" ng-click="finishedBeforePicker.isOpen=true"/>
	              </div>
	            </div>
                <div class="section" ng-if="filter.properties.finishedAfter !== undefined">
	              <div class="subtitle"><label for="filter-finishedAfter" translate="CASE-INSTANCES.FILTER.ENDED-AFTER"></label> </div>
               	  <div class="input-group input-group-sm">
               	  	<span class="input-group-addon"><span class="glyphicon glyphicon-time"></span></span>
	              	<input id="filter-finishedAfter" type="text" class="form-control" ng-model="filter.properties.finishedAfter"
                           ng-change="filter.refreshDelayed()"
                           datepicker-popup="dd/MM/yyyy"
                           is-open="finishedAfterPicker.isOpen" ng-click="finishedAfterPicker.isOpen=true"/>
	              </div>
	            </div>

	            <div class="section clearfix" ng-repeat="varFilter in filter.properties.variables">
	              <div class="seperator" ng-if="$index > 0"></div>
	              <div class="subtitle"><label translate="CASE-INSTANCES.FILTER.VARIABLE"></label> </div>
               	  <div class="inline-button input-group-sm">
	              		<div class="pull-right btn-group">
	                        <button ng-disabled="varFilter.type.id == 'boolean'" tabindex="-1" type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown">
	                             {{varFilter.operator.sign}} <i class="caret"></i>
	                        </button>
	                        <ul class="dropdown-menu">
	                            <li><a href="" ng-click="setVariableFilterOperator(varFilter, operator)" ng-repeat="operator in variableFilterOperators">{{operator.name}}</a></li>
	                        </ul>
	                    </div>
	              		<input id="filter-variable-name-{{$index}}" type="text" class="form-control" ng-model="varFilter.name" ng-change="filter.refreshDelayed()" placeholder="{{'CASE-INSTANCES.FILTER.VARIABLE-NAME' | translate}}" />
	              </div>
               	  <div class="inline-button wide input-group-sm" >
	              		<div class="pull-right btn-group">
	                        <button tabindex="-1" ng-disabled="varFilter.operator.id == 'like'" type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown">
	                           {{varFilter.type.name}} <i class="caret"></i>
	                        </button>
	                        <ul class="dropdown-menu">
	                            <li><a href="" ng-click="setVariableFilterType(varFilter, type)" ng-repeat="type in variableFilterTypes" >{{type.name}}</a></li>
	                        </ul>
	                    </div>
	              		<input ng-if="varFilter.type.id != 'date' && varFilter.type.id != 'boolean'" id="filter-variable-value-{{$index}}" type="text" class="form-control" ng-model="varFilter.value" ng-change="filter.refreshDelayed()" placeholder="{{'CASE-INSTANCES.FILTER.VARIABLE-VALUE' | translate}}" />
	              		<input ng-if="varFilter.type.id == 'date'" id="filter-variable-value-{{$index}}" type="text" class="form-control" ng-model="varFilter.value"
                               ng-change="filter.refresh()"
                               datepicker-popup="dd/MM/yyyy"
                               is-open="varValuePicker.isOpen" ng-click="varValuePicker.isOpen=true"/>
	              		<div class="checkbox" ng-if="varFilter.type.id == 'boolean'">
						    <label>
						      <input type="checkbox" ng-change="filter.refresh()" ng-model="varFilter.value">{{'CASE-INSTANCES.FILTER.VARIABLE-BOOLEAN-VALUE' | translate:varFilter}}
						    </label>
  						</div>
	              </div>
	            </div>
	            <div class="section" ng-if="filter.properties.tenantIdLike !== undefined">
                    <div class="subtitle"><label for="filter-tenantId" translate="CASE-INSTANCES.FILTER.TENANT-ID"></label> </div>
                    <div class="input-group input-group-sm">
                        <input id="filter-tenantId" type="text" class="form-control" value="" ng-model="filter.properties.tenantIdLike" ng-change="filter.refreshDelayed()">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
