summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2024-10-10 13:42:18 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2024-10-14 16:48:37 +0200
commit435797a54e4d322a46711f303c2fc1fd5286330e (patch)
tree7c209135a17fe9b12fa2e2e844f345debed45d97 /ishtar_common
parent69df0a88eeaafeee81d76a3307e79fe5cad8ecf8 (diff)
downloadIshtar-435797a54e4d322a46711f303c2fc1fd5286330e.tar.bz2
Ishtar-435797a54e4d322a46711f303c2fc1fd5286330e.zip
✨ site and operation relations forms refactoring
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/static/js/ishtar.js21
-rw-r--r--ishtar_common/templates/blocks/bs_alert_message.html4
-rw-r--r--ishtar_common/templates/ishtar/blocks/window_nav.html4
-rw-r--r--ishtar_common/templates/ishtar/forms/modify_relations.html9
-rw-r--r--ishtar_common/templatetags/ishtar_helpers.py2
-rw-r--r--ishtar_common/templatetags/window_header.py7
-rw-r--r--ishtar_common/urls_converters.py29
7 files changed, 71 insertions, 5 deletions
diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js
index 2bcfe5a7e..1ef2e4c1d 100644
--- a/ishtar_common/static/js/ishtar.js
+++ b/ishtar_common/static/js/ishtar.js
@@ -454,8 +454,29 @@ $(document).ready(function(){
$("[aria-controls='" + $(this).attr("id") + "']").click();
}
});
+ register_modal_on_close();
});
+
+var modal_on_close = new Array();
+
+var register_modal_on_close = function(){
+ $(".modal").each(
+ function(){
+ if (this.id) {
+ modal_on_close[this.id] = undefined;
+ $("#" + this.id).on('hide.bs.modal', function() {
+ if (modal_on_close[this.id] !== undefined){
+ modal_on_close[this.id]();
+ // reinitialize after call
+ modal_on_close[this.id] = undefined;
+ }
+ });
+ }
+ }
+ );
+}
+
var register_wait_button = function(){
$(".wait-button").click(function(){short_wait()});
};
diff --git a/ishtar_common/templates/blocks/bs_alert_message.html b/ishtar_common/templates/blocks/bs_alert_message.html
new file mode 100644
index 000000000..b0b5241a7
--- /dev/null
+++ b/ishtar_common/templates/blocks/bs_alert_message.html
@@ -0,0 +1,4 @@
+<div class="alert alert-info alert-dismissible fade show" role="alert">
+ <i class="fa fa-info" aria-hidden="true"></i>&nbsp;&nbsp;{{alert_message}}
+ <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
+</div>
diff --git a/ishtar_common/templates/ishtar/blocks/window_nav.html b/ishtar_common/templates/ishtar/blocks/window_nav.html
index e3ed13f97..63aafb93a 100644
--- a/ishtar_common/templates/ishtar/blocks/window_nav.html
+++ b/ishtar_common/templates/ishtar/blocks/window_nav.html
@@ -2,6 +2,8 @@
<script type="text/javascript">{% localize off %}
var current_url_{{window_id_underscore}};
var reload_window_{{window_id_underscore}} = function() {
+ /* reload put the sheet at the end of list - force other to be close in order to not loose the current sheet */
+ $(".sheet > .collapse").removeClass("show");
load_window(current_url_{{window_id_underscore}},
'', function(){hide_window("{{window_id}}");},
true);
@@ -126,4 +128,4 @@ $(document).ready(function(){
</script>
{% else %}
<h3 class="external-source"><i class="fa fa-globe" aria-hidden="true"></i> {{item.current_source}}</h3>
-{% endif %} \ No newline at end of file
+{% endif %}
diff --git a/ishtar_common/templates/ishtar/forms/modify_relations.html b/ishtar_common/templates/ishtar/forms/modify_relations.html
index 1dcf02b0c..419d94c9a 100644
--- a/ishtar_common/templates/ishtar/forms/modify_relations.html
+++ b/ishtar_common/templates/ishtar/forms/modify_relations.html
@@ -12,6 +12,10 @@
{{ formset.management_form }}
{% csrf_token %}
<div class="modal-body body-scroll">
+ {% if excess %}
+ {% with alert_message=excess %}
+ {% include "blocks/bs_alert_message.html" %}
+ {% endwith %}{% endif %}
<div class='form'>
{% block main_form %}
<table class='w-100 inline-table text-center'>
@@ -52,7 +56,10 @@
qa_action_register("{{url}}");
$(document).on("click", '.check-all-relations', function(){
$('input[id$="-DELETE"]:checkbox').prop('checked', $(this).is(':checked'));
- });
+ });{% if window_id %}
+ console.log("{{window_id}}");
+ modal_on_close["modal-dynamic-form"] = reload_window_{{window_id}};
+ {% endif %}
{% block js_ready %}
{% endblock %}
});
diff --git a/ishtar_common/templatetags/ishtar_helpers.py b/ishtar_common/templatetags/ishtar_helpers.py
index 8c8227312..329f82dde 100644
--- a/ishtar_common/templatetags/ishtar_helpers.py
+++ b/ishtar_common/templatetags/ishtar_helpers.py
@@ -107,4 +107,4 @@ def can_edit_item(item, context):
@register.filter
def format_date(value):
- return python_format_date(value) \ No newline at end of file
+ return python_format_date(value)
diff --git a/ishtar_common/templatetags/window_header.py b/ishtar_common/templatetags/window_header.py
index c36cbc465..bfcd95883 100644
--- a/ishtar_common/templatetags/window_header.py
+++ b/ishtar_common/templatetags/window_header.py
@@ -18,8 +18,11 @@ def window_nav(context, item, window_id, show_url, modify_url='', histo_url='',
revert_url='', previous=None, nxt=None, pin_action=False):
extra_actions = []
if hasattr(item, 'get_extra_actions'):
- extra_actions = sorted_actions(
- item.get_extra_actions(context['request']))
+ try:
+ extra_actions = item.get_extra_actions(context['request'], context["window_id_underscore"])
+ except (KeyError, TypeError):
+ extra_actions = item.get_extra_actions(context['request'])
+ extra_actions = sorted_actions(extra_actions)
extra_templates = []
if hasattr(item, 'get_extra_templates'):
extra_templates = item.get_extra_templates(context['request'])
diff --git a/ishtar_common/urls_converters.py b/ishtar_common/urls_converters.py
new file mode 100644
index 000000000..9395af648
--- /dev/null
+++ b/ishtar_common/urls_converters.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright (C) 2024 Étienne Loks <etienne.loks_AT_iggdrasilDOTnet>
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# See the file COPYING for details.
+
+
+class UnderscoreSlug:
+ regex = '[_0-9a-z]+'
+
+ def to_python(self, value):
+ return str(value)
+
+ def to_url(self, value):
+ return str(value)
+