show link share
This commit is contained in:
parent
5dc2c35ce5
commit
ce1b0c650e
|
@ -45,7 +45,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.model) {
|
if (this.model) {
|
||||||
console.log(this.model);
|
|
||||||
var owner = this.model.get('shareOwner');
|
var owner = this.model.get('shareOwner');
|
||||||
if (owner === OC.currentUser) {
|
if (owner === OC.currentUser) {
|
||||||
owner = null;
|
owner = null;
|
||||||
|
@ -59,8 +58,11 @@
|
||||||
itemSource: this.model.get('id'),
|
itemSource: this.model.get('id'),
|
||||||
possiblePermissions: this.model.get('sharePermissions')
|
possiblePermissions: this.model.get('sharePermissions')
|
||||||
};
|
};
|
||||||
var shareModel = new OC.Share.ShareItemModel(attributes, {configModel: configModel});
|
|
||||||
var configModel = new OC.Share.ShareConfigModel();
|
var configModel = new OC.Share.ShareConfigModel();
|
||||||
|
var shareModel = new OC.Share.ShareItemModel(attributes, {
|
||||||
|
configModel: configModel,
|
||||||
|
fileInfoModel: this.model
|
||||||
|
});
|
||||||
this._dialog = new OC.Share.ShareDialogView({
|
this._dialog = new OC.Share.ShareDialogView({
|
||||||
configModel: configModel,
|
configModel: configModel,
|
||||||
model: shareModel
|
model: shareModel
|
||||||
|
|
|
@ -126,10 +126,6 @@ a.unshare {
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#linkText,#linkPass,#expiration {
|
|
||||||
display:none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#link #showPassword img {
|
#link #showPassword img {
|
||||||
padding-left:5px;
|
padding-left:5px;
|
||||||
width:12px;
|
width:12px;
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
|
|
||||||
var ShareConfigModel = OC.Backbone.Model.extend({
|
var ShareConfigModel = OC.Backbone.Model.extend({
|
||||||
defaults: {
|
defaults: {
|
||||||
publicUploadEnabled: false
|
publicUploadEnabled: false,
|
||||||
|
enforcePasswordForPublicLink: oc_appconfig.core.enforcePasswordForPublicLink
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,11 +14,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var TEMPLATE =
|
var TEMPLATE =
|
||||||
|
// well that could go to linkShareView…
|
||||||
|
'{{#if isLinkShare}}' +
|
||||||
'<input type="checkbox" name="expirationCheckbox" id="expirationCheckbox" value="1" />' +
|
'<input type="checkbox" name="expirationCheckbox" id="expirationCheckbox" value="1" />' +
|
||||||
'<label for="expirationCheckbox">{{setExpirationLabel}}</label>' +
|
'<label for="expirationCheckbox">{{setExpirationLabel}}</label>' +
|
||||||
'<label for="expirationDate" class="hidden-visually">{{expirationLabel}}</label>' +
|
'<label for="expirationDate" class="hidden-visually">{{expirationLabel}}</label>' +
|
||||||
'<input id="expirationDate" type="text" placeholder="{{expirationDatePlaceholder}}" class="hidden" />' +
|
'<input id="expirationDate" type="text" placeholder="{{expirationDatePlaceholder}}" class="hidden" />' +
|
||||||
'<em id="defaultExpireMessage">{{defaultExpireMessage}}</em>'
|
'<em id="defaultExpireMessage">{{defaultExpireMessage}}</em>' +
|
||||||
|
'{{/if}}'
|
||||||
;
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,6 +47,8 @@
|
||||||
/** @type {boolean} **/
|
/** @type {boolean} **/
|
||||||
showLink: true,
|
showLink: true,
|
||||||
|
|
||||||
|
className: 'hidden',
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
if(!_.isUndefined(options.configModel)) {
|
if(!_.isUndefined(options.configModel)) {
|
||||||
this.configModel = options.configModel;
|
this.configModel = options.configModel;
|
||||||
|
@ -68,7 +73,8 @@
|
||||||
setExpirationLabel: t('core', 'Set expiration date'),
|
setExpirationLabel: t('core', 'Set expiration date'),
|
||||||
expirationLabel: t('core', 'Expiration'),
|
expirationLabel: t('core', 'Expiration'),
|
||||||
expirationDatePlaceholder: t('core', 'Expiration date'),
|
expirationDatePlaceholder: t('core', 'Expiration date'),
|
||||||
defaultExpireMessage: defaultExpireMessage
|
defaultExpireMessage: defaultExpireMessage,
|
||||||
|
isLinkShare: this.model.get('linkShare').isLinkShare
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -16,16 +16,20 @@
|
||||||
var TEMPLATE =
|
var TEMPLATE =
|
||||||
'{{#if shareAllowed}}' +
|
'{{#if shareAllowed}}' +
|
||||||
'<span class="icon-loading-small hidden"></span>' +
|
'<span class="icon-loading-small hidden"></span>' +
|
||||||
'<input type="checkbox" name="linkCheckbox" id="linkCheckbox" value="1" /><label for="linkCheckbox">{{linkShareLabel}}</label>' +
|
'<input type="checkbox" name="linkCheckbox" id="linkCheckbox" value="1" {{#if isLinkShare}}checked="checked"{{/if}} /><label for="linkCheckbox">{{linkShareLabel}}</label>' +
|
||||||
'<br />' +
|
'<br />' +
|
||||||
'<label for="linkText" class="hidden-visually">{{urlLabel}}</label>' +
|
'<label for="linkText" class="hidden-visually">{{urlLabel}}</label>' +
|
||||||
'<input id="linkText" type="text" readonly="readonly" />' +
|
'<input id="linkText" {{#unless isLinkShare}}class="hidden"{{/unless}} type="text" readonly="readonly" value="{{shareLinkURL}}" />' +
|
||||||
'<input type="checkbox" name="showPassword" id="showPassword" value="1" class="hidden" /><label for="showPassword" class="hidden-visually">{{enablePasswordLabel}}</label>' +
|
' {{#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">' +
|
||||||
' <label for="linkPassText" class="hidden-visually">{{passwordLabel}}</label>' +
|
' <label for="linkPassText" class="hidden-visually">{{passwordLabel}}</label>' +
|
||||||
' <input id="linkPassText" type="password" placeholder="passwordPlaceholder" />' +
|
' <input id="linkPassText" type="password" placeholder="{{passwordPlaceholder}}" />' +
|
||||||
' <span class="icon-loading-small hidden"></span>' +
|
' <span class="icon-loading-small hidden"></span>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
|
' {{/if}}' +
|
||||||
' {{#if publicUpload}}' +
|
' {{#if publicUpload}}' +
|
||||||
'<div id="allowPublicUploadWrapper" class="hidden">' +
|
'<div id="allowPublicUploadWrapper" class="hidden">' +
|
||||||
' <span class="icon-loading-small hidden"></span>' +
|
' <span class="icon-loading-small hidden"></span>' +
|
||||||
|
@ -35,8 +39,8 @@
|
||||||
' {{/if}}' +
|
' {{/if}}' +
|
||||||
' {{#if mailPublicNotificationEnabled}}' +
|
' {{#if mailPublicNotificationEnabled}}' +
|
||||||
'<form id="emailPrivateLink">' +
|
'<form id="emailPrivateLink">' +
|
||||||
' <input id="email" class="hidden" value="" placeholder="{{mailPrivatePlaceholder}}" type="text" />' +
|
' <input id="email" value="" placeholder="{{mailPrivatePlaceholder}}" type="text" />' +
|
||||||
' <input id="emailButton" class="hidden" type="submit" value="{{mailButtonText}}" />' +
|
' <input id="emailButton" type="submit" value="{{mailButtonText}}" />' +
|
||||||
'</form>' +
|
'</form>' +
|
||||||
' {{/if}}' +
|
' {{/if}}' +
|
||||||
'{{else}}' +
|
'{{else}}' +
|
||||||
|
@ -113,17 +117,27 @@
|
||||||
publicUploadChecked = 'checked="checked"';
|
publicUploadChecked = 'checked="checked"';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isLinkShare = this.model.get('linkShare').isLinkShare;
|
||||||
|
var isPasswordSet = !!this.model.get('linkShare').password;
|
||||||
|
var showPasswordCheckBox = isLinkShare
|
||||||
|
&& ( !this.configModel.get('enforcePasswordForPublicLink')
|
||||||
|
|| !this.model.get('linkShare').password);
|
||||||
|
|
||||||
this.$el.html(linkShareTemplate({
|
this.$el.html(linkShareTemplate({
|
||||||
shareAllowed: true,
|
shareAllowed: true,
|
||||||
|
isLinkShare: isLinkShare,
|
||||||
|
shareLinkURL: this.model.get('linkShare').link,
|
||||||
linkShareLabel: t('core', 'Share link'),
|
linkShareLabel: t('core', 'Share link'),
|
||||||
urlLabel: t('core', 'Link'),
|
urlLabel: t('core', 'Link'),
|
||||||
enablePasswordLabel: t('core', 'Password protect'),
|
enablePasswordLabel: t('core', 'Password protect'),
|
||||||
passwordLabel: t('core', 'Password'),
|
passwordLabel: t('core', 'Password'),
|
||||||
passwordPlaceholder: t('core', 'Choose a password for the public link'),
|
passwordPlaceholder: isPasswordSet ? '**********' : t('core', 'Choose a password for the public link'),
|
||||||
publicUpload: publicUpload,
|
isPasswordSet: isPasswordSet,
|
||||||
|
showPasswordCheckBox: showPasswordCheckBox,
|
||||||
|
publicUpload: publicUpload && isLinkShare,
|
||||||
publicUploadChecked: publicUploadChecked,
|
publicUploadChecked: publicUploadChecked,
|
||||||
publicUploadLabel: t('core', 'Allow editing'),
|
publicUploadLabel: t('core', 'Allow editing'),
|
||||||
mailPublicNotificationEnabled: this.configModel.isMailPublicNotificationEnabled(),
|
mailPublicNotificationEnabled: isLinkShare && this.configModel.isMailPublicNotificationEnabled(),
|
||||||
mailPrivatePlaceholder: t('core', 'Email link to person'),
|
mailPrivatePlaceholder: t('core', 'Email link to person'),
|
||||||
mailButtonText: t('core', 'Send')
|
mailButtonText: t('core', 'Send')
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -14,6 +14,14 @@
|
||||||
OC.Share.Types = {};
|
OC.Share.Types = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} OC.Share.Types.LinkShareInfo
|
||||||
|
* @property {bool} isLinkShare
|
||||||
|
* @property {string} token
|
||||||
|
* @property {string|null} password
|
||||||
|
* @property {string} link
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {object} OC.Share.Types.Collection
|
* @typedef {object} OC.Share.Types.Collection
|
||||||
* @property {string} item_type
|
* @property {string} item_type
|
||||||
|
@ -49,6 +57,7 @@
|
||||||
* @typedef {object} OC.Share.Types.ShareItemInfo
|
* @typedef {object} OC.Share.Types.ShareItemInfo
|
||||||
* @property {OC.Share.Types.Reshare} reshare
|
* @property {OC.Share.Types.Reshare} reshare
|
||||||
* @property {OC.Share.Types.ShareInfo[]} shares
|
* @property {OC.Share.Types.ShareInfo[]} shares
|
||||||
|
* @property {OC.Share.Types.LinkShareInfo|undefined} linkShare
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,11 +73,16 @@
|
||||||
if(!_.isUndefined(options.configModel)) {
|
if(!_.isUndefined(options.configModel)) {
|
||||||
this.configModel = options.configModel;
|
this.configModel = options.configModel;
|
||||||
}
|
}
|
||||||
|
if(!_.isUndefined(options.fileInfoModel)) {
|
||||||
|
/** @type {OC.Files.FileInfo} **/
|
||||||
|
this.fileInfoModel = options.fileInfoModel;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
defaults: {
|
defaults: {
|
||||||
allowPublicUploadStatus: false,
|
allowPublicUploadStatus: false,
|
||||||
permissions: 0
|
permissions: 0,
|
||||||
|
linkShare: {}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -186,7 +200,6 @@
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
getReshareOwnerDisplayname: function() {
|
getReshareOwnerDisplayname: function() {
|
||||||
return 'foo';
|
|
||||||
return this.get('reshare').displayname_owner;
|
return this.get('reshare').displayname_owner;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -399,12 +412,52 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @type {OC.Share.Types.ShareInfo[]} **/
|
||||||
var shares = _.toArray(data.shares);
|
var shares = _.toArray(data.shares);
|
||||||
this.legacyFillCurrentShares(shares);
|
this.legacyFillCurrentShares(shares);
|
||||||
|
|
||||||
|
var linkShare = { isLinkShare: false };
|
||||||
|
// filter out the share by link
|
||||||
|
shares = _.reject(shares,
|
||||||
|
/**
|
||||||
|
* @param {OC.Share.Types.ShareInfo} share
|
||||||
|
*/
|
||||||
|
function(share) {
|
||||||
|
var isShareLink =
|
||||||
|
share.share_type === OC.Share.SHARE_TYPE_LINK
|
||||||
|
&& ( share.file_source === this.get('itemSource')
|
||||||
|
|| share.item_source === this.get('itemSource'));
|
||||||
|
|
||||||
|
if (isShareLink) {
|
||||||
|
var link = window.location.protocol + '//' + window.location.host;
|
||||||
|
if (!share.token) {
|
||||||
|
// pre-token link
|
||||||
|
var fullPath = this.fileInfoModel.get('path') + '/' +
|
||||||
|
this.fileInfoModel.get('name');
|
||||||
|
var location = '/' + OC.currentUser + '/files' + fullPath;
|
||||||
|
var type = this.fileInfoModel.isDirectory() ? 'folder' : 'file';
|
||||||
|
link += OC.linkTo('', 'public.php') + '?service=files&' +
|
||||||
|
type + '=' + encodeURIComponent(location);
|
||||||
|
} else {
|
||||||
|
link += OC.generateUrl('/s/') + share.token;
|
||||||
|
}
|
||||||
|
linkShare = {
|
||||||
|
isLinkShare: true,
|
||||||
|
token: share.token,
|
||||||
|
password: share.share_with,
|
||||||
|
link: link
|
||||||
|
};
|
||||||
|
|
||||||
|
return share;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
reshare: data.reshare,
|
reshare: data.reshare,
|
||||||
shares: shares,
|
shares: shares,
|
||||||
|
linkShare: linkShare,
|
||||||
permissions: permissions,
|
permissions: permissions,
|
||||||
allowPublicUploadStatus: allowPublicUploadStatus
|
allowPublicUploadStatus: allowPublicUploadStatus
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue