View | Details | Raw Unified | Return to bug 25318
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities_js.inc (-79 lines)
Lines 1-79 Link Here
1
<!-- authorities_js.inc -->
2
<script>
3
    function mergeAuth(authid, summary) {
4
        var alreadySelected = Cookies.get('auth_to_merge');
5
        if (alreadySelected !== undefined) {
6
            alreadySelected = JSON.parse(alreadySelected);
7
            Cookies.remove('auth_to_merge');
8
            var refstring = "";
9
            if (typeof alreadySelected.mergereference !== 'undefined') {
10
                refstring = "&mergereference=" + alreadySelected.mergereference;
11
            }
12
            window.location.href = "/cgi-bin/koha/authorities/merge.pl?authid=" + authid + "&authid=" + alreadySelected.authid + refstring;
13
        } else {
14
            Cookies.set('auth_to_merge', JSON.stringify({ 'authid': authid, 'summary': summary }), { 'path' : '/', sameSite: 'Lax' });
15
            showMergingInProgress();
16
        }
17
    }
18
19
    function showMergingInProgress() {
20
        var alreadySelected = Cookies.get('auth_to_merge');
21
        if (alreadySelected) {
22
            alreadySelected = JSON.parse(alreadySelected);
23
            $('#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>");
24
            $('#cancel_merge').click(function(event) {
25
                event.preventDefault();
26
                Cookies.remove('auth_to_merge');
27
                $('#merge_in_progress').hide().empty();
28
            });
29
        } else {
30
            $('#merge_in_progress').hide().empty();
31
        }
32
    }
33
34
    $(document).ready(function () {
35
        showMergingInProgress();
36
37
        $('.form_delete').submit(function() {
38
            if ( confirm(_("Are you sure you want to delete this authority?")) ) {
39
                return true;
40
            }
41
            // FIXME Close the dropdown $(this).closest('ul.dropdown-menu').dropdown('toggle');
42
            return false;
43
        });
44
45
        $('.merge_auth').click(function (event) {
46
            event.preventDefault();
47
            mergeAuth($(this).parents('tr').attr('data-authid'), $(this).parents('tr').find('div.authorizedheading').text());
48
        });
49
50
        $("#delAuth").click(function(){
51
            $('.form_delete').submit();
52
        });
53
54
        $("#z3950_new").click(function(e){
55
            e.preventDefault();
56
            window.open("/cgi-bin/koha/cataloguing/z3950_auth_search.pl","z3950search",'width=800,height=550,location=yes,toolbar=no,scrollbars=yes,resize=yes');
57
        });
58
59
        $("#z3950_replace").click(function(e){
60
            e.preventDefault();
61
            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');
62
        });
63
64
        var searchType = '[% marclist | html %]';
65
        if (searchType) {
66
            if ('mainmainentry' == searchType.valueOf()) {
67
                $("#header_search a[href='#mainmain_heading_panel']").tab("show");
68
            } else if ('mainentry' == searchType.valueOf()) {
69
                $("#header_search a[href='#main_heading_panel']").tab("show");
70
            } else if ('match' == searchType.valueOf()) {
71
                $("#header_search a[href='#matchheading_search_panel']").tab("show");
72
            } else if ('all' == searchType.valueOf()) {
73
                $("#header_search a[href='#entire_record_panel']").tab("show");
74
            }
75
        }
76
    });
77
    const template_path = "[% interface | html %]/[% theme | html %]";
78
</script>
79
<!-- / authorities_js.inc -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities-home.tt (-1 / +4 lines)
Lines 40-46 Link Here
40
    [%- END -%]
40
    [%- END -%]
41
[% END %]
41
[% END %]
42
[% MACRO jsinclude BLOCK %]
42
[% MACRO jsinclude BLOCK %]
43
    [% INCLUDE 'authorities_js.inc' %]
43
    <script>
44
        const searchType = "[% marclist | html %]";
45
    </script>
46
    [% Asset.js("js/authorities.js") | $raw %]
44
[% END %]
47
[% END %]
45
48
46
[% INCLUDE 'intranet-bottom.inc' %]
49
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/detail.tt (-1 / +5 lines)
Lines 134-140 Link Here
134
[% END %]
134
[% END %]
135
135
136
[% MACRO jsinclude BLOCK %]
136
[% MACRO jsinclude BLOCK %]
137
    [% INCLUDE 'authorities_js.inc' %]
137
    <script>
138
        const authid = "[% authid | html %]";
139
        const searchType = "[% marclist | html %]";
140
    </script>
141
    [% Asset.js("js/authorities.js") | $raw %]
138
    [% IF ( displayhierarchy ) %]
142
    [% IF ( displayhierarchy ) %]
139
        [% Asset.js("lib/jquery/plugins/jstree/jstree-3.3.12.min.js") | $raw %]
143
        [% Asset.js("lib/jquery/plugins/jstree/jstree-3.3.12.min.js") | $raw %]
140
    [% END %]
144
    [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/merge.tt (-1 / +1 lines)
Lines 140-146 Link Here
140
[% END %]
140
[% END %]
141
141
142
[% MACRO jsinclude BLOCK %]
142
[% MACRO jsinclude BLOCK %]
143
    [% INCLUDE 'authorities_js.inc' %]
143
    [% Asset.js("js/authorities.js") | $raw %]
144
    [% Asset.js("js/merge-record.js") | $raw %]
144
    [% Asset.js("js/merge-record.js") | $raw %]
145
    <script>
145
    <script>
146
        // When submiting the form
146
        // When submiting the form
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt (+2 lines)
Lines 145-150 Link Here
145
    <script>
145
    <script>
146
        var index = "[% index | html %]";
146
        var index = "[% index | html %]";
147
        var authtypecode = "[% authtypecode | html %]";
147
        var authtypecode = "[% authtypecode | html %]";
148
        const searchType = "[% marclist | html %]";
149
        const template_path = "[% interface | html %]/[% theme | html %]";
148
    </script>
150
    </script>
149
    [% Asset.js("js/auth-finder-search.js") | $raw %]
151
    [% Asset.js("js/auth-finder-search.js") | $raw %]
150
    [% Asset.js("js/authorities-detail-modal.js") | $raw %]
152
    [% Asset.js("js/authorities-detail-modal.js") | $raw %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt (-1 / +5 lines)
Lines 155-161 Link Here
155
[% END %]
155
[% END %]
156
156
157
[% MACRO jsinclude BLOCK %]
157
[% MACRO jsinclude BLOCK %]
158
    [% INCLUDE 'authorities_js.inc' %]
158
    <script>
159
        const searchType = "[% marclist | html %]";
160
        const template_path = "[% interface | html %]/[% theme | html %]";
161
    </script>
162
    [% Asset.js("js/authorities.js") | $raw %]
159
    [% Asset.js("js/authorities-detail-modal.js") | $raw %]
163
    [% Asset.js("js/authorities-detail-modal.js") | $raw %]
160
[% END %]
164
[% END %]
161
165
(-)a/koha-tmpl/intranet-tmpl/prog/js/authorities-detail-modal.js (-1 / +1 lines)
Lines 1-4 Link Here
1
/* global template_path */
1
/* global __ template_path */
2
$(document).ready(function () {
2
$(document).ready(function () {
3
    $(".authority_preview a").on("click", function (e) {
3
    $(".authority_preview a").on("click", function (e) {
4
        e.preventDefault();
4
        e.preventDefault();
(-)a/koha-tmpl/intranet-tmpl/prog/js/authorities.js (-1 / +112 lines)
Line 0 Link Here
0
- 
1
/* global __  Cookies */
2
function mergeAuth(authid, summary) {
3
    var alreadySelected = Cookies.get("auth_to_merge");
4
    if (alreadySelected !== undefined) {
5
        alreadySelected = JSON.parse(alreadySelected);
6
        Cookies.remove("auth_to_merge");
7
        var refstring = "";
8
        if (typeof alreadySelected.mergereference !== "undefined") {
9
            refstring = "&mergereference=" + alreadySelected.mergereference;
10
        }
11
        window.location.href =
12
            "/cgi-bin/koha/authorities/merge.pl?authid=" +
13
            authid +
14
            "&authid=" +
15
            alreadySelected.authid +
16
            refstring;
17
    } else {
18
        Cookies.set(
19
            "auth_to_merge",
20
            JSON.stringify({ authid: authid, summary: summary }),
21
            { path: "/", sameSite: "Lax" }
22
        );
23
        showMergingInProgress();
24
    }
25
}
26
27
function showMergingInProgress() {
28
    var alreadySelected = Cookies.get("auth_to_merge");
29
    if (alreadySelected) {
30
        alreadySelected = JSON.parse(alreadySelected);
31
        $("#merge_in_progress")
32
            .show()
33
            .html(
34
                __("Merging with authority: ") +
35
                    "<a href='detail.pl?authid=" +
36
                    alreadySelected.authid +
37
                    "'><span class='authorizedheading'>" +
38
                    alreadySelected.summary +
39
                    "</span> (" +
40
                    alreadySelected.authid +
41
                    ")</a> <a href='#' id='cancel_merge'>" +
42
                    __("Cancel merge") +
43
                    "</a>"
44
            );
45
        $("#cancel_merge").click(function (event) {
46
            event.preventDefault();
47
            Cookies.remove("auth_to_merge");
48
            $("#merge_in_progress").hide().empty();
49
        });
50
    } else {
51
        $("#merge_in_progress").hide().empty();
52
    }
53
}
54
55
$(document).ready(function () {
56
    showMergingInProgress();
57
58
    $(".form_delete").submit(function () {
59
        if (confirm(__("Are you sure you want to delete this authority?"))) {
60
            return true;
61
        }
62
        // FIXME Close the dropdown $(this).closest('ul.dropdown-menu').dropdown('toggle');
63
        return false;
64
    });
65
66
    $(".merge_auth").click(function (event) {
67
        event.preventDefault();
68
        mergeAuth(
69
            $(this).parents("tr").attr("data-authid"),
70
            $(this).parents("tr").find("div.authorizedheading").text()
71
        );
72
    });
73
74
    $("#delAuth").click(function () {
75
        $(".form_delete").submit();
76
    });
77
78
    $("#z3950_new").click(function (e) {
79
        e.preventDefault();
80
        window.open(
81
            "/cgi-bin/koha/cataloguing/z3950_auth_search.pl",
82
            "z3950search",
83
            "width=800,height=550,location=yes,toolbar=no,scrollbars=yes,resize=yes"
84
        );
85
    });
86
87
    if (typeof authid !== undefined) {
88
        $("#z3950_replace").click(function (e) {
89
            e.preventDefault();
90
            window.open(
91
                "/cgi-bin/koha/cataloguing/z3950_auth_search.pl?authid=" +
92
                    authid,
93
                "z3950search",
94
                "width=800,height=500,location=yes,toolbar=no,scrollbars=yes,resize=yes"
95
            );
96
        });
97
    }
98
99
    if (searchType) {
100
        if ("mainmainentry" == searchType.valueOf()) {
101
            $("#header_search a[href='#mainmain_heading_panel']").tab("show");
102
        } else if ("mainentry" == searchType.valueOf()) {
103
            $("#header_search a[href='#main_heading_panel']").tab("show");
104
        } else if ("match" == searchType.valueOf()) {
105
            $("#header_search a[href='#matchheading_search_panel']").tab(
106
                "show"
107
            );
108
        } else if ("all" == searchType.valueOf()) {
109
            $("#header_search a[href='#entire_record_panel']").tab("show");
110
        }
111
    }
112
});

Return to bug 25318