diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-09-14 18:24:58 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-09-16 07:23:29 +0200 |
commit | 62ff78787a0f033ca27a14051affa0be3c9393b2 (patch) | |
tree | 6a13c95e66214ff5a2ad495217b3c60c812fa5d3 /core/js | |
parent | aeee19b3f24eb60252ba55b89be745027ed39faf (diff) | |
download | nextcloud-server-62ff78787a0f033ca27a14051affa0be3c9393b2.tar.gz nextcloud-server-62ff78787a0f033ca27a14051affa0be3c9393b2.zip |
Implement email share link
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/sharedialoglinkshareview.js | 30 | ||||
-rw-r--r-- | core/js/shareitemmodel.js | 31 |
2 files changed, 59 insertions, 2 deletions
diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js index cadec3071d3..599ffd3c43f 100644 --- a/core/js/sharedialoglinkshareview.js +++ b/core/js/sharedialoglinkshareview.js @@ -36,7 +36,7 @@ '</div>' + ' {{/if}}' + ' {{#if mailPublicNotificationEnabled}}' + - '<form id="emailPrivateLink">' + + '<form id="emailPrivateLink" class="emailPrivateLinkForm">' + ' <input id="email" value="" placeholder="{{mailPrivatePlaceholder}}" type="text" />' + ' <input id="emailButton" type="submit" value="{{mailButtonText}}" />' + '</form>' + @@ -69,6 +69,10 @@ /** @type {boolean} **/ showLink: true, + events: { + 'submit .emailPrivateLinkForm': '_onEmailPrivateLink' + }, + initialize: function(options) { var view = this; @@ -160,6 +164,28 @@ this.model.saveLinkShare(); }, + _onEmailPrivateLink: function(event) { + event.preventDefault(); + + var $emailField = this.$el.find('#email'); + var $emailButton = this.$el.find('#emailButton'); + var email = this.$el.find('#email').val(); + if (email !== '') { + $emailField.prop('disabled', true); + $emailButton.prop('disabled', true); + $emailField.val(t('core', 'Sending ...')); + this.model.sendEmailPrivateLink(email).then(function() { + $emailField.css('font-weight', 'bold').val(t('core','Email sent')); + setTimeout(function() { + $emailField.css('font-weight', 'normal').val(''); + $emailField.prop('disabled', false); + $emailButton.prop('disabled', false); + }, 2000); + }); + } + return false; + }, + render: function() { var linkShareTemplate = this.template(); @@ -222,6 +248,8 @@ } }); + this.delegateEvents(); + return this; }, diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index 595670faaef..e0d44586613 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -476,7 +476,7 @@ var itemType = this.get('itemType'); var itemSource = this.get('itemSource'); - $.post( + return $.post( OC.generateUrl('core/ajax/share.php'), { action: state ? 'informRecipients' : 'informRecipientsDisabled', @@ -487,6 +487,7 @@ }, function(result) { if (result.status !== 'success') { + // FIXME: a model should not show dialogs OC.dialogs.alert(t('core', result.data.message), t('core', 'Warning')); } } @@ -494,6 +495,34 @@ }, /** + * Send the link share information by email + * + * @param {string} recipientEmail recipient email address + */ + sendEmailPrivateLink: function(recipientEmail) { + var itemType = this.get('itemType'); + var itemSource = this.get('itemSource'); + var linkShare = this.get('linkShare'); + + return $.post( + OC.generateUrl('core/ajax/share.php'), { + action: 'email', + toaddress: recipientEmail, + link: linkShare.link, + itemType: itemType, + itemSource: itemSource, + file: this.fileInfoModel.get('name'), + expiration: linkShare.expiration || '' + }, + function(result) { + if (!result || result.status !== 'success') { + // FIXME: a model should not show dialogs + OC.dialogs.alert(result.data.message, t('core', 'Error while sending notification')); + } + }); + }, + + /** * @returns {boolean} */ sharePermissionPossible: function() { |