Bugzilla – Attachment 42184 Details for
Bug 13943
Cancelling the deletion process of an item deletes item anyway
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 13943: Prevent the deletion of items if the user cancels
PASSED-QA-Bug-13943-Prevent-the-deletion-of-items-.patch (text/plain), 7.34 KB, created by
Katrin Fischer
on 2015-09-01 22:01:38 UTC
(
hide
)
Description:
[PASSED QA] Bug 13943: Prevent the deletion of items if the user cancels
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2015-09-01 22:01:38 UTC
Size:
7.34 KB
patch
obsolete
>From 4e21be2e40f0ba75b103e8f0f4f72044930aecfc Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 13 Jul 2015 17:34:53 +0100 >Subject: [PATCH] [PASSED QA] Bug 13943: Prevent the deletion of items if the > user cancels > >On the edit items page, there is some weird JS code: if the user clicks >on the delete link and then cancel, the item is deleted anyway. > >It's caused by the following JS code in browser.js > $('a[href*="biblionumber="]').click(function (ev) { > ev.preventDefault(); > window.location = $(this).attr('href') + '&searchid=' + me.searchid; > }); > >Test plan: >- Do a search with multiple results >- Go to the detail page (make sure results browser shows up!) >- Use the "Edit items" link from the toolbar >- Delete an item (try both way) >- Choose "cancel" >- Delete an item (try both way) and confirm the deletion >You should see the browser after the deletion and the item should have >been deleted correctly. >- Edit an item (try both way) >You should see the browser (did not work before this patch) > >Note: Before this patch, the 2 first columns didn't contain the >edit/delete item links, now it's only the 1st one. > >Signed-off-by: Nick Clemens <nick@quecheelibrary.org> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >Much better! >--- > .../prog/en/modules/cataloguing/additem.tt | 52 ++++++++++++---------- > 1 file changed, 29 insertions(+), 23 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >index ab9621b..5028251 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -15,23 +15,35 @@ > browser.show(); > > $(document).ready(function(){ >+ >+ // Remove the onclick event defined in browser.js, >+ // otherwise the deletion confirmation will not work correctly >+ $('a[href*="biblionumber="]').off('click'); >+ > [% IF (popup) %] > [% IF (opisadd) %] > window.close(); > [% END %] > [% END %] > $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit"); >- /* Inline edit/delete links */ >- var biblionumber = $("input[name='biblionumber']").attr("value"); >- $("tr.editable td").click(function(event){ >- var $tgt = $(event.target); >- if($tgt.is("a")||$tgt.is(":first-child")||$tgt.is(":nth-child(2)")){ return true; } else { >- var rowid = $(this).parent().attr("id"); >- num_rowid = rowid.replace("row",""); >- $(".linktools").remove(); >- $(this).append("<span class=\"linktools\"><a href=\"/cgi-bin/koha/cataloguing/additem.pl?op=edititem&frameworkcode=[% frameworkcode %]&biblionumber=[% biblionumber %]&itemnumber="+num_rowid+"#edititem\">" + _("Edit item") + "</a> <a href=\"/cgi-bin/koha/cataloguing/additem.pl?op=delitem&frameworkcode=[% frameworkcode %]&biblionumber=[% biblionumber %]&itemnumber="+num_rowid+"\" onclick=\"confirm_deletion([% biblionumber %],"+num_rowid+"); return false;\">" + _("Delete item") + "</a></span>"); >- } >- }); >+ /* Inline edit/delete links */ >+ var biblionumber = $("input[name='biblionumber']").attr("value"); >+ $("tr.editable").each(function(){ >+ $(this).find("td:not(:first)").on('click', function(){ >+ var rowid = $(this).parent().attr("id"); >+ num_rowid = rowid.replace("row",""); >+ $(".linktools").remove(); >+ var edit_link = $('<a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&frameworkcode=[% frameworkcode %]&biblionumber=[% biblionumber %]&itemnumber='+num_rowid+'&searchid=[% searchid %]#edititem">' + _("Edit item") + '</a>'); >+ var delete_link = $('<a href="/cgi-bin/koha/cataloguing/additem.pl?op=delitem&frameworkcode=[% frameworkcode %]&biblionumber=[% biblionumber %]&itemnumber='+num_rowid+'&searchid=[% searchid %]">' + _("Delete item") + '</a></span>'); >+ $(delete_link).on('click', function(e) { >+ return confirm_deletion(); >+ }); >+ var tools_node = $('<span class="linktools"></span>'); >+ $(tools_node).append(edit_link); >+ $(tools_node).append(delete_link); >+ $(this).append(tools_node); >+ }); >+ }); > > var itemst = $("#itemst").dataTable($.extend(true, {}, dataTablesDefaults, { > "aoColumnDefs": [ >@@ -79,16 +91,10 @@ function Dopop(link,i) { > newin=window.open(link+"&result="+defaultvalue,"valuebuilder",'width=500,height=400,toolbar=false,scrollbars=yes'); > } > >-function confirm_deletion(biblionumber,itemnumber) { >- var original = $("#row"+itemnumber).attr("class"); >- $("#row"+itemnumber).attr("class","confirm"); >- var is_confirmed = confirm(_("Are you sure you want to delete this item?")); >- if (is_confirmed) { >- window.location = "additem.pl?op=delitem&biblionumber="+biblionumber+"&itemnumber="+itemnumber; >- } else { >- $("#row"+itemnumber).attr("class",""); >- } >+function confirm_deletion() { >+ return confirm(_("Are you sure you want to delete this item?")); > } >+ > //]]> > </script> > <link type="text/css" rel="stylesheet" href="[% themelang %]/css/addbiblio.css" /> >@@ -155,13 +161,13 @@ function confirm_deletion(biblionumber,itemnumber) { > [% ELSE %] > <td> > [% IF ( item_loo.hostitemflag ) %] >- <a href="additem.pl?op=edititem&biblionumber=[% item_loo.hostbiblionumber %]&itemnumber=[% item_loo.itemnumber %]#edititem">Edit in host</a> <a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delinkitem&biblionumber=[% biblionumber %]&hostitemnumber=[% item_loo.itemnumber %]">Delink</a> >+ <a href="additem.pl?op=edititem&biblionumber=[% item_loo.hostbiblionumber %]&itemnumber=[% item_loo.itemnumber %]#edititem">Edit in host</a> <a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delinkitem&biblionumber=[% biblionumber %]&hostitemnumber=[% item_loo.itemnumber %]&searchid=[% searchid %]">Delink</a> > [% ELSE %] >- <a href="additem.pl?op=edititem&biblionumber=[% biblionumber %]&itemnumber=[% item_loo.itemnumber %]#edititem">Edit</a> >+ <a href="additem.pl?op=edititem&biblionumber=[% biblionumber %]&itemnumber=[% item_loo.itemnumber %]&searchid=[% searchid %]#edititem">Edit</a> > [% IF ( item_loo.countanalytics ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?idx=hi&q=% item_loo.itemnumber %]">View analytics</a> > [% ELSE %] >- <a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delitem&biblionumber=[% biblionumber %]&itemnumber=[% item_loo.itemnumber %]" onclick="confirm_deletion([% biblionumber %],[% item_loo.itemnumber %]); return false;">Delete</a> >+ <a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delitem&biblionumber=[% biblionumber %]&itemnumber=[% item_loo.itemnumber %]&searchid=[% searchid %]" onclick="return confirm_deletion();">Delete</a> > [% END %] > [% END %] > </td> >-- >1.9.1
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 13943
:
40975
|
40984
|
41091
| 42184