Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable9] remember email when setting expiration date #24149

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions core/js/core.json
Expand Up @@ -32,6 +32,7 @@
"sharedialogview.js",
"sharedialogexpirationview.js",
"sharedialoglinkshareview.js",
"sharedialogmailview.js",
"sharedialogresharerinfoview.js",
"sharedialogshareelistview.js",
"octemplate.js",
Expand Down
69 changes: 0 additions & 69 deletions core/js/sharedialoglinkshareview.js
Expand Up @@ -40,12 +40,6 @@
'<label for="sharingDialogAllowPublicUpload-{{cid}}">{{publicUploadLabel}}</label>' +
'</div>' +
' {{/if}}' +
' {{#if mailPublicNotificationEnabled}}' +
'<form id="emailPrivateLink" class="emailPrivateLinkForm">' +
' <input id="email" class="emailField" value="" placeholder="{{mailPrivatePlaceholder}}" type="text" />' +
' <input id="emailButton" class="emailButton" type="submit" value="{{mailButtonText}}" />' +
'</form>' +
' {{/if}}' +
'{{else}}' +
// FIXME: this doesn't belong in this view
'{{#if noSharingPlaceholder}}<input id="shareWith-{{cid}}" class="shareWithField" type="text" placeholder="{{noSharingPlaceholder}}" disabled="disabled"/>{{/if}}' +
Expand Down Expand Up @@ -76,7 +70,6 @@
showLink: true,

events: {
'submit .emailPrivateLinkForm': '_onEmailPrivateLink',
'focusout input.linkPassText': 'onPasswordEntered',
'keyup input.linkPassText': 'onPasswordKeyUp',
'click .linkCheckbox': 'onLinkCheckBoxChange',
Expand Down Expand Up @@ -112,7 +105,6 @@

_.bindAll(
this,
'_onEmailPrivateLink',
'onLinkCheckBoxChange',
'onPasswordEntered',
'onPasswordKeyUp',
Expand Down Expand Up @@ -218,34 +210,6 @@
});
},

_onEmailPrivateLink: function(event) {
event.preventDefault();

var $emailField = this.$el.find('.emailField');
var $emailButton = this.$el.find('.emailButton');
var email = $emailField.val();
if (email !== '') {
$emailField.prop('disabled', true);
$emailButton.prop('disabled', true);
$emailField.val(t('core', 'Sending ...'));
this.model.sendEmailPrivateLink(email).done(function() {
$emailField.css('font-weight', 'bold').val(t('core','Email sent'));
setTimeout(function() {
$emailField.val('');
$emailField.css('font-weight', 'normal');
$emailField.prop('disabled', false);
$emailButton.prop('disabled', false);
}, 2000);
}).fail(function() {
$emailField.val(email);
$emailField.css('font-weight', 'normal');
$emailField.prop('disabled', false);
$emailButton.prop('disabled', false);
});
}
return false;
},

render: function() {
var linkShareTemplate = this.template();
var resharingAllowed = this.model.sharePermissionPossible();
Expand Down Expand Up @@ -299,39 +263,6 @@
mailButtonText: t('core', 'Send')
}));

var $emailField = this.$el.find('.emailField');
if (isLinkShare && $emailField.length !== 0) {
$emailField.autocomplete({
minLength: 1,
source: function (search, response) {
$.get(
OC.generateUrl('core/ajax/share.php'), {
fetch: 'getShareWithEmail',
search: search.term
}, function(result) {
if (result.status == 'success' && result.data.length > 0) {
response(result.data);
}
});
},
select: function( event, item ) {
$emailField.val(item.item.email);
return false;
}
})
.data("ui-autocomplete")._renderItem = function( ul, item ) {
return $('<li>')
.append('<a>' + escapeHTML(item.displayname) + "<br>" + escapeHTML(item.email) + '</a>' )
.appendTo( ul );
};
}

// TODO drop with IE8 drop
if($('html').hasClass('ie8')) {
this.$el.find('#linkPassText').removeAttr('placeholder');
this.$el.find('#linkPassText').val('');
}

this.delegateEvents();

return this;
Expand Down
176 changes: 176 additions & 0 deletions core/js/sharedialogmailview.js
@@ -0,0 +1,176 @@
/*
* Copyright (c) 2016
*
* This file is licensed under the Affero General Public License version 3
* or later.
*
* See the COPYING-README file.
*
*/

(function() {
if (!OC.Share) {
OC.Share = {};
}

var TEMPLATE =
'{{#if shareAllowed}}' +
' {{#if mailPublicNotificationEnabled}}' +
'<form id="emailPrivateLink" class="emailPrivateLinkForm">' +
' <input id="email" class="emailField" value="{{email}}" placeholder="{{mailPrivatePlaceholder}}" type="text" />' +
' <input id="emailButton" class="emailButton" type="submit" value="{{mailButtonText}}" />' +
'</form>' +
' {{/if}}' +
'{{/if}}'
;

/**
* @class OCA.Share.ShareDialogMailView
* @member {OC.Share.ShareItemModel} model
* @member {jQuery} $el
* @memberof OCA.Sharing
* @classdesc
*
* Represents the GUI of the share dialogue
*
*/
var ShareDialogMailView = OC.Backbone.View.extend({
/** @type {string} **/
id: 'shareDialogMailView',

/** @type {OC.Share.ShareConfigModel} **/
configModel: undefined,

/** @type {Function} **/
_template: undefined,

/** @type {boolean} **/
showLink: true,

events: {
'submit .emailPrivateLinkForm': '_onEmailPrivateLink'
},

initialize: function(options) {
var view = this;

this.model.on('change:linkShare', function() {
view.render();
});

if(!_.isUndefined(options.configModel)) {
this.configModel = options.configModel;
} else {
throw 'missing OC.Share.ShareConfigModel';
}

_.bindAll(
this,
'_onEmailPrivateLink'
);
},

_onEmailPrivateLink: function(event) {
event.preventDefault();

var $emailField = this.$el.find('.emailField');
var $emailButton = this.$el.find('.emailButton');
var email = $emailField.val();
if (email !== '') {
$emailField.prop('disabled', true);
$emailButton.prop('disabled', true);
$emailField.val(t('core', 'Sending ...'));
this.model.sendEmailPrivateLink(email).done(function() {
$emailField.css('font-weight', 'bold').val(t('core','Email sent'));
setTimeout(function() {
$emailField.val('');
$emailField.css('font-weight', 'normal');
$emailField.prop('disabled', false);
$emailButton.prop('disabled', false);
}, 2000);
}).fail(function() {
$emailField.val(email);
$emailField.css('font-weight', 'normal');
$emailField.prop('disabled', false);
$emailButton.prop('disabled', false);
});
}
return false;
},

render: function() {
var linkShareTemplate = this.template();
var resharingAllowed = this.model.sharePermissionPossible();
var email = this.$el.find('.emailField').val();

if(!resharingAllowed
|| !this.showLink
|| !this.configModel.isShareWithLinkAllowed())
{
var templateData = {shareAllowed: false};
if (!resharingAllowed) {
// add message
templateData.noSharingPlaceholder = t('core', 'Resharing is not allowed');
}
this.$el.html(linkShareTemplate(templateData));
return this;
}

var isLinkShare = this.model.get('linkShare').isLinkShare;

this.$el.html(linkShareTemplate({
cid: this.cid,
shareAllowed: true,
mailPublicNotificationEnabled: isLinkShare && this.configModel.isMailPublicNotificationEnabled(),
mailPrivatePlaceholder: t('core', 'Email link to person'),
mailButtonText: t('core', 'Send link via email'),
email: email
}));

var $emailField = this.$el.find('.emailField');
if (isLinkShare && $emailField.length !== 0) {
$emailField.autocomplete({
minLength: 1,
source: function (search, response) {
$.get(
OC.generateUrl('core/ajax/share.php'), {
fetch: 'getShareWithEmail',
search: search.term
}, function(result) {
if (result.status == 'success' && result.data.length > 0) {
response(result.data);
}
});
},
select: function( event, item ) {
$emailField.val(item.item.email);
return false;
}
})
.data("ui-autocomplete")._renderItem = function( ul, item ) {
return $('<li>')
.append('<a>' + escapeHTML(item.displayname) + "<br>" + escapeHTML(item.email) + '</a>' )
.appendTo( ul );
};
}
this.delegateEvents();

return this;
},

/**
* @returns {Function} from Handlebars
* @private
*/
template: function () {
if (!this._template) {
this._template = Handlebars.compile(TEMPLATE);
}
return this._template;
}

});

OC.Share.ShareDialogMailView = ShareDialogMailView;

})();
10 changes: 9 additions & 1 deletion core/js/sharedialogview.js
Expand Up @@ -26,6 +26,7 @@
'<div class="shareeListView subView"></div>' +
'<div class="linkShareView subView"></div>' +
'<div class="expirationView subView"></div>' +
'<div class="mailView subView"></div>' +
'<div class="loading hidden" style="height: 50px"></div>';

var TEMPLATE_REMOTE_SHARE_INFO =
Expand Down Expand Up @@ -67,6 +68,9 @@
/** @type {object} **/
shareeListView: undefined,

/** @type {object} **/
mailView: undefined,

events: {
'input .shareWithField': 'onShareWithFieldChanged'
},
Expand Down Expand Up @@ -103,7 +107,8 @@
resharerInfoView: 'ShareDialogResharerInfoView',
linkShareView: 'ShareDialogLinkShareView',
expirationView: 'ShareDialogExpirationView',
shareeListView: 'ShareDialogShareeListView'
shareeListView: 'ShareDialogShareeListView',
mailView: 'ShareDialogMailView'
};

for(var name in subViews) {
Expand Down Expand Up @@ -360,6 +365,9 @@
this.shareeListView.$el = this.$el.find('.shareeListView');
this.shareeListView.render();

this.mailView.$el = this.$el.find('.mailView');
this.mailView.render();

this.$el.find('.hasTooltip').tooltip();

return this;
Expand Down
1 change: 1 addition & 0 deletions lib/private/share/share.php
Expand Up @@ -90,6 +90,7 @@ public static function registerBackend($itemType, $class, $collectionOf = null,
\OC_Util::addScript('core', 'shareitemmodel');
\OC_Util::addScript('core', 'sharedialogresharerinfoview');
\OC_Util::addScript('core', 'sharedialoglinkshareview');
\OC_Util::addScript('core', 'sharedialogmailview');
\OC_Util::addScript('core', 'sharedialogexpirationview');
\OC_Util::addScript('core', 'sharedialogshareelistview');
\OC_Util::addScript('core', 'sharedialogview');
Expand Down