diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2016-06-07 12:28:02 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2016-06-09 15:15:17 +0200 |
commit | bb54ab0db8bfa1ea62bfa2404cb084a9a68d6e20 (patch) | |
tree | 8127443d4c554ebcd1401ce8227408038f8717e2 /core | |
parent | fc3ad7d5f7acb018329b22d5120c03cd07feecd6 (diff) | |
download | nextcloud-server-bb54ab0db8bfa1ea62bfa2404cb084a9a68d6e20.tar.gz nextcloud-server-bb54ab0db8bfa1ea62bfa2404cb084a9a68d6e20.zip |
add hide file list option
Diffstat (limited to 'core')
-rw-r--r-- | core/js/sharedialoglinkshareview.js | 45 | ||||
-rw-r--r-- | core/js/shareitemmodel.js | 20 |
2 files changed, 60 insertions, 5 deletions
diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js index 817c3408e7e..6ac71aedc95 100644 --- a/core/js/sharedialoglinkshareview.js +++ b/core/js/sharedialoglinkshareview.js @@ -30,7 +30,14 @@ ' <input type="checkbox" value="1" name="allowPublicUpload" id="sharingDialogAllowPublicUpload-{{cid}}" class="checkbox publicUploadCheckbox" {{{publicUploadChecked}}} />' + '<label for="sharingDialogAllowPublicUpload-{{cid}}">{{publicUploadLabel}}</label>' + '</div>' + - ' {{/if}}' + + '{{#if hideFileList}}' + + '<div id="hideFileListWrapper">' + + ' <span class="icon-loading-small hidden"></span>' + + ' <input type="checkbox" value="1" name="hideFileList" id="sharingDialogHideFileList-{{cid}}" class="checkbox hideFileListCheckbox" {{{hideFileListChecked}}} />' + + '<label for="sharingDialogHideFileList-{{cid}}">{{hideFileListLabel}}</label>' + + '</div>' + + '{{/if}}' + + ' {{/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>' + @@ -74,7 +81,8 @@ 'keyup input.linkPassText': 'onPasswordKeyUp', 'click .linkCheckbox': 'onLinkCheckBoxChange', 'click .linkText': 'onLinkTextClick', - 'change .publicUploadCheckbox': 'onAllowPublicUploadChange', + 'change .publicUploadCheckbox': 'onAllowPublicUploadChange', + 'change .hideFileListCheckbox': 'onHideFileListChange', 'click .showPasswordCheckbox': 'onShowPasswordClick' }, @@ -93,6 +101,10 @@ view.render(); }); + this.model.on('change:hideFileListStatus', function() { + view.render(); + }); + this.model.on('change:linkShare', function() { view.render(); }); @@ -110,6 +122,7 @@ 'onPasswordKeyUp', 'onLinkTextClick', 'onShowPasswordClick', + 'onHideFileListChange', 'onAllowPublicUploadChange' ); }, @@ -208,7 +221,21 @@ this.model.saveLinkShare({ permissions: permissions }); - }, + }, + + 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; + if ($checkbox.is(':checked')) { + permissions = OC.PERMISSION_UPDATE | OC.PERMISSION_CREATE; + } + + this.model.saveLinkShare({ + permissions: permissions + }); + }, render: function() { var linkShareTemplate = this.template(); @@ -237,6 +264,13 @@ publicUploadChecked = 'checked="checked"'; } + var hideFileList = publicUploadChecked; + + var hideFileListChecked = ''; + if(this.model.isHideFileListSet()) { + hideFileListChecked = 'checked="checked"'; + } + var isLinkShare = this.model.get('linkShare').isLinkShare; var isPasswordSet = !!this.model.get('linkShare').password; var showPasswordCheckBox = isLinkShare @@ -246,6 +280,7 @@ this.$el.html(linkShareTemplate({ cid: this.cid, shareAllowed: true, + hideFileList: hideFileList, isLinkShare: isLinkShare, shareLinkURL: this.model.get('linkShare').link, linkShareLabel: t('core', 'Share link'), @@ -257,7 +292,9 @@ showPasswordCheckBox: showPasswordCheckBox, publicUpload: publicUpload && isLinkShare, publicUploadChecked: publicUploadChecked, - publicUploadLabel: t('core', 'Allow editing'), + hideFileListChecked: hideFileListChecked, + publicUploadLabel: t('core', 'Allow editing'), + hideFileListLabel: t('core', 'Hide file listing'), mailPublicNotificationEnabled: isLinkShare && this.configModel.isMailPublicNotificationEnabled(), mailPrivatePlaceholder: t('core', 'Email link to person'), mailButtonText: t('core', 'Send') diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index 3ced66a1a78..56ed3f0039b 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -275,6 +275,13 @@ /** * @returns {boolean} */ + isHideFileListSet: function() { + return this.get('hideFileListStatus'); + }, + + /** + * @returns {boolean} + */ isFolder: function() { return this.get('itemType') === 'folder'; }, @@ -685,6 +692,16 @@ }); } + var hideFileListStatus = false; + if(!_.isUndefined(data.shares)) { + $.each(data.shares, function (key, value) { + if (value.share_type === OC.Share.SHARE_TYPE_LINK) { + hideFileListStatus = (value.permissions & OC.PERMISSION_READ) ? false : true; + return true; + } + }); + } + /** @type {OC.Share.Types.ShareInfo[]} **/ var shares = _.map(data.shares, function(share) { // properly parse some values because sometimes the server @@ -757,7 +774,8 @@ shares: shares, linkShare: linkShare, permissions: permissions, - allowPublicUploadStatus: allowPublicUploadStatus + allowPublicUploadStatus: allowPublicUploadStatus, + hideFileListStatus: hideFileListStatus }; }, |