Make files drop more permanent
Implement the suggestions from #2207 Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
parent
3dbf30c220
commit
2e32ab945b
2 changed files with 65 additions and 59 deletions
|
@ -35,20 +35,23 @@
|
||||||
'{{{popoverMenu}}}' +
|
'{{{popoverMenu}}}' +
|
||||||
'{{/if}}' +
|
'{{/if}}' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
' {{#if publicUpload}}' +
|
'{{#if publicUpload}}' +
|
||||||
'<div id="allowPublicUploadWrapper">' +
|
'<div>' +
|
||||||
' <span class="icon-loading-small hidden"></span>' +
|
'<span class="icon-loading-small hidden"></span>' +
|
||||||
' <input type="checkbox" value="1" name="allowPublicUpload" id="sharingDialogAllowPublicUpload-{{cid}}" class="checkbox publicUploadCheckbox" {{{publicUploadChecked}}} />' +
|
'<input type="radio" name="publicUpload" value="{{publicUploadRValue}}" id="sharingDialogAllowPublicUpload-r-{{cid}}" class="publicUploadRadio" {{{publicUploadRChecked}}} />' +
|
||||||
'<label for="sharingDialogAllowPublicUpload-{{cid}}">{{publicUploadLabel}}</label>' +
|
'<label for="sharingDialogAllowPublicUpload-rw-{{cid}}">{{publicUploadRLabel}}</label>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
' {{#if hideFileList}}' +
|
'<div>' +
|
||||||
'<div id="hideFileListWrapper">' +
|
'<span class="icon-loading-small hidden"></span>' +
|
||||||
' <span class="icon-loading-small hidden"></span>' +
|
'<input type="radio" name="publicUpload" value="{{publicUploadRWValue}}" id="sharingDialogAllowPublicUpload-rw-{{cid}}" class="publicUploadRadio" {{{publicUploadRWChecked}}} />' +
|
||||||
' <input type="checkbox" value="1" name="hideFileList" id="sharingDialogHideFileList-{{cid}}" class="checkbox hideFileListCheckbox" {{{hideFileListChecked}}} />' +
|
'<label for="sharingDialogAllowPublicUpload-rw-{{cid}}">{{publicUploadRWLabel}}</label>' +
|
||||||
'<label for="sharingDialogHideFileList-{{cid}}">{{hideFileListLabel}}</label>' +
|
'</div>' +
|
||||||
'</div>' +
|
'<div>' +
|
||||||
' {{/if}}' +
|
'<span class="icon-loading-small hidden"></span>' +
|
||||||
' {{/if}}' +
|
'<input type="radio" name="publicUpload" value="{{publicUploadWValue}}" id="sharingDialogAllowPublicUpload-w-{{cid}}" class="publicUploadRadio" {{{publicUploadWChecked}}} />' +
|
||||||
|
'<label for="sharingDialogAllowPublicUpload-w-{{cid}}">{{publicUploadWLabel}}</label>' +
|
||||||
|
'</div>' +
|
||||||
|
'{{/if}}' +
|
||||||
' {{#if publicEditing}}' +
|
' {{#if publicEditing}}' +
|
||||||
'<div id="allowPublicEditingWrapper">' +
|
'<div id="allowPublicEditingWrapper">' +
|
||||||
' <span class="icon-loading-small hidden"></span>' +
|
' <span class="icon-loading-small hidden"></span>' +
|
||||||
|
@ -126,12 +129,11 @@
|
||||||
'keyup input.linkPassText': 'onPasswordKeyUp',
|
'keyup input.linkPassText': 'onPasswordKeyUp',
|
||||||
'click .linkCheckbox': 'onLinkCheckBoxChange',
|
'click .linkCheckbox': 'onLinkCheckBoxChange',
|
||||||
'click .linkText': 'onLinkTextClick',
|
'click .linkText': 'onLinkTextClick',
|
||||||
'change .publicUploadCheckbox': 'onAllowPublicUploadChange',
|
|
||||||
'change .publicEditingCheckbox': 'onAllowPublicEditingChange',
|
'change .publicEditingCheckbox': 'onAllowPublicEditingChange',
|
||||||
'change .hideFileListCheckbox': 'onHideFileListChange',
|
|
||||||
'click .showPasswordCheckbox': 'onShowPasswordClick',
|
'click .showPasswordCheckbox': 'onShowPasswordClick',
|
||||||
'click .icon-more': 'onToggleMenu',
|
'click .icon-more': 'onToggleMenu',
|
||||||
'click .pop-up': 'onPopUpClick'
|
'click .pop-up': 'onPopUpClick',
|
||||||
|
'change .publicUploadRadio': 'onPublicUploadChange'
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
|
@ -170,9 +172,8 @@
|
||||||
'onPasswordKeyUp',
|
'onPasswordKeyUp',
|
||||||
'onLinkTextClick',
|
'onLinkTextClick',
|
||||||
'onShowPasswordClick',
|
'onShowPasswordClick',
|
||||||
'onHideFileListChange',
|
'onAllowPublicEditingChange',
|
||||||
'onAllowPublicUploadChange',
|
'onPublicUploadChange'
|
||||||
'onAllowPublicEditingChange'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
var clipboard = new Clipboard('.clipboardButton');
|
var clipboard = new Clipboard('.clipboardButton');
|
||||||
|
@ -318,20 +319,6 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onAllowPublicUploadChange: function() {
|
|
||||||
var $checkbox = this.$('.publicUploadCheckbox');
|
|
||||||
$checkbox.siblings('.icon-loading-small').removeClass('hidden').addClass('inlineblock');
|
|
||||||
|
|
||||||
var permissions = OC.PERMISSION_READ;
|
|
||||||
if($checkbox.is(':checked')) {
|
|
||||||
permissions = OC.PERMISSION_UPDATE | OC.PERMISSION_CREATE | OC.PERMISSION_READ | OC.PERMISSION_DELETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.model.saveLinkShare({
|
|
||||||
permissions: permissions
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
onAllowPublicEditingChange: function() {
|
onAllowPublicEditingChange: function() {
|
||||||
var $checkbox = this.$('.publicEditingCheckbox');
|
var $checkbox = this.$('.publicEditingCheckbox');
|
||||||
$checkbox.siblings('.icon-loading-small').removeClass('hidden').addClass('inlineblock');
|
$checkbox.siblings('.icon-loading-small').removeClass('hidden').addClass('inlineblock');
|
||||||
|
@ -346,15 +333,9 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onHideFileListChange: function () {
|
|
||||||
var $checkbox = this.$('.hideFileListCheckbox');
|
|
||||||
$checkbox.siblings('.icon-loading-small').removeClass('hidden').addClass('inlineblock');
|
|
||||||
|
|
||||||
var permissions = OC.PERMISSION_UPDATE | OC.PERMISSION_CREATE | OC.PERMISSION_READ | OC.PERMISSION_DELETE;
|
|
||||||
if ($checkbox.is(':checked')) {
|
|
||||||
permissions = OC.PERMISSION_CREATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
onPublicUploadChange: function(e) {
|
||||||
|
var permissions = e.currentTarget.value;
|
||||||
this.model.saveLinkShare({
|
this.model.saveLinkShare({
|
||||||
permissions: permissions
|
permissions: permissions
|
||||||
});
|
});
|
||||||
|
@ -382,9 +363,20 @@
|
||||||
&& this.model.createPermissionPossible()
|
&& this.model.createPermissionPossible()
|
||||||
&& this.configModel.isPublicUploadEnabled();
|
&& this.configModel.isPublicUploadEnabled();
|
||||||
|
|
||||||
var publicUploadChecked = '';
|
var publicUploadRWChecked = '';
|
||||||
if(this.model.isPublicUploadAllowed()) {
|
var publicUploadRChecked = '';
|
||||||
publicUploadChecked = 'checked="checked"';
|
var publicUploadWChecked = '';
|
||||||
|
|
||||||
|
switch (this.model.linkSharePermissions()) {
|
||||||
|
case OC.PERMISSION_READ:
|
||||||
|
publicUploadRChecked = 'checked';
|
||||||
|
break;
|
||||||
|
case OC.PERMISSION_CREATE:
|
||||||
|
publicUploadWChecked = 'checked';
|
||||||
|
break;
|
||||||
|
case OC.PERMISSION_UPDATE | OC.PERMISSION_CREATE | OC.PERMISSION_READ | OC.PERMISSION_DELETE:
|
||||||
|
publicUploadRWChecked = 'checked';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var publicEditingChecked = '';
|
var publicEditingChecked = '';
|
||||||
|
@ -392,14 +384,6 @@
|
||||||
publicEditingChecked = 'checked="checked"';
|
publicEditingChecked = 'checked="checked"';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var hideFileList = publicUploadChecked;
|
|
||||||
|
|
||||||
var hideFileListChecked = '';
|
|
||||||
if(this.model.isHideFileListSet()) {
|
|
||||||
hideFileListChecked = 'checked="checked"';
|
|
||||||
}
|
|
||||||
|
|
||||||
var isLinkShare = this.model.get('linkShare').isLinkShare;
|
var isLinkShare = this.model.get('linkShare').isLinkShare;
|
||||||
var isPasswordSet = !!this.model.get('linkShare').password;
|
var isPasswordSet = !!this.model.get('linkShare').password;
|
||||||
var showPasswordCheckBox = isLinkShare
|
var showPasswordCheckBox = isLinkShare
|
||||||
|
@ -437,7 +421,6 @@
|
||||||
this.$el.html(linkShareTemplate({
|
this.$el.html(linkShareTemplate({
|
||||||
cid: this.cid,
|
cid: this.cid,
|
||||||
shareAllowed: true,
|
shareAllowed: true,
|
||||||
hideFileList: hideFileList,
|
|
||||||
isLinkShare: isLinkShare,
|
isLinkShare: isLinkShare,
|
||||||
shareLinkURL: this.model.get('linkShare').link,
|
shareLinkURL: this.model.get('linkShare').link,
|
||||||
linkShareLabel: t('core', 'Share link'),
|
linkShareLabel: t('core', 'Share link'),
|
||||||
|
@ -449,17 +432,22 @@
|
||||||
isPasswordSet: isPasswordSet,
|
isPasswordSet: isPasswordSet,
|
||||||
showPasswordCheckBox: showPasswordCheckBox,
|
showPasswordCheckBox: showPasswordCheckBox,
|
||||||
publicUpload: publicUpload && isLinkShare,
|
publicUpload: publicUpload && isLinkShare,
|
||||||
publicUploadChecked: publicUploadChecked,
|
|
||||||
hideFileListChecked: hideFileListChecked,
|
|
||||||
publicUploadLabel: t('core', 'Allow upload and editing'),
|
|
||||||
publicEditing: publicEditable,
|
publicEditing: publicEditable,
|
||||||
publicEditingChecked: publicEditingChecked,
|
publicEditingChecked: publicEditingChecked,
|
||||||
publicEditingLabel: t('core', 'Allow editing'),
|
publicEditingLabel: t('core', 'Allow editing'),
|
||||||
hideFileListLabel: 'Secure drop (' + t('core', 'upload only') + ')',
|
|
||||||
mailPrivatePlaceholder: t('core', 'Email link to person'),
|
mailPrivatePlaceholder: t('core', 'Email link to person'),
|
||||||
mailButtonText: t('core', 'Send'),
|
mailButtonText: t('core', 'Send'),
|
||||||
singleAction: OC.Share.Social.Collection.size() == 0,
|
singleAction: OC.Share.Social.Collection.size() == 0,
|
||||||
popoverMenu: popover
|
popoverMenu: popover,
|
||||||
|
publicUploadRWLabel: t('core', 'Allow upload and editing'),
|
||||||
|
publicUploadRLabel: t('core', 'Read only'),
|
||||||
|
publicUploadWLabel: t('core', 'Secure drop (upload only)'),
|
||||||
|
publicUploadRWValue: OC.PERMISSION_UPDATE | OC.PERMISSION_CREATE | OC.PERMISSION_READ | OC.PERMISSION_DELETE,
|
||||||
|
publicUploadRValue: OC.PERMISSION_READ,
|
||||||
|
publicUploadWValue: OC.PERMISSION_CREATE,
|
||||||
|
publicUploadRWChecked: publicUploadRWChecked,
|
||||||
|
publicUploadRChecked: publicUploadRChecked,
|
||||||
|
publicUploadWChecked: publicUploadWChecked
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (OC.Share.Social.Collection.size() == 0) {
|
if (OC.Share.Social.Collection.size() == 0) {
|
||||||
|
|
|
@ -486,6 +486,13 @@
|
||||||
return date2;
|
return date2;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {int}
|
||||||
|
*/
|
||||||
|
getPermissions: function() {
|
||||||
|
return this.get('permissions');
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
|
@ -568,6 +575,17 @@
|
||||||
|| this.hasDeletePermission(shareIndex);
|
|| this.hasDeletePermission(shareIndex);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {int}
|
||||||
|
*/
|
||||||
|
linkSharePermissions: function() {
|
||||||
|
if (!this.hasLinkShare()) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
return this.get('linkShare').permissions;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_getUrl: function(base, params) {
|
_getUrl: function(base, params) {
|
||||||
params = _.extend({format: 'json'}, params || {});
|
params = _.extend({format: 'json'}, params || {});
|
||||||
return OC.linkToOCS('apps/files_sharing/api/v1', 2) + base + '?' + OC.buildQueryString(params);
|
return OC.linkToOCS('apps/files_sharing/api/v1', 2) + base + '?' + OC.buildQueryString(params);
|
||||||
|
|
Loading…
Reference in a new issue