Skip to content

Commit 13005ca

Browse files
amateurforgerangrynode
authored andcommitted
fix: Readd operation status on new category page
1 parent b8ada45 commit 13005ca

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

src/routes/category.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::database::content_folder;
1212
use crate::database::{category, category::CategoryOperator};
1313
use crate::extractors::normalized_path::*;
1414
use crate::extractors::user::User;
15-
use crate::state::flash_message::OperationStatus;
15+
use crate::state::flash_message::{OperationStatus, get_cookie};
1616
use crate::state::{AppState, AppStateContext, error::*};
1717

1818
#[derive(Clone, Debug, Deserialize, Serialize)]
@@ -123,13 +123,16 @@ pub struct CategoryShowTemplate {
123123
pub user: Option<User>,
124124
/// Category
125125
category: category::Model,
126+
/// Operation status for UI confirmation (Cookie)
127+
pub flash: Option<OperationStatus>,
126128
}
127129

128130
pub async fn show(
129131
State(app_state): State<AppState>,
130132
user: Option<User>,
131133
Path(category_name): Path<String>,
132-
) -> Result<CategoryShowTemplate, AppStateError> {
134+
jar: CookieJar,
135+
) -> Result<impl IntoResponse, AppStateError> {
133136
let app_state_context = app_state.context().await?;
134137

135138
let category: category::Model = CategoryOperator::new(app_state.clone(), user.clone())
@@ -144,10 +147,16 @@ pub async fn show(
144147
.await
145148
.context(CategorySnafu)?;
146149

147-
Ok(CategoryShowTemplate {
148-
content_folders,
149-
category,
150-
state: app_state_context,
151-
user,
152-
})
150+
let (jar, operation_status) = get_cookie(jar);
151+
152+
Ok((
153+
jar,
154+
CategoryShowTemplate {
155+
content_folders,
156+
category,
157+
state: app_state_context,
158+
user,
159+
flash: operation_status,
160+
},
161+
))
153162
}

templates/categories/show.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ <h5 class="mb-0">
5757
{% include "content_folders/dropdown_actions.html" %}
5858
{% endblock %}
5959

60+
{% block alert_message %}
61+
{% include "shared/alert_operation_status.html" %}
62+
{% endblock %}
63+
6064
{% block content_folder_form %}
6165
<form method="POST" action="/folders" accept-charset="utf-8">
6266
<div class="form-group">

0 commit comments

Comments
 (0)