feat: show content and wip editing

This commit is contained in:
Per Stark
2025-02-13 11:12:32 +01:00
parent 09b2451021
commit c055245a48
15 changed files with 326 additions and 33 deletions

View File

@@ -0,0 +1,12 @@
{% extends 'body_base.html' %}
{% block main %}
<main class="flex justify-center grow mt-2 sm:mt-4 gap-6 mb-10">
<div class="container">
<h2 class="text-2xl font-bold mb-2">Text Contents</h2>
{% include "content/content_list.html" %}
</div>
</main>
{% endblock %}

View File

@@ -0,0 +1,40 @@
<div class="grid sm:grid-cols-2 lg:grid-cols-3 gap-4" id="text_content_cards">
{% for text_content in text_contents %}
<div class="card min-w-72 bg-base-100 shadow">
<div class="card-body">
<div class="flex items-center space-x-2">
<div class="flex-shrink-0">
{% if text_content.url %}
{% include "icons/globe_icon.html" %}
{% elif text_content.file_info %}
{% include "icons/document_icon.html" %}
{% else %}
{% include "icons/chat_icon.html" %}
{% endif %}
</div>
<h2 class="card-title truncate">
{{ text_content.text }}
</h2>
</div>
<div class="flex items-center">
<p class="text-xs opacity-60">
{{ text_content.created_at | datetimeformat(format="short", tz=user.timezone) }}
</p>
<div class="flex gap-2">
<button hx-get="/content/{{ text_content.id }}" hx-target="#modal" hx-swap="innerHTML"
class="btn btn-square btn-ghost btn-sm">
{% include "icons/edit_icon.html" %}
</button>
<button hx-delete="/content/{{ text_content.id }}" hx-target="#text_content_cards" hx-swap="outerHTML"
class="btn btn-square btn-ghost btn-sm">
{% include "icons/delete_icon.html" %}
</button>
</div>
</div>
<p class="mt-2">
{{ text_content.instructions }}
</p>
</div>
</div>
{% endfor %}
</div>

View File

@@ -0,0 +1,33 @@
{% extends "modal_base.html" %}
{% block form_attributes %}
hx-patch="/content/{{text_content.id}}"
hx-target="#text_content_cards"
hx-swap="outerHTML"
{% endblock %}
{% block modal_content %}
<h3 class="text-lg font-bold mb-4">Edit Content</h3>
<div class="form-control">
<label class="floating-label">
<span class="label-text">Content Name</span>
<input type="text" name="name" value="{{ text_content.text }}" class="w-full input input-bordered">
</label>
</div>
<input type="text" name="id" value="{{ text_content.id }}" class="hidden">
<div class="form-control mt-4 ">
<label class="floating-label">
<span class="label-text">Description</span>
<textarea name="description" class="textarea textarea-bordered h-32 w-full">{{ text_content.text}}</textarea>
</label>
</div>
{% endblock %}
{% block primary_actions %}
<button type="submit" class="btn btn-primary">
Save Changes
</button>
{% endblock %}