~lthms/ogmios

509a8cd355262223c9fbbcec0d939c0efcd9ee64 — Thomas Letan 1 year, 8 months ago c758d21
feature: Improve navigation between current and future versions
2 files changed, 13 insertions(+), 17 deletions(-)

M src/routes/characters.rs
M templates/character_current.html.tera
M src/routes/characters.rs => src/routes/characters.rs +12 -16
@@ 34,6 34,8 @@ pub fn get_current_sheet(
        },
    };

    let future = Sheet::get_future_sheet(id, &conn)?.is_some();

    let user = match user {
        Some(user) => {
            let sheets = Sheet::get_current_sheets_of(user.id, &conn)?;


@@ 54,6 56,7 @@ pub fn get_current_sheet(
        json!({
            "msg": msg,
            "sheet": sheet,
            "future": future,
            "hash": env!("GIT_HASH"),
            "user": user,
        })


@@ 62,7 65,7 @@ pub fn get_current_sheet(

#[get("/character/<id>/future")]
pub fn get_future_sheet(
    user: Option<User>,
    user: User,
    conn: PgConn,
    id: i32,
) -> Result<Template, Error> {


@@ 77,27 80,20 @@ pub fn get_future_sheet(
        },
    };

    let user = match user {
        Some(user) => {
            let sheets = Sheet::get_current_sheets_of(user.id, &conn)?;

            Some(json!({
                "default": user.default_character,
                "characters": sheets,
                "nickname": user.nickname
            }))
        }
        _ => {
            None
        }
    };
    let current = Sheet::get_current_sheet(id, &conn)?.is_some();
    let sheets = Sheet::get_current_sheets_of(user.id, &conn)?;

    Ok(Template::render(
        "character_future",
        json!({
            "sheet": sheet,
            "current": current,
            "hash": env!("GIT_HASH"),
            "user": user,
            "user": json!({
                "default": user.default_character,
                "characters": sheets,
                "nickname": user.nickname
            }),
        })
    ))
}

M templates/character_current.html.tera => templates/character_current.html.tera +1 -1
@@ 1,6 1,7 @@
{% extends "character" %}

{% block characternav %}
{% if user %}
{% if future %}
<a href="/character/{{ sheet.character_id }}/future">
  <button class="ui button">


@@ 9,7 10,6 @@
</a>
{% else %}

{% if user %}
<form method="post" action="/character/{{ sheet.character_id }}/future/new">
  <button class="ui button positive submit">
    Start an update