1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-12-01 13:24:10 +01:00

Fix being able to link directly to contact, that I broke in other commit.

This commit is contained in:
Thomas Tanghus 2012-06-21 22:02:17 +02:00
parent b3b67ab2cb
commit a48debb3c9
3 changed files with 8 additions and 5 deletions

View File

@ -256,12 +256,14 @@ Contacts={
} }
} else { } else {
newid = id; newid = id;
bookid = bookid?bookid:$('#contacts li[data-id="'+newid+'"]').data('bookid');
} }
var localLoadContact = function(newid, bookid) { var localLoadContact = function(newid, bookid) {
if($('.contacts li').length > 0) { if($('.contacts li').length > 0) {
firstitem.addClass('active'); $('#contacts li[data-id="'+newid+'"]').addClass('active');
$.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':newid},function(jsondata){ $.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':newid},function(jsondata){
if(jsondata.status == 'success'){ if(jsondata.status == 'success'){
$('#contacts h3[data-id="'+bookid+'"]').trigger('click');
Contacts.UI.Card.loadContact(jsondata.data, bookid); Contacts.UI.Card.loadContact(jsondata.data, bookid);
} else { } else {
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
@ -1503,7 +1505,7 @@ Contacts={
}, },
Contacts:{ Contacts:{
// Reload the contacts list. // Reload the contacts list.
update:function(){ update:function(id){
$.getJSON(OC.filePath('contacts', 'ajax', 'contacts.php'),{},function(jsondata){ $.getJSON(OC.filePath('contacts', 'ajax', 'contacts.php'),{},function(jsondata){
if(jsondata.status == 'success'){ if(jsondata.status == 'success'){
$('#contacts').html(jsondata.data.page).ready(function() { $('#contacts').html(jsondata.data.page).ready(function() {
@ -1518,7 +1520,7 @@ Contacts={
})}, 100); })}, 100);
setTimeout(Contacts.UI.Contacts.lazyupdate, 500);*/ setTimeout(Contacts.UI.Contacts.lazyupdate, 500);*/
}); });
Contacts.UI.Card.update(); Contacts.UI.Card.update(id);
} }
else{ else{
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
@ -1707,5 +1709,5 @@ $(document).ready(function(){
$('#contacts_propertymenu_dropdown a').keydown(propertyMenuItem); $('#contacts_propertymenu_dropdown a').keydown(propertyMenuItem);
Contacts.UI.loadHandlers(); Contacts.UI.loadHandlers();
Contacts.UI.Contacts.update(); Contacts.UI.Contacts.update(id);
}); });

View File

@ -1,6 +1,7 @@
<script type='text/javascript'> <script type='text/javascript'>
var totalurl = '<?php echo OCP\Util::linkToRemote('carddav'); ?>addressbooks'; var totalurl = '<?php echo OCP\Util::linkToRemote('carddav'); ?>addressbooks';
var categories = <?php echo json_encode($_['categories']); ?>; var categories = <?php echo json_encode($_['categories']); ?>;
var id = <?php echo $_['id']; ?>;
var lang = '<?php echo OCP\Config::getUserValue(OCP\USER::getUser(), 'core', 'lang', 'en'); ?>'; var lang = '<?php echo OCP\Config::getUserValue(OCP\USER::getUser(), 'core', 'lang', 'en'); ?>';
</script> </script>
<div id="leftcontent"> <div id="leftcontent">

View File

@ -3,7 +3,7 @@ foreach($_['books'] as $id => $addressbook) {
echo '<h3 class="addressbook" data-id="'.$id.'">'.$addressbook['displayname'].'</h3>'; echo '<h3 class="addressbook" data-id="'.$id.'">'.$addressbook['displayname'].'</h3>';
echo '<ul class="contacts hidden" data-id="'.$id.'">'; echo '<ul class="contacts hidden" data-id="'.$id.'">';
foreach($addressbook['contacts'] as $contact) { foreach($addressbook['contacts'] as $contact) {
echo '<li role="button" data-bookid="'.$contact['addressbookid'].'" data-id="'.$contact['id'].'"><a href="index.php?id='.$contact['id'].'" style="background: url('.link_to('contacts','thumbnail.php').'?id='.$contact['id'].') no-repeat scroll 0 0 transparent;">'.$contact['displayname'].'</a></li>'; echo '<li role="button" data-bookid="'.$contact['addressbookid'].'" data-id="'.$contact['id'].'"><a href="'.link_to('contacts','index.php').'&id='.$contact['id'].'" style="background: url('.link_to('contacts','thumbnail.php').'?id='.$contact['id'].') no-repeat scroll 0 0 transparent;">'.$contact['displayname'].'</a></li>';
} }
echo '</ul>'; echo '</ul>';
} }