modal-punto-descarga.html 7.28 KB
<div class="modal-header d-flex">
    <h5 class="modal-title my-1" ng-hide="ingreso || cargaArticulos">Búsqueda de puntos de descarga</h5>
    <h5 class="modal-title my-1" ng-show="ingreso">Crear punto de descarga</h5>
    <h5 class="modal-title my-1" ng-show="cargaArticulos">Cargar articulos en puntos de descarga</h5>
    <button 
        class="btn btn-primary"
        ng-click="ingreso = true"
        ng-hide="ingreso || cargaArticulos">
        <i class="fa fa-plus" aria-hidden="true"></i>
    </button>
</div>
<div class="modal-body" id="modal-body">
    <table 
        class="table table-striped table-sm col-12"
        ng-hide="ingreso || cargaArticulos">
        <thead>
            <tr>
                <th>Código</th>
                <th>Descripción</th>
                <th>Latitud</th>
                <th>Longitud</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            <tr ng-show="puntosDescarga.length == 0">
                <td colspan="3">
                    No se encontraron resultados.
                </td>
            </tr>
            <tr class="selected"
                ng-repeat="(key, puntoDescarga) in puntosDescarga | filter: filters"
                >
                <td ng-bind="puntoDescarga.id | rellenarDigitos: 3: 0"></td>
                <td ng-bind="puntoDescarga.descripcion"></td>
                <td ng-bind="puntoDescarga.latitud"></td>
                <td ng-bind="puntoDescarga.longitud"></td>
                <td class="d-md-none text-primary">
                    <i class="fa fa-circle-thin" aria-hidden="true"></i>
                </td>
                <td class="d-none d-md-table-cell">
                    <input 
                        type="checkbox"
                        class="custom-control-input float-right" 
                        id="checkSelect{{key}}">
                    <label 
                        class="custom-control-label float-right"
                        for="checkSelect{{key}}"
                        ng-click="seleccionarPunto(key)"></label>
                    <button
                        type="button"
                        class="btn btn-xs p-1 float-right mr-5"
                        ng-click="eliminar(key, puntoDescarga.id)">
                        <i class="fa fa-trash" aria-hidden="true"></i>
                    </button>
                    <button
                        type="button"
                        class="btn btn-xs p-1 float-right mr-1"
                        ng-click="editar(puntoDescarga.id)">
                        <i class="fa fa-pencil" aria-hidden="true"></i>
                    </button>
                </td>
            </tr>
        </tbody>
    </table>
    <form ng-show="ingreso">
        <div class="row">
            <div class="col-6">
                <label>Latitud</label>
                <input
                    type="text"
                    class="form-control form-control-sm"
                    ng-model="puntoDescarga.latitud"
                    ng-required="true"
                />
            </div>
            <div class="col-6">
                <label>Longitud</label>
                <input
                    type="text"
                    class="form-control form-control-sm"
                    ng-model="puntoDescarga.longitud"
                    ng-required="true"
                />
            </div>
        </div>
        <div class="row">
            <div class="col-12">
                <label>Descripción</label>
                <textarea 
                    class="form-control form-control-sm"
                    cols="30"
                    rows="5"
                    ng-model="puntoDescarga.descripcion"></textarea>
            </div>
        </div>
    </form>
    <div ng-show="cargaArticulos">
        <div ng-show="articulos.length === 0">
            <h6>No existen articulos para agregar</h6>
        </div>
        <div ng-show="articulos.length > 0">
            <div class="row">
                <div class="form-check ml-4" ng-repeat="(key, articulo) in articulos">
                    <input 
                        class="form-check-input"
                        type="radio"
                        name="exampleRadios"
                        id="inputRadio{{key}}"
                        ng-value="key"
                        ng-model="$parent.articuloSeleccionado"
                        >
                    <label class="form-check-label" for="inputRadio{{key}}">
                        {{articulo.descripcion}} <strong>Cantidad:</strong> {{articulo.cantidad}}
                    </label>
                </div>
            </div>
            <div class="row">
                <div class="form-group col-3 mt-3">
                    <label for="inputCantidad">Cantidad</label>
                    <input
                        type="text" 
                        class="form-control" 
                        id="inputCantidad" 
                        placeholder="Cantidad"
                        ng-model="cantidadArticulo"
                        >
                </div>
            </div>
            <div class="row">
                <div class="col-6" ng-repeat="punto in puntosACargar">
                    <div class="d-flex">
                        <h6>{{punto.descripcion}}</h6>
                        <button
                            class="btn btn-sm btn-outline-primary ml-auto"
                            type="button"
                            ng-click="agregarArticulo(punto)"
                        >
                            Agregar
                        </button>
                    </div>
                    <table class="table table-sm">
                        <thead>
                            <tr>
                                <th>Articulo</th>
                                <th class="text-right">Cantidad</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr ng-repeat="(key, articulo) in punto.articulosAgregados">
                                <td ng-bind="articulo.descripcion" class="p-2"></td>
                                <td ng-bind="articulo.cantidad" class="text-right p-2"></td>
                                <td class="p-2">
                                    <button
                                        type="button"
                                        class="btn btn-xs p-1 float-right mr-5"
                                        ng-click="quitarArticulo(articulo, key, punto)">
                                        <i class="fa fa-trash" aria-hidden="true"></i>
                                    </button>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal-footer">
    <button 
        class="btn btn-sm btn-secondary my-1" 
        type="button" 
        ng-click="cancel()">Cancelar</button>
    <button 
        class="btn btn-sm btn-primary my-1"
        type="button"
        ng-click="aceptar()"
        ng-hide="ingreso">Aceptar</button>
    <button 
        class="btn btn-sm btn-primary my-1"
        type="button"
        ng-click="guardar()"
        ng-show="ingreso">Guardar</button>
</div>