Bug 16268: Add confirm message for deleting circ and fines rules
authorAleisha <aleishaamohia@hotmail.com>
Sun, 17 Apr 2016 22:35:19 +0000 (22:35 +0000)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 29 Apr 2016 10:55:52 +0000 (10:55 +0000)
EDIT: Removes unnecessary code and uses confirm message in staff-global.js

To test:
1) Apply 16267
2) Go to Admin -> Circ and fines rules
3) Try clicking on Delete and Unset buttons
4) Confirm a confirm message pops up and works as expected

Sponsored-by: Catalyst IT

Signed-off-by: Marc VĂ©ron <veron@veron.ch>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt

index 714212f..bdac04b 100644 (file)
@@ -25,7 +25,13 @@ function clear_edit(){
     $(edit_row).find("td:last input[name='clear']").remove();
 }
 
+var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this rule? This cannot be undone.");
+
 $(document).ready(function() {
+    $(".delete").on("click",function(){
+        return confirmDelete(MSG_CONFIRM_DELETE);
+    });
+
         $('#cap_fine_to_replacement_price').on('change', function(){
             $('#overduefinescap').prop('disabled', $(this).is(':checked') );
         });
@@ -260,7 +266,7 @@ for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde
                                                        <td>[% rule.rentaldiscount %]</td>
                                                         <td class="actions">
                                                           <a href="#" class="editrule btn btn-mini"><i class="fa fa-pencil"></i> Edit</a>
-                                                          <a class="btn btn-mini" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% rule.itemtype %]&amp;categorycode=[% rule.categorycode %]&amp;branch=[% rule.current_branch %]"><i class="fa fa-trash"></i> Delete</a>
+                                                          <a class="btn btn-mini delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% rule.itemtype %]&amp;categorycode=[% rule.categorycode %]&amp;branch=[% rule.current_branch %]"><i class="fa fa-trash"></i> Delete</a>
                                                        </td>
                        </tr>
                [% END %]
@@ -480,7 +486,7 @@ for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde
                     </td>
                     <td class="actions">
                         <button type="submit" class="btn btn-mini"><i class="fa fa-save"></i> Save</button>
-                        <a class="btn btn-mini" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=*&amp;branch=[% current_branch %]"><i class="fa fa-undo"></i> Unset</a>
+                        <a class="btn btn-mini delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=*&amp;branch=[% current_branch %]" id="unset"><i class="fa fa-undo"></i> Unset</a>
                     </td>
                 </tr>
             </table>
@@ -531,7 +537,7 @@ for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde
                         </td>
 
                         <td class="actions">
-                            <a class="btn btn-mini" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=[% branch_cat_rule_loo.categorycode %]&amp;branch=[% current_branch %]"><i class="fa fa-trash"></i> Delete</a>
+                            <a class="btn btn-mini delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=[% branch_cat_rule_loo.categorycode %]&amp;branch=[% current_branch %]"><i class="fa fa-trash"></i> Delete</a>
                         </td>
                     </tr>
                 [% END %]
@@ -620,7 +626,7 @@ for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde
                             [% END %]
                         </td>
                         <td class="actions">
-                            <a class="btn btn-mini" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-item&amp;itemtype=[% branch_item_rule_loo.itemtype %]&amp;branch=[% current_branch %]"><i class="fa fa-trash"></i> Delete</a>
+                            <a class="btn btn-mini delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-item&amp;itemtype=[% branch_item_rule_loo.itemtype %]&amp;branch=[% current_branch %]"><i class="fa fa-trash"></i> Delete</a>
                         </td>
                     </tr>
                 [% END %]