From b57d52dc9f6ffe3d451296884a06e3d23ceb6ab3 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Wed, 12 Oct 2022 16:26:01 +0200 Subject: [PATCH] Table improvements * enhances visualization of editable column on tables * simplifies code * enhances visualization of parcel_group column on tables * WIP: Ordering on intervention table is odd. Same results are being displayed on page 2. Needs further analysis and fixing! --- compensation/tables/compensation.py | 17 -------------- compensation/tables/eco_account.py | 20 ----------------- ema/tables.py | 19 ---------------- ema/views/ema.py | 3 +-- intervention/tables.py | 19 ---------------- .../includes/parcels/parcel_table_frame.html | 3 ++- konova/utils/tables.py | 22 ++++++++++++++++++- templates/map/geom_form.html | 7 ++++-- templates/table/gmrkng_col.html | 3 ++- 9 files changed, 31 insertions(+), 82 deletions(-) diff --git a/compensation/tables/compensation.py b/compensation/tables/compensation.py index 02fe00e..fe3efe0 100644 --- a/compensation/tables/compensation.py +++ b/compensation/tables/compensation.py @@ -148,20 +148,3 @@ class CompensationTable(BaseTable, TableRenderMixin, TableOrderMixin): ) return format_html(html) - def render_e(self, value, record: Compensation): - """ Renders the editable column for a compensation - - Args: - value (str): The identifier value - record (Compensation): The compensation record - - Returns: - - """ - has_access = record.is_shared_with(self.user) - - html = self.render_icn( - tooltip=_("Full access granted") if has_access else _("Access not granted"), - icn_class="fas fa-edit rlp-r-inv" if has_access else "far fa-edit", - ) - return format_html(html) diff --git a/compensation/tables/eco_account.py b/compensation/tables/eco_account.py index 65489b5..da1444e 100644 --- a/compensation/tables/eco_account.py +++ b/compensation/tables/eco_account.py @@ -134,23 +134,3 @@ class EcoAccountTable(BaseTable, TableRenderMixin, TableOrderMixin): icn_filled=checked, ) return format_html(html) - - def render_e(self, value, record: EcoAccount): - """ Renders the editable column for an eco account - - Args: - value (str): The identifier value - record (EcoAccount): The eco account record - - Returns: - - """ - html = "" - # Do not use value in here, since value does use unprefetched 'users' manager, where record has already - # prefetched users data - has_access = record.is_shared_with(self.user) - html += self.render_icn( - tooltip=_("Full access granted") if has_access else _("Access not granted"), - icn_class="fas fa-edit rlp-r-inv" if has_access else "far fa-edit", - ) - return format_html(html) diff --git a/ema/tables.py b/ema/tables.py index 928b3e2..aa043c2 100644 --- a/ema/tables.py +++ b/ema/tables.py @@ -111,22 +111,3 @@ class EmaTable(BaseTable, TableRenderMixin, TableOrderMixin): icn_filled=recorded, ) return format_html(html) - - def render_e(self, value, record: Ema): - """ Renders the editable column for a EMA - - Args: - value (str): The identifier value - record (Ema): The EMA record - - Returns: - - """ - html = "" - has_access = record.is_shared_with(self.user) - - html += self.render_icn( - tooltip=_("Full access granted") if has_access else _("Access not granted"), - icn_class="fas fa-edit rlp-r-inv" if has_access else "far fa-edit", - ) - return format_html(html) diff --git a/ema/views/ema.py b/ema/views/ema.py index b298959..b4ad6fd 100644 --- a/ema/views/ema.py +++ b/ema/views/ema.py @@ -39,9 +39,8 @@ def index_view(request: HttpRequest): template = "generic_index.html" emas = Ema.objects.filter( deleted=None, - ).order_by( - "-modified" ) + table = EmaTable( request, queryset=emas diff --git a/intervention/tables.py b/intervention/tables.py index bdcdc07..39cae2a 100644 --- a/intervention/tables.py +++ b/intervention/tables.py @@ -146,22 +146,3 @@ class InterventionTable(BaseTable, TableRenderMixin, TableOrderMixin): ) return format_html(html) - def render_e(self, value, record: Intervention): - """ Renders the editable column for an intervention - - Args: - value (str): The identifier value - record (Intervention): The intervention record - - Returns: - - """ - html = "" - has_access = record.is_shared_with(self.user) - - html += self.render_icn( - tooltip=_("Full access granted") if has_access else _("Access not granted"), - icn_class="fas fa-edit rlp-r-inv" if has_access else "far fa-edit", - ) - return format_html(html) - diff --git a/konova/templates/konova/includes/parcels/parcel_table_frame.html b/konova/templates/konova/includes/parcels/parcel_table_frame.html index 21b75b7..8adc2e8 100644 --- a/konova/templates/konova/includes/parcels/parcel_table_frame.html +++ b/konova/templates/konova/includes/parcels/parcel_table_frame.html @@ -1,7 +1,8 @@ -{% load i18n l10n %} +{% load i18n l10n fontawesome_5 %}
{% if parcels|length == 0 %}
+ {% fa5_icon 'search-location' %} {% trans 'Parcels can not be calculated, since no geometry is given.' %}
{% else %} diff --git a/konova/utils/tables.py b/konova/utils/tables.py index 1953724..795c6ba 100644 --- a/konova/utils/tables.py +++ b/konova/utils/tables.py @@ -12,8 +12,9 @@ from django.http import HttpRequest from django.template.loader import render_to_string from django.utils.html import format_html import django_tables2 as tables +from django.utils.translation import gettext_lazy as _ -from konova.models import BaseObject, GeoReferencedMixin +from konova.models import BaseObject, GeoReferencedMixin, ShareableObjectMixin from konova.settings import PAGE_SIZE_DEFAULT, PAGE_PARAM, RESULTS_PER_PAGE_PARAM, PAGE_SIZE_OPTIONS @@ -200,6 +201,25 @@ class TableRenderMixin: ) return html + def render_e(self, value, record: ShareableObjectMixin): + """ Renders the editable column + + Args: + value (str): The identifier value + record (ShareableObjectMixin): The record + + Returns: + + """ + html = "" + has_access = record.is_shared_with(self.user) + + html += self.render_icn( + tooltip=_("Full access granted") if has_access else _("Access not granted"), + icn_class="fas fa-share-alt rlp-r-inv" if has_access else "", + ) + return format_html(html) + class TableOrderMixin: """ diff --git a/templates/map/geom_form.html b/templates/map/geom_form.html index 363c940..5cc5bdd 100644 --- a/templates/map/geom_form.html +++ b/templates/map/geom_form.html @@ -1,4 +1,4 @@ -{% load i18n %} +{% load i18n fontawesome_5 %} {% comment %} Encapsules the rendering and initializing of a geometry view component, e.g. used in the detail views. @@ -6,7 +6,10 @@ {% if geom_form.empty %}
-
{% trans 'No geometry added, yet.' %}
+
+ {% fa5_icon 'search-location' %} + {% trans 'No geometry added, yet.' %} +
{% endif %} diff --git a/templates/table/gmrkng_col.html b/templates/table/gmrkng_col.html index 2f5521b..f8d7397 100644 --- a/templates/table/gmrkng_col.html +++ b/templates/table/gmrkng_col.html @@ -10,6 +10,7 @@ {% endfor %} {% else %} - {% fa5_icon 'ellipsis-h' %} + {% fa5_icon 'search-location' %} + {% fa5_icon 'question' %} {% endif %} \ No newline at end of file