<!--

    Copyright © 2016-2020 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.

-->
<section layout='column'>
    <md-autocomplete md-input-name="gateway" flex
                     ng-required="tbRequired"
                     md-no-cache="true"
                     ng-model="gateway"
                     md-selected-item="gateway"
                     md-search-text="gatewaySearchText"
                     md-items="item in gatewayNameSearch(gatewaySearchText)"
                     md-item-text="item.name"
                     tb-keydown="gatewayNameEnter($event)"
                     tb-keypress="gatewayNameEnter($event)"
                     md-min-length="0"
                     md-clear-button="true"
                     md-floating-label="{{ 'gateway.gateway-name' | translate }}"
                     md-menu-class="tb-gateway-autocomplete"
                     md-input-class="tb-test"
                     md-menu-container-class="tb-gateway-autocomplete-container">
        <md-item-template>
            <span md-highlight-text="gatewaySearchText" md-highlight-flags="^i">{{item.name}}</span>
        </md-item-template>
        <md-not-found>
            <div class="tb-not-found">
                <div class="tb-no-gateway" ng-if="textIsEmpty(gatewaySearchText)">
                    <span translate>gateway.no-gateway-found</span>
                </div>
                <div ng-if="!textIsEmpty(gatewaySearchText)">
                    <span translate translate-values='{ item: "{{gatewaySearchText | truncate:true:6:&apos;...&apos;}}" }'>gateway.no-gateway-matching</span>
                    <a translate ng-click="createNewGatewayDialog($event, gatewaySearchText)">gateway.create-new-gateway</a>
                </div>
            </div>
        </md-not-found>
        <div ng-messages="theForm.gateway.$error">
            <div ng-message="required" translate>gateway.gateway-name-required</div>
        </div>
    </md-autocomplete>
</section>
