mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-30 19:52:17 +01:00
Open contact from search without reloading app.
This commit is contained in:
parent
09843741e3
commit
307409b7e2
18
js/app.js
18
js/app.js
@ -452,10 +452,10 @@ OC.Contacts = OC.Contacts || {
|
|||||||
message: 'error in: ' + settings.url + ', '+'error: ' + xhr.responseText,
|
message: 'error in: ' + settings.url + ', '+'error: ' + xhr.responseText,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
if(id) {
|
//if(id) {
|
||||||
this.currentid = parseInt(id);
|
this.currentid = parseInt(id);
|
||||||
console.log('init, id:', id);
|
console.log('init, id:', id);
|
||||||
}
|
//}
|
||||||
// Holds an array of {id,name} maps
|
// Holds an array of {id,name} maps
|
||||||
this.scrollTimeoutMiliSecs = 100;
|
this.scrollTimeoutMiliSecs = 100;
|
||||||
this.isScrolling = false;
|
this.isScrolling = false;
|
||||||
@ -583,6 +583,7 @@ OC.Contacts = OC.Contacts || {
|
|||||||
self.loading(self.$rightContent, false);
|
self.loading(self.$rightContent, false);
|
||||||
self.Groups.loadGroups(self.numcontacts, function() {
|
self.Groups.loadGroups(self.numcontacts, function() {
|
||||||
self.loading($('#leftcontent'), false);
|
self.loading($('#leftcontent'), false);
|
||||||
|
console.log('Groups loaded, currentid', self.currentid);
|
||||||
if(self.currentid) {
|
if(self.currentid) {
|
||||||
self.openContact(self.currentid);
|
self.openContact(self.currentid);
|
||||||
}
|
}
|
||||||
@ -1053,14 +1054,19 @@ OC.Contacts = OC.Contacts || {
|
|||||||
},
|
},
|
||||||
closeContact: function(id) {
|
closeContact: function(id) {
|
||||||
if(typeof this.currentid === 'number') {
|
if(typeof this.currentid === 'number') {
|
||||||
this.Contacts.findById(id).close();
|
if(this.Contacts.findById(id).close()) {
|
||||||
this.$contactList.show();
|
this.$contactList.show();
|
||||||
this.jumpToContact(id);
|
this.jumpToContact(id);
|
||||||
delete this.currentid;
|
delete this.currentid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.$groups.find('optgroup,option:not([value="-1"])').remove();
|
this.$groups.find('optgroup,option:not([value="-1"])').remove();
|
||||||
},
|
},
|
||||||
openContact: function(id) {
|
openContact: function(id) {
|
||||||
|
console.log('Contacts.openContact', id);
|
||||||
|
if(this.currentid) {
|
||||||
|
this.closeContact(this.currentid);
|
||||||
|
}
|
||||||
this.currentid = parseInt(id);
|
this.currentid = parseInt(id);
|
||||||
this.$contactList.hide();
|
this.$contactList.hide();
|
||||||
this.$toggleAll.hide();
|
this.$toggleAll.hide();
|
||||||
|
@ -255,6 +255,9 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
console.log('Contact.close', this);
|
console.log('Contact.close', this);
|
||||||
if(this.$fullelem) {
|
if(this.$fullelem) {
|
||||||
this.$fullelem.remove();
|
this.$fullelem.remove();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +76,15 @@ Contacts_Import={
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var openContact = function(id) {
|
||||||
|
if(typeof OC.Contacts !== 'undefined') {
|
||||||
|
OC.Contacts.openContact(id);
|
||||||
|
} else {
|
||||||
|
window.location.href = OC.linkTo('contacts', 'index.php') + '?id=' + id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
if(typeof FileActions !== 'undefined'){
|
if(typeof FileActions !== 'undefined'){
|
||||||
FileActions.register('text/vcard','importaddressbook', OC.PERMISSION_READ, '', Contacts_Import.importdialog);
|
FileActions.register('text/vcard','importaddressbook', OC.PERMISSION_READ, '', Contacts_Import.importdialog);
|
||||||
|
@ -9,12 +9,13 @@ class SearchProvider extends \OC_Search_Provider{
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
$results=array();
|
$results=array();
|
||||||
$l = new OC_l10n('contacts');
|
$l = new \OC_l10n('contacts');
|
||||||
foreach($addressbooks as $addressbook) {
|
foreach($addressbooks as $addressbook) {
|
||||||
$vcards = VCard::all($addressbook['id']);
|
$vcards = VCard::all($addressbook['id']);
|
||||||
foreach($vcards as $vcard) {
|
foreach($vcards as $vcard) {
|
||||||
if(substr_count(strtolower($vcard['fullname']), strtolower($query)) > 0) {
|
if(substr_count(strtolower($vcard['fullname']), strtolower($query)) > 0) {
|
||||||
$link = \OCP\Util::linkTo('contacts', 'index.php').'?id='.urlencode($vcard['id']);
|
//$link = \OCP\Util::linkTo('contacts', 'index.php').'?id='.urlencode($vcard['id']);
|
||||||
|
$link = 'javascript:openContact(' . $vcard['id'] . ')';
|
||||||
$results[]=new \OC_Search_Result($vcard['fullname'], '', $link, (string)$l->t('Contact'));//$name,$text,$link,$type
|
$results[]=new \OC_Search_Result($vcard['fullname'], '', $link, (string)$l->t('Contact'));//$name,$text,$link,$type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user