Correction du lien entre les duplications de fiches

This commit is contained in:
xdrm-brackets 2016-05-26 11:39:58 +02:00
parent f8c89ea5ea
commit dbc1ec20fb
4 changed files with 8 additions and 6 deletions

View File

@ -11,8 +11,8 @@ for(b=0;b<c.length;b++)c[b].value==a.famsit?c[b].setAttribute("checked","checked
for(b=0;b<c.length;b++)c[b].value==a.loc?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="facebook"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="context"]');for(b=0;b<c.length;b++)c[b].value==a.context?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="facebook"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="freq"]');
for(b=0;b<c.length;b++)-1<a.freq.indexOf(c[b].value)?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="facebook"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect"]');for(b=0;b<c.length;b++)-1<a.connect.indexOf(c[b].value)?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};
inputFacebookFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi["export"]("f_fiches");this.container.innerHTML="";for(var b in a)a[b].uid==this.selected&&this.add(a[b]);this.updateNavBar()};
inputFacebookFiche.prototype.sync=function(){console.log("FICHE: SYNC");var a=lsi["export"]("f_contacts"),b=[],c=20>lsi.keys("f_contacts").length?lsi.keys("f_contacts").length:20;if(b.length<c)for(var e in a){for(a=0;-1<b.indexOf(a)&&a<c;)a++;b.push(a);var d=lsi.get("f_fiches",a);null==d&&(d=this.defaultData);d.uid=a;d.contact=parseInt(e);lsi.set("f_fiches",a,d);if(b.length>=c)break}for(var f in d)b=lsi.get("f_contacts",d[f].contact),null!=b&&-1!=b.sms&&-1!=b.call&&(b=10>parseInt(f)?10+b.sms:b.call,
b=d[b],b.timestamp>=d[f].timestamp||(c=d[f],c.uid=b.uid,lsi.set("f_fiches",b.uid,c)))};inputFacebookFiche.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"f_nav-fiche"!=a.parentNode.id)return!1;for(var b=$$('[data-sublink="facebook"] #f_nav-fiche > span.active'),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
inputFacebookFiche.prototype.sync=function(){console.log("FICHE: SYNC");var a=lsi["export"]("f_contacts"),b=[],c=20>lsi.keys("f_contacts").length?lsi.keys("f_contacts").length:20;if(b.length<c)for(var e in a){for(var d=0;-1<b.indexOf(d)&&d<c;)d++;b.push(d);a=lsi.get("f_fiches",d);null==a&&(a=this.defaultData);a.uid=d;a.contact=parseInt(e);lsi.set("f_fiches",d,a);if(b.length>=c)break}var a=lsi["export"]("f_fiches"),f;for(f in a)b=lsi.get("f_contacts",a[f].contact),null!=b&&-1!=b.sms&&-1!=b.call&&(b=
10>parseInt(f)?10+b.sms:b.call,b=a[b],b.timestamp>=a[f].timestamp||(c=a[f],c.uid=b.uid,lsi.set("f_fiches",b.uid,c)))};inputFacebookFiche.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"f_nav-fiche"!=a.parentNode.id)return!1;for(var b=$$('[data-sublink="facebook"] #f_nav-fiche > span.active'),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
inputFacebookFiche.prototype.updateNavBar=function(){var a=lsi["export"]("f_fiches");this.nav_container.innerHTML="";for(var b=Object.keys(a),c=0;c<b.length;c++){var e=parseInt(b[c]);0==e&&(this.nav_container.innerHTML+="<span>HISTORIQUE</span>");10>e&&c<b.length-1&&10<=b[c+1]?this.nav_container.innerHTML+='<span data-n="'+e+'" class="lc">'+(e%10+1)+"</span>&nbsp;&nbsp;":(10==e&&(this.nav_container.innerHTML+='<span class="fc">MESSENGER</span>'),this.nav_container.innerHTML+='<span data-n="'+e+'">'+
(e%10+1)+"</span>")}for(var d in a)b=$('[data-sublink="facebook"] #f_nav-fiche [data-n="'+a[d].uid+'"]'),null!=b&&(!0===a[d].valid?b.addClass("done"):b.remClass("done"));this.nav($('[data-sublink="facebook"] #f_nav-fiche [data-n="'+this.selected+'"]'))};
inputFacebookFiche.prototype.check=function(a){if(2>a.city.length||isNaN(parseInt(a.duration[0]))&&0<a.duration[0].length||isNaN(parseInt(a.duration[1]))&&0<a.duration[1].length||0==a.duration[0].length+a.duration[1].length||"."==a.job||"."==a.studies||"."==a.age||""==a.sexe||""==a.famsit||""==a.reltype||""==a.loc||""==a.context)return!1;for(var b=0;b<a.freq.length;b++)if(""==a.freq[b])return!1;for(b=0;b<a.connect.length;b++)if(""==a.connect[b])return!1;return"10"==a.reltype&&2>a.reltypeSpecial.length||

View File

@ -351,6 +351,8 @@ inputFacebookFiche.prototype.sync = function(){
/* (3) Mise à jour des fiches dupliquées entre le top 10 des APPELS et celui des SMS
---------------------------------------------------------*/
ficheData = lsi.export('f_fiches');
for( var key in ficheData ){
/* (1) On récupère le contact associé */
var associatedContact = lsi.get('f_contacts', ficheData[key].contact);

View File

@ -11,8 +11,8 @@ for(b=0;b<c.length;b++)c[b].value==a.famsit?c[b].setAttribute("checked","checked
for(b=0;b<c.length;b++)c[b].value==a.loc?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="context"]');for(b=0;b<c.length;b++)c[b].value==a.context?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="freq"]');
for(b=0;b<c.length;b++)-1<a.freq.indexOf(c[b].value)?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect"]');for(b=0;b<c.length;b++)-1<a.connect.indexOf(c[b].value)?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};
inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi["export"]("p_fiches");this.container.innerHTML="";for(var b in a)a[b].uid==this.selected&&this.add(a[b]);this.updateNavBar()};
inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");var a=lsi["export"]("p_contacts"),b=[],c;for(c in a){if(-1<a[c].call){var e=a[c].call;b.push(e);var d=lsi.get("p_fiches",e);null==d&&(d=this.defaultData);d.uid=e;d.contact=parseInt(c);lsi.set("p_fiches",e,d)}-1<a[c].sms&&(e=10+a[c].sms,b.push(e),d=lsi.get("p_fiches",e),null==d&&(d=this.defaultData),d.uid=e,d.contact=parseInt(c),lsi.set("p_fiches",e,d))}e=20>lsi.keys("p_contacts").length?lsi.keys("p_contacts").length:20;console.log("nbMaxFiche:",
e);if(b.length<e)for(c in a){for(a=0;-1<b.indexOf(a)&&a<e;)a++;b.push(a);d=lsi.get("p_fiches",a);null==d&&(d=this.defaultData);d.uid=a;d.contact=parseInt(c);lsi.set("p_fiches",a,d);if(b.length>=e)break}for(var f in d)b=lsi.get("p_contacts",d[f].contact),null!=b&&-1!=b.sms&&-1!=b.call&&(b=10>parseInt(f)?10+b.sms:b.call,b=d[b],b.timestamp>=d[f].timestamp||(c=d[f],c.uid=b.uid,lsi.set("p_fiches",b.uid,c)))};
inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");var a=lsi["export"]("p_contacts"),b=[],c;for(c in a){if(-1<a[c].call){var e=a[c].call;b.push(e);var d=lsi.get("p_fiches",e);null==d&&(d=this.defaultData);d.uid=e;d.contact=parseInt(c);lsi.set("p_fiches",e,d)}-1<a[c].sms&&(e=10+a[c].sms,b.push(e),d=lsi.get("p_fiches",e),null==d&&(d=this.defaultData),d.uid=e,d.contact=parseInt(c),lsi.set("p_fiches",e,d))}e=20>lsi.keys("p_contacts").length?lsi.keys("p_contacts").length:20;if(b.length<
e)for(c in a){for(a=0;-1<b.indexOf(a)&&a<e;)a++;b.push(a);d=lsi.get("p_fiches",a);null==d&&(d=this.defaultData);d.uid=a;d.contact=parseInt(c);lsi.set("p_fiches",a,d);if(b.length>=e)break}var d=lsi["export"]("p_fiches"),f;for(f in d)b=lsi.get("p_contacts",d[f].contact),null!=b&&-1!=b.sms&&-1!=b.call&&(b=10>parseInt(f)?10+b.sms:b.call,b=d[b],b.timestamp>=d[f].timestamp||(c=d[f],c.uid=b.uid,lsi.set("p_fiches",b.uid,c)))};
inputPhoneFiche.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"p_nav-fiche"!=a.parentNode.id)return!1;for(var b=$$('[data-sublink="phone"] #p_nav-fiche > span.active'),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("p_fiches");this.nav_container.innerHTML="";for(var b=Object.keys(a),c=0;c<b.length;c++){var e=parseInt(b[c]);0==e&&(this.nav_container.innerHTML+="<span>APPELS</span>");10>e&&c<b.length-1&&10<=b[c+1]?this.nav_container.innerHTML+='<span data-n="'+e+'" class="lc">'+(e%10+1)+"</span>&nbsp;&nbsp;":(10==e&&(this.nav_container.innerHTML+='<span class="fc">SMS</span>'),this.nav_container.innerHTML+='<span data-n="'+e+'">'+(e%10+1)+"</span>")}for(var d in a)b=
$('[data-sublink="phone"] #p_nav-fiche [data-n="'+a[d].uid+'"]'),null!=b&&(!0===a[d].valid?b.addClass("done"):b.remClass("done"));this.nav($('[data-sublink="phone"] #p_nav-fiche [data-n="'+this.selected+'"]'))};

View File

@ -365,7 +365,6 @@ inputPhoneFiche.prototype.sync = function(){
---------------------------------------------------------*/
// Nombre maximum de fiches (20, sauf si moins de 20 contacts, dans ce cas, le nombre de contacts);
var nbMaxFiche = lsi.keys('p_contacts').length < 20 ? lsi.keys('p_contacts').length : 20;
console.log('nbMaxFiche:', nbMaxFiche);
// Si moins de 10+10 contacts crées, on les complètes en fonction des contacts séquentiellement
if( addedFicheUids.length < nbMaxFiche ){
@ -403,6 +402,8 @@ inputPhoneFiche.prototype.sync = function(){
/* (3) Mise à jour des fiches dupliquées entre le top 10 des APPELS et celui des SMS
---------------------------------------------------------*/
ficheData = lsi.export('p_fiches');
for( var key in ficheData ){
/* (1) On récupère le contact associé */
var associatedContact = lsi.get('p_contacts', ficheData[key].contact);
@ -415,7 +416,6 @@ inputPhoneFiche.prototype.sync = function(){
if( associatedContact.sms == -1 || associatedContact.call == -1 )
continue; // On passe au suivant
/* (3) On récupère l'autre fiche (clone) */
var inCall = parseInt(key) < 10; // Si on est dans le top 10 des APPELS, sinon dans celui des SMS
var cloneIndex = inCall ? 10+associatedContact.sms : associatedContact.call; // Contient l'index du clone dans l'autre top (APPELS ou SMS)