rearrange intro selector to be side-by-side
parent
b02d3f3da7
commit
d8d9fb578c
48
src/page.rs
48
src/page.rs
|
@ -44,7 +44,6 @@ pub(crate) async fn home(
|
|||
// TODO: change this to returning a error to the client
|
||||
Redirect::to(&format!("{}/login", state.origin))
|
||||
})?;
|
||||
tracing::info!("user name: {}", user.name);
|
||||
let user_app_permissions = db.get_user_app_permissions(&user.name).unwrap_or_default();
|
||||
let can_add_guild = user_app_permissions.can(auth::AppPermission::AddGuild);
|
||||
|
||||
|
@ -155,7 +154,7 @@ fn intro_list<'a>(
|
|||
.builder(Tag::FieldSet, |b| {
|
||||
let mut b = b
|
||||
.attribute("class", "container")
|
||||
.attribute("style", "max-height: 50%; overflow-y: scroll");
|
||||
.attribute("style", "height: 256px; overflow: auto");
|
||||
for intro in intros {
|
||||
b = b.builder(Tag::Label, |b| {
|
||||
b.builder(Tag::Input, |b| {
|
||||
|
@ -265,24 +264,29 @@ pub(crate) async fn guild_dashboard(
|
|||
|
||||
let mut user_intros = user_intros.into_iter().peekable();
|
||||
|
||||
for guild_channel_name in guild_channels {
|
||||
for guild_channel_name in &guild_channels {
|
||||
// Get user intros for this channel
|
||||
let intros = user_intros
|
||||
.peeking_take_while(|(channel_name, _)| {
|
||||
channel_name == &&guild_channel_name
|
||||
channel_name == &guild_channel_name
|
||||
})
|
||||
.map(|(_, intros)| intros.map(|intro| &intro.intro))
|
||||
.flatten();
|
||||
|
||||
b = b.builder(Tag::Article, |b| {
|
||||
b.builder_text(Tag::Header, &guild_channel_name).builder(
|
||||
b = b.builder(Tag::Details, |b| {
|
||||
let mut b = b;
|
||||
if guild_channels.len() < 2 {
|
||||
b = b.attribute("open", "");
|
||||
}
|
||||
b.builder_text(Tag::Summary, guild_channel_name).builder(
|
||||
Tag::Div,
|
||||
|b| {
|
||||
b.attribute("id", "channel-intro-selector")
|
||||
.attribute("style", "display: flex; align-items: flex-end; max-height: 50%; overflow: hidden;")
|
||||
.push_builder(channel_intro_selector(
|
||||
&state.origin,
|
||||
guild_id,
|
||||
&guild_channel_name,
|
||||
guild_channel_name,
|
||||
intros,
|
||||
guild_intros.iter(),
|
||||
))
|
||||
|
@ -307,18 +311,24 @@ pub fn channel_intro_selector<'a>(
|
|||
guild_intros: impl Iterator<Item = &'a db::Intro>,
|
||||
) -> HtmxBuilder {
|
||||
HtmxBuilder::new(Tag::Empty)
|
||||
.builder_text(Tag::Strong, "Your Current Intros")
|
||||
.push_builder(intro_list(
|
||||
intros,
|
||||
"Remove Intro",
|
||||
&format!("{}/v2/intros/remove/{}/{}", origin, guild_id, &channel_name),
|
||||
))
|
||||
.builder_text(Tag::Strong, "Select Intros")
|
||||
.push_builder(intro_list(
|
||||
guild_intros,
|
||||
"Add Intro",
|
||||
&format!("{}/v2/intros/add/{}/{}", origin, guild_id, channel_name),
|
||||
))
|
||||
.builder(Tag::Div, |b| {
|
||||
b.attribute("style", "display: flex; flex-direction: column; justify-content: space-between; align-items: center; width: 100%; height: 100%; padding: 16px;")
|
||||
.builder_text(Tag::Strong, "Your Current Intros")
|
||||
.push_builder(intro_list(
|
||||
intros,
|
||||
"Remove Intro",
|
||||
&format!("{}/v2/intros/remove/{}/{}", origin, guild_id, &channel_name),
|
||||
))
|
||||
})
|
||||
.builder(Tag::Div, |b| {
|
||||
b.attribute("style", "display: flex; flex-direction: column; justify-content: space-between; align-items: center; width: 100%; height: 100%; padding: 16px;")
|
||||
.builder_text(Tag::Strong, "Select Intros")
|
||||
.push_builder(intro_list(
|
||||
guild_intros,
|
||||
"Add Intro",
|
||||
&format!("{}/v2/intros/add/{}/{}", origin, guild_id, channel_name),
|
||||
))
|
||||
})
|
||||
}
|
||||
|
||||
fn upload_form(origin: &str, guild_id: u64) -> HtmxBuilder {
|
||||
|
|
Loading…
Reference in New Issue