Cache the table and remove CRUD tools included in mixins

This commit is contained in:
Mark Veidemanis 2023-02-11 15:44:20 +00:00
parent 5d6f96bbf3
commit 11d4542412
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
18 changed files with 513 additions and 725 deletions

View File

@ -1,4 +1,4 @@
{% extends 'wm/modal.html' %} {% extends 'mixins/wm/modal.html' %}
{% load index %} {% load index %}
{% load static %} {% load static %}

View File

@ -1,4 +1,4 @@
{% extends 'wm/modal.html' %} {% extends 'mixins/wm/modal.html' %}
{% block modal_content %} {% block modal_content %}
{% include 'window-content/drilldown.html' %} {% include 'window-content/drilldown.html' %}

View File

@ -1 +0,0 @@
<button class="modal-close is-large" aria-label="close"></button>

View File

@ -1,3 +0,0 @@
<i
class="fa-solid fa-xmark has-text-grey-light float-right"
onclick='grid.removeWidget("widget-{{ unique }}");'></i>

View File

@ -1,3 +0,0 @@
<i
class="fa-solid fa-xmark has-text-grey-light float-right"
data-script="on click remove the closest <nav/>"></i>

View File

@ -1,4 +1,4 @@
{% extends 'wm/widget.html' %} {% extends 'mixins/wm/widget.html' %}
{% load static %} {% load static %}
{% block heading %} {% block heading %}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
{% extends 'wm/widget.html' %} {% extends 'mixins/wm/widget.html' %}
{% block widget_options %} {% block widget_options %}

View File

@ -1,34 +0,0 @@
{% include 'mixins/partials/notify.html' %}
{% if page_title is not None %}
<h1 class="title is-4">{{ page_title }}</h1>
{% endif %}
{% if page_subtitle is not None %}
<h1 class="subtitle">{{ page_subtitle }}</h1>
{% endif %}
{% load crispy_forms_tags %}
{% load crispy_forms_bulma_field %}
<form
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-post="{{ submit_url }}"
hx-target="#modals-here"
hx-swap="innerHTML">
{% csrf_token %}
{{ form|crispy }}
{% if hide_cancel is not True %}
<button
type="button"
class="button is-light modal-close-button">
Cancel
</button>
{% endif %}
<button type="submit" class="button modal-close-button">Submit</button>
</form>

View File

@ -1,45 +0,0 @@
{% include 'mixins/partials/notify.html' %}
{% if page_title is not None %}
<h1 class="title is-4">{{ page_title }}</h1>
{% endif %}
{% if page_subtitle is not None %}
<h1 class="subtitle">{{ page_subtitle }}</h1>
{% endif %}
<div class="buttons">
{% if submit_url is not None %}
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{{ submit_url }}"
hx-trigger="click"
hx-target="#modals-here"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-plus"></i>
</span>
<span>{{ title_singular }}</span>
</span>
</button>
{% endif %}
{% if delete_all_url is not None %}
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="{{ delete_all_url }}"
hx-trigger="click"
hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish to delete all {{ context_object_name }}?"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
<span>Delete all {{ context_object_name }} </span>
</span>
</button>
{% endif %}
</div>
{% include detail_template %}

View File

@ -1,45 +0,0 @@
{% include 'mixins/partials/notify.html' %}
{% if page_title is not None %}
<h1 class="title is-4">{{ page_title }}</h1>
{% endif %}
{% if page_subtitle is not None %}
<h1 class="subtitle">{{ page_subtitle }}</h1>
{% endif %}
<div class="buttons">
{% if submit_url is not None %}
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{{ submit_url }}"
hx-trigger="click"
hx-target="#modals-here"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-plus"></i>
</span>
<span>{{ title_singular }}</span>
</span>
</button>
{% endif %}
{% if delete_all_url is not None %}
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="{{ delete_all_url }}"
hx-trigger="click"
hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish to delete all {{ context_object_name }}?"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
<span>Delete all {{ context_object_name }} </span>
</span>
</button>
{% endif %}
</div>
{% include list_template %}

View File

@ -1,4 +1,4 @@
{% extends 'wm/window.html' %} {% extends 'mixins/wm/window.html' %}
{% block heading %} {% block heading %}
Drilldown Drilldown

View File

@ -1,20 +0,0 @@
{% load static %}
<script src="{% static 'modal.js' %}"></script>
{% block scripts %}
{% endblock %}
{% block styles %}
{% endblock %}
<div id="modal" class="modal is-active is-clipped">
<div class="modal-background"></div>
<div class="modal-content">
<div class="box">
{% block modal_content %}
{% include window_content %}
{% endblock %}
{% include 'partials/close-modal.html' %}
</div>
</div>
</div>

View File

@ -1,6 +0,0 @@
{% extends "base.html" %}
{% block content %}
{% include window_content %}
{% endblock %}

View File

@ -1,17 +0,0 @@
<nav class="panel">
<p class="panel-heading" style="padding: .2em; line-height: .5em;">
<i class="fa-solid fa-arrows-up-down-left-right has-text-grey-light"></i>
{% block close_button %}
{% include 'partials/close-window.html' %}
{% endblock %}
{% block heading %}
{% endblock %}
</p>
<article class="panel-block is-active">
<div class="control">
{% block panel_content %}
{% endblock %}
</div>
</article>
</nav>

View File

@ -1,37 +0,0 @@
<div id="widget">
<div id="widget-{{ unique }}" class="grid-stack-item" {% block widget_options %}gs-w="10" gs-h="1" gs-y="10" gs-x="1"{% endblock %}>
<div class="grid-stack-item-content">
<nav class="panel">
<p class="panel-heading" style="padding: .2em; line-height: .5em;">
<i class="fa-solid fa-arrows-up-down-left-right has-text-grey-light"></i>
{% block close_button %}
{% include 'partials/close-widget.html' %}
{% endblock %}
<i
class="fa-solid fa-arrows-minimize has-text-grey-light float-right"
onclick='grid.compact();'></i>
{% block heading %}
{{ title }}
{% endblock %}
</p>
<article class="panel-block is-active">
<div class="control">
{% block panel_content %}
{% include window_content %}
{% endblock %}
</div>
</article>
</nav>
</div>
</div>
</div>
<script>
{% block custom_script %}
{% endblock %}
var widget_event = new Event('load-widget');
document.dispatchEvent(widget_event);
</script>
{% block custom_end %}
{% endblock %}

View File

@ -1,10 +0,0 @@
<magnet-block attract-distance="10" align-to="outer|center" class="floating-window">
{% extends 'wm/panel.html' %}
{% block heading %}
{{ title }}
{% endblock %}
{% block panel_content %}
{% include window_content %}
{% endblock %}
</magnet-block>

View File

@ -98,10 +98,11 @@ def make_graph(results):
class DrilldownTableView(SingleTableView): class DrilldownTableView(SingleTableView):
table_class = DrilldownTable table_class = DrilldownTable
template_name = "wm/widget.html" template_name = "mixins/wm/widget.html"
window_content = "window-content/results.html" window_content = "window-content/results.html"
# htmx_partial = "partials/" # htmx_partial = "partials/"
paginate_by = settings.DRILLDOWN_RESULTS_PER_PAGE paginate_by = settings.DRILLDOWN_RESULTS_PER_PAGE
widget_options = 'gs-w="10" gs-h="1" gs-y="10" gs-x="1"'
def common_request(self, request, **kwargs): def common_request(self, request, **kwargs):
extra_params = {} extra_params = {}
@ -112,6 +113,7 @@ class DrilldownTableView(SingleTableView):
sizes = settings.MAIN_SIZES sizes = settings.MAIN_SIZES
if request.GET: if request.GET:
print("GET")
self.template_name = "index.html" self.template_name = "index.html"
# GET arguments in URL like ?query=xyz # GET arguments in URL like ?query=xyz
query_params = request.GET.dict() query_params = request.GET.dict()
@ -119,6 +121,7 @@ class DrilldownTableView(SingleTableView):
if request.resolver_match.url_name == "search_partial": if request.resolver_match.url_name == "search_partial":
self.template_name = "partials/results_table.html" self.template_name = "partials/results_table.html"
elif request.POST: elif request.POST:
print("POST")
query_params = request.POST.dict() query_params = request.POST.dict()
else: else:
self.template_name = "index.html" self.template_name = "index.html"
@ -126,10 +129,12 @@ class DrilldownTableView(SingleTableView):
# Don't try to search, since there's clearly nothing to do # Don't try to search, since there's clearly nothing to do
params_with_defaults = {} params_with_defaults = {}
add_defaults(params_with_defaults) add_defaults(params_with_defaults)
print("GOT TO CONTEXT")
context = { context = {
"sizes": sizes, "sizes": sizes,
"params": params_with_defaults, "params": params_with_defaults,
"unique": "results", "unique": "results",
"widget_options": self.widget_options,
"window_content": self.window_content, "window_content": self.window_content,
"title": "Results", "title": "Results",
} }
@ -187,6 +192,7 @@ class DrilldownTableView(SingleTableView):
# We don't want a random one since we only want one results pane. # We don't want a random one since we only want one results pane.
context["unique"] = "results" context["unique"] = "results"
context["window_content"] = self.window_content context["window_content"] = self.window_content
context["widget_options"] = self.widget_options
context["title"] = "Results" context["title"] = "Results"
# Valid sizes # Valid sizes