Bugzilla – Attachment 42762 Details for
Bug 14805
Allow the deletion of multiple patron card batches
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14805: Allow the user to delete multiple batches
Bug-14805-Allow-the-user-to-delete-multiple-batche.patch (text/plain), 7.94 KB, created by
Jonathan Druart
on 2015-09-22 09:05:29 UTC
(
hide
)
Description:
Bug 14805: Allow the user to delete multiple batches
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-09-22 09:05:29 UTC
Size:
7.94 KB
patch
obsolete
>From 39f96c162fb78615d98ec7fbd0882e75de9885a6 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= <j.kylmala@gmail.com> >Date: Fri, 11 Sep 2015 13:55:07 +0000 >Subject: [PATCH] Bug 14805: Allow the user to delete multiple batches >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Allows the user to delete multiple patron card batches. > >Test plan: > >1. Add first some 20 batches >2. Go to the edit page of some X batch by first selecting from the > batch list the batch you want to edit and then after that by clicking > edit. >3. Delete one batch by selecting one batch and then clicking delete. >4. Select 0 batches and click delete, notice you cannot delete. >5. Select 0 batches and click edit, notice you cannot edit. >6. Select 2 batches and click edit, notice you cannot edit. >7. Apply patch >8. Check that steps from 2-6 work like they worked before. > (and add more batches so that you have ~20 of them) >9. Select 2 batches and click delete. Make sure they are deleted. >10. Try to figure out some anomalies this patch might have caused. > >Sponsored-by: Vaara-kirjastot > >Followed test plan, works as expected. >Signed-off-by: Marc Véron <veron@veron.ch> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > .../prog/en/modules/patroncards/manage.tt | 63 ++++++++++++++++------ > patroncards/manage.pl | 13 +++-- > 2 files changed, 56 insertions(+), 20 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/manage.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/manage.tt >index 1daf3bd..1c9b7a1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/manage.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/manage.tt >@@ -17,23 +17,38 @@ > <script type="text/javascript"> > //<![CDATA[ > function DeleteConfirm() { >- var element_id = selected_layout("delete"); >- if (element_id>-1) { >- var msg = _("Are you sure you want to delete %s %s?").format("[% PROCESS translate_card_element element=card_element %]", element_id); >- var answer = confirm(msg); >- if (answer) { >- window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=[% card_element %]&element_id=" + element_id; >- } >- else { >- return; // abort delete >+ var element_ids = selected_layouts("delete"); >+ >+ var answer; >+ if (element_ids.length > 1) { >+ var msg = _("Are you sure you want to delete %s batches?").format(element_ids.length); >+ answer = confirm(msg); >+ } else if (element_ids.length == 1) { >+ var msg = _("Are you sure you want to delete %s %s?").format("[% PROCESS translate_card_element element=card_element %]", element_ids[0]); >+ answer = confirm(msg); >+ } >+ >+ if (answer) { >+ var elements = ""; >+ for (var i = 0; i < element_ids.length; i++) { >+ if (element_ids[i] > -1) { >+ elements += element_ids[i] + "," >+ } >+ else { >+ return; // no layout selected >+ } > } >+ >+ window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=[% card_element %]&element_id=" + elements; > } > else { >- return; // no layout selected >- }; >+ return; // abort delete >+ } >+ > }; >+ > function Edit() { >- var element_id = selected_layout("edit"); >+ var element_id = selected_layouts("edit"); > if (element_id>-1) { > window.location = "/cgi-bin/koha/patroncards/edit-[% card_element %].pl?op=edit&element_id=" + element_id; > } >@@ -64,7 +79,7 @@ > } > return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?" + getstr, 700, 800); > }; >- function selected_layout(op) { >+ function selected_layouts(op) { > var selected = new Array; > if (document.layouts.action.length) { > for (i=0;i<document.layouts.action.length;i++){ >@@ -72,8 +87,26 @@ > selected.push(i); > } > }; >- if (selected.length == 1) { >- return(document.layouts.action[selected[0]].value); >+ if (selected.length == 1 || (op == "delete" && selected.length >= 1)) { >+ if (op == "delete") { >+ var selectedDelete = new Array; >+ for (i = 0; i < selected.length; i++) { >+ selectedDelete.push(document.layouts.action[selected[i]].value); >+ } >+ return(selectedDelete); >+ } else { >+ // op == 'edit' returns only the object and not list >+ return(document.layouts.action[selected[0]].value); >+ } >+ } >+ else if (selected.length < 1) { >+ if (op == "edit") { >+ alert(_("Please select one %s to %s.").format("[% PROCESS translate_card_element element=card_element %]", op)); >+ return (-1); >+ } else { >+ alert(_("Please select at least one %s to %s.").format("[% PROCESS translate_card_element element=card_element %]", op)); >+ return (-1); >+ } > } > else { > alert(_("Please select only one %s to %s.").format("[% PROCESS translate_card_element element=card_element %]", op)); >diff --git a/patroncards/manage.pl b/patroncards/manage.pl >index e5c54f5..26f2123 100755 >--- a/patroncards/manage.pl >+++ b/patroncards/manage.pl >@@ -76,11 +76,14 @@ my $branch_code = ($card_element eq 'batch' ? C4::Context->userenv->{'branch'} : > > if ($op eq 'delete') { > my $err = 0; >- if ($card_element eq 'layout') {$err = C4::Patroncards::Layout::delete(layout_id => $element_id);} >- elsif ($card_element eq 'template') {$err = C4::Patroncards::Template::delete(template_id => $element_id);} >- elsif ($card_element eq 'profile') {$err = C4::Patroncards::Profile::delete(profile_id => $element_id);} >- elsif ($card_element eq 'batch') {$err = C4::Labels::Batch::delete(batch_id => $element_id, branch_code => $branch_code);} >- else {warn sprintf("Unknown card element passed in for delete operation: %s.",$card_element); $errstr = 202;} >+ my @element_ids = split(/,/, $element_id); >+ foreach my $element_id (@element_ids) { >+ if ($card_element eq 'layout') {$err = C4::Patroncards::Layout::delete(layout_id => $element_id);} >+ elsif ($card_element eq 'template') {$err = C4::Patroncards::Template::delete(template_id => $element_id);} >+ elsif ($card_element eq 'profile') {$err = C4::Patroncards::Profile::delete(profile_id => $element_id);} >+ elsif ($card_element eq 'batch') {$err = C4::Labels::Batch::delete(batch_id => $element_id, branch_code => $branch_code);} >+ else {warn sprintf("Unknown card element passed in for delete operation: %s.",$card_element); $errstr = 202;} >+ } > print $cgi->redirect("manage.pl?card_element=$card_element" . ($err ? "&error=102" : '')); > exit; > } >-- >2.1.0
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 14805
:
42522
|
42592
|
42639
|
42647
|
42725
|
42752
| 42762 |
42763
|
42764
|
42765
|
44358