Improve pending image state

This commit is contained in:
asonix 2022-06-21 10:44:39 -05:00
parent 40a76f4cb0
commit 3b4e7db912
4 changed files with 58 additions and 68 deletions

View file

@ -33,8 +33,8 @@ statics::file_upload_js};
</article> </article>
<article class="content-group"> <article class="content-group">
<form method="POST" action="@state.update_collection_path(collection_id, token)"> <form method="POST" action="@state.update_collection_path(collection_id, token)">
@:text_input("title", Some("Collection Title"), Some(&collection.title)) @:text_input("title", Some("Collection Title"), Some(&collection.title), false)
@:text_area("description", Some("Collection Description"), Some(&collection.description)) @:text_area("description", Some("Collection Description"), Some(&collection.description), false)
<div class="button-group button-space"> <div class="button-group button-space">
@:button("Update Collection", ButtonKind::Submit) @:button("Update Collection", ButtonKind::Submit)
@:button_link("Delete Collection", &state.delete_collection_path(collection_id, token, false), @:button_link("Delete Collection", &state.delete_collection_path(collection_id, token, false),
@ -52,21 +52,25 @@ statics::file_upload_js};
</div> </div>
<div class="edit-item"> <div class="edit-item">
<form method="POST" action="@state.update_entry_path(collection_id, *id, token)"> <form method="POST" action="@state.update_entry_path(collection_id, *id, token)">
@if let Some(upload_id) = entry.upload_id() { @:text_input("title", Some("Image Title"), entry.title.as_deref(), entry.file_parts().is_none())
<input type="hidden" name="upload_id" value="@upload_id" /> @:text_area("description", Some("Image Description"), entry.description.as_deref(),
} entry.file_parts().is_none())
@if let Some((filename, delete_token)) = entry.file_parts() { @:text_input("link", Some("Image Link"), entry.link.as_ref().map(|l| l.as_str()),
@:text_input("title", Some("Image Title"), entry.title.as_deref()) entry.file_parts().is_none())
@:text_area("description", Some("Image Description"), entry.description.as_deref())
@:text_input("link", Some("https://..."), entry.link.as_ref().map(|l| l.as_str()))
<input type="hidden" name="filename" value="@filename" />
<input type="hidden" name="delete_token" value="@delete_token" />
<div class="button-group button-space"> <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("Refresh", &state.edit_collection_path(collection_id, token), 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("Update Image", ButtonKind::Submit) @:button("Update Image", ButtonKind::Submit)
@:button_link("Delete Image", &state.delete_entry_path(collection_id, *id, token, false), @:button_link("Delete Image", &state.delete_entry_path(collection_id, *id, token, false),
ButtonKind::Outline) ButtonKind::Outline)
}
</div> </div>
<div class="button-group button-space"> <div class="button-group button-space">
@if i != 0 { @if i != 0 {
@:button_link("Move Up", &state.move_entry_path(collection_id, *id, token, Direction::Up), @:button_link("Move Up", &state.move_entry_path(collection_id, *id, token, Direction::Up),
@ -78,7 +82,6 @@ statics::file_upload_js};
ButtonKind::Outline) ButtonKind::Outline)
} }
</div> </div>
}
</form> </form>
</div> </div>
</div> </div>

View file

@ -5,21 +5,23 @@
@:layout(state, "Collection", None, {}, { @:layout(state, "Collection", None, {}, {
<section> <section>
<article> <article>
<form method="POST" action="@state.create_collection_path()"> <form method="POST" action="@state.create_collection_path()">
<div class="content-group"> <div class="content-group">
<h3><legend>Create Collection</legend></h3> <h3>
</div> <legend>Create Collection</legend>
<div class="content-group"> </h3>
@:text_input("title", Some("Title"), None) </div>
@:text_area("description", Some("Description"), None) <div class="content-group">
</div> @:text_input("title", Some("Title"), None, false)
<div class="content-group"> @:text_area("description", Some("Description"), None, false)
<div class="button-group"> </div>
@:button("Create Collection", ButtonKind::Submit) <div class="content-group">
</div> <div class="button-group">
</div> @:button("Create Collection", ButtonKind::Submit)
</form> </div>
</article> </div>
</form>
</article>
</section> </section>
}) })

View file

@ -1,21 +1,12 @@
@(name: &str, title: Option<&str>, value: Option<&str>) @(name: &str, title: Option<&str>, value: Option<&str>, disabled: bool)
<div class="input-wrapper">
@if let Some(title) = title {
<label for="@name">
<div class="input-title">@title</div>
@if let Some(value) = value {
<textarea class="input" name="@name">@value</textarea>
} else {
<textarea class="input" name="@name"></textarea>
}
</label>
} else {
@if let Some(value) = value {
<textarea class="input" name="@name">@value</textarea>
} else {
<textarea class="input" name="@name"></textarea>
}
}
</div>
<div class="input-wrapper">
@if let Some(title) = title {
<label for="@name">
<div class="input-title">@title</div>
<textarea class="input" name="@name" @if disabled { disabled }>@if let Some(value) = value { @value }</textarea>
</label>
} else {
<textarea class="input" name="@name" @if disabled { disabled }>@if let Some(value) = value { @value }</textarea>
}
</div>

View file

@ -1,20 +1,14 @@
@(name: &str, title: Option<&str>, value: Option<&str>) @(name: &str, title: Option<&str>, value: Option<&str>, disabled: bool)
<div class="input-wrapper"> <div class="input-wrapper">
@if let Some(title) = title { @if let Some(title) = title {
<label for="@name"> <label for="@name">
<div class="input-title">@title</div> <div class="input-title">@title</div>
@if let Some(value) = value { <input type="text" class="input" name="@name" @if disabled { disabled } @if let Some(value)=value {
<input type="text" class="input" name="@name" value="@value" /> value="@value" } />
} else { </label>
<input type="text" class="input" name="@name" /> } else {
} <input type="text" class="input" name="@name" @if disabled { disabled } @if let Some(value)=value { value="@value"
</label> } />
} else { }
@if let Some(value) = value { </div>
<input type="text" class="input" name="@name" value="@value" />
} else {
<input type="text" class="input" name="@name" />
}
}
</div>