Implement boilerplate search widget/page view
This commit is contained in:
parent
0488a3e0b2
commit
b3df0bf249
|
@ -20,7 +20,7 @@ from django.contrib.auth.views import LogoutView
|
||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
from two_factor.urls import urlpatterns as tf_urls
|
from two_factor.urls import urlpatterns as tf_urls
|
||||||
|
|
||||||
from core.views import base, demo, drugs, notifications
|
from core.views import base, demo, drugs, notifications, search
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("__debug__/", include("debug_toolbar.urls")),
|
path("__debug__/", include("debug_toolbar.urls")),
|
||||||
|
@ -66,4 +66,6 @@ urlpatterns = [
|
||||||
drugs.DrugPullMerge.as_view(),
|
drugs.DrugPullMerge.as_view(),
|
||||||
name="drug_pull_merge",
|
name="drug_pull_merge",
|
||||||
),
|
),
|
||||||
|
# Drug search
|
||||||
|
path("search/<str:type>/", search.Search.as_view(), name="search"),
|
||||||
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||||
|
|
|
@ -218,6 +218,9 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
|
<a class="navbar-item" href="{% url 'search' type='page' %}">
|
||||||
|
Search
|
||||||
|
</a>
|
||||||
<div class="navbar-item has-dropdown is-hoverable">
|
<div class="navbar-item has-dropdown is-hoverable">
|
||||||
<a class="navbar-link">
|
<a class="navbar-link">
|
||||||
Account
|
Account
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
<form class="skipEmptyFields" method="POST" hx-post="#"
|
||||||
|
hx-trigger="change"
|
||||||
|
hx-target="#widgets-here"
|
||||||
|
hx-swap="innerHTML"
|
||||||
|
hx-indicator="#spinner">
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="columns">
|
||||||
|
<div class="column">
|
||||||
|
<div class="field has-addons">
|
||||||
|
<div id="query" class="control is-expanded has-icons-left">
|
||||||
|
<input
|
||||||
|
hx-post="#"
|
||||||
|
hx-trigger="keyup changed delay:200ms"
|
||||||
|
hx-target="#widgets-here"
|
||||||
|
hx-swap="innerHTML"
|
||||||
|
name="query"
|
||||||
|
value=""
|
||||||
|
class="input"
|
||||||
|
type="text"
|
||||||
|
placeholder="Search something">
|
||||||
|
<span class="icon is-small is-left">
|
||||||
|
<i class="fas fa-magnifying-glass"></i>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="control">
|
||||||
|
<div class="field">
|
||||||
|
<button
|
||||||
|
id="search"
|
||||||
|
class="button is-fullwidth"
|
||||||
|
hx-post="#"
|
||||||
|
hx-trigger="click"
|
||||||
|
hx-target="#widgets-here"
|
||||||
|
hx-swap="innerHTML">
|
||||||
|
Search
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="column is-3">
|
||||||
|
<div class="nowrap-parent">
|
||||||
|
<div
|
||||||
|
data-script="on click toggle .is-hidden on #options"
|
||||||
|
class="button is-right nowrap-child">
|
||||||
|
Options
|
||||||
|
</div>
|
||||||
|
<div class="nowrap-child">
|
||||||
|
<span id="spinner" class="button is-light has-text-link is-loading htmx-indicator">Static</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="block">
|
||||||
|
<input
|
||||||
|
hx-trigger="change"
|
||||||
|
hx-post="#"
|
||||||
|
hx-target="#widgets-here"
|
||||||
|
hx-swap="innerHTML"
|
||||||
|
id="tags"
|
||||||
|
class="input"
|
||||||
|
type="tags"
|
||||||
|
name="tags"
|
||||||
|
placeholder="Tag search: nick: john"
|
||||||
|
value="##">
|
||||||
|
</div>
|
||||||
|
<div class="is-hidden"></div>
|
||||||
|
|
||||||
|
</form>
|
|
@ -1,9 +1,9 @@
|
||||||
<p class="title">This is a demo panel</p>
|
<p class="title">Common controls</p>
|
||||||
|
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<button
|
<button
|
||||||
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
||||||
hx-get="{% url 'modal' %}"
|
hx-get="{% url 'search' type='widget' %}"
|
||||||
hx-trigger="click"
|
hx-trigger="click"
|
||||||
hx-target="#modals-here"
|
hx-target="#modals-here"
|
||||||
class="button is-info">
|
class="button is-info">
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<i class="fa-solid fa-list"></i>
|
<i class="fa-solid fa-list"></i>
|
||||||
</span>
|
</span>
|
||||||
<span>Open modal</span>
|
<span>Open search widget</span>
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
from django.shortcuts import render
|
||||||
|
from django.views import View
|
||||||
|
from mixins.views import (
|
||||||
|
ObjectCreate,
|
||||||
|
ObjectDelete,
|
||||||
|
ObjectList,
|
||||||
|
ObjectRead,
|
||||||
|
ObjectUpdate,
|
||||||
|
)
|
||||||
|
|
||||||
|
from core.models import Drug
|
||||||
|
|
||||||
|
# class Search(View):
|
||||||
|
# template_name = "widgets/widget.html"
|
||||||
|
|
||||||
|
# def get(self, request):
|
||||||
|
# unique = str(uuid.uuid4())[:8]
|
||||||
|
# return render(request, self.template_name, {"unique": unique})
|
||||||
|
|
||||||
|
|
||||||
|
class Search(LoginRequiredMixin, ObjectRead):
|
||||||
|
model = Drug
|
||||||
|
detail_template = "window-content/drug_search.html"
|
||||||
|
|
||||||
|
def get_object(self, type):
|
||||||
|
return {}
|
Loading…
Reference in New Issue