diff options
author | Björn Schießle <bjoern@schiessle.org> | 2017-01-25 15:35:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-25 15:35:57 +0100 |
commit | 5873a0a7d4e8fa442cc7796f133e39b6f998bbf1 (patch) | |
tree | 0af80910e8d3c3d527afdd9304a6f596fcebfcde /core | |
parent | f469b3e9587e9eae2cce924241f90baa1da30b31 (diff) | |
parent | 92d7dd4781bdf7c4134cd6fdbfd6f6915919545b (diff) | |
download | nextcloud-server-5873a0a7d4e8fa442cc7796f133e39b6f998bbf1.tar.gz nextcloud-server-5873a0a7d4e8fa442cc7796f133e39b6f998bbf1.zip |
Merge pull request #3231 from nextcloud/allow-editing-public-links
allow editing single files shared as public link
Diffstat (limited to 'core')
-rw-r--r-- | core/js/sharedialoglinkshareview.js | 39 | ||||
-rw-r--r-- | core/js/shareitemmodel.js | 16 |
2 files changed, 54 insertions, 1 deletions
diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js index cb553947de6..84a3d18942f 100644 --- a/core/js/sharedialoglinkshareview.js +++ b/core/js/sharedialoglinkshareview.js @@ -43,6 +43,13 @@ '</div>' + ' {{/if}}' + ' {{/if}}' + + ' {{#if publicEditing}}' + + '<div id="allowPublicEditingWrapper">' + + ' <span class="icon-loading-small hidden"></span>' + + ' <input type="checkbox" value="1" name="allowPublicEditing" id="sharingDialogAllowPublicEditing-{{cid}}" class="checkbox publicEditingCheckbox" {{{publicEditingChecked}}} />' + + '<label for="sharingDialogAllowPublicEditing-{{cid}}">{{publicEditingLabel}}</label>' + + '</div>' + + ' {{/if}}' + ' {{#if showPasswordCheckBox}}' + '<input type="checkbox" name="showPassword" id="showPassword-{{cid}}" class="checkbox showPasswordCheckbox" {{#if isPasswordSet}}checked="checked"{{/if}} value="1" />' + '<label for="showPassword-{{cid}}">{{enablePasswordLabel}}</label>' + @@ -87,6 +94,7 @@ 'click .linkCheckbox': 'onLinkCheckBoxChange', 'click .linkText': 'onLinkTextClick', 'change .publicUploadCheckbox': 'onAllowPublicUploadChange', + 'change .publicEditingCheckbox': 'onAllowPublicEditingChange', 'change .hideFileListCheckbox': 'onHideFileListChange', 'click .showPasswordCheckbox': 'onShowPasswordClick' }, @@ -128,7 +136,8 @@ 'onLinkTextClick', 'onShowPasswordClick', 'onHideFileListChange', - 'onAllowPublicUploadChange' + 'onAllowPublicUploadChange', + 'onAllowPublicEditingChange' ); var clipboard = new Clipboard('.clipboardButton'); @@ -266,6 +275,20 @@ }); }, + onAllowPublicEditingChange: function() { + var $checkbox = this.$('.publicEditingCheckbox'); + $checkbox.siblings('.icon-loading-small').removeClass('hidden').addClass('inlineblock'); + + var permissions = OC.PERMISSION_READ; + if($checkbox.is(':checked')) { + permissions = OC.PERMISSION_UPDATE | OC.PERMISSION_READ; + } + + this.model.saveLinkShare({ + permissions: permissions + }); + }, + onHideFileListChange: function () { var $checkbox = this.$('.hideFileListCheckbox'); $checkbox.siblings('.icon-loading-small').removeClass('hidden').addClass('inlineblock'); @@ -307,6 +330,12 @@ publicUploadChecked = 'checked="checked"'; } + var publicEditingChecked = ''; + if(this.model.isPublicEditingAllowed()) { + publicEditingChecked = 'checked="checked"'; + } + + var hideFileList = publicUploadChecked; var hideFileListChecked = ''; @@ -320,6 +349,11 @@ && ( !this.configModel.get('enforcePasswordForPublicLink') || !this.model.get('linkShare').password); + var publicEditable = + !this.model.isFolder() + && isLinkShare + && this.model.updatePermissionPossible(); + this.$el.html(linkShareTemplate({ cid: this.cid, shareAllowed: true, @@ -337,6 +371,9 @@ publicUploadChecked: publicUploadChecked, hideFileListChecked: hideFileListChecked, publicUploadLabel: t('core', 'Allow upload and editing'), + publicEditing: publicEditable, + publicEditingChecked: publicEditingChecked, + publicEditingLabel: t('core', 'Allow editing'), hideFileListLabel: t('core', 'File drop (upload only)'), mailPrivatePlaceholder: t('core', 'Email link to person'), mailButtonText: t('core', 'Send') diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index 9b10f067afc..ae4c07e3f4e 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -272,6 +272,10 @@ return this.get('allowPublicUploadStatus'); }, + isPublicEditingAllowed: function() { + return this.get('allowPublicEditingStatus'); + }, + /** * @returns {boolean} */ @@ -679,6 +683,17 @@ }); } + var allowPublicEditingStatus = true; + if(!_.isUndefined(data.shares)) { + $.each(data.shares, function (key, value) { + if (value.share_type === OC.Share.SHARE_TYPE_LINK) { + allowPublicEditingStatus = (value.permissions & OC.PERMISSION_UPDATE) ? true : false; + return true; + } + }); + } + + var hideFileListStatus = false; if(!_.isUndefined(data.shares)) { $.each(data.shares, function (key, value) { @@ -762,6 +777,7 @@ linkShare: linkShare, permissions: permissions, allowPublicUploadStatus: allowPublicUploadStatus, + allowPublicEditingStatus: allowPublicEditingStatus, hideFileListStatus: hideFileListStatus }; }, |