💄 (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
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue