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