Bug 36639: Fix delete on authorities detail
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / includes / authorities_js.inc
1 <!-- authorities_js.inc -->
2 <script>
3
4 function mergeAuth(authid, summary) {
5     var alreadySelected = Cookies.get('auth_to_merge');
6     if (alreadySelected !== undefined) {
7         alreadySelected = JSON.parse(alreadySelected);
8         Cookies.remove('auth_to_merge');
9         var refstring = "";
10         if (typeof alreadySelected.mergereference !== 'undefined') {
11             refstring = "&mergereference=" + alreadySelected.mergereference;
12         }
13         window.location.href = "/cgi-bin/koha/authorities/merge.pl?authid=" + authid + "&authid=" + alreadySelected.authid + refstring;
14     } else {
15         Cookies.set('auth_to_merge', JSON.stringify({ 'authid': authid, 'summary': summary }), { 'path' : '/', sameSite: 'Lax' });
16         showMergingInProgress();
17     }
18 }
19
20 function showMergingInProgress() {
21     var alreadySelected = Cookies.get('auth_to_merge');
22     if (alreadySelected !== undefined) {
23         alreadySelected = JSON.parse(alreadySelected);
24         $('#merge_in_progress').show().html(_("Merging with authority: ") + "<a href='detail.pl?authid=" + alreadySelected.authid + "'><span class='authorizedheading'>" + alreadySelected.summary + "</span> (" + alreadySelected.authid + ")</a> <a href='#' id='cancel_merge'>" + _("Cancel merge") + "</a>");
25         $('#cancel_merge').click(function(event) {
26             event.preventDefault();
27             Cookies.remove('auth_to_merge');
28             $('#merge_in_progress').hide().empty();
29         });
30     } else {
31         $('#merge_in_progress').hide().empty();
32     }
33 }
34
35 $(document).ready(function () {
36     showMergingInProgress();
37
38     $('.form_delete').submit(function() {
39         if ( confirm(_("Are you sure you want to delete this authority?")) ) {
40             return true;
41         }
42         // FIXME Close the dropdown $(this).closest('ul.dropdown-menu').dropdown('toggle');
43         return false;
44     });
45
46     $('.merge_auth').click(function (event) {
47         event.preventDefault();
48         mergeAuth($(this).parents('tr').attr('data-authid'), $(this).parents('tr').find('div.authorizedheading').text());
49     });
50
51     $("#delAuth").click(function(){
52         $('.form_delete').submit();
53     });
54
55     $("#z3950_new").click(function(e){
56         e.preventDefault();
57         window.open("/cgi-bin/koha/cataloguing/z3950_auth_search.pl","z3950search",'width=800,height=550,location=yes,toolbar=no,scrollbars=yes,resize=yes');
58     });
59
60     $("#z3950_replace").click(function(e){
61         e.preventDefault();
62         window.open("/cgi-bin/koha/cataloguing/z3950_auth_search.pl?authid=[% authid | html %]","z3950search",'width=800,height=500,location=yes,toolbar=no,scrollbars=yes,resize=yes');
63     });
64
65     var searchType = '[% marclist | html %]';
66     if (searchType) {
67         if ('mainmainentry' == searchType) {
68             $("#header_search a[href='#mainmain_heading']").tab("show");
69         } else if ('mainentry' == searchType) {
70             $("#header_search a[href='#main_heading']").tab("show");
71         } else if ('match' == searchType) {
72             $("#header_search a[href='#matchheading_search']").tab("show");
73         } else if ('all' == searchType) {
74             $("#header_search a[href='#entire_record']").tab("show");
75         }
76     }
77 });
78 const template_path = "[% interface | html %]/[% theme | html %]";
79
80 </script>
81 <!-- / authorities_js.inc -->