diff --git a/sapl-frontend/package.json b/sapl-frontend/package.json
index 53d9af4cc..14afa817a 100644
--- a/sapl-frontend/package.json
+++ b/sapl-frontend/package.json
@@ -12,6 +12,7 @@
"bootstrap-material-design": "^4.1.1",
"dotenv": "^6.2.0",
"jquery": "^3.3.1",
+ "jquery-ui": "^1.12.1",
"popper.js": "^1.14.6",
"sapl-oficial-theme": "../../sapl-oficial-theme",
"vue": "^2.5.21",
diff --git a/sapl-frontend/src/global/functions.js b/sapl-frontend/src/global/functions.js
index 032639dc2..2116a50b2 100644
--- a/sapl-frontend/src/global/functions.js
+++ b/sapl-frontend/src/global/functions.js
@@ -1,4 +1,9 @@
-import jQuery from 'jquery'
+import jQuery from "jquery";
+
+import dialog from "jquery-ui/ui/widgets/dialog";
+import "jquery-ui/themes/base/all.css"
+
+jQuery.dialog = dialog;
window.getCookie = function(name) {
var cookieValue = null;
@@ -14,3 +19,108 @@ window.getCookie = function(name) {
}
return cookieValue;
}
+
+window.autorModal = function() {
+
+ jQuery(function() {
+ var dialog = jQuery("#modal_autor").dialog({
+ autoOpen: false,
+ modal: true,
+ width: 500,
+ height: 340,
+ show: {
+ effect: "blind",
+ duration: 500},
+ hide: {
+ effect: "explode",
+ duration: 500
+ }
+ });
+
+ jQuery("#button-id-limpar").click(function() {
+ jQuery("#nome_autor").text('');
+
+ function clean_if_exists(fieldname) {
+ if (jQuery(fieldname).length > 0) {
+ jQuery(fieldname).val('');
+ }
+ }
+
+ clean_if_exists("#id_autor");
+ clean_if_exists("#id_autoria__autor");
+ });
+
+ jQuery("#button-id-pesquisar").click(function() {
+ jQuery("#q").val('');
+ jQuery("#div-resultado").children().remove();
+ jQuery("#modal_autor").dialog( "open" );
+ jQuery("#selecionar").attr("hidden", "hidden");
+ });
+
+ jQuery("#pesquisar").click(function() {
+ var name_in_query = jQuery("#q").val()
+ //var q_0 = "q_0=nome__icontains"
+ //var q_1 = name_in_query
+ //query = q_1
+
+ jQuery.get("/api/autor?q=" + name_in_query, function(data, status) {
+ jQuery("#div-resultado").children().remove();
+ if (data.pagination.total_entries == 0) {
+ jQuery("#selecionar").attr("hidden", "hidden");
+ jQuery("#div-resultado").html(
+ "Nenhum resultado");
+ return;
+ }
+
+ var select = jQuery(
+ '');
+
+ data.results.forEach(function(item, index) {
+ select.append(jQuery("