Skip to content

Commit

Permalink
Added small toolbox to text view if logged in. (Actions not implement…
Browse files Browse the repository at this point in the history
…ed.)
  • Loading branch information
BurnyLlama committed Apr 21, 2024
1 parent b2b6d06 commit e67d9bc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ async fn text_by_id(
return Ok(AnyResponder::from(redirect));
}

let template = Template::render("text-by-id", context! { text, tags, authors, is_logged_in });
let template = Template::render(
"single-text-view",
context! { text, tags, authors, is_logged_in, creator: claims.map(|claims| claims.data) },
);
Ok(AnyResponder::from(template))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,33 @@
#}
</article>
{% endblock main %}

{% block aside %}
{% if is_logged_in %}
<div class="side-content">
<h1>Verktygslåda</h1>
<div class="flex wrap gap">
{% if text.author == creator.username %}
{% if text.marked_as_done %}
<button class="btn" icon="done">Markera som klar</button>
{% else %}
<button class="btn" icon="close">Markera som inte klar</button>
{% endif %}
{% endif %}

{% if creator.role == "Publisher" or text.author == creator.username and not text.is_published %}
<button class="btn" icon="edit_note">Redigera</button>
{% endif %}

{% if creator.role == "Publisher" %}
{% if text.is_published %}
<button class="btn dangerous" icon="unpublished">Avpublicera</button>
{% else %}
<button class="btn dangerous" icon="publish">Publicera</button>
{% endif %}
{% endif %}
</div>
</div>
{% endif %}
{{ super() }}
{% endblock aside %}

0 comments on commit e67d9bc

Please sign in to comment.