Save addressbook id to be able to rearrange contacts properly.
This commit is contained in:
parent
3efec3fde9
commit
cab4a634df
|
@ -171,13 +171,14 @@ Contacts={
|
||||||
});*/
|
});*/
|
||||||
|
|
||||||
// Name has changed. Update it and reorder.
|
// Name has changed. Update it and reorder.
|
||||||
|
// TODO: Take addressbook into account
|
||||||
$('#fn').change(function(){
|
$('#fn').change(function(){
|
||||||
var name = $('#fn').val().strip_tags();
|
var name = $('#fn').val().strip_tags();
|
||||||
var item = $('.contacts [data-id="'+Contacts.UI.Card.id+'"]');
|
var item = $('.contacts [data-id="'+Contacts.UI.Card.id+'"]');
|
||||||
$(item).find('a').html(name);
|
$(item).find('a').html(name);
|
||||||
Contacts.UI.Card.fn = name;
|
Contacts.UI.Card.fn = name;
|
||||||
var added = false;
|
var added = false;
|
||||||
$('.contacts li').each(function(){
|
$('.contacts li[data-bookid="'+Contacts.UI.Card.bookid+'"]').each(function(){
|
||||||
if ($(this).text().toLowerCase() > name.toLowerCase()) {
|
if ($(this).text().toLowerCase() > name.toLowerCase()) {
|
||||||
$(this).before(item).fadeIn('fast');
|
$(this).before(item).fadeIn('fast');
|
||||||
added = true;
|
added = true;
|
||||||
|
@ -185,7 +186,7 @@ Contacts={
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(!added) {
|
if(!added) {
|
||||||
$('#leftcontent ul').append(item);
|
$('#leftcontent ul[data-id="'+Contacts.UI.Card.bookid+'"]').append(item);
|
||||||
}
|
}
|
||||||
Contacts.UI.Contacts.scrollTo(Contacts.UI.Card.id);
|
Contacts.UI.Contacts.scrollTo(Contacts.UI.Card.id);
|
||||||
});
|
});
|
||||||
|
@ -245,19 +246,20 @@ Contacts={
|
||||||
honpre:'',
|
honpre:'',
|
||||||
honsuf:'',
|
honsuf:'',
|
||||||
data:undefined,
|
data:undefined,
|
||||||
update:function(id) {
|
update:function(id, bookid) {
|
||||||
var newid;
|
var newid;
|
||||||
if(!id) {
|
if(!id) {
|
||||||
newid = $('.contacts li:first-child').data('id');
|
newid = $('.contacts li:first-child').data('id');
|
||||||
|
bookid = $('.contacts li:first-child').data('bookid');
|
||||||
} else {
|
} else {
|
||||||
newid = id;
|
newid = id;
|
||||||
}
|
}
|
||||||
var localLoadContact = function(id) {
|
var localLoadContact = function(id, bookid) {
|
||||||
if($('.contacts li').length > 0) {
|
if($('.contacts li').length > 0) {
|
||||||
$('#leftcontent li[data-id="'+newid+'"]').addClass('active');
|
$('#leftcontent 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.UI.Card.loadContact(jsondata.data);
|
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'));
|
||||||
}
|
}
|
||||||
|
@ -271,7 +273,7 @@ Contacts={
|
||||||
if(jsondata.status == 'success'){
|
if(jsondata.status == 'success'){
|
||||||
$('#rightcontent').html(jsondata.data.page).ready(function() {
|
$('#rightcontent').html(jsondata.data.page).ready(function() {
|
||||||
Contacts.UI.loadHandlers();
|
Contacts.UI.loadHandlers();
|
||||||
localLoadContact(newid);
|
localLoadContact(newid, bookid);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
|
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
|
||||||
|
@ -370,7 +372,7 @@ Contacts={
|
||||||
if(answer == true) {
|
if(answer == true) {
|
||||||
$.post(OC.filePath('contacts', 'ajax', 'deletecard.php'),{'id':Contacts.UI.Card.id},function(jsondata){
|
$.post(OC.filePath('contacts', 'ajax', 'deletecard.php'),{'id':Contacts.UI.Card.id},function(jsondata){
|
||||||
if(jsondata.status == 'success'){
|
if(jsondata.status == 'success'){
|
||||||
var newid = '';
|
var newid = '', bookid;
|
||||||
var curlistitem = $('#leftcontent [data-id="'+jsondata.data.id+'"]');
|
var curlistitem = $('#leftcontent [data-id="'+jsondata.data.id+'"]');
|
||||||
var newlistitem = curlistitem.prev();
|
var newlistitem = curlistitem.prev();
|
||||||
if(newlistitem == undefined) {
|
if(newlistitem == undefined) {
|
||||||
|
@ -379,13 +381,14 @@ Contacts={
|
||||||
curlistitem.remove();
|
curlistitem.remove();
|
||||||
if(newlistitem != undefined) {
|
if(newlistitem != undefined) {
|
||||||
newid = newlistitem.data('id');
|
newid = newlistitem.data('id');
|
||||||
|
bookid = newlistitem.data('id');
|
||||||
}
|
}
|
||||||
$('#rightcontent').data('id',newid);
|
$('#rightcontent').data('id',newid);
|
||||||
this.id = this.fn = this.fullname = this.shortname = this.famname = this.givname = this.addname = this.honpre = this.honsuf = '';
|
this.id = this.fn = this.fullname = this.shortname = this.famname = this.givname = this.addname = this.honpre = this.honsuf = '';
|
||||||
this.data = undefined;
|
this.data = undefined;
|
||||||
|
|
||||||
if($('.contacts li').length > 0) { // Load first in list.
|
if($('.contacts li').length > 0) { // Load first in list.
|
||||||
Contacts.UI.Card.update(newid);
|
Contacts.UI.Card.update(newid, bookid);
|
||||||
} else {
|
} else {
|
||||||
// load intro page
|
// load intro page
|
||||||
$.getJSON(OC.filePath('contacts', 'ajax', 'loadintro.php'),{},function(jsondata){
|
$.getJSON(OC.filePath('contacts', 'ajax', 'loadintro.php'),{},function(jsondata){
|
||||||
|
@ -408,9 +411,10 @@ Contacts={
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
loadContact:function(jsondata){
|
loadContact:function(jsondata, bookid){
|
||||||
this.data = jsondata;
|
this.data = jsondata;
|
||||||
this.id = this.data.id;
|
this.id = this.data.id;
|
||||||
|
this.bookid = bookid;
|
||||||
$('#rightcontent').data('id',this.id);
|
$('#rightcontent').data('id',this.id);
|
||||||
this.populateNameFields();
|
this.populateNameFields();
|
||||||
this.loadPhoto();
|
this.loadPhoto();
|
||||||
|
@ -1498,7 +1502,7 @@ Contacts={
|
||||||
update:function(){
|
update:function(){
|
||||||
$.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'){
|
||||||
$('#leftcontent').html(jsondata.data.page).ready(function() {
|
$('#contacts').html(jsondata.data.page).ready(function() {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$('.contacts li').unbind('inview');
|
$('.contacts li').unbind('inview');
|
||||||
$('.contacts li:visible').bind('inview', function(event, isInView, visiblePartX, visiblePartY) {
|
$('.contacts li:visible').bind('inview', function(event, isInView, visiblePartX, visiblePartY) {
|
||||||
|
@ -1573,6 +1577,7 @@ $(document).ready(function(){
|
||||||
if ($tgt.is('li') || $tgt.is('a')) {
|
if ($tgt.is('li') || $tgt.is('a')) {
|
||||||
var item = $tgt.is('li')?$($tgt):($tgt).parent();
|
var item = $tgt.is('li')?$($tgt):($tgt).parent();
|
||||||
var id = item.data('id');
|
var id = item.data('id');
|
||||||
|
var bookid = item.data('bookid');
|
||||||
item.addClass('active');
|
item.addClass('active');
|
||||||
var oldid = $('#rightcontent').data('id');
|
var oldid = $('#rightcontent').data('id');
|
||||||
if(oldid != 0){
|
if(oldid != 0){
|
||||||
|
@ -1580,7 +1585,7 @@ $(document).ready(function(){
|
||||||
}
|
}
|
||||||
$.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':id},function(jsondata){
|
$.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':id},function(jsondata){
|
||||||
if(jsondata.status == 'success'){
|
if(jsondata.status == 'success'){
|
||||||
Contacts.UI.Card.loadContact(jsondata.data);
|
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'));
|
||||||
|
|
Loading…
Reference in New Issue