Clean up in the dropdown for unsharing
This commit is contained in:
parent
1e36e1f2cb
commit
5e8ef33190
|
@ -6,9 +6,9 @@
|
||||||
-moz-box-shadow:0 1px 1px #777; -webkit-box-shadow:0 1px 1px #777; box-shadow:0 1px 1px #777;
|
-moz-box-shadow:0 1px 1px #777; -webkit-box-shadow:0 1px 1px #777; box-shadow:0 1px 1px #777;
|
||||||
-moz-border-radius-bottomleft:1em; -webkit-border-bottom-left-radius:1em; border-bottom-left-radius:1em;
|
-moz-border-radius-bottomleft:1em; -webkit-border-bottom-left-radius:1em; border-bottom-left-radius:1em;
|
||||||
-moz-border-radius-bottomright:1em; -webkit-border-bottom-right-radius:1em; border-bottom-right-radius:1em; }
|
-moz-border-radius-bottomright:1em; -webkit-border-bottom-right-radius:1em; border-bottom-right-radius:1em; }
|
||||||
#sharedWithList { padding:0.5em; list-style-type: none; }
|
#shareWithList { padding:0.5em; list-style-type: none; }
|
||||||
#privateLink { border-top:1px solid #ddd; padding-top:0.5em; }
|
#privateLink { border-top:1px solid #ddd; padding-top:0.5em; }
|
||||||
a.unshare { float:right; display:inline; margin:0 .5em; padding:.3em .3em 0 .3em !important; opacity:.5; }
|
a.unshare { float:right; display:inline; padding:.3em 0 0 .3em !important; opacity:.5; }
|
||||||
a.unshare:hover { opacity:1; }
|
a.unshare:hover { opacity:1; }
|
||||||
#share_with { width: 16em; }
|
#share_with { width: 16em; }
|
||||||
#privateLink label, .edit { font-weight:normal; }
|
#privateLink label, .edit { font-weight:normal; }
|
||||||
|
|
|
@ -47,7 +47,8 @@ if (isset($_POST['action'])) {
|
||||||
$return = OCP\Share::getItemsShared($_GET['itemType'], OCP\Share::FORMAT_STATUSES);
|
$return = OCP\Share::getItemsShared($_GET['itemType'], OCP\Share::FORMAT_STATUSES);
|
||||||
($return) ? OC_JSON::success(array('data' => $return)) : OC_JSON::error();
|
($return) ? OC_JSON::success(array('data' => $return)) : OC_JSON::error();
|
||||||
break;
|
break;
|
||||||
case 'getItemShared':
|
case 'getItem':
|
||||||
|
// TODO Check if the item was shared to the current user
|
||||||
$return = OCP\Share::getItemShared($_GET['itemType'], $_GET['item']);
|
$return = OCP\Share::getItemShared($_GET['itemType'], $_GET['item']);
|
||||||
($return) ? OC_JSON::success(array('data' => $return)) : OC_JSON::error();
|
($return) ? OC_JSON::success(array('data' => $return)) : OC_JSON::error();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -25,7 +25,7 @@ OC.Share={
|
||||||
},
|
},
|
||||||
loadItem:function(itemType, item) {
|
loadItem:function(itemType, item) {
|
||||||
var data = '';
|
var data = '';
|
||||||
$.ajax({type: 'GET', url: OC.filePath('core', 'ajax', 'share.php'), data: { fetch: 'getItemShared', itemType: itemType, item: item }, async: false, success: function(result) {
|
$.ajax({type: 'GET', url: OC.filePath('core', 'ajax', 'share.php'), data: { fetch: 'getItem', itemType: itemType, item: item }, async: false, success: function(result) {
|
||||||
if (result && result.status === 'success') {
|
if (result && result.status === 'success') {
|
||||||
data = result.data;
|
data = result.data;
|
||||||
} else {
|
} else {
|
||||||
|
@ -45,8 +45,8 @@ OC.Share={
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
unshare:function(itemType, shareType, shareWith, callback) {
|
unshare:function(itemType, item, shareType, shareWith, callback) {
|
||||||
$.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'unshare', itemType: itemType, shareType: shareType, shareWith: shareWith }, function(result) {
|
$.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'unshare', itemType: itemType, item: item, shareType: shareType, shareWith: shareWith }, function(result) {
|
||||||
if (result && result.status === 'success') {
|
if (result && result.status === 'success') {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback();
|
callback();
|
||||||
|
@ -67,15 +67,8 @@ OC.Share={
|
||||||
var html = '<div id="dropdown" class="drop" data-item-type="'+itemType+'" data-item="'+item+'">';
|
var html = '<div id="dropdown" class="drop" data-item-type="'+itemType+'" data-item="'+item+'">';
|
||||||
// TODO replace with autocomplete textbox
|
// TODO replace with autocomplete textbox
|
||||||
html += '<input id="shareWith" type="text" placeholder="Share with" />';
|
html += '<input id="shareWith" type="text" placeholder="Share with" />';
|
||||||
html += '<div id="sharedWithList">';
|
html += '<ul id="shareWithList">';
|
||||||
var sharedWith = OC.Share.loadItem(itemType, item);
|
html += '</ul>';
|
||||||
if (sharedWith) {
|
|
||||||
$.each(sharedWith, function(index, row) {
|
|
||||||
html += row.share_with;
|
|
||||||
html += '<br />';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
html += '</div>';
|
|
||||||
html += '<div id="privateLink">';
|
html += '<div id="privateLink">';
|
||||||
html += '<input type="checkbox" name="privateLinkCheckbox" id="privateLinkCheckbox" value="1" /><label for="privateLinkCheckbox">Share with private link</label>';
|
html += '<input type="checkbox" name="privateLinkCheckbox" id="privateLinkCheckbox" value="1" /><label for="privateLinkCheckbox">Share with private link</label>';
|
||||||
html += '<br />';
|
html += '<br />';
|
||||||
|
@ -86,6 +79,14 @@ OC.Share={
|
||||||
html += '</form>';
|
html += '</form>';
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
$(html).appendTo(appendTo);
|
$(html).appendTo(appendTo);
|
||||||
|
var data = OC.Share.loadItem(itemType, item);
|
||||||
|
if (data) {
|
||||||
|
$.each(data, function(index, shares) {
|
||||||
|
$.each(shares, function(id, share) {
|
||||||
|
OC.Share.addShareWith(share.share_with, share.permissions);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
$('#dropdown').show('blind');
|
$('#dropdown').show('blind');
|
||||||
$('#share_with').chosen();
|
$('#share_with').chosen();
|
||||||
},
|
},
|
||||||
|
@ -97,54 +98,16 @@ OC.Share={
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
addSharedWith:function(uid_shared_with, permissions, isGroup, parentFolder) {
|
addShareWith:function(shareWith, permissions) {
|
||||||
if (parentFolder) {
|
|
||||||
var sharedWith = '<li>Parent folder '+parentFolder+' shared with '+uid_shared_with+'</li>';
|
|
||||||
} else {
|
|
||||||
var checked = ((permissions > 0) ? 'checked="checked"' : 'style="display:none;"');
|
var checked = ((permissions > 0) ? 'checked="checked"' : 'style="display:none;"');
|
||||||
var style = ((permissions == 0) ? 'style="display:none;"' : '');
|
var style = ((permissions == 0) ? 'style="display:none;"' : '');
|
||||||
var sharedWith = '<li data-uid_shared_with="'+uid_shared_with+'">';
|
var html = '<li >';
|
||||||
sharedWith += '<a href="" class="unshare" style="display:none;"><img class="svg" alt="Unshare" src="'+OC.imagePath('core','actions/delete')+'"/></a>';
|
html += shareWith;
|
||||||
sharedWith += uid_shared_with;
|
html += '<a href="" class="unshare" data-share-with="'+shareWith+'" style="display:none;"><img class="svg" alt="Unshare" src="'+OC.imagePath('core','actions/delete')+'"/></a>';
|
||||||
sharedWith += '<input type="checkbox" name="permissions" id="'+uid_shared_with+'" class="permissions" '+checked+' />';
|
html += '</li>';
|
||||||
sharedWith += '<label class="edit" for="'+uid_shared_with+'" '+style+'>can edit</label>';
|
$(html).appendTo('#shareWithList');
|
||||||
sharedWith += '</li>';
|
|
||||||
}
|
|
||||||
if (isGroup) {
|
|
||||||
// Groups are added to a different list
|
|
||||||
$('#groups').show();
|
|
||||||
$(sharedWith).appendTo('#groupList');
|
|
||||||
// Remove group from select form
|
|
||||||
$('#share_with option[value="'+uid_shared_with+'(group)"]').remove();
|
|
||||||
$('#share_with').trigger('liszt:updated');
|
|
||||||
// Remove users in group from select form
|
|
||||||
$.each(isGroup, function(index, user) {
|
|
||||||
$('#share_with option[value="'+user+'"]').remove();
|
|
||||||
$('#share_with').trigger('liszt:updated');
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$(sharedWith).appendTo('#userList');
|
|
||||||
// Remove user from select form
|
|
||||||
$('#share_with option[value="'+uid_shared_with+'"]').remove();
|
|
||||||
$('#share_with').trigger('liszt:updated');
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
},
|
||||||
removeSharedWith:function(uid_shared_with) {
|
|
||||||
var option;
|
|
||||||
if ($('#userList li[data-uid_shared_with="'+uid_shared_with+'"]').length > 0) {
|
|
||||||
$('#userList li[data-uid_shared_with="'+uid_shared_with+'"]').remove();
|
|
||||||
option = '<option value="'+uid_shared_with+'">'+uid_shared_with+'</option>';
|
|
||||||
} else if ($('#groupList li[data-uid_shared_with="'+uid_shared_with+'"]').length > 0) {
|
|
||||||
$('#groupList li[data-uid_shared_with="'+uid_shared_with+'"]').remove();
|
|
||||||
if ($('#groupList li').length < 1) {
|
|
||||||
$('#groups').hide();
|
|
||||||
}
|
|
||||||
option = '<option value="'+uid_shared_with+'(group)">'+uid_shared_with+' (group)</option>';
|
|
||||||
}
|
|
||||||
$(option).appendTo('#share_with');
|
|
||||||
$('#share_with').trigger('liszt:updated');
|
|
||||||
},
|
|
||||||
showPrivateLink:function(item, token) {
|
showPrivateLink:function(item, token) {
|
||||||
$('#privateLinkCheckbox').attr('checked', true);
|
$('#privateLinkCheckbox').attr('checked', true);
|
||||||
var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=files&token='+token;
|
var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=files&token='+token;
|
||||||
|
@ -244,12 +207,12 @@ $(document).ready(function() {
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
$('#sharedWithList li').live('mouseenter', function(event) {
|
$('#shareWithList li').live('mouseenter', function(event) {
|
||||||
// Show permissions and unshare button
|
// Show permissions and unshare button
|
||||||
$(':hidden', this).show();
|
$(':hidden', this).show();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#sharedWithList li').live('mouseleave', function(event) {
|
$('#shareWithList li').live('mouseleave', function(event) {
|
||||||
// Hide permissions and unshare button
|
// Hide permissions and unshare button
|
||||||
$('a', this).hide();
|
$('a', this).hide();
|
||||||
if (!$('input:[type=checkbox]', this).is(':checked')) {
|
if (!$('input:[type=checkbox]', this).is(':checked')) {
|
||||||
|
@ -263,16 +226,9 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.unshare').live('click', function() {
|
$('.unshare').live('click', function() {
|
||||||
var item = $('#dropdown').data('item');
|
var li = $(this).parent();
|
||||||
var uid_shared_with = $(this).parent().data('uid_shared_with');
|
OC.Share.unshare($('#dropdown').data('item-type'), $('#dropdown').data('item'), 0, $(this).data('share-with'), function() {
|
||||||
OC.Share.unshare(item, uid_shared_with, function() {
|
$(li).remove();
|
||||||
OC.Share.removeSharedWith(uid_shared_with);
|
|
||||||
// Reload item to update cached users and groups for the icon check
|
|
||||||
OC.Share.loadItem(item);
|
|
||||||
// Change icon
|
|
||||||
if (!OC.Share.itemPrivateLink && !OC.Share.itemUsers && !OC.Share.itemGroups) {
|
|
||||||
OC.Share.icons[item] = OC.imagePath('core', 'actions/share');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -479,7 +479,7 @@ class Share {
|
||||||
if (isset($uidOwner)) {
|
if (isset($uidOwner)) {
|
||||||
$select = 'id, item_type, item, item_source, share_type, share_with, permissions, stime, file_source';
|
$select = 'id, item_type, item, item_source, share_type, share_with, permissions, stime, file_source';
|
||||||
} else {
|
} else {
|
||||||
$select = 'id, item_type, item, item_source, item_target, share_type, share_with, permissions, stime, file_source, file_target';
|
$select = '*';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$query = \OC_DB::prepare('SELECT '.$select.' FROM *PREFIX*share '.$where);
|
$query = \OC_DB::prepare('SELECT '.$select.' FROM *PREFIX*share '.$where);
|
||||||
|
|
Loading…
Reference in New Issue