<!--

    Copyright © 2016-2018 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" class="tb-kv-map">
    <label translate class="tb-title no-padding">{{ vm.titleText }}</label>
    <div flex layout="row"
         ng-repeat="keyVal in vm.kvList track by $index"
         style="max-height: 40px;" layout-align="start center">
        <md-input-container flex md-no-float class="md-block"
                            style="margin: 10px 0px 0px 0px; max-height: 40px;">
            <input placeholder="{{ (vm.keyPlaceholderText ? vm.keyPlaceholderText : 'key-val.key') | translate }}"
                   ng-disabled="vm.disabled" ng-required="true" name="key" ng-model="keyVal.key">
        </md-input-container>
        <md-input-container flex md-no-float class="md-block"
                            style="margin: 10px 0px 0px 0px; max-height: 40px;">
            <input placeholder="{{ (vm.valuePlaceholderText ? vm.valuePlaceholderText : 'key-val.value') | translate }}"
                   ng-disabled="vm.disabled" ng-required="true" name="value" ng-model="keyVal.value">
        </md-input-container>
        <md-button ng-show="!vm.disabled" ng-disabled="$root.loading" class="md-icon-button md-primary"
                   ng-click="vm.removeKeyVal($index)"
                   aria-label="{{ 'action.remove' | translate }}">
            <md-tooltip md-direction="top">
                {{ 'key-val.remove-entry' | translate }}
            </md-tooltip>
            <md-icon aria-label="{{ 'action.delete' | translate }}"
                     class="material-icons">
                close
            </md-icon>
        </md-button>
    </div>
    <span ng-show="!vm.kvList.length"
          layout-align="center center" ng-class="{'disabled': vm.disabled}"
          class="no-data-found" translate>{{vm.noDataText ? vm.noDataText : 'key-val.no-data'}}</span>
    <div>
        <md-button ng-show="!vm.disabled" ng-disabled="$root.loading" class="md-primary md-raised"
                   ng-click="vm.addKeyVal()"
                   aria-label="{{ 'action.add' | translate }}">
            <md-tooltip md-direction="top">
                {{ 'key-val.add-entry' | translate }}
            </md-tooltip>
            <span translate>action.add</span>
        </md-button>
    </div>
</section>
