2022-01-30 20:52:49 +00:00
|
|
|
@use crate::{ui::ButtonKind, Collection, Direction, Entry, State, ValidToken};
|
2020-12-12 03:36:07 +00:00
|
|
|
@use super::{button, button_link, image, file_input, layout, return_home, text_area, text_input, statics::file_upload_js};
|
2020-12-08 21:59:55 +00:00
|
|
|
@use uuid::Uuid;
|
|
|
|
|
2020-12-10 05:09:39 +00:00
|
|
|
@(collection: &Collection, collection_id: Uuid, entries: &[(Uuid, Entry)], token: &ValidToken, state: &State)
|
2020-12-08 21:59:55 +00:00
|
|
|
|
2020-12-10 05:09:39 +00:00
|
|
|
@:layout(state, "Edit Collection", None, {
|
2020-12-08 21:59:55 +00:00
|
|
|
<script
|
2021-09-12 16:30:22 +00:00
|
|
|
src="@state.statics_path(file_upload_js.name)"
|
2020-12-08 21:59:55 +00:00
|
|
|
type="text/javascript"
|
|
|
|
>
|
|
|
|
</script>
|
|
|
|
}, {
|
|
|
|
<section>
|
|
|
|
<article class="content-group">
|
2020-12-10 05:09:39 +00:00
|
|
|
<h3>Share Collection</h3>
|
2020-12-08 21:59:55 +00:00
|
|
|
</article>
|
|
|
|
<article class="content-group">
|
|
|
|
<a
|
2020-12-10 05:09:39 +00:00
|
|
|
href="@state.public_collection_path(collection_id)"
|
2020-12-08 21:59:55 +00:00
|
|
|
target="_blank"
|
|
|
|
rel="noopen noreferer"
|
|
|
|
>
|
|
|
|
Public Link
|
|
|
|
</a>
|
|
|
|
</article>
|
|
|
|
</section>
|
|
|
|
<section>
|
|
|
|
<article class="content-group">
|
2020-12-10 05:09:39 +00:00
|
|
|
<h3>Edit Collection</h3>
|
2020-12-08 21:59:55 +00:00
|
|
|
</article>
|
|
|
|
<article class="content-group">
|
2020-12-10 05:09:39 +00:00
|
|
|
<p class="subtitle"><a href="@state.edit_collection_path(collection_id, token)">Do not lose this link</a></p>
|
2020-12-08 21:59:55 +00:00
|
|
|
</article>
|
|
|
|
<article class="content-group">
|
2020-12-10 05:09:39 +00:00
|
|
|
<form method="POST" action="@state.update_collection_path(collection_id, token)">
|
2020-12-12 03:36:07 +00:00
|
|
|
@:text_input("title", Some("Collection Title"), Some(&collection.title))
|
|
|
|
@:text_area("description", Some("Collection Description"), Some(&collection.description))
|
|
|
|
<div class="button-group button-space">
|
2020-12-10 05:09:39 +00:00
|
|
|
@:button("Update Collection", ButtonKind::Submit)
|
2020-12-12 03:36:07 +00:00
|
|
|
@:button_link("Delete Collection", &state.delete_collection_path(collection_id, token, false), ButtonKind::Outline)
|
2020-12-08 21:59:55 +00:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</article>
|
|
|
|
<ul>
|
2022-01-30 20:56:31 +00:00
|
|
|
@for (i, (id, entry)) in entries.iter().enumerate() {
|
2020-12-08 21:59:55 +00:00
|
|
|
<li class="content-group">
|
|
|
|
<article>
|
|
|
|
<div class="edit-row">
|
|
|
|
<div class="edit-item">
|
2020-12-12 03:36:07 +00:00
|
|
|
@:image(entry, state)
|
2020-12-08 21:59:55 +00:00
|
|
|
</div>
|
|
|
|
<div class="edit-item">
|
2020-12-10 05:09:39 +00:00
|
|
|
<form method="POST" action="@state.update_entry_path(collection_id, *id, token)">
|
2020-12-12 03:36:07 +00:00
|
|
|
@:text_input("title", Some("Image Title"), Some(&entry.title))
|
|
|
|
@:text_area("description", Some("Image Description"), Some(&entry.description))
|
2020-12-08 21:59:55 +00:00
|
|
|
<input type="hidden" name="filename" value="@entry.filename" />
|
|
|
|
<input type="hidden" name="delete_token" value="@entry.delete_token" />
|
2020-12-12 03:36:07 +00:00
|
|
|
<div class="button-group button-space">
|
2020-12-08 21:59:55 +00:00
|
|
|
@:button("Update Image", ButtonKind::Submit)
|
2020-12-12 03:36:07 +00:00
|
|
|
@:button_link("Delete Image", &state.delete_entry_path(collection_id, *id, token, false), ButtonKind::Outline)
|
2020-12-08 21:59:55 +00:00
|
|
|
</div>
|
2022-01-30 20:52:49 +00:00
|
|
|
|
|
|
|
<div class="button-group button-space">
|
|
|
|
@if i != 0 {
|
|
|
|
@:button_link("Move Up", &state.move_entry_path(collection_id, *id, token, Direction::Up), ButtonKind::Outline)
|
|
|
|
}
|
|
|
|
|
|
|
|
@if (i + 1) != entries.len() {
|
|
|
|
@:button_link("Move Down", &state.move_entry_path(collection_id, *id, token, Direction::Down), ButtonKind::Outline)
|
|
|
|
}
|
|
|
|
</div>
|
2020-12-08 21:59:55 +00:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</article>
|
|
|
|
</li>
|
|
|
|
}
|
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
<section>
|
|
|
|
<article>
|
|
|
|
<form
|
|
|
|
method="POST"
|
2020-12-10 05:09:39 +00:00
|
|
|
action="@state.create_entry_path(collection_id, token)"
|
2020-12-08 21:59:55 +00:00
|
|
|
enctype="multipart/form-data"
|
|
|
|
>
|
|
|
|
<div class="content-group">
|
|
|
|
<h3><legend>Add Image</legend></h3>
|
|
|
|
</div>
|
|
|
|
<div class="content-group" id="file-input-container">
|
2020-12-12 03:36:07 +00:00
|
|
|
<div class="button-group">
|
2020-12-08 21:59:55 +00:00
|
|
|
@:file_input("images[]", Some("Select Image"), Some(crate::accept()), false)
|
|
|
|
</div>
|
2020-12-12 03:36:07 +00:00
|
|
|
<div class="button-group button-space">
|
2020-12-08 21:59:55 +00:00
|
|
|
@:button("Upload", ButtonKind::Submit)
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</article>
|
|
|
|
</section>
|
2020-12-12 03:36:07 +00:00
|
|
|
@:return_home(state)
|
2020-12-08 21:59:55 +00:00
|
|
|
})
|