2016-04-22 12:44:23 +00:00
|
|
|
// STRUCTURE DU localStorage
|
2016-04-22 17:35:05 +00:00
|
|
|
// subject -> contient les données du sujet
|
|
|
|
// contacts -> contient les données de tous les contacts
|
|
|
|
// fiches -> contient les données de toutes les fiches
|
2016-04-22 12:44:23 +00:00
|
|
|
|
2016-04-25 14:18:50 +00:00
|
|
|
|
2016-04-21 14:41:11 +00:00
|
|
|
|
|
|
|
|
2016-04-22 14:40:06 +00:00
|
|
|
/* (3) Fonction qui met à jour un élément et son listener */
|
|
|
|
function updateListener(element, eventType, handler){
|
2016-04-21 15:14:50 +00:00
|
|
|
element.removeEventListener(eventType, handler);
|
2016-04-22 14:40:06 +00:00
|
|
|
element.addEventListener(eventType, handler);
|
2016-04-21 15:14:50 +00:00
|
|
|
}
|
2016-04-21 14:41:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-04-21 09:46:24 +00:00
|
|
|
|
2016-04-22 17:35:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
/* [1] Initialisation des utilitaires et variables
|
2016-04-21 09:46:24 +00:00
|
|
|
=========================================================*/
|
2016-04-26 14:16:43 +00:00
|
|
|
/* (1) Input de type fichier pour l'import */
|
|
|
|
var importCallLog = $('input#call_log-import[type="file"]');
|
2016-04-21 13:22:43 +00:00
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
/* (2) Conteneur des fiches relation */
|
|
|
|
var ficheContainer = $('article.relation-panel');
|
2016-04-20 13:21:01 +00:00
|
|
|
|
2016-04-21 09:46:24 +00:00
|
|
|
|
2016-04-21 14:41:11 +00:00
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
/* (3) Initialisation des managers */
|
|
|
|
var subjectManager;
|
|
|
|
var contactManager;
|
|
|
|
var miniManager;
|
|
|
|
var ficheManager;
|
2016-04-21 14:41:11 +00:00
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
function dynamicUpdate(){
|
2016-04-26 16:44:39 +00:00
|
|
|
console.log('DYNAMIC UPDATE: UPDATING');
|
|
|
|
|
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
/* (1) On enregistre les MINI fiches relation */
|
|
|
|
miniManager.fieldsToStorage();
|
2016-04-21 14:41:11 +00:00
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
/* (2) On enregister les FICHES relation */
|
|
|
|
// ficheManager.fieldsToStorage();
|
2016-04-21 14:41:11 +00:00
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
/* (3) On enregistre les CONTACTS */
|
|
|
|
contactManager.fieldsToStorage();
|
2016-04-21 14:41:11 +00:00
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
/* (4) On synchronise les MINI avec les CONTACTS */
|
|
|
|
miniManager.sync();
|
2016-04-22 13:51:17 +00:00
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
/* (5) On synchronise les FICHE avec les CONTACTS */
|
|
|
|
// ficheManager.sync();
|
2016-04-22 17:35:05 +00:00
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
/* (6) On affiche le tout */
|
|
|
|
miniManager.storageToFields();
|
|
|
|
// ficheManager.storageToFields();
|
|
|
|
contactManager.storageToFields();
|
|
|
|
}
|
2016-04-22 17:35:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-04-21 09:46:24 +00:00
|
|
|
|
2016-04-22 17:35:05 +00:00
|
|
|
|
2016-04-25 14:18:50 +00:00
|
|
|
|
|
|
|
|
2016-04-22 17:35:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-04-21 14:41:11 +00:00
|
|
|
|
2016-04-22 17:35:05 +00:00
|
|
|
|
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
/* [2] Inclusion des scripts externes et lancement
|
|
|
|
=========================================================*/
|
|
|
|
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(){
|
|
|
|
|
|
|
|
|
|
|
|
/* [3] Gestion du formulaire du sujet
|
|
|
|
=========================================================*/
|
|
|
|
/* (1) On crée une instance du manager du sujet */
|
|
|
|
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"]')
|
|
|
|
);
|
2016-04-22 17:35:05 +00:00
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
/* (2) On le démarre */
|
|
|
|
subjectManager.attach();
|
2016-04-22 17:35:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
/* [4] Gestion des formulaires de contact
|
|
|
|
=========================================================*/
|
|
|
|
/* (1) On crée une instance du gestionnaire des CONTACTS */
|
|
|
|
contactManager = new inputPhoneContact(
|
|
|
|
$('article.contact-panel'),
|
|
|
|
$('h4.add-contact')
|
|
|
|
);
|
2016-04-22 17:35:05 +00:00
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
/* (2) On le démarre */
|
|
|
|
contactManager.attach(dynamicUpdate);
|
2016-04-22 17:35:05 +00:00
|
|
|
|
2016-04-21 09:46:24 +00:00
|
|
|
|
2016-04-22 13:51:17 +00:00
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
/* [5] Gestion des mini fiches relation
|
|
|
|
=========================================================*/
|
|
|
|
/* (1) On crée une instance du gestionnaire des mini fiches relation */
|
|
|
|
miniManager = new inputPhoneMini(
|
2016-04-26 16:44:39 +00:00
|
|
|
$('article.mini-relation-panel'),
|
|
|
|
$('#nav-mini')
|
2016-04-26 14:16:43 +00:00
|
|
|
);
|
2016-04-21 14:41:11 +00:00
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
miniManager.attach();
|
2016-04-21 14:41:11 +00:00
|
|
|
|
2016-04-22 14:40:06 +00:00
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
/* [6] Gestion des fiches relation
|
|
|
|
=========================================================*/
|
|
|
|
/* (1) On crée une instance du gestionnaire des fiches relation */
|
2016-04-22 14:40:06 +00:00
|
|
|
|
|
|
|
|
2016-04-22 17:35:05 +00:00
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
}) }) }) });
|
2016-04-26 09:30:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
// ETAPE 1 : INITIALISATION (ON RESTAURE LES DONNEES)
|
|
|
|
// 1. contact.storageToFields();
|
|
|
|
// 2. contact.add();
|
|
|
|
// 3. mini.storageToFields();
|
|
|
|
// 4. fiche.storageToFields();
|
2016-04-26 09:30:02 +00:00
|
|
|
|
2016-04-26 14:16:43 +00:00
|
|
|
// ETAPE 2 : ENREGISTREMENT + MISE À JOUR
|
|
|
|
// 1. mini.fieldsToStorage();
|
|
|
|
// 2. fiche.fieldsToStorage();
|
|
|
|
// 3. contact.fieldsToStorage();
|
|
|
|
// 4. mini.sync();
|
|
|
|
// 5. fiche.sync();
|
2016-04-26 09:30:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-04-21 14:41:11 +00:00
|
|
|
|
2016-04-26 09:30:02 +00:00
|
|
|
|
2016-04-22 17:35:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* [6] Gestion de l'import du fichier
|
2016-04-21 09:46:24 +00:00
|
|
|
=========================================================*/
|
|
|
|
importCallLog.addEventListener('change', function(e){
|
2016-04-20 13:21:01 +00:00
|
|
|
/* (1) On rédige la requête */
|
2016-04-20 13:46:19 +00:00
|
|
|
var uploadRequest = {
|
2016-04-20 13:21:01 +00:00
|
|
|
path: 'upload/call_log',
|
2016-04-21 09:46:24 +00:00
|
|
|
file: importCallLog.files[0]
|
2016-04-20 13:21:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* (2) On effectue l'upload (import) */
|
2016-04-20 13:46:19 +00:00
|
|
|
api.send(uploadRequest, function(response){
|
2016-04-20 13:21:01 +00:00
|
|
|
console.log( response );
|
2016-04-21 14:41:11 +00:00
|
|
|
// Si tout est bon, on met l'input en bleu
|
|
|
|
if( response.ModuleError == 0 )
|
|
|
|
importCallLog.addClass('active');
|
|
|
|
|
2016-04-21 09:46:24 +00:00
|
|
|
// TODO: Gestion de l'ajout des fiches relation
|
2016-04-20 13:21:01 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
}, false);
|
2016-04-21 09:26:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-04-22 08:27:58 +00:00
|
|
|
// var number = $('input.number[type="text"]');
|
2016-04-21 13:22:43 +00:00
|
|
|
// ic.append(number, format_number, '06 06 06 06 06');
|
|
|
|
// // format_number -> format pour les numéros de téléphones
|
|
|
|
//
|
|
|
|
// number.addEventListener('keyup', function(e){
|
|
|
|
// ic.correct(number, false);
|
|
|
|
// }, false);
|