diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-09-09 14:44:08 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-09-09 14:44:08 -0400 |
commit | 6c17a4cb77f50ce851ce8f3bc9a94f7f40967df0 (patch) | |
tree | d57bf8e495d3d52beb7797e0e8b205880cf05afa /core/js | |
parent | 13d513c17c264a3bbb1b2c874bb742afbce76e10 (diff) | |
download | nextcloud-server-6c17a4cb77f50ce851ce8f3bc9a94f7f40967df0.tar.gz nextcloud-server-6c17a4cb77f50ce851ce8f3bc9a94f7f40967df0.zip |
Don't display actions for children in shared collections, show the parent collection the child is shared in
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/share.js | 103 |
1 files changed, 61 insertions, 42 deletions
diff --git a/core/js/share.js b/core/js/share.js index b5e8b0e6613..535ae6da995 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -71,7 +71,8 @@ OC.Share={ var item = itemSource; } if (typeof OC.Share.statuses[item] === 'undefined') { - checkShares = false; + // NOTE: Check doesn't always work and misses some shares, fix later + checkShares = true; } else { checkShares = true; } @@ -149,7 +150,11 @@ OC.Share={ if (share.share_type == OC.Share.SHARE_TYPE_LINK) { OC.Share.showLink(itemSource, share.share_with); } else { - OC.Share.addShareWith(share.share_type, share.share_with, share.permissions, possiblePermissions); + if (share.collection) { + OC.Share.addShareWith(share.share_type, share.share_with, share.permissions, possiblePermissions, share.collection); + } else { + OC.Share.addShareWith(share.share_type, share.share_with, share.permissions, possiblePermissions, false); + } } }); } @@ -213,56 +218,70 @@ OC.Share={ } }); }, - addShareWith:function(shareType, shareWith, permissions, possiblePermissions) { + addShareWith:function(shareType, shareWith, permissions, possiblePermissions, collection) { if (!OC.Share.itemShares[shareType]) { OC.Share.itemShares[shareType] = []; } OC.Share.itemShares[shareType].push(shareWith); - 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 = '<li style="clear: both;" data-share-type="'+shareType+'" data-share-with="'+shareWith+'">'; - html += shareWith; - if (possiblePermissions & OC.PERMISSION_CREATE || possiblePermissions & OC.PERMISSION_UPDATE || possiblePermissions & OC.PERMISSION_DELETE) { - if (editChecked == '') { - html += '<label style="display:none;">'; + if (collection) { + if (collection.item_type == 'file' || collection.item_type == 'folder') { + var item = collection.path; } else { - html += '<label>'; + var item = collection.item_source; } - html += '<input type="checkbox" name="edit" class="permissions" '+editChecked+' />can edit</label>'; - } - html += '<a href="#" class="showCruds" style="display:none;"><img class="svg" alt="Unshare" src="'+OC.imagePath('core', 'actions/triangle-s')+'"/></a>'; - html += '<a href="#" class="unshare" style="display:none;"><img class="svg" alt="Unshare" src="'+OC.imagePath('core', 'actions/delete')+'"/></a>'; - html += '<div class="cruds" style="display:none;">'; - if (possiblePermissions & OC.PERMISSION_CREATE) { - html += '<label><input type="checkbox" name="create" class="permissions" '+createChecked+' data-permissions="'+OC.PERMISSION_CREATE+'" />create</label>'; + var collectionList = $('#shareWithList li').filterAttr('data-collection', item); + if (collectionList.length > 0) { + $(collectionList).append(', '+shareWith); + } else { + var html = '<li style="clear: both;" data-collection="'+item+'">Shared in '+item+' with '+shareWith+'</li>'; + $('#shareWithList').prepend(html); } - if (possiblePermissions & OC.PERMISSION_UPDATE) { - html += '<label><input type="checkbox" name="update" class="permissions" '+updateChecked+' data-permissions="'+OC.PERMISSION_UPDATE+'" />update</label>'; + } else { + var editChecked = createChecked = updateChecked = deleteChecked = shareChecked = ''; + if (permissions & OC.PERMISSION_CREATE) { + createChecked = 'checked="checked"'; + editChecked = 'checked="checked"'; } - if (possiblePermissions & OC.PERMISSION_DELETE) { - html += '<label><input type="checkbox" name="delete" class="permissions" '+deleteChecked+' data-permissions="'+OC.PERMISSION_DELETE+'" />delete</label>'; + if (permissions & OC.PERMISSION_UPDATE) { + updateChecked = 'checked="checked"'; + editChecked = 'checked="checked"'; } - if (possiblePermissions & OC.PERMISSION_SHARE) { - html += '<label><input type="checkbox" name="share" class="permissions" '+shareChecked+' data-permissions="'+OC.PERMISSION_SHARE+'" />share</label>'; + if (permissions & OC.PERMISSION_DELETE) { + deleteChecked = 'checked="checked"'; + editChecked = 'checked="checked"'; } - html += '</div>'; - html += '</li>'; - $(html).appendTo('#shareWithList'); - + if (permissions & OC.PERMISSION_SHARE) { + shareChecked = 'checked="checked"'; + } + var html = '<li style="clear: both;" data-share-type="'+shareType+'" data-share-with="'+shareWith+'">'; + html += shareWith; + if (possiblePermissions & OC.PERMISSION_CREATE || possiblePermissions & OC.PERMISSION_UPDATE || possiblePermissions & OC.PERMISSION_DELETE) { + if (editChecked == '') { + html += '<label style="display:none;">'; + } else { + html += '<label>'; + } + html += '<input type="checkbox" name="edit" class="permissions" '+editChecked+' />can edit</label>'; + } + html += '<a href="#" class="showCruds" style="display:none;"><img class="svg" alt="Unshare" src="'+OC.imagePath('core', 'actions/triangle-s')+'"/></a>'; + html += '<a href="#" class="unshare" style="display:none;"><img class="svg" alt="Unshare" src="'+OC.imagePath('core', 'actions/delete')+'"/></a>'; + html += '<div class="cruds" style="display:none;">'; + if (possiblePermissions & OC.PERMISSION_CREATE) { + html += '<label><input type="checkbox" name="create" class="permissions" '+createChecked+' data-permissions="'+OC.PERMISSION_CREATE+'" />create</label>'; + } + if (possiblePermissions & OC.PERMISSION_UPDATE) { + html += '<label><input type="checkbox" name="update" class="permissions" '+updateChecked+' data-permissions="'+OC.PERMISSION_UPDATE+'" />update</label>'; + } + if (possiblePermissions & OC.PERMISSION_DELETE) { + html += '<label><input type="checkbox" name="delete" class="permissions" '+deleteChecked+' data-permissions="'+OC.PERMISSION_DELETE+'" />delete</label>'; + } + if (possiblePermissions & OC.PERMISSION_SHARE) { + html += '<label><input type="checkbox" name="share" class="permissions" '+shareChecked+' data-permissions="'+OC.PERMISSION_SHARE+'" />share</label>'; + } + html += '</div>'; + html += '</li>'; + $(html).appendTo('#shareWithList'); + } }, showLink:function(itemSource, password) { $('#linkCheckbox').attr('checked', true); |