Merge pull request #5381 from owncloud/files-sharingstateafterupload

Fixed sharing status update for new/uploaded files
This commit is contained in:
Morris Jobke 2013-10-17 05:51:12 -07:00
commit 01349850b0
5 changed files with 85 additions and 48 deletions

View File

@ -539,7 +539,7 @@ $(document).ready(function() {
lazyLoadPreview(path, result.data.mime, function(previewpath){
tr.find('td.filename').attr('style','background-image:url('+previewpath+')');
});
FileActions.display(tr.find('td.filename'));
FileActions.display(tr.find('td.filename'), true);
} else {
OC.dialogs.alert(result.data.message, t('core', 'Error'));
}

View File

@ -61,7 +61,13 @@ var FileActions = {
var actions = this.get(mime, type, permissions);
return actions[name];
},
display: function (parent) {
/**
* Display file actions for the given element
* @param parent "td" element of the file for which to display actions
* @param triggerEvent if true, triggers the fileActionsReady on the file
* list afterwards (false by default)
*/
display: function (parent, triggerEvent) {
FileActions.currentFile = parent;
var actions = FileActions.get(FileActions.getCurrentMimeType(), FileActions.getCurrentType(), FileActions.getCurrentPermissions());
var file = FileActions.getCurrentFile();
@ -137,6 +143,10 @@ var FileActions = {
element.on('click', {a: null, elem: parent, actionFunc: actions['Delete']}, actionHandler);
parent.parent().children().last().append(element);
}
if (triggerEvent){
$('#fileList').trigger(jQuery.Event("fileActionsReady"));
}
},
getCurrentFile: function () {
return FileActions.currentFile.parent().attr('data-file');

View File

@ -151,7 +151,7 @@ var FileList={
if (hidden) {
tr.hide();
}
FileActions.display(tr.find('td.filename'));
FileActions.display(tr.find('td.filename'), true);
return tr;
},
/**
@ -817,7 +817,7 @@ $(document).ready(function(){
data.context.attr('data-permissions', file.permissions);
data.context.data('permissions', file.permissions);
}
FileActions.display(data.context.find('td.filename'));
FileActions.display(data.context.find('td.filename'), true);
var path = getPathForPreview(file.name);
lazyLoadPreview(path, file.mime, function(previewpath){

View File

@ -1,11 +1,19 @@
$(document).ready(function() {
var disableSharing = $('#disableSharing').data('status');
var disableSharing = $('#disableSharing').data('status'),
sharesLoaded = false;
if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined' && !disableSharing) {
$('#fileList').on('fileActionsReady',function(){
if (!sharesLoaded){
OC.Share.loadIcons('file');
// assume that we got all shares, so switching directories
// will not invalidate that list
sharesLoaded = true;
}
else{
OC.Share.updateIcons('file');
}
});
FileActions.register('all', 'Share', OC.PERMISSION_READ, OC.imagePath('core', 'actions/share'), function(filename) {

View File

@ -4,14 +4,35 @@ OC.Share={
SHARE_TYPE_LINK:3,
SHARE_TYPE_EMAIL:4,
itemShares:[],
statuses:[],
statuses:{},
droppedDown:false,
/**
* Loads ALL share statuses from server, stores them in OC.Share.statuses then
* calls OC.Share.updateIcons() to update the files "Share" icon to "Shared"
* according to their share status and share type.
*/
loadIcons:function(itemType) {
// Load all share icons
$.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getItemsSharedStatuses', itemType: itemType }, function(result) {
if (result && result.status === 'success') {
OC.Share.statuses = {};
$.each(result.data, function(item, data) {
OC.Share.statuses[item] = data;
});
OC.Share.updateIcons(itemType);
}
});
},
/**
* Updates the files' "Share" icons according to the known
* sharing states stored in OC.Share.statuses.
* (not reloaded from server)
*/
updateIcons:function(itemType){
var item;
for (item in OC.Share.statuses){
var data = OC.Share.statuses[item];
var hasLink = data['link'];
// Links override shared in terms of icon display
if (hasLink) {
@ -52,9 +73,7 @@ OC.Share={
}
}
}
});
}
});
},
updateIcon:function(itemType, itemSource) {
var shares = false;