pict-rs-aggregator/templates/edit_collection.rs.html

114 lines
4.5 KiB
HTML
Raw Permalink Normal View History

2022-01-30 20:52:49 +00:00
@use crate::{ui::ButtonKind, Collection, Direction, Entry, State, ValidToken};
@use super::{button_html, button_link_html, image_html, file_input_html, layout_html, return_home_html, text_area_html,
text_input_html, statics::file_upload_js};
2020-12-08 21:59:55 +00:00
@use uuid::Uuid;
2022-02-19 02:08:56 +00:00
@(collection: &Collection, collection_id: Uuid, entries: &[(Uuid, Entry)], token: &ValidToken, state: &State, qr: &str)
2020-12-08 21:59:55 +00:00
2023-01-29 19:51:04 +00:00
@:layout_html(state, "Edit Collection", None, {
2022-02-19 02:08:56 +00:00
<script src="@state.statics_path(file_upload_js.name)" type="text/javascript">
</script>
2020-12-08 21:59:55 +00:00
}, {
<section>
2022-02-19 02:08:56 +00:00
<article class="content-group">
<h3>Share Collection</h3>
</article>
<article class="content-group">
<a href="@state.public_collection_path(collection_id)" target="_blank" rel="noopen noreferer">
Public Link
</a>
</article>
<article class="content-group">
<div class="qr">
@Html(qr)
</div>
</article>
2020-12-08 21:59:55 +00:00
</section>
<section>
2022-02-19 02:08:56 +00:00
<article class="content-group">
<h3>Edit Collection</h3>
</article>
<article class="content-group">
<p class="subtitle"><a href="@state.edit_collection_path(collection_id, None, token)">Do not lose this link</a></p>
2022-02-19 02:08:56 +00:00
</article>
<article class="content-group">
<form method="POST" action="@state.update_collection_path(collection_id, token)">
2023-01-29 19:51:04 +00:00
@:text_input_html("title", Some("Collection Title"), Some(&collection.title), false)
@:text_area_html("description", Some("Collection Description"), Some(&collection.description), false)
2022-02-19 02:08:56 +00:00
<div class="button-group button-space">
2023-01-29 19:51:04 +00:00
@:button_html("Update Collection", ButtonKind::Submit)
@:button_link_html("Delete Collection", &state.delete_collection_path(collection_id, token, false),
2022-02-19 02:08:56 +00:00
ButtonKind::Outline)
</div>
</form>
</article>
<ul>
@for (i, (id, entry)) in entries.iter().enumerate() {
<li class="content-group" id="@id">
2022-02-19 02:08:56 +00:00
<article>
<div class="edit-row">
<div class="edit-item">
@:image_html(*id, entry, state)
2022-02-19 02:08:56 +00:00
</div>
<div class="edit-item">
<form method="POST" action="@state.update_entry_path(collection_id, *id, token)">
2023-01-29 19:51:04 +00:00
@:text_input_html("title", Some("Image Title"), entry.title.as_deref(), entry.file_parts().is_none())
@:text_area_html("description", Some("Image Description"), entry.description.as_deref(),
2022-06-21 15:44:39 +00:00
entry.file_parts().is_none())
2023-01-29 19:51:04 +00:00
@:text_input_html("link", Some("Image Link"), entry.link.as_ref().map(|l| l.as_str()),
2022-06-21 15:44:39 +00:00
entry.file_parts().is_none())
2022-02-19 02:08:56 +00:00
<div class="button-group button-space">
2022-06-21 15:44:39 +00:00
@if let Some(upload_id) = entry.upload_id() {
<input type="hidden" name="upload_id" value="@upload_id" />
@:button_link_html("Refresh", "javascript:window.location.reload(true);", ButtonKind::Submit)
2022-06-21 15:44:39 +00:00
}
@if let Some((filename, delete_token)) = entry.file_parts() {
<input type="hidden" name="filename" value="@filename" />
<input type="hidden" name="delete_token" value="@delete_token" />
2023-01-29 19:51:04 +00:00
@:button_html("Update Image", ButtonKind::Submit)
@:button_link_html("Delete Image", &state.delete_entry_path(collection_id, *id, token, false),
2022-02-19 02:08:56 +00:00
ButtonKind::Outline)
2022-06-21 15:44:39 +00:00
}
2022-02-19 02:08:56 +00:00
</div>
<div class="button-group button-space">
@if i != 0 {
2023-01-29 19:51:04 +00:00
@:button_link_html("Move Up", &state.move_entry_path(collection_id, *id, token, Direction::Up),
2022-02-19 02:08:56 +00:00
ButtonKind::Outline)
}
2022-01-30 20:52:49 +00:00
2022-02-19 02:08:56 +00:00
@if (i + 1) != entries.len() {
2023-01-29 19:51:04 +00:00
@:button_link_html("Move Down", &state.move_entry_path(collection_id, *id, token, Direction::Down),
2022-02-19 02:08:56 +00:00
ButtonKind::Outline)
}
</div>
</form>
</div>
</div>
</article>
</li>
}
</ul>
2020-12-08 21:59:55 +00:00
</section>
<section>
2022-02-19 02:08:56 +00:00
<article>
<form method="POST" action="@state.create_entry_path(collection_id, token)" enctype="multipart/form-data">
<div class="content-group">
<h3>
<legend>Add Image</legend>
</h3>
</div>
<div class="content-group" id="file-input-container">
<div class="button-group">
2023-01-29 19:51:04 +00:00
@:file_input_html("images[]", Some("Select Image"), Some(crate::accept()), false)
2022-02-19 02:08:56 +00:00
</div>
<div class="button-group button-space">
2023-01-29 19:51:04 +00:00
@:button_html("Upload", ButtonKind::Submit)
2022-02-19 02:08:56 +00:00
</div>
</div>
</form>
</article>
2020-12-08 21:59:55 +00:00
</section>
2023-01-29 19:51:04 +00:00
@:return_home_html(state)
2020-12-08 21:59:55 +00:00
})