💄 (user): Unifica botoneras y enlaces de vuelta
- "Guardar" y "Cancelar" en la misma fila en todos los formularios. - "Volver" sólo en fichas de sólo lectura. - Búsqueda de usuarios con `form::input::Field` y botones de alta en estilo principal.
This commit is contained in:
parent
698b917fb1
commit
bdc94be92a
15 changed files with 115 additions and 114 deletions
|
|
@ -24,11 +24,11 @@ pub use user_name::UserName;
|
|||
|
||||
use pagetop::prelude::*;
|
||||
|
||||
use crate::LOCALES_USER;
|
||||
use crate::account::UserStatus;
|
||||
use crate::component::admin::status_key;
|
||||
use crate::config::{user_language_applies, user_timezone_applies};
|
||||
use crate::entity::user;
|
||||
use crate::{LOCALES_USER, PROFILE_PATH};
|
||||
|
||||
// Texto libre de varias líneas como contenido seguro: cada salto de línea se convierte en `<br>`,
|
||||
// sin depender del CSS del tema. Se usa para mostrar el "Sobre mí" del usuario.
|
||||
|
|
@ -87,6 +87,27 @@ pub(crate) fn error_banner(error: Option<Lc>) -> Html {
|
|||
})
|
||||
}
|
||||
|
||||
// Enlace para salir de un formulario sin guardar.
|
||||
pub(crate) fn cancel_link(route: impl Into<Route>) -> Button {
|
||||
Button::anchor(Lc::t("btn-cancel", &LOCALES_USER), route).with_style(button::Style::Link)
|
||||
}
|
||||
|
||||
// Botonera de un formulario: el botón de envío y, en la misma fila, el enlace para salir sin
|
||||
// guardar.
|
||||
pub(crate) fn form_actions(submit: Lc, cancel: impl Into<Route>) -> Flex {
|
||||
Flex::new()
|
||||
.with_wrap(flex::Behavior::Wrap)
|
||||
.with_align(align::Items::Center)
|
||||
.with_gap(align::Gap::Both(UnitValue::RelRem(0.5)))
|
||||
.with_child(Button::submit(submit).with_style(button::Style::Solid(Intent::Primary)))
|
||||
.with_child(cancel_link(cancel))
|
||||
}
|
||||
|
||||
// Botonera de los formularios del perfil propio, que al cancelar vuelven al perfil.
|
||||
pub(crate) fn profile_form_actions(submit: Lc, cx: &Context) -> Flex {
|
||||
form_actions(submit, cx.route(PROFILE_PATH))
|
||||
}
|
||||
|
||||
// Bloque de sólo lectura con los datos de perfil de un usuario, para «Mi cuenta» y para la ficha de
|
||||
// administración.
|
||||
pub(crate) async fn user_details(user: &user::Model, cx: &mut Context) -> Block {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use pagetop::prelude::*;
|
|||
use crate::LOCALES_USER;
|
||||
use crate::user_path;
|
||||
|
||||
use crate::component::{PasswordConfirm, error_banner};
|
||||
use crate::component::{PasswordConfirm, error_banner, form_actions};
|
||||
|
||||
#[derive(AutoDefault, Clone, Debug, Getters)]
|
||||
pub(crate) struct AdminPasswordForm {
|
||||
|
|
@ -34,10 +34,11 @@ impl Component for AdminPasswordForm {
|
|||
PasswordConfirm::new()
|
||||
.with_password_label(Lc::t("field-new-password", &LOCALES_USER)),
|
||||
)
|
||||
.with_child(
|
||||
Button::submit(Lc::t("btn-save", &LOCALES_USER))
|
||||
.with_style(button::Style::Solid(Intent::Primary)),
|
||||
);
|
||||
.with_child(form_actions(
|
||||
Lc::t("btn-save", &LOCALES_USER),
|
||||
self.waypoint()
|
||||
.append_to(cx.route(user_path(self.user_id(), "edit"))),
|
||||
));
|
||||
|
||||
Ok(form.render(cx).await)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use crate::ADMIN_ROLES_PATH;
|
|||
use crate::LOCALES_USER;
|
||||
use crate::role_path;
|
||||
|
||||
use crate::component::error_banner;
|
||||
use crate::component::{error_banner, form_actions};
|
||||
use crate::service::role_admin::{ROLE_LABEL_MAX_CHARS, ROLE_MACHINE_NAME_MAX_CHARS};
|
||||
|
||||
#[derive(AutoDefault, Clone, Copy, Debug, PartialEq)]
|
||||
|
|
@ -86,10 +86,10 @@ impl Component for RoleForm {
|
|||
.with_inputmode(Some(form::input::Mode::Numeric)),
|
||||
);
|
||||
|
||||
form = form.with_child(
|
||||
Button::submit(Lc::t("btn-save", &LOCALES_USER))
|
||||
.with_style(button::Style::Solid(Intent::Primary)),
|
||||
);
|
||||
form = form.with_child(form_actions(
|
||||
Lc::t("btn-save", &LOCALES_USER),
|
||||
self.waypoint().or(cx.route(ADMIN_ROLES_PATH.as_str())),
|
||||
));
|
||||
|
||||
Ok(form.render(cx).await)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@
|
|||
|
||||
use pagetop::prelude::*;
|
||||
|
||||
use crate::ADMIN_ROLES_PATH;
|
||||
use crate::LOCALES_USER;
|
||||
use crate::component::form_actions;
|
||||
use crate::role_path;
|
||||
|
||||
use crate::component::admin::PermissionGroups;
|
||||
|
|
@ -52,10 +54,10 @@ impl Component for RolePermissionsForm {
|
|||
form = form.with_child(fieldset);
|
||||
}
|
||||
|
||||
form = form.with_child(
|
||||
Button::submit(Lc::t("btn-save", &LOCALES_USER))
|
||||
.with_style(button::Style::Solid(Intent::Primary)),
|
||||
);
|
||||
form = form.with_child(form_actions(
|
||||
Lc::t("btn-save", &LOCALES_USER),
|
||||
self.waypoint().or(cx.route(ADMIN_ROLES_PATH.as_str())),
|
||||
));
|
||||
|
||||
Ok(form.render(cx).await)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,7 +121,10 @@ impl Component for RoleTable {
|
|||
|
||||
Ok(html! {
|
||||
div (self.props().unpack(cx)) {
|
||||
(Button::anchor(Lc::t("btn-create-role", &LOCALES_USER), new_href).render(cx).await)
|
||||
(Button::anchor(Lc::t("btn-create-role", &LOCALES_USER), new_href)
|
||||
.with_style(button::Style::Solid(Intent::Primary))
|
||||
.render(cx)
|
||||
.await)
|
||||
@if let Some(message) = self.message() {
|
||||
div class="user-form-error" role="alert" { (message.clone().using(cx)) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use crate::config::{SETTINGS, user_language_applies, user_timezone_applies};
|
|||
use crate::user_path;
|
||||
use crate::{ADMIN_USERS_PATH, PROFILE_EDIT_PATH};
|
||||
|
||||
use crate::component::{PasswordConfirm, error_banner};
|
||||
use crate::component::{PasswordConfirm, error_banner, form_actions, profile_form_actions};
|
||||
use crate::identity::{EMAIL_MAX_CHARS, USERNAME_MIN_CHARS, username_help, username_max_chars};
|
||||
use crate::service::user_admin::{ABOUT_MAX_CHARS, DISPLAY_NAME_MAX_CHARS};
|
||||
|
||||
|
|
@ -159,14 +159,18 @@ impl Component for UserForm {
|
|||
);
|
||||
}
|
||||
|
||||
// En modo `Edit`, "Guardar" se renderiza fuera del formulario, junto al resto de acciones
|
||||
// de la pantalla (ver `USER_ADMIN_FORM_ID`); en los demás modos no hay ninguna botonera con
|
||||
// la que agruparlo, así que se queda aquí, dentro del propio `<form>`.
|
||||
if *self.mode() != UserFormMode::Edit {
|
||||
form = form.with_child(
|
||||
Button::submit(Lc::t("btn-save", &LOCALES_USER))
|
||||
.with_style(button::Style::Solid(Intent::Primary)),
|
||||
);
|
||||
// En modo `Edit`, "Guardar" y "Cancelar" se renderizan fuera del formulario, junto al resto
|
||||
// de acciones de la pantalla (ver `USER_ADMIN_FORM_ID`).
|
||||
let save = Lc::t("btn-save", &LOCALES_USER);
|
||||
match self.mode() {
|
||||
UserFormMode::Edit => {}
|
||||
UserFormMode::Profile => {
|
||||
form = form.with_child(profile_form_actions(save, cx));
|
||||
}
|
||||
UserFormMode::New => {
|
||||
let cancel = self.waypoint().or(cx.route(ADMIN_USERS_PATH.as_str()));
|
||||
form = form.with_child(form_actions(save, cancel));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(form.render(cx).await)
|
||||
|
|
|
|||
|
|
@ -87,7 +87,10 @@ impl Component for UserTable {
|
|||
|
||||
Ok(html! {
|
||||
div (self.props().unpack(cx)) {
|
||||
(Button::anchor(Lc::t("btn-create-user", &LOCALES_USER), new_href).render(cx).await)
|
||||
(Button::anchor(Lc::t("btn-create-user", &LOCALES_USER), new_href)
|
||||
.with_style(button::Style::Solid(Intent::Primary))
|
||||
.render(cx)
|
||||
.await)
|
||||
(table.render(cx).await)
|
||||
(pager)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use pagetop::prelude::*;
|
|||
|
||||
use crate::{EMAIL_PATH, LOCALES_USER};
|
||||
|
||||
use crate::component::error_banner;
|
||||
use crate::component::{error_banner, profile_form_actions};
|
||||
use crate::identity::EMAIL_MAX_CHARS;
|
||||
|
||||
/// Pide la nueva dirección y la contraseña actual. Si ya hay un cambio pendiente de confirmar, lo
|
||||
|
|
@ -56,10 +56,10 @@ impl Component for ChangeEmailForm {
|
|||
.with_autocomplete(Some(form::Autocomplete::current_password()))
|
||||
.with_required(true),
|
||||
)
|
||||
.with_child(
|
||||
Button::submit(Lc::t("btn-change-email", &LOCALES_USER))
|
||||
.with_style(button::Style::Solid(Intent::Primary)),
|
||||
);
|
||||
.with_child(profile_form_actions(
|
||||
Lc::t("btn-change-email", &LOCALES_USER),
|
||||
cx,
|
||||
));
|
||||
|
||||
Ok(form.render(cx).await)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use pagetop::prelude::*;
|
|||
|
||||
use crate::{LOCALES_USER, PROFILE_PASSWORD_PATH};
|
||||
|
||||
use crate::component::{PasswordConfirm, error_banner};
|
||||
use crate::component::{PasswordConfirm, error_banner, profile_form_actions};
|
||||
|
||||
/// Pide la contraseña actual además de la nueva y su confirmación, a diferencia del
|
||||
/// restablecimiento por un administrador.
|
||||
|
|
@ -36,10 +36,10 @@ impl Component for ChangePasswordForm {
|
|||
PasswordConfirm::new()
|
||||
.with_password_label(Lc::t("field-new-password", &LOCALES_USER)),
|
||||
)
|
||||
.with_child(
|
||||
Button::submit(Lc::t("btn-set-password", &LOCALES_USER))
|
||||
.with_style(button::Style::Solid(Intent::Primary)),
|
||||
);
|
||||
.with_child(profile_form_actions(
|
||||
Lc::t("btn-set-password", &LOCALES_USER),
|
||||
cx,
|
||||
));
|
||||
|
||||
Ok(form.render(cx).await)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -547,21 +547,15 @@ pub(crate) async fn email_confirm_post(
|
|||
|
||||
// **< render_profile_page >************************************************************************
|
||||
|
||||
// Página del perfil propio con un formulario y un botón para volver al perfil sin guardar.
|
||||
// Página del perfil propio con un formulario.
|
||||
async fn render_profile_page(
|
||||
request: HttpRequest,
|
||||
title: Lc,
|
||||
form: impl Component + 'static,
|
||||
) -> Response {
|
||||
let page = Page::new(request);
|
||||
let cancel = Button::anchor(Lc::t("btn-cancel", &LOCALES_USER), page.route(PROFILE_PATH));
|
||||
page.with_title(title.clone())
|
||||
.with_child(
|
||||
Block::new()
|
||||
.with_title(title)
|
||||
.with_child(form)
|
||||
.with_child(cancel),
|
||||
)
|
||||
Page::new(request)
|
||||
.with_title(title.clone())
|
||||
.with_child(Block::new().with_title(title).with_child(form))
|
||||
.render()
|
||||
.await
|
||||
.into_response()
|
||||
|
|
|
|||
|
|
@ -59,14 +59,7 @@ pub(crate) fn map_auth_error(err: &AuthError) -> Lc {
|
|||
}
|
||||
}
|
||||
|
||||
// Enlace de vuelta al listado, usado en las pantallas de alta/edición/asignación.
|
||||
pub(crate) fn back_link(href: impl Into<RoutePath>) -> Html {
|
||||
let href = href.into();
|
||||
Html::with(move |cx| {
|
||||
html! {
|
||||
p class="user-admin-back-link" {
|
||||
a href=(href.clone()) { (Lc::t("link-back-to-list", &LOCALES_USER).using(cx)) }
|
||||
}
|
||||
}
|
||||
})
|
||||
// Enlace para salir de una ficha de sólo lectura. Los formularios tienen `form_actions()`.
|
||||
pub(crate) fn back_link(route: impl Into<Route>) -> Button {
|
||||
Button::anchor(Lc::t("link-back", &LOCALES_USER), route).with_style(button::Style::Link)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,6 @@ pub(crate) async fn new_get(
|
|||
web::Query(waypoint): web::Query<Waypoint>,
|
||||
) -> Result<Response, ErrorPage> {
|
||||
let page = Page::admin(request);
|
||||
let back_href = waypoint.or(page.route(ADMIN_ROLES_PATH.as_str()));
|
||||
let title = Lc::t("title-admin-role-new", &LOCALES_USER);
|
||||
Ok(page
|
||||
.with_title(title)
|
||||
|
|
@ -85,7 +84,6 @@ pub(crate) async fn new_get(
|
|||
.with_mode(RoleFormMode::New)
|
||||
.with_waypoint(waypoint),
|
||||
)
|
||||
.with_child(back_link(back_href))
|
||||
.render()
|
||||
.await
|
||||
.into_response())
|
||||
|
|
@ -125,7 +123,6 @@ pub(crate) async fn new_post(
|
|||
}
|
||||
Err(err) => {
|
||||
let page = Page::admin(request);
|
||||
let back_href = waypoint.or(page.route(ADMIN_ROLES_PATH.as_str()));
|
||||
let form_component = RoleForm::new()
|
||||
.with_mode(RoleFormMode::New)
|
||||
.with_machine_name(form.machine_name)
|
||||
|
|
@ -138,7 +135,6 @@ pub(crate) async fn new_post(
|
|||
Ok(page
|
||||
.with_title(title)
|
||||
.with_child(form_component)
|
||||
.with_child(back_link(back_href))
|
||||
.render()
|
||||
.await
|
||||
.into_response())
|
||||
|
|
@ -163,7 +159,6 @@ pub(crate) async fn edit_get(
|
|||
}
|
||||
|
||||
let page = Page::admin(request);
|
||||
let back_href = waypoint.or(page.route(ADMIN_ROLES_PATH.as_str()));
|
||||
|
||||
let title = Lc::t("title-admin-role-edit", &LOCALES_USER);
|
||||
Ok(page
|
||||
|
|
@ -178,7 +173,6 @@ pub(crate) async fn edit_get(
|
|||
.with_weight(role.weight)
|
||||
.with_waypoint(waypoint),
|
||||
)
|
||||
.with_child(back_link(back_href))
|
||||
.render()
|
||||
.await
|
||||
.into_response())
|
||||
|
|
@ -224,7 +218,6 @@ pub(crate) async fn edit_post(
|
|||
.map(|role| role.machine_name)
|
||||
.unwrap_or_default();
|
||||
let page = Page::admin(request);
|
||||
let back_href = waypoint.or(page.route(ADMIN_ROLES_PATH.as_str()));
|
||||
let form_component = RoleForm::new()
|
||||
.with_mode(RoleFormMode::Edit)
|
||||
.with_role_id(Some(id))
|
||||
|
|
@ -238,7 +231,6 @@ pub(crate) async fn edit_post(
|
|||
Ok(page
|
||||
.with_title(title)
|
||||
.with_child(form_component)
|
||||
.with_child(back_link(back_href))
|
||||
.render()
|
||||
.await
|
||||
.into_response())
|
||||
|
|
@ -481,7 +473,6 @@ pub(crate) async fn permissions_get(
|
|||
let page = Page::admin(request);
|
||||
|
||||
let groups = build_permission_groups(&selected, page.context());
|
||||
let back_href = waypoint.or(page.route(ADMIN_ROLES_PATH.as_str()));
|
||||
|
||||
let title = Lc::t("title-admin-role-permissions", &LOCALES_USER);
|
||||
Ok(page
|
||||
|
|
@ -492,7 +483,6 @@ pub(crate) async fn permissions_get(
|
|||
.with_groups(groups)
|
||||
.with_waypoint(waypoint),
|
||||
)
|
||||
.with_child(back_link(back_href))
|
||||
.render()
|
||||
.await
|
||||
.into_response())
|
||||
|
|
@ -530,7 +520,6 @@ pub(crate) async fn permissions_post(
|
|||
let page = Page::admin(request);
|
||||
|
||||
let groups = build_permission_groups(&form.permission_keys, page.context());
|
||||
let back_href = waypoint.or(page.route(ADMIN_ROLES_PATH.as_str()));
|
||||
let form_component = RolePermissionsForm::new()
|
||||
.with_role_id(id)
|
||||
.with_groups(groups)
|
||||
|
|
@ -540,7 +529,6 @@ pub(crate) async fn permissions_post(
|
|||
Ok(page
|
||||
.with_title(title)
|
||||
.with_child(form_component)
|
||||
.with_child(back_link(back_href))
|
||||
.render()
|
||||
.await
|
||||
.into_response())
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use crate::account::{Account, UserStatus};
|
|||
use crate::component::admin::{
|
||||
AdminPasswordForm, USER_ADMIN_FORM_ID, UserForm, UserFormMode, UserTable,
|
||||
};
|
||||
use crate::component::user_details;
|
||||
use crate::component::{cancel_link, user_details};
|
||||
use crate::config::SETTINGS;
|
||||
use crate::entity::{role, user};
|
||||
use crate::error::AuthError;
|
||||
|
|
@ -70,9 +70,11 @@ pub(crate) async fn list_get(
|
|||
Ok(HtmxResponse::new(table.render(&mut cx).await).into_response())
|
||||
} else {
|
||||
let title = Lc::t("title-admin-users", &LOCALES_USER);
|
||||
Ok(Page::admin(request)
|
||||
let page = Page::admin(request);
|
||||
let search = search_bar(page.route(ADMIN_USERS_PATH.as_str()), query.q);
|
||||
Ok(page
|
||||
.with_title(title)
|
||||
.with_child(search_bar(query.q))
|
||||
.with_child(search)
|
||||
.with_child(table)
|
||||
.render()
|
||||
.await
|
||||
|
|
@ -82,25 +84,24 @@ pub(crate) async fn list_get(
|
|||
|
||||
// **< search_bar >*********************************************************************************
|
||||
|
||||
fn search_bar(current_query: Option<String>) -> Html {
|
||||
let value = current_query.unwrap_or_default();
|
||||
Html::with(move |cx| {
|
||||
html! {
|
||||
div class="user-admin-search" {
|
||||
input
|
||||
type="search"
|
||||
id="user-admin-search-input"
|
||||
name="q"
|
||||
value=(value.as_str())
|
||||
placeholder=[Lc::t("field-search-users", &LOCALES_USER).lookup(cx)]
|
||||
hx-get=(cx.route(ADMIN_USERS_PATH.as_str()).to_string())
|
||||
hx-trigger="keyup changed delay:400ms, search"
|
||||
hx-target="#user-table-wrapper"
|
||||
hx-swap=(hx::swap::OUTER_HTML_SCROLL_TOP)
|
||||
hx-push-url="true";
|
||||
}
|
||||
}
|
||||
})
|
||||
// Los atributos HTMX van en el formulario porque `with_prop()` de un campo los pondría en su
|
||||
// contenedor, que no enviaría el valor. `input` cubre también vaciar con la "x" del navegador.
|
||||
fn search_bar(route: RoutePath, current_query: Option<String>) -> Form {
|
||||
Form::new()
|
||||
.with_action(route.clone())
|
||||
.with_method(form::Method::Get)
|
||||
.with_prop(PropsOp::set(hx::GET, route.to_string()))
|
||||
.with_prop(PropsOp::set(hx::TRIGGER, "input delay:400ms, submit"))
|
||||
.with_prop(PropsOp::set(hx::TARGET, "#user-table-wrapper"))
|
||||
.with_prop(PropsOp::set(hx::SWAP, hx::swap::OUTER_HTML_SCROLL_TOP))
|
||||
.with_prop(PropsOp::set(hx::PUSH_URL, "true"))
|
||||
.with_child(
|
||||
form::input::Field::search()
|
||||
.with_id("user-admin-search")
|
||||
.with_name("q")
|
||||
.with_value(current_query.unwrap_or_default())
|
||||
.with_placeholder(Lc::t("field-search-users", &LOCALES_USER)),
|
||||
)
|
||||
}
|
||||
|
||||
// **< available_roles >****************************************************************************
|
||||
|
|
@ -158,7 +159,6 @@ pub(crate) async fn new_get(
|
|||
// permiso del catálogo (igual que conceder/revocar en la edición, ver `set_user_admin`).
|
||||
let allow_admin_field = request.extension::<Account>().is_some_and(|a| a.is_admin());
|
||||
let page = Page::admin(request);
|
||||
let back_href = waypoint.or(page.route(ADMIN_USERS_PATH.as_str()));
|
||||
let title = Lc::t("title-admin-user-new", &LOCALES_USER);
|
||||
Ok(page
|
||||
.with_title(title)
|
||||
|
|
@ -169,7 +169,6 @@ pub(crate) async fn new_get(
|
|||
.with_allow_admin_field(allow_admin_field)
|
||||
.with_waypoint(waypoint),
|
||||
)
|
||||
.with_child(back_link(back_href))
|
||||
.render()
|
||||
.await
|
||||
.into_response())
|
||||
|
|
@ -236,7 +235,6 @@ pub(crate) async fn new_post(
|
|||
Err(err) => {
|
||||
let roles = available_roles(&role_ids).await.unwrap_or_default();
|
||||
let page = Page::admin(request);
|
||||
let back_href = waypoint.or(page.route(ADMIN_USERS_PATH.as_str()));
|
||||
let form_component = UserForm::new()
|
||||
.with_mode(UserFormMode::New)
|
||||
.with_username(form.username)
|
||||
|
|
@ -254,7 +252,6 @@ pub(crate) async fn new_post(
|
|||
Ok(page
|
||||
.with_title(title)
|
||||
.with_child(form_component)
|
||||
.with_child(back_link(back_href))
|
||||
.render()
|
||||
.await
|
||||
.into_response())
|
||||
|
|
@ -318,7 +315,6 @@ async fn render_edit_page(
|
|||
// Bloquear y activar exige además `user:block_accounts` (ver `status_post`).
|
||||
let can_change_status = has_permission(&request, &UserPermission::BlockAccounts);
|
||||
let mut page = Page::admin(request);
|
||||
let back_href = waypoint.or(page.route(ADMIN_USERS_PATH.as_str()));
|
||||
let title = Lc::t("title-admin-user-edit", &LOCALES_USER);
|
||||
let actions = edit_actions(
|
||||
id,
|
||||
|
|
@ -337,25 +333,22 @@ async fn render_edit_page(
|
|||
.with_waypoint(waypoint.clone()),
|
||||
)
|
||||
.with_child(actions)
|
||||
.with_child(back_link(back_href))
|
||||
.render()
|
||||
.await
|
||||
.into_response()
|
||||
}
|
||||
|
||||
// Enlace a la pantalla de restablecer contraseña y botones de bloqueo/activación (sólo si
|
||||
// `can_change_status`) y de concesión/revocación de acceso irrestricto (sólo si
|
||||
// `can_toggle_admin`). El listado
|
||||
// de origen (`waypoint`) se arrastra a todas ellas para que, al volver aquí, esta misma pantalla
|
||||
// siga sabiendo devolver al listado en el estado en que se dejó.
|
||||
// Botonera de la edición: "Guardar", "Cancelar", el enlace a la pantalla de restablecer contraseña
|
||||
// y los botones de bloqueo/activación (sólo si `can_change_status`) y de concesión/revocación de
|
||||
// acceso irrestricto (sólo si `can_toggle_admin`). El listado de origen (`waypoint`) se arrastra a
|
||||
// todas ellas para que, al volver aquí, esta misma pantalla siga sabiendo devolver al listado en el
|
||||
// estado en que se dejó.
|
||||
//
|
||||
// "Guardar" (envía el `<form>` de `UserForm` vía el atributo `form`, ver `USER_ADMIN_FORM_ID`) y
|
||||
// "Restablecer contraseña" son botones sueltos; bloqueo/activación y concesión/revocación de admin
|
||||
// (este último sólo si `can_toggle_admin`) van cada uno en su propio `Form`, con un campo `Hidden`
|
||||
// para el nuevo valor, para conservar el envío nativo sin JavaScript, mejorado con
|
||||
// `hx-post`/`hx-confirm`. Todos son hijos directos del mismo `Container` con Flex, que los alinea
|
||||
// en fila con espaciado uniforme sin que ninguno tenga que ser forzosamente un `Button` suelto (ver
|
||||
// PAGETOP.md, "Preferir componentes a `html!` en bruto").
|
||||
// "Guardar" (envía el `<form>` de `UserForm` vía el atributo `form`, ver `USER_ADMIN_FORM_ID`),
|
||||
// "Cancelar" y "Restablecer contraseña" son botones sueltos; bloqueo/activación y
|
||||
// concesión/revocación de admin van cada uno en su propio `Form`, con un campo `Hidden` para el
|
||||
// nuevo valor, para conservar el envío nativo sin JavaScript, mejorado con `hx-post`/`hx-confirm`.
|
||||
// Todos son hijos directos del mismo `Flex`, que los alinea en fila con espaciado uniforme.
|
||||
fn edit_actions(
|
||||
user_id: i32,
|
||||
status: UserStatus,
|
||||
|
|
@ -403,6 +396,9 @@ fn edit_actions(
|
|||
.with_style(button::Style::Solid(Intent::Primary))
|
||||
.with_prop(PropsOp::set("form", USER_ADMIN_FORM_ID)),
|
||||
)
|
||||
.with_child(cancel_link(
|
||||
waypoint.or(cx.route(ADMIN_USERS_PATH.as_str())),
|
||||
))
|
||||
.with_child(
|
||||
Button::anchor(Lc::t("btn-reset-password", &LOCALES_USER), password_href)
|
||||
.with_style(button::Style::Solid(Intent::Neutral)),
|
||||
|
|
@ -709,7 +705,6 @@ pub(crate) async fn password_get(
|
|||
) -> Result<Response, ErrorPage> {
|
||||
let user = require_manageable(&request, id).await?;
|
||||
let page = Page::admin(request);
|
||||
let edit_href = waypoint.append_to(page.route(user_path(id, "edit")));
|
||||
let title = Lc::t("title-admin-user-password", &LOCALES_USER);
|
||||
Ok(page
|
||||
.with_title(title)
|
||||
|
|
@ -719,7 +714,6 @@ pub(crate) async fn password_get(
|
|||
.with_user_id(id)
|
||||
.with_waypoint(waypoint),
|
||||
)
|
||||
.with_child(back_link(edit_href))
|
||||
.render()
|
||||
.await
|
||||
.into_response())
|
||||
|
|
@ -755,7 +749,6 @@ pub(crate) async fn password_post(
|
|||
}
|
||||
Err(err) => {
|
||||
let page = Page::admin(request);
|
||||
let edit_href = waypoint.append_to(page.route(user_path(id, "edit")));
|
||||
let title = Lc::t("title-admin-user-password", &LOCALES_USER);
|
||||
Ok(page
|
||||
.with_title(title)
|
||||
|
|
@ -766,7 +759,6 @@ pub(crate) async fn password_post(
|
|||
.with_error(map_auth_error(&err))
|
||||
.with_waypoint(waypoint),
|
||||
)
|
||||
.with_child(back_link(edit_href))
|
||||
.render()
|
||||
.await
|
||||
.into_response())
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ btn-block = Block
|
|||
btn-activate = Activate
|
||||
btn-grant-admin = Grant administrator
|
||||
btn-revoke-admin = Revoke administrator
|
||||
link-back-to-list = Back to list
|
||||
link-back = Back
|
||||
|
||||
# **< Admin: confirmations and badges >**
|
||||
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ btn-block = Bloquear
|
|||
btn-activate = Activar
|
||||
btn-grant-admin = Conceder administrador
|
||||
btn-revoke-admin = Revocar administrador
|
||||
link-back-to-list = Volver al listado
|
||||
link-back = Volver
|
||||
|
||||
# **< Administración: confirmaciones y distintivos >**
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue