<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you 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 class="custom-config-widget suggestion-dropdown config-flex-row">
    <label class="control-label" for="{{item.name}}">
        <span class="label-spec-configuration">{{item.label || item.name}}</span>
        <span class="info-spec-configuration">
            <i class="fa fa-fw fa-info-circle" popover-trigger="'mouseenter'"
                popover-title="{{item.label || item.name}}"
                uib-popover-template="'blueprint-composer/component/spec-editor/config-info.html'"
                popover-class="spec-editor-popover" popover-placement="top-left" popover-append-to-body="true"></i>
            </span>
    </label>

    <span class="label-rhs-buttons">
        <span class="spacer"> </span>
        <span class="custom-widget-enable-button custom-widget-active">
            <i class="fa fa-fw fa-sun-o" ng-click="specEditor.toggleCustomConfigWidgetMode(item, false)" aria-hidden="true" title="{{specEditor.getCustomConfigWidgetModeTitle(item)}} [{{item.name}}]"></i>
            <span class="sr-only">{{specEditor.getCustomConfigWidgetModeTitle(item)}} [{{item.name}}]</span>
        </span>
    </span>

    <div class="control-value" ng-class="{ 'inline-control': item.widgetMode==='boolean', 'unset': !defined(config[item.name]), 'has-default': defined(item.defaultValue) && item.defaultValue!=null }">
        <div class="hide-when-collapsed extra-label" ng-if="params['label-expanded']">
            {{ params['label-expanded'] || "" }}
        </div>
        <div class="config-flex-row">
            <span class="hide-when-expanded inline-label extra-label" ng-if="params['label-collapsed']">{{ params['label-collapsed'] || "" }}</span>
            <div class="input-group">
                <span class="main-control span-for-rounded-edge">
                  <textarea ng-model="config[item.name]" class="form-control rounded-edge" name="{{item.name}}" id="{{item.name}}" auto-grow
                          placeholder="{{defined(config[item.name]) ? null : item.defaultValue=='' || item.defaultValue==null ? '(empty)' : item.defaultValue}}"
                          ng-focus="specEditor.recordFocus(item)" on-enter="specEditor.advanceOutToFormGroupInPanel"
                          uib-typeahead="suggestion.value for suggestion in getSuggestions() | filter:{value:$viewValue}"
                          typeahead-min-length=0
                          typeahead-template-url="SuggestionTemplate.html"></textarea>
                </span>
                <span class="input-group-btn dsl-wizard-button rounded-edge" ng-if="specEditor.isDslWizardButtonAllowed(item.name)">
                    <a ui-sref="main.graphical.edit.dsl({entityId: model._id, for: item.name})" class="btn btn-default" title="Open in DSL editor"><i class="fa fa-bolt"></i></a>
                </span>
            </div>
        </div>
    </div>
    
    <small ng-repeat="issue in model.issues | filter:{ref: item.name}:true" class="help-block issue" ng-bind-html="issue.message"></small>

</div>

<!--TYPEAHEAD TEMPLATE :: START-->
<script type="text/ng-template" id="SuggestionTemplate.html" defer-to-preexisting-id="true">
    <div class="dropdown-item">
        <span class="dropdown-item-value" ng-bind-html="match.model.value | uibTypeaheadHighlight:query"></span>
        <p class="dropdown-item-description" ng-if="match.model.description">{{ match.model.description }}</p>
    </div>
</script>
<!--TYPEAHEAD TEMPLATE :: END-->
