Gestion des FICHES avec enregistrement/restitution ok
This commit is contained in:
parent
d84f3b9363
commit
ad43715420
File diff suppressed because one or more lines are too long
|
@ -54,7 +54,7 @@ miniFicheBuilder.setLayout(
|
|||
"\t</h5>\n"+
|
||||
|
||||
"\t<h5 class='nobold color0'>\n"+
|
||||
"\t\t<span class='select-container'><select data-name='job' value='@job'>\n"+
|
||||
"\t\t<span class='select-container'><select data-name='job'>\n"+
|
||||
"\t\t\t<option value='.' disabled>Dernière profession exercée:</option>\n"+
|
||||
"\t\t\t<option value='0'>Inconnue</option>\n"+
|
||||
"\t\t\t<option value='1-' disabled>Agriculateur exploitants</option>\n"+
|
||||
|
@ -164,7 +164,7 @@ ficheBuilder.setLayout(
|
|||
|
||||
"\t<h5 class='nobold color0'>\n"+
|
||||
"\t\t<input type='radio' name='sexe_@uid' data-name='sexe' id='sexeH_@uid'><label for='sexeH_@uid'>Homme</label>\n"+
|
||||
"\t\t <input type='radio' class='btm' name='sexe_@uid' data-name='sexe' id='sexeF_@uid'><label for='sexeF_@uid'>Femme</label>\n"+
|
||||
"\t\t <input type='radio' name='sexe_@uid' data-name='sexe' id='sexeF_@uid'><label for='sexeF_@uid'>Femme</label>\n"+
|
||||
"\t</h5>\n"+
|
||||
|
||||
|
||||
|
@ -264,13 +264,13 @@ ficheBuilder.setLayout(
|
|||
"\t\t <input type='radio' name='reltype_@uid' data-name='reltype' id='reltype5_@uid'><label for='reltype5_@uid'>Voisin</label><br>\n"+
|
||||
"\t\t <input type='radio' name='reltype_@uid' data-name='reltype' id='reltype6_@uid'><label for='reltype6_@uid'>Ami</label><br>\n"+
|
||||
"\t\t <input type='radio' name='reltype_@uid' data-name='reltype' id='reltype7_@uid'><label for='reltype7_@uid'>Copain</label><br>\n"+
|
||||
"\t\t <input type='radio' name='reltype_@uid' data-name='reltype' id='reltype8_@uid'><label for='reltype8_@uid'>Autre : <input type='text' data-name='reltypeSpecial' placeholder='coéquipier de tennis, ..'></label><br>\n"+
|
||||
"\t\t <input type='radio' name='reltype_@uid' data-name='reltype' id='reltype8_@uid'><label for='reltype8_@uid'>Autre : <input type='text' data-name='reltypeSpecial' placeholder='coéquipier de tennis, ..' value='@reltypespecial'></label><br>\n"+
|
||||
"\t</h5>\n"+
|
||||
|
||||
"\t<h4 data-icon='m'>Où habite t-elle/il ?</h4>\n"+
|
||||
|
||||
"\t<h5 class='nobold color0'>\n"+
|
||||
"\t\t<input type='text' data-name='city' placeholder='Ville'>\n"+
|
||||
"\t\t<input type='text' data-name='city' placeholder='Ville' value='@city'>\n"+
|
||||
"\t</h5>\n"+
|
||||
|
||||
|
||||
|
@ -283,8 +283,8 @@ ficheBuilder.setLayout(
|
|||
|
||||
"\t<h5 class='nobold color0'>\n"+
|
||||
"\t\tDepuis quand connaissez-vous cette personne ?<br><br>\n"+
|
||||
"\t\t<input type='number' style='width: 5em;' data-name='duration' min='0' max='11' step='1' placeholder='mois'>mois\n"+
|
||||
"\t\tet <input type='number' style='width: 5em;' data-name='duration' min='0' max='100' step='1' placeholder='années'>ans.\n"+
|
||||
"\t\t<input type='number' style='width: 5em;' data-name='duration' min='0' max='11' step='1' placeholder='mois' value='@duration0'>mois\n"+
|
||||
"\t\tet <input type='number' style='width: 5em;' data-name='duration' min='0' max='100' step='1' placeholder='années' value='@duration1'>ans.\n"+
|
||||
"\t</h5>\n"+
|
||||
|
||||
|
||||
|
@ -304,9 +304,9 @@ ficheBuilder.setLayout(
|
|||
|
||||
"\t<h5 class='nobold color0'>\n"+
|
||||
"\t\t <input type='radio' name='contexte_@uid' data-name='context' id='contexte10_@uid'><label for='contexte10_@uid'>Au travail</label><br>\n"+
|
||||
"\t\t <input type='radio' name='contexte_@uid' data-name='context' id='contexte11_@uid'><label for='contexte11_@uid'>Internet (quel contexte ? préciser <input type='text' data-name='contextSpecial' placeholder='facebook, youtube, twitter, ..'>)</label><br>\n"+
|
||||
"\t\t <input type='radio' name='contexte_@uid' data-name='context' id='contexte12_@uid'><label for='contexte12_@uid'>Par une association (quel type : <input type='text' data-name='contextSpecial' placeholder='aide à la personne, sport, ..'>)</label><br>\n"+
|
||||
"\t\t <input type='radio' name='contexte_@uid' data-name='context' id='contexte13_@uid'><label for='contexte13_@uid'>Autre : <input type='text' data-name='contextSpecial' placeholder='vacances, ..'></label><br>\n"+
|
||||
"\t\t <input type='radio' name='contexte_@uid' data-name='context' id='contexte11_@uid'><label for='contexte11_@uid'>Internet (quel contexte ? préciser <input type='text' data-name='contextSpecial' placeholder='facebook, youtube, twitter, ..' value='@contextspecial0'>)</label><br>\n"+
|
||||
"\t\t <input type='radio' name='contexte_@uid' data-name='context' id='contexte12_@uid'><label for='contexte12_@uid'>Par une association (quel type : <input type='text' data-name='contextSpecial' placeholder='aide à la personne, sport, ..' value='@contextspecial1'>)</label><br>\n"+
|
||||
"\t\t <input type='radio' name='contexte_@uid' data-name='context' id='contexte13_@uid'><label for='contexte13_@uid'>Autre : <input type='text' data-name='contextSpecial' placeholder='vacances, ..' value='@contextspecial2'></label><br>\n"+
|
||||
"\t</h5>\n"+
|
||||
|
||||
"\t<h4 data-icon='b'>Avec quelle fréquence discutez-vous avec cette personne ?</h4>\n"+
|
||||
|
@ -389,11 +389,11 @@ ficheBuilder.setLayout(
|
|||
"\t</h5>\n"+
|
||||
|
||||
"\t<h5 class='nobold color0'>\n"+
|
||||
"\t\tVous communiquez dans autre réseau social : <input type='text' data-name='connectSpecial'>\n"+
|
||||
"\t\tVous communiquez dans autre réseau social : <input type='text' data-name='connectSpecial' value='@connectspecial0'>\n"+
|
||||
"\t</h5>\n"+
|
||||
|
||||
"\t<h5 class='nobold color0'>\n"+
|
||||
"\t\tVous communiquez dans un autre dispositif (blogs, jeu vidéo ou autre) : <input type='text' data-name='connectSpecial'>\n"+
|
||||
"\t\tVous communiquez dans un autre dispositif (blogs, jeu vidéo ou autre) : <input type='text' data-name='connectSpecial' value='@connectspecial1'>\n"+
|
||||
"\t</h5>\n"+
|
||||
|
||||
"</article>\n");
|
||||
|
|
|
@ -1,13 +1,19 @@
|
|||
function inputPhoneFiche(b,c){this.container=b;this.nav_container=c}inputPhoneFiche.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null};
|
||||
inputPhoneFiche.prototype.fieldsToStorage=function(){console.log("FICHE: FIELDS TO STORAGE");for(var b=$$("article.relation-panel .fiche-relation"),c=0;c<b.length;c++){var a=(new FormDeflater(b[c],["input","select"],["data-name"])).deflate();console.log(a);var d=lsi.get("fiches","form"+a.uid.value);!1===d&&(d.username="inconnu",d.firstname="inconnu",d.lastname="inconnu");a={uid:a.uid.value,firstname:d.firstname,lastname:d.lastname,username:d.username,sexe:[a.sexe[0].status,a.sexe[1].status],age:a.age.value,
|
||||
job:a.job.value,famsit:[a.famsit[0].status,a.famsit[1].status,a.famsit[2].status],studies:a.studies.value,reltype:[a.reltype[0].status,a.reltype[1].status,a.reltype[2].status,a.reltype[3].status,a.reltype[4].status,a.reltype[5].status,a.reltype[6].status,a.reltype[7].status,a.reltype[8].status],reltypeSpecial:a.reltypeSpecial.value,city:a.city.value,loc:[a.loc[0].status,a.loc[1].status,a.loc[2].status,a.loc[3].status],duration:[a.duration[0].value,a.duration[1].value],context:[a.context[0].status,
|
||||
a.context[1].status,a.context[2].status,a.context[3].status,a.context[4].status,a.context[5].status,a.context[6].status,a.context[7].status,a.context[8].status,a.context[9].status,a.context[10].status,a.context[11].status,a.context[12].status,a.context[13].status],contextSpecial:[a.contextSpecial[0].value,a.contextSpecial[1].value,a.contextSpecial[2].value],freq:[[a.freq0[0].status,a.freq0[1].status,a.freq0[2].status,a.freq0[3].status],[a.freq1[0].status,a.freq1[1].status,a.freq1[2].status,a.freq1[3].status],
|
||||
[a.freq2[0].status,a.freq2[1].status,a.freq2[2].status,a.freq2[3].status],[a.freq3[0].status,a.freq3[1].status,a.freq3[2].status,a.freq3[3].status],[a.freq4[0].status,a.freq4[1].status,a.freq4[2].status,a.freq4[3].status]],connect:[[a.connect0[0].status,a.connect0[1].status],[a.connect1[0].status,a.connect1[1].status],[a.connect2[0].status,a.connect2[1].status],[a.connect3[0].status,a.connect3[1].status],[a.connect4[0].status,a.connect4[1].status],[a.connect5[0].status,a.connect5[1].status]],connectSpecial:[a.connectSpecial[0].value,
|
||||
a.connectSpecial[1].value]};lsi.set("fiches","form"+a.uid,a)}};
|
||||
inputPhoneFiche.prototype.add=function(b){console.log("FICHE: ADD");if(null==b.uid)return!1;b.firstname=null!=b.firstname?b.firstname:"";b.lastname=null!=b.lastname?b.lastname:"";b.username=null!=b.username?b.username:"";b.age=null!=b.age?b.age:"";b.sexe=null!=b.sexe?b.sexe:[!0,!1];b.job=null!=b.job?b.job:".";b.loc=null!=b.loc?b.loc:[!0,!1,!1,!1];this.container.innerHTML+=ficheBuilder.build({firstname:b.firstname,lastname:b.lastname,username:b.username,uid:b.uid,age:b.age});$('[data-name="uid"][value="'+
|
||||
b.uid+'"] ~ h5>span>select').value=b.job;for(var c=$$('[data-name="uid"][value="'+b.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),a=0;a<c.length;a++)b.sexe[a]?c[a].setAttribute("checked","checked"):c[a].removeAttribute("checked");c=$$('[data-name="uid"][value="'+b.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(a=0;a<c.length;a++)b.loc[a]?c[a].setAttribute("checked","checked"):c[a].removeAttribute("checked")};
|
||||
inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var b=lsi.keys("fiches");this.container.innerHTML="";for(var c=[],a=0;a<b.length;a++){var d=lsi.get("fiches",b[a]);this.add({uid:d.uid,firstname:d.firstname,lastname:d.lastname,username:d.username,age:d.age,sexe:d.sexe,job:d.job,loc:d.loc});c.push(d.uid)}this.updateNavBar(c)};
|
||||
inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");for(var b=lsi.keys("contacts"),c=0;c<b.length&&9>c;c++){var a=lsi.get("contacts",b[c]),d=lsi.get("fiches",b[c]);null==d?lsi.set("fiches",b[c],{uid:a.uid,firstname:a.firstname,lastname:a.lastname,username:a.username,sexe:[!0,!1],age:"",job:".",loc:[!0,!1,!1,!1]}):(d.firstname=a.firstname,d.lastname=a.lastname,d.username=a.username,lsi.set("fiches",b[c],d))}};
|
||||
inputPhoneFiche.prototype.nav=function(b){if("undefined"==typeof b||isNaN(b.innerHTML))return!1;for(var c=$$("#nav-fiche > span.active"),a=0;a<c.length;a++)c[a].remClass("active");b.addClass("active");this.selected=parseInt(b.innerHTML)-1;b=$$("article.relation-panel .fiche-relation.active");for(a=0;a<b.length;a++)b[a].remClass("active");this.container.children[this.selected].addClass("active")};
|
||||
inputPhoneFiche.prototype.updateNavBar=function(b){this.nav_container.innerHTML="";for(var c=0;c<b.length;c++){var a=parseInt(b[c])+1;this.nav_container.innerHTML+="<span>"+a+"</span>"}this.check();this.nav(this.nav_container.children[this.selected])};inputPhoneFiche.prototype.check=function(){for(var b=lsi.keys("fiches"),c=0;c<b.length;c++){var a=lsi.get("fiches",b[c]),d=!0;(d=(d=d&&!isNaN(parseInt(a.age)))&&"."!=a.job)?this.nav_container.children[a.uid].addClass("done"):this.nav_container.children[a.uid].remClass("done")}};
|
||||
inputPhoneFiche.prototype.attach=function(b){console.log("FICHE: ATTACH");lsi.createDataset("fiches");this.storageToFields();this.handler=b;var c=this,c=this;this.nav_container.addEventListener("click",function(a){c.nav(a.target);c.handler()},!1)};
|
||||
function inputPhoneFiche(a,c){this.container=a;this.nav_container=c}
|
||||
inputPhoneFiche.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{firstname:"",lastname:"",username:"",sexe:[{status:!0},{status:!1}],age:"",job:".",famsit:[{status:!0},{status:!1},{status:!1}],studies:".",reltype:[{status:!0},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1}],reltypeSpecial:"",city:"",loc:[{status:!0},{status:!1},{status:!1},{status:!1}],duration:["",""],context:[{status:!0},{status:!1},
|
||||
{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1}],contextSpecial:["","",""],freq:[[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}]],connect:[[{status:!0},{status:!1}],[{status:!0},{status:!1}],[{status:!0},
|
||||
{status:!1}],[{status:!0},{status:!1}],[{status:!0},{status:!1}],[{status:!0},{status:!1}]],connectSpecial:["",""]}};
|
||||
inputPhoneFiche.prototype.fieldsToStorage=function(){console.log("FICHE: FIELDS TO STORAGE");for(var a=$$("article.relation-panel .fiche-relation"),c=0;c<a.length;c++){var b=(new FormDeflater(a[c],["input","select"],["data-name"])).deflate();console.log(b);var d=lsi.get("fiches","form"+b.uid.value);!1===d&&(d.username="inconnu",d.firstname="inconnu",d.lastname="inconnu");b={uid:b.uid.value,firstname:d.firstname,lastname:d.lastname,username:d.username,sexe:b.sexe,age:b.age.value,job:b.job.value,famsit:b.famsit,
|
||||
studies:b.studies.value,reltype:b.reltype,reltypeSpecial:b.reltypeSpecial.value,city:b.city.value,loc:b.loc,duration:[b.duration[0].value,b.duration[1].value],context:b.context,contextSpecial:[b.contextSpecial[0].value,b.contextSpecial[1].value,b.contextSpecial[2].value],freq:[b.freq0,b.freq1,b.freq2,b.freq3,b.freq4],connect:[b.connect0,b.connect1,b.connect2,b.connect3,b.connect4,b.connect5],connectSpecial:[b.connectSpecial[0].value,b.connectSpecial[1].value]};lsi.set("fiches","form"+b.uid,b)}};
|
||||
inputPhoneFiche.prototype.add=function(a){console.log("FICHE: ADD");if(null==a.uid)return!1;a.firstname=null!=a.firstname?a.firstname:this.defaultData.firstname;a.lastname=null!=a.lastname?a.lastname:this.defaultData.lastname;a.username=null!=a.username?a.username:this.defaultData.username;a.age=null!=a.age?a.age:this.defaultData.age;a.city=null!=a.city?a.city:this.defaultData.city;a.duration[0]=null!=a.duration[0]?a.duration[0]:this.defaultData.duration[0];a.duration[1]=null!=a.duration[1]?a.duration[1]:
|
||||
this.defaultData.duration[1];a.reltypeSpecial=null!=a.reltypeSpecial?a.reltypeSpecial:this.defaultData.reltypeSpecial;a.contextSpecial[0]=null!=a.contextSpecial[0]?a.contextSpecial[0]:this.defaultData.contextSpecial[0];a.contextSpecial[1]=null!=a.contextSpecial[1]?a.contextSpecial[1]:this.defaultData.contextSpecial[1];a.contextSpecial[2]=null!=a.contextSpecial[2]?a.contextSpecial[2]:this.defaultData.contextSpecial[2];a.connectSpecial[0]=null!=a.connectSpecial[0]?a.connectSpecial[0]:this.defaultData.connectSpecial[0];
|
||||
a.connectSpecial[1]=null!=a.connectSpecial[1]?a.connectSpecial[1]:this.defaultData.connectSpecial[1];a.job=null!=a.job?a.job:this.defaultData.job;a.studies=null!=a.studies?a.studies:this.defaultData.studies;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.famsit=null!=a.famsit?a.famsit:this.defaultData.famsit;a.reltype=null!=a.reltype?a.reltype:this.defaultData.reltype;a.loc=null!=a.loc?a.loc:this.defaultData.loc;a.context=null!=a.context?a.context:this.defaultData.context;a.freq=null!=a.freq?a.freq:
|
||||
this.defaultData.freq;a.connect=null!=a.connect?a.connect:this.defaultData.connect;this.container.innerHTML+=ficheBuilder.build({firstname:a.firstname,lastname:a.lastname,username:a.username,uid:a.uid,age:a.age,city:a.city,duration0:a.duration[0],duration1:a.duration[1],reltypespecial:a.reltypeSpecial,contextspecial0:a.contextSpecial[0],contextspecial1:a.contextSpecial[1],contextspecial2:a.contextSpecial[2],connectspecial0:a.connectSpecial[0],connectspecial1:a.connectSpecial[1]});var c=$('article.fiche-relation input[data-name="uid"][value="'+
|
||||
a.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+a.job+'"]');null!=c&&c.setAttribute("selected","selected");c=$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=c&&c.setAttribute("selected","selected");for(var b=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),c=0;c<b.length&&c<a.sexe.length;c++)a.sexe[c].status?b[c].setAttribute("checked",
|
||||
"checked"):b[c].removeAttribute("checked");b=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');for(c=0;c<b.length&&c<a.famsit.length;c++)a.famsit[c].status?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');for(c=0;c<b.length&&c<a.reltype.length;c++)a.reltype[c].status?b[c].setAttribute("checked",
|
||||
"checked"):b[c].removeAttribute("checked");b=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(c=0;c<b.length&&c<a.loc.length;c++)a.loc[c].status?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="context"]');for(c=0;c<b.length&&c<a.context.length;c++)a.context[c].status?b[c].setAttribute("checked","checked"):
|
||||
b[c].removeAttribute("checked");for(b=0;b<a.freq.length;b++)for(var d=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="freq'+b+'"]'),c=0;c<d.length&&c<a.freq[b].length;c++)a.freq[b][c].status?d[c].setAttribute("checked","checked"):d[c].removeAttribute("checked");for(b=0;b<a.connect.length;b++)for(d=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect'+b+'"]'),c=0;c<d.length&&c<a.connect[b].length;c++)a.connect[b][c].status?
|
||||
d[c].setAttribute("checked","checked"):d[c].removeAttribute("checked")};inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi.keys("fiches");this.container.innerHTML="";for(var c=[],b=0;b<a.length;b++){var d=lsi.get("fiches",a[b]);this.add(d);c.push(d.uid)}this.updateNavBar(c)};
|
||||
inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");for(var a=lsi.keys("contacts"),c=0;c<a.length&&9>c;c++){var b=lsi.get("contacts",a[c]),d=lsi.get("fiches",a[c]);null==d&&(d=this.defaultData);d.uid=b.uid;d.firstname=b.firstname;d.lastname=b.lastname;d.username=b.username;lsi.set("fiches",a[c],d)}};
|
||||
inputPhoneFiche.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML))return!1;for(var c=$$("#nav-fiche > span.active"),b=0;b<c.length;b++)c[b].remClass("active");a.addClass("active");this.selected=parseInt(a.innerHTML)-1;a=$$("article.relation-panel .fiche-relation.active");for(b=0;b<a.length;b++)a[b].remClass("active");this.container.children[this.selected].addClass("active")};
|
||||
inputPhoneFiche.prototype.updateNavBar=function(a){this.nav_container.innerHTML="";for(var c=0;c<a.length;c++){var b=parseInt(a[c])+1;this.nav_container.innerHTML+="<span>"+b+"</span>"}this.check();this.nav(this.nav_container.children[this.selected])};inputPhoneFiche.prototype.check=function(){for(var a=lsi.keys("fiches"),c=0;c<a.length;c++){var b=lsi.get("fiches",a[c]),d=!0;(d=(d=d&&!isNaN(parseInt(b.age)))&&"."!=b.job)?this.nav_container.children[b.uid].addClass("done"):this.nav_container.children[b.uid].remClass("done")}};
|
||||
inputPhoneFiche.prototype.attach=function(a){console.log("FICHE: ATTACH");lsi.createDataset("fiches");this.storageToFields();this.handler=a;var c=this,c=this;this.nav_container.addEventListener("click",function(a){c.nav(a.target);c.handler()},!1)};
|
||||
|
|
|
@ -11,7 +11,41 @@ inputPhoneFiche.prototype = {
|
|||
container: this.container, // Conteneur des fiche fiches relation
|
||||
nav_container: this.nav_container, // Conteneur de la navigation entre les fiches
|
||||
selected: 0, // UID de la FICHE sélectionnée
|
||||
handler: null // Fonction pour l'enregistrement et la synchronisation des données
|
||||
handler: null, // Fonction pour l'enregistrement et la synchronisation des données
|
||||
defaultData: { // Valeurs par défaut
|
||||
firstname: '',
|
||||
lastname: '',
|
||||
username: '',
|
||||
sexe: [ {status:true}, {status:false}],
|
||||
age: '',
|
||||
job: '.',
|
||||
famsit: [ {status:true}, {status:false}, {status:false} ], // Choix 1 à 3
|
||||
studies: '.',
|
||||
reltype: [ {status:true}, {status:false}, {status:false}, {status:false}, {status:false},
|
||||
{status:false}, {status:false}, {status:false}, {status:false}], // Choix 1 à 9
|
||||
reltypeSpecial: '',
|
||||
city: '',
|
||||
loc: [ {status:true}, {status:false}, {status:false}, {status:false} ],
|
||||
duration: ['', ''],
|
||||
context: [ {status:true}, {status:false}, {status:false}, {status:false}, {status:false},
|
||||
{status:false}, {status:false}, {status:false}, {status:false}, {status:false},
|
||||
{status:false}, {status:false}, {status:false}, {status:false}], // Choix 1 à 14
|
||||
contextSpecial: ['', '', ''],
|
||||
freq: [
|
||||
[ {status:true}, {status:false}, {status:false}, {status:false} ],
|
||||
[ {status:true}, {status:false}, {status:false}, {status:false} ],
|
||||
[ {status:true}, {status:false}, {status:false}, {status:false} ],
|
||||
[ {status:true}, {status:false}, {status:false}, {status:false} ],
|
||||
[ {status:true}, {status:false}, {status:false}, {status:false} ]],
|
||||
connect: [
|
||||
[ {status:true}, {status:false} ],
|
||||
[ {status:true}, {status:false} ],
|
||||
[ {status:true}, {status:false} ],
|
||||
[ {status:true}, {status:false} ],
|
||||
[ {status:true}, {status:false} ],
|
||||
[ {status:true}, {status:false} ]],
|
||||
connectSpecial: ['', '']
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -51,76 +85,39 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){
|
|||
firstname: existingData.firstname,
|
||||
lastname: existingData.lastname,
|
||||
username: existingData.username,
|
||||
sexe: [
|
||||
deflated.sexe[0].status, // VRAI SI HOMME
|
||||
deflated.sexe[1].status // VRAI SI FEMME
|
||||
],
|
||||
sexe: deflated.sexe, // Choix 1 à 2
|
||||
age: deflated.age.value,
|
||||
job: deflated.job.value,
|
||||
famsit: [
|
||||
deflated.famsit[0].status, // VRAI si choix 1
|
||||
deflated.famsit[1].status, // VRAI si choix 2
|
||||
deflated.famsit[2].status // VRAI si choix 3
|
||||
],
|
||||
famsit: deflated.famsit, // Choix 1 à 3
|
||||
studies: deflated.studies.value,
|
||||
reltype: [
|
||||
deflated.reltype[0].status, // VRAI si choix 1
|
||||
deflated.reltype[1].status, // VRAI si choix 2
|
||||
deflated.reltype[2].status, // VRAI si choix 3
|
||||
deflated.reltype[3].status, // VRAI si choix 4
|
||||
deflated.reltype[4].status, // VRAI si choix 5
|
||||
deflated.reltype[5].status, // VRAI si choix 6
|
||||
deflated.reltype[6].status, // VRAI si choix 7
|
||||
deflated.reltype[7].status, // VRAI si choix 8
|
||||
deflated.reltype[8].status // VRAI si choix 9
|
||||
],
|
||||
reltype: deflated.reltype, // Choix 1 à 9
|
||||
reltypeSpecial: deflated.reltypeSpecial.value,
|
||||
city: deflated.city.value,
|
||||
loc: [
|
||||
deflated.loc[0].status, // VRAI si choix 1
|
||||
deflated.loc[1].status, // VRAI si choix 2
|
||||
deflated.loc[2].status, // VRAI si choix 3
|
||||
deflated.loc[3].status // VRAI si choix 4
|
||||
],
|
||||
loc: deflated.loc, // Choix 1 à 3
|
||||
duration: [
|
||||
deflated.duration[0].value, // Durée de la relation en mois
|
||||
deflated.duration[1].value // Durée de la relation en années
|
||||
],
|
||||
context: [
|
||||
deflated.context[0].status, // VRAI si choix 1
|
||||
deflated.context[1].status, // VRAI si choix 2
|
||||
deflated.context[2].status, // VRAI si choix 3
|
||||
deflated.context[3].status, // VRAI si choix 4
|
||||
deflated.context[4].status, // VRAI si choix 5
|
||||
deflated.context[5].status, // VRAI si choix 6
|
||||
deflated.context[6].status, // VRAI si choix 7
|
||||
deflated.context[7].status, // VRAI si choix 8
|
||||
deflated.context[8].status, // VRAI si choix 9
|
||||
deflated.context[9].status, // VRAI si choix 10
|
||||
deflated.context[10].status, // VRAI si choix 11
|
||||
deflated.context[11].status, // VRAI si choix 12
|
||||
deflated.context[12].status, // VRAI si choix 13
|
||||
deflated.context[13].status // VRAI si choix 14
|
||||
],
|
||||
context: deflated.context, // Choix 1 à 14
|
||||
contextSpecial: [
|
||||
deflated.contextSpecial[0].value, // Valeur du contexte si context[11]
|
||||
deflated.contextSpecial[1].value, // Valeur du contexte si context[12]
|
||||
deflated.contextSpecial[2].value // Valeur du contexte si context[13]
|
||||
],
|
||||
freq: [
|
||||
[ deflated.freq0[0].status, deflated.freq0[1].status, deflated.freq0[2].status, deflated.freq0[3].status ],
|
||||
[ deflated.freq1[0].status, deflated.freq1[1].status, deflated.freq1[2].status, deflated.freq1[3].status ],
|
||||
[ deflated.freq2[0].status, deflated.freq2[1].status, deflated.freq2[2].status, deflated.freq2[3].status ],
|
||||
[ deflated.freq3[0].status, deflated.freq3[1].status, deflated.freq3[2].status, deflated.freq3[3].status ],
|
||||
[ deflated.freq4[0].status, deflated.freq4[1].status, deflated.freq4[2].status, deflated.freq4[3].status ]
|
||||
deflated.freq0, // Choix 1 à 4
|
||||
deflated.freq1, // Choix 1 à 4
|
||||
deflated.freq2, // Choix 1 à 4
|
||||
deflated.freq3, // Choix 1 à 4
|
||||
deflated.freq4 // Choix 1 à 4
|
||||
],
|
||||
connect: [
|
||||
[ deflated.connect0[0].status, deflated.connect0[1].status ],
|
||||
[ deflated.connect1[0].status, deflated.connect1[1].status ],
|
||||
[ deflated.connect2[0].status, deflated.connect2[1].status ],
|
||||
[ deflated.connect3[0].status, deflated.connect3[1].status ],
|
||||
[ deflated.connect4[0].status, deflated.connect4[1].status ],
|
||||
[ deflated.connect5[0].status, deflated.connect5[1].status ]
|
||||
deflated.connect0, // Choix 1 à 2
|
||||
deflated.connect1, // Choix 1 à 2
|
||||
deflated.connect2, // Choix 1 à 2
|
||||
deflated.connect3, // Choix 1 à 2
|
||||
deflated.connect4, // Choix 1 à 2
|
||||
deflated.connect5 // Choix 1 à 2
|
||||
],
|
||||
connectSpecial: [
|
||||
deflated.connectSpecial[0].value,
|
||||
|
@ -160,13 +157,33 @@ inputPhoneFiche.prototype.add = function(objectData){
|
|||
return false;
|
||||
|
||||
/* (0) Gestion du formattage des valeur */
|
||||
objectData.firstname = (objectData.firstname != null) ? objectData.firstname : '';
|
||||
objectData.lastname = (objectData.lastname != null) ? objectData.lastname : '';
|
||||
objectData.username = (objectData.username != null) ? objectData.username : '';
|
||||
objectData.age = (objectData.age != null) ? objectData.age : '';
|
||||
objectData.sexe = (objectData.sexe != null) ? objectData.sexe : [true, false];
|
||||
objectData.job = (objectData.job != null) ? objectData.job : '.';
|
||||
objectData.loc = (objectData.loc != null) ? objectData.loc : [true, false, false, false];
|
||||
// {1} Champs de texte //
|
||||
objectData.firstname = (objectData.firstname != null) ? objectData.firstname : this.defaultData.firstname;
|
||||
objectData.lastname = (objectData.lastname != null) ? objectData.lastname : this.defaultData.lastname;
|
||||
objectData.username = (objectData.username != null) ? objectData.username : this.defaultData.username;
|
||||
objectData.age = (objectData.age != null) ? objectData.age : this.defaultData.age;
|
||||
objectData.city = (objectData.city != null) ? objectData.city : this.defaultData.city;
|
||||
objectData.duration[0] = (objectData.duration[0] != null) ? objectData.duration[0] : this.defaultData.duration[0];
|
||||
objectData.duration[1] = (objectData.duration[1] != null) ? objectData.duration[1] : this.defaultData.duration[1];
|
||||
objectData.reltypeSpecial = (objectData.reltypeSpecial != null) ? objectData.reltypeSpecial : this.defaultData.reltypeSpecial;
|
||||
objectData.contextSpecial[0] = (objectData.contextSpecial[0] != null) ? objectData.contextSpecial[0] : this.defaultData.contextSpecial[0];
|
||||
objectData.contextSpecial[1] = (objectData.contextSpecial[1] != null) ? objectData.contextSpecial[1] : this.defaultData.contextSpecial[1];
|
||||
objectData.contextSpecial[2] = (objectData.contextSpecial[2] != null) ? objectData.contextSpecial[2] : this.defaultData.contextSpecial[2];
|
||||
objectData.connectSpecial[0] = (objectData.connectSpecial[0] != null) ? objectData.connectSpecial[0] : this.defaultData.connectSpecial[0];
|
||||
objectData.connectSpecial[1] = (objectData.connectSpecial[1] != null) ? objectData.connectSpecial[1] : this.defaultData.connectSpecial[1];
|
||||
|
||||
// {2} Champs <select> //
|
||||
objectData.job = (objectData.job != null) ? objectData.job : this.defaultData.job;
|
||||
objectData.studies = (objectData.studies != null) ? objectData.studies : this.defaultData.studies;
|
||||
|
||||
// {3} Champs <radio> //
|
||||
objectData.sexe = (objectData.sexe != null) ? objectData.sexe : this.defaultData.sexe;
|
||||
objectData.famsit = (objectData.famsit != null) ? objectData.famsit : this.defaultData.famsit;
|
||||
objectData.reltype = (objectData.reltype != null) ? objectData.reltype : this.defaultData.reltype;
|
||||
objectData.loc = (objectData.loc != null) ? objectData.loc : this.defaultData.loc;
|
||||
objectData.context = (objectData.context != null) ? objectData.context : this.defaultData.context;
|
||||
objectData.freq = (objectData.freq != null) ? objectData.freq : this.defaultData.freq;
|
||||
objectData.connect = (objectData.connect != null) ? objectData.connect : this.defaultData.connect;
|
||||
|
||||
|
||||
// {1} Création physique //
|
||||
|
@ -175,32 +192,83 @@ inputPhoneFiche.prototype.add = function(objectData){
|
|||
lastname: objectData.lastname,
|
||||
username: objectData.username,
|
||||
uid: objectData.uid,
|
||||
age: objectData.age
|
||||
// sexe: objectData.sexe[0] ? 'true' : 'false',
|
||||
// job: objectData.job,
|
||||
// loca: objectData.loc[0] ? 'true' : 'false',
|
||||
// locb: objectData.loc[1] ? 'true' : 'false',
|
||||
// locc: objectData.loc[2] ? 'true' : 'false',
|
||||
// locd: objectData.loc[3] ? 'true' : 'false'
|
||||
age: objectData.age,
|
||||
city: objectData.city,
|
||||
duration0: objectData.duration[0],
|
||||
duration1: objectData.duration[1],
|
||||
reltypespecial: objectData.reltypeSpecial,
|
||||
contextspecial0: objectData.contextSpecial[0],
|
||||
contextspecial1: objectData.contextSpecial[1],
|
||||
contextspecial2: objectData.contextSpecial[2],
|
||||
connectspecial0: objectData.connectSpecial[0],
|
||||
connectspecial1: objectData.connectSpecial[1]
|
||||
});
|
||||
|
||||
|
||||
/* (2) On sélectionne la valeur dans le select (manuellement) */
|
||||
var createdSelect = $('[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select');
|
||||
createdSelect.value = objectData.job;
|
||||
/* (2) On sélectionne la valeur dans le select (manuellement) de la PROFESSION */
|
||||
var selectedOption = $('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+objectData.job+'"]');
|
||||
if( selectedOption != null )
|
||||
selectedOption.setAttribute('selected', 'selected');
|
||||
|
||||
/* (3) On sélectionna la valeur des boutons <radio> pour le SEXE */
|
||||
var sexeCreated = $$('[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]');
|
||||
for( var i = 0 ; i < sexeCreated.length ; i++ )
|
||||
if( objectData.sexe[i] ) sexeCreated[i].setAttribute('checked', 'checked');
|
||||
/* (3) On sélectionne la valeur dans le select (manuellement) des ETUDES */
|
||||
selectedOption = $('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+objectData.studies+'"]');
|
||||
if( selectedOption != null )
|
||||
selectedOption.setAttribute('selected', 'selected');
|
||||
|
||||
|
||||
/* (4) On sélectionna la valeur des boutons <radio> pour le SEXE */
|
||||
var sexeCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]');
|
||||
for( var i = 0 ; i < sexeCreated.length && i < objectData.sexe.length ; i++ )
|
||||
if( objectData.sexe[i].status ) sexeCreated[i].setAttribute('checked', 'checked');
|
||||
else sexeCreated[i].removeAttribute('checked');
|
||||
|
||||
/* (4) On sélectionna la valeur des boutons <radio> pour la LOCATION */
|
||||
var locCreated = $$('[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');
|
||||
for( var i = 0 ; i < locCreated.length ; i++ )
|
||||
if( objectData.loc[i] ) locCreated[i].setAttribute('checked', 'checked');
|
||||
|
||||
/* (5) On sélectionna la valeur des boutons <radio> pour la SITUATION FAMILIALE */
|
||||
var famsitCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');
|
||||
for( var i = 0 ; i < famsitCreated.length && i < objectData.famsit.length ; i++ )
|
||||
if( objectData.famsit[i].status ) famsitCreated[i].setAttribute('checked', 'checked');
|
||||
else famsitCreated[i].removeAttribute('checked');
|
||||
|
||||
|
||||
/* (6) On sélectionna la valeur des boutons <radio> pour le TYPE DE RELATION */
|
||||
var reltypeCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');
|
||||
for( var i = 0 ; i < reltypeCreated.length && i < objectData.reltype.length ; i++ )
|
||||
if( objectData.reltype[i].status ) reltypeCreated[i].setAttribute('checked', 'checked');
|
||||
else reltypeCreated[i].removeAttribute('checked');
|
||||
|
||||
|
||||
/* (7) On sélectionna la valeur des boutons <radio> pour la LOCATION */
|
||||
var locCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');
|
||||
for( var i = 0 ; i < locCreated.length && i < objectData.loc.length ; i++ )
|
||||
if( objectData.loc[i].status ) locCreated[i].setAttribute('checked', 'checked');
|
||||
else locCreated[i].removeAttribute('checked');
|
||||
|
||||
|
||||
/* (8) On sélectionna la valeur des boutons <radio> pour le CONTEXTE DE RENCONTRE */
|
||||
var contextCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="context"]');
|
||||
for( var i = 0 ; i < contextCreated.length && i < objectData.context.length ; i++ )
|
||||
if( objectData.context[i].status ) contextCreated[i].setAttribute('checked', 'checked');
|
||||
else contextCreated[i].removeAttribute('checked');
|
||||
|
||||
|
||||
/* (9) On sélectionna la valeur des boutons <radio> pour les FREQUENCES */
|
||||
for( var f = 0 ; f < objectData.freq.length ; f++ ){
|
||||
var freqCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="freq'+f+'"]');
|
||||
for( var i = 0 ; i < freqCreated.length && i < objectData.freq[f].length ; i++ )
|
||||
if( objectData.freq[f][i].status ) freqCreated[i].setAttribute('checked', 'checked');
|
||||
else freqCreated[i].removeAttribute('checked');
|
||||
}
|
||||
|
||||
/* (10) On sélectionna la valeur des boutons <radio> pour les CONNECTIONS */
|
||||
for( var c = 0 ; c < objectData.connect.length ;c++ ){
|
||||
var connectCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="connect'+c+'"]');
|
||||
for( var i = 0 ; i < connectCreated.length && i < objectData.connect[c].length ; i++ )
|
||||
if( objectData.connect[c][i].status ) connectCreated[i].setAttribute('checked', 'checked');
|
||||
else connectCreated[i].removeAttribute('checked');
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -231,16 +299,7 @@ inputPhoneFiche.prototype.storageToFields = function(){
|
|||
var ficheData = lsi.get('fiches', existingFiches[i]);
|
||||
|
||||
// {3} On ajoute un contact à la liste //
|
||||
this.add({
|
||||
uid: ficheData.uid,
|
||||
firstname: ficheData.firstname,
|
||||
lastname: ficheData.lastname,
|
||||
username: ficheData.username,
|
||||
age: ficheData.age,
|
||||
sexe: ficheData.sexe,
|
||||
job: ficheData.job,
|
||||
loc: ficheData.loc
|
||||
});
|
||||
this.add(ficheData);
|
||||
|
||||
UIDs.push(ficheData.uid);
|
||||
}
|
||||
|
@ -278,36 +337,21 @@ inputPhoneFiche.prototype.sync = function(){
|
|||
var ficheData = lsi.get('fiches', contactUIDs[i]);
|
||||
|
||||
|
||||
/* (5) Cas 1 : la MINI fiche n'exise pas */
|
||||
if( ficheData == null ){
|
||||
|
||||
// On crée la MINI fiche
|
||||
lsi.set('fiches', contactUIDs[i], {
|
||||
uid: contactData.uid,
|
||||
firstname: contactData.firstname,
|
||||
lastname: contactData.lastname,
|
||||
username: contactData.username,
|
||||
sexe: [true, false], // valeur par défaut
|
||||
age: '', // valeur par défaut
|
||||
job: '.', // valeur par défaut
|
||||
loc: [true, false, false, false] // valeur par défaut
|
||||
});
|
||||
/* (5) Si la FICHE n'exise pas, on la crée avec les valeurs par défaut */
|
||||
if( ficheData == null )
|
||||
ficheData = this.defaultData;
|
||||
|
||||
|
||||
/* (6) Cas 2 : la MINI fiche existe déja */
|
||||
}else{
|
||||
|
||||
// On modifie la MINI fiche
|
||||
/* (6) On met à jour la fiche */
|
||||
ficheData.uid = contactData.uid;
|
||||
ficheData.firstname = contactData.firstname;
|
||||
ficheData.lastname = contactData.lastname;
|
||||
ficheData.username = contactData.username;
|
||||
|
||||
// On met à jour la MINI fiche
|
||||
|
||||
/* (7) On enregistre les modification */
|
||||
lsi.set('fiches', contactUIDs[i], ficheData);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
function inputPhoneMini(a,b){this.container=a;this.nav_container=b}inputPhoneMini.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null};
|
||||
function inputPhoneMini(a,b){this.container=a;this.nav_container=b}inputPhoneMini.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{firstname:"",lastname:"",username:"",sexe:[{status:!0},{status:!1}],age:"",job:".",loc:[{status:!0},{status:!1},{status:!1},{status:!1}]}};
|
||||
inputPhoneMini.prototype.fieldsToStorage=function(){console.log("MINI FICHE: FIELDS TO STORAGE");for(var a=$$("article.mini-relation-panel .mini-fiche-relation"),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate(),d=lsi.get("mini-fiches","form"+c.uid.value);!1===d&&(d.username="inconnu",d.firstname="inconnu",d.lastname="inconnu");c={uid:c.uid.value,firstname:d.firstname,lastname:d.lastname,username:d.username,sexe:c.sexe,age:c.age.value,job:c.job.value,loc:c.loc};
|
||||
lsi.set("mini-fiches","form"+c.uid,c)}};
|
||||
inputPhoneMini.prototype.add=function(a){console.log("MINI FICHE: ADD");if(null==a.uid)return!1;a.firstname=null!=a.firstname?a.firstname:"";a.lastname=null!=a.lastname?a.lastname:"";a.username=null!=a.username?a.username:"";a.age=null!=a.age?a.age:"";a.sexe=null!=a.sexe?a.sexe:[{status:!0},{status:!1}];a.job=null!=a.job?a.job:".";a.loc=null!=a.loc?a.loc:[{status:!0},{status:!1},{status:!1},{status:!1}];this.container.innerHTML+=miniFicheBuilder.build({firstname:a.firstname,lastname:a.lastname,username:a.username,
|
||||
uid:a.uid,age:a.age,job:a.job});console.log(a.job);var b=$('[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select>option[value="'+a.job+'"]');console.log(b);null!=b&&b.setAttribute("selected","selected");for(var c=$$('[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length;b++)a.sexe[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<
|
||||
c.length;b++)a.loc[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};inputPhoneMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi.keys("mini-fiches");this.container.innerHTML="";for(var b=[],c=0;c<a.length;c++){var d=lsi.get("mini-fiches",a[c]);this.add({uid:d.uid,firstname:d.firstname,lastname:d.lastname,username:d.username,age:d.age,sexe:d.sexe,job:d.job,loc:d.loc});b.push(d.uid)}this.updateNavBar(b)};
|
||||
inputPhoneMini.prototype.sync=function(){console.log("MINI FICHE: SYNC");for(var a=lsi.keys("contacts"),b=0;b<a.length;b++){var c=lsi.get("contacts",a[b]),d=lsi.get("mini-fiches",a[b]);null==d?d={uid:c.uid,firstname:c.firstname,lastname:c.lastname,username:c.username,sexe:[{status:!0},{status:!1}],age:"",job:".",loc:[{status:!0},{status:!1},{status:!1},{status:!1}]}:(d.firstname=c.firstname,d.lastname=c.lastname,d.username=c.username);lsi.set("mini-fiches",a[b],d)}};
|
||||
inputPhoneMini.prototype.add=function(a){console.log("MINI FICHE: ADD");if(null==a.uid)return!1;a.firstname=null!=a.firstname?a.firstname:this.defaultData.firstname;a.lastname=null!=a.lastname?a.lastname:this.defaultData.lastname;a.username=null!=a.username?a.username:this.defaultData.username;a.age=null!=a.age?a.age:this.defaultData.age;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.job=null!=a.job?a.job:this.defaultData.job;a.loc=null!=a.loc?a.loc:this.defaultData.loc;this.container.innerHTML+=
|
||||
miniFicheBuilder.build({firstname:a.firstname,lastname:a.lastname,username:a.username,uid:a.uid,age:a.age,job:a.job});var b=$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+a.job+'"]');null!=b&&b.setAttribute("selected","selected");for(var c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length&&b<a.sexe.length;b++)a.sexe[b].status?c[b].setAttribute("checked",
|
||||
"checked"):c[b].removeAttribute("checked");c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');console.log(a.loc);for(b=0;b<c.length&&b<a.loc.length;b++)a.loc[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};
|
||||
inputPhoneMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi.keys("mini-fiches");this.container.innerHTML="";for(var b=[],c=0;c<a.length;c++){var d=lsi.get("mini-fiches",a[c]);this.add({uid:d.uid,firstname:d.firstname,lastname:d.lastname,username:d.username,age:d.age,sexe:d.sexe,job:d.job,loc:d.loc});b.push(d.uid)}this.updateNavBar(b)};
|
||||
inputPhoneMini.prototype.sync=function(){console.log("MINI FICHE: SYNC");for(var a=lsi.keys("contacts"),b=0;b<a.length;b++){var c=lsi.get("contacts",a[b]),d=lsi.get("mini-fiches",a[b]);null==d&&(d=this.defaultData);d.uid=c.uid;d.firstname=c.firstname;d.lastname=c.lastname;d.username=c.username;lsi.set("mini-fiches",a[b],d)}};
|
||||
inputPhoneMini.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML))return!1;for(var b=$$("#nav-mini > span.active"),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.innerHTML)-1;a=$$("article.mini-relation-panel .mini-fiche-relation.active");for(c=0;c<a.length;c++)a[c].remClass("active");this.container.children[this.selected].addClass("active")};
|
||||
inputPhoneMini.prototype.updateNavBar=function(a){this.nav_container.innerHTML="";for(var b=0;b<a.length;b++){var c=parseInt(a[b])+1;this.nav_container.innerHTML+="<span>"+c+"</span>"}this.check();this.nav(this.nav_container.children[this.selected])};inputPhoneMini.prototype.check=function(){for(var a=lsi.keys("mini-fiches"),b=0;b<a.length;b++){var c=lsi.get("mini-fiches",a[b]),d=!0;(d=(d=d&&!isNaN(parseInt(c.age)))&&"."!=c.job)?this.nav_container.children[c.uid].addClass("done"):this.nav_container.children[c.uid].remClass("done")}};
|
||||
inputPhoneMini.prototype.attach=function(a){console.log("MINI FICHE: ATTACH");lsi.createDataset("mini-fiches");this.storageToFields();this.handler=a;var b=this,b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler()},!1)};
|
||||
|
|
|
@ -11,7 +11,16 @@ inputPhoneMini.prototype = {
|
|||
container: this.container, // Conteneur des mini fiches relation
|
||||
nav_container: this.nav_container, // Conteneur de la navigation entre les fiches
|
||||
selected: 0, // UID de la MINI fiche sélectionnée
|
||||
handler: null // Fonction pour l'enregistrement et la synchronisation des données
|
||||
handler: null, // Fonction pour l'enregistrement et la synchronisation des données
|
||||
defaultData: { // Valeur par défaut
|
||||
firstname: '',
|
||||
lastname: '',
|
||||
username: '',
|
||||
sexe: [{status:true}, {status:false}],
|
||||
age: '',
|
||||
job: '.',
|
||||
loc: [{status:true}, {status:false}, {status:false}, {status:false}]
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -85,13 +94,13 @@ inputPhoneMini.prototype.add = function(objectData){
|
|||
return false;
|
||||
|
||||
/* (0) Gestion du formattage des valeur */
|
||||
objectData.firstname = (objectData.firstname != null) ? objectData.firstname : '';
|
||||
objectData.lastname = (objectData.lastname != null) ? objectData.lastname : '';
|
||||
objectData.username = (objectData.username != null) ? objectData.username : '';
|
||||
objectData.age = (objectData.age != null) ? objectData.age : '';
|
||||
objectData.sexe = (objectData.sexe != null) ? objectData.sexe : [{status:true}, {status:false}];
|
||||
objectData.job = (objectData.job != null) ? objectData.job : '.';
|
||||
objectData.loc = (objectData.loc != null) ? objectData.loc : [{status:true}, {status:false}, {status:false}, {status:false}];
|
||||
objectData.firstname = (objectData.firstname != null) ? objectData.firstname : this.defaultData.firstname;
|
||||
objectData.lastname = (objectData.lastname != null) ? objectData.lastname : this.defaultData.lastname;
|
||||
objectData.username = (objectData.username != null) ? objectData.username : this.defaultData.username;
|
||||
objectData.age = (objectData.age != null) ? objectData.age : this.defaultData.age;
|
||||
objectData.sexe = (objectData.sexe != null) ? objectData.sexe : this.defaultData.sexe;
|
||||
objectData.job = (objectData.job != null) ? objectData.job : this.defaultData.job;
|
||||
objectData.loc = (objectData.loc != null) ? objectData.loc : this.defaultData.loc;
|
||||
|
||||
|
||||
// {1} Création physique //
|
||||
|
@ -105,20 +114,21 @@ inputPhoneMini.prototype.add = function(objectData){
|
|||
});
|
||||
|
||||
|
||||
/* (2) On sélectionne la valeur dans le select (manuellement) */
|
||||
var selectedOption = $('[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select>option[value="'+objectData.job+'"]');
|
||||
/* (2) On sélectionne la valeur dans le select (manuellement) de la PROFESSION */
|
||||
var selectedOption = $('article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+objectData.job+'"]');
|
||||
if( selectedOption != null )
|
||||
selectedOption.setAttribute('selected', 'selected');
|
||||
|
||||
/* (3) On sélectionna la valeur des boutons <radio> pour le SEXE */
|
||||
var sexeCreated = $$('[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]');
|
||||
for( var i = 0 ; i < sexeCreated.length ; i++ )
|
||||
var sexeCreated = $$('article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]');
|
||||
for( var i = 0 ; i < sexeCreated.length && i < objectData.sexe.length ; i++ )
|
||||
if( objectData.sexe[i].status ) sexeCreated[i].setAttribute('checked', 'checked');
|
||||
else sexeCreated[i].removeAttribute('checked');
|
||||
|
||||
/* (4) On sélectionna la valeur des boutons <radio> pour la LOCATION */
|
||||
var locCreated = $$('[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');
|
||||
for( var i = 0 ; i < locCreated.length ; i++ )
|
||||
var locCreated = $$('article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');
|
||||
console.log(objectData.loc);
|
||||
for( var i = 0 ; i < locCreated.length && i < objectData.loc.length ; i++ )
|
||||
if( objectData.loc[i].status ) locCreated[i].setAttribute('checked', 'checked');
|
||||
else locCreated[i].removeAttribute('checked');
|
||||
|
||||
|
@ -199,36 +209,21 @@ inputPhoneMini.prototype.sync = function(){
|
|||
var miniData = lsi.get('mini-fiches', contactUIDs[i]);
|
||||
|
||||
|
||||
/* (5) Cas 1 : la MINI fiche n'exise pas */
|
||||
if( miniData == null ){
|
||||
|
||||
// On crée la MINI fiche
|
||||
miniData = {
|
||||
uid: contactData.uid,
|
||||
firstname: contactData.firstname,
|
||||
lastname: contactData.lastname,
|
||||
username: contactData.username,
|
||||
sexe: [{status:true}, {status:false}], // valeur par défaut
|
||||
age: '', // valeur par défaut
|
||||
job: '.', // valeur par défaut
|
||||
loc: [{status:true}, {status:false}, {status:false}, {status:false}] // valeur par défaut
|
||||
};
|
||||
/* (5) Si la MINI fiche n'exise pas, on la crée avec les valeurs par défaut */
|
||||
if( miniData == null )
|
||||
miniData = this.defaultData;
|
||||
|
||||
|
||||
/* (6) Cas 2 : la MINI fiche existe déja */
|
||||
}else{
|
||||
|
||||
// On modifie la MINI fiche
|
||||
/* (6) On met à jour la MINI fiche */
|
||||
miniData.uid = contactData.uid;
|
||||
miniData.firstname = contactData.firstname;
|
||||
miniData.lastname = contactData.lastname;
|
||||
miniData.username = contactData.username;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* (7) On met à jour la MINI fiche */
|
||||
/* (7) On enregistre les modification */
|
||||
lsi.set('mini-fiches', contactUIDs[i], miniData);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
function updateListener(b,a,c){b.removeEventListener(a,c);b.addEventListener(a,c)}var importCallLog=$('input#call_log-import[type="file"]'),ficheContainer=$("article.relation-panel"),subjectManager,contactManager,miniManager,ficheManager;function dynamicUpdate(){console.log("DYNAMIC UPDATE: UPDATING");miniManager.fieldsToStorage();contactManager.fieldsToStorage();miniManager.sync();miniManager.storageToFields();contactManager.storageToFields()}
|
||||
function updateListener(b,a,c){b.removeEventListener(a,c);b.addEventListener(a,c)}var importCallLog=$('input#call_log-import[type="file"]'),ficheContainer=$("article.relation-panel"),subjectManager,contactManager,miniManager,ficheManager;
|
||||
function dynamicUpdate(){console.log("DYNAMIC UPDATE: UPDATING");miniManager.fieldsToStorage();ficheManager.fieldsToStorage();contactManager.fieldsToStorage();miniManager.sync();ficheManager.sync();miniManager.storageToFields();ficheManager.storageToFields();contactManager.storageToFields()}
|
||||
include("/js/includes/input-phone-subject.js",function(){include("/js/includes/input-phone-contact.js",function(){include("/js/includes/input-phone-mini.js",function(){include("/js/includes/input-phone-fiche.js",function(){subjectManager=new inputPhoneSubject($('article.subject-panel [data-name="number"]'),$('article.subject-panel [data-name="username"]'),$('article.subject-panel [data-name="firstname"]'),$('article.subject-panel [data-name="lastname"]'),$('article.subject-panel [data-name="submit"]'));
|
||||
subjectManager.attach();contactManager=new inputPhoneContact($("article.contact-panel"),$("h4.add-contact"));contactManager.attach(dynamicUpdate);miniManager=new inputPhoneMini($("article.mini-relation-panel"),$("#nav-mini"));miniManager.attach(dynamicUpdate)})})})});importCallLog.addEventListener("change",function(b){api.send({path:"upload/call_log",file:importCallLog.files[0]},function(a){console.log(a);0==a.ModuleError&&importCallLog.addClass("active")})},!1);
|
||||
|
|
|
@ -53,7 +53,7 @@ function dynamicUpdate(){
|
|||
miniManager.fieldsToStorage();
|
||||
|
||||
/* (2) On enregister les FICHES relation */
|
||||
// ficheManager.fieldsToStorage();
|
||||
ficheManager.fieldsToStorage();
|
||||
|
||||
/* (3) On enregistre les CONTACTS */
|
||||
contactManager.fieldsToStorage();
|
||||
|
@ -62,11 +62,11 @@ function dynamicUpdate(){
|
|||
miniManager.sync();
|
||||
|
||||
/* (5) On synchronise les FICHE avec les CONTACTS */
|
||||
// ficheManager.sync();
|
||||
ficheManager.sync();
|
||||
|
||||
/* (6) On affiche le tout */
|
||||
miniManager.storageToFields();
|
||||
// ficheManager.storageToFields();
|
||||
ficheManager.storageToFields();
|
||||
contactManager.storageToFields();
|
||||
}
|
||||
|
||||
|
@ -141,13 +141,13 @@ include('/js/includes/input-phone-fiche.js', function(){
|
|||
/* [6] Gestion des fiches relation
|
||||
=========================================================*/
|
||||
/* (1) On crée une instance du gestionnaire des fiches relation */
|
||||
// ficheManager = new inputPhoneFiche(
|
||||
// $('article.relation-panel'),
|
||||
// $('#nav-fiche')
|
||||
// );
|
||||
//
|
||||
// /* (2) On le démarre */
|
||||
// ficheManager.attach(dynamicUpdate);
|
||||
ficheManager = new inputPhoneFiche(
|
||||
$('article.relation-panel'),
|
||||
$('#nav-fiche')
|
||||
);
|
||||
|
||||
/* (2) On le démarre */
|
||||
ficheManager.attach(dynamicUpdate);
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue