♻️ Migra #[builder_fn] a #[builder_impl]

Sustituye las ~400 anotaciones `#[builder_fn]` método a método por un
único `#[builder_impl]` por `impl`/`trait`, en 74 ficheros de pagetop y
sus extensiones (admin, bootsier, menu, user).
This commit is contained in:
Manuel Cillero 2026-08-29 19:25:58 +02:00
parent c34dc02357
commit 1be3d88888
74 changed files with 104 additions and 394 deletions

View file

@ -24,6 +24,7 @@ pub struct Cell {
children: Children,
}
#[builder_impl]
impl Cell {
/// Crea una celda a partir del componente o texto ([`Lc`]) indicado.
///
@ -44,14 +45,12 @@ impl Cell {
// **< Cell BUILDER >***************************************************************************
/// Establece el identificador único de la celda.
#[builder_fn]
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
self.props.alter_id(id);
self
}
/// Modifica identificador, clases CSS o atributos HTML de la celda.
#[builder_fn]
pub fn with_prop(mut self, op: PropsOp) -> Self {
self.props.alter_prop(op);
self
@ -60,7 +59,6 @@ impl Cell {
/// Establece el número de columnas que ocupa la celda (atributo `colspan`).
///
/// Con `1` (el valor por defecto de HTML) elimina el atributo en vez de fijarlo.
#[builder_fn]
pub fn with_colspan(mut self, span: u8) -> Self {
self.props.alter_prop(if span == 1 {
PropsOp::remove("colspan")
@ -73,7 +71,6 @@ impl Cell {
/// Establece el número de filas que ocupa la celda (atributo `rowspan`).
///
/// Con `1` (el valor por defecto de HTML) elimina el atributo en vez de fijarlo.
#[builder_fn]
pub fn with_rowspan(mut self, span: u8) -> Self {
self.props.alter_prop(if span == 1 {
PropsOp::remove("rowspan")
@ -85,7 +82,6 @@ impl Cell {
/// Añade un nuevo componente a la celda o modifica la lista de componentes (`children`) con una
/// operación [`ChildOp`].
#[builder_fn]
pub fn with_child(mut self, op: impl Into<ChildOp>) -> Self {
self.children.alter_child(op.into());
self

View file

@ -27,6 +27,7 @@ pub struct Column {
sort: Option<table::SortLink>,
}
#[builder_impl]
impl Column {
/// Crea una cabecera con el texto localizado indicado.
pub fn new(label: Lc) -> Self {
@ -39,14 +40,12 @@ impl Column {
// **< Column BUILDER >*************************************************************************
/// Establece el identificador único de la celda de cabecera.
#[builder_fn]
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
self.props.alter_id(id);
self
}
/// Modifica identificador, clases CSS o atributos HTML de la columna.
#[builder_fn]
pub fn with_prop(mut self, op: PropsOp) -> Self {
self.props.alter_prop(op);
self
@ -55,7 +54,6 @@ impl Column {
/// Establece el número de columnas que ocupa la cabecera (atributo `colspan`).
///
/// Con `1` (el valor por defecto de HTML) elimina el atributo en vez de fijarlo.
#[builder_fn]
pub fn with_colspan(mut self, span: u8) -> Self {
self.props.alter_prop(if span == 1 {
PropsOp::remove("colspan")
@ -68,7 +66,6 @@ impl Column {
/// Establece el número de filas que ocupa la cabecera (atributo `rowspan`).
///
/// Con `1` (el valor por defecto de HTML) elimina el atributo en vez de fijarlo.
#[builder_fn]
pub fn with_rowspan(mut self, span: u8) -> Self {
self.props.alter_prop(if span == 1 {
PropsOp::remove("rowspan")
@ -80,7 +77,6 @@ impl Column {
/// Convierte la columna en ordenable con el enlace indicado, o la vuelve no ordenable con
/// `None`.
#[builder_fn]
pub fn with_sort(mut self, sort: impl Into<Option<table::SortLink>>) -> Self {
self.sort = sort.into();
self

View file

@ -118,18 +118,17 @@ impl Component for Table {
}
}
#[builder_impl]
impl Table {
// **< Table BUILDER >**************************************************************************
/// Establece el identificador único de la tabla.
#[builder_fn]
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
self.props.alter_id(id);
self
}
/// Modifica identificador, clases CSS o atributos HTML de la tabla.
#[builder_fn]
pub fn with_prop(mut self, op: PropsOp) -> Self {
self.props.alter_prop(op);
self
@ -141,14 +140,12 @@ impl Table {
/// `table::Column::new(...)` con el texto indicado), o un [`table::Column`] ya construido (por
/// ejemplo para asignarle clases, atributos propios o un enlace de ordenación con
/// `with_sort()`).
#[builder_fn]
pub fn with_column(mut self, column: impl Into<table::Column>) -> Self {
self.columns.push(column.into());
self
}
/// Añade una fila de datos al final de la tabla.
#[builder_fn]
pub fn with_row(mut self, row: table::Row) -> Self {
self.rows.push(row);
self
@ -160,7 +157,6 @@ impl Table {
///
/// Ese mismo resultado se obtiene también si la traducción no resuelve a ningún texto (por
/// ejemplo, con `Lc::n("")`).
#[builder_fn]
pub fn with_empty(mut self, empty: impl Into<Option<Lc>>) -> Self {
self.empty = empty.into();
self

View file

@ -39,6 +39,7 @@ pub struct SortLink {
dir: Option<SortDir>,
}
#[builder_impl]
impl SortLink {
/// Crea un enlace de ordenación hacia la URL indicada, sin dirección activa.
pub fn new(href: impl Into<RoutePath>) -> Self {
@ -51,7 +52,6 @@ impl SortLink {
// **< SortLink BUILDER >***********************************************************************
/// Establece el identificador único del enlace.
#[builder_fn]
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
self.props.alter_id(id);
self
@ -59,7 +59,6 @@ impl SortLink {
/// Establece la dirección de orden vigente, o `None` si esta columna no es la que ordena
/// actualmente la tabla.
#[builder_fn]
pub fn with_dir(mut self, dir: impl Into<Option<SortDir>>) -> Self {
self.dir = dir.into();
self
@ -67,7 +66,6 @@ impl SortLink {
/// Modifica los atributos HTML del enlace. Es el punto de extensión para añadir atributos de
/// interactividad sin que `Table` necesite conocerlos.
#[builder_fn]
pub fn with_prop(mut self, op: PropsOp) -> Self {
self.props.alter_prop(op);
self

View file

@ -19,6 +19,7 @@ pub struct Row {
cells: Vec<table::Cell>,
}
#[builder_impl]
impl Row {
/// Crea una fila vacía.
pub fn new() -> Self {
@ -28,14 +29,12 @@ impl Row {
// **< Row BUILDER >****************************************************************************
/// Establece el identificador único de la fila.
#[builder_fn]
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
self.props.alter_id(id);
self
}
/// Modifica identificador, clases CSS o atributos HTML de la fila.
#[builder_fn]
pub fn with_prop(mut self, op: PropsOp) -> Self {
self.props.alter_prop(op);
self
@ -46,7 +45,6 @@ impl Row {
/// Acepta directamente un `&str`, un `String` o un [`Lc`] (equivalen a `table::Cell::new(...)`
/// con el contenido indicado), o un [`table::Cell`] ya construido (por ejemplo para asignarle
/// clases o atributos propios, o para contener otros componentes).
#[builder_fn]
pub fn with_cell(mut self, cell: impl Into<table::Cell>) -> Self {
self.cells.push(cell.into());
self