<div ng-controller="fornecedorController">

    <div class="modal-header" >
        <h3>Fornecedores</h3>
        <nav class="navbar navbar-default" role="navigation">
            <div class="container-fluid">
                <form class="navbar-form navbar-right" role="navigation">
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="Procurar..." ng-model="procurar_forn" ng-change="selectedRow=null">
                    </div>

                    <button popover-placement="top"
                            popover-trigger="mouseenter"
                            data-popover="Remover"
                            ng-click="confirmarApagarFornecedor(selectedRow)"
                            type="button"
                            ng-show="fornecedores.length>0 && selectedRow!=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="Novo Fornecedor"
                            ng-click="fornecedorEditRow(null)"
                            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="fornecedorEditRow(selectedRow)"
                            type="button"
                            ng-show="fornecedores.length>0 && selectedRow!=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" ng-init="carregarFornecedores()">
        
        <div style="height:270px; overflow:auto">
            <div class="list-group">
                <!--<a ng-click="selectItem(f); selected.item.NomeFornecedor = f.Nome; selected.item.Fk_Fornecedor=f.Pk_Fornecedor"-->
                <a ng-click="atribuirFornecedorCadastro(f,selected.item)"
                   href="javascript:void(0)"
                   ng-repeat="f in fornecedores | filter:procurar_forn"
                   class="list-group-item"
                   ng-selected="ativarLinha(f,selected.item)"
                   ng-class="{active:f.Pk_Fornecedor==selected.item.Fk_Fornecedor}">
                    {{f.Nome}}
                </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="fornecedores.length>0 && selectedRow!=null">
            Aplicar
        </button>
        <button class="btn btn-warning" ng-click="cancel()">Cancelar</button>
    </div>

</div>
