From edd163a6113664921a2fda730037dcf68bfe08ae Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 31 Jul 2015 00:07:41 +0200 Subject: refactor share dialog for multi-purpose use (dropdown, sidebar) and better maintainability --- core/js/shareitemmodel.js | 113 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 core/js/shareitemmodel.js (limited to 'core/js/shareitemmodel.js') diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js new file mode 100644 index 00000000000..1db49536db5 --- /dev/null +++ b/core/js/shareitemmodel.js @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2015 + * + * This file is licensed under the Affero General Public License version 3 + * or later. + * + * See the COPYING-README file. + * + */ + +(function() { + if(!OC.Share) { + OC.Share = {}; + OC.Share.Types = {}; + } + + /** + * @typedef {object} OC.Share.Types.Reshare + * @property {string} uid_owner + * @property {number} share_type + * @property {string} share_with + * @property {string} displayname_owner + * @property {number} permissions + */ + + /** + * @typedef {object} OC.Share.Types.ShareInfo + * @property {number} share_type + * @property {number} permissions + * @property {number} file_source optional + * @property {number} item_source + * @property {string} token + * @property {string} share_with + * @property {string} share_with_displayname + * @property {string} share_mail_send + * @property {bool} collection //TODO: verify + * @property {Date} expiration optional? + * @property {number} stime optional? + */ + + /** + * @typedef {object} OC.Share.Types.ShareItemInfo + * @property {OC.Share.Types.Reshare} reshare + * @property {OC.Share.Types.ShareInfo[]} shares + */ + + /** + * @class OCA.Share.ShareItemModel + * @classdesc + * + * Represents the GUI of the share dialogue + * + */ + var ShareItemModel = function(itemType, itemSource) { + this.initialize(itemType, itemSource); + }; + + /** + * @memberof OCA.Sharing + */ + ShareItemModel.prototype = { + /** @var {string} **/ + _itemType: null, + /** @var {mixed} **/ //TODO: what type? + _itemSource: null, + + /** @var {OC.Share.Types.Reshare} **/ + _reshare: null, + + /** @var {OC.Share.Types.ShareInfo[]} **/ + _shares: null, + + initialize: function(itemType, itemSource) { + this._itemType = itemType; + this._itemSource = itemSource; + this._retrieveData(); + }, + + hasReshare: function() { + return _.isObject(this._reshare) && !_.isUndefined(this._reshare.uid_owner); + }, + + getReshareOwner: function() { + return this._reshare.uid_owner; + }, + + getReshareOwnerDisplayname: function() { + return this._reshare.displayname_owner; + }, + + getReshareWith: function() { + return this._reshare.share_with; + }, + + getReshareType: function() { + return this._reshare.share_type; + }, + + _retrieveData: function() { + /** var {OC.Share.Types.ShareItemInfo} **/ + var data = OC.Share.loadItem(this._itemType, this._itemSource); + if(data === false) { + console.warn('no data was returned'); + return; + } + this._reshare = data.reshare; + this._shares = data.shares; + + } + }; + + OC.Share.ShareItemModel = ShareItemModel; +})(); -- cgit v1.2.3 From 1651b8212cf67e2ca59cf890cefe6097fbfa6a8a Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 10 Aug 2015 22:23:52 +0200 Subject: started to port the Model to Backbone`s --- core/js/share.js | 3 ++- core/js/shareitemmodel.js | 43 +++++++++++++++++-------------------------- 2 files changed, 19 insertions(+), 27 deletions(-) (limited to 'core/js/shareitemmodel.js') diff --git a/core/js/share.js b/core/js/share.js index 9aba894f676..59467427eb3 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -377,7 +377,8 @@ OC.Share = _.extend(OC.Share, { }); }, showDropDown:function(itemType, itemSource, appendTo, link, possiblePermissions, filename) { - var itemModel = new OC.Share.ShareItemModel(itemType, itemSource); + var attributes = {itemType: itemType, itemSource: itemSource}; + var itemModel = new OC.Share.ShareItemModel(attributes); var dialogView = new OC.Share.ShareDialogView({ id: 'dropdown', model: itemModel, diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index 1db49536db5..2914b281ee1 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -55,59 +55,50 @@ this.initialize(itemType, itemSource); }; + // FIXME: migration is to Backbone.Model still WIP, only pushing for the night. + /** * @memberof OCA.Sharing */ - ShareItemModel.prototype = { - /** @var {string} **/ - _itemType: null, - /** @var {mixed} **/ //TODO: what type? - _itemSource: null, - - /** @var {OC.Share.Types.Reshare} **/ - _reshare: null, - - /** @var {OC.Share.Types.ShareInfo[]} **/ - _shares: null, - - initialize: function(itemType, itemSource) { - this._itemType = itemType; - this._itemSource = itemSource; - this._retrieveData(); + var ShareItemModel = OC.Backbone.Model.extend({ + initialize: function() { + this._retrieveData(); // TODO I need to get my head around fetch() respectively sync() and url(). Left for later, it's late. }, hasReshare: function() { - return _.isObject(this._reshare) && !_.isUndefined(this._reshare.uid_owner); + return _.isObject(this.get('reshare')) && !_.isUndefined(this.get('reshare').uid_owner); }, getReshareOwner: function() { - return this._reshare.uid_owner; + return this.get('reshare').uid_owner; }, getReshareOwnerDisplayname: function() { - return this._reshare.displayname_owner; + return this.get('reshare').displayname_owner; }, getReshareWith: function() { - return this._reshare.share_with; + return this.get('reshare').share_with; }, getReshareType: function() { - return this._reshare.share_type; + return this.get('reshare').share_type; }, _retrieveData: function() { /** var {OC.Share.Types.ShareItemInfo} **/ - var data = OC.Share.loadItem(this._itemType, this._itemSource); + var data = OC.Share.loadItem(this.get('itemType'), this.get('itemSource')); if(data === false) { console.warn('no data was returned'); return; } - this._reshare = data.reshare; - this._shares = data.shares; - + var attributes = { + reshare: data.reshare, + shares: data.shares + }; + this.set(attributes); } - }; + }); OC.Share.ShareItemModel = ShareItemModel; })(); -- cgit v1.2.3 From 7971bc1ac0a52ed5171a3a663b6e18dcda93bbc3 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 11 Aug 2015 14:10:25 +0200 Subject: model now extends Backbone's model and isadjusted --- core/js/shareitemmodel.js | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) (limited to 'core/js/shareitemmodel.js') diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index 2914b281ee1..74e696e7200 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -50,53 +50,67 @@ * * Represents the GUI of the share dialogue * - */ - var ShareItemModel = function(itemType, itemSource) { - this.initialize(itemType, itemSource); - }; - - // FIXME: migration is to Backbone.Model still WIP, only pushing for the night. - - /** - * @memberof OCA.Sharing + * // FIXME: use OC Share API once #17143 is done */ var ShareItemModel = OC.Backbone.Model.extend({ initialize: function() { - this._retrieveData(); // TODO I need to get my head around fetch() respectively sync() and url(). Left for later, it's late. + this.fetch(); }, + /** + * whether this item has reshare information + * @returns {boolean} + */ hasReshare: function() { return _.isObject(this.get('reshare')) && !_.isUndefined(this.get('reshare').uid_owner); }, + /** + * @returns {string} + */ getReshareOwner: function() { return this.get('reshare').uid_owner; }, + /** + * @returns {string} + */ getReshareOwnerDisplayname: function() { return this.get('reshare').displayname_owner; }, + /** + * @returns {string} + */ getReshareWith: function() { return this.get('reshare').share_with; }, + /** + * @returns {number} + */ getReshareType: function() { return this.get('reshare').share_type; }, - _retrieveData: function() { + fetch: function() { /** var {OC.Share.Types.ShareItemInfo} **/ var data = OC.Share.loadItem(this.get('itemType'), this.get('itemSource')); + var attributes = this.parse(data); + this.set(attributes); + console.warn(this.attributes); + }, + + parse: function(data) { if(data === false) { console.warn('no data was returned'); - return; + return {}; } var attributes = { reshare: data.reshare, shares: data.shares }; - this.set(attributes); + return attributes; } }); -- cgit v1.2.3 From 97b5fe0b1e7ece1c402f9226f13a6e9d711055cf Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 11 Aug 2015 22:36:28 +0200 Subject: switch to async item loading, take care stuff is updated subsequently --- core/js/sharedialogview.js | 12 ++++++++++++ core/js/shareitemmodel.js | 18 +++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) (limited to 'core/js/shareitemmodel.js') diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index 38b98a218aa..3c12bedca86 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -76,10 +76,22 @@ /** @type {string} **/ tagName: 'div', + initialize: function() { + var view = this; + this.model.on('change', function() { + view.render(); + }); + + this.model.on('fetchError', function() { + OC.Notification.showTemporary(t('core', 'Share details could not be loaded for this item.')); + }); + }, + render: function() { var baseTemplate = this._getTemplate('base', TEMPLATE_BASE); this.$el.html(baseTemplate({ + shareLabel: t('core', 'Share'), resharerInfo: this._renderResharerInfo(), sharePlaceholder: this._renderSharePlaceholderPart(), diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index 74e696e7200..fe7aed46509 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -65,6 +65,14 @@ return _.isObject(this.get('reshare')) && !_.isUndefined(this.get('reshare').uid_owner); }, + /** + * whether this item has reshare information + * @returns {boolean} + */ + hasShares: function() { + return _.isObject(this.get('shares')); + }, + /** * @returns {string} */ @@ -94,16 +102,16 @@ }, fetch: function() { - /** var {OC.Share.Types.ShareItemInfo} **/ - var data = OC.Share.loadItem(this.get('itemType'), this.get('itemSource')); - var attributes = this.parse(data); - this.set(attributes); - console.warn(this.attributes); + var model = this; + OC.Share.loadItem(this.get('itemType'), this.get('itemSource'), function(data) { + model.set(model.parse(data)); + }); }, parse: function(data) { if(data === false) { console.warn('no data was returned'); + trigger('fetchError'); return {}; } var attributes = { -- cgit v1.2.3 From b015eff2e92ba83c6bf95c0084e283ddc7a5df70 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 11 Aug 2015 23:14:44 +0200 Subject: improve reshare rendering part and move permission calculation to model --- core/js/share.js | 7 +++--- core/js/sharedialogview.js | 62 ++++++++++++++++++++-------------------------- core/js/shareitemmodel.js | 57 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 87 insertions(+), 39 deletions(-) (limited to 'core/js/shareitemmodel.js') diff --git a/core/js/share.js b/core/js/share.js index d84da322274..db35a2e111c 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -382,18 +382,19 @@ OC.Share = _.extend(OC.Share, { }); }, showDropDown:function(itemType, itemSource, appendTo, link, possiblePermissions, filename) { - var attributes = {itemType: itemType, itemSource: itemSource}; + var attributes = {itemType: itemType, itemSource: itemSource, possiblePermissions: possiblePermissions}; var itemModel = new OC.Share.ShareItemModel(attributes); var dialogView = new OC.Share.ShareDialogView({ id: 'dropdown', model: itemModel, className: 'drop shareDropDown', attributes: { - 'data-item-source-name': filename + 'data-item-source-name': filename, + 'data-item-type': itemType, + 'data-item-soruce': itemSource } }); dialogView.setShowLink(link); - dialogView.setPossiblePermissions(possiblePermissions); var $dialog = dialogView.render().$el; $dialog.appendTo(appendTo); $dialog.slideDown(OC.menuSpeed, function() { diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index 3c12bedca86..4ff4eb9a94e 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -70,9 +70,6 @@ /** @type {boolean} **/ _showLink: true, - /** @type {unknown} **/ - _possiblePermissions: null, - /** @type {string} **/ tagName: 'div', @@ -91,7 +88,6 @@ var baseTemplate = this._getTemplate('base', TEMPLATE_BASE); this.$el.html(baseTemplate({ - shareLabel: t('core', 'Share'), resharerInfo: this._renderResharerInfo(), sharePlaceholder: this._renderSharePlaceholderPart(), @@ -112,41 +108,37 @@ this._showLink = (typeof showLink === 'boolean') ? showLink : true; }, - setPossiblePermissions: function(permissions) { - //TODO: maybe move to model? Whatever this is. - this._possiblePermissions = permissions; - }, - _renderResharerInfo: function() { var resharerInfo = ''; - if ( this.model.hasReshare() - && this.model.getReshareOwner() !== OC.currentUser) + if ( !this.model.hasReshare() + || !this.model.getReshareOwner() !== OC.currentUser) { - var reshareTemplate = this._getReshareTemplate(); - var sharedByText = ''; - if (this.model.getReshareType() === OC.Share.SHARE_TYPE_GROUP) { - sharedByText = t( - 'core', - 'Shared with you and the group {group} by {owner}', - { - group: this.model.getReshareWith(), - owner: this.model.getReshareOwnerDisplayname() - } - ); - } else { - sharedByText = t( - 'core', - 'Shared with you by {owner}', - { owner: this.model.getReshareOwnerDisplayname() } - ); - } - - - resharerInfo = reshareTemplate({ - avatarEnabled: oc_config.enable_avatars === true, - sharedByText: sharedByText - }); + return ''; } + + var reshareTemplate = this._getReshareTemplate(); + var sharedByText = ''; + if (this.model.getReshareType() === OC.Share.SHARE_TYPE_GROUP) { + sharedByText = t( + 'core', + 'Shared with you and the group {group} by {owner}', + { + group: this.model.getReshareWith(), + owner: this.model.getReshareOwnerDisplayname() + } + ); + } else { + sharedByText = t( + 'core', + 'Shared with you by {owner}', + { owner: this.model.getReshareOwnerDisplayname() } + ); + } + + return reshareTemplate({ + avatarEnabled: oc_config.enable_avatars === true, + sharedByText: sharedByText + }); }, _renderRemoteShareInfoPart: function() { diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index fe7aed46509..efce69f0f3e 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -57,6 +57,22 @@ this.fetch(); }, + defaults: { + allowPublicUploadStatus: false + }, + + /** + * @returns {boolean|jQuery} + */ + isPublicUploadEnabled: function() { + // FIXME: this really needs a better place + var publicUploadEnabled = $('#filestable').data('allow-public-upload'); + if (_.isUndefined(publicUploadEnabled)) { + publicUploadEnabled = 'no'; + } + return publicUploadEnabled; + }, + /** * whether this item has reshare information * @returns {boolean} @@ -101,6 +117,26 @@ return this.get('reshare').share_type; }, + /** + * @returns {number} + */ + getPermissions: function() { + var permissions = this.get('permissions'); + if(_.isUndefined(permissions)) { + // model was not properly initialized + console.warn('Sharing error: undefined permissions'); + permissions = 0; + } + return permissions; + }, + + /** + * @returns {boolean} + */ + hasSharePermission: function() { + return (this.getPermissions & OC.PERMISSION_SHARE) === OC.PERMISSION_SHARE; + }, + fetch: function() { var model = this; OC.Share.loadItem(this.get('itemType'), this.get('itemSource'), function(data) { @@ -114,10 +150,29 @@ trigger('fetchError'); return {}; } + + var permissions = this.get('possiblePermissions'); + if(!_.isUndefined(data.reshare) && !_.isUndefined(data.reshare.permissions)) { + permissions = permissions & data.reshare.permissions; + } + + var allowPublicUploadStatus = false; + if(!_.isUndefined(data.shares)) { + $.each(data.shares, function (key, value) { + if (value.share_type === OC.Share.SHARE_TYPE_LINK) { + allowPublicUploadStatus = (value.permissions & OC.PERMISSION_CREATE) ? true : false; + return true; + } + }); + } + var attributes = { reshare: data.reshare, - shares: data.shares + shares: data.shares, + permissions: permissions, + allowPublicUploadStatus: allowPublicUploadStatus }; + return attributes; } }); -- cgit v1.2.3 From 83d91ddf20bd2e61b9f01c82817ac8b815d3ac66 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 13 Aug 2015 02:38:14 +0200 Subject: further work on reimplementing the dialog layout --- core/js/share.js | 4 +- core/js/shareconfigmodel.js | 54 +++++++++++++++++++++ core/js/sharedialogview.js | 112 +++++++++++++++++++++++++++++++++++++++++--- core/js/shareitemmodel.js | 39 +++++++++++---- lib/private/share/share.php | 1 + 5 files changed, 193 insertions(+), 17 deletions(-) create mode 100644 core/js/shareconfigmodel.js (limited to 'core/js/shareitemmodel.js') diff --git a/core/js/share.js b/core/js/share.js index db35a2e111c..8d25749a107 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -382,11 +382,13 @@ OC.Share = _.extend(OC.Share, { }); }, showDropDown:function(itemType, itemSource, appendTo, link, possiblePermissions, filename) { + var configModel = new OC.Share.ShareConfigModel(); var attributes = {itemType: itemType, itemSource: itemSource, possiblePermissions: possiblePermissions}; - var itemModel = new OC.Share.ShareItemModel(attributes); + var itemModel = new OC.Share.ShareItemModel(attributes, {configModel: configModel}); var dialogView = new OC.Share.ShareDialogView({ id: 'dropdown', model: itemModel, + configModel: configModel, className: 'drop shareDropDown', attributes: { 'data-item-source-name': filename, diff --git a/core/js/shareconfigmodel.js b/core/js/shareconfigmodel.js new file mode 100644 index 00000000000..371cc96df5e --- /dev/null +++ b/core/js/shareconfigmodel.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2015 + * + * This file is licensed under the Affero General Public License version 3 + * or later. + * + * See the COPYING-README file. + * + */ + +(function() { + if (!OC.Share) { + OC.Share = {}; + OC.Share.Types = {}; + } + + var ShareConfigModel = OC.Backbone.Model.extend({ + defaults: { + publicUploadEnabled: false + }, + + /** + * @returns {boolean} + */ + isPublicUploadEnabled: function() { + var publicUploadEnabled = $('#filestable').data('allow-public-upload'); + return !_.isUndefined(publicUploadEnabled); + }, + + /** + * @returns {boolean} + */ + isMailPublicNotificationEnabled: function() { + return $('input:hidden[name=mailPublicNotificationEnabled]').val() === 'yes'; + }, + + /** + * @returns {boolean} + */ + isDefaultExpireDateEnforced: function() { + return oc_appconfig.core.defaultExpireDateEnforced === true; + }, + + /** + * @returns {number} + */ + getDefaultExpireDate: function () { + return oc_appconfig.core.defaultExpireDate; + } + }); + + + OC.Share.ShareConfigModel = ShareConfigModel; +})(); diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index 4ff4eb9a94e..7b0af2bc84c 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -24,7 +24,13 @@ '{{{remoteShareInfo}}}' + '
    ' + '
' + - '{{{linkShare}}}'; + '{{#if shareAllowed}}' + + '{{{linkShare}}}' + + '{{else}}' + + '{{{noSharing}}}' + + '{{/if}}' + + '{{{expiration}}}' + ; var TEMPLATE_RESHARER_INFO = '' + @@ -50,9 +56,37 @@ ' ' + ' ' + ' ' + - ' ' + ' ' + + ' {{#if publicUpload}}' + + ' ' + + ' {{/if}}' + + ' {{#if mailPublicNotificationEnabled}}' + + ' ' + + ' {{/if}}' + + '' ; + var TEMPLATE_NO_SHARING = + '' + ; + + var TEMPLATE_EXPIRATION = + '
' + + ' ' + + ' ' + + ' ' + + ' ' + + ' {{defaultExpireMessage}}' + + '
' + ; + /** * @class OCA.Share.ShareDialogView * @member {OC.Share.ShareItemModel} model @@ -73,7 +107,10 @@ /** @type {string} **/ tagName: 'div', - initialize: function() { + /** @type {OC.Share.ShareConfigModel} **/ + configModel: undefined, + + initialize: function(options) { var view = this; this.model.on('change', function() { view.render(); @@ -82,6 +119,12 @@ this.model.on('fetchError', function() { OC.Notification.showTemporary(t('core', 'Share details could not be loaded for this item.')); }); + + if(!_.isUndefined(options.configModel)) { + this.configModel = options.configModel; + } else { + console.warn('missing OC.Share.ShareConfigModel'); + } }, render: function() { @@ -92,7 +135,10 @@ resharerInfo: this._renderResharerInfo(), sharePlaceholder: this._renderSharePlaceholderPart(), remoteShareInfo: this._renderRemoteShareInfoPart(), - linkShare: this._renderLinkSharePart() + linkShare: this._renderLinkSharePart(), + shareAllowed: this.model.hasSharePermission(), + noSharing: this._renderNoSharing(), + expiration: this._renderExpirationPart() })); return this; @@ -155,14 +201,34 @@ _renderLinkSharePart: function() { var linkShare = ''; - if(this._showLink && $('#allowShareWithLink').val() === 'yes') { + if( this.model.hasSharePermission() + && this._showLink + && $('#allowShareWithLink').val() === 'yes') + { var linkShareTemplate = this._getLinkShareTemplate(); + + var publicUpload = + this.model.isFolder() + && this.model.hasCreatePermission() + && this.configModel.isPublicUploadEnabled(); + + var publicUploadChecked = ''; + if(this.model.isPublicUploadAllowed) { + publicUploadChecked = 'checked="checked"'; + } + linkShare = linkShareTemplate({ linkShareLabel: t('core', 'Share link'), urlLabel: t('core', 'Link'), enablePasswordLabel: t('core', 'Password protect'), passwordLabel: t('core', 'Password'), - passwordPlaceholder: t('core', 'Choose a password for the public link') + passwordPlaceholder: t('core', 'Choose a password for the public link'), + publicUpload: publicUpload, + publicUploadChecked: publicUploadChecked, + publicUploadLabel: t('core', 'Allow editing'), + mailPublicNotificationEnabled: this.configModel.isMailPublicNotificationEnabled(), + mailPrivatePlaceholder: t('core', 'Email link to person'), + mailButtonText: t('core', 'Send') }); } return linkShare; @@ -176,6 +242,40 @@ return sharePlaceholder; }, + _renderNoSharing: function () { + var noSharing = ''; + if(!this.model.hasSharePermission()) { + var noSharingTemplate = this._getTemplate('noSharing', TEMPLATE_NO_SHARING); + noSharing = noSharingTemplate({ + placeholder: t('core', 'Resharing is not allowed') + }); + } + return noSharing; + }, + + _renderExpirationPart: function() { + var expirationTemplate = this._getTemplate('expiration', TEMPLATE_EXPIRATION); + + var defaultExpireMessage = ''; + if(( this.model.isFolder() || this.model.isFile()) + && this.configModel.isDefaultExpireDateEnforced()) { + defaultExpireMessage = t( + 'core', + 'The public link will expire no later than {days} days after it is created', + {'days': this.configModel.getDefaultExpireDate()} + ); + } + + var expiration = expirationTemplate({ + setExpirationLabel: t('core', 'Set expiration date'), + expirationLabel: t('core', 'Expiration'), + expirationDatePlaceholder: t('core', 'Expiration date'), + defaultExpireMessage: defaultExpireMessage + }); + + return expiration; + }, + /** * * @param {string} key - an identifier for the template diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index efce69f0f3e..eb93b91ce92 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -53,7 +53,10 @@ * // FIXME: use OC Share API once #17143 is done */ var ShareItemModel = OC.Backbone.Model.extend({ - initialize: function() { + initialize: function(attributes, options) { + if(!_.isUndefined(options.configModel)) { + this.configModel = options.configModel; + } this.fetch(); }, @@ -62,15 +65,24 @@ }, /** - * @returns {boolean|jQuery} + * @returns {boolean} */ - isPublicUploadEnabled: function() { - // FIXME: this really needs a better place - var publicUploadEnabled = $('#filestable').data('allow-public-upload'); - if (_.isUndefined(publicUploadEnabled)) { - publicUploadEnabled = 'no'; - } - return publicUploadEnabled; + isPublicUploadAllowed: function() { + return this.get('allowPublicUploadStatus'); + }, + + /** + * @returns {boolean} + */ + isFolder: function() { + return this.get('itemType') === 'folder'; + }, + + /** + * @returns {boolean} + */ + isFile: function() { + return this.get('itemType') === 'file'; }, /** @@ -134,7 +146,14 @@ * @returns {boolean} */ hasSharePermission: function() { - return (this.getPermissions & OC.PERMISSION_SHARE) === OC.PERMISSION_SHARE; + return (this.getPermissions() & OC.PERMISSION_SHARE) === OC.PERMISSION_SHARE; + }, + + /** + * @returns {boolean} + */ + hasCreatePermission: function() { + return (this.getPermissions() & OC.PERMISSION_CREATE) === OC.PERMISSION_CREATE; }, fetch: function() { diff --git a/lib/private/share/share.php b/lib/private/share/share.php index 65968f581f5..cd3f0cbfb34 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -83,6 +83,7 @@ class Share extends Constants { 'supportedFileExtensions' => $supportedFileExtensions ); if(count(self::$backendTypes) === 1) { + \OC_Util::addScript('core', 'shareconfigmodel'); \OC_Util::addScript('core', 'shareitemmodel'); \OC_Util::addScript('core', 'sharedialogview'); \OC_Util::addScript('core', 'share'); -- cgit v1.2.3 From dcb084a617b2ee24031a14bce8b8e9749c821b75 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 19 Aug 2015 00:04:16 +0200 Subject: split ShareDialogResharerInfoView from base view --- core/js/sharedialogresharerinfoview.js | 117 +++++++++++++++++++++++++++++++++ core/js/sharedialogview.js | 62 ++++++----------- core/js/shareitemmodel.js | 1 + lib/private/share/share.php | 1 + 4 files changed, 138 insertions(+), 43 deletions(-) create mode 100644 core/js/sharedialogresharerinfoview.js (limited to 'core/js/shareitemmodel.js') diff --git a/core/js/sharedialogresharerinfoview.js b/core/js/sharedialogresharerinfoview.js new file mode 100644 index 00000000000..3f996bb6d21 --- /dev/null +++ b/core/js/sharedialogresharerinfoview.js @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2015 + * + * This file is licensed under the Affero General Public License version 3 + * or later. + * + * See the COPYING-README file. + * + */ + +(function() { + if (!OC.Share) { + OC.Share = {}; + } + + var TEMPLATE = + '' + + ' {{#if avatarEnabled}}' + + '
' + + ' {{/if}}' + + ' {{sharedByText}}' + + '

' + ; + + /** + * @class OCA.Share.ShareDialogView + * @member {OC.Share.ShareItemModel} model + * @member {jQuery} $el + * @memberof OCA.Sharing + * @classdesc + * + * Represents the GUI of the share dialogue + * + */ + var ShareDialogResharerInfoView = OC.Backbone.View.extend({ + /** @type {string} **/ + id: 'shareDialogResharerInfo', + + /** @type {string} **/ + tagName: 'div', + + /** @type {string} **/ + className: 'reshare', + + /** @type {OC.Share.ShareConfigModel} **/ + configModel: undefined, + + /** @type {Function} **/ + _template: undefined, + + initialize: function(options) { + var view = this; + + //FIXME: specific to reshares stuff + this.model.on('change', function() { + view.render(); + }); + + if(!_.isUndefined(options.configModel)) { + this.configModel = options.configModel; + } else { + console.warn('missing OC.Share.ShareConfigModel'); + } + }, + + render: function() { + if ( !this.model.hasReshare() + || !this.model.getReshareOwner() !== OC.currentUser) + { + this.$el.html(''); + return this; + } + + var reshareTemplate = this.template(); + var ownerDisplayName = this.model.getReshareOwnerDisplayname(); + var sharedByText = ''; + if (this.model.getReshareType() === OC.Share.SHARE_TYPE_GROUP) { + sharedByText = t( + 'core', + 'Shared with you and the group {group} by {owner}', + { + group: this.model.getReshareWith(), + owner: ownerDisplayName + } + ); + } else { + sharedByText = t( + 'core', + 'Shared with you by {owner}', + { owner: ownerDisplayName } + ); + } + + this.$el.html(reshareTemplate({ + avatarEnabled: this.configModel.areAvatarsEnabled(), + sharedByText: sharedByText + })); + + return this; + }, + + /** + * @returns {Function} from Handlebars + * @private + */ + template: function () { + if (!this._template) { + this._template = Handlebars.compile(TEMPLATE); + } + return this._template; + } + + }); + + OC.Share.ShareDialogResharerInfoView = ShareDialogResharerInfoView; + +})(); diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index 5e3fb8b8d97..179d818e90f 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -32,14 +32,6 @@ '{{{expiration}}}' ; - var TEMPLATE_RESHARER_INFO = - '' + - ' {{#if avatarEnabled}}' + - '
' + - ' {{/if}}' + - ' {{sharedByText}}' + - '

'; - var TEMPLATE_REMOTE_SHARE_INFO = ''; @@ -110,6 +102,9 @@ /** @type {OC.Share.ShareConfigModel} **/ configModel: undefined, + /** @type {object} **/ + resharerInfoView: undefined, + initialize: function(options) { var view = this; this.model.on('change', function() { @@ -125,14 +120,26 @@ } else { console.warn('missing OC.Share.ShareConfigModel'); } + + var subViewOptions = { + model: this.model, + configModel: this.configModel + }; + + this.resharerInfoView = _.isUndefined(options.resharerInfoView) + ? new OC.Share.ShareDialogResharerInfoView(subViewOptions) + : options.resharerInfoView; + }, render: function() { var baseTemplate = this._getTemplate('base', TEMPLATE_BASE); + this.resharerInfoView.render(); + this.$el.html(baseTemplate({ shareLabel: t('core', 'Share'), - resharerInfo: this._renderResharerInfo(), + resharerInfo: this.resharerInfoView.el.innerHTML, sharePlaceholder: this._renderSharePlaceholderPart(), remoteShareInfo: this._renderRemoteShareInfoPart(), linkShare: this._renderLinkSharePart(), @@ -142,7 +149,9 @@ })); this.$el.find('.hasTooltip').tooltip(); - this.$el.find('.avatar').avatar(this.model.getReshareOwner, 32); + if(this.configModel.areAvatarsEnabled()) { + this.$el.find('.avatar').avatar(this.model.getReshareOwner, 32); + } return this; }, @@ -157,39 +166,6 @@ this._showLink = (typeof showLink === 'boolean') ? showLink : true; }, - _renderResharerInfo: function() { - var resharerInfo = ''; - if ( !this.model.hasReshare() - || !this.model.getReshareOwner() !== OC.currentUser) - { - return ''; - } - - var reshareTemplate = this._getReshareTemplate(); - var sharedByText = ''; - if (this.model.getReshareType() === OC.Share.SHARE_TYPE_GROUP) { - sharedByText = t( - 'core', - 'Shared with you and the group {group} by {owner}', - { - group: this.model.getReshareWith(), - owner: this.model.getReshareOwnerDisplayname() - } - ); - } else { - sharedByText = t( - 'core', - 'Shared with you by {owner}', - { owner: this.model.getReshareOwnerDisplayname() } - ); - } - - return reshareTemplate({ - avatarEnabled: this.configModel.areAvatarsEnabled(), - sharedByText: sharedByText - }); - }, - _renderRemoteShareInfoPart: function() { var remoteShareInfo = ''; if(this.configModel.isRemoteShareAllowed()) { diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index eb93b91ce92..0d2bce8b2ef 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -112,6 +112,7 @@ * @returns {string} */ getReshareOwnerDisplayname: function() { + return 'foo'; return this.get('reshare').displayname_owner; }, diff --git a/lib/private/share/share.php b/lib/private/share/share.php index cd3f0cbfb34..10d0480ab89 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -85,6 +85,7 @@ class Share extends Constants { if(count(self::$backendTypes) === 1) { \OC_Util::addScript('core', 'shareconfigmodel'); \OC_Util::addScript('core', 'shareitemmodel'); + \OC_Util::addScript('core', 'sharedialogresharerinfoview'); \OC_Util::addScript('core', 'sharedialogview'); \OC_Util::addScript('core', 'share'); \OC_Util::addStyle('core', 'share'); -- cgit v1.2.3 From 277b786886de7979fea308595e4cf658e85aacf7 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 21 Aug 2015 15:00:15 +0200 Subject: ShareDialogResharerInfoView improvements --- core/js/sharedialogresharerinfoview.js | 8 ++++---- core/js/sharedialogview.js | 8 ++++---- core/js/shareitemmodel.js | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) (limited to 'core/js/shareitemmodel.js') diff --git a/core/js/sharedialogresharerinfoview.js b/core/js/sharedialogresharerinfoview.js index 3f996bb6d21..8970d857fc3 100644 --- a/core/js/sharedialogresharerinfoview.js +++ b/core/js/sharedialogresharerinfoview.js @@ -51,8 +51,7 @@ initialize: function(options) { var view = this; - //FIXME: specific to reshares stuff - this.model.on('change', function() { + this.model.on('change:reshare', function() { view.render(); }); @@ -67,7 +66,7 @@ if ( !this.model.hasReshare() || !this.model.getReshareOwner() !== OC.currentUser) { - this.$el.html(''); + this.$el.empty(); return this; } @@ -91,7 +90,8 @@ ); } - this.$el.html(reshareTemplate({ + this.$el.empty(); + this.$el.append(reshareTemplate({ avatarEnabled: this.configModel.areAvatarsEnabled(), sharedByText: sharedByText })); diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index 179d818e90f..67017778632 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -14,7 +14,7 @@ } var TEMPLATE_BASE = - '{{{resharerInfo}}}' + + '
' + '' + '
' + ' ' + @@ -135,11 +135,8 @@ render: function() { var baseTemplate = this._getTemplate('base', TEMPLATE_BASE); - this.resharerInfoView.render(); - this.$el.html(baseTemplate({ shareLabel: t('core', 'Share'), - resharerInfo: this.resharerInfoView.el.innerHTML, sharePlaceholder: this._renderSharePlaceholderPart(), remoteShareInfo: this._renderRemoteShareInfoPart(), linkShare: this._renderLinkSharePart(), @@ -148,6 +145,9 @@ expiration: this._renderExpirationPart() })); + this.resharerInfoView.$el = this.$el.find('.resharerInfo'); + this.resharerInfoView.render(); + this.$el.find('.hasTooltip').tooltip(); if(this.configModel.areAvatarsEnabled()) { this.$el.find('.avatar').avatar(this.model.getReshareOwner, 32); diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index 0d2bce8b2ef..9c4a8141cda 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -90,7 +90,8 @@ * @returns {boolean} */ hasReshare: function() { - return _.isObject(this.get('reshare')) && !_.isUndefined(this.get('reshare').uid_owner); + var reshare = this.get('reshare'); + return _.isObject(reshare) && !_.isUndefined(reshare.uid_owner); }, /** -- cgit v1.2.3 From f2fb20ed1cfc88c5e37c2ecc84ec4ec77d98f371 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 24 Aug 2015 23:27:43 +0200 Subject: no auto-fetch in model --- core/js/share.js | 1 + core/js/shareitemmodel.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'core/js/shareitemmodel.js') diff --git a/core/js/share.js b/core/js/share.js index 84da511497e..1fc1ac9e20c 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -404,6 +404,7 @@ OC.Share = _.extend(OC.Share, { $dialog.slideDown(OC.menuSpeed, function() { OC.Share.droppedDown = true; }); + itemModel.fetch(); return; diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index 9c4a8141cda..0d823f05749 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -57,7 +57,6 @@ if(!_.isUndefined(options.configModel)) { this.configModel = options.configModel; } - this.fetch(); }, defaults: { -- cgit v1.2.3 From 755d4016b11cd90806e29b0aafcd2ad09161ae57 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 24 Aug 2015 23:37:04 +0200 Subject: set default value and remove now superflous method --- core/js/shareitemmodel.js | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'core/js/shareitemmodel.js') diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index 0d823f05749..c5d0581390c 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -60,7 +60,8 @@ }, defaults: { - allowPublicUploadStatus: false + allowPublicUploadStatus: false, + permissions: 0 }, /** @@ -130,31 +131,18 @@ return this.get('reshare').share_type; }, - /** - * @returns {number} - */ - getPermissions: function() { - var permissions = this.get('permissions'); - if(_.isUndefined(permissions)) { - // model was not properly initialized - console.warn('Sharing error: undefined permissions'); - permissions = 0; - } - return permissions; - }, - /** * @returns {boolean} */ hasSharePermission: function() { - return (this.getPermissions() & OC.PERMISSION_SHARE) === OC.PERMISSION_SHARE; + return (this.get('permissions') & OC.PERMISSION_SHARE) === OC.PERMISSION_SHARE; }, /** * @returns {boolean} */ hasCreatePermission: function() { - return (this.getPermissions() & OC.PERMISSION_CREATE) === OC.PERMISSION_CREATE; + return (this.get('permissions') & OC.PERMISSION_CREATE) === OC.PERMISSION_CREATE; }, fetch: function() { @@ -186,14 +174,12 @@ }); } - var attributes = { + return { reshare: data.reshare, shares: data.shares, permissions: permissions, allowPublicUploadStatus: allowPublicUploadStatus }; - - return attributes; } }); -- cgit v1.2.3 From 5db1db38efffc2110e34886263f3a1117fe8efa5 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 1 Sep 2015 12:43:04 +0200 Subject: continue to reimplement sharee list view. still WIP --- core/js/sharedialoglinkshareview.js | 4 +- core/js/sharedialogresharerinfoview.js | 3 +- core/js/sharedialogshareelistview.js | 113 ++++++++++++++++-- core/js/sharedialogview.js | 14 ++- core/js/shareitemmodel.js | 212 ++++++++++++++++++++++++++++++++- 5 files changed, 327 insertions(+), 19 deletions(-) (limited to 'core/js/shareitemmodel.js') diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js index ff22b629dc4..eebf8a34247 100644 --- a/core/js/sharedialoglinkshareview.js +++ b/core/js/sharedialoglinkshareview.js @@ -92,7 +92,7 @@ render: function() { var linkShareTemplate = this.template(); - if( !this.model.hasSharePermission() + if( !this.model.sharePermissionPossible() || !this.showLink || !this.configModel.isShareWithLinkAllowed()) { @@ -105,7 +105,7 @@ var publicUpload = this.model.isFolder() - && this.model.hasCreatePermission() + && this.model.createPermissionPossible() && this.configModel.isPublicUploadEnabled(); var publicUploadChecked = ''; diff --git a/core/js/sharedialogresharerinfoview.js b/core/js/sharedialogresharerinfoview.js index 63df25b4ed8..f7de90e264f 100644 --- a/core/js/sharedialogresharerinfoview.js +++ b/core/js/sharedialogresharerinfoview.js @@ -16,7 +16,7 @@ var TEMPLATE = '' + ' {{#if avatarEnabled}}' + - '
' + + '
' + ' {{/if}}' + ' {{sharedByText}}' + '

' @@ -92,6 +92,7 @@ this.$el.html(reshareTemplate({ avatarEnabled: this.configModel.areAvatarsEnabled(), + reshareOwner: this.model.getReshareOwner(), sharedByText: sharedByText })); diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js index 177e0b4a899..8179926ad51 100644 --- a/core/js/sharedialogshareelistview.js +++ b/core/js/sharedialogshareelistview.js @@ -16,18 +16,41 @@ var TEMPLATE = '
    ' + '{{#each sharees}}' + + ' {{#if isCollection}}' + + '
  • {{text}}
  • ' + + ' {{/if}}' + + ' {{#unless isCollection}}' + '
  • ' + ' {{unshareLabel}}' + ' {{#if avatarEnabled}}' + - '
    ' + + '
    ' + ' {{/if}}' + ' {{shareWithDisplayName}}' + ' {{#if mailPublicNotificationEnabled}} {{#unless isRemoteShare}}' + - ' ' + + ' ' + ' {{/unless}} {{/if}}' + - ' {{#if isResharingAllowed}} {{#if hasSharePermission}}' + + ' {{#if isResharingAllowed}} {{#if sharePermissionPossible}}' + + ' ' + ' {{/if}} {{/if}}' + + ' {{#if editPermissionPossible}}' + + ' ' + + ' {{/if}}' + + ' {{#unless isRemoteShare}}' + + ' {{crudsLabel}}' + + '
    ' + + ' {{#if createPermissionPossible}}' + + ' ' + + ' {{/if}}' + + ' {{#if updatePermissionPossible}}' + + ' ' + + ' {{/if}}' + + ' {{#if deletePermissionPossible}}' + + ' ' + + ' {{/if}}' + + '
    ' + + ' {{/unless}}' + '
  • ' + + ' {{/unless}}' + '{{/each}}' + '
' ; @@ -61,6 +84,54 @@ } else { throw 'missing OC.Share.ShareConfigModel'; } + + var view = this; + this.model.on('change:shares', function() { + view.render(); + }); + }, + + getCollectionObject: function(shareIndex) { + var type = this.model.getCollectionType(shareIndex); + var id = this.model.getCollectionPath(shareIndex); + if(type !== 'file' && type !== 'folder') { + id = this.model.getCollectionSource(shareIndex); + } + return { + collectionID: id, + text: t('core', 'Shared in {item} with {user}', {'item': id, user: this.model.getShareWithDisplayName(shareIndex)}) + } + }, + + /** + * + * @param {OC.Share.Types.ShareInfo} shareInfo + * @returns {object} + */ + getShareeObject: function(shareIndex) { + var shareWith = this.model.getShareWith(shareIndex); + var shareWithDisplayName = this.model.getShareWithDisplayName(shareIndex); + var shareType = this.model.getShareType(shareIndex); + + if (shareType === OC.Share.SHARE_TYPE_GROUP) { + shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'group') + ')'; + } else if (shareType === OC.Share.SHARE_TYPE_REMOTE) { + shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'remote') + ')'; + } + + + return { + hasSharePermission: this.model.hasSharePermission(shareIndex), + hasEditPermission: this.model.hasEditPermission(shareIndex), + hasCreatePermission: this.model.hasCreatePermission(shareIndex), + hasUpdatePermission: this.model.hasUpdatePermission(shareIndex), + hasDeletePermission: this.model.hasDeletePermission(shareIndex), + wasMailSent: this.model.notificationMailWasSent(shareIndex), + shareWith: shareWith, + shareWithDisplayName: shareWithDisplayName, + shareType: shareType, + modSeed: shareType !== OC.Share.SHARE_TYPE_USER + }; }, getShareeList: function() { @@ -69,23 +140,49 @@ mailPublicNotificationEnabled: this.configModel.isMailPublicNotificationEnabled(), notifyByMailLabel: t('core', 'notify by email'), unshareLabel: t('core', 'Unshare'), - unshareImage: OC.imagePath('core', 'actions/delete') + unshareImage: OC.imagePath('core', 'actions/delete'), + canShareLabel: t('core', 'can share'), + canEditLabel: t('core', 'can edit'), + createPermissionLabel: t('core', 'create'), + updatePermissionLabel: t('core', 'change'), + deletePermissionLabel: t('core', 'delete'), + crudsLabel: t('core', 'access control'), + triangleSImage: OC.imagePath('core', 'actions/triangle-s'), + isResharingAllowed: this.configModel.isResharingAllowed(), + sharePermissionPossible: this.model.sharePermissionPossible(), + editPermissionPossible: this.model.editPermissionPossible(), + createPermissionPossible: this.model.createPermissionPossible(), + updatePermissionPossible: this.model.updatePermissionPossible(), + deletePermissionPossible: this.model.deletePermissionPossible(), + sharePermission: OC.PERMISSION_SHARE, + createPermission: OC.PERMISSION_CREATE, + updatePermission: OC.PERMISSION_UPDATE, + deletePermission: OC.PERMISSION_DELETE }; // TODO: sharess must have following attributes - // shareType - // shareWith - // shareWithDisplayName // isRemoteShare // isMailSent - var list = _.extend({}, universal); + if(!this.model.hasShares()) { + return []; + } + + var list = []; + for(var index in this.model.get('shares')) { + if(this.model.isCollection(index)) { + list.unshift(this.getCollectionObject(index)); + } else { + list.push(_.extend(this.getShareeObject(index), universal)) + } + } return list; }, render: function() { var shareeListTemplate = this.template(); + var list = this.getShareeList(); this.$el.html(shareeListTemplate({ sharees: this.getShareeList() })); diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index 2348c14bb88..9bfe38eea3c 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -63,6 +63,9 @@ /** @type {object} **/ expirationView: undefined, + /** @type {object} **/ + shareeListView: undefined, + initialize: function(options) { var view = this; this.model.on('change', function() { @@ -118,11 +121,18 @@ this.expirationView.render(); this.shareeListView.$el = this.$el.find('.shareeListView'); - this.shareeListView.redner(); + this.shareeListView.render(); this.$el.find('.hasTooltip').tooltip(); if(this.configModel.areAvatarsEnabled()) { - this.$el.find('.avatar').avatar(this.model.getReshareOwner, 32); + this.$el.find('.avatar').each(function() { + var $this = $(this); + $this.avatar($this.data('username'), 32); + }); + this.$el.find('.avatar.imageplaceholderseed').each(function() { + var $this = $(this); + $this.imageplaceholder($this.data('seed')); + }); } return this; diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index c5d0581390c..b5370faca0a 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -14,6 +14,13 @@ OC.Share.Types = {}; } + /** + * @typedef {object} OC.Share.Types.Collection + * @property {string} item_type + * @property {string} path + * @property {string} item_source TODO: verify + */ + /** * @typedef {object} OC.Share.Types.Reshare * @property {string} uid_owner @@ -33,7 +40,7 @@ * @property {string} share_with * @property {string} share_with_displayname * @property {string} share_mail_send - * @property {bool} collection //TODO: verify + * @property {OC.Share.Types.Collection|undefined} collection * @property {Date} expiration optional? * @property {number} stime optional? */ @@ -95,13 +102,79 @@ }, /** - * whether this item has reshare information + * whether this item has share information * @returns {boolean} */ hasShares: function() { - return _.isObject(this.get('shares')); + var shares = this.get('shares'); + return _.isArray(this.get('shares')); }, + /** + * @param {number} shareIndex + * @returns {string} + */ + getCollectionType: function(shareIndex) { + /** @type OC.Share.Types.ShareInfo **/ + var share = this.get('shares')[shareIndex]; + if(!_.isObject(share)) { + throw "Unknown Share"; + } else if(_.isUndefined(share.collection)) { + throw "Share is not a collection"; + } + + return share.collection.item_type; + }, + + /** + * @param {number} shareIndex + * @returns {string} + */ + getCollectionPath: function(shareIndex) { + /** @type OC.Share.Types.ShareInfo **/ + var share = this.get('shares')[shareIndex]; + if(!_.isObject(share)) { + throw "Unknown Share"; + } else if(_.isUndefined(share.collection)) { + throw "Share is not a collection"; + } + + return share.collection.path; + }, + + /** + * @param {number} shareIndex + * @returns {string} + */ + getCollectionSource: function(shareIndex) { + /** @type OC.Share.Types.ShareInfo **/ + var share = this.get('shares')[shareIndex]; + if(!_.isObject(share)) { + throw "Unknown Share"; + } else if(_.isUndefined(share.collection)) { + throw "Share is not a collection"; + } + + return share.collection.item_source; + }, + + /** + * @param {number} shareIndex + * @returns {boolean} + */ + isCollection: function(shareIndex) { + /** @type OC.Share.Types.ShareInfo **/ + var share = this.get('shares')[shareIndex]; + if(!_.isObject(share)) { + throw "Unknown Share"; + } + if(_.isUndefined(share.collection)) { + return false; + } + return true; + }, + + /** * @returns {string} */ @@ -131,20 +204,145 @@ return this.get('reshare').share_type; }, + /** + * @param shareIndex + * @returns {string} + */ + getShareWith: function(shareIndex) { + /** @type OC.Share.Types.ShareInfo **/ + var share = this.get('shares')[shareIndex]; + if(!_.isObject(share)) { + throw "Unknown Share"; + } + return share.share_with; + }, + + /** + * @param shareIndex + * @returns {string} + */ + getShareWithDisplayName: function(shareIndex) { + /** @type OC.Share.Types.ShareInfo **/ + var share = this.get('shares')[shareIndex]; + if(!_.isObject(share)) { + throw "Unknown Share"; + } + return share.share_with_displayname; + }, + + getShareType: function(shareIndex) { + /** @type OC.Share.Types.ShareInfo **/ + var share = this.get('shares')[shareIndex]; + if(!_.isObject(share)) { + throw "Unknown Share"; + } + return share.share_type; + }, + + /** + * whether a share from shares has the requested permission + * + * @param {number} shareIndex + * @param {number} permission + * @returns {boolean} + * @private + */ + _shareHasPermission: function(shareIndex, permission) { + /** @type OC.Share.Types.ShareInfo **/ + var share = this.get('shares')[shareIndex]; + if(!_.isObject(share)) { + throw "Unknown Share"; + } + return (share.permissions & permission) === permission; + }, + + notificationMailWasSent: function(shareIndex) { + /** @type OC.Share.Types.ShareInfo **/ + var share = this.get('shares')[shareIndex]; + if(!_.isObject(share)) { + throw "Unknown Share"; + } + return share.share_mail_send === '1'; + }, + /** * @returns {boolean} */ - hasSharePermission: function() { + sharePermissionPossible: function() { return (this.get('permissions') & OC.PERMISSION_SHARE) === OC.PERMISSION_SHARE; }, + /** + * @param {number} shareIndex + * @returns {boolean} + */ + hasSharePermission: function(shareIndex) { + return this._shareHasPermission(shareIndex, OC.PERMISSION_SHARE); + }, + /** * @returns {boolean} */ - hasCreatePermission: function() { + createPermissionPossible: function() { return (this.get('permissions') & OC.PERMISSION_CREATE) === OC.PERMISSION_CREATE; }, + /** + * @param {number} shareIndex + * @returns {boolean} + */ + hasCreatePermission: function(shareIndex) { + return this._shareHasPermission(shareIndex, OC.PERMISSION_CREATE); + }, + + /** + * @returns {boolean} + */ + updatePermissionPossible: function() { + return (this.get('permissions') & OC.PERMISSION_UPDATE) === OC.PERMISSION_UPDATE; + }, + + /** + * @param {number} shareIndex + * @returns {boolean} + */ + hasUpdatePermission: function(shareIndex) { + return this._shareHasPermission(shareIndex, OC.PERMISSION_UPDATE); + }, + + /** + * @returns {boolean} + */ + deletePermissionPossible: function() { + return (this.get('permissions') & OC.PERMISSION_DELETE) === OC.PERMISSION_DELETE; + }, + + /** + * @param {number} shareIndex + * @returns {boolean} + */ + hasDeletePermission: function(shareIndex) { + return this._shareHasPermission(shareIndex, OC.PERMISSION_DELETE); + }, + + /** + * @returns {boolean} + */ + editPermissionPossible: function() { + return this.createPermissionPossible() + || this.updatePermissionPossible() + || this.deletePermissionPossible(); + }, + + /** + * @returns {boolean} + */ + hasEditPermission: function(shareIndex) { + return this.hasCreatePermission(shareIndex) + || this.hasUpdatePermission(shareIndex) + || this.hasDeletePermission(shareIndex); + }, + fetch: function() { var model = this; OC.Share.loadItem(this.get('itemType'), this.get('itemSource'), function(data) { @@ -159,6 +357,8 @@ return {}; } + console.log(data.shares); + var permissions = this.get('possiblePermissions'); if(!_.isUndefined(data.reshare) && !_.isUndefined(data.reshare.permissions)) { permissions = permissions & data.reshare.permissions; @@ -176,7 +376,7 @@ return { reshare: data.reshare, - shares: data.shares, + shares: $.map(data.shares, function(value) { return [value]; }), permissions: permissions, allowPublicUploadStatus: allowPublicUploadStatus }; -- cgit v1.2.3 From 44ecdde10d347dc0e77576b35dc3d066dfc0fce6 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 2 Sep 2015 13:06:00 +0200 Subject: sharee list view: better handle collections --- core/js/sharedialogshareelistview.js | 41 +++++++++++++++++++++++++++++++----- core/js/shareitemmodel.js | 4 +--- 2 files changed, 37 insertions(+), 8 deletions(-) (limited to 'core/js/shareitemmodel.js') diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js index 8179926ad51..8e08e2b4f76 100644 --- a/core/js/sharedialogshareelistview.js +++ b/core/js/sharedialogshareelistview.js @@ -78,6 +78,9 @@ /** @type {boolean} **/ showLink: true, + /** @type {object} **/ + _collections: {}, + initialize: function(options) { if(!_.isUndefined(options.configModel)) { this.configModel = options.configModel; @@ -91,6 +94,23 @@ }); }, + processCollectionShare: function(shareIndex) { + var type = this.model.getCollectionType(shareIndex); + var id = this.model.getCollectionPath(shareIndex); + if(type !== 'file' && type !== 'folder') { + id = this.model.getCollectionSource(shareIndex); + } + var displayName = this.model.getShareWithDisplayName(shareIndex); + if(!_.isUndefined(this._collections[id])) { + this._collections[id].text = this._collections[id].text + ", " + displayName; + } else { + this._collections[id] = {}; + this._collections[id].text = t('core', 'Shared in {item} with {user}', {'item': id, user: displayName}); + this._collections[id].id = id; + this._collections[id].isCollection = true; + } + }, + getCollectionObject: function(shareIndex) { var type = this.model.getCollectionType(shareIndex); var id = this.model.getCollectionPath(shareIndex); @@ -119,7 +139,6 @@ shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'remote') + ')'; } - return { hasSharePermission: this.model.hasSharePermission(shareIndex), hasEditPermission: this.model.hasEditPermission(shareIndex), @@ -160,21 +179,34 @@ deletePermission: OC.PERMISSION_DELETE }; + this._collections = {}; + // TODO: sharess must have following attributes // isRemoteShare - // isMailSent if(!this.model.hasShares()) { return []; } + var shares = this.model.get('shares'); var list = []; - for(var index in this.model.get('shares')) { + for(var index = 0; index < shares.length; index++) { + + // #### FIXME: LEGACY #### + // this does not belong to a view + var shareType = this.model.getShareType(index); + if (!OC.Share.currentShares[shareType]) { + OC.Share.currentShares[shareType] = []; + } + OC.Share.currentShares[shareType].push(this.model.getShareWith(index)); + // #### /FIXME: LEGACY #### + if(this.model.isCollection(index)) { - list.unshift(this.getCollectionObject(index)); + this.processCollectionShare(index); } else { list.push(_.extend(this.getShareeObject(index), universal)) } + list = _.union(_.values(this._collections), list); } return list; @@ -182,7 +214,6 @@ render: function() { var shareeListTemplate = this.template(); - var list = this.getShareeList(); this.$el.html(shareeListTemplate({ sharees: this.getShareeList() })); diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index b5370faca0a..d4fbc3543a7 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -357,8 +357,6 @@ return {}; } - console.log(data.shares); - var permissions = this.get('possiblePermissions'); if(!_.isUndefined(data.reshare) && !_.isUndefined(data.reshare.permissions)) { permissions = permissions & data.reshare.permissions; @@ -376,7 +374,7 @@ return { reshare: data.reshare, - shares: $.map(data.shares, function(value) { return [value]; }), + shares: _.toArray(data.shares), permissions: permissions, allowPublicUploadStatus: allowPublicUploadStatus }; -- cgit v1.2.3 From 60abfcdab16ed674015422a6300bd28f3baa5e91 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 2 Sep 2015 16:47:25 +0200 Subject: old OC.Share.addShareWith now reimplemented --- core/js/share.js | 106 ----------------------------------- core/js/sharedialogshareelistview.js | 28 +-------- core/js/shareitemmodel.js | 26 ++++++++- 3 files changed, 27 insertions(+), 133 deletions(-) (limited to 'core/js/shareitemmodel.js') diff --git a/core/js/share.js b/core/js/share.js index 1fc1ac9e20c..bd87ab10d40 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -685,112 +685,6 @@ OC.Share = _.extend(OC.Share, { } }); }, - addShareWith:function(shareType, shareWith, shareWithDisplayName, permissions, possiblePermissions, mailSend, collection) { - var shareItem = { - share_type: shareType, - share_with: shareWith, - share_with_displayname: shareWithDisplayName, - permissions: permissions - }; - if (shareType === OC.Share.SHARE_TYPE_GROUP) { - shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'group') + ')'; - } - if (shareType === OC.Share.SHARE_TYPE_REMOTE) { - shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'remote') + ')'; - } - if (!OC.Share.itemShares[shareType]) { - OC.Share.itemShares[shareType] = []; - } - OC.Share.itemShares[shareType].push(shareWith); - if (collection) { - if (collection.item_type == 'file' || collection.item_type == 'folder') { - var item = collection.path; - } else { - var item = collection.item_source; - } - var collectionList = $('#shareWithList li').filterAttr('data-collection', item); - if (collectionList.length > 0) { - $(collectionList).append(', '+shareWithDisplayName); - } else { - var html = '
  • '+t('core', 'Shared in {item} with {user}', {'item': item, user: shareWithDisplayName})+'
  • '; - $('#shareWithList').prepend(html); - } - } else { - var editChecked = createChecked = updateChecked = deleteChecked = shareChecked = ''; - if (permissions & OC.PERMISSION_CREATE) { - createChecked = 'checked="checked"'; - editChecked = 'checked="checked"'; - } - if (permissions & OC.PERMISSION_UPDATE) { - updateChecked = 'checked="checked"'; - editChecked = 'checked="checked"'; - } - if (permissions & OC.PERMISSION_DELETE) { - deleteChecked = 'checked="checked"'; - editChecked = 'checked="checked"'; - } - if (permissions & OC.PERMISSION_SHARE) { - shareChecked = 'checked="checked"'; - } - var html = '
  • '; - var showCrudsButton; - html += ''+t('core', 'Unshare')+''; - if (oc_config.enable_avatars === true) { - html += '
    '; - } - html += '' + escapeHTML(shareWithDisplayName) + ''; - var mailNotificationEnabled = $('input:hidden[name=mailNotificationEnabled]').val(); - if (mailNotificationEnabled === 'yes' && shareType !== OC.Share.SHARE_TYPE_REMOTE) { - var checked = ''; - if (mailSend === '1') { - checked = 'checked'; - } - html += ' '; - } - if (oc_appconfig.core.resharingAllowed && (possiblePermissions & OC.PERMISSION_SHARE)) { - html += ''; - } - if (possiblePermissions & OC.PERMISSION_CREATE || possiblePermissions & OC.PERMISSION_UPDATE || possiblePermissions & OC.PERMISSION_DELETE) { - html += ''; - } - if (shareType !== OC.Share.SHARE_TYPE_REMOTE) { - showCrudsButton = ''+t('core', 'access control')+''; - } - html += ''; - html += '
  • '; - html = $(html).appendTo('#shareWithList'); - if (oc_config.enable_avatars === true) { - if (shareType === OC.Share.SHARE_TYPE_USER) { - html.find('.avatar').avatar(escapeHTML(shareWith), 32); - } else { - //Add sharetype to generate different seed if there is a group and use with the same name - html.find('.avatar').imageplaceholder(escapeHTML(shareWith) + ' ' + shareType); - } - } - // insert cruds button into last label element - var lastLabel = html.find('>label:last'); - if (lastLabel.exists()){ - lastLabel.append(showCrudsButton); - } - else{ - html.find('.cruds').before(showCrudsButton); - } - if (!OC.Share.currentShares[shareType]) { - OC.Share.currentShares[shareType] = []; - } - OC.Share.currentShares[shareType].push(shareItem); - } - }, showLink:function(token, password, itemSource) { OC.Share.itemShares[OC.Share.SHARE_TYPE_LINK] = true; $('#linkCheckbox').attr('checked', true); diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js index 8e08e2b4f76..f9d725bf51e 100644 --- a/core/js/sharedialogshareelistview.js +++ b/core/js/sharedialogshareelistview.js @@ -111,18 +111,6 @@ } }, - getCollectionObject: function(shareIndex) { - var type = this.model.getCollectionType(shareIndex); - var id = this.model.getCollectionPath(shareIndex); - if(type !== 'file' && type !== 'folder') { - id = this.model.getCollectionSource(shareIndex); - } - return { - collectionID: id, - text: t('core', 'Shared in {item} with {user}', {'item': id, user: this.model.getShareWithDisplayName(shareIndex)}) - } - }, - /** * * @param {OC.Share.Types.ShareInfo} shareInfo @@ -149,7 +137,8 @@ shareWith: shareWith, shareWithDisplayName: shareWithDisplayName, shareType: shareType, - modSeed: shareType !== OC.Share.SHARE_TYPE_USER + modSeed: shareType !== OC.Share.SHARE_TYPE_USER, + isRemoteShare: shareType === OC.Share.SHARE_TYPE_REMOTE }; }, @@ -181,9 +170,6 @@ this._collections = {}; - // TODO: sharess must have following attributes - // isRemoteShare - if(!this.model.hasShares()) { return []; } @@ -191,16 +177,6 @@ var shares = this.model.get('shares'); var list = []; for(var index = 0; index < shares.length; index++) { - - // #### FIXME: LEGACY #### - // this does not belong to a view - var shareType = this.model.getShareType(index); - if (!OC.Share.currentShares[shareType]) { - OC.Share.currentShares[shareType] = []; - } - OC.Share.currentShares[shareType].push(this.model.getShareWith(index)); - // #### /FIXME: LEGACY #### - if(this.model.isCollection(index)) { this.processCollectionShare(index); } else { diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index d4fbc3543a7..8afc4954902 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -350,6 +350,27 @@ }); }, + legacyFillCurrentShares: function(shares) { + OC.Share.currentShares = {}; + OC.Share.itemShares = []; + _.each(shares, + /** + * @param {OC.Share.Types.ShareInfo} share + */ + function(share) { + if (!OC.Share.currentShares[share.share_type]) { + OC.Share.currentShares[share.share_type] = []; + } + OC.Share.currentShares[share.share_type].push(share); + + if (!OC.Share.itemShares[share.share_type]) { + OC.Share.itemShares[share.share_type] = []; + } + OC.Share.itemShares[share.share_type].push(share.share_with); + } + ); + }, + parse: function(data) { if(data === false) { console.warn('no data was returned'); @@ -372,9 +393,12 @@ }); } + var shares = _.toArray(data.shares); + this.legacyFillCurrentShares(shares); + return { reshare: data.reshare, - shares: _.toArray(data.shares), + shares: shares, permissions: permissions, allowPublicUploadStatus: allowPublicUploadStatus }; -- cgit v1.2.3 From 5dc2c35ce5f3023ccea4cc599cf54d6b1c0e2c01 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 2 Sep 2015 17:27:25 +0200 Subject: fixed set of possible permissions for remote shares --- core/js/sharedialogshareelistview.js | 19 ++++++++++++------- core/js/shareitemmodel.js | 6 ++++++ 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'core/js/shareitemmodel.js') diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js index f9d725bf51e..6a356b8144c 100644 --- a/core/js/sharedialogshareelistview.js +++ b/core/js/sharedialogshareelistview.js @@ -29,9 +29,9 @@ ' {{#if mailPublicNotificationEnabled}} {{#unless isRemoteShare}}' + ' ' + ' {{/unless}} {{/if}}' + - ' {{#if isResharingAllowed}} {{#if sharePermissionPossible}}' + + ' {{#if isResharingAllowed}} {{#if sharePermissionPossible}} {{#unless isRemoteShare}}' + ' ' + - ' {{/if}} {{/if}}' + + ' {{/unless}} {{/if}} {{/if}}' + ' {{#if editPermissionPossible}}' + ' ' + ' {{/if}}' + @@ -44,9 +44,9 @@ ' {{#if updatePermissionPossible}}' + ' ' + ' {{/if}}' + - ' {{#if deletePermissionPossible}}' + + ' {{#if deletePermissionPossible}} {{#unless isRemoteShare}}' + ' ' + - ' {{/if}}' + + ' {{/unless}} {{/if}}' + '
    ' + ' {{/unless}}' + ' ' + @@ -121,13 +121,18 @@ var shareWithDisplayName = this.model.getShareWithDisplayName(shareIndex); var shareType = this.model.getShareType(shareIndex); + var hasPermissionOverride = {}; if (shareType === OC.Share.SHARE_TYPE_GROUP) { shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'group') + ')'; } else if (shareType === OC.Share.SHARE_TYPE_REMOTE) { shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'remote') + ')'; + hasPermissionOverride = { + createPermissionPossible: true, + updatePermissionPossible: true + }; } - return { + return _.extend(hasPermissionOverride, { hasSharePermission: this.model.hasSharePermission(shareIndex), hasEditPermission: this.model.hasEditPermission(shareIndex), hasCreatePermission: this.model.hasCreatePermission(shareIndex), @@ -139,7 +144,7 @@ shareType: shareType, modSeed: shareType !== OC.Share.SHARE_TYPE_USER, isRemoteShare: shareType === OC.Share.SHARE_TYPE_REMOTE - }; + }); }, getShareeList: function() { @@ -180,7 +185,7 @@ if(this.model.isCollection(index)) { this.processCollectionShare(index); } else { - list.push(_.extend(this.getShareeObject(index), universal)) + list.push(_.extend(universal, this.getShareeObject(index))) } list = _.union(_.values(this._collections), list); } diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index 8afc4954902..acaa890be11 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -253,6 +253,12 @@ if(!_.isObject(share)) { throw "Unknown Share"; } + if( share.share_type === OC.Share.SHARE_TYPE_REMOTE + && ( permission === OC.PERMISSION_SHARE + || permission === OC.PERMISSION_DELETE)) + { + return false; + } return (share.permissions & permission) === permission; }, -- cgit v1.2.3 From ce1b0c650e3a0e4cb701609ee08a13182909219a Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 3 Sep 2015 15:53:17 +0200 Subject: show link share --- apps/files_sharing/js/sharetabview.js | 6 ++-- core/css/share.css | 4 --- core/js/shareconfigmodel.js | 3 +- core/js/sharedialogexpirationview.js | 10 ++++-- core/js/sharedialoglinkshareview.js | 32 ++++++++++++++------ core/js/shareitemmodel.js | 57 +++++++++++++++++++++++++++++++++-- 6 files changed, 92 insertions(+), 20 deletions(-) (limited to 'core/js/shareitemmodel.js') diff --git a/apps/files_sharing/js/sharetabview.js b/apps/files_sharing/js/sharetabview.js index 11f25c0c47c..6836107306a 100644 --- a/apps/files_sharing/js/sharetabview.js +++ b/apps/files_sharing/js/sharetabview.js @@ -45,7 +45,6 @@ } if (this.model) { - console.log(this.model); var owner = this.model.get('shareOwner'); if (owner === OC.currentUser) { owner = null; @@ -59,8 +58,11 @@ itemSource: this.model.get('id'), possiblePermissions: this.model.get('sharePermissions') }; - var shareModel = new OC.Share.ShareItemModel(attributes, {configModel: configModel}); var configModel = new OC.Share.ShareConfigModel(); + var shareModel = new OC.Share.ShareItemModel(attributes, { + configModel: configModel, + fileInfoModel: this.model + }); this._dialog = new OC.Share.ShareDialogView({ configModel: configModel, model: shareModel diff --git a/core/css/share.css b/core/css/share.css index 0d687cb76da..bdf34e9a863 100644 --- a/core/css/share.css +++ b/core/css/share.css @@ -126,10 +126,6 @@ a.unshare { margin-right: 0; } -#linkText,#linkPass,#expiration { - display:none; -} - #link #showPassword img { padding-left:5px; width:12px; diff --git a/core/js/shareconfigmodel.js b/core/js/shareconfigmodel.js index e948c57cbac..846b2692ecb 100644 --- a/core/js/shareconfigmodel.js +++ b/core/js/shareconfigmodel.js @@ -16,7 +16,8 @@ var ShareConfigModel = OC.Backbone.Model.extend({ defaults: { - publicUploadEnabled: false + publicUploadEnabled: false, + enforcePasswordForPublicLink: oc_appconfig.core.enforcePasswordForPublicLink }, /** diff --git a/core/js/sharedialogexpirationview.js b/core/js/sharedialogexpirationview.js index 4c628f5498a..9fb404a090e 100644 --- a/core/js/sharedialogexpirationview.js +++ b/core/js/sharedialogexpirationview.js @@ -14,11 +14,14 @@ } var TEMPLATE = + // well that could go to linkShareView… + '{{#if isLinkShare}}' + '' + '' + '' + '' + - '{{defaultExpireMessage}}' + '{{defaultExpireMessage}}' + + '{{/if}}' ; /** @@ -44,6 +47,8 @@ /** @type {boolean} **/ showLink: true, + className: 'hidden', + initialize: function(options) { if(!_.isUndefined(options.configModel)) { this.configModel = options.configModel; @@ -68,7 +73,8 @@ setExpirationLabel: t('core', 'Set expiration date'), expirationLabel: t('core', 'Expiration'), expirationDatePlaceholder: t('core', 'Expiration date'), - defaultExpireMessage: defaultExpireMessage + defaultExpireMessage: defaultExpireMessage, + isLinkShare: this.model.get('linkShare').isLinkShare })); return this; diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js index eebf8a34247..373d6d180bc 100644 --- a/core/js/sharedialoglinkshareview.js +++ b/core/js/sharedialoglinkshareview.js @@ -16,16 +16,20 @@ var TEMPLATE = '{{#if shareAllowed}}' + '' + - '' + + '' + '
    ' + '' + - '' + - '' + + '' + + ' {{#if showPasswordCheckBox}}' + + '' + + ' {{/if}}' + + ' {{#if isPasswordSet}}' + '
    ' + ' ' + - ' ' + + ' ' + ' ' + '
    ' + + ' {{/if}}' + ' {{#if publicUpload}}' + '