Fixed upload/local_data for `facebook`

+ fixed subject non-updatable if only coords
+ fixed refresh when importing local_data
This commit is contained in:
xdrm-brackets 2016-12-14 12:18:15 +01:00
parent be7fb63f9c
commit 44519c6484
8 changed files with 96 additions and 33 deletions

View File

@ -131,7 +131,7 @@
$subject_set['subject']['surveys'][] = 'phone';
/* (5) On met à jour si le sujet veut renouveller l'enquête plus tard */
$subject_set['subject']['renew'] = $subject['renew'];
$subject_set['subject']['coords'] = $subject['renew'];
/* (6) On récupère les noms des contacts */
$contactsById = []; // idContact -> nomContact, typeEnquete ('mini' ou 'fiche')
@ -497,7 +497,7 @@
$subject_set['subject']['surveys'][] = 'facebook';
/* (5) On met à jour si le sujet veut renouveller l'enquête plus tard */
$subject_set['subject']['renew'] = $subject['renew'];
$subject_set['subject']['coords'] = $subject['renew'];
/* (6) On récupère les noms des contacts */
$contactsById = []; // idContact -> nomContact, typeEnquete ('mini' ou 'fiche')

View File

@ -158,6 +158,7 @@
/* (3) Vérification du sujet */
$checkSubject = isset($json['subject']['subject_id']) && is_numeric($json['subject']['subject_id']);
$checkSubject = $checkSubject && isset($json['subject']['coords']) && is_string($json['subject']['coords']);
// Erreur des attributs du sujet incorrects ou manquants
if( !$checkSubject )

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
231
232

View File

@ -25,14 +25,19 @@ inputFacebookSubject.prototype.check = function(){
/* [3] Gestion de l'enregistrement des formulaires de contact
=========================================================*/
inputFacebookSubject.prototype.fieldsToStorage = function(){
inputFacebookSubject.prototype.fieldsToStorage = function(onlyCoords){
console.group('[facebook.subject] fields to storage');
( typeof onlyCoords != 'boolean' ) ? false : onlyCoords;
// {1} Si le formulaire n'est pas valide, on ne l'enregistre pas //
if( !this.check() ) return false;
if( !onlyCoords )
if( !this.check() )
return false;
// {2} Si on a déja saisie 1+ contact, on ne l'enregistre pas //
if( lsi.keys('f_contacts').length > 0 ){
// et si on modifie le sujet
if( lsi.keys('f_subject').length === 1 && this.subject_id.value != lsi.get('f_subject',0).subject_id && lsi.keys('f_contacts').length > 0 ){
Notification.warning('Attention', 'Vous devez effacer le formulaire pour changer de sujet');
return false;
}
@ -81,19 +86,20 @@ inputFacebookSubject.prototype.attach = function(handler){
// Pointeur pour les scopes des addEventListener()
this.handler = handler;
var ptr = this;
// Handler de mise à jour quand les champs sont bons
function fts(e){ ptr.fieldsToStorage(); ptr.handler(true); ptr.storageToFields(); }
function fts(e){ this.fieldsToStorage(); this.handler(true); this.storageToFields(); };
function fts2(e){ this.fieldsToStorage(true); this.storageToFields(); };
/* (2) On attache l'évènement sur le bouton d'enregistrement */
this.store_button.addEventListener('click', fts, false);
this.store_button.addEventListener('click', fts.bind(this), false);
/* (3) On attache un évènement de 'blur' sur chaque '<input type="text">' */
this.subject_id.addEventListener('blur', fts, false);
this.subject_id.addEventListener('blur', fts.bind(this), false);
/* (4) On attache un évènement pour le champ coord */
this.coords.addEventListener('blur', fts, false);
this.coords.addEventListener('blur', fts2.bind(this), false);
/* (4) On charge le sujet depuis la mémoire ('localStorage') */
this.storageToFields();

View File

@ -25,14 +25,19 @@ inputPhoneSubject.prototype.check = function(){
/* [3] Gestion de l'enregistrement des formulaires de contact
=========================================================*/
inputPhoneSubject.prototype.fieldsToStorage = function(){
inputPhoneSubject.prototype.fieldsToStorage = function(onlyCoords){
console.group('[phone.subject] fields to storage');
( typeof onlyCoords != 'boolean' ) ? false : onlyCoords;
// {1} Si le formulaire n'est pas valide, on ne l'enregistre pas //
if( !this.check() ) return false;
if( !onlyCoords )
if( !this.check() )
return false;
// {2} Si on a déja saisie 1+ contact, on ne l'enregistre pas //
if( lsi.keys('p_contacts').length > 0 ){
// et si on modifie le sujet
if( lsi.keys('p_subject').length === 1 && this.subject_id.value != lsi.get('p_subject',0).subject_id && lsi.keys('p_contacts').length > 0 ){
Notification.warning('Attention', 'Vous devez effacer le formulaire pour changer de sujet');
return false;
}
@ -84,24 +89,19 @@ inputPhoneSubject.prototype.attach = function(handler){
this.handler = handler;
// Handler de mise à jour quand les champs sont bons
var fts = function(e){
this.fieldsToStorage();
this.handler(true);
this.storageToFields();
}.bind(this);
function fts(e){ this.fieldsToStorage(); this.handler(true); this.storageToFields(); };
function fts2(e){ this.fieldsToStorage(true); this.storageToFields(); };
/* (2) On attache l'évènement sur le bouton d'enregistrement */
this.store_button.addEventListener('click', fts, false);
this.store_button.addEventListener('click', fts.bind(this), false);
/* (3) On attache un évènement de 'blur' sur chaque '<input type="text">' */
this.subject_id.addEventListener('blur', fts, false);
this.subject_id.addEventListener('blur', fts.bind(this), false);
/* (4) On attache un évènement pour le champ coord */
this.coords.addEventListener('blur', fts, false);
this.coords.addEventListener('blur', fts2.bind(this), false);
/* (4) On charge le sujet depuis la mémoire ('localStorage') */
/* (4) On charge le sujet depuis la mémoire ('localStorage') */
this.storageToFields();

File diff suppressed because one or more lines are too long

View File

@ -260,6 +260,8 @@ var phoneRoutine = function(){
/* (3) On met à jour l'affichage */
pSubjectManager.storageToFields();
pContactManager.storageToFields();
pMiniManager.storageToFields();
pFicheManager.storageToFields();
pMatriceManager.storageToFields();
pDynamicUpdate(true);
@ -516,10 +518,12 @@ var facebookRoutine = function(){
lsi.set('f_matrice', 0, response.local_data.matrice);
/* (3) On met à jour l'affichage */
pSubjectManager.storageToFields();
pContactManager.storageToFields();
pMatriceManager.storageToFields();
pDynamicUpdate(true);
fSubjectManager.storageToFields();
fContactManager.storageToFields();
fMiniManager.storageToFields();
fFicheManager.storageToFields();
fMatriceManager.storageToFields();
fDynamicUpdate(true);
});
@ -976,7 +980,7 @@ function testRoutinePhone(doMini){
$('#medrel'+medrelVal+'_p_'+f).checked = true;
// {8} Temps de connaissance //
var duration = $$('article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="duration"]');
var duration = $$('section[data-sublink="phone"] article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="duration"]');
duration[0].value = count.toString();
duration[1].value = 1+count.toString();
@ -984,7 +988,7 @@ function testRoutinePhone(doMini){
var ctxVal = count % 14;
$('article.fiche-relation #contexte'+ctxVal+'_p_'+f).checked = true;
var ctxSpe = $$('article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="contextSpecial"]');
var ctxSpe = $$('section[data-sublink="phone"] article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="contextSpecial"]');
// Si special1
if( ctxVal == 11 )
@ -1181,10 +1185,10 @@ function testRoutineFacebook(doMini){
$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value = stuVal;
// {5} Type de relation //
var relVal = count % 9;
var relVal = count % 8;
// Si AUTRE
if( relVal == 8 ){
if( relVal == 7 ){
$('#reltype10_f_'+f).checked = true;
$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="reltypeSpecial"]').value = 'autre';
// Sinon
@ -1200,6 +1204,22 @@ function testRoutineFacebook(doMini){
var locVal = ['A', 'B', 'C', 'D'][ Math.floor(count % 4) ];
$('#loc'+locVal+'_f_'+f).checked = true;
// {7} Situation familiale //
var famsitVal = ['A', 'B', 'C', 'D'][ Math.floor(count % 4) ];
$('#famsit'+famsitVal+'_f_'+f).checked = true;
// {7} Situation familiale //
var famsitVal = ['A', 'B', 'C', 'D'][ Math.floor(count % 4) ];
$('#famsit'+famsitVal+'_f_'+f).checked = true;
// {7} Utilisation des Medias Sociaux //
var medsocVal = ['A', 'B', 'C', 'D'][ Math.floor(count % 4) ];
$('#medsoc'+medsocVal+'_f_'+f).checked = true;
// {7} Relation via médias sociaux //
var medrelVal = ['A', 'B', 'C'][ Math.floor(count % 3) ];
$('#medrel'+medrelVal+'_f_'+f).checked = true;
// {8} Temps de connaissance //
var duration = $$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="duration"]');
duration[0].value = count.toString();
@ -1223,6 +1243,41 @@ function testRoutineFacebook(doMini){
if( ctxVal == 13 )
ctxSpe[2].value = 'autre';
// {3} On remplit les interets //
var interestVal = ['0','1','2','3','4'];
interestVal = interestVal[ count % interestVal.length ];
$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="interest"]').value = interestVal;
// {3} On remplit la relation avec la personne //
var relmarkVal = ['0','1','2','3','4'];
relmarkVal = relmarkVal[ count % relmarkVal.length ];
$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="relmark"]').value = relmarkVal;
// FREQ
var freqVal;
for( var i = 0 ; i < 5 ; i++ ){
freqVal = 1+ i*5+ Math.floor( count % 4 );
if( freqVal < 10 ) freqVal = '0'+freqVal;
$('#freq'+freqVal+'_f_'+f).checked = true;
}
// IRLFREQ
var irlfreqVal;
for( var i = 0 ; i < 5 ; i++ ){
irlfreqVal = 1+ i*5+ Math.floor( count % 4 );
if( irlfreqVal < 10 ) irlfreqVal = '0'+irlfreqVal;
$('#irlfreq'+irlfreqVal+'_f_'+f).checked = true;
}
// CONNECT
var connectVal;
for( var i = 1 ; i < 7 ; i++ ){
connectVal = 1+ Math.floor( count % 2 );
$('#connect'+i+''+connectVal+'_f_'+f).checked = true;
}
count++;