Gestion du `clonage` entre 2 fiches dans la partie `input/phone.fiche` il est possible de commencer par modifier n'importe lequel des clones

This commit is contained in:
xdrm-brackets 2016-10-14 10:47:55 +02:00
parent 2276e63a55
commit ca35d0e5af
2 changed files with 4 additions and 3 deletions

View File

@ -424,7 +424,7 @@ inputPhoneFiche.prototype.sync = function(){
if( inCall && i < this.top_size || !inCall && i >= this.top_size ) if( inCall && i < this.top_size || !inCall && i >= this.top_size )
continue; continue;
// on récupère le contact associé // on récupère le contact associé (si on est dans `call`, celui dans la tranche avec `sms` / et inversement)
contactData = lsi.get('p_contacts', ficheData[i].contact); contactData = lsi.get('p_contacts', ficheData[i].contact);
if( i == key || !contactData ) if( i == key || !contactData )
@ -444,12 +444,13 @@ inputPhoneFiche.prototype.sync = function(){
} }
/* (4) Si c'est le clone qui a été modifié en dernier, on ne fait rien */ /* (4) Si c'est le clone qui a été modifié en dernier, on ne fait rien */
if( clone === null || clone.timestamp > ficheData[key].timestamp ) if( clone === null || clone_ts > fiche_ts )
continue; continue;
/* (5) On copie les données de la FICHE dans le CLONE */ /* (5) On copie les données de la FICHE dans le CLONE */
var obj = ficheData[key]; var obj = ficheData[key];
obj.uid = clone.uid; obj.uid = clone.uid;
obj.timestamp = Date.now();
lsi.set('p_fiches', clone.uid, obj); lsi.set('p_fiches', clone.uid, obj);
} }

View File

@ -13,7 +13,7 @@ a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(c=0;c<b.length;c++)b[c
a.uid+'"] ~ h5>input[type="radio"][data-name="freq"]');for(c=0;c<b.length;c++)-1<a.freq.indexOf(b[c].value)?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect"]');for(c=0;c<b.length;c++)-1<a.connect.indexOf(b[c].value)?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked")}; a.uid+'"] ~ h5>input[type="radio"][data-name="freq"]');for(c=0;c<b.length;c++)-1<a.freq.indexOf(b[c].value)?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect"]');for(c=0;c<b.length;c++)-1<a.connect.indexOf(b[c].value)?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked")};
inputPhoneFiche.prototype.storageToFields=function(){console.group("[phone.fiche] storage to fields");var a=lsi["export"]("p_fiches");this.container.innerHTML="";for(var c in a)a[c].uid==this.selected&&this.add(a[c]);this.updateNavBar();console.groupEnd()}; inputPhoneFiche.prototype.storageToFields=function(){console.group("[phone.fiche] storage to fields");var a=lsi["export"]("p_fiches");this.container.innerHTML="";for(var c in a)a[c].uid==this.selected&&this.add(a[c]);this.updateNavBar();console.groupEnd()};
inputPhoneFiche.prototype.sync=function(){console.group("[phone.fiche] synchronisation");var a=lsi["export"]("p_contacts"),c=[],b,d=lsi.keys("p_contacts").length<2*this.top_size?lsi.keys("p_contacts").length:2*this.top_size,e;for(e in a){for(ficheUid=0;-1<c.indexOf(ficheUid)&&ficheUid<d;)ficheUid++;c.push(ficheUid);a=lsi.get("p_fiches",ficheUid);!a&&(a=this.defaultData);a.uid=ficheUid;a.contact=parseInt(e);lsi.set("p_fiches",ficheUid,a);if(c.length>=d)break}var a=lsi["export"]("p_fiches"),f;for(f in a)if(d= inputPhoneFiche.prototype.sync=function(){console.group("[phone.fiche] synchronisation");var a=lsi["export"]("p_contacts"),c=[],b,d=lsi.keys("p_contacts").length<2*this.top_size?lsi.keys("p_contacts").length:2*this.top_size,e;for(e in a){for(ficheUid=0;-1<c.indexOf(ficheUid)&&ficheUid<d;)ficheUid++;c.push(ficheUid);a=lsi.get("p_fiches",ficheUid);!a&&(a=this.defaultData);a.uid=ficheUid;a.contact=parseInt(e);lsi.set("p_fiches",ficheUid,a);if(c.length>=d)break}var a=lsi["export"]("p_fiches"),f;for(f in a)if(d=
lsi.get("p_contacts",a[f].contact)){c=null;e=parseInt(a[f].uid)<this.top_size;for(var g in a)if(!(e&&g<this.top_size||!e&&g>=this.top_size)&&(b=lsi.get("p_contacts",a[g].contact),g!=f&&b)){var h=0<b.username.length&&d.username===b.username;b=!isNaN(b.existing)&&d.existing===b.existing;(h||b)&&(c=a[g]);if(null!==c)break}null===c||c.timestamp>a[f].timestamp||(d=a[f],d.uid=c.uid,lsi.set("p_fiches",c.uid,d))}console.groupEnd()}; lsi.get("p_contacts",a[f].contact)){c=null;e=parseInt(a[f].uid)<this.top_size;for(var g in a)if(!(e&&g<this.top_size||!e&&g>=this.top_size)&&(b=lsi.get("p_contacts",a[g].contact),g!=f&&b)){var h=0<b.username.length&&d.username===b.username;b=!isNaN(b.existing)&&d.existing===b.existing;(h||b)&&(c=a[g]);if(null!==c)break}null===c||clone_ts>fiche_ts||(d=a[f],d.uid=c.uid,d.timestamp=Date.now(),lsi.set("p_fiches",c.uid,d))}console.groupEnd()};
inputPhoneFiche.prototype.nav=function(a){if(!(a instanceof Element&&a.getData("n"))||isNaN(a.getData("n"))||"p_nav-fiche"!=a.parentNode.id)return!1;for(var c=$$('[data-sublink="phone"] #p_nav-fiche > span.active'),b=0;b<c.length;b++)c[b].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))}; inputPhoneFiche.prototype.nav=function(a){if(!(a instanceof Element&&a.getData("n"))||isNaN(a.getData("n"))||"p_nav-fiche"!=a.parentNode.id)return!1;for(var c=$$('[data-sublink="phone"] #p_nav-fiche > span.active'),b=0;b<c.length;b++)c[b].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 c=Object.keys(a),b=0;b<c.length;b++){var d=parseInt(c[b]);0==d&&(this.nav_container.innerHTML+="<span>APPELS</span>");20>d&&b<c.length-1&&20<=c[b+1]?this.nav_container.innerHTML+='<span data-n="'+d+'" class="lc">'+(d%20+1)+"</span>&nbsp;&nbsp;":(20==d&&(this.nav_container.innerHTML+='<br><span class="fc">&nbsp;&nbsp; SMS &nbsp;&nbsp;</span>'),this.nav_container.innerHTML+='<span data-n="'+ inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("p_fiches");this.nav_container.innerHTML="";for(var c=Object.keys(a),b=0;b<c.length;b++){var d=parseInt(c[b]);0==d&&(this.nav_container.innerHTML+="<span>APPELS</span>");20>d&&b<c.length-1&&20<=c[b+1]?this.nav_container.innerHTML+='<span data-n="'+d+'" class="lc">'+(d%20+1)+"</span>&nbsp;&nbsp;":(20==d&&(this.nav_container.innerHTML+='<br><span class="fc">&nbsp;&nbsp; SMS &nbsp;&nbsp;</span>'),this.nav_container.innerHTML+='<span data-n="'+
d+'">'+(d%20+1)+"</span>")}for(var e in a)c=$('[data-sublink="phone"] #p_nav-fiche [data-n="'+a[e].uid+'"]'),null!=c&&(!0===a[e].valid?c.addClass("done"):c.remClass("done"));this.nav($('[data-sublink="phone"] #p_nav-fiche [data-n="'+this.selected+'"]'))}; d+'">'+(d%20+1)+"</span>")}for(var e in a)c=$('[data-sublink="phone"] #p_nav-fiche [data-n="'+a[e].uid+'"]'),null!=c&&(!0===a[e].valid?c.addClass("done"):c.remClass("done"));this.nav($('[data-sublink="phone"] #p_nav-fiche [data-n="'+this.selected+'"]'))};