diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-07-04 17:31:14 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-07-04 17:34:50 +0200 |
commit | eaf0393eabd7089247b152897465b186b92be86f (patch) | |
tree | 8be87532d26e0a9c7f589810fe2ece50eaa1c242 /ishtar_common | |
parent | 7a7da8e6cbd7121d2c1d121b3ba595d276241a60 (diff) | |
download | Ishtar-eaf0393eabd7089247b152897465b186b92be86f.tar.bz2 Ishtar-eaf0393eabd7089247b152897465b186b92be86f.zip |
✨ sheet: add a refresh button to update informations
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/templates/ishtar/blocks/window_nav.html | 30 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/sheet.html | 4 | ||||
-rw-r--r-- | ishtar_common/templatetags/window_header.py | 2 | ||||
-rw-r--r-- | ishtar_common/views_item.py | 1 |
4 files changed, 23 insertions, 14 deletions
diff --git a/ishtar_common/templates/ishtar/blocks/window_nav.html b/ishtar_common/templates/ishtar/blocks/window_nav.html index c1d96acde..41572c5f2 100644 --- a/ishtar_common/templates/ishtar/blocks/window_nav.html +++ b/ishtar_common/templates/ishtar/blocks/window_nav.html @@ -1,11 +1,23 @@ -{% load i18n ishtar_helpers %} +{% load l10n i18n ishtar_helpers %} +<script type="text/javascript">{% localize off %} + var current_url_{{window_id_underscore}}; + var reload_window_{{window_id_underscore}} = function() { + load_window(current_url_{{window_id_underscore}}, + '', function(){hide_window("{{window_id}}");}, + true); + }; +{% endlocalize %}</script> {% if not item.is_external %} <div class="row toolbar"> - {% if current_user.is_superuser %} - {% if previous or next %} <div class='col-md-2'> <div class="btn-group btn-group-sm" role="group" aria-label="{% trans 'History'%}"> - {% if previous %} + <button type="button" class="btn btn-secondary" + data-toggle="tooltip" data-placement="bottom" + title="{% trans 'Refresh' %}" + onclick="reload_window_{{window_id_underscore}}();return false;"> + <i class="fa fa-refresh"></i> + </button> + {% if current_user.is_superuser and previous %} <button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="bottom" title="{{previous|date}} {{previous|time:'H:i'}}" @@ -13,10 +25,10 @@ <i class="fa fa-step-backward"></i> </button> {% endif %} - {% if next %} + {% if current_user.is_superuser and next %} <button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="bottom" - onclick='if(confirm("{%trans 'Are you sure to restore to this version? All changes made since this version will be lost.' %}")){load_url("{% url revert_url item.pk item.history_date|date:"c"%}", function(){closeAllWindows();load_window("{% url show_url item.pk None %}");});}' + onclick='if(confirm("{% trans 'Are you sure to restore to this version? All changes made since this version will be lost.' %}")){load_url("{% url revert_url item.pk item.history_date|date:"c"%}", function(){closeAllWindows();load_window("{% url show_url item.pk None %}");});}' title="{% trans 'Restore this version' %}"> <i class="fa fa-history"></i> </button> @@ -30,12 +42,6 @@ </div> </div> <div class='offset-md-1 col-md-9 text-right'> - {% else %} - <div class='offset-md-3 col-md-9 text-right'> - {% endif %} - {% else %} - <div class='offset-md-6 col-md-6 text-right'> - {% endif %} {% if pin_action and item.SLUG %} <div class="btn-group btn-group-sm" role="group" aria-label="{% trans 'Pin' %}"> diff --git a/ishtar_common/templates/ishtar/sheet.html b/ishtar_common/templates/ishtar/sheet.html index f3df2e510..49c06b0a6 100644 --- a/ishtar_common/templates/ishtar/sheet.html +++ b/ishtar_common/templates/ishtar/sheet.html @@ -77,8 +77,8 @@ {% if output != "ODT" and output != "PDF" %} {% block head_sheet %} <script type="text/javascript">{% localize off %} - var last_window='{{window_id}}'; - + var last_window = '{{window_id}}'; + var current_url_{{window_id_underscore}} = "{{current_window_url}}{{item.pk}}/"; jQuery(document).ready(function(){ if (! get_next_table_id("{{item.pk}}")){ jQuery('.next_page').hide(); diff --git a/ishtar_common/templatetags/window_header.py b/ishtar_common/templatetags/window_header.py index 5d0e85f72..c36cbc465 100644 --- a/ishtar_common/templatetags/window_header.py +++ b/ishtar_common/templatetags/window_header.py @@ -44,6 +44,7 @@ def window_nav(context, item, window_id, show_url, modify_url='', histo_url='', 'revert_url': revert_url, 'item': item, 'window_id': window_id, + 'window_id_underscore': window_id.replace("-", "_"), 'previous': previous, 'next': nxt, 'extra_actions': extra_actions, @@ -91,6 +92,7 @@ def window_file_nav(context, item, window_id, previous=None, nxt=None): 'item': item, 'extra_action': mark_safe(add_operation), 'window_id': window_id, + 'window_id_underscore': window_id.replace("-", "_"), 'previous': previous, 'next': nxt, 'extra_actions': extra_actions, diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index 1cb0b80f2..da1543e7b 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -367,6 +367,7 @@ def show_item(model, name, extra_dct=None, model_for_perms=None): date = dct.pop("date") dct["sheet_id"] = f"{name}-{pk}" dct["window_id"] = f"{name}-{pk}-{datetime.datetime.now().strftime('%M%s')}" + dct["window_id_underscore"] = dct["window_id"].replace("-", "_") if str(pk).startswith("source-"): return show_source_item(request, pk, model, name, dct, extra_dct) try: |