diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2015-09-01 12:43:04 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-09-16 07:23:27 +0200 |
commit | 5db1db38efffc2110e34886263f3a1117fe8efa5 (patch) | |
tree | 943418f57362240e5f7f0aecef6921312e122e58 /core/js/sharedialogshareelistview.js | |
parent | c17d022ca42dda31f321276f2c4973ca2e43c8a4 (diff) | |
download | nextcloud-server-5db1db38efffc2110e34886263f3a1117fe8efa5.tar.gz nextcloud-server-5db1db38efffc2110e34886263f3a1117fe8efa5.zip |
continue to reimplement sharee list view. still WIP
Diffstat (limited to 'core/js/sharedialogshareelistview.js')
-rw-r--r-- | core/js/sharedialogshareelistview.js | 113 |
1 files changed, 105 insertions, 8 deletions
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 = '<ul id="shareWithList">' + '{{#each sharees}}' + + ' {{#if isCollection}}' + + ' <li data-collection="{{collectionID}}">{{text}}</li>' + + ' {{/if}}' + + ' {{#unless isCollection}}' + ' <li data-share-type="{{shareType}}" data-share-with="{{shareWith}}" title="{{shareWith}}">' + ' <a href="#" class="unshare"><img class="svg" alt="{{unshareLabel}}" title="{{unshareLabel}}" src="{{unshareImage}}" /></a>' + ' {{#if avatarEnabled}}' + - ' <div class="avatar"></div>' + + ' <div class="avatar {{#if modSeed}}imageplaceholderseed{{/if}}" data-username="{{shareWith}}" {{#if modSeed}}data-seed="{{shareWith}} {{shareType}}"{{/if}}></div>' + ' {{/if}}' + ' <span class="username">{{shareWithDisplayName}}</span>' + ' {{#if mailPublicNotificationEnabled}} {{#unless isRemoteShare}}' + - ' <label><input type="checkbox" name="mailNotification" class="mailNotification" {{isMailSent}} />{{notifyByMailLabel}}</label>' + + ' <label><input type="checkbox" name="mailNotification" class="mailNotification" {{#if wasMailSent}}checked="checked"{{/if}} />{{notifyByMailLabel}}</label>' + ' {{/unless}} {{/if}}' + - ' {{#if isResharingAllowed}} {{#if hasSharePermission}}' + + ' {{#if isResharingAllowed}} {{#if sharePermissionPossible}}' + + ' <label><input id="canShare-{{shareWith}}" type="checkbox" name="share" class="permissions" {{#if hasSharePermission}}checked="checked"{{/if}} data-permissions="{{sharePermission}}" />{{canShareLabel}}</label>' + ' {{/if}} {{/if}}' + + ' {{#if editPermissionPossible}}' + + ' <label><input id="canEdit-{{shareWith}}" type="checkbox" name="edit" class="permissions" {{#if hasEditPermission}}checked="checked"{{/if}} />{{canEditLabel}}</label>' + + ' {{/if}}' + + ' {{#unless isRemoteShare}}' + + ' <a href="#" class="showCruds"><img class="svg" alt="{{crudsLabel}}" src="{{triangleSImage}}"/></a>' + + ' <div class="cruds" class="hidden">' + + ' {{#if createPermissionPossible}}' + + ' <label><input id="canCreate-{{shareWith}}" type="checkbox" name="create" class="permissions" {{#if hasCreatePermission}}checked="checked"{{/if}} data-permissions="{{createPermission}}"/>{{createPermissionLabel}}</label>' + + ' {{/if}}' + + ' {{#if updatePermissionPossible}}' + + ' <label><input id="canUpdate-{{shareWith}}" type="checkbox" name="update" class="permissions" {{#if hasUpdatePermission}}checked="checked"{{/if}} data-permissions="{{updatePermission}}"/>{{updatePermissionLabel}}</label>' + + ' {{/if}}' + + ' {{#if deletePermissionPossible}}' + + ' <label><input id="canDelete-{{shareWith}}" type="checkbox" name="delete" class="permissions" {{#if hasDeletePermission}}checked="checked"{{/if}} data-permissions="{{deletePermission}}"/>{{deletePermissionLabel}}</label>' + + ' {{/if}}' + + ' </div>' + + ' {{/unless}}' + ' </li>' + + ' {{/unless}}' + '{{/each}}' + '</ul>' ; @@ -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() })); |