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

(-)a/koha-tmpl/intranet-tmpl/prog/en/js/biblio_framework.js (+76 lines)
Line 0 Link Here
1
/* Import/Export from/to spreadsheet */
2
3
    var importing = false;
4
5
    $(document).ready(function() {
6
        $("#table_biblio_frameworks").dataTable($.extend(true, {}, dataTablesDefaults, {
7
            "aoColumnDefs": [
8
                { "aTargets": [ -1, -2, -3, -4, -5 ], "bSortable": false, "bSearchable": false },
9
                { "aTargets": [ 0, 1 ], "sType": "natural" },
10
            ],
11
            "bSort": true,
12
            "sPaginationType": "four_button"
13
        }));
14
15
        $("body").css("cursor", "auto");
16
        $('.import_export_options').hide();
17
        $('a.import_export_fw').click(function() {
18
            if (!importing) {
19
                $('.import_export_options').hide();
20
                $(this).next().show('slide');
21
            }
22
            return false;
23
        });
24
        $('.import_export_close').click(function() {
25
            if (!importing) {
26
                $('.import_export_options').fadeOut('fast');
27
                $("body").css("cursor", "auto");
28
                return false;
29
            }
30
        });
31
        $('.input_import').val("");
32
33
        var matches = new RegExp("\\?error_import_export=(.+)$").exec(window.location.search);
34
        if (matches && matches.length > 1) {
35
            alert( MSG_IMPORT_ERROR + " %s".format(decodeURIComponent(matches[1])));
36
        }
37
38
        $('input.input_import').change( function() {
39
            var filename = $(this).val();
40
            if ( ! /(?:\.csv|\.ods|\.xml)$/.test(filename)) {
41
                $(this).css("background-color","yellow");
42
                alert( MSG_SELECT_FILE_FORMAT );
43
                $(this).val("");
44
                $(this).css("background-color","white");
45
            }
46
        });
47
        $('form.form_export').submit(function() {
48
            $('.modal').modal("hide");
49
            return true;
50
        });
51
        $('form.form_import').submit(function() {
52
            var id = $(this).attr('id');
53
            var obj = $('#' + id + ' input:file');
54
            if (/(?:\.csv|\.ods|\.xml)$/.test(obj.val())) {
55
                if (confirm( MSG_OVERWRITE_WARNING )) {
56
                    var frameworkcode = $('#' + id + ' input:hidden[name=frameworkcode]').val();
57
                    $('#importing_' + frameworkcode).find("span").html(MSG_IMPORTING_TO_FRAMEWORK.format("<strong>" + frameworkcode + "</strong>", "<i>" + obj.val().replace(new RegExp("^.+[/\\\\]"),"") + "</i>"));
58
                    if (navigator.userAgent.toLowerCase().indexOf('msie') != -1) {
59
                        var timestamp = new Date().getTime();
60
                        $('#importing_' + frameworkcode).find("img").attr('src', template_path + '/img/loading-small.gif' + '?' +timestamp);
61
                    }
62
                    $('#importing_' + frameworkcode).css('display', 'block');
63
                    if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1) $("body").css("cursor", "progress");
64
                    importing = true;
65
                    $(".modal-footer,.closebtn").hide();
66
                    return true;
67
                } else
68
                    return false;
69
            }
70
            obj.css("background-color","yellow");
71
            alert( MSG_SELECT_FILE_FORMAT );
72
            obj.val("");
73
            obj.css("background-color","white");
74
            return false;
75
        });
76
    });
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tt (-78 / +7 lines)
Lines 10-93 Link Here
10
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
10
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
11
[% INCLUDE 'datatables.inc' %]
11
[% INCLUDE 'datatables.inc' %]
12
<script type="text/javascript">
12
<script type="text/javascript">
13
/* Import/Export from/to spreadsheet */
13
    /* Set some variable needed in biblio_framework.js */
14
14
    var MSG_IMPORT_ERROR = _("Error importing the framework");
15
    var importing = false;
15
    var MSG_SELECT_FILE_FORMAT = _("Please select a spreadsheet (.csv, .xml, .ods) file");
16
16
    var MSG_OVERWRITE_WARNING = _("Do you really want to import the framework fields and subfields? This will overwrite the current configuration. For safety reasons please use the export option to make a backup");
17
    $(document).ready(function() {
17
    var MSG_IMPORTING_TO_FRAMEWORK = _("Importing to framework: %s. Importing from file: %s.");
18
        $("#table_biblio_frameworks").dataTable($.extend(true, {}, dataTablesDefaults, {
18
    var template_path = "[% interface %]/[% theme %]";
19
            "aoColumnDefs": [
20
                { "aTargets": [ -1, -2, -3, -4, -5 ], "bSortable": false, "bSearchable": false },
21
                { "aTargets": [ 0, 1 ], "sType": "natural" },
22
            ],
23
            "bSort": true,
24
            "sPaginationType": "four_button"
25
        }));
26
27
        $("body").css("cursor", "auto");
28
        $('.import_export_options').hide();
29
        $('a.import_export_fw').click(function() {
30
            if (!importing) {
31
                $('.import_export_options').hide();
32
                $(this).next().show('slide');
33
            }
34
            return false;
35
        });
36
        $('.import_export_close').click(function() {
37
            if (!importing) {
38
                $('.import_export_options').fadeOut('fast');
39
                $("body").css("cursor", "auto");
40
                return false;
41
            }
42
        });
43
        $('.input_import').val("");
44
45
        var matches = new RegExp("\\?error_import_export=(.+)$").exec(window.location.search);
46
        if (matches && matches.length > 1) {
47
            alert(_("Error importing the framework %s").format(decodeURIComponent(matches[1])));
48
        }
49
50
        $('input.input_import').change( function() {
51
            var filename = $(this).val();
52
            if ( ! /(?:\.csv|\.ods|\.xml)$/.test(filename)) {
53
                $(this).css("background-color","yellow");
54
                alert(_("Please select an ods or xml file"));
55
                $(this).val("");
56
                $(this).css("background-color","white");
57
            }
58
        });
59
        $('form.form_export').submit(function() {
60
            $('.modal').modal("hide");
61
            return true;
62
        });
63
        $('form.form_import').submit(function() {
64
            var id = $(this).attr('id');
65
            var obj = $('#' + id + ' input:file');
66
            if (/(?:\.csv|\.ods|\.xml)$/.test(obj.val())) {
67
                if (confirm(_("Do you really want to import the framework fields and subfields? This will overwrite the current configuration. For safety reasons please use the export option to make a backup"))) {
68
                    var frameworkcode = $('#' + id + ' input:hidden[name=frameworkcode]').val();
69
                    $('#importing_' + frameworkcode).find("span").html(_("Importing to framework: %s. Importing from file: %s").format("<strong>" + frameworkcode + "</strong>", "<i>" + obj.val().replace(new RegExp("^.+[/\\\\]"),"") + "</i>"));
70
                    if (navigator.userAgent.toLowerCase().indexOf('msie') != -1) {
71
                        var timestamp = new Date().getTime();
72
                        $('#importing_' + frameworkcode).find("img").attr('src', '[% interface %]/[% theme %]/img/loading-small.gif' + '?' +timestamp);
73
                    }
74
                    $('#importing_' + frameworkcode).css('display', 'block');
75
                    if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1) $("body").css("cursor", "progress");
76
                    importing = true;
77
                    $(".modal-footer,.closebtn").hide();
78
                    return true;
79
                } else
80
                    return false;
81
            }
82
            obj.css("background-color","yellow");
83
            alert(_("Please select an spreadsheet (csv, ods, xml) file"));
84
            obj.val("");
85
            obj.css("background-color","white");
86
            return false;
87
        });
88
    });
89
90
</script>
19
</script>
20
<script type="text/javascript" src="[% themelang %]/js/biblio_framework.js"></script>
91
21
92
</head>
22
</head>
93
<body id="admin_biblio_framework" class="admin">
23
<body id="admin_biblio_framework" class="admin">
94
- 

Return to bug 15846