This commit is contained in:
2024-05-25 10:56:15 +02:00
parent b8a2f02657
commit c05de5d325
6 changed files with 48 additions and 30 deletions
-11
View File
@@ -1,11 +0,0 @@
<div id="modal">
<div class="modal-underlay" hx-get="/empty" hx-target="#modal" hx-swap="outerHTML"></div>
<div class="modal-content">
<h1>Modal Dialog</h1>
This is the modal content.
You can put anything here, like text, or a form, or an image.
<br>
<br>
<button hx-get="/empty" hx-target="#modal" hx-swap="outerHTML">Close</button>
</div>
</div>
+13 -11
View File
@@ -13,9 +13,11 @@
<div class="dropdown-item">
<div id="conversation-list">
{% for Conversation in Conversations %}
<div class="icon-text has-text unselected icon-conv" data-id="{{ Conversation.ID.String() }}"
style="cursor: pointer;" onclick="toggleConversationSelection(this)" hx-get="/loadChat"
hx-swap="outerHTML" hx-target="#chat-container">
<div class="icon-text has-text unselected icon-conv {% if Conversation.Name == 'Default' %} selected {% endif %}"
data-id="{{ Conversation.ID.String() }}" style="cursor: pointer;"
onclick="toggleConversationSelection(this)"
hx-get="/selectConversation?conversation-id={{ Conversation.ID.String() }}" hx-swap="outerHTML"
hx-target="#chat-container">
<span>{{ Conversation.Name }}</span>
</div>
{% endfor %}
@@ -23,7 +25,9 @@
<input class="input is-small mt-2 is-hidden" type="text" id="conversation-name-input"
name="conversation-name-input" placeholder="Conversation name" autocomplete="off">
<div class="is-flex is-justify-content-space-between mt-4">
<button disabled class="button is-small is-danger" id="delete-conversation-button">
<button class="button is-small is-danger" id="delete-conversation-button"
hx-get="/deleteConversation" hx-swap="outerHTML" hx-target="#conversation-dropdown"
hx-vals="js:{conversationId: findSelectedConversationID()}">
<span class="icon">
<i class="fa-solid fa-trash"></i>
</span>
@@ -54,17 +58,15 @@
</div>
</div>
<script>
function findSelectedConversationID() {
return document.getElementsByClassName('icon-conv selected')[0].getAttribute('data-id');
}
function toggleConversationSelection(element) {
const elements = Array.from(document.getElementsByClassName('icon-conv'));
// If the conversation is already selected, unselect it
// If the conversation is already selected, keep it
if (element.classList.contains('selected')) {
for (let i = 0; i < elements.length; i++) {
elements[i].classList.remove('selected');
elements[i].classList.add('unselected');
}
element.classList.remove('selected');
element.classList.add('unselected');
// Do nothing
return;
} else if (element.classList.contains('unselected')) {
for (let i = 0; i < elements.length; i++) {