Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1C182200BD5 for ; Wed, 23 Nov 2016 16:49:40 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 1AA3C160AEC; Wed, 23 Nov 2016 15:49:40 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 381B4160B21 for ; Wed, 23 Nov 2016 16:49:39 +0100 (CET) Received: (qmail 71338 invoked by uid 500); 23 Nov 2016 15:49:38 -0000 Mailing-List: contact commits-help@airavata.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airavata.apache.org Delivered-To: mailing list commits@airavata.apache.org Received: (qmail 71121 invoked by uid 99); 23 Nov 2016 15:49:38 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Nov 2016 15:49:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 05CAFF0DBF; Wed, 23 Nov 2016 15:49:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: scnakandala@apache.org To: commits@airavata.apache.org Date: Wed, 23 Nov 2016 15:49:43 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [07/11] airavata-php-gateway git commit: AIRAVATA-2228 Fix bug when sharing update fails archived-at: Wed, 23 Nov 2016 15:49:40 -0000 AIRAVATA-2228 Fix bug when sharing update fails A bug occurs when share_settings is updated in share.js but the sharing update actually fails server side. The fix is to update a copy of share_settings (new_share_settings) and then only update share_settings when the server side update completes successfully. Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/4c01c628 Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/4c01c628 Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/4c01c628 Branch: refs/heads/develop Commit: 4c01c6288d0d52d48c68c4d2941daf17627c467b Parents: 83e215b Author: Marcus Christie Authored: Tue Nov 22 17:48:54 2016 -0500 Committer: Marcus Christie Committed: Tue Nov 22 17:48:54 2016 -0500 ---------------------------------------------------------------------- public/js/sharing/share.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4c01c628/public/js/sharing/share.js ---------------------------------------------------------------------- diff --git a/public/js/sharing/share.js b/public/js/sharing/share.js index a25b2b9..e87598a 100755 --- a/public/js/sharing/share.js +++ b/public/js/sharing/share.js @@ -205,13 +205,15 @@ $(function() { // Save the sharing permissions of each selected user $('body').on('click', '#share-box-button', function(e) { - var data, resource_id, $share_list, $update_list; + var data, resource_id, $share_list, $update_list, new_share_settings; e.stopPropagation(); e.preventDefault(); $('#share-box-error-message').empty(); data = $("#share-box").data(); $share_list = $("#share-box-share").children(); $update_list = $('.sharing-to-update'); + // Clone current share settings + new_share_settings = JSON.parse(JSON.stringify(share_settings)); // TODO: is this used any longer? I don't see where resource_id gets // set and updateUserPrivileges doesn't seem to be defined if (data.hasOwnProperty('resource_id')) { @@ -228,17 +230,17 @@ $(function() { if (data.hasOwnProperty('currentaccess')) { newaccess = data.currentaccess; } - share_settings[data.username] = newaccess; + new_share_settings[data.username] = newaccess; }); if ($(this).data().hasOwnProperty('ajaxUpdateUrl')) { - ajaxUpdateSharing($(this).data().ajaxUpdateUrl, share_settings, function(){ - updateSharingAndCloseModal(share_settings); + ajaxUpdateSharing($(this).data().ajaxUpdateUrl, new_share_settings, function(){ + updateSharingAndCloseModal(new_share_settings); }); } else { - updateSharingAndCloseModal(share_settings); + updateSharingAndCloseModal(new_share_settings); } } else { - updateSharingAndCloseModal(share_settings); + updateSharingAndCloseModal(new_share_settings); } } return false; @@ -260,6 +262,7 @@ $(function() { data.access = new_share_settings[data.username]; }); $('#share-settings').val(JSON.stringify(new_share_settings)); + share_settings = new_share_settings; $('#shared-users').removeClass('text-align-center'); } if ($share_list.length === 0) {