share and unshare via link (not yet password). also some internal changes to reduce unnecessary rendering
This commit is contained in:
parent
4c702aa8fd
commit
f29b51682b
|
@ -956,80 +956,6 @@ $(document).ready(function() {
|
|||
permissions);
|
||||
});
|
||||
|
||||
$(document).on('change', '#dropdown #linkCheckbox', function() {
|
||||
var $dropDown = $('#dropdown');
|
||||
var itemType = $dropDown.data('item-type');
|
||||
var itemSource = $dropDown.data('item-source');
|
||||
var itemSourceName = $dropDown.data('item-source-name');
|
||||
var $loading = $dropDown.find('#link .icon-loading-small');
|
||||
var $button = $(this);
|
||||
|
||||
if (!$loading.hasClass('hidden')) {
|
||||
// already in progress
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.checked) {
|
||||
// Reset password placeholder
|
||||
$('#linkPassText').attr('placeholder', t('core', 'Choose a password for the public link'));
|
||||
// Reset link
|
||||
$('#linkText').val('');
|
||||
$('#showPassword').prop('checked', false);
|
||||
$('#linkPass').hide();
|
||||
$('#sharingDialogAllowPublicUpload').prop('checked', false);
|
||||
$('#expirationCheckbox').prop('checked', false);
|
||||
$('#expirationDate').hide();
|
||||
var expireDateString = '';
|
||||
// Create a link
|
||||
if (oc_appconfig.core.enforcePasswordForPublicLink === false) {
|
||||
expireDateString = OC.Share.getDefaultExpirationDate();
|
||||
$loading.removeClass('hidden');
|
||||
$button.addClass('hidden');
|
||||
$button.prop('disabled', true);
|
||||
|
||||
OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', OC.PERMISSION_READ, itemSourceName, expireDateString, function(data) {
|
||||
$loading.addClass('hidden');
|
||||
$button.removeClass('hidden');
|
||||
$button.prop('disabled', false);
|
||||
OC.Share.showLink(data.token, null, itemSource);
|
||||
$('#dropdown').trigger(new $.Event('sharesChanged', {shares: OC.Share.currentShares}));
|
||||
OC.Share.updateIcon(itemType, itemSource);
|
||||
});
|
||||
} else {
|
||||
$('#linkPass').slideToggle(OC.menuSpeed);
|
||||
// TODO drop with IE8 drop
|
||||
if($('html').hasClass('ie8')) {
|
||||
$('#linkPassText').attr('placeholder', null);
|
||||
$('#linkPassText').val('');
|
||||
}
|
||||
$('#linkPassText').focus();
|
||||
}
|
||||
if (expireDateString !== '') {
|
||||
OC.Share.showExpirationDate(expireDateString);
|
||||
}
|
||||
} else {
|
||||
// Delete private link
|
||||
OC.Share.hideLink();
|
||||
$('#expiration').slideUp(OC.menuSpeed);
|
||||
if ($('#linkText').val() !== '') {
|
||||
$loading.removeClass('hidden');
|
||||
$button.addClass('hidden');
|
||||
$button.prop('disabled', true);
|
||||
OC.Share.unshare(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', function() {
|
||||
$loading.addClass('hidden');
|
||||
$button.removeClass('hidden');
|
||||
$button.prop('disabled', false);
|
||||
OC.Share.itemShares[OC.Share.SHARE_TYPE_LINK] = false;
|
||||
$('#dropdown').trigger(new $.Event('sharesChanged', {shares: OC.Share.currentShares}));
|
||||
OC.Share.updateIcon(itemType, itemSource);
|
||||
if (typeof OC.Share.statuses[itemSource] === 'undefined') {
|
||||
$('#expiration').slideUp(OC.menuSpeed);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '#dropdown #linkText', function() {
|
||||
$(this).focus();
|
||||
$(this).select();
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
publicUploadEnabled: false,
|
||||
enforcePasswordForPublicLink: oc_appconfig.core.enforcePasswordForPublicLink,
|
||||
isDefaultExpireDateEnforced: oc_appconfig.core.defaultExpireDateEnforced === true,
|
||||
isDefaultExpireDateEnabled: oc_appconfig.core.defaultExpireDateEnabled === true,
|
||||
isRemoteShareAllowed: oc_appconfig.core.remoteShareAllowed,
|
||||
defaultExpireDate: oc_appconfig.core.defaultExpireDate,
|
||||
isResharingAllowed: oc_appconfig.core.resharingAllowed
|
||||
},
|
||||
|
@ -45,13 +47,6 @@
|
|||
return $('input:hidden[name=mailPublicNotificationEnabled]').val() === 'yes';
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isRemoteShareAllowed: function() {
|
||||
return oc_appconfig.core.remoteShareAllowed;
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
|
@ -64,6 +59,20 @@
|
|||
*/
|
||||
getFederatedShareDocLink: function() {
|
||||
return oc_appconfig.core.federatedCloudShareDoc;
|
||||
},
|
||||
|
||||
getDefaultExpirationDateString: function () {
|
||||
var expireDateString = '';
|
||||
if (this.get('isDefaultExpireDateEnabled')) {
|
||||
var date = new Date().getTime();
|
||||
var expireAfterMs = this.get('defaultExpireDate') * 24 * 60 * 60 * 1000;
|
||||
var expireDate = new Date(date + expireAfterMs);
|
||||
var month = expireDate.getMonth() + 1;
|
||||
var year = expireDate.getFullYear();
|
||||
var day = expireDate.getDate();
|
||||
expireDateString = year + "-" + month + '-' + day + ' 00:00:00';
|
||||
}
|
||||
return expireDateString;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
'<label for="expirationCheckbox">{{setExpirationLabel}}</label>' +
|
||||
' {{#if isExpirationSet}}' +
|
||||
'<label for="expirationDate" class="hidden-visually" value="{{expirationDate}}">{{expirationLabel}}</label>' +
|
||||
'<input id="expirationDate" class="datepicker" type="text" placeholder="{{expirationDatePlaceholder}}" />' +
|
||||
'<input id="expirationDate" class="datepicker" type="text" placeholder="{{expirationDatePlaceholder}}" value="{{expirationValue}}" />' +
|
||||
' {{/if}}' +
|
||||
' {{#if isExpirationEnforced}}' +
|
||||
// originally the expire message was shown when a default date was set, however it never had text
|
||||
|
@ -64,13 +64,28 @@
|
|||
} else {
|
||||
throw 'missing OC.Share.ShareConfigModel';
|
||||
}
|
||||
|
||||
var view = this;
|
||||
this.configModel.on('change:isDefaultExpireDateEnforced', function() {
|
||||
view.render();
|
||||
});
|
||||
|
||||
this.model.on('change:itemType', function() {
|
||||
view.render();
|
||||
});
|
||||
|
||||
this.model.on('change:linkShare', function() {
|
||||
view.render();
|
||||
});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var defaultExpireMessage = '';
|
||||
var defaultExpireDays = this.configModel.get('defaultExpireDate');
|
||||
var isExpirationEnforced = this.configModel.get('isDefaultExpireDateEnforced');
|
||||
|
||||
if( (this.model.isFolder() || this.model.isFile())
|
||||
&& this.configModel.get('isDefaultExpireDateEnforced')) {
|
||||
&& isExpirationEnforced) {
|
||||
defaultExpireMessage = t(
|
||||
'core',
|
||||
'The public link will expire no later than {days} days after it is created',
|
||||
|
@ -79,7 +94,6 @@
|
|||
}
|
||||
|
||||
var isExpirationSet = !!this.model.get('linkShare').expiration;
|
||||
var isExpirationEnforced = this.configModel.get('isDefaultExpireDateEnforced');
|
||||
|
||||
var expirationTemplate = this.template();
|
||||
this.$el.html(expirationTemplate({
|
||||
|
@ -120,6 +134,8 @@
|
|||
});
|
||||
}
|
||||
|
||||
this.$el.find('.datepicker').datepicker({dateFormat : 'dd-mm-yy'});
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
|
|
|
@ -23,13 +23,11 @@
|
|||
' {{#if showPasswordCheckBox}}' +
|
||||
'<input type="checkbox" name="showPassword" id="showPassword" {{#if isPasswordSet}}checked="checked"{{/if}} value="1" /><label for="showPassword">{{enablePasswordLabel}}</label>' +
|
||||
' {{/if}}' +
|
||||
' {{#if isPasswordSet}}' +
|
||||
'<div id="linkPass">' +
|
||||
'<div id="linkPass" {{#unless isPasswordSet}}class="hidden"{{/unless}}>' +
|
||||
' <label for="linkPassText" class="hidden-visually">{{passwordLabel}}</label>' +
|
||||
' <input id="linkPassText" type="password" placeholder="{{passwordPlaceholder}}" />' +
|
||||
' <span class="icon-loading-small hidden"></span>' +
|
||||
'</div>' +
|
||||
' {{/if}}' +
|
||||
' {{#if publicUpload}}' +
|
||||
'<div id="allowPublicUploadWrapper" class="hidden">' +
|
||||
' <span class="icon-loading-small hidden"></span>' +
|
||||
|
@ -86,11 +84,42 @@
|
|||
view.render();
|
||||
});
|
||||
|
||||
this.model.on('change:linkShare', function() {
|
||||
view.render();
|
||||
});
|
||||
|
||||
if(!_.isUndefined(options.configModel)) {
|
||||
this.configModel = options.configModel;
|
||||
} else {
|
||||
throw 'missing OC.Share.ShareConfigModel';
|
||||
}
|
||||
|
||||
_.bindAll(this, 'onLinkCheckBoxChange');
|
||||
},
|
||||
|
||||
onLinkCheckBoxChange: function() {
|
||||
var $checkBox = this.$el.find('#linkCheckbox');
|
||||
var $loading = $checkBox.siblings('.icon-loading-small');
|
||||
if(!$loading.hasClass('hidden')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if($checkBox.is(':checked')) {
|
||||
if(this.configModel.get('enforcePasswordForPublicLink') === false) {
|
||||
$loading.removeClass('hidden');
|
||||
this.model.addLinkShare();
|
||||
} else {
|
||||
this.$el.find('#linkPass').slideToggle(OC.menuSpeed);
|
||||
// TODO drop with IE8 drop
|
||||
if($('html').hasClass('ie8')) {
|
||||
this.$el.find('#linkPassText').attr('placeholder', null);
|
||||
this.$el.find('#linkPassText').val('');
|
||||
}
|
||||
this.$el.find('#linkPassText').focus();
|
||||
}
|
||||
} else {
|
||||
this.model.removeLinkShare();
|
||||
}
|
||||
},
|
||||
|
||||
render: function() {
|
||||
|
@ -142,6 +171,8 @@
|
|||
mailButtonText: t('core', 'Send')
|
||||
}));
|
||||
|
||||
this.$el.find('#linkCheckbox').change(this.onLinkCheckBoxChange);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
|
|
|
@ -96,6 +96,13 @@
|
|||
sharedByText: sharedByText
|
||||
}));
|
||||
|
||||
if(this.configModel.areAvatarsEnabled()) {
|
||||
this.$el.find('.avatar').each(function() {
|
||||
var $this = $(this);
|
||||
$this.avatar($this.data('username'), 32);
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
|
|
|
@ -201,6 +201,17 @@
|
|||
sharees: this.getShareeList()
|
||||
}));
|
||||
|
||||
if(this.configModel.areAvatarsEnabled()) {
|
||||
this.$el.find('.avatar').each(function() {
|
||||
var $this = $(this);
|
||||
$this.avatar($this.data('username'), 32);
|
||||
});
|
||||
this.$el.find('.avatar.imageplaceholderseed').each(function() {
|
||||
var $this = $(this);
|
||||
$this.imageplaceholder($this.data('seed'));
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
|
|
|
@ -68,9 +68,6 @@
|
|||
|
||||
initialize: function(options) {
|
||||
var view = this;
|
||||
this.model.on('change', function() {
|
||||
view.render();
|
||||
});
|
||||
|
||||
this.model.on('fetchError', function() {
|
||||
OC.Notification.showTemporary(t('core', 'Share details could not be loaded for this item.'));
|
||||
|
@ -82,6 +79,10 @@
|
|||
throw 'missing OC.Share.ShareConfigModel';
|
||||
}
|
||||
|
||||
this.configModel.on('change:isRemoteShareAllowed', function() {
|
||||
view.render();
|
||||
});
|
||||
|
||||
var subViewOptions = {
|
||||
model: this.model,
|
||||
configModel: this.configModel
|
||||
|
@ -188,17 +189,6 @@
|
|||
this.shareeListView.render();
|
||||
|
||||
this.$el.find('.hasTooltip').tooltip();
|
||||
if(this.configModel.areAvatarsEnabled()) {
|
||||
this.$el.find('.avatar').each(function() {
|
||||
var $this = $(this);
|
||||
$this.avatar($this.data('username'), 32);
|
||||
});
|
||||
this.$el.find('.avatar.imageplaceholderseed').each(function() {
|
||||
var $this = $(this);
|
||||
$this.imageplaceholder($this.data('seed'));
|
||||
});
|
||||
}
|
||||
this.$el.find('.datepicker').datepicker({dateFormat : 'dd-mm-yy'});
|
||||
|
||||
return this;
|
||||
},
|
||||
|
@ -216,7 +206,7 @@
|
|||
|
||||
_renderRemoteShareInfoPart: function() {
|
||||
var remoteShareInfo = '';
|
||||
if(this.configModel.isRemoteShareAllowed()) {
|
||||
if(this.configModel.get('isRemoteShareAllowed')) {
|
||||
var infoTemplate = this._getRemoteShareInfoTemplate();
|
||||
remoteShareInfo = infoTemplate({
|
||||
docLink: this.configModel.getFederatedShareDocLink(),
|
||||
|
@ -229,7 +219,7 @@
|
|||
|
||||
_renderSharePlaceholderPart: function () {
|
||||
var sharePlaceholder = t('core', 'Share with users or groups …');
|
||||
if (this.configModel.isRemoteShareAllowed()) {
|
||||
if (this.configModel.get('isRemoteShareAllowed')) {
|
||||
sharePlaceholder = t('core', 'Share with users, groups or remote users …');
|
||||
}
|
||||
return sharePlaceholder;
|
||||
|
|
|
@ -89,12 +89,33 @@
|
|||
linkShare: {}
|
||||
},
|
||||
|
||||
addLinkShare: function() {
|
||||
var model = this;
|
||||
var expiration = this.configModel.getDefaultExpirationDateString();
|
||||
var itemType = this.get('itemType');
|
||||
var itemSource = this.get('itemSource');
|
||||
OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', OC.PERMISSION_READ, this.fileInfoModel.get('name'), expiration, function(data) {
|
||||
model.fetch();
|
||||
//FIXME: updateIcon belongs to view
|
||||
OC.Share.updateIcon(itemType, itemSource);
|
||||
});
|
||||
},
|
||||
|
||||
removeLinkShare: function() {
|
||||
var model = this;
|
||||
var itemType = this.get('itemType');
|
||||
var itemSource = this.get('itemSource');
|
||||
|
||||
OC.Share.unshare(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', function() {
|
||||
model.fetch();
|
||||
//FIXME: updateIcon belongs to view
|
||||
OC.Share.updateIcon(itemType, itemSource);
|
||||
});
|
||||
},
|
||||
|
||||
addShare: function(event, selected, options) {
|
||||
event.preventDefault();
|
||||
|
||||
//console.warn(selected);
|
||||
//return false;
|
||||
|
||||
var shareType = selected.item.value.shareType;
|
||||
var shareWith = selected.item.value.shareWith;
|
||||
var fileName = this.fileInfoModel.get('name');
|
||||
|
@ -121,8 +142,10 @@
|
|||
}
|
||||
|
||||
var model = this;
|
||||
OC.Share.share(this.get('itemType'), this.get('itemSource'), shareType, shareWith, permissions, fileName, options.expiration, function() {
|
||||
model.fetch()
|
||||
var itemType = this.get('itemType');
|
||||
var itemSource = this.get('itemSource');
|
||||
OC.Share.share(itemType, itemSource, shareType, shareWith, permissions, fileName, options.expiration, function() {
|
||||
model.fetch();
|
||||
//FIXME: updateIcon belongs to view
|
||||
OC.Share.updateIcon(itemType, itemSource);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue