<!--

    Copyright © 2016-2017 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<div layout='column' class="tb-entity-filter">
    <md-input-container class="md-block">
        <label>{{ 'alias.filter-type' | translate }}</label>
        <md-select required name="filterType"
                   ng-model="filter.type" aria-label="{{ 'alias.filter-type' | translate }}">
            <md-option ng-repeat="type in aliasFilterTypes" ng-value="type.value">
                {{type.name | translate}}
            </md-option>
        </md-select>
        <div ng-messages="theForm.filterType.$error">
            <div ng-message="required" translate>alias.filter-type-required</div>
        </div>
    </md-input-container>
    <section layout="column" ng-if="filter.type == types.aliasFilterType.entityList.value" id="entityListFilter">
        <tb-entity-type-select
                ng-model="filter.entityType"
                the-form="theForm"
                tb-required="true"
                allowed-entity-types="allowedEntityTypes">
        </tb-entity-type-select>
        <tb-entity-list
                ng-model="filter.entityList"
                tb-required="true"
                entity-type="filter.entityType">
        </tb-entity-list>
    </section>
    <section flex layout="column" ng-if="filter.type == types.aliasFilterType.entityName.value" id="entityNameFilter">
        <tb-entity-type-select
                ng-model="filter.entityType"
                the-form="theForm"
                tb-required="true"
                allowed-entity-types="allowedEntityTypes">
        </tb-entity-type-select>
        <md-input-container class="md-block">
            <label translate>entity.name-starts-with</label>
            <input required name="entityNameFilter"
                   ng-model="filter.entityNameFilter"
                   aria-label="{{ 'entity.name-starts-with' | translate }}">
            <div ng-messages="theForm.entityNameFilter.$error">
                <div ng-message="required" translate>entity.entity-name-filter-required</div>
            </div>
        </md-input-container>
    </section>
    <section layout="column" ng-if="filter.type == types.aliasFilterType.stateEntity.value" id="stateEntityFilter">
    </section>
    <section layout="column" ng-if="filter.type == types.aliasFilterType.assetType.value" id="assetTypeFilter">
        <tb-entity-subtype-autocomplete
                tb-required="true"
                the-form="theForm"
                ng-model="filter.assetType"
                entity-type="types.entityType.asset">
        </tb-entity-subtype-autocomplete>
        <md-input-container class="md-block">
            <label translate>asset.name-starts-with</label>
            <input name="assetNameFilter"
                   ng-model="filter.assetNameFilter"
                   aria-label="{{ 'asset.name-starts-with' | translate }}">
        </md-input-container>
    </section>
    <section layout="column" ng-if="filter.type == types.aliasFilterType.deviceType.value" id="deviceTypeFilter">
        <tb-entity-subtype-autocomplete
                tb-required="true"
                the-form="theForm"
                ng-model="filter.deviceType"
                entity-type="types.entityType.device">
        </tb-entity-subtype-autocomplete>
        <md-input-container class="md-block">
            <label translate>device.name-starts-with</label>
            <input name="deviceNameFilter"
                   ng-model="filter.deviceNameFilter"
                   aria-label="{{ 'device.name-starts-with' | translate }}">
        </md-input-container>
    </section>
</div>
