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

114 lines
4.5 KiB
HTML

@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};
@use uuid::Uuid;
@(collection: &Collection, collection_id: Uuid, entries: &[(Uuid, Entry)], token: &ValidToken, state: &State, qr: &str)
@:layout_html(state, "Edit Collection", None, {
<script src="@state.statics_path(file_upload_js.name)" type="text/javascript">
</script>
}, {
<section>
<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>
</section>
<section>
<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>
</article>
<article class="content-group">
<form method="POST" action="@state.update_collection_path(collection_id, token)">
@:text_input_html("title", Some("Collection Title"), Some(&collection.title), false)
@:text_area_html("description", Some("Collection Description"), Some(&collection.description), false)
<div class="button-group button-space">
@:button_html("Update Collection", ButtonKind::Submit)
@:button_link_html("Delete Collection", &state.delete_collection_path(collection_id, token, false),
ButtonKind::Outline)
</div>
</form>
</article>
<ul>
@for (i, (id, entry)) in entries.iter().enumerate() {
<li class="content-group" id="@id">
<article>
<div class="edit-row">
<div class="edit-item">
@:image_html(*id, entry, state)
</div>
<div class="edit-item">
<form method="POST" action="@state.update_entry_path(collection_id, *id, token)">
@: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(),
entry.file_parts().is_none())
@:text_input_html("link", Some("Image Link"), entry.link.as_ref().map(|l| l.as_str()),
entry.file_parts().is_none())
<div class="button-group button-space">
@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)
}
@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" />
@:button_html("Update Image", ButtonKind::Submit)
@:button_link_html("Delete Image", &state.delete_entry_path(collection_id, *id, token, false),
ButtonKind::Outline)
}
</div>
<div class="button-group button-space">
@if i != 0 {
@:button_link_html("Move Up", &state.move_entry_path(collection_id, *id, token, Direction::Up),
ButtonKind::Outline)
}
@if (i + 1) != entries.len() {
@:button_link_html("Move Down", &state.move_entry_path(collection_id, *id, token, Direction::Down),
ButtonKind::Outline)
}
</div>
</form>
</div>
</div>
</article>
</li>
}
</ul>
</section>
<section>
<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">
@:file_input_html("images[]", Some("Select Image"), Some(crate::accept()), false)
</div>
<div class="button-group button-space">
@:button_html("Upload", ButtonKind::Submit)
</div>
</div>
</form>
</article>
</section>
@:return_home_html(state)
})