<!--
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 id="list-controller" ng-controller="QDR.ListController"  ng-include="tmplListTree"></div>

<script type="text/ng-template" id="listGrid.html">
    <div class="row-fluid qdrListActions">
        <ul class="nav nav-tabs">
            <li ng-repeat="mode in modes" ng-show="isValid(mode)" ng-click="selectMode(mode)" ng-class="{active : isModeSelected(mode)}" title="{{mode.title}}" ng-bind-html-unsafe="mode.content"> </li>
        </ul>
        <h4>{{selectedRecordName}}</h4>
        <div ng-show="currentMode.id === 'attributes'" class="selectedItems">
            <div ng-show="selectedRecordName === selectedEntity" class="no-content">There are no {{selectedEntity | safePlural}}</div>
            <div ng-hide="selectedRecordName === selectedEntity" ng-grid="details"></div>
        </div>
        <div ng-show="currentMode.id === 'delete'">
            <div class="delete" ng-show="selectedRecordName !== selectedEntity">
                <button class="btn btn-primary" ng-click="remove()">Delete</button> {{selectedRecordName}}
            </div>
            <div ng-hide="selectedRecordName !== selectedEntity">
                There are no {{selectedEntity | safePlural}}
            </div>
        </div>
        <div class="operations" ng-show="currentMode.id === 'operations'">
            <fieldset ng-show="operation != ''">
                <table>
                    <tr>
                        <th>Attribute</th>
                        <th>Value</th>
                    </tr>
                <tr title="{{attribute.title}}" ng-repeat="attribute in detailFields">
                    <td><label for="{{attribute.name}}">{{attribute.name | humanify}}</label></td>
                    <!-- we can't do <input type="{angular expression}"> because... jquery throws an exception because... -->
                    <td>
                    <div ng-if="attribute.input == 'input'">
                        <!-- ng-pattern="testPattern(attribute)" -->
                        <div ng-if="attribute.type == 'number'"><input type="number" name="{{attribute.name}}" id="{{attribute.name}}" ng-model="attribute.rawValue" ng-required="attribute.required" ng-class="{required: attribute.required, unique: attribute.unique}" class="ui-widget-content ui-corner-all"/><span ng-if="attribute.required" title="required" class="required-indicator"></span><span ng-if="attribute.unique" title="unique" class="unique-indicator"></span></div>
                        <div ng-if="attribute.type == 'text'"><input type="text" name="{{attribute.name}}" id="{{attribute.name}}" ng-model="attribute.attributeValue" ng-required="attribute.required" ng-class="{required: attribute.required, unique: attribute.unique}" class="ui-widget-content ui-corner-all"/><span ng-if="attribute.required" title="required" class="required-indicator"></span><span ng-if="attribute.unique" title="unique" class="unique-indicator"></span></div>
                        <div ng-if="attribute.type == 'textarea'"><textarea name="{{attribute.name}}" id="{{attribute.name}}" ng-model="attribute.attributeValue" ng-required="attribute.required" ng-class="{required: attribute.required, unique: attribute.unique}" class="ui-widget-content ui-corner-all"></textarea><span ng-if="attribute.required" title="required" class="required-indicator"></span><span ng-if="attribute.unique" title="unique" class="unique-indicator"></span></div>
                        <span ng-if="attribute.type == 'disabled'" >{{getAttributeValue(attribute)}}</span>
                    </div>
                    <div ng-if="attribute.input == 'select'">
                        <select id="{{attribute.name}}" ng-model="attribute.selected" ng-required="attribute.required" ng-class="{required: attribute.required, unique: attribute.unique}" ng-options="item for item in attribute.rawtype track by item"></select>
                        <span ng-if="attribute.required" title="required" class="required-indicator"></span><span ng-if="attribute.unique" title="unique" class="unique-indicator"></span>
                    </div>
                    <div ng-if="attribute.input == 'boolean'" class="boolean">
                        <label><input type="radio" ng-model="attribute.rawValue" ng-value="true"> True</label>
                        <label><input type="radio" ng-model="attribute.rawValue" ng-value="false"> False</label>
                    </div>
                    </td>
                </tr>
                <tr><td></td><td><button class="btn btn-primary" type="button" ng-click="ok()">{{operation | Pascalcase}}</button></td></tr>
                </table>
            </fieldset>
        </div>
        <div ng-show="currentMode.id === 'log'">
            <div ng-if="logResults.length > 0">
                <table class="log-entry" ng-repeat="entry in logResults track by $index">
                    <tr>
                        <td align="left" colspan="2">{{entry.time}}</td>
                    </tr>
                    <tr>
                        <td>Type</td><td>{{entry.type}}</td>
                    </tr>
                    <tr>
                        <td>Source</td><td>{{entry.source}}:{{entry.line}}</td>
                    </tr>
                    <tr>
                        <td valign="middle">Message</td><td valign="middle"><pre>{{entry.message}}</pre></td>
                    </tr>
                </table>
            </div>
            <div ng-if="logResults.length == 0 && !fetchingLog">No log entries for {{selectedRecordName}}</div>
            <div ng-if="fetchingLog">Fetching logs for {{selectedRecordName}}</div>
        </div>
    </div>
</script>
