fix: ingestion modal works on all pages

This commit is contained in:
Per Stark
2025-04-30 15:10:53 +02:00
parent 3f032c6930
commit 0169c9b525
3 changed files with 19 additions and 13 deletions

View File

@@ -1,7 +1,9 @@
<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">
{% if text_content.url_info %}
<img class="rounded-t-md overflow-clip" src="/file/{{text_content.url_info.image_id}}" />
{% endif %}
<div class="card-body">
<div class="flex justify-between space-x-2">
<h2 class="card-title truncate">
@@ -14,7 +16,7 @@
{% endif %}
</h2>
<div class="flex-shrink-0">
{% if text_content.url %}
{% if text_content.url_info %}
{% include "icons/globe_icon.html" %}
{% elif text_content.file_info %}
{% include "icons/document_icon.html" %}

View File

@@ -1,15 +1,10 @@
{% extends "modal_base.html" %}
{% block form_attributes %}
hx-post="/ingress-form"
enctype="multipart/form-data"
hx-target="#active_jobs_section"
hx-swap="outerHTML"
{% endblock %}
{% block modal_content %}
<h3 class="text-lg font-bold">Add new content</h3>
<div class="form-control">
<label class="floating-label">
<span>Instructions</span>
@@ -19,7 +14,6 @@ hx-swap="outerHTML"
<div class="validator-hint hidden">Instructions are required</div>
</label>
</div>
<div class="form-control">
<label class="floating-label">
<span>Content</span>
@@ -27,7 +21,6 @@ hx-swap="outerHTML"
placeholder="Enter the content you want to ingress, it can be an URL or a text snippet">{{ content }}</textarea>
</label>
</div>
<div class="form-control">
<label class="floating-label">
<span>Category</span>
@@ -41,15 +34,26 @@ hx-swap="outerHTML"
<div class="validator-hint hidden">Category is required</div>
</label>
</div>
<div class="form-control">
<label class="label label-text">Files</label>
<input type="file" name="files" multiple class="file-input file-input-bordered w-full" />
</div>
<div id="error-message" class="text-error text-center {% if not error %}hidden{% endif %}">{{ error }}</div>
<script>
(function () {
const form = document.getElementById('modal_form');
if (!form) return;
const targetElement = document.getElementById('active_jobs_section');
if (targetElement) {
form.setAttribute('hx-target', '#active_jobs_section');
form.setAttribute('hx-swap', 'outerHTML');
} else {
form.setAttribute('hx-swap', 'none');
form.removeAttribute('hx-target');
}
})();
</script>
{% endblock %}
{% block primary_actions %}
<button type="submit" class="btn btn-primary">
Save Changes

View File

@@ -32,7 +32,8 @@
</li>
{% endfor %}
<li>
<button class="btn btn-primary" hx-get="/ingress-form" hx-target="#modal" hx-swap="innerHTML">Add
<button class="btn btn-primary btn-outline w-full flex items-center gap-3 justify-start mt-2"
hx-get="/ingress-form" hx-target="#modal" hx-swap="innerHTML">{% include "icons/send_icon.html" %} Add
Content</button>
</li>
<div class="divider "></div>
@@ -78,7 +79,6 @@
</li>
{% endfor %}
{% else %}
<li><span class="text-xs italic text-base-content/60 px-4">No recent chats</span></li>
{% endif %}
</div>