1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-18 07:52:21 +01:00

UI permission fixes noticed when merging #457

This commit is contained in:
Thomas Tanghus 2014-04-15 14:06:44 +02:00
parent 41cdd2173d
commit 26bed15085
3 changed files with 19 additions and 10 deletions

View File

@ -29,6 +29,12 @@ OC.Contacts = OC.Contacts || {};
if(!this.hasPermission(OC.PERMISSION_UPDATE)) {
this.$li.find('a.action.edit').hide();
}
if(!this.hasPermission(OC.PERMISSION_SHARE)) {
this.$li.find('a.action.share').hide();
}
if(['local', 'ldap'].indexOf(this.getBackend() === -1)) {
this.$li.find('a.action.carddav').hide();
}
this.$li.find('input:checkbox').prop('checked', this.book.active).on('change', function() {
console.log('activate', self.getId());
var checkbox = $(this).get(0);
@ -53,7 +59,7 @@ OC.Contacts = OC.Contacts || {};
console.log('delete', self.getId());
self.destroy();
});
this.$li.find('a.action.globe').on('click keypress', function() {
this.$li.find('a.action.carddav').on('click keypress', function() {
var uri = (self.book.owner === oc_current_user ) ? self.book.uri : self.book.uri + '_shared_by_' + self.book.owner;
var link = OC.linkToRemote('carddav')+'/addressbooks/'+encodeURIComponent(oc_current_user)+'/'+encodeURIComponent(uri);
var $dropdown = $('<li><div id="dropdown" class="drop"><input type="text" value="{link}" readonly /></div></li>')

View File

@ -1488,15 +1488,18 @@ OC.Contacts = OC.Contacts || {};
}
}
});
if(this.metadata.owner !== OC.currentUser
&& !(this.hasPermission(OC.PERMISSION_UPDATE)
|| this.hasPermission(OC.PERMISSION_DELETE))) {
this.setEnabled(false);
this.showActions(['close', 'export']);
} else {
this.setEnabled(true);
this.showActions(['close', 'add', 'export', 'delete']);
var actions = ['close', 'export'];
if(this.hasPermission(OC.PERMISSION_DELETE)) {
actions.push('delete');
}
if(this.hasPermission(OC.PERMISSION_UPDATE)) {
actions.push('add');
this.setEnabled(true);
} else {
this.setEnabled(false);
}
this.showActions(actions);
return this.$fullelem;
};

View File

@ -501,7 +501,7 @@ use OCA\Contacts\ImportManager;
<span class="actions">
<a title="<?php p($l->t('Share')); ?>" class="icon-share share action" data-possible-permissions="{permissions}" data-item="{id}" data-item-type="addressbook"></a>
<a title="<?php p($l->t('Export')); ?>" class="icon-download download action"></a>
<a title="<?php p($l->t('CardDAV link')); ?>" class="icon-public globe action"></a>
<a title="<?php p($l->t('CardDAV link')); ?>" class="icon-public carddav action"></a>
<a title="<?php p($l->t('Edit')); ?>" class="icon-rename edit action"></a>
<a title="<?php p($l->t('Delete')); ?>" class="icon-delete delete action"></a>
</span>