Bugzilla – Attachment 48452 Details for
Bug 15846
Move MARC Framework JavaScript into separate file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15846: Move MARC Framework JavaScript into separate file
Bug-15846-Move-MARC-Framework-JavaScript-into-sepa.patch (text/plain), 10.08 KB, created by
Owen Leonard
on 2016-02-29 13:49:23 UTC
(
hide
)
Description:
Bug 15846: Move MARC Framework JavaScript into separate file
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2016-02-29 13:49:23 UTC
Size:
10.08 KB
patch
obsolete
>From 78dcb6ed2e05b49b94660bcf5ce9b36efbcb9cfe Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Wed, 17 Feb 2016 11:19:51 -0500 >Subject: [PATCH] Bug 15846: Move MARC Framework JavaScript into separate file >Content-Type: text/plain; charset="utf-8" > >The JavaScript embedded in the MARC framework template is not >dependent on template processing to such an extent that it can't >be safely moved to a separate file. This patch does so, adding >definition of a few translatable strings to the template. > >To test, apply the patch and go to Administration -> MARC frameworks. > >- The table of existing frameworks should be sortable. >- The "Export" link should trigger the export modal. >- The "Import" link should trigger the import modal. > -- Clicking "Import" without selecting a file should trigger an alert. > -- Selecting the wrong file type should trigger an alert. > -- Importing a file of the correct type should trigger an overwrite > warning ("Do you really want to import...?"). > -- A progress indicator should show during the import, with correct > values for "Importing from" and "Importing to". > -- Importing an incorrectly-formatted file of a correct type should > trigger an alert, "Error importing the framework..." > >Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com> >Works as advertised. Export and Import options work properly >--- > .../intranet-tmpl/prog/en/js/biblio_framework.js | 76 ++++++++++++++++++++ > .../prog/en/modules/admin/biblio_framework.tt | 84 ++-------------------- > 2 files changed, 83 insertions(+), 77 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/js/biblio_framework.js > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/biblio_framework.js b/koha-tmpl/intranet-tmpl/prog/en/js/biblio_framework.js >new file mode 100644 >index 0000000..36b7232 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/biblio_framework.js >@@ -0,0 +1,76 @@ >+/* Import/Export from/to spreadsheet */ >+ >+ var importing = false; >+ >+ $(document).ready(function() { >+ $("#table_biblio_frameworks").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "aoColumnDefs": [ >+ { "aTargets": [ -1, -2, -3, -4, -5 ], "bSortable": false, "bSearchable": false }, >+ { "aTargets": [ 0, 1 ], "sType": "natural" }, >+ ], >+ "bSort": true, >+ "sPaginationType": "four_button" >+ })); >+ >+ $("body").css("cursor", "auto"); >+ $('.import_export_options').hide(); >+ $('a.import_export_fw').click(function() { >+ if (!importing) { >+ $('.import_export_options').hide(); >+ $(this).next().show('slide'); >+ } >+ return false; >+ }); >+ $('.import_export_close').click(function() { >+ if (!importing) { >+ $('.import_export_options').fadeOut('fast'); >+ $("body").css("cursor", "auto"); >+ return false; >+ } >+ }); >+ $('.input_import').val(""); >+ >+ var matches = new RegExp("\\?error_import_export=(.+)$").exec(window.location.search); >+ if (matches && matches.length > 1) { >+ alert( MSG_IMPORT_ERROR + " %s".format(decodeURIComponent(matches[1]))); >+ } >+ >+ $('input.input_import').change( function() { >+ var filename = $(this).val(); >+ if ( ! /(?:\.csv|\.ods|\.xml)$/.test(filename)) { >+ $(this).css("background-color","yellow"); >+ alert( MSG_SELECT_FILE_FORMAT ); >+ $(this).val(""); >+ $(this).css("background-color","white"); >+ } >+ }); >+ $('form.form_export').submit(function() { >+ $('.modal').modal("hide"); >+ return true; >+ }); >+ $('form.form_import').submit(function() { >+ var id = $(this).attr('id'); >+ var obj = $('#' + id + ' input:file'); >+ if (/(?:\.csv|\.ods|\.xml)$/.test(obj.val())) { >+ if (confirm( MSG_OVERWRITE_WARNING )) { >+ var frameworkcode = $('#' + id + ' input:hidden[name=frameworkcode]').val(); >+ $('#importing_' + frameworkcode).find("span").html(MSG_IMPORTING_TO_FRAMEWORK.format("<strong>" + frameworkcode + "</strong>", "<i>" + obj.val().replace(new RegExp("^.+[/\\\\]"),"") + "</i>")); >+ if (navigator.userAgent.toLowerCase().indexOf('msie') != -1) { >+ var timestamp = new Date().getTime(); >+ $('#importing_' + frameworkcode).find("img").attr('src', template_path + '/img/loading-small.gif' + '?' +timestamp); >+ } >+ $('#importing_' + frameworkcode).css('display', 'block'); >+ if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1) $("body").css("cursor", "progress"); >+ importing = true; >+ $(".modal-footer,.closebtn").hide(); >+ return true; >+ } else >+ return false; >+ } >+ obj.css("background-color","yellow"); >+ alert( MSG_SELECT_FILE_FORMAT ); >+ obj.val(""); >+ obj.css("background-color","white"); >+ return false; >+ }); >+ }); >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tt >index 5345022..f131874 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tt >@@ -10,84 +10,14 @@ > <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> > [% INCLUDE 'datatables.inc' %] > <script type="text/javascript"> >-/* Import/Export from/to spreadsheet */ >- >- var importing = false; >- >- $(document).ready(function() { >- $("#table_biblio_frameworks").dataTable($.extend(true, {}, dataTablesDefaults, { >- "aoColumnDefs": [ >- { "aTargets": [ -1, -2, -3, -4, -5 ], "bSortable": false, "bSearchable": false }, >- { "aTargets": [ 0, 1 ], "sType": "natural" }, >- ], >- "bSort": true, >- "sPaginationType": "four_button" >- })); >- >- $("body").css("cursor", "auto"); >- $('.import_export_options').hide(); >- $('a.import_export_fw').click(function() { >- if (!importing) { >- $('.import_export_options').hide(); >- $(this).next().show('slide'); >- } >- return false; >- }); >- $('.import_export_close').click(function() { >- if (!importing) { >- $('.import_export_options').fadeOut('fast'); >- $("body").css("cursor", "auto"); >- return false; >- } >- }); >- $('.input_import').val(""); >- >- var matches = new RegExp("\\?error_import_export=(.+)$").exec(window.location.search); >- if (matches && matches.length > 1) { >- alert(_("Error importing the framework %s").format(decodeURIComponent(matches[1]))); >- } >- >- $('input.input_import').change( function() { >- var filename = $(this).val(); >- if ( ! /(?:\.csv|\.ods|\.xml)$/.test(filename)) { >- $(this).css("background-color","yellow"); >- alert(_("Please select a CSV (.csv), ODS (.ods) or XML (.xml) spreadsheet file.")); >- $(this).val(""); >- $(this).css("background-color","white"); >- } >- }); >- $('form.form_export').submit(function() { >- $('.modal').modal("hide"); >- return true; >- }); >- $('form.form_import').submit(function() { >- var id = $(this).attr('id'); >- var obj = $('#' + id + ' input:file'); >- if (/(?:\.csv|\.ods|\.xml)$/.test(obj.val())) { >- 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"))) { >- var frameworkcode = $('#' + id + ' input:hidden[name=frameworkcode]').val(); >- $('#importing_' + frameworkcode).find("span").html(_("Importing to framework: %s. Importing from file: %s").format("<strong>" + frameworkcode + "</strong>", "<i>" + obj.val().replace(new RegExp("^.+[/\\\\]"),"") + "</i>")); >- if (navigator.userAgent.toLowerCase().indexOf('msie') != -1) { >- var timestamp = new Date().getTime(); >- $('#importing_' + frameworkcode).find("img").attr('src', '[% interface %]/[% theme %]/img/loading-small.gif' + '?' +timestamp); >- } >- $('#importing_' + frameworkcode).css('display', 'block'); >- if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1) $("body").css("cursor", "progress"); >- importing = true; >- $(".modal-footer,.closebtn").hide(); >- return true; >- } else >- return false; >- } >- obj.css("background-color","yellow"); >- alert(_("Please select a CSV (.csv), ODS (.ods) or XML (.xml) spreadsheet file.")); >- obj.val(""); >- obj.css("background-color","white"); >- return false; >- }); >- }); >- >+ /* Set some variable needed in biblio_framework.js */ >+ var MSG_IMPORT_ERROR = _("Error importing the framework"); >+ var MSG_SELECT_FILE_FORMAT = _("Please select a CSV (.csv), ODS (.ods) or XML (.xml) spreadsheet file."); >+ 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"); >+ var MSG_IMPORTING_TO_FRAMEWORK = _("Importing to framework: %s. Importing from file: %s."); >+ var template_path = "[% interface %]/[% theme %]"; > </script> >+<script type="text/javascript" src="[% themelang %]/js/biblio_framework.js"></script> > > </head> > <body id="admin_biblio_framework" class="admin"> >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15846
:
48193
|
48194
|
48452
|
49528