mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 09:42:09 -04:00
old OC.Share.addShareWith now reimplemented
This commit is contained in:
parent
44ecdde10d
commit
60abfcdab1
3 changed files with 27 additions and 133 deletions
106
core/js/share.js
106
core/js/share.js
|
|
@ -685,112 +685,6 @@ OC.Share = _.extend(OC.Share, {
|
|||
}
|
||||
});
|
||||
},
|
||||
addShareWith:function(shareType, shareWith, shareWithDisplayName, permissions, possiblePermissions, mailSend, collection) {
|
||||
var shareItem = {
|
||||
share_type: shareType,
|
||||
share_with: shareWith,
|
||||
share_with_displayname: shareWithDisplayName,
|
||||
permissions: permissions
|
||||
};
|
||||
if (shareType === OC.Share.SHARE_TYPE_GROUP) {
|
||||
shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'group') + ')';
|
||||
}
|
||||
if (shareType === OC.Share.SHARE_TYPE_REMOTE) {
|
||||
shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'remote') + ')';
|
||||
}
|
||||
if (!OC.Share.itemShares[shareType]) {
|
||||
OC.Share.itemShares[shareType] = [];
|
||||
}
|
||||
OC.Share.itemShares[shareType].push(shareWith);
|
||||
if (collection) {
|
||||
if (collection.item_type == 'file' || collection.item_type == 'folder') {
|
||||
var item = collection.path;
|
||||
} else {
|
||||
var item = collection.item_source;
|
||||
}
|
||||
var collectionList = $('#shareWithList li').filterAttr('data-collection', item);
|
||||
if (collectionList.length > 0) {
|
||||
$(collectionList).append(', '+shareWithDisplayName);
|
||||
} else {
|
||||
var html = '<li style="clear: both;" data-collection="'+item+'">'+t('core', 'Shared in {item} with {user}', {'item': item, user: shareWithDisplayName})+'</li>';
|
||||
$('#shareWithList').prepend(html);
|
||||
}
|
||||
} else {
|
||||
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="'+escapeHTML(shareType)+'" data-share-with="'+escapeHTML(shareWith)+'" title="' + escapeHTML(shareWith) + '">';
|
||||
var showCrudsButton;
|
||||
html += '<a href="#" class="unshare"><img class="svg" alt="'+t('core', 'Unshare')+'" title="'+t('core', 'Unshare')+'" src="'+OC.imagePath('core', 'actions/delete')+'"/></a>';
|
||||
if (oc_config.enable_avatars === true) {
|
||||
html += '<div class="avatar"></div>';
|
||||
}
|
||||
html += '<span class="username">' + escapeHTML(shareWithDisplayName) + '</span>';
|
||||
var mailNotificationEnabled = $('input:hidden[name=mailNotificationEnabled]').val();
|
||||
if (mailNotificationEnabled === 'yes' && shareType !== OC.Share.SHARE_TYPE_REMOTE) {
|
||||
var checked = '';
|
||||
if (mailSend === '1') {
|
||||
checked = 'checked';
|
||||
}
|
||||
html += '<label><input type="checkbox" name="mailNotification" class="mailNotification" ' + checked + ' />'+t('core', 'notify by email')+'</label> ';
|
||||
}
|
||||
if (oc_appconfig.core.resharingAllowed && (possiblePermissions & OC.PERMISSION_SHARE)) {
|
||||
html += '<label><input id="canShare-'+escapeHTML(shareWith)+'" type="checkbox" name="share" class="permissions" '+shareChecked+' data-permissions="'+OC.PERMISSION_SHARE+'" />'+t('core', 'can share')+'</label>';
|
||||
}
|
||||
if (possiblePermissions & OC.PERMISSION_CREATE || possiblePermissions & OC.PERMISSION_UPDATE || possiblePermissions & OC.PERMISSION_DELETE) {
|
||||
html += '<label><input id="canEdit-'+escapeHTML(shareWith)+'" type="checkbox" name="edit" class="permissions" '+editChecked+' />'+t('core', 'can edit')+'</label>';
|
||||
}
|
||||
if (shareType !== OC.Share.SHARE_TYPE_REMOTE) {
|
||||
showCrudsButton = '<a href="#" class="showCruds"><img class="svg" alt="'+t('core', 'access control')+'" src="'+OC.imagePath('core', 'actions/triangle-s')+'"/></a>';
|
||||
}
|
||||
html += '<div class="cruds" style="display:none;">';
|
||||
if (possiblePermissions & OC.PERMISSION_CREATE) {
|
||||
html += '<label><input id="canCreate-' + escapeHTML(shareWith) + '" type="checkbox" name="create" class="permissions" ' + createChecked + ' data-permissions="' + OC.PERMISSION_CREATE + '"/>' + t('core', 'create') + '</label>';
|
||||
}
|
||||
if (possiblePermissions & OC.PERMISSION_UPDATE) {
|
||||
html += '<label><input id="canUpdate-' + escapeHTML(shareWith) + '" type="checkbox" name="update" class="permissions" ' + updateChecked + ' data-permissions="' + OC.PERMISSION_UPDATE + '"/>' + t('core', 'change') + '</label>';
|
||||
}
|
||||
if (possiblePermissions & OC.PERMISSION_DELETE) {
|
||||
html += '<label><input id="canDelete-' + escapeHTML(shareWith) + '" type="checkbox" name="delete" class="permissions" ' + deleteChecked + ' data-permissions="' + OC.PERMISSION_DELETE + '"/>' + t('core', 'delete') + '</label>';
|
||||
}
|
||||
html += '</div>';
|
||||
html += '</li>';
|
||||
html = $(html).appendTo('#shareWithList');
|
||||
if (oc_config.enable_avatars === true) {
|
||||
if (shareType === OC.Share.SHARE_TYPE_USER) {
|
||||
html.find('.avatar').avatar(escapeHTML(shareWith), 32);
|
||||
} else {
|
||||
//Add sharetype to generate different seed if there is a group and use with the same name
|
||||
html.find('.avatar').imageplaceholder(escapeHTML(shareWith) + ' ' + shareType);
|
||||
}
|
||||
}
|
||||
// insert cruds button into last label element
|
||||
var lastLabel = html.find('>label:last');
|
||||
if (lastLabel.exists()){
|
||||
lastLabel.append(showCrudsButton);
|
||||
}
|
||||
else{
|
||||
html.find('.cruds').before(showCrudsButton);
|
||||
}
|
||||
if (!OC.Share.currentShares[shareType]) {
|
||||
OC.Share.currentShares[shareType] = [];
|
||||
}
|
||||
OC.Share.currentShares[shareType].push(shareItem);
|
||||
}
|
||||
},
|
||||
showLink:function(token, password, itemSource) {
|
||||
OC.Share.itemShares[OC.Share.SHARE_TYPE_LINK] = true;
|
||||
$('#linkCheckbox').attr('checked', true);
|
||||
|
|
|
|||
|
|
@ -111,18 +111,6 @@
|
|||
}
|
||||
},
|
||||
|
||||
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
|
||||
|
|
@ -149,7 +137,8 @@
|
|||
shareWith: shareWith,
|
||||
shareWithDisplayName: shareWithDisplayName,
|
||||
shareType: shareType,
|
||||
modSeed: shareType !== OC.Share.SHARE_TYPE_USER
|
||||
modSeed: shareType !== OC.Share.SHARE_TYPE_USER,
|
||||
isRemoteShare: shareType === OC.Share.SHARE_TYPE_REMOTE
|
||||
};
|
||||
},
|
||||
|
||||
|
|
@ -181,9 +170,6 @@
|
|||
|
||||
this._collections = {};
|
||||
|
||||
// TODO: sharess must have following attributes
|
||||
// isRemoteShare
|
||||
|
||||
if(!this.model.hasShares()) {
|
||||
return [];
|
||||
}
|
||||
|
|
@ -191,16 +177,6 @@
|
|||
var shares = this.model.get('shares');
|
||||
var list = [];
|
||||
for(var index = 0; index < shares.length; index++) {
|
||||
|
||||
// #### FIXME: LEGACY ####
|
||||
// this does not belong to a view
|
||||
var shareType = this.model.getShareType(index);
|
||||
if (!OC.Share.currentShares[shareType]) {
|
||||
OC.Share.currentShares[shareType] = [];
|
||||
}
|
||||
OC.Share.currentShares[shareType].push(this.model.getShareWith(index));
|
||||
// #### /FIXME: LEGACY ####
|
||||
|
||||
if(this.model.isCollection(index)) {
|
||||
this.processCollectionShare(index);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -350,6 +350,27 @@
|
|||
});
|
||||
},
|
||||
|
||||
legacyFillCurrentShares: function(shares) {
|
||||
OC.Share.currentShares = {};
|
||||
OC.Share.itemShares = [];
|
||||
_.each(shares,
|
||||
/**
|
||||
* @param {OC.Share.Types.ShareInfo} share
|
||||
*/
|
||||
function(share) {
|
||||
if (!OC.Share.currentShares[share.share_type]) {
|
||||
OC.Share.currentShares[share.share_type] = [];
|
||||
}
|
||||
OC.Share.currentShares[share.share_type].push(share);
|
||||
|
||||
if (!OC.Share.itemShares[share.share_type]) {
|
||||
OC.Share.itemShares[share.share_type] = [];
|
||||
}
|
||||
OC.Share.itemShares[share.share_type].push(share.share_with);
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
parse: function(data) {
|
||||
if(data === false) {
|
||||
console.warn('no data was returned');
|
||||
|
|
@ -372,9 +393,12 @@
|
|||
});
|
||||
}
|
||||
|
||||
var shares = _.toArray(data.shares);
|
||||
this.legacyFillCurrentShares(shares);
|
||||
|
||||
return {
|
||||
reshare: data.reshare,
|
||||
shares: _.toArray(data.shares),
|
||||
shares: shares,
|
||||
permissions: permissions,
|
||||
allowPublicUploadStatus: allowPublicUploadStatus
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue