From b5253c40a5666bc86f0faed3ccf565b3f99dd58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Mon, 23 Dec 2019 12:04:53 +0100 Subject: [PATCH] Re-open popover on link password save failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- core/js/sharedialoglinkshareview.js | 17 +++++++++++++---- core/js/tests/specs/sharedialoglinkshareview.js | 12 +++++++++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js index 30c3362d3e36d..51f9e9a7b27f2 100644 --- a/core/js/sharedialoglinkshareview.js +++ b/core/js/sharedialoglinkshareview.js @@ -346,6 +346,7 @@ }, onPasswordEntered: function(event) { + var self = this; var $element = $(event.target); var $li = $element.closest('li[data-share-id]'); var shareId = $li.data('share-id'); @@ -387,6 +388,11 @@ $loading.removeClass('inlineblock').addClass('hidden'); }, error: function(model, msg) { + // force open the menu + if (event) { + self.onToggleMenu(event) + } + // Add visual feedback to both the input and the submit button $input.parent().find('input').addClass('error'); @@ -667,8 +673,8 @@ } } - this.$el.on('beforeHide', function() { - this.onMenuhide() + this.$el.on('beforeHide', function(e) { + this.onMenuhide(e) }.bind(this)); this.$el.html(linkShareTemplate({ @@ -709,13 +715,16 @@ } }, - onMenuhide: function() { + onMenuhide: function(event) { if (this.hasPasswordChanged) { var shareId = this.hasPasswordChanged var target = this.$el.find('li[data-share-id=' + shareId + '] #linkPassText-' + shareId); console.debug('Force saving password for share number ', shareId) - this.onPasswordEntered({ target: target }) + // replace target by last opened menu + this.onPasswordEntered(_.extend(event, { target: target })) } + // force close all opened tooltips + this.$el.find('[data-original-title]').tooltip('hide') }, /** diff --git a/core/js/tests/specs/sharedialoglinkshareview.js b/core/js/tests/specs/sharedialoglinkshareview.js index 39bf256d33409..479a239a94993 100644 --- a/core/js/tests/specs/sharedialoglinkshareview.js +++ b/core/js/tests/specs/sharedialoglinkshareview.js @@ -202,14 +202,18 @@ describe('OC.Share.ShareDialogLinkShareView', function () { }); it('shows the working icon when called', function () { - view.onPasswordEntered({target: view.$el.find('.linkPassText')}); + view.onPasswordEntered(jQuery.Event('click', { + target: view.$el.find('.linkPassText') + })); expect($workingIcon.hasClass('hidden')).toBeFalsy(); expect(shareModel.saveLinkShare.withArgs({ password: 'myPassword', cid: 123 }).calledOnce).toBeTruthy(); }); it('hides the working icon when saving the password succeeds', function () { - view.onPasswordEntered({target: view.$el.find('.linkPassText')}); + view.onPasswordEntered(jQuery.Event('click', { + target: view.$el.find('.linkPassText') + })); expect($workingIcon.hasClass('hidden')).toBeFalsy(); expect(shareModel.saveLinkShare.withArgs({ password: 'myPassword', cid: 123 }).calledOnce).toBeTruthy(); @@ -220,7 +224,9 @@ describe('OC.Share.ShareDialogLinkShareView', function () { }); it('hides the working icon when saving the password fails', function () { - view.onPasswordEntered({target: view.$el.find('.linkPassText')}); + view.onPasswordEntered(jQuery.Event('click', { + target: view.$el.find('.linkPassText') + })); expect($workingIcon.hasClass('hidden')).toBeFalsy(); expect(shareModel.saveLinkShare.withArgs({ password: 'myPassword', cid: 123 }).calledOnce).toBeTruthy();