diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index 5af558d77ba7a..2981fb64c1106 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -371,6 +371,7 @@ }, false, context); $el.addClass('permanent'); + }, /** diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index c7169b3ce12ad..d339ae1dcb4e1 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -50,6 +50,8 @@ OCA.Sharing.PublicApp = { this.initialDir = $('#dir').val(); var token = $('#sharingToken').val(); + var hideDownload = $('#hideDownload').val(); + // file list mode ? if ($el.find('#filestable').length) { @@ -92,6 +94,9 @@ OCA.Sharing.PublicApp = { ] } ); + if (hideDownload === 'true') { + this.fileList._allowSelection = false; + } this.files = OCA.Files.Files; this.files.initialize(); // TODO: move to PublicFileList.initialize() once @@ -192,6 +197,27 @@ OCA.Sharing.PublicApp = { return OC.generateUrl('/s/' + token + '/download') + '?' + OC.buildQueryString(params); }; + this.fileList._createRow = function(fileData) { + var $tr = OCA.Files.FileList.prototype._createRow.apply(this, arguments); + if (hideDownload === 'true') { + this.fileActions.currentFile = $tr.find('td'); + var mime = this.fileActions.getCurrentMimeType(); + var type = this.fileActions.getCurrentType(); + var permissions = this.fileActions.getCurrentPermissions(); + var action = this.fileActions.getDefault(mime, type, permissions); + + // Remove the link. This means that files without a default action fail hard + $tr.find('a.name').attr('href', '#'); + + this.fileActions.actions.all = {}; + } + return $tr; + }; + + this.fileList.isSelectedDownloadable = function () { + return hideDownload !== 'true'; + }; + this.fileList.getUploadUrl = function(fileName, dir) { if (_.isUndefined(dir)) { dir = this.getCurrentDirectory(); @@ -270,6 +296,11 @@ OCA.Sharing.PublicApp = { e.preventDefault(); OC.redirect(FileList.getDownloadUrl()); }); + + if (hideDownload === 'true') { + this.fileList.$el.find('#headerSelection').remove(); + this.fileList.$el.find('.summary').find('td:first-child').remove(); + } } $(document).on('click', '#directLink', function () { diff --git a/core/js/share/sharedialoglinkshareview_popover_menu.handlebars b/core/js/share/sharedialoglinkshareview_popover_menu.handlebars index 3f47f62d68a62..9c715c7f4eeac 100644 --- a/core/js/share/sharedialoglinkshareview_popover_menu.handlebars +++ b/core/js/share/sharedialoglinkshareview_popover_menu.handlebars @@ -37,7 +37,6 @@ {{/if}} - {{#if showHideDownloadCheckbox}}
  • @@ -46,7 +45,6 @@
  • - {{/if}} {{#if showPasswordCheckBox}}
  • diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js index a28b05aa75a26..989c10c2c570b 100644 --- a/core/js/sharedialoglinkshareview.js +++ b/core/js/sharedialoglinkshareview.js @@ -868,7 +868,6 @@ var isTalkEnabled = oc_appswebroots['spreed'] !== undefined; var sendPasswordByTalk = share.sendPasswordByTalk; - var showHideDownloadCheckbox = !this.model.isFolder(); var hideDownload = share.hideDownload; var maxDate = null; @@ -905,7 +904,6 @@ shareNote: share.note, hasNote: share.note !== '', maxDate: maxDate, - showHideDownloadCheckbox: showHideDownloadCheckbox, hideDownload: hideDownload, isExpirationEnforced: isExpirationEnforced, } diff --git a/core/js/sharetemplates.js b/core/js/sharetemplates.js index d982b242c4877..049ee90aa6fa7 100644 --- a/core/js/sharetemplates.js +++ b/core/js/sharetemplates.js @@ -122,68 +122,56 @@ templates['sharedialoglinkshareview_popover_menu'] = template({"1":function(cont + alias4(((helper = (helper = helpers.publicEditingLabel || (depth0 != null ? depth0.publicEditingLabel : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"publicEditingLabel","hash":{},"data":data}) : helper))) + "\n \n
  • \n"; },"5":function(container,depth0,helpers,partials,data) { - var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; - - return "
  • \n \n \n \n \n \n
  • \n"; -},"6":function(container,depth0,helpers,partials,data) { return "checked=\"checked\""; -},"8":function(container,depth0,helpers,partials,data) { +},"7":function(container,depth0,helpers,partials,data) { var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; return "
  • \n \n \n \n \n
  • \n
  • \n \n \n \n \n \n
  • \n"; -},"9":function(container,depth0,helpers,partials,data) { +},"8":function(container,depth0,helpers,partials,data) { return "disabled=\"disabled\""; -},"11":function(container,depth0,helpers,partials,data) { +},"10":function(container,depth0,helpers,partials,data) { return "hidden"; -},"13":function(container,depth0,helpers,partials,data) { +},"12":function(container,depth0,helpers,partials,data) { var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; return "
  • \n \n \n \n \n \n
  • \n"; -},"15":function(container,depth0,helpers,partials,data) { +},"14":function(container,depth0,helpers,partials,data) { return "datepicker"; -},"17":function(container,depth0,helpers,partials,data) { +},"16":function(container,depth0,helpers,partials,data) { var helper; return container.escapeExpression(((helper = (helper = helpers.expireDate || (depth0 != null ? depth0.expireDate : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"expireDate","hash":{},"data":data}) : helper))); -},"19":function(container,depth0,helpers,partials,data) { +},"18":function(container,depth0,helpers,partials,data) { var helper; return container.escapeExpression(((helper = (helper = helpers.defaultExpireDate || (depth0 != null ? depth0.defaultExpireDate : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"defaultExpireDate","hash":{},"data":data}) : helper))); -},"21":function(container,depth0,helpers,partials,data) { +},"20":function(container,depth0,helpers,partials,data) { return "readonly"; -},"23":function(container,depth0,helpers,partials,data) { +},"22":function(container,depth0,helpers,partials,data) { var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; return "
  • \n \n \n
  • \n" + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.publicUpload : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.publicEditing : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.showHideDownloadCheckbox : depth0),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.showPasswordCheckBox : depth0),{"name":"if","hash":{},"fn":container.program(8, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.showPasswordByTalkCheckBox : depth0),{"name":"if","hash":{},"fn":container.program(13, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "
  • \n \n \n \n \n \n
  • \n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.showPasswordCheckBox : depth0),{"name":"if","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.showPasswordByTalkCheckBox : depth0),{"name":"if","hash":{},"fn":container.program(12, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "
  • \n \n \n \n \n
  • \n
  • \n \n \n
  • \n
  • \n \n \n \n " + alias4(((helper = (helper = helpers.addNoteLabel || (depth0 != null ? depth0.addNoteLabel : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"addNoteLabel","hash":{},"data":data}) : helper))) + "\n \n \n
  • \n
  • \n \n \n \n \n
  • \n" - + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.social : depth0),{"name":"each","hash":{},"fn":container.program(23, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.social : depth0),{"name":"each","hash":{},"fn":container.program(22, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "
  • \n " + alias4(((helper = (helper = helpers.unshareLinkLabel || (depth0 != null ? depth0.unshareLinkLabel : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"unshareLinkLabel","hash":{},"data":data}) : helper))) + "\n
  • \n
  • \n \n \n \n " diff --git a/core/js/tests/specs/sharedialoglinkshareview.js b/core/js/tests/specs/sharedialoglinkshareview.js index 0272b07297ea0..9e6c67dca14a5 100644 --- a/core/js/tests/specs/sharedialoglinkshareview.js +++ b/core/js/tests/specs/sharedialoglinkshareview.js @@ -114,7 +114,7 @@ describe('OC.Share.ShareDialogLinkShareView', function () { $hideDownloadCheckbox = view.$el.find('.hideDownloadCheckbox'); - expect($hideDownloadCheckbox.length).toBeFalsy(); + expect($hideDownloadCheckbox.length).toBeTruthy(); }); it('checkbox is checked when the setting is enabled', function () {