Implement email share link
This commit is contained in:
parent
aeee19b3f2
commit
62ff78787a
|
@ -36,7 +36,7 @@
|
||||||
'</div>' +
|
'</div>' +
|
||||||
' {{/if}}' +
|
' {{/if}}' +
|
||||||
' {{#if mailPublicNotificationEnabled}}' +
|
' {{#if mailPublicNotificationEnabled}}' +
|
||||||
'<form id="emailPrivateLink">' +
|
'<form id="emailPrivateLink" class="emailPrivateLinkForm">' +
|
||||||
' <input id="email" value="" placeholder="{{mailPrivatePlaceholder}}" type="text" />' +
|
' <input id="email" value="" placeholder="{{mailPrivatePlaceholder}}" type="text" />' +
|
||||||
' <input id="emailButton" type="submit" value="{{mailButtonText}}" />' +
|
' <input id="emailButton" type="submit" value="{{mailButtonText}}" />' +
|
||||||
'</form>' +
|
'</form>' +
|
||||||
|
@ -69,6 +69,10 @@
|
||||||
/** @type {boolean} **/
|
/** @type {boolean} **/
|
||||||
showLink: true,
|
showLink: true,
|
||||||
|
|
||||||
|
events: {
|
||||||
|
'submit .emailPrivateLinkForm': '_onEmailPrivateLink'
|
||||||
|
},
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
var view = this;
|
var view = this;
|
||||||
|
|
||||||
|
@ -160,6 +164,28 @@
|
||||||
this.model.saveLinkShare();
|
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() {
|
render: function() {
|
||||||
var linkShareTemplate = this.template();
|
var linkShareTemplate = this.template();
|
||||||
|
|
||||||
|
@ -222,6 +248,8 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.delegateEvents();
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -476,7 +476,7 @@
|
||||||
var itemType = this.get('itemType');
|
var itemType = this.get('itemType');
|
||||||
var itemSource = this.get('itemSource');
|
var itemSource = this.get('itemSource');
|
||||||
|
|
||||||
$.post(
|
return $.post(
|
||||||
OC.generateUrl('core/ajax/share.php'),
|
OC.generateUrl('core/ajax/share.php'),
|
||||||
{
|
{
|
||||||
action: state ? 'informRecipients' : 'informRecipientsDisabled',
|
action: state ? 'informRecipients' : 'informRecipientsDisabled',
|
||||||
|
@ -487,12 +487,41 @@
|
||||||
},
|
},
|
||||||
function(result) {
|
function(result) {
|
||||||
if (result.status !== 'success') {
|
if (result.status !== 'success') {
|
||||||
|
// FIXME: a model should not show dialogs
|
||||||
OC.dialogs.alert(t('core', result.data.message), t('core', 'Warning'));
|
OC.dialogs.alert(t('core', result.data.message), t('core', 'Warning'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue