diff --git a/apis_core/relations/static/css/relations.css b/apis_core/relations/static/css/relations.css
index cda88d50f..ae262ebda 100644
--- a/apis_core/relations/static/css/relations.css
+++ b/apis_core/relations/static/css/relations.css
@@ -2,3 +2,22 @@
overflow-y: auto;
max-height: 40vh;
}
+
+#relationdialog {
+ border: 1px solid black;
+ border-radius: .3rem;
+ overflow: visible;
+ padding: 0;
+ opacity: 1;
+ transform: scale(1);
+ transition: all 0.5s ease-in-out;
+
+ @starting-style {
+ opacity: 0;
+ transform: scale(0.8);
+ }
+}
+
+#relation-dialog-content {
+ padding: 1rem;
+}
diff --git a/apis_core/relations/static/js/relation_dialog.js b/apis_core/relations/static/js/relation_dialog.js
new file mode 100644
index 000000000..d70510c58
--- /dev/null
+++ b/apis_core/relations/static/js/relation_dialog.js
@@ -0,0 +1,20 @@
+document.body.addEventListener("reinit_select2", function(evt) {
+ form = document.getElementById(evt.detail.value);
+ form.querySelectorAll(".listselect2").forEach(element => {
+ $(element).select2({
+ ajax: {
+ url: $(element).data("autocomplete-light-url"),
+ },
+ dropdownParent: $("#relationdialog"),
+ });
+ });
+ $('.select2-selection').addClass("form-control");
+});
+document.body.addEventListener("dismissModal", function(evt) {
+ document.getElementById("relationdialog").close();
+});
+document.addEventListener('DOMContentLoaded', function() {
+ document.getElementById("relationdialog").addEventListener("mousedown", function(evt) {
+ evt.target == this && this.close();
+ });
+});
diff --git a/apis_core/relations/templates/apis_core/apis_entities/abstractentity_form.html b/apis_core/relations/templates/apis_core/apis_entities/abstractentity_form.html
index 839047a5c..00eb50415 100644
--- a/apis_core/relations/templates/apis_core/apis_entities/abstractentity_form.html
+++ b/apis_core/relations/templates/apis_core/apis_entities/abstractentity_form.html
@@ -1,4 +1,17 @@
{% extends "apis_core/apis_entities/abstractentity_form.html" %}
+{% load static %}
+
+{% block styles %}
+ {{ block.super }}
+
+{% endblock styles %}
+
+{% block content %}
+ {{ block.super }}
+
+{% endblock content %}
{% block col-one %}
{% include "relations/list_relations_include.html" with edit=True %}
@@ -6,23 +19,6 @@
{% endblock col-one %}
{% block scripts %}
-
{{ block.super }}
+
{% endblock scripts %}
diff --git a/apis_core/relations/templates/relations/list_relations.html b/apis_core/relations/templates/relations/list_relations.html
index d9a004fec..decc3fa71 100644
--- a/apis_core/relations/templates/relations/list_relations.html
+++ b/apis_core/relations/templates/relations/list_relations.html
@@ -17,17 +17,15 @@
{{ relation.model_class.reverse_name }}
+ hx-target="#relation-dialog-content"
+ hx-on:click="relationdialog.showModal();">{{ relation.model_class.reverse_name }}
{% endif %}
{% if target.model_class in relation.model_class.obj_list and object.self_contenttype.model_class in relation.model_class.subj_list %}
{{ relation.model_class.name }}
+ hx-target="#relation-dialog-content"
+ hx-on:click="relationdialog.showModal();">{{ relation.model_class.name }}
{% endif %}
{% endif %}
{% endfor %}