Skip to content

Commit dd2e78e

Browse files
committed
minor: ContentFolderShowTemplate constructor
1 parent 5fa2a78 commit dd2e78e

2 files changed

Lines changed: 24 additions & 11 deletions

File tree

src/routes/content_folder.rs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub struct ContentFolderShowTemplate {
3030
/// Global application state
3131
pub state: AppStateContext,
3232
/// current folder
33-
pub current_content_folder: content_folder::Model,
33+
pub folder: content_folder::Model,
3434
/// Folders with parent_id set to current folder
3535
pub children: Vec<FileSystemEntry>,
3636
/// Category
@@ -41,6 +41,26 @@ pub struct ContentFolderShowTemplate {
4141
pub flash: Option<OperationStatus>,
4242
}
4343

44+
impl ContentFolderShowTemplate {
45+
fn new(context: AppStateContext, folder: FolderRequest) -> Self {
46+
let FolderRequest {
47+
breadcrumbs,
48+
category,
49+
children,
50+
folder,
51+
} = folder;
52+
53+
Self {
54+
breadcrumbs,
55+
category,
56+
children,
57+
flash: None,
58+
folder,
59+
state: context,
60+
}
61+
}
62+
}
63+
4464
impl FallibleTemplate for ContentFolderShowTemplate {
4565
fn with_optional_flash(&mut self, flash: Option<OperationStatus>) {
4666
self.flash = flash;
@@ -52,14 +72,7 @@ pub async fn show(
5272
folder: FolderRequest,
5373
status: StatusCookie,
5474
) -> FlashTemplate<ContentFolderShowTemplate> {
55-
status.with_template(ContentFolderShowTemplate {
56-
breadcrumbs: folder.breadcrumbs,
57-
children: folder.children,
58-
current_content_folder: folder.folder,
59-
category: folder.category,
60-
state: context,
61-
flash: None,
62-
})
75+
status.with_template(ContentFolderShowTemplate::new(context, folder))
6376
}
6477

6578
pub async fn create(

templates/content_folders/show.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% extends "layouts/file_system_base.html" %}
22

33
{% block folder_title %}
4-
{{ current_content_folder.name }}
4+
{{ folder.name }}
55
{% endblock%}
66

77
{% block actions_buttons %}
@@ -22,7 +22,7 @@
2222
</div>
2323

2424
<input type="hidden" id="category_id" name="category_id" value="{{ category.id }}" />
25-
<input type="hidden" id="parent_id" name="parent_id" value="{{ current_content_folder.id }}" />
25+
<input type="hidden" id="parent_id" name="parent_id" value="{{ folder.id }}" />
2626
<input type="hidden" id="path" name="path" value="fake_path" />
2727

2828
<div class="text-center mt-4">

0 commit comments

Comments
 (0)