From 842a758f31143a5934b2798a4d0f40f11a402919 Mon Sep 17 00:00:00 2001
From: Alexander_Kabui
Date: Wed, 29 May 2024 14:27:40 +0300
Subject: Add htmx js api  for delete functionality.

---
 gn2/wqflask/templates/gnqa_search_history.html | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

(limited to 'gn2')

diff --git a/gn2/wqflask/templates/gnqa_search_history.html b/gn2/wqflask/templates/gnqa_search_history.html
index c1e66541..976fd7fd 100644
--- a/gn2/wqflask/templates/gnqa_search_history.html
+++ b/gn2/wqflask/templates/gnqa_search_history.html
@@ -1,4 +1,4 @@
-<section class="container-fluid  gnqa-copy">
+<section class="container-fluid  gnqa-copy" id="search-hist">
   <header class="row">
     <div class="panel panel default col-sm-6 col-sm-offset-3">
       <div class="panel panel-default">
@@ -15,8 +15,8 @@
       <div class="col-sm-6 col-sm-offset-3" style="margin-bottom:10px">
 	<button type="button" class="btn btn-danger" id="delete-btn">Delete Selected </button>
       </div>
-      <div>
-	<div class="panel panel-default col-sm-6 col-sm-offset-3 ">
+      <div >
+      <div class="panel panel-default col-sm-6 col-sm-offset-3 ">
       <div>
 	<ul class="list-group list-group-flush" style="overflow-y:scroll">
     {% for item in  prev_queries %}
@@ -44,15 +44,9 @@
   </div>
   </div>
 </section>
-{% block js %}
-  <script>
+<script>
   htmx.on("#delete-btn", "click", function(evt){
-      // todo: complete this for delete /export functionality
-      htmx.ajax("POST", "/gnqna/hist", {target:"",
-				swap:"innerHTML",values:
-			Array.from(htmx.findAll("input[type=checkbox]:checked"), e => e.value);}
-      )
+      htmx.ajax("DELETE","/gnqna/hist", {target: "#search-hist","swap" :"outerHTML",
+				      values: Array.from(htmx.findAll("input[type=checkbox]:checked"), e => e.value)}) 
   })
 </script>
-
-{% endblock %}
-- 
cgit v1.2.3