mirror of
https://github.com/perstarkse/minne.git
synced 2026-04-23 17:28:34 +02:00
feat: show content and wip editing
This commit is contained in:
12
templates/content/base.html
Normal file
12
templates/content/base.html
Normal 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 %}
|
||||
40
templates/content/content_list.html
Normal file
40
templates/content/content_list.html
Normal 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>
|
||||
33
templates/content/edit_text_content_modal.html
Normal file
33
templates/content/edit_text_content_modal.html
Normal 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 %}
|
||||
@@ -1,5 +1,6 @@
|
||||
<div class="flex gap-4 flex-col sm:flex-row">
|
||||
<a class="btn btn-secondary" href="/knowledge" hx-boost="true">View Knowledge</a>
|
||||
<a class="btn btn-accent" href="/content" hx-boost="true">View Content</a>
|
||||
<button class="btn btn-primary" hx-get="/ingress-form" hx-target="#modal" hx-swap="innerHTML">Add
|
||||
Content</button>
|
||||
</div>
|
||||
@@ -10,19 +10,19 @@ hx-swap="outerHTML"
|
||||
<h3 class="text-lg font-bold mb-4">Edit Entity</h3>
|
||||
|
||||
<div class="form-control">
|
||||
<label class="label">
|
||||
<label class="floating-label">
|
||||
<span class="label-text">Entity Name</span>
|
||||
<input type="text" name="name" value="{{ entity.name }}" class="input input-bordered w-full">
|
||||
</label>
|
||||
<input type="text" name="name" value="{{ entity.name }}" class="input input-bordered">
|
||||
</div>
|
||||
|
||||
<input type="text" name="id" value="{{ entity.id }}" class="hidden">
|
||||
|
||||
<div class="form-control mt-4">
|
||||
<label class="label">
|
||||
<label class="floating-label">
|
||||
<span class="label-text">Description</span>
|
||||
<textarea name="description" class="w-full textarea textarea-bordered h-32">{{ entity.description }}</textarea>
|
||||
</label>
|
||||
<textarea name="description" class="textarea textarea-bordered h-32">{{ entity.description }}</textarea>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -15,29 +15,22 @@
|
||||
<!-- Origin column -->
|
||||
<td>
|
||||
{% for entity in entities if entity.id == relationship.in %}
|
||||
<span class="cursor-pointer tooltip tooltip-info" data-tip="Click for more details"
|
||||
hx-get="/knowledge-entity/{{entity.id}}" hx-trigger="click" hx-target="#entity_detail_modal"
|
||||
hx-swap="innerHTML">
|
||||
{{ entity.name }}
|
||||
<span> {{ entity.name }}
|
||||
</span>
|
||||
{% else %}
|
||||
{{ relationship.in }}
|
||||
{% endfor %}
|
||||
</td>
|
||||
|
||||
<!-- Target column -->
|
||||
<td>
|
||||
{% for entity in entities if entity.id == relationship.out %}
|
||||
<span class="cursor-pointer tooltip tooltip-info" data-tip="Click for more details"
|
||||
hx-get="/knowledge-entity/{{entity.id}}" hx-trigger="click" hx-target="#entity_detail_modal"
|
||||
hx-swap="innerHTML">
|
||||
<span>
|
||||
{{ entity.name }}
|
||||
</span>
|
||||
{% else %}
|
||||
{{ relationship.out }}
|
||||
{% endfor %}
|
||||
</td>
|
||||
|
||||
<td>{{ relationship.metadata.relationship_type }}</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-outline" hx-delete="/knowledge-relationship/{{ relationship.id }}"
|
||||
@@ -50,15 +43,17 @@
|
||||
<!-- New linking row -->
|
||||
<tr id="new_relationship">
|
||||
<td>
|
||||
<select name="origin_id" class="select select-bordered w-full new_relationship_input">
|
||||
<select name="in_" class="select select-bordered w-full new_relationship_input">
|
||||
<option disabled selected>Select Origin</option>
|
||||
{% for entity in entities %}
|
||||
<option value="{{ entity.id }}">{{ entity.name }}</option>
|
||||
<option value="{{ entity.id }}">
|
||||
{{ entity.name }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select name="target_id" class="select select-bordered w-full new_relationship_input">
|
||||
<select name="out" class="select select-bordered w-full new_relationship_input">
|
||||
<option disabled selected>Select Target</option>
|
||||
{% for entity in entities %}
|
||||
<option value="{{ entity.id }}">{{ entity.name }}</option>
|
||||
@@ -66,12 +61,13 @@
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<input name="relationship_type" type="text" placeholder="RelatedTo"
|
||||
<input id="relationship_type_input" name="relationship_type" type="text" placeholder="RelatedTo"
|
||||
class="input input-bordered w-full new_relationship_input" />
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-primary btn-sm" hx-post="/relationship/create"
|
||||
hx-target="#relationship_table" hx-swap="outerHTML" hx-include=".new_relationship_input">
|
||||
<button id="save_relationship_button" type="button" class="btn btn-primary btn-sm"
|
||||
hx-post="/knowledge-relationship" hx-target="#relationship_table_section" hx-swap="outerHTML"
|
||||
hx-include=".new_relationship_input">
|
||||
Save
|
||||
</button>
|
||||
</td>
|
||||
@@ -79,8 +75,11 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Modal containers for dynamic content -->
|
||||
<div id="entity_detail_modal" class="mt-4"></div>
|
||||
<div id="modal_container"></div>
|
||||
<script>
|
||||
document.getElementById('relationship_type_input').addEventListener('keydown', function (event) {
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault(); // Prevent form submission if within a form
|
||||
document.getElementById('save_relationship_button').click();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -18,7 +18,6 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Auto-open modal when injected
|
||||
document.getElementById('body_modal').showModal();
|
||||
@@ -29,5 +28,10 @@
|
||||
document.getElementById('body_modal').close();
|
||||
}
|
||||
});
|
||||
|
||||
// Clear modal content on close to prevent browser back from reopening it
|
||||
document.getElementById('body_modal').addEventListener('close', (evt) => {
|
||||
evt.target.innerHTML = '';
|
||||
});
|
||||
</script>
|
||||
</dialog>
|
||||
Reference in New Issue
Block a user