<div ng-controller="entidadeController">

    <div class="modal-header">
        <h3>Entidades</h3>
        <nav class="navbar navbar-default" role="navigation">
            <div class="container-fluid">
                <ul class="nav navbar-nav">
                    <li ng-click="" ng-class="{active:true}"><a href="">Entidades</a></li>
                </ul>
                
                
                <form class="navbar-form navbar-right" role="navigation" ng-show="true">
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="Procurar..." ng-model="procurar_ent">
                    </div>

                    <button popover-placement="top"
                            popover-trigger="mouseenter"
                            data-popover="Remover"
                            ng-click="confirmarApagarEntidade(selectedEntidade)"
                            type="button"
                            ng-show="items.length>0 && selectedEntidade!=null"
                            ng-disabled="selected.item.perm.PApagar==false"
                            class="btn btn-default">
                        <span class="glyphicon glyphicon-remove"></span>
                    </button>
                    <button popover-placement="top"
                            popover-trigger="mouseenter"
                            data-popover="Nova Entidade"
                            ng-click="entidadeEditRow()"
                            type="button"
                            ng-disabled="selected.item.perm.PCriar==false"
                            class="btn btn-default">
                        <span class="glyphicon glyphicon-plus"></span>
                    </button>
                    <button popover-placement="top"
                            popover-trigger="mouseenter"
                            data-popover="Editar"
                            ng-click="entidadeEditRow(selectedEntidade)"
                            type="button"
                            ng-show="items.length>0 && selectedEntidade!=null"
                            ng-disabled="selected.item.perm.PEditar==false"
                            class="btn btn-default">
                        <span class="glyphicon glyphicon-pencil"></span>
                    </button>
                </form>
            </div>
        </nav>

    </div>

    <div class="modal-body">

        
        <div style="height:270px; overflow:auto" ng-show="true" ng-init="carregarEntidades()">
            <div class="list-group">
                <a ng-click="selEntidade(ent); selected.item.FK_Entidade=ent.PK_Entidade; selected.item.NomeEntidade=ent.NomeEntidade"
                   href="javascript:void(0)"
                   ng-repeat="ent in items | filter:procurar_ent"
                   class="list-group-item"
                   ng-class="{active:ent.PK_Entidade==selected.item.FK_Entidade}">
                   {{ent.NomeEntidade}}

                </a>

            </div>
            
        </div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-primary"
                ng-click="ok()"
                ng-disabled="selected.item.perm.PEditar==false || selected.item.perm.PCriar==false"
                ng-show="items.length>0 && selectedEntidade!=null">
            Aplicar Entidade
        </button>
        <button class="btn btn-warning" ng-click="cancel()">Sair</button>
    </div>

</div>

