cargos.jsp 2.98 KB
Newer Older
1 2 3
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib
prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ page
contentType="text/html;charset=UTF-8" language="java" %>
4 5
<%@ taglib uri="http://kwonnam.pe.kr/jsp/template-inheritance" prefix="layout"%>
<layout:extends name="layouts/base.jsp">
6
  <layout:put block="cssDeclaracion" type="APPEND"></layout:put>
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
    <layout:put block="contents" type="REPLACE">
      <div class="container-xxl my-md-4 bd-layout">
        <h2>Lista de cargos</h2>
          <div>
            <form>
              <label for="cargos">Nombre:</label>
              <input
                type="text"
                name="nombre"
                id="nombre"
                value="${param.nombre}"
              />
              <input type="submit" value="Buscar" />
            </form>
            <a href="/cargo">Agregar Nuevo Cargo</a>
          </div>
23 24 25 26 27 28
          <div class="card text-dark bg-light mt-3">
        
            <div class="card-body">
              <div class="table-responsive">
              <table class="table">
                <thead>
29
                  <tr>
30 31
                    <th scope="col">#</th>
                    <th scope="col">Cargo</th>
32
                  </tr>
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
                </thead>
                <tbody>
                  <c:forEach items="${cargos}" var="cargo" varStatus="sta">
                    <tr>
                      <th scope="row">${sta.index+1}</th>
                      <td>${cargo.getNombre()}</td>
                      <td>
                        <a href="/convocatorias?cargoId=${cargo.id}"
                          >Ver Convocatorias</a
                        >
                      </td>
                      <td><a href="/cargo/${cargo.id}">Editar cargo</a></td>
                    </tr>
                  </c:forEach>
                </tbody>
              </table>
              </div>
            </div>
51
          </div>
52 53 54 55 56 57 58 59 60 61
          <div class="card-footer">
            <div>
              <nav aria-label="Page navigation example">
                <ul class="pagination">
                  <c:forEach begin="1" end="${pages}" var="nro">
                    <li class="page-item ${(param.nroPagina == null and nro == 1)  or param.nroPagina == nro-1 ? 'active' : ''}"><a class="page-link" href="javascript:buscarPagina(${nro})">${nro}</a></li>
                  </c:forEach>
                </ul>
              </nav>
            </div>
62 63 64
          </div>
        </div>
      </div>  
65 66
    </layout:put>
    <layout:put block="scripts" type="APPEND">
67 68 69 70 71 72 73 74 75 76 77 78
      <script>
        function buscarPagina(nro){
          nro--
          const aBuscar = 'nroPagina='+nro
          if(!location.search) location.search = "?"+aBuscar
          const inicial = location.search.search(aBuscar);
          if(inicial==-1){//si no se encuentra y hay otros queries
            location.search = "&"+aBuscar
          }
          location.search.replace('nroPagina=',aBuscar)
        }
      </script>
79 80
    </layout:put>
</layout:extends>