From f9c232c4ce16b101fce233f1f20e0cafc7e4d1fa Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 21 Aug 2015 15:40:50 +0200 Subject: split off linkShareView --- core/js/sharedialoglinkshareview.js | 143 ++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 core/js/sharedialoglinkshareview.js (limited to 'core/js/sharedialoglinkshareview.js') diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js new file mode 100644 index 00000000000..ccd705803f6 --- /dev/null +++ b/core/js/sharedialoglinkshareview.js @@ -0,0 +1,143 @@ +/* + * 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 = + '' + ; + + /** + * @class OCA.Share.ShareDialogLinkShareView + * @member {OC.Share.ShareItemModel} model + * @member {jQuery} $el + * @memberof OCA.Sharing + * @classdesc + * + * Represents the GUI of the share dialogue + * + */ + var ShareDialogLinkShareView = OC.Backbone.View.extend({ + /** @type {string} **/ + id: 'shareDialogLinkShare', + + /** @type {OC.Share.ShareConfigModel} **/ + configModel: undefined, + + /** @type {Function} **/ + _template: undefined, + + /** @type {boolean} **/ + showLink: true, + + initialize: function(options) { + var view = this; + + this.model.on('change:permissions', function() { + view.render(); + }); + + this.model.on('change:itemType', function() { + view.render(); + }); + + this.model.on('change:allowPublicUploadStatus', function() { + view.render(); + }); + + if(!_.isUndefined(options.configModel)) { + this.configModel = options.configModel; + } else { + console.warn('missing OC.Share.ShareConfigModel'); + } + }, + + render: function() { + if( !this.model.hasSharePermission() + || !this.showLink + || !this.configModel.isShareWithLinkAllowed()) + { + this.$el.empty(); + return this; + } + + var publicUpload = + this.model.isFolder() + && this.model.hasCreatePermission() + && this.configModel.isPublicUploadEnabled(); + + var publicUploadChecked = ''; + if(this.model.isPublicUploadAllowed()) { + publicUploadChecked = 'checked="checked"'; + } + + var linkShareTemplate = this.template(); + this.$el.empty(); + this.$el.append(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'), + 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 this; + }, + + /** + * @returns {Function} from Handlebars + * @private + */ + template: function () { + if (!this._template) { + this._template = Handlebars.compile(TEMPLATE); + } + return this._template; + } + + }); + + OC.Share.ShareDialogLinkShareView = ShareDialogLinkShareView; + +})(); -- cgit v1.2.3 From 6af6024e172bc4810691f54ccaa2da6912395962 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 21 Aug 2015 20:29:12 +0200 Subject: integraton noshare part into ShareDialogLinkShareView --- core/js/sharedialoglinkshareview.js | 52 +++++++++++++++++++++---------------- core/js/sharedialogview.js | 25 +++--------------- 2 files changed, 33 insertions(+), 44 deletions(-) (limited to 'core/js/sharedialoglinkshareview.js') diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js index ccd705803f6..ca6413761b0 100644 --- a/core/js/sharedialoglinkshareview.js +++ b/core/js/sharedialoglinkshareview.js @@ -14,32 +14,34 @@ } var TEMPLATE = - '' + '{{else}}' + + '' + + '{{/if}}' ; /** @@ -88,11 +90,17 @@ }, render: function() { + var linkShareTemplate = this.template(); + if( !this.model.hasSharePermission() || !this.showLink || !this.configModel.isShareWithLinkAllowed()) { this.$el.empty(); + this.$el.append(linkShareTemplate({ + shareAllowed: false, + noSharingPlaceholder: t('core', 'Resharing is not allowed') + })); return this; } @@ -106,9 +114,9 @@ publicUploadChecked = 'checked="checked"'; } - var linkShareTemplate = this.template(); this.$el.empty(); this.$el.append(linkShareTemplate({ + shareAllowed: true, linkShareLabel: t('core', 'Share link'), urlLabel: t('core', 'Link'), enablePasswordLabel: t('core', 'Password protect'), diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index b33130a83dc..63c3473252f 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -24,11 +24,7 @@ '{{{remoteShareInfo}}}' + '' + - '{{#if shareAllowed}}' + '
' + - '{{else}}' + - '{{{noSharing}}}' + - '{{/if}}' + '
' ; @@ -114,21 +110,17 @@ shareLabel: t('core', 'Share'), sharePlaceholder: this._renderSharePlaceholderPart(), remoteShareInfo: this._renderRemoteShareInfoPart(), - shareAllowed: this.model.hasSharePermission(), - noSharing: this._renderNoSharing(), })); this.resharerInfoView.$el = this.$el.find('.resharerInfoView'); this.resharerInfoView.render(); + this.linkShareView.$el = this.$el.find('.linkShareView'); + this.linkShareView.render(); + this.expirationView.$el = this.$el.find('.expirationView'); this.expirationView.render(); - if(this.model.hasSharePermission()) { - this.linkShareView.$el = this.$el.find('.linkShareView'); - this.linkShareView.render(); - } - this.$el.find('.hasTooltip').tooltip(); if(this.configModel.areAvatarsEnabled()) { this.$el.find('.avatar').avatar(this.model.getReshareOwner, 32); @@ -169,17 +161,6 @@ 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; - }, - /** * * @param {string} key - an identifier for the template -- cgit v1.2.3 From fdb95613e9b133feed7b7dbad22dc289a54ef094 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 24 Aug 2015 23:20:01 +0200 Subject: simplification, and throwing where throwing is needed --- core/js/sharedialogexpirationview.js | 5 ++--- core/js/sharedialoglinkshareview.js | 8 +++----- core/js/sharedialogresharerinfoview.js | 5 ++--- core/js/sharedialogview.js | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) (limited to 'core/js/sharedialoglinkshareview.js') diff --git a/core/js/sharedialogexpirationview.js b/core/js/sharedialogexpirationview.js index e752c66bf35..4c628f5498a 100644 --- a/core/js/sharedialogexpirationview.js +++ b/core/js/sharedialogexpirationview.js @@ -48,7 +48,7 @@ if(!_.isUndefined(options.configModel)) { this.configModel = options.configModel; } else { - console.warn('missing OC.Share.ShareConfigModel'); + throw 'missing OC.Share.ShareConfigModel'; } }, @@ -64,8 +64,7 @@ } var expirationTemplate = this.template(); - this.$el.empty(); - this.$el.append(expirationTemplate({ + this.$el.html(expirationTemplate({ setExpirationLabel: t('core', 'Set expiration date'), expirationLabel: t('core', 'Expiration'), expirationDatePlaceholder: t('core', 'Expiration date'), diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js index ca6413761b0..ff22b629dc4 100644 --- a/core/js/sharedialoglinkshareview.js +++ b/core/js/sharedialoglinkshareview.js @@ -85,7 +85,7 @@ if(!_.isUndefined(options.configModel)) { this.configModel = options.configModel; } else { - console.warn('missing OC.Share.ShareConfigModel'); + throw 'missing OC.Share.ShareConfigModel'; } }, @@ -96,8 +96,7 @@ || !this.showLink || !this.configModel.isShareWithLinkAllowed()) { - this.$el.empty(); - this.$el.append(linkShareTemplate({ + this.$el.html(linkShareTemplate({ shareAllowed: false, noSharingPlaceholder: t('core', 'Resharing is not allowed') })); @@ -114,8 +113,7 @@ publicUploadChecked = 'checked="checked"'; } - this.$el.empty(); - this.$el.append(linkShareTemplate({ + this.$el.html(linkShareTemplate({ shareAllowed: true, linkShareLabel: t('core', 'Share link'), urlLabel: t('core', 'Link'), diff --git a/core/js/sharedialogresharerinfoview.js b/core/js/sharedialogresharerinfoview.js index 8970d857fc3..63df25b4ed8 100644 --- a/core/js/sharedialogresharerinfoview.js +++ b/core/js/sharedialogresharerinfoview.js @@ -58,7 +58,7 @@ if(!_.isUndefined(options.configModel)) { this.configModel = options.configModel; } else { - console.warn('missing OC.Share.ShareConfigModel'); + throw 'missing OC.Share.ShareConfigModel'; } }, @@ -90,8 +90,7 @@ ); } - this.$el.empty(); - this.$el.append(reshareTemplate({ + this.$el.html(reshareTemplate({ avatarEnabled: this.configModel.areAvatarsEnabled(), sharedByText: sharedByText })); diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index 63c3473252f..e07a5cee49a 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -81,7 +81,7 @@ if(!_.isUndefined(options.configModel)) { this.configModel = options.configModel; } else { - console.warn('missing OC.Share.ShareConfigModel'); + throw 'missing OC.Share.ShareConfigModel'; } var subViewOptions = { -- 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/sharedialoglinkshareview.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 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/sharedialoglinkshareview.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}}' + '