From a0f34df6ae07f3d4e825a7af6745102862d3e655 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Mon, 21 Sep 2015 12:39:45 +0300 Subject: [PATCH] Bug 14855: Resend notices in Notices tab with AJAX + REST Bug 12426 introduces a resend link to resend sent and failed messages. It uses POST method. Since Bug 14843 gives us REST API for notifications, we should enhance 12426 to use REST API via AJAX and only allow Staff members with permission "resend_message" to be able to see the link and use it. This patch changes the request into AJAX POST via the REST API for notifications. To test: -2. Make sure you have all the dependant patches -1. Enable system preference EnhancedMessagingPreferences -0. Make sure you do not have permission messages -> resend_message To test: 1. Have/create some pending sms messages into message_queue 2. Go to Patrons -> Notices 3. Resend one of the message and observe the page will reload 4. Apply patch 5. Reload Patrons -> Notices and observe there is no Resend link 6. Add yourself the permission messages -> resend_message 7. Reload Patrons -> Notices and observe there is Resend link 8. Resend a message and observe page will not reload 9. Observe that the message status has changed to pending --- .../prog/en/modules/members/notices.tt | 24 +++- members/notices.pl | 29 ++-- t/db_dependent/ResendMessage.t | 155 +++++++++++++++++++++ 3 files changed, 190 insertions(+), 18 deletions(-) create mode 100644 t/db_dependent/ResendMessage.t diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt index 0208374..198f76d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt @@ -21,6 +21,21 @@ }); }); + function resendMessage(id, status_element){ + var resend = $.ajax({ + type: "POST", + url: "/api/v1/messages/"+id+"/resend", + data: { }, + statusCode: { + 404: function(){ + alert("Message not found."); + }, + 204: function(){ + $(status_element).text("pending"); + } + } + }); + } //]]>