[Rt-commit] rt branch, 4.4/selfservice-delete-attachment, created. rt-4.4.1-344-gbde1cb9

Brian Duggan brian at bestpractical.com
Fri May 19 10:52:22 EDT 2017


The branch, 4.4/selfservice-delete-attachment has been created
        at  bde1cb91af5ebdfb14dea7693eeb315127d50706 (commit)

- Log -----------------------------------------------------------------
commit bde1cb91af5ebdfb14dea7693eeb315127d50706
Author: Brian C. Duggan <brian at bestpractical.com>
Date:   Thu May 18 15:11:10 2017 -0400

    Add SelfService/Helpers/Upload/Delete
    
    SelfService's attachments dropzone responded correctly to a user
    clicking on the button to delete an attachment by removing the
    attachment from the dropzone. But RT's JavaScript function to then
    delete the attachment from the transaction failed because the path to
    /Helpers/Upload/Delete always loaded the version under /. This showed
    SelfService users that RT had deleted their attachment when the
    resulting transaction would still have the attachment.
    
    This change follows the pattern of /SelfService/Helpers/Upload/Add and
    copies /Helpers/Upload/Delete to the
    /SelfService/Helpers/Upload/Delete. It also adjusts that paths to
    /Helpers/Upload/Delete in RT's attachment deletion JavaScript
    functions to use WepHomePath instead of WePath.
    
    Fixes: I#32663

diff --git a/share/html/SelfService/Helpers/Upload/Delete b/share/html/SelfService/Helpers/Upload/Delete
new file mode 100644
index 0000000..918acca
--- /dev/null
+++ b/share/html/SelfService/Helpers/Upload/Delete
@@ -0,0 +1,58 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC
+%#                                          <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<%args>
+$Name => ''
+$Token => ''
+</%args>
+<%init>
+delete $session{'Attachments'}{ $Token }{ $Name };
+$session{'Attachments'} = $session{'Attachments'};
+$r->content_type('application/json; charset=utf-8');
+$m->out( JSON({status => 'success'}) );
+$m->abort;
+</%init>
diff --git a/share/html/Ticket/Elements/AddAttachments b/share/html/Ticket/Elements/AddAttachments
index 1531aa2..42e9659 100644
--- a/share/html/Ticket/Elements/AddAttachments
+++ b/share/html/Ticket/Elements/AddAttachments
@@ -132,7 +132,7 @@ jQuery( function() {
         }
     });
     attachDropzone.on('removedfile', function(file) {
-        jQuery.post('<% RT->Config->Get('WebPath') %>/Helpers/Upload/Delete', { Name: file.name, Token: jQuery('#attach-dropzone').closest('form').find('input[name=Token]').val() }, 'json');
+        jQuery.post( RT.Config.WebHomePath + '/Helpers/Upload/Delete', { Name: file.name, Token: jQuery('#attach-dropzone').closest('form').find('input[name=Token]').val() }, 'json');
     });
     attachDropzone.on('dragenter', function() {
         jQuery('#attach-dropzone').addClass('scaled');
diff --git a/share/static/js/util.js b/share/static/js/util.js
index eda0127..d5bf845 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -552,7 +552,7 @@ jQuery(function() {
         var parent = jQuery(this).closest('div');
         var name = jQuery(this).attr('data-name');
         var token = jQuery(this).closest('form').find('input[name=Token]').val();
-        jQuery.post('/Helpers/Upload/Delete', { Name: name, Token: token }, function(data) {
+        jQuery.post( RT.Config.WebHomePath + '/Helpers/Upload/Delete', { Name: name, Token: token }, function(data) {
             if ( data.status == 'success' ) {
                 parent.remove();
             }

-----------------------------------------------------------------------


More information about the rt-commit mailing list