Skip to content

Commit

Permalink
Force save share link password if click outside
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Nov 7, 2019
1 parent a8405bf commit 41f83a0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/js/dist/share_backend.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/js/dist/share_backend.js.map

Large diffs are not rendered by default.

26 changes: 25 additions & 1 deletion core/js/sharedialoglinkshareview.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
/** @type {boolean} **/
showPending: false,

/** @type {boolean} **/
hasPasswordChanged: false,

/** @type {string} **/
password: '',

Expand Down Expand Up @@ -323,6 +326,7 @@
password: '',
cid: shareId
});
this.hasPasswordChanged = false
} else {
if (!OC.Util.isIE()) {
$li.find('.linkPassText').focus();
Expand All @@ -331,8 +335,13 @@
},

onPasswordKeyUp: function(event) {
if(event.keyCode === 13) {
var $element = $(event.target);
var $li = $element.closest('li[data-share-id]');
var shareId = $li.data('share-id');
if (event.keyCode === 13) {
this.onPasswordEntered(event);
} else {
this.hasPasswordChanged = shareId
}
},

Expand Down Expand Up @@ -367,6 +376,8 @@
$loading
.removeClass('hidden')
.addClass('inlineblock');

this.hasPasswordChanged = false

this.model.saveLinkShare({
password: password,
Expand Down Expand Up @@ -656,6 +667,10 @@
}
}

this.$el.on('beforeHide', function() {
this.onMenuhide()
}.bind(this));

this.$el.html(linkShareTemplate({
linkShares: linkShares,
shareAllowed: true,
Expand Down Expand Up @@ -694,6 +709,15 @@
}
},

onMenuhide: function() {
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 })
}
},

/**
* @returns {Function} from Handlebars
* @private
Expand Down

0 comments on commit 41f83a0

Please sign in to comment.