✨ (base) Añade ListView y ListFilter para listados
- ListView: botones, mensajes, tabla y paginador en orden fijo; anuncia el número de resultados a los lectores de pantalla. - ListFilter: filtros en fila con "Filtrar" y "Limpiar", envío automático opcional y marcas de cambios sin aplicar. - pagetop-htmx: hx_pager::boost() y hx_filter::boost(); cancelan las peticiones solapadas y atenúan el listado mientras carga, con estilos sólo en las páginas con listado. - Usuarios y roles migrados al nuevo patrón.
This commit is contained in:
parent
0f71eba7ab
commit
d8493291e4
28 changed files with 1264 additions and 144 deletions
|
|
@ -10,7 +10,9 @@ impl Extension for TestApp {
|
|||
}
|
||||
|
||||
fn configure_router(&self, routes: Routes) -> Routes {
|
||||
routes.public_route("/page", web::get(render_page))
|
||||
routes
|
||||
.public_route("/page", web::get(render_page))
|
||||
.public_route("/list", web::get(render_list))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -21,6 +23,13 @@ async fn render_page(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
|||
.await
|
||||
}
|
||||
|
||||
async fn render_list(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
||||
Page::new(request)
|
||||
.with_child(ListView::new().with_table(Table::new().with_column(Lc::n("Name"))))
|
||||
.render()
|
||||
.await
|
||||
}
|
||||
|
||||
// All tests in this file share the same root extension (`TestApp`), since `EXTENSIONS` is a global
|
||||
// `OnceLock` initialized only once per test binary (see `core/extension/all.rs`).
|
||||
|
||||
|
|
@ -60,3 +69,22 @@ async fn rendered_pages_automatically_include_the_pinned_htmx_script_tag() {
|
|||
assert!(body.contains("defer"));
|
||||
assert!(body.contains("<p>hello</p>"));
|
||||
}
|
||||
|
||||
// **< List loading styles >************************************************************************
|
||||
|
||||
#[pagetop::test]
|
||||
async fn pages_with_a_list_embed_the_list_loading_styles_and_others_do_not() {
|
||||
let app = web::test::init_router(Application::prepare(&TestApp).await.test());
|
||||
|
||||
let req = web::test::TestRequest::get().uri("/list").to_request();
|
||||
let body = web::test::read_body_text(web::test::send_request(&app, req).await).await;
|
||||
// HTMX sets `htmx-request` on the element named by `hx-indicator`: the list.
|
||||
assert!(
|
||||
body.contains(".list-view.htmx-request{opacity:0.5}"),
|
||||
"{body}"
|
||||
);
|
||||
|
||||
let req = web::test::TestRequest::get().uri("/page").to_request();
|
||||
let body = web::test::read_body_text(web::test::send_request(&app, req).await).await;
|
||||
assert!(!body.contains("htmx-request"), "{body}");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue