Bugzilla – Attachment 130921 Details for
Bug 13952
Import and export of authority types
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13952: (follow-up) template filters, moving js to separate file
Bug-13952-follow-up-template-filters-moving-js-to-.patch (text/plain), 21.25 KB, created by
Katrin Fischer
on 2022-02-19 21:30:00 UTC
(
hide
)
Description:
Bug 13952: (follow-up) template filters, moving js to separate file
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2022-02-19 21:30:00 UTC
Size:
21.25 KB
patch
obsolete
>From 590d412d7a6d2796ff78c92a694f4a0328c9c270 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Wed, 5 Dec 2018 21:33:48 +0000 >Subject: [PATCH] Bug 13952: (follow-up) template filters, moving js to > separate file > >This patch adds filters to the template file and moves the JS into a >separate file. > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >Signed-off-by: Michal Denar <black23@gmail.com> > >Signed-off-by: Michal Denar <black23@gmail.com> >Signed-off-by: Mazen Khallaf <mazen.i.khallaf@gamil.com> > >Signed-off-by: Michal Denar <black23@gmail.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > .../prog/en/modules/admin/authtypes.tt | 181 +++++------------- > koha-tmpl/intranet-tmpl/prog/js/authtype.js | 85 ++++++++ > 2 files changed, 136 insertions(+), 130 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/authtype.js > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tt >index f1251a8b53..eff2c33150 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tt >@@ -192,61 +192,61 @@ Authority types › Administration › Koha > <li><a href="/cgi-bin/koha/admin/authtypes.pl?op=add_form&authtypecode=[% authority_type.authtypecode | uri %]"><i class="fa fa-pencil"></i> Edit</a></li> > [% IF authority_type.authtypecode %]<li><a href="/cgi-bin/koha/admin/authtypes.pl?op=delete_confirm&authtypecode=[% authority_type.authtypecode | uri %]"><i class="fa fa-trash"></i> Delete</a></li>[% END %] > <!-- Button to trigger modal --> >- <li><a href="#" data-toggle="modal" data-target="#exportModal_[% authority_type.authtypecode %][% loop.count %]" title="Export authority type (fields, subfields) to a spreadsheet file (.csv, .xml, .ods)"><i class="fa fa-upload"></i> Export</a></li> >+ <li><a href="#" data-toggle="modal" data-target="#exportModal_[% authority_type.authtypecode | html %][% loop.count | html %]" title="Export authority type (fields, subfields) to a spreadsheet file (.csv, .xml, .ods)"><i class="fa fa-upload"></i> Export</a></li> > <!-- Button to trigger modal --> >- <li><a href="#" data-toggle="modal" data-target="#importModal_[% authority_type.authtypecode %][% loop.count %]" title="Import authority type (fields, subfields) from a spreadsheet file (.csv, .xml, .ods)"><i class="fa fa-download"></i> Import</a></li> >+ <li><a href="#" data-toggle="modal" data-target="#importModal_[% authority_type.authtypecode | html %][% loop.count | html %]" title="Import authority type (fields, subfields) from a spreadsheet file (.csv, .xml, .ods)"><i class="fa fa-download"></i> Import</a></li> > </ul> > </div> > >- <!-- Modal for export --> >- <div class="modal" id="exportModal_[% authority_type.authtypecode %][% loop.count %]" tabindex="-1" role="dialog" aria-labelledby="exportLabelexportModal_[% authority_type.authtypecode %][% loop.count %]" aria-hidden="true"> >- <div class="modal-dialog"> >- <div class="modal-content"> >- <div class="modal-header"> >- <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> >- <h3 id="exportLabelexportModal_[% authority_type.authtypecode %][% loop.count %]">Export [% authority_type.authtypetext %] authority type</h3> >- </div> >- <form action="import_export_authtype.pl" name="form_[% authority_type.authtypecode %]" method="get" target="_blank" class="form_export"> >- <div class="modal-body"> >- <fieldset> >- <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode %]" /> >- <p><label for="csv_type_export_[% authority_type.authtypecode %][% loop.count %]"><input type="radio" name="type_export_[% authority_type.authtypecode %]" value="csv" id="csv_type_export_[% authority_type.authtypecode %][% loop.count %]" checked="checked" /> Export to CSV spreadsheet</label></p> >- <p><label for="xml_type_export_[% authority_type.authtypecode %][% loop.count %]"><input type="radio" name="type_export_[% authority_type.authtypecode %]" value="excel" id="xml_type_export_[% authority_type.authtypecode %][% loop.count %]" /> Export to Excel with XML format, compatible with OpenOffice/LibreOffice as well</label></p> >- <p><label for="ods_type_export_[% authority_type.authtypecode %][% loop.count %]"><input type="radio" name="type_export_[% authority_type.authtypecode %]" value="ods" id="ods_type_export_[% authority_type.authtypecode %][% loop.count %]" /> Export to OpenDocument spreadsheet format</label></p> >- </fieldset> >- </div> >- <div class="modal-footer"> >- <button type="submit" class="btn btn-default">Export</button> >- <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button> >- </div> >- </form> >- </div> >- </div> >- </div> >+ <!-- Modal for export --> >+ <div class="modal" id="exportModal_[% authority_type.authtypecode | html %][% loop.count | html %]" tabindex="-1" role="dialog" aria-labelledby="exportLabelexportModal_[% authority_type.authtypecode | html %][% loop.count | html %]" aria-hidden="true"> >+ <div class="modal-dialog"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> >+ <h3 id="exportLabelexportModal_[% authority_type.authtypecode | html %][% loop.count | html %]">Export [% authority_type.authtypetext | html %] authority type</h3> >+ </div> >+ <form action="/cgi-bin/koha/admin/import_export_authtype.pl" name="form_[% authority_type.authtypecode | html %]" method="get" target="_blank" class="form_export"> >+ <div class="modal-body"> >+ <fieldset> >+ <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode | html %]" /> >+ <p><label for="csv_type_export_[% authority_type.authtypecode | html %][% loop.count | html %]"><input type="radio" name="type_export_[% authority_type.authtypecode | html %]" value="csv" id="csv_type_export_[% authority_type.authtypecode | html %][% loop.count | html %]" checked="checked" /> Export to CSV spreadsheet</label></p> >+ <p><label for="xml_type_export_[% authority_type.authtypecode | html %][% loop.count | html %]"><input type="radio" name="type_export_[% authority_type.authtypecode | html %]" value="excel" id="xml_type_export_[% authority_type.authtypecode | html %][% loop.count | html %]" /> Export to Excel with XML format, compatible with OpenOffice/LibreOffice as well</label></p> >+ <p><label for="ods_type_export_[% authority_type.authtypecode | html %][% loop.count | html %]"><input type="radio" name="type_export_[% authority_type.authtypecode | html %]" value="ods" id="ods_type_export_[% authority_type.authtypecode | html %][% loop.count | html %]" /> Export to OpenDocument spreadsheet format</label></p> >+ </fieldset> >+ </div> >+ <div class="modal-footer"> >+ <button type="submit" class="btn btn-default">Export</button> >+ <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button> >+ </div> >+ </form> >+ </div> >+ </div> >+ </div> > >- <!-- Modal for import --> >- <div class="modal" id="importModal_[% authority_type.authtypecode %][% loop.count %]" tabindex="-1" role="dialog" aria-labelledby="importLabelexportModal_[% authority_type.authtypecode %][% loop.count %]" aria-hidden="true"> >- <div class="modal-dialog"> >- <div class="modal-content"> >- <div class="modal-header"> >- <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> >- <h3 id="importLabelexportModal_[% authority_type.authtypecode %][% loop.count %]">Import [% authority_type.authtypecode %] authority type (fields and subfields) from a spreadsheet file (.csv, .xml, .ods)</h3> >- </div> >- <form action="/cgi-bin/koha/admin/import_export_authtype.pl" name="form_i_[% authority_type.authtypecode %]" id="form_i_[% authority_type.authtypecode %]" method="post" enctype="multipart/form-data" class="form_import"> >- <div class="modal-body"> >- <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode %]" /> >- <input type="hidden" name="action" value="import" /> >- <p><label for="file_import_[% authority_type.authtypecode %]">Upload file:</label> <input type="file" name="file_import_[% authority_type.authtypecode %]" id="file_import_[% authority_type.authtypecode %]" class="input_import" /></p> >- <div id="importing_[% authority_type.authtypecode %]" style="display:none" class="importing"><img src="[% interface %]/[% theme %]/img/loading-small.gif" alt="" /><span class="importing_msg"></span></div> >- </div> >- <div class="modal-footer"> >- <button type="submit" class="btn btn-default">Import</button> >- <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Close</button> >- </div> >- </form> >- </div> >- </div> >- </div> >+ <!-- Modal for import --> >+ <div class="modal" id="importModal_[% authority_type.authtypecode | html %][% loop.count | html %]" tabindex="-1" role="dialog" aria-labelledby="importLabelexportModal_[% authority_type.authtypecode | html %][% loop.count | html %]" aria-hidden="true"> >+ <div class="modal-dialog"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> >+ <h3 id="importLabelexportModal_[% authority_type.authtypecode | html %][% loop.count | html %]">Import [% authority_type.authtypecode | html %] authority type (fields and subfields) from a spreadsheet file (.csv, .xml, .ods)</h3> >+ </div> >+ <form action="/cgi-bin/koha/admin/import_export_authtype.pl" name="form_i_[% authority_type.authtypecode | html %]" id="form_i_[% authority_type.authtypecode | html %]" method="post" enctype="multipart/form-data" class="form_import"> >+ <div class="modal-body"> >+ <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode | html %]" /> >+ <input type="hidden" name="action" value="import" /> >+ <p><label for="file_import_[% authority_type.authtypecode | html %]">Upload file:</label> <input type="file" name="file_import_[% authority_type.authtypecode | html %]" id="file_import_[% authority_type.authtypecode | html %]" class="input_import" /></p> >+ <div id="importing_[% authority_type.authtypecode | html %]" style="display:none" class="importing"><img src="[% interface | html %]/[% theme | html %]/img/loading-small.gif" alt="" /><span class="importing_msg"></span></div> >+ </div> >+ <div class="modal-footer"> >+ <button type="submit" class="btn btn-default">Import</button> >+ <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Close</button> >+ </div> >+ </form> >+ </div> >+ </div> >+ </div> > </td> > </tr> > [% END %] >@@ -267,85 +267,6 @@ Authority types › Administration › Koha > [% MACRO jsinclude BLOCK %] > [% INCLUDE 'datatables.inc' %] > [% Asset.js("js/admin-menu.js") | $raw %] >- <script> >- var importing = false; >- >- $(document).ready(function() { >- $("#authtypes").dataTable($.extend(true, {}, dataTablesDefaults, { >- "aoColumnDefs": [ >- { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false }, >- { "aTargets": [ 0, 1 ], "sType": "natural" }, >- ], >- "sPaginationType": "full" >- })); >- $("#authtypecode").on("blur",function(){ >- toUC(this); >- }); >- >- $("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 authority type %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 authority type fields and subfields? This will overwrite the current configuration. For safety reasons please use the export option to make a backup"))) { >- var authtypecode = $('#' + id + ' input:hidden[name=authtypecode]').val(); >- $('#importing_' + authtypecode).find("span").html(_("Importing to authority type: %s. Importing from file: %s").format("<strong>" + authtypecode + "</strong>", "<i>" + obj.val().replace(new RegExp("^.+[/\\\\]"),"") + "</i>")); >- if (navigator.userAgent.toLowerCase().indexOf('msie') != -1) { >- var timestamp = new Date().getTime(); >- $('#importing_' + authtypecode).find("img").attr('src', '[% interface %]/[% theme %]/img/loading-small.gif' + '?' +timestamp); >- } >- $('#importing_' + authtypecode).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; >- }); >- }); >- </script> >+ [% Asset.js("js/authtype.js") | $raw %] > [% END %] > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/authtype.js b/koha-tmpl/intranet-tmpl/prog/js/authtype.js >new file mode 100644 >index 0000000000..b4c95017cc >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/authtype.js >@@ -0,0 +1,85 @@ >+/* Import/export from/to a spreadsheet */ >+ >+var importing = false; >+ >+$(document).ready(function() { >+ $("#authtypes").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "aoColumnDefs": [ >+ { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false }, >+ { "aTargets": [ 0, 1 ], "sType": "natural" }, >+ ], >+ "bSort": true, >+ "sPaginationType": "full" >+ })); >+ >+ $("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 authority type %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 authority type fields and subfields? This will overwrite the current configuration. For safety reasons please use the export option to make a backup"))) { >+ var authtypecode = $('#' + id + ' input:hidden[name=authtypecode]').val(); >+ $('#importing_' + authtypecode).find("span").html(_("Importing to authority type: %s. Importing from file: %s").format("<strong>" + authtypecode + "</strong>", "<i>" + obj.val().replace(new RegExp("^.+[/\\\\]"),"") + "</i>")); >+ if (navigator.userAgent.toLowerCase().indexOf('msie') != -1) { >+ var timestamp = new Date().getTime(); >+ $('#importing_' + authtypecode).find("img").attr('src', '[% interface | html %]/[% theme | html %]/img/loading-small.gif' + '?' +timestamp); >+ } >+ $('#importing_' + authtypecode).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(""); >+ bj.css("background-color","white"); >+ return false; >+ }); >+ $("#authtypecode").on("blur",function(){ >+ toUC(this); >+ }); >+ >+}); >-- >2.30.2
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 13952
:
44770
|
47326
|
47360
|
47364
|
50046
|
53065
|
53066
|
54840
|
54899
|
54900
|
57873
|
59831
|
64421
|
67914
|
67915
|
68299
|
68300
|
68301
|
68502
|
68512
|
68513
|
68514
|
68515
|
68556
|
69940
|
69941
|
69942
|
69943
|
69944
|
76665
|
76666
|
76667
|
76668
|
80794
|
80795
|
80796
|
80797
|
81248
|
82853
|
82854
|
82855
|
82856
|
82895
|
83024
|
83025
|
83026
|
83027
|
83028
|
85073
|
86549
|
86550
|
86551
|
86552
|
86553
|
86554
|
86555
|
103610
|
103611
|
103612
|
103613
|
103614
|
103615
|
103616
|
114170
|
114171
|
114172
|
114173
|
114174
|
114175
|
114176
|
114177
|
115379
|
115381
|
115382
|
115383
|
115384
|
115385
|
115386
|
115387
|
115388
|
125383
|
125384
|
125385
|
125386
|
125387
|
125388
|
125389
|
125390
|
128316
|
128317
|
128318
|
128319
|
128320
|
128321
|
128322
|
128323
|
128324
|
128325
|
128326
|
128327
|
128328
|
128329
|
128330
|
128331
|
130587
|
130917
|
130918
|
130919
|
130920
| 130921 |
130922
|
130923
|
130924
|
130925