Mejora y simplifica la gestión global de acciones

This commit is contained in:
Manuel Cillero 2022-05-05 21:43:00 +02:00
parent 7c8f51ba86
commit 67ddb8d899
29 changed files with 184 additions and 206 deletions

View file

@ -20,12 +20,18 @@ impl ModuleTrait for Node {
cfg.route("/node", app::web::get().to(node));
}
fn migrations(&self) -> Vec<Box<dyn db::MigrationTrait>> {
fn actions(&self) -> Vec<ActionItem> {
vec![
boxed_migration!(m20220316_000001_create_table_node_type),
boxed_migration!(m20220316_000002_create_table_node),
boxed_migration!(m20220316_000003_create_table_node_access),
boxed_migration!(m20220316_000004_create_table_node_revision),
action_item!(ActionBeforeRenderPage => before_render_page, -1)
]
}
fn migrations(&self) -> Vec<MigrationItem> {
vec![
migration_item!(m20220316_000001_create_table_node_type),
migration_item!(m20220316_000002_create_table_node),
migration_item!(m20220316_000003_create_table_node_access),
migration_item!(m20220316_000004_create_table_node_revision),
]
}
}
@ -37,3 +43,7 @@ async fn node() -> app::Result<Markup> {
)
.render()
}
fn before_render_page(page: &mut Page) {
page.alter_body_classes("test-node", ClassesOp::Add);
}

View file

@ -19,7 +19,7 @@ enum NodeType {
// different from the current type name if the locked field is 0.
}
pub struct Migration;
pub_migration!(Migration);
#[async_trait::async_trait]
impl MigrationTrait for Migration {
@ -82,9 +82,3 @@ impl MigrationTrait for Migration {
.await
}
}
impl MigrationName for Migration {
fn name(&self) -> &str {
module_name!()
}
}

View file

@ -26,7 +26,7 @@ enum Node {
Translate, // A boolean indicating whether this translation page needs to be updated.
}
pub struct Migration;
pub_migration!(Migration);
#[async_trait::async_trait]
impl MigrationTrait for Migration {
@ -105,9 +105,3 @@ impl MigrationTrait for Migration {
.await
}
}
impl MigrationName for Migration {
fn name(&self) -> &str {
module_name!()
}
}

View file

@ -18,7 +18,7 @@ enum NodeAccess {
// this node.
}
pub struct Migration;
pub_migration!(Migration);
#[async_trait::async_trait]
impl MigrationTrait for Migration {
@ -65,9 +65,3 @@ impl MigrationTrait for Migration {
.await
}
}
impl MigrationName for Migration {
fn name(&self) -> &str {
module_name!()
}
}

View file

@ -20,7 +20,7 @@ enum NodeRevision {
// be displayed at the top of lists in which it appears.
}
pub struct Migration;
pub_migration!(Migration);
#[async_trait::async_trait]
impl MigrationTrait for Migration {
@ -83,9 +83,3 @@ impl MigrationTrait for Migration {
.await
}
}
impl MigrationName for Migration {
fn name(&self) -> &str {
module_name!()
}
}