💄 (user): Usa componentes base en Administración
Sustituye marcado propio y clases sin estilo por componentes de base, para que la interfaz se vea igual con cualquier tema.
This commit is contained in:
parent
c848b97450
commit
35f2b66161
6 changed files with 39 additions and 78 deletions
|
|
@ -81,8 +81,7 @@ impl Component for RoleTable {
|
|||
for role in self.items() {
|
||||
let system_badge = if role.locked {
|
||||
Some(
|
||||
Badge::labeled(Lc::t("badge-system-role", &LOCALES_USER))
|
||||
.with_prop(PropsOp::add_classes("user-admin-badge-system"))
|
||||
Badge::warning(Lc::t("badge-system-role", &LOCALES_USER))
|
||||
.render(cx)
|
||||
.await,
|
||||
)
|
||||
|
|
@ -111,11 +110,7 @@ impl Component for RoleTable {
|
|||
|
||||
Ok(html! {
|
||||
div (self.props().unpack(cx)) {
|
||||
div class="user-admin-actions" {
|
||||
a href=(new_href) {
|
||||
(Lc::t("btn-create-role", &LOCALES_USER).using(cx))
|
||||
}
|
||||
}
|
||||
(Button::anchor(Lc::t("btn-create-role", &LOCALES_USER), new_href).render(cx).await)
|
||||
@if let Some(message) = self.message() {
|
||||
div class="user-form-error" role="alert" { (message.clone().using(cx)) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,11 +96,7 @@ impl Component for UserTable {
|
|||
|
||||
Ok(html! {
|
||||
div (self.props().unpack(cx)) {
|
||||
div class="user-admin-actions" {
|
||||
a href=(new_href) {
|
||||
(Lc::t("btn-create-user", &LOCALES_USER).using(cx))
|
||||
}
|
||||
}
|
||||
(Button::anchor(Lc::t("btn-create-user", &LOCALES_USER), new_href).render(cx).await)
|
||||
(table.render(cx).await)
|
||||
(pager)
|
||||
}
|
||||
|
|
@ -266,8 +262,7 @@ async fn actions_cell(
|
|||
async fn roles_cell(user: &UserListItem, cx: &mut Context) -> Html {
|
||||
let admin_badge = if user.is_admin {
|
||||
Some(
|
||||
Badge::labeled(Lc::t("badge-admin", &LOCALES_USER))
|
||||
.with_prop(PropsOp::add_classes("user-admin-badge-admin"))
|
||||
Badge::severe(Lc::t("badge-admin", &LOCALES_USER))
|
||||
.render(cx)
|
||||
.await,
|
||||
)
|
||||
|
|
@ -277,12 +272,7 @@ async fn roles_cell(user: &UserListItem, cx: &mut Context) -> Html {
|
|||
|
||||
let mut role_badges = Vec::with_capacity(user.roles.len());
|
||||
for role in &user.roles {
|
||||
role_badges.push(
|
||||
Badge::labeled(Lc::n(role.clone()))
|
||||
.with_prop(PropsOp::add_classes("user-admin-badge"))
|
||||
.render(cx)
|
||||
.await,
|
||||
);
|
||||
role_badges.push(Badge::neutral(Lc::n(role.clone())).render(cx).await);
|
||||
}
|
||||
|
||||
let is_admin = user.is_admin;
|
||||
|
|
|
|||
|
|
@ -77,8 +77,7 @@ async fn profile_details(user: &user::Model, status: UserStatus, cx: &mut Contex
|
|||
);
|
||||
|
||||
if user.is_admin {
|
||||
let badge = Badge::labeled(Lc::t("badge-admin", &LOCALES_USER))
|
||||
.with_prop(PropsOp::add_classes("user-admin-badge-admin"))
|
||||
let badge = Badge::severe(Lc::t("badge-admin", &LOCALES_USER))
|
||||
.render(cx)
|
||||
.await;
|
||||
table = table.with_row(
|
||||
|
|
@ -101,8 +100,7 @@ async fn profile_roles(roles: &[role::Model], cx: &mut Context) -> Block {
|
|||
for r in roles {
|
||||
let system_badge = if r.locked {
|
||||
Some(
|
||||
Badge::labeled(Lc::t("badge-system-role", &LOCALES_USER))
|
||||
.with_prop(PropsOp::add_classes("user-admin-badge-system"))
|
||||
Badge::warning(Lc::t("badge-system-role", &LOCALES_USER))
|
||||
.render(cx)
|
||||
.await,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -21,26 +21,19 @@ pub(crate) async fn list_get(request: HttpRequest) -> Result<Response, ErrorPage
|
|||
let mut content = frame(title.clone());
|
||||
|
||||
for (group, group_label) in registry.groups_sorted(page.context()) {
|
||||
let items: Vec<(CowStr, Lc)> = registry
|
||||
.by_group(group)
|
||||
.map(|permission| (permission.key(), permission.label()))
|
||||
.collect();
|
||||
content = content.with_child(Block::new().with_title(group_label.clone()).with_child(
|
||||
Html::with(move |cx| {
|
||||
html! {
|
||||
table class="user-admin-table" {
|
||||
tbody {
|
||||
@for (key, label) in &items {
|
||||
tr {
|
||||
td { (label.using(cx)) }
|
||||
td class="user-admin-permission-key" { (key) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}),
|
||||
));
|
||||
let mut table = Table::new().with_prop(PropsOp::add_classes("user-admin-table"));
|
||||
for permission in registry.by_group(group) {
|
||||
table = table.with_row(
|
||||
table::Row::new()
|
||||
.with_cell(permission.label())
|
||||
.with_cell(permission.key().as_ref()),
|
||||
);
|
||||
}
|
||||
content = content.with_child(
|
||||
Block::new()
|
||||
.with_title(group_label.clone())
|
||||
.with_child(table),
|
||||
);
|
||||
}
|
||||
|
||||
Ok(page
|
||||
|
|
|
|||
|
|
@ -333,8 +333,7 @@ async fn role_view_details(role: &role::Model, cx: &mut Context) -> Block {
|
|||
);
|
||||
|
||||
if role.locked {
|
||||
let badge = Badge::labeled(Lc::t("badge-system-role", &LOCALES_USER))
|
||||
.with_prop(PropsOp::add_classes("user-admin-badge-system"))
|
||||
let badge = Badge::warning(Lc::t("badge-system-role", &LOCALES_USER))
|
||||
.render(cx)
|
||||
.await;
|
||||
table = table.with_row(
|
||||
|
|
|
|||
|
|
@ -557,8 +557,7 @@ async fn user_view_details(user: &user::Model, status: UserStatus, cx: &mut Cont
|
|||
);
|
||||
|
||||
if user.is_admin {
|
||||
let badge = Badge::labeled(Lc::t("badge-admin", &LOCALES_USER))
|
||||
.with_prop(PropsOp::add_classes("user-admin-badge-admin"))
|
||||
let badge = Badge::severe(Lc::t("badge-admin", &LOCALES_USER))
|
||||
.render(cx)
|
||||
.await;
|
||||
table = table.with_row(
|
||||
|
|
@ -576,49 +575,36 @@ async fn user_view_details(user: &user::Model, status: UserStatus, cx: &mut Cont
|
|||
// Bloque de sólo lectura con los roles asignados al usuario, cada uno enlazado a su propia
|
||||
// pantalla de vista.
|
||||
async fn user_view_roles(roles: &[role::Model], cx: &mut Context) -> Block {
|
||||
let mut items: Vec<(i32, String, String, Option<Markup>)> = Vec::with_capacity(roles.len());
|
||||
let mut table = Table::new()
|
||||
.with_prop(PropsOp::add_classes("user-admin-table"))
|
||||
.with_empty(Lc::n("-"));
|
||||
|
||||
for r in roles {
|
||||
let system_badge = if r.locked {
|
||||
Some(
|
||||
Badge::labeled(Lc::t("badge-system-role", &LOCALES_USER))
|
||||
.with_prop(PropsOp::add_classes("user-admin-badge-system"))
|
||||
Badge::warning(Lc::t("badge-system-role", &LOCALES_USER))
|
||||
.render(cx)
|
||||
.await,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
items.push((r.id, r.machine_name.clone(), r.label.clone(), system_badge));
|
||||
let (id, label) = (r.id, r.label.clone());
|
||||
table = table.with_row(
|
||||
table::Row::new()
|
||||
.with_cell(Html::with(move |cx| {
|
||||
html! { a href=(cx.route(role_path(id, "view"))) { (label.as_str()) } }
|
||||
}))
|
||||
.with_cell(r.machine_name.as_str())
|
||||
.with_cell(Html::with(move |_| {
|
||||
html! { @if let Some(badge) = &system_badge { (badge) } }
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
Block::new()
|
||||
.with_title(Lc::t("field-roles", &LOCALES_USER))
|
||||
.with_child(Html::with(move |cx| {
|
||||
html! {
|
||||
@if items.is_empty() {
|
||||
"-"
|
||||
} @else {
|
||||
table class="user-admin-table" {
|
||||
tbody {
|
||||
@for (id, machine_name, label, system_badge) in &items {
|
||||
@let href = cx.route(role_path(*id, "view")).to_string();
|
||||
tr {
|
||||
td {
|
||||
a href=(href) {
|
||||
(label.as_str())
|
||||
}
|
||||
}
|
||||
td { (machine_name.as_str()) }
|
||||
td {
|
||||
@if let Some(badge) = system_badge { (badge) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
.with_child(table)
|
||||
}
|
||||
|
||||
// **< roles_get / roles_post >*********************************************************************
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue