diff --git a/core/assets/js/backend.min.js b/core/assets/js/backend.min.js
index 4802575d..a432d5a8 100644
--- a/core/assets/js/backend.min.js
+++ b/core/assets/js/backend.min.js
@@ -484,2624 +484,2778 @@ window.eoxiaJS.digirisk.accident.checkAllData = function( element ) {
return true;
}
-"use strict";
-
-var digi_chemical_product = {
- $: undefined,
+/**
+ * Initialise l'objet "causerie" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ *
+ * @since 6.6.0
+ */
+window.eoxiaJS.digirisk.causerie = {};
- init: function( event, $ ) {
- digi_chemical_product.$ = $;
- if ( event || event === undefined ) {
- digi_chemical_product.event();
- }
- },
+/**
+ * Gestion des signatures.
+ *
+ * @type {HTMLCanvasElement}
+ */
+window.eoxiaJS.digirisk.causerie.canvas;
- event: function() {
- digi_chemical_product.$( document ).on( 'click', '.form-chemical-product .wp-digi-action-new', function( event ) { digi_chemical_product.edit_chemical_product( event, digi_chemical_product.$( this ) ); } );
- digi_chemical_product.$( document ).on( 'click', '.wp-digi-chemical-product .wp-digi-action-delete', function( event ) { digi_chemical_product.delete_chemical_product( event, digi_chemical_product.$( this ) ); } );
- digi_chemical_product.$( document ).on( 'click', '.wp-digi-chemical-product .wp-digi-action-load', function( event ) { digi_chemical_product.load_chemical_product( event, digi_chemical_product.$( this ) ); } );
- // digi_chemical_product.$( document ).on( 'click', '.wp-digi-chemical_product .wp-digi-action-edit', function( event ) { digi_chemical_product.edit_chemical_product( event, digi_chemical_product.$( this ) ); } );
- },
+/**
+ * Initialise les évènements.
+ *
+ * @since 6.6.0
+ *
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.causerie.init = function() {
+ window.eoxiaJS.digirisk.causerie.event();
+ window.eoxiaJS.digirisk.causerie.refresh();
+};
- edit_chemical_product: function( event, element ) {
+/**
+ * Initialise le canvas, ainsi que owlCarousel.
+ *
+ * @since 6.6.0
+ *
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.causerie.refresh = function() {
+ jQuery( '.causerie-wrap .owl-carousel' ).owlCarousel( {
+ 'nav': 1,
+ 'loop': 1,
+ 'items': 1,
+ 'dots' : false,
+ 'navText' : [' ',' '],
+ } );
+};
- digi_chemical_product.$( element ).closest( 'form' ).ajaxSubmit( {
- 'beforeSubmit': function() {
- digi_chemical_product.$( '.wp-digi-content' ).addClass( "wp-digi-bloc-loading" );
- },
- success: function( response ) {
- digi_chemical_product.$( '.wp-digi-content' ).removeClass( "wp-digi-bloc-loading" );
- digi_chemical_product.$( '.wp-digi-chemical-product.wp-digi-list' ).replaceWith( response.data.template );
- }
- } );
- },
+/**
+ * Quand on "resize" la fenêtre, adapte le canvas.
+ *
+ * @since 6.4.0
+ *
+ * @param {Event} event L'état de l'évènement à ce moment T.
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.causerie.resizeCanvas = function( event ) {
+ var ratio = Math.max( window.devicePixelRatio || 1, 1 );
- delete_chemical_product: function( event, element ) {
- event.preventDefault();
+ for( var i = 0; i < window.eoxiaJS.digirisk.causerie.canvas.length; i++ ) {
+ window.eoxiaJS.digirisk.causerie.canvas[i].width = window.eoxiaJS.digirisk.causerie.canvas[i].offsetWidth * ratio;
+ window.eoxiaJS.digirisk.causerie.canvas[i].height = window.eoxiaJS.digirisk.causerie.canvas[i].offsetHeight * ratio;
+ window.eoxiaJS.digirisk.causerie.canvas[i].getContext( "2d" ).scale( ratio, ratio );
+ window.eoxiaJS.digirisk.causerie.canvas[i].signaturePad.clear();
+ }
+};
- if( window.confirm( window.digi_confirm_delete ) ) {
- var chemical_product_id = digi_chemical_product.$( element ).data( 'id' );
+/**
+ * Initialise les évènements principaux des causeries.
+ *
+ * @since 6.6.0
+ *
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.causerie.event = function() {
+ // Gestion du titre de la modal.
+ jQuery( document ).on( 'change', '.digi-causerie-parent .wpeo-autocomplete', window.eoxiaJS.digirisk.causerie.updateModalTitle );
+ jQuery( document ).on( 'click', '.digirisk_page_digirisk-causerie .modal-signature .wpeo-button.button-blue', window.eoxiaJS.digirisk.causerie.saveSignatureURL );
- digi_chemical_product.$( '.wp-digi-content' ).addClass( "wp-digi-bloc-loading" );
+ jQuery( document ).on( 'click', '.causerie-wrap a.disabled', function( event ) {
+ event.preventDefault();
+ return false;
+ } );
- var data = {
- action: 'wpdigi-delete-chemical_product',
- _wpnonce: digi_chemical_product.$( element ).data( 'nonce' ),
- global: digi_chemical_product.$( element ).data( 'global' ),
- chemical_product_id: chemical_product_id,
- };
+ jQuery( document ).on( 'click', '.digi-import-add-keyword > .wpeo-button', window.eoxiaJS.digirisk.causerie.addKeywordToTextarea );
- digi_chemical_product.$.post( window.ajaxurl, data, function() {
- digi_chemical_product.$( '.wp-digi-content' ).removeClass( "wp-digi-bloc-loading" );
- digi_chemical_product.$( '.wp-digi-list .wp-digi-list-item[data-chemical-product-id="' + chemical_product_id + '"]' ).fadeOut();
- } );
- }
- },
+ jQuery( document ).on( 'click', '.digi-import-add-keyword .dropdown-content .item', window.eoxiaJS.digirisk.causerie.itemSelectToTextarea );
- load_chemical_product: function( event, element ) {
- event.preventDefault();
+ jQuery( document ).on( 'keyup', '.digi-import-add-keyword .digi-info-import-link input', window.eoxiaJS.digirisk.causerie.updateImportTextFromUrl );
- digi_chemical_product.send_chemical_product();
+ // jQuery( document ).on( 'click', '.wpeo-modal .import-git-button', window.eoxiaJS.digirisk.causerie.importGitContent );
- var chemical_product_id = digi_chemical_product.$( element ).data( 'id' );
- digi_chemical_product.$( '.wp-digi-content' ).addClass( "wp-digi-bloc-loading" );
+ jQuery( document ).on( 'click', '.modal-footer .digi-display-view-git .digi-content-git', window.eoxiaJS.digirisk.causerie.txtHiddenGitToTextArea );
- var data = {
- action: 'load_chemical_product',
- _wpnonce: digi_chemical_product.$( element ).data( 'nonce' ),
- chemical_product_id: chemical_product_id,
- };
+ jQuery( document ).on( 'click', '.modal-container .digi-import-git-success .digi-picture-download', window.eoxiaJS.digirisk.causerie.importAllPictureToMedia );
- digi_chemical_product.$.post( window.ajaxurl, data, function( response ) {
- digi_chemical_product.$( '.wp-digi-list-item .dashicons-edit' ).hide();
- digi_chemical_product.$( '.wp-digi-content' ).removeClass( "wp-digi-bloc-loading" );
- digi_chemical_product.$( '.wp-digi-chemical-product .wp-digi-list-item[data-chemical-product-id="' + chemical_product_id + '"]' ).replaceWith( response.data.template );
- } );
- },
+ jQuery( document ).on( 'click', '.modal-container .modal-footer-view-git .digi-footer-git-display ', window.eoxiaJS.digirisk.causerie.displayImportGitInput );
- send_chemical_product: function() {
- digi_chemical_product.$( '.wp-digi-table-item-edit' ).each( function() {
- digi_chemical_product.$( this ).find( '.dashicons-edit' ).click();
- } );
- }
-};
-
-window.eoxiaJS.digirisk.comment = {};
+ jQuery( document ).on( 'click', '.modal-container .digi-view-execute .digi-view-execute-hide', window.eoxiaJS.digirisk.causerie.displayImportGitFromExecute );
-window.eoxiaJS.digirisk.comment.init = function() {
- window.eoxiaJS.digirisk.comment.event();
-};
+ jQuery( document ).on( 'click', '.modal-container .digi-footer-execute .digi-import-execute-run', window.eoxiaJS.digirisk.causerie.importModalExecuteIt );
-window.eoxiaJS.digirisk.comment.event = function() {};
+ jQuery( document ).on( 'click', '.wrap-causerie .tab-select-redirect .tab-element', window.eoxiaJS.digirisk.causerie.tabSelectRedirect );
-window.eoxiaJS.digirisk.comment.delete_success = function( element, response ) {
- jQuery( element ).closest( 'li' ).fadeOut();
+ jQuery( document ).on( 'click', '.wrap-causerie .modal-footer-view-textarea .digi-display-textarea', window.eoxiaJS.digirisk.causerie.causerieImportDisplayTextarea );
};
-window.eoxiaJS.digirisk.comment.saved_comment_success = function( element, response ) {
- element.closest( '.comment-container' ).replaceWith( response.data.view );
-};
-
/**
- * Initialise l'objet "correctiveTask" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ * Met à jour le titre de la modal lors du clic sur le bouton pour que l'utilisateur effectue sa signature.
*
- * @since 6.0.0
- * @version 6.4.4
+ * @since 6.6.0
+ *
+ * @param {MouseEvent} event Les données du clic.
+ * @param {Object} data Contient les données de la requête XHR.
*/
+window.eoxiaJS.digirisk.causerie.updateModalTitle = function( event, data ) {
+ var title = '';
+ var element = jQuery( this );
-window.eoxiaJS.digirisk.correctiveTask = {};
+ if ( data && data.element ) {
+ var request_data = {};
+ request_data.action = 'causerie_save_former';
+ request_data.id = jQuery( this ).closest( '.table-row' ).find( 'input[name="causerie_id"]' ).val();
+ request_data.user_id = jQuery( this ).closest( '.table-row' ).find( 'input[name="former_id"]' ).val();
-window.eoxiaJS.digirisk.correctiveTask.init = function() {
- window.eoxiaJS.digirisk.correctiveTask.event();
+ window.eoxiaJS.loader.display( jQuery( this ) );
+ window.eoxiaJS.request.send( jQuery( this ), request_data, function( triggeredElement, response ) {
+ title = 'Signature de l\'utilisateur: ' + data.element.data( 'result' );
+ element.closest( '.table-row' ).find( '.wpeo-modal-event' ).attr( 'data-title', title );
+ element.closest( '.table-row' ).find( '.wpeo-modal-event' ).removeClass( 'button-disable' );
+ } );
+ }
};
/**
- * Les évènements
+ * Enregistres dans un champ caché
*
- * @since 6.0.0
- * @version 6.4.4
+ * @since 6.6.0
*
- * @return {void}
+ * @param {MouseEvent} event Les données du clic.
*
- * @todo: En attente de la livraison 1.6.0 de Task Manager pour décommenter le code.
+ * @TODO: Mieux définir cette méthode.
*/
-window.eoxiaJS.digirisk.correctiveTask.event = function() {
- // jQuery( document ).on( 'change', '.popup.corrective-task .point[data-id="0"] input[name="content"]', window.eoxiaJS.digirisk.correctiveTask.listenAddSafeExit );
- // jQuery( document ).on( 'addedPointSuccess', '.popup.corrective-task .point[data-id="0"] .action-input', window.eoxiaJS.digirisk.correctiveTask.addedPointSuccess );
+window.eoxiaJS.digirisk.causerie.saveSignatureURL = function( event ) {
+ event.preventDefault();
+ if ( jQuery( '.step-4' ).length ) {
+ var allNotEmpty = true;
+ jQuery( '.step-4 .signature-image').each(function () {
+ if ( jQuery( this ).attr( 'data-url') == '' ) {
+ allNotEmpty = false;
+ }
+ });
+ if (allNotEmpty) {
+ jQuery('.step-4 a.button-disable').removeClass('button-disable');
+
+ }
+ } else {
+ jQuery('.modal-signature').find('canvas').each(function () {
+ if (!jQuery(this)[0].signaturePad.isEmpty()) {
+ jQuery(this).closest('div').find('input:first').val(jQuery(this)[0].toDataURL());
+ jQuery('.step-1 .action-input[data-action="next_step_causerie"]').removeClass('button-disable');
+ }
+ });
+ }
};
/**
- * Si le contenu du point à ajouter change, on ajoutes le "safeExit".
+ * Appliques la signature.
*
- * @since 6.4.4
- * @version 6.4.4
+ * @since 6.6.0
*
- * @param {CustomEvent} event Evenement spécial envoyé par TaskManager lors de la modification d'un point.
+ * @param {[type]} element [description]
+ * @return {boolean} [description]
*
- * @return {void}
+ * @TODO: Mieux définir cette méthode.
*/
-window.eoxiaJS.digirisk.correctiveTask.listenAddSafeExit = function( event ) {
- if ( '' !== jQuery( this ).val() ) {
- jQuery( '.popup.corrective-task' ).addClass( 'no-close' );
- jQuery( '.popup.corrective-task .message' ).removeClass( 'hidden' );
- window.addEventListener( 'beforeunload', window.eoxiaJS.digirisk.correctiveTask.safeExit );
- } else {
- jQuery( '.popup.corrective-task' ).removeClass( 'no-close' );
- jQuery( '.popup.corrective-task .message' ).addClass( 'hidden' );
- window.removeEventListener( 'beforeunload', window.eoxiaJS.digirisk.correctiveTask.safeExit );
+window.eoxiaJS.digirisk.causerie.applySignature = function( element ) {
+ if ( ! element.closest( '.wpeo-modal' ).find( 'canvas' )[0].signaturePad.isEmpty() ) {
+ element.closest( '.wpeo-modal' ).find( 'input[name="signature_data"]' ).val( element.closest( '.wpeo-modal' ).find( 'canvas' )[0].toDataURL() );
}
+
+ return true;
};
/**
- * Evenement envoyé par Task Manager lorsqu'un point est ajouté correctement.
+ * Vérifie que la catégorie de risque soit sélectionné avant d'enregistrer la causerie.
*
- * @since 6.4.4
- * @version 6.4.4
+ * @since 6.6.0
*
- * @param {CustomEvent} event Envoyé par Task Manager.
+ * @param {HTMLDivElement} triggeredElement L'élément déclenchant l'action.
*
- * @return {void}
+ * @return {boolean} True pour continuer l'action. False pour stopper l'action.
*/
-window.eoxiaJS.digirisk.correctiveTask.addedPointSuccess = function( event ) {
- jQuery( '.popup.corrective-task' ).removeClass( 'no-close' );
- jQuery( '.popup.corrective-task .message' ).addClass( 'hidden' );
- window.removeEventListener( 'beforeunload', window.eoxiaJS.digirisk.correctiveTask.safeExit );
+window.eoxiaJS.digirisk.causerie.beforeSaveCauserie = function( triggeredElement ) {
+ window.eoxiaJS.tooltip.remove( triggeredElement.closest( '.causerie-row' ).find( '.category-danger.wpeo-tooltip-event' ) );
+
+ // Vérification du danger.
+ if ( '-1' === triggeredElement.closest( '.causerie-row' ).find( 'input[name="risk_category_id"]' ).val() ) {
+ window.eoxiaJS.tooltip.display( triggeredElement.closest( '.causerie-row' ).find( '.category-danger.wpeo-tooltip-event' ) );
+ return false;
+ }
+
+ return true;
};
/**
- * Vérification avant la fermeture de la page si toutes les données sont enregistrées.
+ * Le callback en cas de réussite à la requête Ajax "edit_causerie".
+ * Remplaces le contenu du tableau par la vue renvoyée par la réponse Ajax.
*
- * @since 6.4.4
- * @version 6.4.4
+ * @since 6.6.0
*
- * @param {WindowEventHandlers} event L'évènement de la fenêtre.
- * @return {string}
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
*/
-window.eoxiaJS.digirisk.correctiveTask.safeExit = function( event ) {
- var confirmationMessage = 'Vos données sont en attentes d\'enregistrement';
-
- event.returnValue = confirmationMessage;
- return confirmationMessage;
+window.eoxiaJS.digirisk.causerie.editedCauserieSuccess = function( triggeredElement, response ) {
+ triggeredElement.closest( '.tab-content' ).html( response.data.view );
};
/**
- * Le callback en cas de réussite à la requête Ajax "open_task".
- * Remplaces le contenu de la popup "corrective-task" par la vue renvoyée par la réponse Ajax.
+ * Le callback en cas de réussite à la requête Ajax "load_causerie".
+ * Remplaces le contenu de la ligne du tableau "causerie" par le template renvoyé par la requête Ajax.
*
- * @since 6.0.0
- * @version 6.4.4
+ * @since 6.6.0
*
* @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
* @param {Object} response Les données renvoyées par la requête Ajax.
- *
* @return {void}
*/
-window.eoxiaJS.digirisk.correctiveTask.openedTaskPopup = function( triggeredElement, response ) {
- jQuery( '.popup.corrective-task .content' ).html( response.data.view );
- jQuery( '.popup.corrective-task .container.loading' ).removeClass( 'loading' );
+window.eoxiaJS.digirisk.causerie.loadedCauserieSuccess = function( element, response ) {
+ jQuery( element ).closest( '.table-row' ).replaceWith( response.data.view );
};
-
+
/**
- * Initialise l'objet "diffusionInformations" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ * Le callback en cas de réussite à la requête Ajax "delete_causerie".
+ * Supprimes la ligne du tableau.
*
- * @since 6.4.0
+ * @since 6.6.0
+ *
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
*/
-
-window.eoxiaJS.digirisk.diffusionInformations = {};
-
-window.eoxiaJS.digirisk.diffusionInformations.init = function() {};
+window.eoxiaJS.digirisk.causerie.deletedCauserieSuccess = function( element, response ) {
+ element.closest( '.table-row' ).fadeOut();
+};
/**
- * Le callback en cas de réussite à la requête Ajax "generate_diffusion_information".
- * Actualises la vue en cliquant sur l'onglet "Informations".
+ * Le callback en cas de réussite à la requête Ajax "save_final_causerie_step_1".
+ *
+ * @since 6.6.0
*
* @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
* @param {Object} response Les données renvoyées par la requête Ajax.
* @return {void}
- *
- * @since 6.4.0
*/
-window.eoxiaJS.digirisk.diffusionInformations.generatedDiffusionInformationSuccess = function( triggeredElement, response ) {
- jQuery( '.tab-list .tab-element[data-target="digi-diffusion-informations"]' ).click();
-};
-
-window.eoxiaJS.digirisk.document = {};
-
-window.eoxiaJS.digirisk.document.init = function() {
- window.eoxiaJS.digirisk.document.event();
-};
-
-window.eoxiaJS.digirisk.document.event = function() {
- jQuery( ".wp-digi-societytree-right-container" ).on( "click", "#wpdigi-save-element-sheet", window.eoxiaJS.digirisk.document.save_element_sheet );
- jQuery( ".wp-digi-societytree-right-container" ).on( "click", ".wp-digi-list-document .wp-digi-action-regenerate", window.eoxiaJS.digirisk.document.regenerate_document );
- jQuery( document ).on( 'click', '.wp-digi-doc-pagination a', window.eoxiaJS.digirisk.document.pagination );
-
-};
-
-window.eoxiaJS.digirisk.document.save_element_sheet = function ( event ) {
- event.preventDefault();
-
- jQuery( this ).addClass( "wp-digi-loading" );
+window.eoxiaJS.digirisk.causerie.nextStep = function( element, response ) {
+ jQuery( '.ajax-content' ).html( response.data.view );
+ var currentStep = response.data.current_step;
+ var percent = 0;
- var options = {
- beforeSubmit: function( formData, jqForm, options ) {
- },
- success: function( responseText, statusText, xhr, $form ) {
- jQuery( this ).removeClass( "wp-digi-loading" );
- if ( responseText.success ) {
- if ( undefined !== jQuery( ".wp-digi-global-sheet-content ul.wp-digi-list-document" ).html() ) {
- jQuery( ".wp-digi-global-sheet-content ul.wp-digi-list-document" ).prepend( responseText.data.output );
- }
- else {
- jQuery( ".wp-digi-global-sheet-tab li.wp-digi-sheet-generation-button" ).click();
- }
- }
- else {
+ if ( 2 === currentStep ) {
+ percent = 37;
+ } else if ( 3 === currentStep ) {
+ percent = 62;
+ }else if( 4 === currentStep ) {
+ percent = 100;
+ }else{
+ percent = 0;
+ }
- }
- },
- dataType: "json",
- resetForm: true,
- };
- jQuery( "#wpdigi-save-element-form" ).ajaxSubmit( options );
-};
+ if ( jQuery( '.main-content' ).hasClass( 'step-1' ) ) {
+ jQuery( '.main-content' ).removeClass( 'step-1' ).addClass( 'step-2' );
+ } else if ( jQuery( '.main-content' ).hasClass( 'step-2' ) ) {
+ jQuery( '.main-content' ).removeClass( 'step-2' ).addClass( 'step-3' );
+ }else if ( jQuery( '.main-content' ).hasClass( 'step-3' ) ) {
+ jQuery( '.main-content' ).removeClass( 'step-3' ).addClass( 'step-4' );
+ }
-window.eoxiaJS.digirisk.document.regenerate_document = function ( event ) {
- event.preventDefault();
+ jQuery( '.causerie-wrap .bar .loader' ).css( 'width', percent + '%' );
+ jQuery( '.causerie-wrap .bar .loader' ).attr( 'data-width', percent );
+ jQuery( '.causerie-wrap .step-list .step[data-width="' + percent + '"]' ).addClass( 'active' );
- var data = {
- action: 'wpdigi_regenerate_document',
- element_id: jQuery( this ).data( 'id' ),
- parent_id: jQuery( this ).data( 'parent-id' ),
- model_name: jQuery( this ).data( 'model'),
- _wpnonce: jQuery( this ).data( 'nonce' ),
- };
- jQuery.post( window.ajaxurl, data, function() {} );
+ window.eoxiaJS.refresh();
};
-window.eoxiaJS.digirisk.document.pagination = function( event ) {
- event.preventDefault();
-
- var href = jQuery( this ).attr( 'href' ).split( '&' );
- var next_page = href[1].replace('current_page=', '');
- var element_id = href[2].replace('element_id=', '');
-
- var data = {
- action: 'paginate_document',
- element_id: element_id,
- next_page: next_page
- };
-
- jQuery.post( window.ajaxurl, data, function( template ) {
- jQuery( '.doc-content' ).replaceWith( template );
- } );
-};
-
/**
- * Initialise l'objet "evaluationMethod" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ * Ajoutes la nouvelle ligne du participant dans le tableau.
*
- * @since 7.0.0
- * @version 7.0.0
+ * @since 6.6.0
+ *
+ * @param {HTMLDivElement} element Le bouton déclencahd l'action AJAX.
+ * @param {Object} response Les données reçu dans le formulaire.
+ *
+ * @return {void}
*/
-window.eoxiaJS.digirisk.evaluationMethod = {};
-
-window.eoxiaJS.digirisk.evaluationMethod.init = function() {
- window.eoxiaJS.digirisk.evaluationMethod.event();
-};
-
-window.eoxiaJS.digirisk.evaluationMethod.event = function() {};
+window.eoxiaJS.digirisk.causerie.savedParticipant = function( element, response ) {
+ jQuery( '.ajax-content' ).html( response.data.view );
-window.eoxiaJS.digirisk.evaluationMethod.updateInputVariables = function( riskID, evaluationID, variableID, value, field ) {
- var updateEvaluationID = false;
+ window.eoxiaJS.digirisk.causerie.checkParticipantsSignature();
- if ( ! field ) {
- updateEvaluationID = true;
- field = jQuery( '.risk-row.edit[data-id="' + riskID + '"] textarea[name="evaluation_variables"]' );
- }
-
- var currentVal = JSON.parse(field.val());
+ // window.eoxiaJS.refresh();
+};
- currentVal[variableID] = value;
+/**
+ * Vérifie si toutes les signatures sont présentes dans le tableau.
+ * Si toutes les signatures sont présentes, le bouton pour cloturer la causerie est cliquable.
+ * Sinon, si une signature est manquante, le bouton est grisé.
+ *
+ * @since 6.6.0
+ *
+ * @return {boolean}
+ */
+window.eoxiaJS.digirisk.causerie.checkParticipantsSignature = function() {
+ var allSignature = true
- field.val( JSON.stringify( currentVal ) );
+ if ( '.step-4 input[name="signature_data"]'.length ) {
+ jQuery( '.step-4 input[name="signature_data"]' ).each( function() {
+ if ( ! jQuery( this ).val() ) {
+ allSignature = false;
+ return false;
+ }
+ } );
+ }
- if ( updateEvaluationID ) {
- jQuery( '.risk-row.edit[data-id="' + riskID + '"] input[name="evaluation_method_id"]' ).val( evaluationID );
- }
-
- // Rend le bouton "active".
- if ( '-1' !== jQuery( '.risk-row.edit[data-id="' + riskID + '"]' ).find( 'input[name="risk_category_id"]' ).val() ) {
- jQuery( '.risk-row.edit[data-id="' + riskID + '"]' ).find( '.action .wpeo-button.button-disable' ).removeClass( 'button-disable' );
+ if ( allSignature ) {
+ jQuery( '.step-4 a.disabled' ).removeClass( 'disabled wpeo-tooltip-event' );
+ } else {
+ jQuery( '.step-4 a.disabled' ).addClass( 'disabled wpeo-tooltip-event' );
}
};
-
+
/**
- * Initialise l'objet "evaluationMethodDropdown" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ * Remplaces le contenu de la ligne déclenchant cette action.
+ * Cette action est déclenché lorsqu'un participant signe dans la modal.
*
- * @since 6.0.0
- * @version 6.5.0
+ * Cette méthode appelle la méthode "checkParticipantsSignature" afin de vérifier
+ * si le bouton "cloturer la causerie" peut être cliquable.
+ *
+ * @since 6.6.0
+ * @version 6.6.0
+ *
+ * @param {HTMLDivElement} element Le bouton déclenchant l'action.
+ * @param {Object} response La réponse de la requête avec la vue.
+ *
+ * @return {void}
*/
-window.eoxiaJS.digirisk.evaluationMethodDropdown = {};
+window.eoxiaJS.digirisk.causerie.savedSignature = function( element, response ) {
+ element.closest( '.table-row' ).replaceWith( response.data.view );
-window.eoxiaJS.digirisk.evaluationMethodDropdown.init = function() {
- window.eoxiaJS.digirisk.evaluationMethodDropdown.event();
-};
+ window.eoxiaJS.digirisk.causerie.checkParticipantsSignature();
-window.eoxiaJS.digirisk.evaluationMethodDropdown.event = function() {
- jQuery( document ).on( 'click', '.table.risk .dropdown-list li.dropdown-item:not(.open-popup), .wpeo-table.table-listing-risk .dropdown-list li.dropdown-item:not(.open-popup), .wpeo-table.table-risk .dropdown-list li.dropdown-item:not(.open-popup)', window.eoxiaJS.digirisk.evaluationMethodDropdown.selectSeuil );
+ // window.eoxiaJS.digirisk.causerie.refresh();
};
/**
- * Clique sur une des cotations simples.
+ * Remplaces le contenu de la ligne déclenchant cette action.
+ * Cette action est déclenché lorsqu'un participant signe dans la modal.
*
- * @param {ClickEvent} event L'état du clic.
- * @return {void}
+ * Cette méthode appelle la méthode "checkParticipantsSignature" afin de vérifier
+ * si le bouton "cloturer la causerie" peut être cliquable.
*
- * @since 6.0.0
- * @version 7.0.0
+ * @since 6.6.0
+ * @version 6.6.0
+ *
+ * @param {HTMLDivElement} element Le bouton déclenchant l'action.
+ * @param {Object} response La réponse de la requête avec la vue.
+ *
+ * @return {void}
*/
-window.eoxiaJS.digirisk.evaluationMethodDropdown.selectSeuil = function( event ) {
- var element = jQuery( this );
- var riskID = element.data( 'id' );
- var seuil = element.data( 'seuil' );
- var variableID = element.data( 'variable-id' );
- var evaluationID = element.data( 'evaluation-id' );
-
- jQuery( '.risk-row.edit[data-id="' + riskID + '"] .cotation-container .dropdown-toggle.cotation span' ).text( jQuery( this ).text() );
- jQuery( '.risk-row.edit[data-id="' + riskID + '"] .cotation-container .dropdown-toggle.cotation' ).attr( 'data-scale', seuil );
-
+window.eoxiaJS.digirisk.causerie.savedFormerSignature = function( element, response ) {
+ element.closest( '.table-row' ).find( '.signature' ).replaceWith( response.data.view );
- if ( variableID && evaluationID && seuil ) {
- window.eoxiaJS.digirisk.evaluationMethod.updateInputVariables( riskID, evaluationID, variableID, seuil );
- }
+ // window.eoxiaJS.digirisk.causerie.refresh();
};
-
+
/**
- * Initialise l'objet "evaluationMethodEvarisk" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ * Vérifie que l'utilisateur et que la signature soit bien présente dans le formulaire.
*
- * @since 1.0
- * @version 6.2.6.0
+ * @since 6.6.0
+ *
+ * @param {[type]} element [description]
+ * @return {void}
*/
-window.eoxiaJS.digirisk.evaluationMethodEvarisk = {};
+window.eoxiaJS.digirisk.causerie.checkAllData = function( element ) {
+ jQuery( '.step-1 .former-tooltip' ).removeClass( 'active' );
+ jQuery( '.step-1 .signature-tooltip' ).removeClass( 'active' );
-window.eoxiaJS.digirisk.evaluationMethodEvarisk.init = function() {
- window.eoxiaJS.digirisk.evaluationMethodEvarisk.event();
-};
+ if ( ! jQuery( '.step-1 input[name="former_id"]' ).val() ) {
+ jQuery( '.step-1 .former-tooltip' ).addClass( 'active' );
-window.eoxiaJS.digirisk.evaluationMethodEvarisk.event = function() {
- jQuery( document ).on( 'click', '.wpeo-modal.evaluation-method .wpeo-table.evaluation-method .table-cell.can-select', window.eoxiaJS.digirisk.evaluationMethodEvarisk.selectSeuil );
- jQuery( document ).on( 'click', '.wpeo-modal.evaluation-method .wpeo-button.button-main', window.eoxiaJS.digirisk.evaluationMethodEvarisk.save );
- jQuery( document ).on( 'click', '.wpeo-modal.evaluation-method .wpeo-button.button-secondary', window.eoxiaJS.digirisk.evaluationMethodEvarisk.close_modal );
-};
+ return false;
+ }
-window.eoxiaJS.digirisk.evaluationMethodEvarisk.selectSeuil = function( event ) {
- jQuery( this ).closest( '.table-row' ).find( '.active' ).removeClass( 'active' );
- jQuery( this ).addClass( 'active' );
+ if ( ! jQuery( '.step-1 input[name="have_signature"]' ).length ) {
+ jQuery( '.step-1 .signature-tooltip' ).addClass( 'active' );
- var element = jQuery( this );
- var riskID = element.data( 'id' );
- var seuil = element.data( 'seuil' );
- var variableID = element.data( 'variable-id' );
- var evaluationID = element.data( 'evaluation-id' );
+ return false;
+ }
- window.eoxiaJS.digirisk.evaluationMethod.updateInputVariables( riskID, evaluationID, variableID, seuil, jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' textarea' ) );
+ return true;
+};
- var data = {
- action: 'get_scale',
- method_evaluation_id: evaluationID,
- variables: jQuery( '.wpeo-modal.modal-risk-' + riskID + ' textarea' ).val()
- };
+/**
+ * Vérifie que l'ID de l'utilisateur soit bien présente dans le formulaire.
+ *
+ * @since 6.6.0
+ *
+ * @param {HTMLDivElement} element Le bouton déclenchant cette méthode.
+ *
+ * @return {boolean} True si le formateur à été choisi, sinon false pour stopper la requête XHR.
+ */
+window.eoxiaJS.digirisk.causerie.checkUserID = function( element ) {
+ element.closest( '.table-row' ).find( '.user-tooltip' ).removeClass( 'active' );
- var currentVal = JSON.parse(jQuery( '.wpeo-modal.modal-risk-' + riskID + ' textarea' ).val());
- var canGetDetails = true;
- for (var key in currentVal) {
- if (currentVal[key] == '') {
- canGetDetails = false;
- }
- }
-
- if ( jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .table-cell.active' ).length == 5 ) {
- if ( jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .button-main' ).length ) {
- window.eoxiaJS.loader.display( jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .button-main' ) );
- jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .button-main' ).addClass( 'disabled' );
- }
- jQuery.post( window.ajaxurl, data, function( response ) {
- if ( response.data.details ) {
- if ( jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .button-main' ).length ) {
- window.eoxiaJS.loader.remove( jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .button-main' ) );
- jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .button-main' ).removeClass( 'disabled' );
- }
- jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .cotation' ).attr( 'data-scale', response.data.details.scale );
- jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .cotation span' ).text( response.data.details.equivalence );
- jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .wpeo-button.button-disable' ).removeClass( 'button-disable' ).addClass( 'button-main' );
- }
- } );
- }
-};
-
+ if ( ! element.closest( '.table-row' ).find( 'input[name="participant_id"]' ).val() ) {
+ element.closest( '.table-row' ).find( '.user-tooltip' ).addClass( 'active' );
-window.eoxiaJS.digirisk.evaluationMethodEvarisk.save = function( event ) {
- var riskID = jQuery( this ).data( 'id' );
- var evaluationID = jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .digi-method-evaluation-id' ).val();
- var value = jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' textarea' ).val();
-
- jQuery( '.risk-row.edit[data-id="' + riskID + '"] textarea[name="evaluation_variables"]' ).val( value );
- jQuery( '.risk-row.edit[data-id="' + riskID + '"] input[name="evaluation_method_id"]' ).val( evaluationID );
-
- // On met à jour l'affichage de la cotation.
- jQuery( '.risk-row.edit[data-id="' + riskID + '"] .cotation:first' ).attr( 'data-scale', jQuery( '.wpeo-modal.modal-risk-' + riskID + ' .cotation' ).attr( 'data-scale' ) );
- jQuery( '.risk-row.edit[data-id="' + riskID + '"] .cotation:first span' ).text( jQuery( '.wpeo-modal.modal-risk-' + riskID + ' .cotation span' ).text() );
+ return false;
+ }
- window.eoxiaJS.digirisk.evaluationMethodEvarisk.close_modal( undefined, riskID );
+ return true;
};
-window.eoxiaJS.digirisk.evaluationMethodEvarisk.close_modal = function( event, riskID ) {
- if ( ! riskID ) {
- riskID = jQuery( this ).data( 'id' );
+window.eoxiaJS.digirisk.causerie.addKeywordToTextarea = function( event ){
+ var importContent = jQuery( this ).closest( '.digi-import-causeries.modal-active' ).find( 'textarea' );
+ if( jQuery( this ).attr( 'data-type' ) == "link" ){
+ window.eoxiaJS.digirisk.causerie.buttonLinkExternalText( jQuery( this ), importContent );
+ }else{
+ if( jQuery( this ).attr( 'data-type' ) != "" && jQuery( this ).attr( 'data-type' ) != null ){
+ var keyword = '%' + jQuery( this ).attr( 'data-type' ) + '% ';
+ importContent.focus().val( importContent.val() + '\r\n' + keyword );
+ }
}
-
- jQuery( '.wpeo-modal.modal-active .modal-close' ).click();
-};
-
-window.eoxiaJS.digirisk.evaluationMethodEvarisk.fillVariables = function( element ) {
- element.attr( 'data-variables', element.closest( 'td' ).find( 'textarea[name="evaluation_variables"]' ).val() );
}
-
-/**
- * Initialise l'objet "DUER" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
- *
- * @since 6.2.1
- * @version 7.0.0
- */
-window.eoxiaJS.digirisk.DUER = {};
+window.eoxiaJS.digirisk.causerie.itemSelectToTextarea = function( event ){
+ var keyword = jQuery( this ).attr( 'aria-label' );
+ var importContent = jQuery( this ).closest( '.digi-import-causeries.modal-active' ).find( 'textarea' );
+ importContent.val( importContent.val() + '\r\n' + '%risque%' + keyword );
+}
-/**
- * Méthode obligatoire pour initialiser l'objet DUER avec EO-Framework.
- *
- * @since 6.2.1
- * @version 6.2.1
- *
- * @return {void}
- */
-window.eoxiaJS.digirisk.DUER.init = function() {
- window.eoxiaJS.digirisk.DUER.event();
-};
+window.eoxiaJS.digirisk.causerie.buttonLinkExternalText = function( element, importContent ){
-/**
- * Méthode pour initialiser tous les évènements.
- *
- * @since 6.2.1
- * @version 7.0.0
- *
- * @return void
- */
-window.eoxiaJS.digirisk.DUER.event = function() {
- jQuery( document ).on( 'modal-opened', '.duer-modal', window.eoxiaJS.digirisk.DUER.modalOpened );
- jQuery( document ).on( 'click', '.duer-modal .button-main', window.eoxiaJS.digirisk.DUER.applyValueToTextarea );
+ if( element.closest( '.digi-import-add-keyword' ).find( '.digi-info-import-link input' ).attr( 'data-import' ) == "true" ){
+ var data = {};
+ data.action = 'get_text_from_url';
+ data.content = element.closest( '.digi-import-add-keyword' ).find( '.digi-info-import-link input' ).val(); // On recupere le contenu
- jQuery( document ).on( 'modal-opened', '.generate-duer-modal', window.eoxiaJS.digirisk.DUER.generateDUERModalOpened );
- jQuery( document ).on( 'click', '.generate-duer-modal .button-main', window.eoxiaJS.digirisk.DUER.closeModalGenerateDUER );
-};
+ window.eoxiaJS.loader.display( jQuery( '.digi-import-add-keyword' ) );
+ window.eoxiaJS.request.send( element, data );
+ }else{
+ if( element.attr( 'data-link' ) == "no"){
+ element.find( '.digi_save_backup' ).val( importContent.val() ); // On recupere le contenu
-/**
- * @todo
- * @param {[type]} event [description]
- * @param {[type]} data [description]
- * @return {[type]} [description]
- */
-window.eoxiaJS.digirisk.DUER.modalOpened = function( event, triggeredElement ) {
- jQuery( this ).find( '.modal-content' ).html( '' );
+ var next_step = 'yes';
+ element.removeClass( 'button-grey' ).addClass( 'button-green' );
+ element.closest( '.digi-import-add-keyword' ).find( '.digi-info-import-link' ).show( '200' );
+ }else{
+ importContent.focus().val( element.find( '.digi_save_backup' ).val() );
- if ( 'view' !== jQuery( triggeredElement ).data( 'type' ) ) {
- var textareaContent = jQuery( triggeredElement ).closest( '.table-row' ).find( '.textarea-content-' + jQuery( triggeredElement ).data( 'src' ) ).val();
- jQuery( this ).find( '.modal-content' ).html( '' );
+ var next_step = 'no';
+ element.removeClass( 'button-green' ).addClass( 'button-grey' );
+ element.closest( '.digi-import-add-keyword' ).find( '.digi-info-import-link' ).hide( '200' );
+ }
+ element.attr( 'data-link', next_step );
+ element.find( '.digi_link_external' ).val( next_step );
+ }
+}
- jQuery( '.duer-modal' ).find( 'textarea' ).val( textareaContent );
- } else {
- var content = jQuery( triggeredElement ).closest( '.table-row' ).find( '.text-content-' + jQuery( triggeredElement ).data( 'src' ) ).html();
- jQuery( this ).find( '.modal-content' ).html( '
' );
+window.eoxiaJS.digirisk.causerie.updateImportTextFromUrl = function( event ){
+ if( jQuery( this ).val().trim() != "" ){
+ jQuery( this ).closest( '.digi-import-add-keyword' ).find( '.digi-icon-import-from-url' ).removeClass( 'fa-link' ).addClass( 'fa-file-import' );
+ jQuery( this ).attr( 'data-import', "true" );
+ }else{
+ jQuery( this ).closest( '.digi-import-add-keyword' ).find( '.digi-icon-import-from-url' ).removeClass( 'fa-file-import' ).addClass( 'fa-link' );
+ jQuery( this ).attr( 'data-import', "false" );
+ }
+}
- jQuery( '.duer-modal' ).find( 'p' ).html( content );
+window.eoxiaJS.digirisk.causerie.get_content_from_url_to_import_textarea = function( element, response ){
+ if( response.data.error == "" ){
+ element.closest( '.tm-import-tasks.modal-active' ).find( 'textarea' ).val( response.data.content );
}
-};
+ element.closest( '.digi-import-add-keyword' ).find( '.digi-info-import-link input' ).val( '' );
+ element.removeClass( 'button-green' ).addClass( 'button-grey' );
+ element.closest( '.digi-import-add-keyword' ).find( '.digi-info-import-link' ).hide( '200' );
+
+ element.attr( 'data-link', "no" );
+ element.find( '.digi_link_external' ).val( "no" );
+}
/**
- * [description]
+ * Le callback en cas de réussite à la requête Ajax "delete_started_causerie".
+ * Remplaces le contenu du tableau par la vue renvoyée par la réponse Ajax.
*
- * @since 7.0.0
+ * @since 7.3.0
*
- * @param {[type]} triggeredElement [description]
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
*/
-window.eoxiaJS.digirisk.DUER.viewInPopup = function( triggeredElement ) {
- return true;
+window.eoxiaJS.digirisk.causerie.deletedStartedCauserie = function( triggeredElement, response ) {
+ triggeredElement.closest( '.causerie-row' ).fadeOut();
};
-/**
- * @todo
- * @param {[type]} event [description]
- * @return {[type]} [description]
- */
-window.eoxiaJS.digirisk.DUER.applyValueToTextarea = function( event ) {
- var textarea = jQuery( '.duer-modal' ).find( 'textarea' );
+window.eoxiaJS.digirisk.causerie.getContentFromUrl = function( triggeredElement, response ){
+ var data = response.data.response_git;
- jQuery( '.wpeo-table.table-duer .table-edit .textarea-content-' + textarea.attr( 'data-to' ) ).val( textarea.val() );
-};
+ if( data.success ){
+ triggeredElement.closest( '.modal-container' ).find( '.digi-view-git' ).html( response.data.view );
-window.eoxiaJS.digirisk.DUER.generateDUERModalOpened = function( event, triggeredElement ) {
- window.eoxiaJS.digirisk.DUER.generateDUER( jQuery( triggeredElement ), {
- data: {
- index: 1
- }
- } );
+ }else{
+ triggeredElement.closest( '.modal-footer-view-git' ).find( '.digi-info-git-error' ).show();
+ triggeredElement.closest( '.modal-footer-view-git' ).find( '.digi-info-git-error .notice-title' ).html( response.data.error );
+ }
}
-/**
- * Construit, et génères tous les documents ainsi que le DUER.
- *
- * @since 6.2.1
- * @version 7.0.0
- *
- * @param {HTMLDivElement} triggeredElement [description]
- * @param {object} preData [description]
- * @return {void} [description]
- */
-window.eoxiaJS.digirisk.DUER.generateDUER = function( triggeredElement, preData ) {
- var data = {};
- var i = 0;
- var key;
- var listInput = window.eoxiaJS.arrayForm.getInput( triggeredElement.closest( '.table-row' ) );
+window.eoxiaJS.digirisk.causerie.importGitContent = function( event ){
+ var url = jQuery( this ).closest( '.digi-import-add-keyword' ).find( '.import-git-input input[type="text"]' );
+ var textarea_element = jQuery( this ).closest( '.digi-view-textarea' );
- for ( i = 0; i < listInput.length; i++ ) {
- if ( listInput[i].name ) {
- data[listInput[i].name] = window.eoxiaJS.arrayForm.getInputValue( listInput[i] );
+ var data = {};
+ data.url = url;
+ data.action = jQuery( this ).attr( 'data-action' );
+ data._wpnonce = jQuery( this ).attr( 'data-nonce' );
+ data.url = jQuery( this ).attr( 'data-url' );
+
+ window.eoxiaJS.loader.display( jQuery( this ).parent() );
+ window.eoxiaJS.request.send( jQuery( this ), data );
+}
+
+window.eoxiaJS.digirisk.causerie.importPictureToMediaSuccess = function( triggeredElement, response ){
+ var success_element = triggeredElement.closest( '.modal-container' ).find( '.digi-info-git-success' );
+ if( response.data.id > 0 ){
+ triggeredElement.removeClass( 'action-attribute' );
+ triggeredElement.removeClass( 'button-green' ).addClass( 'button-grey' );
+ triggeredElement.html( ' ' );
+ triggeredElement.closest( '.table-row' ).css( 'border', 'solid 2px green' );
+
+ var id = " (#" + response.data.id + ")";
+ success_element.html( ' ' + response.data.text_info + id + ' ' );
+ success_element.show();
+
+ triggeredElement.closest( '.modal-container' ).find( '.modal-footer-view-git .digi-footer-git-import' ).hide();
+ triggeredElement.closest( '.modal-container' ).find( '.modal-footer-view-git .digi-footer-git-display' ).show();
+
+
+
+ triggeredElement.closest( '.modal-container' ).find( '.digi-display-view-git [data-display="git"]' ).attr( 'data-buttongit', true );
+ var str = triggeredElement.closest( '.modal-container' ).find( '.digi-display-view-git [name="contentgit"]' ).val();
+ triggeredElement.closest( '.modal-container' ).find( '.digi-display-view-git [name="contentgit"]' ).val( str + '\r\n' + response.data.content );
+
+ triggeredElement.attr( 'data-alreadydl', 'true' );
+
+ var nbr = triggeredElement.closest( '.modal-container' ).find( '.digi-import-git-success .digi-number-picture' ).html();
+ nbr = parseInt( nbr ) - 1;
+ if( nbr > 0 ){
+ triggeredElement.closest( '.modal-container' ).find( '.digi-import-git-success .digi-number-picture' ).html( nbr );
+ }else{
+ triggeredElement.closest( '.modal-container' ).find( '.digi-import-git-success .digi-picture-download' ).hide( '200' );
}
- }
- for ( key in preData.data ) {
- data[key] = preData.data[key];
}
+}
- jQuery( '.generate-duer-modal li:nth-child(' + ( preData.data.index ) + ')' ).get_data( function( attributeData ) {
- for( key in attributeData ) {
- data[key] = attributeData[key];
+window.eoxiaJS.digirisk.causerie.importTxtToTextareaSuccess = function( triggeredElement, response ){
+ triggeredElement.closest( '.modal-content' ).find( '.digi-view-textarea [name="content"]' ).val( response.data.content );
+
+ var success_element = triggeredElement.closest( '.modal-container' ).find( '.digi-info-git-success' );
+
+ success_element.html( response.data.text_info );
+ success_element.show();
+}
+
+window.eoxiaJS.digirisk.causerie.txtHiddenGitToTextArea = function( event ){
+ var gitstr = jQuery( this ).find( '[name ="contentgit"]' ).val();
+ var str = jQuery( this ).closest( '.modal-container').find( '.digi-view-textarea textarea[ name="content" ]' ).val();
+ jQuery( this ).closest( '.modal-container').find( '.digi-view-textarea textarea[ name="content" ]' ).val( str + gitstr );
+}
+
+window.eoxiaJS.digirisk.causerie.importAllPictureToMedia = function( event ){
+ var button_element = jQuery( this );
+ jQuery( this ).closest( '.digi-view-git' ).find( '.digi-display-response-git .table-row .digi-this-is-a-picture' ).each( function( e ){
+ if( jQuery( this ).attr( 'data-alreadydl' ) == "false" ){
+ jQuery( this ).attr( 'data-alreadydl', 'true' );
+
+ var data = {};
+ data.filename = jQuery( this ).attr( 'data-filename' );
+ data.url = jQuery( this ).attr( 'data-url' );
+ data.action = jQuery( this ).attr( 'data-action' );
+ data._wpnonce = jQuery( this ).attr( 'data-nonce' );
+ data.url = jQuery( this ).attr( 'data-url' );
+
+ window.eoxiaJS.loader.display( jQuery( this ).parent() );
+ window.eoxiaJS.request.send( jQuery( this ), data );
}
+ })
+}
- window.eoxiaJS.request.send( triggeredElement, data );
- } );
-};
+window.eoxiaJS.digirisk.causerie.displayImportGitInput = function( event ){
+ jQuery( this ).closest( '.modal-footer' ).find( '.modal-footer-view-git .digi-footer-git-import' ).show();
+ jQuery( this ).closest( '.modal-footer' ).find( '.modal-footer-view-git .digi-info-git-success' ).hide();
+ jQuery( this ).hide();
+}
-/**
- * Le callback en cas de réussite à la requête Ajax "generate_DUER".
- * Coches le LI correspondant à index et regénères un DUER.
- * Si la réponse contient "end", stop la génération du DUER, et rend le bouton cliquable.
- *
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
- *
- * @since 6.2.1
- * @version 6.5.0
- */
-window.eoxiaJS.digirisk.DUER.generatedDUERSuccess = function( element, response ) {
- jQuery( '.generate-duer-modal li:nth-child(' + ( response.data.index ) + ')' ).find( 'img' ).remove();
- jQuery( '.generate-duer-modal li:nth-child(' + ( response.data.index ) + ')' ).append( ' ' );
+window.eoxiaJS.digirisk.causerie.executeTxtToTextareaSuccess = function( triggeredElement, response ){
+ triggeredElement.closest( '.modal-container' ).find( '.view-git-element' ).hide( '200' );
+ triggeredElement.closest( '.modal-container' ).find( '.digi-view-execute' ).show();
+ triggeredElement.closest( '.modal-container' ).find( '.digi-content-execute' ).html( response.data.view );
+ triggeredElement.closest( '.modal-container' ).find( '.digi-footer-execute' ).html( response.data.view_footer );
+}
- if ( ! response.data.end ) {
- response.data.index++;
- window.eoxiaJS.digirisk.DUER.generateDUER( element, response );
- } else {
- jQuery( '.generate-duer-modal' ).removeClass( 'no-close modal-force-display' );
+window.eoxiaJS.digirisk.causerie.displayImportGitFromExecute = function( event ){
+ jQuery( this ).closest( '.modal-container' ).find( '.view-git-element' ).show( '200' );
+ jQuery( this ).closest( '.modal-container' ).find( '.digi-view-execute' ).hide();
+}
+
+
+window.eoxiaJS.digirisk.causerie.importModalExecuteIt = function ( event ){
+
+ var content = '';
+ jQuery( this ).closest( '.modal-container' ).find('.digi-view-execute .digi-import-execute-success' ).each( function( e ){
+ content += jQuery( this ).find( 'span' ).html();
+ })
+
+ var request_data = {};
+ request_data.action = 'execute_git_txt';
+ request_data.content = content;
+ request_data._wpnonce = jQuery( this ).attr( 'data-nonce' );
+
+ window.eoxiaJS.loader.display( jQuery( this ) );
+ window.eoxiaJS.request.send( jQuery( this ), request_data );
+}
+
+window.eoxiaJS.digirisk.causerie.executeGitTxtSuccess = function ( triggeredElement, response ){
+ triggeredElement.closest( '.modal-container' ).find( '.tab-content' ).html( response.data.view );
+}
+
+window.eoxiaJS.digirisk.causerie.tabSelectRedirect = function( event ){
+ var url = jQuery( this ).attr( 'data-url' );
+ window.location.href = url;
+}
+
+
+window.eoxiaJS.digirisk.causerie.deletedAccidentSuccess = function( triggeredElement, response ){
+ triggeredElement.closest( '.causerie-row' ).hide( '200' );
+}
+
+window.eoxiaJS.digirisk.causerie.causerieImportTxtFromUrl = function( triggeredElement, response ){
+ if( response.data.view != "" ){
+ var parent_element = triggeredElement.closest( '.digi-view-textarea' );
+ parent_element.find( '.digi-import-add-keyword' ).hide();
+ parent_element.find( '.digi-import-modal-content-main' ).hide();
+ parent_element.find( '.digi-import-modal-content-main textarea' ).val( response.data.content );
+
+ parent_element.find( '.digi-import-modal-content-git' ).show();
+ parent_element.find( '.digi-import-modal-content-git' ).html( response.data.view );
+
+ triggeredElement.closest( '.modal-container' ).find( '.digi-button-import-git' ).show();
+ triggeredElement.closest( '.modal-container' ).find( '.digi-button-import' ).hide();
}
-};
+}
+
+window.eoxiaJS.digirisk.causerie.causerieImportDisplayTextarea = function( event ){
+ jQuery( this ).closest( '.modal-container' ).find( '.digi-import-modal-content-main' ).show();
+ jQuery( this ).closest( '.modal-container' ).find( '.digi-import-add-keyword' ).show();
+ jQuery( this ).closest( '.modal-container' ).find( '.digi-button-import' ).show();
+
+ jQuery( this ).closest( '.modal-container' ).find( '.digi-import-modal-content-git' ).hide();
+ jQuery( this ).closest( '.modal-container' ).find( '.digi-button-import-git' ).hide();
+}
-/**
- * @todo
- * @return {[type]} [description]
- */
-window.eoxiaJS.digirisk.DUER.callback_generate_duer_error = function() {};
/**
- * Lors de la fermeture de la popup qui génère le DUER.
+ * Clear le canvas.
*
- * @since 6.2.1
- * @version 6.5.0
+ * @since 6.4.0
*
- * @param {HTMLSpanElement} element L'élément déclencheur de l'action.
- * @param {ClickEvent} event L'état de la souris
+ * @param {Event} event L'état de l'évènement à ce moment T.
* @return {void}
*/
-window.eoxiaJS.digirisk.DUER.closeModalGenerateDUER = function( element, event ) {
- if ( jQuery( '.digirisk-wrap .tab-element[data-target="digi-list-duer"]' ) ) {
- jQuery( '.digirisk-wrap .tab-element[data-target="digi-list-duer"]' ).click();
- }
+window.eoxiaJS.digirisk.causerie.clearCanvas = function( event ) {
+ var canvas = jQuery( this ).closest( '.wpeo-modal' ).find( 'canvas' );
+ canvas[0].signaturePad.clear();
};
-/**
- * Initialise l'objet "evaluator" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
- *
- * @since 6.0.0
- * @version 6.3.1
- */
-
-window.eoxiaJS.digirisk.evaluator = {};
+"use strict";
-window.eoxiaJS.digirisk.evaluator.init = function() {
- window.eoxiaJS.digirisk.evaluator.event();
-};
+var digi_chemical_product = {
+ $: undefined,
-window.eoxiaJS.digirisk.evaluator.event = function() {
-};
+ init: function( event, $ ) {
+ digi_chemical_product.$ = $;
+ if ( event || event === undefined ) {
+ digi_chemical_product.event();
+ }
+ },
-/**
-* Après le changement d'onglet
-*
-* @since 6.3.1
-* @version 6.3.1
-*/
-window.eoxiaJS.digirisk.evaluator.tabChanged = function() {
- // window.eoxiaJS.digirisk.search.renderChanged();
+ event: function() {
+ digi_chemical_product.$( document ).on( 'click', '.form-chemical-product .wp-digi-action-new', function( event ) { digi_chemical_product.edit_chemical_product( event, digi_chemical_product.$( this ) ); } );
+ digi_chemical_product.$( document ).on( 'click', '.wp-digi-chemical-product .wp-digi-action-delete', function( event ) { digi_chemical_product.delete_chemical_product( event, digi_chemical_product.$( this ) ); } );
+ digi_chemical_product.$( document ).on( 'click', '.wp-digi-chemical-product .wp-digi-action-load', function( event ) { digi_chemical_product.load_chemical_product( event, digi_chemical_product.$( this ) ); } );
+ // digi_chemical_product.$( document ).on( 'click', '.wp-digi-chemical_product .wp-digi-action-edit', function( event ) { digi_chemical_product.edit_chemical_product( event, digi_chemical_product.$( this ) ); } );
+ },
+
+ edit_chemical_product: function( event, element ) {
+
+ digi_chemical_product.$( element ).closest( 'form' ).ajaxSubmit( {
+ 'beforeSubmit': function() {
+ digi_chemical_product.$( '.wp-digi-content' ).addClass( "wp-digi-bloc-loading" );
+ },
+ success: function( response ) {
+ digi_chemical_product.$( '.wp-digi-content' ).removeClass( "wp-digi-bloc-loading" );
+ digi_chemical_product.$( '.wp-digi-chemical-product.wp-digi-list' ).replaceWith( response.data.template );
+ }
+ } );
+ },
+
+ delete_chemical_product: function( event, element ) {
+ event.preventDefault();
+
+ if( window.confirm( window.digi_confirm_delete ) ) {
+ var chemical_product_id = digi_chemical_product.$( element ).data( 'id' );
+
+ digi_chemical_product.$( '.wp-digi-content' ).addClass( "wp-digi-bloc-loading" );
+
+ var data = {
+ action: 'wpdigi-delete-chemical_product',
+ _wpnonce: digi_chemical_product.$( element ).data( 'nonce' ),
+ global: digi_chemical_product.$( element ).data( 'global' ),
+ chemical_product_id: chemical_product_id,
+ };
+
+ digi_chemical_product.$.post( window.ajaxurl, data, function() {
+ digi_chemical_product.$( '.wp-digi-content' ).removeClass( "wp-digi-bloc-loading" );
+ digi_chemical_product.$( '.wp-digi-list .wp-digi-list-item[data-chemical-product-id="' + chemical_product_id + '"]' ).fadeOut();
+ } );
+ }
+ },
+
+ load_chemical_product: function( event, element ) {
+ event.preventDefault();
+
+ digi_chemical_product.send_chemical_product();
+
+ var chemical_product_id = digi_chemical_product.$( element ).data( 'id' );
+ digi_chemical_product.$( '.wp-digi-content' ).addClass( "wp-digi-bloc-loading" );
+
+ var data = {
+ action: 'load_chemical_product',
+ _wpnonce: digi_chemical_product.$( element ).data( 'nonce' ),
+ chemical_product_id: chemical_product_id,
+ };
+
+ digi_chemical_product.$.post( window.ajaxurl, data, function( response ) {
+ digi_chemical_product.$( '.wp-digi-list-item .dashicons-edit' ).hide();
+ digi_chemical_product.$( '.wp-digi-content' ).removeClass( "wp-digi-bloc-loading" );
+ digi_chemical_product.$( '.wp-digi-chemical-product .wp-digi-list-item[data-chemical-product-id="' + chemical_product_id + '"]' ).replaceWith( response.data.template );
+ } );
+ },
+
+ send_chemical_product: function() {
+ digi_chemical_product.$( '.wp-digi-table-item-edit' ).each( function() {
+ digi_chemical_product.$( this ).find( '.dashicons-edit' ).click();
+ } );
+ }
+};
+
+window.eoxiaJS.digirisk.comment = {};
+
+window.eoxiaJS.digirisk.comment.init = function() {
+ window.eoxiaJS.digirisk.comment.event();
+};
+
+window.eoxiaJS.digirisk.comment.event = function() {};
+
+window.eoxiaJS.digirisk.comment.delete_success = function( element, response ) {
+ jQuery( element ).closest( 'li' ).fadeOut();
};
+window.eoxiaJS.digirisk.comment.saved_comment_success = function( element, response ) {
+ element.closest( '.comment-container' ).replaceWith( response.data.view );
+};
+
/**
- * Le callback en cas de réussite à la requête Ajax "edit_evaluator_assign".
- * Remplaces le contenu du tableau "affected-evaluator" par le template renvoyé par la requête Ajax.
- *
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
+ * Initialise l'objet "correctiveTask" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
*
* @since 6.0.0
- * @version 6.4.0
+ * @version 6.4.4
*/
-window.eoxiaJS.digirisk.evaluator.callback_edit_evaluator_assign_success = function( triggeredElement, response ) {
- triggeredElement.closest( '.table-row.evaluator-row.edit' ).before( response.data.view );
- triggeredElement.closest( '.table-row.evaluator-row.edit' ).find('.autocomplete-icon-after').click();
+
+window.eoxiaJS.digirisk.correctiveTask = {};
+
+window.eoxiaJS.digirisk.correctiveTask.init = function() {
+ window.eoxiaJS.digirisk.correctiveTask.event();
};
/**
- * Gestion de la suppression des évaluateurs.
+ * Les évènements
+ *
+ * @since 6.0.0
+ * @version 6.4.4
*
- * @param {ClickEvent} event [description]
* @return {void}
*
- * @since 6.0.0
- * @version 6.2.5
+ * @todo: En attente de la livraison 1.6.0 de Task Manager pour décommenter le code.
*/
-window.eoxiaJS.digirisk.evaluator.callback_detach_evaluator_success = function( element, response ) {
- element.closest( '.table-row' ).fadeOut();
+window.eoxiaJS.digirisk.correctiveTask.event = function() {
+ // jQuery( document ).on( 'change', '.popup.corrective-task .point[data-id="0"] input[name="content"]', window.eoxiaJS.digirisk.correctiveTask.listenAddSafeExit );
+ // jQuery( document ).on( 'addedPointSuccess', '.popup.corrective-task .point[data-id="0"] .action-input', window.eoxiaJS.digirisk.correctiveTask.addedPointSuccess );
};
-
-
-
/**
- * Gères l'export en CSV
+ * Si le contenu du point à ajouter change, on ajoutes le "safeExit".
*
- * @author Jimmy Latour
+ * @since 6.4.4
+ * @version 6.4.4
*
- * @since 6.2.6.0
- * @version 6.2.6.0
+ * @param {CustomEvent} event Evenement spécial envoyé par TaskManager lors de la modification d'un point.
*
- * @memberof export
+ * @return {void}
*/
+window.eoxiaJS.digirisk.correctiveTask.listenAddSafeExit = function( event ) {
+ if ( '' !== jQuery( this ).val() ) {
+ jQuery( '.popup.corrective-task' ).addClass( 'no-close' );
+ jQuery( '.popup.corrective-task .message' ).removeClass( 'hidden' );
+ window.addEventListener( 'beforeunload', window.eoxiaJS.digirisk.correctiveTask.safeExit );
+ } else {
+ jQuery( '.popup.corrective-task' ).removeClass( 'no-close' );
+ jQuery( '.popup.corrective-task .message' ).addClass( 'hidden' );
+ window.removeEventListener( 'beforeunload', window.eoxiaJS.digirisk.correctiveTask.safeExit );
+ }
+};
/**
- * Initialise l'objet exportCSV dans l'objet digirisk
- * @memberof export
- * @type {Object}
+ * Evenement envoyé par Task Manager lorsqu'un point est ajouté correctement.
+ *
+ * @since 6.4.4
+ * @version 6.4.4
+ *
+ * @param {CustomEvent} event Envoyé par Task Manager.
+ *
+ * @return {void}
*/
-window.eoxiaJS.digirisk.exportCSV = {};
+window.eoxiaJS.digirisk.correctiveTask.addedPointSuccess = function( event ) {
+ jQuery( '.popup.corrective-task' ).removeClass( 'no-close' );
+ jQuery( '.popup.corrective-task .message' ).addClass( 'hidden' );
+ window.removeEventListener( 'beforeunload', window.eoxiaJS.digirisk.correctiveTask.safeExit );
+};
/**
- * La méthode init est appelé automatiquement
- *
- * @since 6.1.5.5
- * @version 6.2.1.2
+ * Vérification avant la fermeture de la page si toutes les données sont enregistrées.
*
- * @memberof exportCSV
+ * @since 6.4.4
+ * @version 6.4.4
*
- * @return {void}
+ * @param {WindowEventHandlers} event L'évènement de la fenêtre.
+ * @return {string}
*/
-window.eoxiaJS.digirisk.exportCSV.init = function() {
- window.eoxiaJS.digirisk.exportCSV.event();
+window.eoxiaJS.digirisk.correctiveTask.safeExit = function( event ) {
+ var confirmationMessage = 'Vos données sont en attentes d\'enregistrement';
+
+ event.returnValue = confirmationMessage;
+ return confirmationMessage;
};
/**
- * Initialies les évènements submit et change
+ * Le callback en cas de réussite à la requête Ajax "open_task".
+ * Remplaces le contenu de la popup "corrective-task" par la vue renvoyée par la réponse Ajax.
*
- * @since 6.2.6.0
- * @version 6.2.6.0
+ * @since 6.0.0
+ * @version 6.4.4
*
- * @memberof exportCSV
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
*
* @return {void}
*/
-window.eoxiaJS.digirisk.exportCSV.event = function() {
- jQuery( document ).on( 'click', '#digi-export-csv-form button.blue', window.eoxiaJS.digirisk.exportCSV.makeExport );
+window.eoxiaJS.digirisk.correctiveTask.openedTaskPopup = function( triggeredElement, response ) {
+ jQuery( '.popup.corrective-task .content' ).html( response.data.view );
+ jQuery( '.popup.corrective-task .container.loading' ).removeClass( 'loading' );
};
+
+/**
+ * Initialise l'objet "diffusionInformations" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ *
+ * @since 6.4.0
+ */
+
+window.eoxiaJS.digirisk.diffusionInformations = {};
+
+window.eoxiaJS.digirisk.diffusionInformations.init = function() {};
/**
- * Utilises ajaxSubmit pour envoyer le formulaire en AJAX.
+ * Le callback en cas de réussite à la requête Ajax "generate_diffusion_information".
+ * Actualises la vue en cliquant sur l'onglet "Informations".
*
- * @param {ClickEvent} event L'évènement du clic.
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
* @return {void}
*
- * @since 6.2.6.0
- * @version 6.2.6.0
+ * @since 6.4.0
*/
-window.eoxiaJS.digirisk.exportCSV.makeExport = function( event ) {
- var button = jQuery( this );
- event.preventDefault();
- jQuery( this ).closest( 'form' ).ajaxSubmit( {
- 'beforeSubmit': function() {
- window.eoxiaJS.loader.display( button );
- },
- success: function( response ) {
- if ( response.data.end ) {
- button.closest( 'form' ).find( 'progress' ).attr( 'max', 100 );
- button.closest( 'form' ).find( 'progress' ).val( 100 );
- window.eoxiaJS.loader.remove( button );
- window.eoxiaJS.global.downloadFile( response.data.url_to_file, response.data.filename );
- jQuery( '#digi-export-csv-form input[name="offset"]' ).val( 0 );
- jQuery( '#digi-export-csv-form input[name="filepath"]' ).val( '' );
- jQuery( '#digi-export-csv-form input[name="filename"]' ).val( '' );
- jQuery( '#digi-export-csv-form input[name="number_risks"]' ).val( 0 );
- jQuery( '#digi-export-csv-form input[name="url_to_file"]' ).val( '' );
- } else {
- button.closest( 'form' ).find( 'progress' ).attr( 'max', response.data.number_risks );
- button.closest( 'form' ).find( 'progress' ).val( ( response.data.offset / response.data.number_risks ) * response.data.number_risks );
- jQuery( '#digi-export-csv-form input[name="offset"]' ).val( response.data.offset );
- jQuery( '#digi-export-csv-form input[name="filepath"]' ).val( response.data.filepath );
- jQuery( '#digi-export-csv-form input[name="filename"]' ).val( response.data.filename );
- jQuery( '#digi-export-csv-form input[name="number_risks"]' ).val( response.data.number_risks );
- jQuery( '#digi-export-csv-form input[name="url_to_file"]' ).val( response.data.url_to_file );
-
- jQuery( '#digi-export-csv-form button.blue' ).click();
- }
- }
- } );
+window.eoxiaJS.digirisk.diffusionInformations.generatedDiffusionInformationSuccess = function( triggeredElement, response ) {
+ jQuery( '.tab-list .tab-element[data-target="digi-diffusion-informations"]' ).click();
};
-/**
- * Gères l'export et l'import des modèles de donnée de DigiRisk
- *
- * @author Evarisk
- *
- * @since 6.1.5.5
- *
- * @memberof export
- */
-
-/**
- * Initialise l'objet export dans l'objet digirisk
- * @memberof export
- * @type {Object}
- */
-window.eoxiaJS.digirisk.export = {};
-
-/**
- * La méthode init est appelé automatiquement
- *
- * @since 6.1.5.5
- *
- * @memberof export
- *
- * @return {void}
- */
-window.eoxiaJS.digirisk.export.init = function() {
- window.eoxiaJS.digirisk.export.event();
-};
-
-/**
- * Initialies les évènements submit et change
- *
- * @since 6.1.5.5
- *
- * @memberof export
- *
- * @return {void}
- */
-window.eoxiaJS.digirisk.export.event = function() {
- jQuery( document ).on( 'submit', '#digi-data-export #digi-export-form, #digi-data-export #digi-export-tree, #digi-data-export #digi-export-risks', window.eoxiaJS.digirisk.export.create_export );
- jQuery( document ).on( 'change', '#digi-data-export #digi-import-form input[type="file"]', window.eoxiaJS.digirisk.export.make_import );
-};
-
-/**
- * Lances la requête XHR pour créer le fichier .zip de l'export du modèle de donnée.
- *
- * @since 6.1.5.5
- *
- * @param {Object} event [description]
- * @return {void}
- */
-window.eoxiaJS.digirisk.export.create_export = function( event ) {
- var form = jQuery( this );
- event.preventDefault();
- jQuery( this ).closest( 'form' ).ajaxSubmit( {
- 'beforeSubmit': function() {
- window.eoxiaJS.loader.display( form.find( 'button' ) );
- },
- success: function( response ) {
- window.eoxiaJS.loader.remove( form.find( 'button' ) );
- window.eoxiaJS.global.downloadFile( response.data.url_to_file, response.data.filename );
- }
- } );
-},
-
-/**
- * Prépare la première requête pour importer un modèle de donnée.
- *
- * @since 6.1.5.5
- *
- * @param {[type]} event [description]
- * @return {void}
- */
-window.eoxiaJS.digirisk.export.make_import = function( event ) {
- var data = new FormData();
-
- event.preventDefault();
-
- data.append( 'file', jQuery( this )[0].files[0] );
- data.append( 'action', 'digi_import_data' );
- data.append( '_wpnonce', jQuery( this ).closest( 'form' ).find( 'input[name="_wpnonce"]' ).val() );
- data.append( 'index_element', 0 );
-
- window.eoxiaJS.digirisk.export.request_import( data );
-},
-
-/**
- * Lances la requête pour importer un modèle de donnée.
- * Modifie la barre de progression.
- *
- * @since 6.1.5.5
- *
- * @param {object} data Les données pour la requête
- * @return {void}
- */
-window.eoxiaJS.digirisk.export.request_import = function( data ) {
- jQuery.ajax( {
- url: ajaxurl,
- data: data,
- processData: false,
- contentType: false,
- type: 'POST',
- beforeSend: function() {
- window.eoxiaJS.loader.display( jQuery( '#digi-import-form .button.blue' ) );
- jQuery( '.digi-import-detail' ).html( window.digi_tools_in_progress );
- },
- success: function( response ) {
- var data = new FormData();
-
- if ( response.success ) {
- jQuery( '#digi-import-form progress' ).attr( 'max', response.data.count_element );
- jQuery( '#digi-import-form progress' ).val( ( response.data.index_element / response.data.count_element ) * response.data.count_element );
-
- if ( ! response.data.end ) {
- data.append( 'action', 'digi_import_data' );
- data.append( '_wpnonce', jQuery( '#digi-import-form' ).find( 'input[name="_wpnonce"]' ).val() );
- data.append( 'path_to_json', response.data.path_to_json );
- data.append( 'index_element', response.data.index_element );
- jQuery( '.digi-import-detail' ).html( window.digi_tools_in_progress );
- window.eoxiaJS.digirisk.export.request_import( data );
- } else {
- jQuery( '.digi-import-detail' ).html( window.digi_tools_done );
- if ( jQuery( '#toplevel_page_digi-setup a' ).attr( 'href' ) ) {
- jQuery( '#toplevel_page_digi-setup a' ).attr( 'href', jQuery( '#toplevel_page_digi-setup a' ).attr( 'href' ).replace( 'digi-setup', 'digirisk' ) );
- }
-
- jQuery( '#digi-import-form progress' ).attr( 'max', 100 );
- jQuery( '#digi-import-form progress' ).val( 100 );
-
- window.eoxiaJS.loader.remove( jQuery( '#digi-import-form .button.blue' ) );
- }
- } else {
- alert( 'Problème lors de l\'importation du modèle' );
- }
- }
- } );
-};
-
/**
- * Initialise l'objet "group" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ * Initialise l'objet "DUER" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
*
- * @since 1.0
- * @version 6.2.4.0
+ * @since 6.2.1
+ * @version 7.0.0
*/
-window.eoxiaJS.digirisk.group = {};
+window.eoxiaJS.digirisk.DUER = {};
/**
- * La méthode appelée automatiquement par la bibliothèque EoxiaJS.
- *
- * @return {void}
+ * Méthode obligatoire pour initialiser l'objet DUER avec EO-Framework.
*
- * @since 1.0
- * @version 6.2.4.0
- */
-window.eoxiaJS.digirisk.group.init = function() {};
-
-/**
- * Le callback en cas de réussite à la requête Ajax "create_group".
- * Remplaces le contenu de toute l'application par la vue renvoyé par la requête Ajax.
- * Clic ensuite sur le nouveau groupement pour lancer la requête "load_society".
+ * @since 6.2.1
+ * @version 6.2.1
*
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
* @return {void}
- *
- * @since 1.0
- * @version 6.2.4.0
*/
-window.eoxiaJS.digirisk.group.createdGroupSuccess = function( element, response ) {
- jQuery( '.digirisk-wrap' ).replaceWith( response.data.template );
- jQuery( '.workunit-navigation span.action-attribute[data-groupment-id="' + response.data.groupment_id + '"]' ).click();
+window.eoxiaJS.digirisk.DUER.init = function() {
+ window.eoxiaJS.digirisk.DUER.event();
};
-
+
/**
- * Initialise l'objet "handleModel" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ * Méthode pour initialiser tous les évènements.
*
- * @since 6.0.0
- * @version 6.3.0
+ * @since 6.2.1
+ * @version 7.0.0
+ *
+ * @return void
*/
+window.eoxiaJS.digirisk.DUER.event = function() {
+ jQuery( document ).on( 'modal-opened', '.duer-modal', window.eoxiaJS.digirisk.DUER.modalOpened );
+ jQuery( document ).on( 'click', '.duer-modal .button-main', window.eoxiaJS.digirisk.DUER.applyValueToTextarea );
-window.eoxiaJS.digirisk.handleModel = {};
+ jQuery( document ).on( 'modal-opened', '.generate-duer-modal', window.eoxiaJS.digirisk.DUER.generateDUERModalOpened );
+ jQuery( document ).on( 'click', '.generate-duer-modal .button-main', window.eoxiaJS.digirisk.DUER.closeModalGenerateDUER );
+};
/**
- * Keep the button in memory.
- *
- * @type {Object}
+ * @todo
+ * @param {[type]} event [description]
+ * @param {[type]} data [description]
+ * @return {[type]} [description]
*/
-window.eoxiaJS.digirisk.handleModel.currentButton;
+window.eoxiaJS.digirisk.DUER.modalOpened = function( event, triggeredElement ) {
+ jQuery( this ).find( '.modal-content' ).html( '' );
-/**
- * Keep the media frame in memory.
- * @type {Object}
- */
-window.eoxiaJS.digirisk.handleModel.mediaFrame;
+ if ( 'view' !== jQuery( triggeredElement ).data( 'type' ) ) {
+ var textareaContent = jQuery( triggeredElement ).closest( '.table-row' ).find( '.textarea-content-' + jQuery( triggeredElement ).data( 'src' ) ).val();
+ jQuery( this ).find( '.modal-content' ).html( '' );
-/**
- * Keep the selected media in memory.
- * @type {Object}
- */
-window.eoxiaJS.digirisk.handleModel.selectedInfos = {
- JSON: undefined,
- fileID: undefined
-};
+ jQuery( '.duer-modal' ).find( 'textarea' ).val( textareaContent );
+ } else {
+ var content = jQuery( triggeredElement ).closest( '.table-row' ).find( '.text-content-' + jQuery( triggeredElement ).data( 'src' ) ).html();
+ jQuery( this ).find( '.modal-content' ).html( '
' );
-window.eoxiaJS.digirisk.handleModel.init = function() {
- window.eoxiaJS.digirisk.handleModel.event();
+ jQuery( '.duer-modal' ).find( 'p' ).html( content );
+ }
};
/**
- * Les évènements
+ * [description]
*
- * @return {void}
+ * @since 7.0.0
+ *
+ * @param {[type]} triggeredElement [description]
*/
-window.eoxiaJS.digirisk.handleModel.event = function() {
- jQuery( document ).on( 'click', '.digi-tools-main-container .upload-model', window.eoxiaJS.digirisk.handleModel.openMediaFrame );
+window.eoxiaJS.digirisk.DUER.viewInPopup = function( triggeredElement ) {
+ return true;
};
/**
- * Open the media frame from WordPress.
- *
- * @return void
- *
- * @since 6.3.0
- * @version 6.3.0
+ * @todo
+ * @param {[type]} event [description]
+ * @return {[type]} [description]
*/
-window.eoxiaJS.digirisk.handleModel.openMediaFrame = function() {
- window.eoxiaJS.digirisk.handleModel.currentButton = jQuery( this );
- window.eoxiaJS.digirisk.handleModel.mediaFrame = new window.wp.media.view.MediaFrame.Post({
- library: {
- type: 'application/vnd.oasis.opendocument.text'
- }
- }).open();
- window.eoxiaJS.digirisk.handleModel.mediaFrame.on( 'insert', function() { window.eoxiaJS.digirisk.handleModel.selectedFile(); } );
+window.eoxiaJS.digirisk.DUER.applyValueToTextarea = function( event ) {
+ var textarea = jQuery( '.duer-modal' ).find( 'textarea' );
+
+ jQuery( '.wpeo-table.table-duer .table-edit .textarea-content-' + textarea.attr( 'data-to' ) ).val( textarea.val() );
};
+window.eoxiaJS.digirisk.DUER.generateDUERModalOpened = function( event, triggeredElement ) {
+ window.eoxiaJS.digirisk.DUER.generateDUER( jQuery( triggeredElement ), {
+ data: {
+ index: 1
+ }
+ } );
+}
+
/**
- * Get the media selected and call associateFile.
+ * Construit, et génères tous les documents ainsi que le DUER.
*
- * @return void
+ * @since 6.2.1
+ * @version 7.0.0
*
- * @since 6.3.0
- * @version 6.3.0
+ * @param {HTMLDivElement} triggeredElement [description]
+ * @param {object} preData [description]
+ * @return {void} [description]
*/
-window.eoxiaJS.digirisk.handleModel.selectedFile = function() {
- window.eoxiaJS.digirisk.handleModel.mediaFrame.state().get( 'selection' ).map( function( attachment ) {
- window.eoxiaJS.digirisk.handleModel.selectedInfos.JSON = attachment.toJSON();
- window.eoxiaJS.digirisk.handleModel.selectedInfos.id = attachment.id;
- } );
- window.eoxiaJS.digirisk.handleModel.associateFile();
-};
+window.eoxiaJS.digirisk.DUER.generateDUER = function( triggeredElement, preData ) {
+ var data = {};
+ var i = 0;
+ var key;
+ var listInput = window.eoxiaJS.arrayForm.getInput( triggeredElement.closest( '.table-row' ) );
-/**
- * Make request for associate file
- *
- * @return void
- *
- * @since 6.3.0
- * @version 6.3.0
- */
-window.eoxiaJS.digirisk.handleModel.associateFile = function() {
- var data = {
- action: 'set_model',
- type: window.eoxiaJS.digirisk.handleModel.currentButton.data( 'type' ),
- file_id: window.eoxiaJS.digirisk.handleModel.selectedInfos.id,
- dashboard: window.eoxiaJS.digirisk.handleModel.currentButton.data( 'dashboard' )
- };
+ for ( i = 0; i < listInput.length; i++ ) {
+ if ( listInput[i].name ) {
+ data[listInput[i].name] = window.eoxiaJS.arrayForm.getInputValue( listInput[i] );
+ }
+ }
- window.eoxiaJS.loader.display( window.eoxiaJS.digirisk.handleModel.currentButton );
+ for ( key in preData.data ) {
+ data[key] = preData.data[key];
+ }
- jQuery.post( window.ajaxurl, data, function( response ) {
- if ( response.data.dashboard ) {
- jQuery( '.model-items' ).replaceWith( response.data.view );
- } else {
- jQuery('#digi-handle-model').html(response.data.view);
+ jQuery( '.generate-duer-modal li:nth-child(' + ( preData.data.index ) + ')' ).get_data( function( attributeData ) {
+ for( key in attributeData ) {
+ data[key] = attributeData[key];
}
+
+ window.eoxiaJS.request.send( triggeredElement, data );
} );
};
/**
- * Après la requête AJAX qui ouvre la popup "Historique des modèles"
+ * Le callback en cas de réussite à la requête Ajax "generate_DUER".
+ * Coches le LI correspondant à index et regénères un DUER.
+ * Si la réponse contient "end", stop la génération du DUER, et rend le bouton cliquable.
*
- * @param {HTMLAnchorElement} element Le lien qui permet d'ouvrir la popup
- * @param {Object} response Les données de la réponse de la requête XHR
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
* @return {void}
+ *
+ * @since 6.2.1
+ * @version 6.5.0
*/
-window.eoxiaJS.digirisk.handleModel.loadedPopupHistoric = function( element, response ) {
- element.closest( '.block' ).find( '.popup .title' ).text( response.data.title );
- element.closest( '.block' ).find( '.popup .content' ).html( response.data.view );
- jQuery( '.container.loading' ).removeClass( 'loading' );
+window.eoxiaJS.digirisk.DUER.generatedDUERSuccess = function( element, response ) {
+ jQuery( '.generate-duer-modal li:nth-child(' + ( response.data.index ) + ')' ).find( 'img' ).remove();
+ jQuery( '.generate-duer-modal li:nth-child(' + ( response.data.index ) + ')' ).append( ' ' );
+
+ if ( ! response.data.end ) {
+ response.data.index++;
+ window.eoxiaJS.digirisk.DUER.generateDUER( element, response );
+ } else {
+ jQuery( '.generate-duer-modal' ).removeClass( 'no-close modal-force-display' );
+ }
};
/**
- * Met à jour le bouton "Télécharger le modèle courant" de response.data.type
- * @param {HTMLAnchorElement} element Le lien "Télécharger le modèle courant"
- * @param {void}
+ * @todo
+ * @return {[type]} [description]
*/
-window.eoxiaJS.digirisk.handleModel.reset_default_model_success = function( element, response ) {
- element.closest( '.block' ).find( 'li:first a' ).attr( 'href', response.data.url );
-};
-
+window.eoxiaJS.digirisk.DUER.callback_generate_duer_error = function() {};
+
/**
- * Initialise l'objet "historic" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ * Lors de la fermeture de la popup qui génère le DUER.
*
- * @since 6.3.0
- * @version 6.4.0
+ * @since 6.2.1
+ * @version 6.5.0
+ *
+ * @param {HTMLSpanElement} element L'élément déclencheur de l'action.
+ * @param {ClickEvent} event L'état de la souris
+ * @return {void}
*/
-window.eoxiaJS.digirisk.historic = {};
+window.eoxiaJS.digirisk.DUER.closeModalGenerateDUER = function( element, event ) {
+ if ( jQuery( '.digirisk-wrap .tab-element[data-target="digi-list-duer"]' ) ) {
+ jQuery( '.digirisk-wrap .tab-element[data-target="digi-list-duer"]' ).click();
+ }
+};
+
+window.eoxiaJS.digirisk.document = {};
-window.eoxiaJS.digirisk.historic.init = function() {
- window.eoxiaJS.digirisk.historic.event();
+window.eoxiaJS.digirisk.document.init = function() {
+ window.eoxiaJS.digirisk.document.event();
};
-window.eoxiaJS.digirisk.historic.event = function() {};
+window.eoxiaJS.digirisk.document.event = function() {
+ jQuery( ".wp-digi-societytree-right-container" ).on( "click", "#wpdigi-save-element-sheet", window.eoxiaJS.digirisk.document.save_element_sheet );
+ jQuery( ".wp-digi-societytree-right-container" ).on( "click", ".wp-digi-list-document .wp-digi-action-regenerate", window.eoxiaJS.digirisk.document.regenerate_document );
+ jQuery( document ).on( 'click', '.wp-digi-doc-pagination a', window.eoxiaJS.digirisk.document.pagination );
-/**
- * Le callback en cas de réussite à la requête Ajax "historic_risk".
- * Remplaces le contenu de la popup "corrective-task" par la vue renvoyée par la réponse Ajax.
- *
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
- *
- * @since 6.3.0
- * @version 6.4.0
- */
-window.eoxiaJS.digirisk.historic.openedHistoricRiskPopup = function( triggeredElement, response ) {
- jQuery( '.popup.historic-risk .content' ).html( response.data.view );
- jQuery( '.popup.historic-risk .container.loading' ).removeClass( 'loading' );
};
-
-/**
- * Initialise l'objet "installer" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
- *
- * @since 6.0.0
- */
-window.eoxiaJS.digirisk.installer = {};
-window.eoxiaJS.digirisk.installer.progressInterval = undefined;
+window.eoxiaJS.digirisk.document.save_element_sheet = function ( event ) {
+ event.preventDefault();
+
+ jQuery( this ).addClass( "wp-digi-loading" );
+
+
+ var options = {
+ beforeSubmit: function( formData, jqForm, options ) {
+ },
+ success: function( responseText, statusText, xhr, $form ) {
+ jQuery( this ).removeClass( "wp-digi-loading" );
+ if ( responseText.success ) {
+ if ( undefined !== jQuery( ".wp-digi-global-sheet-content ul.wp-digi-list-document" ).html() ) {
+ jQuery( ".wp-digi-global-sheet-content ul.wp-digi-list-document" ).prepend( responseText.data.output );
+ }
+ else {
+ jQuery( ".wp-digi-global-sheet-tab li.wp-digi-sheet-generation-button" ).click();
+ }
+ }
+ else {
+
+ }
+ },
+ dataType: "json",
+ resetForm: true,
+ };
+ jQuery( "#wpdigi-save-element-form" ).ajaxSubmit( options );
+};
+
+window.eoxiaJS.digirisk.document.regenerate_document = function ( event ) {
+ event.preventDefault();
+
+ var data = {
+ action: 'wpdigi_regenerate_document',
+ element_id: jQuery( this ).data( 'id' ),
+ parent_id: jQuery( this ).data( 'parent-id' ),
+ model_name: jQuery( this ).data( 'model'),
+ _wpnonce: jQuery( this ).data( 'nonce' ),
+ };
+ jQuery.post( window.ajaxurl, data, function() {} );
+};
+
+window.eoxiaJS.digirisk.document.pagination = function( event ) {
+ event.preventDefault();
+
+ var href = jQuery( this ).attr( 'href' ).split( '&' );
+ var next_page = href[1].replace('current_page=', '');
+ var element_id = href[2].replace('element_id=', '');
+
+ var data = {
+ action: 'paginate_document',
+ element_id: element_id,
+ next_page: next_page
+ };
+ jQuery.post( window.ajaxurl, data, function( template ) {
+ jQuery( '.doc-content' ).replaceWith( template );
+ } );
+};
+
/**
- * Méthodes obligatoire pour utiliser EO-JS.
+ * Initialise l'objet "evaluationMethod" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
*
- * @since 6.0.0
+ * @since 7.0.0
+ * @version 7.0.0
*/
-window.eoxiaJS.digirisk.installer.init = function() {
- window.eoxiaJS.digirisk.installer.event();
- window.eoxiaJS.digirisk.initOwlCarousel();
+window.eoxiaJS.digirisk.evaluationMethod = {};
+
+window.eoxiaJS.digirisk.evaluationMethod.init = function() {
+ window.eoxiaJS.digirisk.evaluationMethod.event();
};
+window.eoxiaJS.digirisk.evaluationMethod.event = function() {};
+
+window.eoxiaJS.digirisk.evaluationMethod.updateInputVariables = function( riskID, evaluationID, variableID, value, field ) {
+ var updateEvaluationID = false;
+
+ if ( ! field ) {
+ updateEvaluationID = true;
+ field = jQuery( '.risk-row.edit[data-id="' + riskID + '"] textarea[name="evaluation_variables"]' );
+ }
+
+ var currentVal = JSON.parse(field.val());
+
+ currentVal[variableID] = value;
+
+ field.val( JSON.stringify( currentVal ) );
+
+ if ( updateEvaluationID ) {
+ jQuery( '.risk-row.edit[data-id="' + riskID + '"] input[name="evaluation_method_id"]' ).val( evaluationID );
+ }
+
+ // Rend le bouton "active".
+ if ( '-1' !== jQuery( '.risk-row.edit[data-id="' + riskID + '"]' ).find( 'input[name="risk_category_id"]' ).val() ) {
+ jQuery( '.risk-row.edit[data-id="' + riskID + '"]' ).find( '.action .wpeo-button.button-disable' ).removeClass( 'button-disable' );
+ }
+};
+
/**
- * Initialise tous les évènements pour la page "digi-setup".
+ * Initialise l'objet "evaluationMethodDropdown" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
*
* @since 6.0.0
+ * @version 6.5.0
*/
-window.eoxiaJS.digirisk.installer.event = function() {
- jQuery( document ).on( 'keyup', '.wpdigi-installer input[name="title"]', window.eoxiaJS.digirisk.installer.keyUpGroupmentTitle );
- jQuery( document ).on( 'click', '.wpdigi-installer input[type="checkbox"]', window.eoxiaJS.digirisk.installer.toggleDefaultInstall );
+window.eoxiaJS.digirisk.evaluationMethodDropdown = {};
- jQuery( document ).on( 'click', '.wpdigi-installer input[name="title"]', window.eoxiaJS.digirisk.installer.emptyPlaceHolder );
- jQuery( document ).on( 'blur', '.wpdigi-installer input[name="title"]', window.eoxiaJS.digirisk.installer.fillProgressBar );
+window.eoxiaJS.digirisk.evaluationMethodDropdown.init = function() {
+ window.eoxiaJS.digirisk.evaluationMethodDropdown.event();
+};
+
+window.eoxiaJS.digirisk.evaluationMethodDropdown.event = function() {
+ jQuery( document ).on( 'click', '.table.risk .dropdown-list li.dropdown-item:not(.open-popup), .wpeo-table.table-listing-risk .dropdown-list li.dropdown-item:not(.open-popup), .wpeo-table.table-risk .dropdown-list li.dropdown-item:not(.open-popup)', window.eoxiaJS.digirisk.evaluationMethodDropdown.selectSeuil );
};
/**
- * Initialise le "owlCarousel" sur l'élement "owl-carousel".
+ * Clique sur une des cotations simples.
+ *
+ * @param {ClickEvent} event L'état du clic.
+ * @return {void}
*
* @since 6.0.0
+ * @version 7.0.0
*/
-window.eoxiaJS.digirisk.initOwlCarousel = function() {
- jQuery( '.owl-carousel' ).owlCarousel( {
- 'items': 1,
- 'nav': true,
- 'navText': [],
- 'pagination': true,
- 'autoHeight': true,
- 'autoplay': true,
- 'autoplayTimeout': 25000
- } );
-}
+window.eoxiaJS.digirisk.evaluationMethodDropdown.selectSeuil = function( event ) {
+ var element = jQuery( this );
+ var riskID = element.data( 'id' );
+ var seuil = element.data( 'seuil' );
+ var variableID = element.data( 'variable-id' );
+ var evaluationID = element.data( 'evaluation-id' );
-/**
- * Évènement lors du "keyup" sur le champ "Nom de ma société".
- *
- * @since 6.0.0
- *
- * @param {KeyEvent} event L'état du clavier.
- */
-window.eoxiaJS.digirisk.installer.keyUpGroupmentTitle = function( event ) {
- if ( 13 === event.keyCode ) {
- jQuery( '.main-content .action-input:first' ).click();
- }
+ jQuery( '.risk-row.edit[data-id="' + riskID + '"] .cotation-container .dropdown-toggle.cotation span' ).text( jQuery( this ).text() );
+ jQuery( '.risk-row.edit[data-id="' + riskID + '"] .cotation-container .dropdown-toggle.cotation' ).attr( 'data-scale', seuil );
- if ( jQuery( this ).val() != '' ) {
- jQuery( '.wpdigi-installer .bar .loader' ).css( 'width', '12%' );
- jQuery( '.wpdigi-installer .bar .loader' ).attr( 'data-width', 12 );
- } else {
- jQuery( '.wpdigi-installer .bar .loader' ).css( 'width', '0%' );
- jQuery( '.wpdigi-installer .bar .loader' ).attr( 'data-width', 0 );
+
+ if ( variableID && evaluationID && seuil ) {
+ window.eoxiaJS.digirisk.evaluationMethod.updateInputVariables( riskID, evaluationID, variableID, seuil );
}
};
-
+
/**
- * Ouvre les détails des données par défaut lorsqu'on "check" la case à coché.
- *
- * @since 7.0.0
+ * Initialise l'objet "evaluationMethodEvarisk" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
*
- * @param {MouseEvent} event L'état de la souri lors du clic.
+ * @since 1.0
+ * @version 6.2.6.0
*/
-window.eoxiaJS.digirisk.installer.toggleDefaultInstall = function( event ) {
- jQuery( '.wpdigi-installer .bloc-create-society .default-data-details' ).toggleClass( 'hidden' );
+window.eoxiaJS.digirisk.evaluationMethodEvarisk = {};
+
+window.eoxiaJS.digirisk.evaluationMethodEvarisk.init = function() {
+ window.eoxiaJS.digirisk.evaluationMethodEvarisk.event();
};
-/**
- * Enlèves le placeholder lors du "clic" sur le champ "Nom de ma société".
- *
- * @since 6.0.0
- *
- * @param {ClickEvent} event L'état du clique.
- */
-window.eoxiaJS.digirisk.installer.emptyPlaceHolder = function( event ) {
- if ( '' === jQuery( this ).val() ) {
- jQuery( this ).closest( '.society-form' ).find( 'label' ).hide();
- }
+window.eoxiaJS.digirisk.evaluationMethodEvarisk.event = function() {
+ jQuery( document ).on( 'click', '.wpeo-modal.evaluation-method .wpeo-table.evaluation-method .table-cell.can-select', window.eoxiaJS.digirisk.evaluationMethodEvarisk.selectSeuil );
+ jQuery( document ).on( 'click', '.wpeo-modal.evaluation-method .wpeo-button.button-main', window.eoxiaJS.digirisk.evaluationMethodEvarisk.save );
+ jQuery( document ).on( 'click', '.wpeo-modal.evaluation-method .wpeo-button.button-secondary', window.eoxiaJS.digirisk.evaluationMethodEvarisk.close_modal );
};
-/**
- * Remplie la barre de progression.
- *
- * @since 6.0.0
- *
- * @param {FocusEvent} event L'état du focus.
- */
-window.eoxiaJS.digirisk.installer.fillProgressBar = function( event ) {
- if ( '' === jQuery( this ).val() ) {
- jQuery( this ).closest( '.society-form' ).find( 'label' ).show();
- jQuery( '.wpdigi-installer .bar .loader' ).css( 'width', '0%' );
- jQuery( '.wpdigi-installer .bar .loader' ).attr( 'data-width', 0 );
+window.eoxiaJS.digirisk.evaluationMethodEvarisk.selectSeuil = function( event ) {
+ jQuery( this ).closest( '.table-row' ).find( '.active' ).removeClass( 'active' );
+ jQuery( this ).addClass( 'active' );
+
+ var element = jQuery( this );
+ var riskID = element.data( 'id' );
+ var seuil = element.data( 'seuil' );
+ var variableID = element.data( 'variable-id' );
+ var evaluationID = element.data( 'evaluation-id' );
+
+ window.eoxiaJS.digirisk.evaluationMethod.updateInputVariables( riskID, evaluationID, variableID, seuil, jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' textarea' ) );
+
+ var data = {
+ action: 'get_scale',
+ method_evaluation_id: evaluationID,
+ variables: jQuery( '.wpeo-modal.modal-risk-' + riskID + ' textarea' ).val()
+ };
+
+ var currentVal = JSON.parse(jQuery( '.wpeo-modal.modal-risk-' + riskID + ' textarea' ).val());
+ var canGetDetails = true;
+ for (var key in currentVal) {
+ if (currentVal[key] == '') {
+ canGetDetails = false;
+ }
+ }
+
+ if ( jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .table-cell.active' ).length == 5 ) {
+ if ( jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .button-main' ).length ) {
+ window.eoxiaJS.loader.display( jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .button-main' ) );
+ jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .button-main' ).addClass( 'disabled' );
+ }
+ jQuery.post( window.ajaxurl, data, function( response ) {
+ if ( response.data.details ) {
+ if ( jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .button-main' ).length ) {
+ window.eoxiaJS.loader.remove( jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .button-main' ) );
+ jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .button-main' ).removeClass( 'disabled' );
+ }
+ jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .cotation' ).attr( 'data-scale', response.data.details.scale );
+ jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .cotation span' ).text( response.data.details.equivalence );
+ jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .wpeo-button.button-disable' ).removeClass( 'button-disable' ).addClass( 'button-main' );
+ }
+ } );
}
};
+
+
+window.eoxiaJS.digirisk.evaluationMethodEvarisk.save = function( event ) {
+ var riskID = jQuery( this ).data( 'id' );
+ var evaluationID = jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' .digi-method-evaluation-id' ).val();
+ var value = jQuery( '.wpeo-modal.modal-active.modal-risk-' + riskID + ' textarea' ).val();
+
+ jQuery( '.risk-row.edit[data-id="' + riskID + '"] textarea[name="evaluation_variables"]' ).val( value );
+ jQuery( '.risk-row.edit[data-id="' + riskID + '"] input[name="evaluation_method_id"]' ).val( evaluationID );
+
+ // On met à jour l'affichage de la cotation.
+ jQuery( '.risk-row.edit[data-id="' + riskID + '"] .cotation:first' ).attr( 'data-scale', jQuery( '.wpeo-modal.modal-risk-' + riskID + ' .cotation' ).attr( 'data-scale' ) );
+ jQuery( '.risk-row.edit[data-id="' + riskID + '"] .cotation:first span' ).text( jQuery( '.wpeo-modal.modal-risk-' + riskID + ' .cotation span' ).text() );
+
+ window.eoxiaJS.digirisk.evaluationMethodEvarisk.close_modal( undefined, riskID );
+};
+
+window.eoxiaJS.digirisk.evaluationMethodEvarisk.close_modal = function( event, riskID ) {
+ if ( ! riskID ) {
+ riskID = jQuery( this ).data( 'id' );
+ }
+ jQuery( '.wpeo-modal.modal-active .modal-close' ).click();
+};
+
+window.eoxiaJS.digirisk.evaluationMethodEvarisk.fillVariables = function( element ) {
+ element.attr( 'data-variables', element.closest( 'td' ).find( 'textarea[name="evaluation_variables"]' ).val() );
+}
+
/**
- * Vérifie que le nom de la société ne soit pas vide.
+ * Initialise l'objet "evaluator" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
*
* @since 6.0.0
- *
- * @param {HTMLDivElement} element Le bouton déclenchant la création de la société
+ * @version 6.3.1
*/
-window.eoxiaJS.digirisk.installer.beforeCreateSociety = function( element ) {
- if ( '' === element.closest( 'form' ).find( 'input[name="title"]' ).val() ) {
- element.closest( 'form' ).find( 'span.tooltip' ).addClass( 'active' );
- return false;
- }
- element.closest( 'form' ).find( 'span.tooltip.active' ).removeClass( 'active' );
+window.eoxiaJS.digirisk.evaluator = {};
- return true;
+window.eoxiaJS.digirisk.evaluator.init = function() {
+ window.eoxiaJS.digirisk.evaluator.event();
+};
+
+window.eoxiaJS.digirisk.evaluator.event = function() {
};
/**
- * Le callback en cas de réussite à la requête Ajax "save_society".
- * Ferme la div "society". Changes l'étape de "Votre société" en "Composants".
- * Ouvre la div "wpdigi-components".
- * Appel la méthode "requestInstallComponent".
+* Après le changement d'onglet
+*
+* @since 6.3.1
+* @version 6.3.1
+*/
+window.eoxiaJS.digirisk.evaluator.tabChanged = function() {
+ // window.eoxiaJS.digirisk.search.renderChanged();
+};
+
+/**
+ * Le callback en cas de réussite à la requête Ajax "edit_evaluator_assign".
+ * Remplaces le contenu du tableau "affected-evaluator" par le template renvoyé par la requête Ajax.
*
* @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
* @param {Object} response Les données renvoyées par la requête Ajax.
* @return {void}
*
* @since 6.0.0
+ * @version 6.4.0
*/
-window.eoxiaJS.digirisk.installer.savedSociety = function( element, response ) {
- jQuery( '.wpdigi-installer .bloc-create-society' ).hide();
- jQuery( '.wpdigi-installer .wpdigi-components' ).show();
- jQuery( '.wpdigi-installer .start-install' ).hide();
- jQuery( '.wpdigi-installer .end-install' ).removeClass( 'wpeo-util-hidden' );
- jQuery( '.wpdigi-installer .bar .loader' ).css( 'width', '30%' );
- jQuery( '.wpdigi-installer .bar .loader' ).attr( 'data-width', 25 );
- jQuery( '.wpdigi-installer .step-list .step[data-width="' + 25 + '"]' ).addClass( 'active' );
-
- window.eoxiaJS.loader.display( jQuery( '.wpdigi-installer a.end-install' ) );
-
- window.eoxiaJS.digirisk.installer.requestInstallComponent();
+window.eoxiaJS.digirisk.evaluator.callback_edit_evaluator_assign_success = function( triggeredElement, response ) {
+ triggeredElement.closest( '.table-row.evaluator-row.edit' ).before( response.data.view );
+ triggeredElement.closest( '.table-row.evaluator-row.edit' ).find('.autocomplete-icon-after').click();
};
/**
- * Envoie une requête pour installer les composants nécessaires à l'utilisation de DigiRisk.
+ * Gestion de la suppression des évaluateurs.
+ *
+ * @param {ClickEvent} event [description]
+ * @return {void}
*
* @since 6.0.0
+ * @version 6.2.5
*/
-window.eoxiaJS.digirisk.installer.requestInstallComponent = function() {
- var _wpnonce = jQuery( '.wpdigi-installer .wpdigi-components .nonce-installer-components' ).val();
- window.eoxiaJS.request.get( undefined, ajaxurl + '?action=installer_components&_wpnonce=' + _wpnonce );
+window.eoxiaJS.digirisk.evaluator.callback_detach_evaluator_success = function( element, response ) {
+ element.closest( '.table-row' ).fadeOut();
};
+
+
+
/**
- * Le callback en cas de réussite à la requête Ajax "installer_components".
- * Met le li active en statut "finit" et passes au suivant, tout en relancant la requête pour installer le composant suivant.
- * Si tous les li sont en statut "finit" passes à l'étape suivante qui est "Création des utilisateurs"
+ * Gères l'export en CSV
*
- * @since 6.0.0
+ * @author Jimmy Latour
*
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @since 6.2.6.0
+ * @version 6.2.6.0
+ *
+ * @memberof export
*/
-window.eoxiaJS.digirisk.installer.installedComponentSuccess = function( triggeredElement, response ) {
-
- // Si l'installation n'est pas terminée, on relance une requête avec les prochains composants à installer.
- if ( ! response.data.core_option.installed ) {
- if ( ! response.data.core_option.recommendation_installed && response.data.core_option.danger_installed ) {
- window.eoxiaJS.digirisk.installer.progressBar( 55 );
- } else if ( response.data.core_option.recommendation_installed ) {
- window.eoxiaJS.digirisk.installer.progressBar( 80 );
- }
- window.eoxiaJS.digirisk.installer.requestInstallComponent();
- } else {
- window.eoxiaJS.digirisk.installer.progressBar( 100 );
-
- jQuery( '.wpdigi-installer .wpdigi-components .next' ).removeClass( 'button-disable' );
- if ( 0 < jQuery( '#toplevel_page_digi-setup a' ).length ) {
- jQuery( '#toplevel_page_digi-setup a' ).attr( 'href', jQuery( '#toplevel_page_digi-setup a' ).attr( 'href' ).replace( 'digi-setup', 'digirisk-du' ) );
- }
- window.eoxiaJS.loader.remove( jQuery( '.wpdigi-installer a' ) );
- }
-};
+/**
+ * Initialise l'objet exportCSV dans l'objet digirisk
+ * @memberof export
+ * @type {Object}
+ */
+window.eoxiaJS.digirisk.exportCSV = {};
/**
- * Met à jour la barre de progression.
+ * La méthode init est appelé automatiquement
*
- * @since 6.0.0
+ * @since 6.1.5.5
+ * @version 6.2.1.2
*
- * @param {integer} pourcent Le pourcentage courant.
+ * @memberof exportCSV
+ *
+ * @return {void}
*/
-window.eoxiaJS.digirisk.installer.progressBar = function( pourcent ) {
- clearInterval( window.eoxiaJS.digirisk.installer.progressInterval );
- window.eoxiaJS.digirisk.installer.progressInterval = undefined;
-
- window.eoxiaJS.digirisk.installer.progressInterval = setInterval( function() {
- var currentWidth = jQuery( '.wpdigi-installer .bar .loader' ).attr( 'data-width' );
- currentWidth++;
-
- jQuery( '.wpdigi-installer .bar .loader' ).css( 'width', currentWidth + '%' );
- jQuery( '.wpdigi-installer .bar .loader' ).attr( 'data-width', currentWidth );
+window.eoxiaJS.digirisk.exportCSV.init = function() {
+ window.eoxiaJS.digirisk.exportCSV.event();
+};
- jQuery( '.wpdigi-installer .step-list .step[data-width="' + currentWidth + '"]' ).addClass( 'active' );
+/**
+ * Initialies les évènements submit et change
+ *
+ * @since 6.2.6.0
+ * @version 6.2.6.0
+ *
+ * @memberof exportCSV
+ *
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.exportCSV.event = function() {
+ jQuery( document ).on( 'click', '#digi-export-csv-form button.blue', window.eoxiaJS.digirisk.exportCSV.makeExport );
+};
- if ( jQuery( '.wpdigi-installer .bar .loader' ).attr( 'data-width' ) >= pourcent ) {
- clearInterval( window.eoxiaJS.digirisk.installer.progressInterval );
- window.eoxiaJS.digirisk.installer.progressInterval = undefined;
+/**
+ * Utilises ajaxSubmit pour envoyer le formulaire en AJAX.
+ *
+ * @param {ClickEvent} event L'évènement du clic.
+ * @return {void}
+ *
+ * @since 6.2.6.0
+ * @version 6.2.6.0
+ */
+window.eoxiaJS.digirisk.exportCSV.makeExport = function( event ) {
+ var button = jQuery( this );
+ event.preventDefault();
+ jQuery( this ).closest( 'form' ).ajaxSubmit( {
+ 'beforeSubmit': function() {
+ window.eoxiaJS.loader.display( button );
+ },
+ success: function( response ) {
+ if ( response.data.end ) {
+ button.closest( 'form' ).find( 'progress' ).attr( 'max', 100 );
+ button.closest( 'form' ).find( 'progress' ).val( 100 );
+ window.eoxiaJS.loader.remove( button );
+ window.eoxiaJS.global.downloadFile( response.data.url_to_file, response.data.filename );
+ jQuery( '#digi-export-csv-form input[name="offset"]' ).val( 0 );
+ jQuery( '#digi-export-csv-form input[name="filepath"]' ).val( '' );
+ jQuery( '#digi-export-csv-form input[name="filename"]' ).val( '' );
+ jQuery( '#digi-export-csv-form input[name="number_risks"]' ).val( 0 );
+ jQuery( '#digi-export-csv-form input[name="url_to_file"]' ).val( '' );
+ } else {
+ button.closest( 'form' ).find( 'progress' ).attr( 'max', response.data.number_risks );
+ button.closest( 'form' ).find( 'progress' ).val( ( response.data.offset / response.data.number_risks ) * response.data.number_risks );
+ jQuery( '#digi-export-csv-form input[name="offset"]' ).val( response.data.offset );
+ jQuery( '#digi-export-csv-form input[name="filepath"]' ).val( response.data.filepath );
+ jQuery( '#digi-export-csv-form input[name="filename"]' ).val( response.data.filename );
+ jQuery( '#digi-export-csv-form input[name="number_risks"]' ).val( response.data.number_risks );
+ jQuery( '#digi-export-csv-form input[name="url_to_file"]' ).val( response.data.url_to_file );
- if ( pourcent === 100 ) {
- jQuery( '.wpdigi-installer .end-install.button-disable' ).removeClass( 'button-disable' );
+ jQuery( '#digi-export-csv-form button.blue' ).click();
}
}
- }, 100 );
+ } );
};
+/**
+ * Gères l'export et l'import des modèles de donnée de DigiRisk
+ *
+ * @author Evarisk
+ *
+ * @since 6.1.5.5
+ *
+ * @memberof export
+ */
+
+/**
+ * Initialise l'objet export dans l'objet digirisk
+ * @memberof export
+ * @type {Object}
+ */
+window.eoxiaJS.digirisk.export = {};
+
+/**
+ * La méthode init est appelé automatiquement
+ *
+ * @since 6.1.5.5
+ *
+ * @memberof export
+ *
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.export.init = function() {
+ window.eoxiaJS.digirisk.export.event();
+};
+
+/**
+ * Initialies les évènements submit et change
+ *
+ * @since 6.1.5.5
+ *
+ * @memberof export
+ *
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.export.event = function() {
+ jQuery( document ).on( 'submit', '#digi-data-export #digi-export-form, #digi-data-export #digi-export-tree, #digi-data-export #digi-export-risks, #digi-data-export #digi-export-risksigns, #digi-data-export #digi-export-global', window.eoxiaJS.digirisk.export.create_export );
+ jQuery( document ).on( 'change', '#digi-data-export #digi-import-form input[type="file"]', window.eoxiaJS.digirisk.export.make_import );
+};
+
+/**
+ * Lances la requête XHR pour créer le fichier .zip de l'export du modèle de donnée.
+ *
+ * @since 6.1.5.5
+ *
+ * @param {Object} event [description]
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.export.create_export = function( event ) {
+ var form = jQuery( this );
+ event.preventDefault();
+ jQuery( this ).closest( 'form' ).ajaxSubmit( {
+ 'beforeSubmit': function() {
+ window.eoxiaJS.loader.display( form.find( 'button' ) );
+ },
+ success: function( response ) {
+ window.eoxiaJS.loader.remove( form.find( 'button' ) );
+ window.eoxiaJS.global.downloadFile( response.data.url_to_file, response.data.filename );
+ }
+ } );
+},
+
+/**
+ * Prépare la première requête pour importer un modèle de donnée.
+ *
+ * @since 6.1.5.5
+ *
+ * @param {[type]} event [description]
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.export.make_import = function( event ) {
+ var data = new FormData();
+
+ event.preventDefault();
+
+ data.append( 'file', jQuery( this )[0].files[0] );
+ data.append( 'action', 'digi_import_data' );
+ data.append( '_wpnonce', jQuery( this ).closest( 'form' ).find( 'input[name="_wpnonce"]' ).val() );
+ data.append( 'index_element', 0 );
+
+ window.eoxiaJS.digirisk.export.request_import( data );
+},
+
+/**
+ * Lances la requête pour importer un modèle de donnée.
+ * Modifie la barre de progression.
+ *
+ * @since 6.1.5.5
+ *
+ * @param {object} data Les données pour la requête
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.export.request_import = function( data ) {
+ jQuery.ajax( {
+ url: ajaxurl,
+ data: data,
+ processData: false,
+ contentType: false,
+ type: 'POST',
+ beforeSend: function() {
+ window.eoxiaJS.loader.display( jQuery( '#digi-import-form .button.blue' ) );
+ jQuery( '.digi-import-detail' ).html( window.digi_tools_in_progress );
+ },
+ success: function( response ) {
+ var data = new FormData();
+
+ if ( response.success ) {
+ jQuery( '#digi-import-form progress' ).attr( 'max', response.data.count_element );
+ jQuery( '#digi-import-form progress' ).val( ( response.data.index_element / response.data.count_element ) * response.data.count_element );
+
+ if ( ! response.data.end ) {
+ data.append( 'action', 'digi_import_data' );
+ data.append( '_wpnonce', jQuery( '#digi-import-form' ).find( 'input[name="_wpnonce"]' ).val() );
+ data.append( 'path_to_json', response.data.path_to_json );
+ data.append( 'index_element', response.data.index_element );
+ jQuery( '.digi-import-detail' ).html( window.digi_tools_in_progress );
+ window.eoxiaJS.digirisk.export.request_import( data );
+ } else {
+ jQuery( '.digi-import-detail' ).html( window.digi_tools_done );
+ if ( jQuery( '#toplevel_page_digi-setup a' ).attr( 'href' ) ) {
+ jQuery( '#toplevel_page_digi-setup a' ).attr( 'href', jQuery( '#toplevel_page_digi-setup a' ).attr( 'href' ).replace( 'digi-setup', 'digirisk' ) );
+ }
+
+ jQuery( '#digi-import-form progress' ).attr( 'max', 100 );
+ jQuery( '#digi-import-form progress' ).val( 100 );
+
+ window.eoxiaJS.loader.remove( jQuery( '#digi-import-form .button.blue' ) );
+ }
+ } else {
+ alert( 'Problème lors de l\'importation du modèle' );
+ }
+ }
+ } );
+};
+
/**
- * Initialise l'objet "legalDisplay" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ * Initialise l'objet "group" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
*
- * @since 6.0.0
- * @version 6.4.4
+ * @since 1.0
+ * @version 6.2.4.0
*/
-window.eoxiaJS.digirisk.legalDisplay = {};
+window.eoxiaJS.digirisk.group = {};
-window.eoxiaJS.digirisk.legalDisplay.init = function() {};
+/**
+ * La méthode appelée automatiquement par la bibliothèque EoxiaJS.
+ *
+ * @return {void}
+ *
+ * @since 1.0
+ * @version 6.2.4.0
+ */
+window.eoxiaJS.digirisk.group.init = function() {};
/**
- * Le callback en cas de réussite à la requête Ajax "save_legal_display".
- * Actualises la vue en cliquant sur l'onglet "Affichage légal".
+ * Le callback en cas de réussite à la requête Ajax "create_group".
+ * Remplaces le contenu de toute l'application par la vue renvoyé par la requête Ajax.
+ * Clic ensuite sur le nouveau groupement pour lancer la requête "load_society".
*
* @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
* @param {Object} response Les données renvoyées par la requête Ajax.
* @return {void}
*
- * @since 6.0.0
+ * @since 1.0
+ * @version 6.2.4.0
*/
-window.eoxiaJS.digirisk.legalDisplay.generatedSuccess = function( triggeredElement, response ) {
- jQuery( '.wpeo-table.table-documents' ).replaceWith( response.data.view );
- window.scrollTo( 0, 0 );
+window.eoxiaJS.digirisk.group.createdGroupSuccess = function( element, response ) {
+ jQuery( '.digirisk-wrap' ).replaceWith( response.data.template );
+ jQuery( '.workunit-navigation span.action-attribute[data-groupment-id="' + response.data.groupment_id + '"]' ).click();
};
+
+/**
+ * Initialise l'objet "historic" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ *
+ * @since 6.3.0
+ * @version 6.4.0
+ */
+window.eoxiaJS.digirisk.historic = {};
-window.eoxiaJS.digirisk.legalDisplay.generateSocietyIndicator = function( focus ) {
- jQuery( '.main-information-society .bloc-information-society' ).each( function( index ){
- if( jQuery( this ).find( 'input[name="indicator-id"]' ).length == 0 || jQuery( this ).find( 'input[name="indicator-id"]' ).val() == "" ){
- return;
- }else{
- var id_indicator = jQuery( this ).find( 'input[name="indicator-id"]' ).val();
- }
-
- var nbr_total = 1;
- if( jQuery( this ).find( 'input[name="indicator-nbr-total"]' ).length > 0 ){
- nbr_total = jQuery( this ).find( 'input[name="indicator-nbr-total"]' ).val();
- }
-
- var nbr_valid = 0;
- if( jQuery( this ).find( 'input[name="indicator-nbr-valid"]' ).length > 0 ){
- nbr_valid = jQuery( this ).find( 'input[name="indicator-nbr-valid"]' ).val();
- }
- var nbr_unvalid = nbr_total - nbr_valid;
-
- var percent = 0;
- if( jQuery( this ).find( '.bloc-indicator' ).length > 0 ){
- percent = jQuery( this ).find( '.bloc-indicator' ).attr( 'data-percent' );
- }
-
- // RED, ORANGE, YELLOW, GREEN
- var color = window.eoxiaJS.digirisk.legalDisplay.getColorFromPercent( percent );
-
- var canvasDonut = document.getElementById( id_indicator ).getContext('2d');
- var data_canvas_donut = {
- labels : [ 'Completed', 'Uncompleted' ],
- datasets: [
- {
- backgroundColor: [ color, "rgb(230,230,230)" ],
- data: [ nbr_valid, nbr_unvalid ],
- }
- ],
- };
-
- if ( 0 == percent ) {
- data_canvas_donut.datasets[0].backgroundColor = [ color, 'red' ];
- }
-
-
- var option = {
- title: {},
- tooltips: {
- custom: function(tooltip) {
- }
- },
- legend: {
- display: false
- },
- elements: {
- center: {
- text: percent + '%',
- }
- },
- animation:{
-
- }
- };
- if( focus != "" ){
- option.animation.duration = 0;
- }
-
- canvasDonut.canvas.width = 80;
- canvasDonut.canvas.height = 80;
-
- new Chart( canvasDonut, {
- type: 'doughnut',
- data: data_canvas_donut,
- options: option
- });
-
- Chart.pluginService.register({ // ------------
-
- beforeDraw: function(chart) {
- var width = chart.chart.width,
- height = chart.chart.height,
- ctx = chart.chart.ctx;
-
- ctx.restore();
- // var fontSize = (height / 114).toFixed(2);
- ctx.font = 'italic 20px -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif';
- ctx.textBaseline = "middle";
-
- var centerConfig = chart.config.options.elements.center;
- var text = centerConfig.text,
- textX = Math.round((width - ctx.measureText(text).width) / 2),
- textY = height / 2;
-
- ctx.fillText(text, textX, textY);
- ctx.save();
- }
- }); // ------------
- } );
+window.eoxiaJS.digirisk.historic.init = function() {
+ window.eoxiaJS.digirisk.historic.event();
};
-window.eoxiaJS.digirisk.legalDisplay.getColorFromPercent = function ( percent ){
- var color = [ 'rgb(255,1,1)', 'rgb(255,153,0)', 'rgb(255,213,0)', 'rgb(71,229,142)' ];
+window.eoxiaJS.digirisk.historic.event = function() {};
- if( percent > 75 ){
- return color[3];
- }else if( percent > 50 ){
- return color[2];
- }else if( percent > 25 ){
- return color[1];
- }else{
- return color[1];
- }
-}
+/**
+ * Le callback en cas de réussite à la requête Ajax "historic_risk".
+ * Remplaces le contenu de la popup "corrective-task" par la vue renvoyée par la réponse Ajax.
+ *
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
+ *
+ * @since 6.3.0
+ * @version 6.4.0
+ */
+window.eoxiaJS.digirisk.historic.openedHistoricRiskPopup = function( triggeredElement, response ) {
+ jQuery( '.popup.historic-risk .content' ).html( response.data.view );
+ jQuery( '.popup.historic-risk .container.loading' ).removeClass( 'loading' );
+};
/**
- * Initialise l'objet "listingRisk" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ * Initialise l'objet "handleModel" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
*
- * @since 6.5.0
+ * @since 6.0.0
+ * @version 6.3.0
*/
-window.eoxiaJS.digirisk.listingRisk = {};
+window.eoxiaJS.digirisk.handleModel = {};
/**
- * Méthode obligatoire pour initialiser l'objet listingRisk avec EO-Framework.
+ * Keep the button in memory.
*
- * @since 6.5.0
+ * @type {Object}
*/
-window.eoxiaJS.digirisk.listingRisk.init = function() {
- window.eoxiaJS.digirisk.listingRisk.event();
-};
+window.eoxiaJS.digirisk.handleModel.currentButton;
/**
- * Méthode pour initialiser tous les évènements.
- *
- * @since 6.5.0
+ * Keep the media frame in memory.
+ * @type {Object}
*/
-window.eoxiaJS.digirisk.listingRisk.event = function() {};
+window.eoxiaJS.digirisk.handleModel.mediaFrame;
/**
- * Le callback en cas de réussite à la requête Ajax "generate_listing_risk".
- * Cliques sur le bouton "Listing des risques" pour recharger la vue.
- *
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
- *
- * @since 6.5.0
+ * Keep the selected media in memory.
+ * @type {Object}
*/
-window.eoxiaJS.digirisk.listingRisk.generatedListingRiskSuccess = function( triggeredElement, response ) {
- if ( 'photos' === response.data.type ) {
- jQuery( '.tab-element[data-target="digi-listing-risk-photo"]' ).click();
- } else {
- jQuery( '.tab-element[data-target="digi-listing-risk-action-corrective"]' ).click();
- }
+window.eoxiaJS.digirisk.handleModel.selectedInfos = {
+ JSON: undefined,
+ fileID: undefined
};
-
-/**
- * Initialise l'objet "navigation" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
- *
- * @since 6.0.0
- * @version 7.0.0
- */
-window.eoxiaJS.digirisk.navigation = {};
+window.eoxiaJS.digirisk.handleModel.init = function() {
+ window.eoxiaJS.digirisk.handleModel.event();
+};
/**
- * La méthode appelée automatiquement par la bibliothèque EoxiaJS.
+ * Les évènements
*
* @return {void}
- *
- * @since 6.0.0
- * @version 6.2.4
*/
-window.eoxiaJS.digirisk.navigation.init = function() {
- window.eoxiaJS.digirisk.navigation.event();
+window.eoxiaJS.digirisk.handleModel.event = function() {
+ jQuery( document ).on( 'click', '.digi-tools-main-container .upload-model', window.eoxiaJS.digirisk.handleModel.openMediaFrame );
};
/**
- * La méthode contenant tous les évènements pour la navigation.
+ * Open the media frame from WordPress.
*
- * @since 6.0.0
- * @version 6.3.0
+ * @return void
*
- * @return {void}
+ * @since 6.3.0
+ * @version 6.3.0
*/
-window.eoxiaJS.digirisk.navigation.event = function() {
- jQuery( document ).on( 'click', '.digirisk-wrap .navigation-container .unit-container .toggle-unit', window.eoxiaJS.digirisk.navigation.switchToggle );
- jQuery( document ).on( 'click', '.digirisk-wrap .navigation-container .add-container .wpeo-button, .digirisk-wrap .navigation-container .mobile-add-container .dropdown-item', window.eoxiaJS.digirisk.navigation.displayAddField );
- jQuery( document ).on( 'click', '.digirisk-wrap .navigation-container .toolbar div', window.eoxiaJS.digirisk.navigation.toggleAll );
- jQuery( document ).on( 'click', '.digirisk-wrap .navigation-container .unit.new .placeholder-icon', window.eoxiaJS.digirisk.navigation.focusField );
- jQuery( document ).on( 'keyup', '.digirisk-wrap .navigation-container input[name="title"]', window.eoxiaJS.digirisk.navigation.triggerCreateSociety );
-
- jQuery( document ).on( 'click', '.digirisk-wrap .mobile-navigation', window.eoxiaJS.digirisk.navigation.openNavigationContainer );
- jQuery( document ).on( 'click', '.digirisk-wrap .navigation-container.active .close-popup', window.eoxiaJS.digirisk.navigation.closeNavigationContainer );
+window.eoxiaJS.digirisk.handleModel.openMediaFrame = function() {
+ window.eoxiaJS.digirisk.handleModel.currentButton = jQuery( this );
+ window.eoxiaJS.digirisk.handleModel.mediaFrame = new window.wp.media.view.MediaFrame.Post({
+ library: {
+ type: 'application/vnd.oasis.opendocument.text'
+ }
+ }).open();
+ window.eoxiaJS.digirisk.handleModel.mediaFrame.on( 'insert', function() { window.eoxiaJS.digirisk.handleModel.selectedFile(); } );
};
/**
- * Gestion du toggle dans la navigation.
+ * Get the media selected and call associateFile.
+ *
+ * @return void
*
* @since 6.3.0
* @version 6.3.0
- *
- * @param {MouseEvent} event Les attributs lors du clic.
- * @return {void}
*/
-window.eoxiaJS.digirisk.navigation.switchToggle = function( event ) {
- event.preventDefault();
-
- if ( jQuery( this ).find( '.toggle-icon' ).hasClass( 'fa-chevron-down' ) ) {
- jQuery(this).find( '.toggle-icon' ).removeClass('fa-chevron-down').addClass('fa-chevron-right');
- jQuery(this).closest('.unit').removeClass('toggled');
- } else {
- jQuery(this).find( '.toggle-icon' ).removeClass('fa-chevron-right').addClass('fa-chevron-down');
- jQuery(this).closest('.unit').addClass('toggled');
- }
+window.eoxiaJS.digirisk.handleModel.selectedFile = function() {
+ window.eoxiaJS.digirisk.handleModel.mediaFrame.state().get( 'selection' ).map( function( attachment ) {
+ window.eoxiaJS.digirisk.handleModel.selectedInfos.JSON = attachment.toJSON();
+ window.eoxiaJS.digirisk.handleModel.selectedInfos.id = attachment.id;
+ } );
+ window.eoxiaJS.digirisk.handleModel.associateFile();
};
/**
- * Affiches le champ pour créer un établissement.
+ * Make request for associate file
+ *
+ * @return void
*
* @since 6.3.0
* @version 6.3.0
- *
- * @param {MouseEvent} event Les attributs lors du clic.
- * @return {void}
*/
-window.eoxiaJS.digirisk.navigation.displayAddField = function( event ) {
- var closest = jQuery( this ).closest( '.society-header' ).length ? jQuery( this ).closest( '.navigation-container' ) : jQuery( this ).closest( '.unit' );
- event.preventDefault();
- event.stopPropagation();
-
- // Mobile.
- jQuery( '.mobile-add-container .content.active' ).removeClass( 'active' );
+window.eoxiaJS.digirisk.handleModel.associateFile = function() {
+ var data = {
+ action: 'set_model',
+ type: window.eoxiaJS.digirisk.handleModel.currentButton.data( 'type' ),
+ file_id: window.eoxiaJS.digirisk.handleModel.selectedInfos.id,
+ dashboard: window.eoxiaJS.digirisk.handleModel.currentButton.data( 'dashboard' )
+ };
- closest.addClass( 'toggled' );
+ window.eoxiaJS.loader.display( window.eoxiaJS.digirisk.handleModel.currentButton );
- if ( 'Group_Class' === jQuery( this ).data( 'type' ) ) {
- closest.find( '.unit.new:first .placeholder-icon' ).removeClass( 'dashicons-admin-home' );
- closest.find( '.unit.new:first .placeholder-icon' ).addClass( 'dashicons-admin-multisite' );
- } else {
- closest.find( '.unit.new:first .placeholder-icon' ).removeClass( 'dashicons-admin-multisite' );
- closest.find( '.unit.new:first .placeholder-icon' ).addClass( 'dashicons-admin-home' );
- }
-
- if ( closest.find( '.unit.new:first' ).hasClass( 'active' ) && closest.find( '.unit.new:first input[name="class"]' ).val() != jQuery( this ).data( 'type' ) ) {
- } else {
- closest.find( '.unit.new:first' ).toggleClass( 'active' );
- }
+ jQuery.post( window.ajaxurl, data, function( response ) {
+ if ( response.data.dashboard ) {
+ jQuery( '.model-items' ).replaceWith( response.data.view );
+ } else {
+ jQuery('#digi-handle-model').html(response.data.view);
+ }
+ } );
+};
- if ( closest.find( '.unit.new:first' ).hasClass( 'active' ) ) {
- closest.find( '.unit.new:first.active input[type="text"]' ).focus();
- }
+/**
+ * Après la requête AJAX qui ouvre la popup "Historique des modèles"
+ *
+ * @param {HTMLAnchorElement} element Le lien qui permet d'ouvrir la popup
+ * @param {Object} response Les données de la réponse de la requête XHR
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.handleModel.loadedPopupHistoric = function( element, response ) {
+ element.closest( '.block' ).find( '.popup .title' ).text( response.data.title );
+ element.closest( '.block' ).find( '.popup .content' ).html( response.data.view );
+ jQuery( '.container.loading' ).removeClass( 'loading' );
+};
- closest.find( '.unit.new:first input[name="class"]' ).val( jQuery( this ).data( 'type' ) );
+/**
+ * Met à jour le bouton "Télécharger le modèle courant" de response.data.type
+ * @param {HTMLAnchorElement} element Le lien "Télécharger le modèle courant"
+ * @param {void}
+ */
+window.eoxiaJS.digirisk.handleModel.reset_default_model_success = function( element, response ) {
+ element.closest( '.block' ).find( 'li:first a' ).attr( 'href', response.data.url );
};
+
+/**
+ * Initialise l'objet "installer" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ *
+ * @since 6.0.0
+ */
+
+window.eoxiaJS.digirisk.installer = {};
+window.eoxiaJS.digirisk.installer.progressInterval = undefined;
/**
- * Focus le champ 'title' pour créer un établissement
+ * Méthodes obligatoire pour utiliser EO-JS.
*
- * @since 6.3.0
- * @version 6.3.0
+ * @since 6.0.0
+ */
+window.eoxiaJS.digirisk.installer.init = function() {
+ window.eoxiaJS.digirisk.installer.event();
+ window.eoxiaJS.digirisk.initOwlCarousel();
+};
+
+/**
+ * Initialise tous les évènements pour la page "digi-setup".
*
- * @param {MouseEvent} event Les attributs lors du clic.
- * @return {void}
+ * @since 6.0.0
*/
-window.eoxiaJS.digirisk.navigation.focusField = function( event ) {
- event.preventDefault();
+window.eoxiaJS.digirisk.installer.event = function() {
+ jQuery( document ).on( 'keyup', '.wpdigi-installer input[name="title"]', window.eoxiaJS.digirisk.installer.keyUpGroupmentTitle );
+ jQuery( document ).on( 'click', '.wpdigi-installer input[type="checkbox"]', window.eoxiaJS.digirisk.installer.toggleDefaultInstall );
- jQuery( this ).closest( '.unit.new' ).find( 'input[type="text"]' ).focus();
+ jQuery( document ).on( 'click', '.wpdigi-installer input[name="title"]', window.eoxiaJS.digirisk.installer.emptyPlaceHolder );
+ jQuery( document ).on( 'blur', '.wpdigi-installer input[name="title"]', window.eoxiaJS.digirisk.installer.fillProgressBar );
};
/**
- * Déplies ou replies tous les éléments enfants
- *
- * @since 6.3.0
- * @version 6.3.0
+ * Initialise le "owlCarousel" sur l'élement "owl-carousel".
*
- * @param {MouseEvent} event Les attributs lors du clic
- * @return {void}
+ * @since 6.0.0
*/
-window.eoxiaJS.digirisk.navigation.toggleAll = function( event ) {
- event.preventDefault();
+window.eoxiaJS.digirisk.initOwlCarousel = function() {
+ jQuery( '.owl-carousel' ).owlCarousel( {
+ 'items': 1,
+ 'nav': true,
+ 'navText': [],
+ 'pagination': true,
+ 'autoHeight': true,
+ 'autoplay': true,
+ 'autoplayTimeout': 25000
+ } );
+}
- if ( jQuery( this ).hasClass( 'toggle-plus' ) ) {
- jQuery( '.digirisk-wrap .navigation-container .workunit-list .unit .toggle-icon').removeClass( 'fa-chevron-right').addClass( 'fa-chevron-down' );
- jQuery( '.digirisk-wrap .navigation-container .workunit-list .unit' ).addClass( 'toggled' );
+/**
+ * Évènement lors du "keyup" sur le champ "Nom de ma société".
+ *
+ * @since 6.0.0
+ *
+ * @param {KeyEvent} event L'état du clavier.
+ */
+window.eoxiaJS.digirisk.installer.keyUpGroupmentTitle = function( event ) {
+ if ( 13 === event.keyCode ) {
+ jQuery( '.main-content .action-input:first' ).click();
}
- if ( jQuery( this ).hasClass( 'toggle-minus' ) ) {
- jQuery( '.digirisk-wrap .navigation-container .workunit-list .unit.toggled' ).removeClass( 'toggled' );
- jQuery( '.digirisk-wrap .navigation-container .workunit-list .unit .toggle-icon').addClass( 'fa-chevron-right').removeClass( 'fa-chevron-down' );
+ if ( jQuery( this ).val() != '' ) {
+ jQuery( '.wpdigi-installer .bar .loader' ).css( 'width', '12%' );
+ jQuery( '.wpdigi-installer .bar .loader' ).attr( 'data-width', 12 );
+ } else {
+ jQuery( '.wpdigi-installer .bar .loader' ).css( 'width', '0%' );
+ jQuery( '.wpdigi-installer .bar .loader' ).attr( 'data-width', 0 );
}
};
/**
- * Ajout la classe 'active' à l'élément.
+ * Ouvre les détails des données par défaut lorsqu'on "check" la case à coché.
*
- * @since 6.3.0
- * @version 6.3.0
+ * @since 7.0.0
*
- * @param {HTMLDivElement} element L'attribut de l'élement.
- * @return {boolean}
+ * @param {MouseEvent} event L'état de la souri lors du clic.
*/
-window.eoxiaJS.digirisk.navigation.setUnitActive = function( element ) {
- jQuery( '.digirisk-wrap .navigation-container .unit.active' ).removeClass( 'active' );
- jQuery( element ).closest( '.unit' ).addClass( 'active' );
- return true;
+window.eoxiaJS.digirisk.installer.toggleDefaultInstall = function( event ) {
+ jQuery( '.wpdigi-installer .bloc-create-society .default-data-details' ).toggleClass( 'hidden' );
};
/**
- * Clic automatiquement sur le 'action-input'.
+ * Enlèves le placeholder lors du "clic" sur le champ "Nom de ma société".
*
- * @since 6.3.0
- * @version 6.3.0
+ * @since 6.0.0
*
- * @param {KeyboardEvent} event Les attributs du clavier.
- * @return {void}
+ * @param {ClickEvent} event L'état du clique.
*/
-window.eoxiaJS.digirisk.navigation.triggerCreateSociety = function( event ) {
- if ( event.ctrlKey && 13 === event.keyCode ) {
- jQuery( this ).closest( '.unit.new' ).find( '.action-input' ).click();
+window.eoxiaJS.digirisk.installer.emptyPlaceHolder = function( event ) {
+ if ( '' === jQuery( this ).val() ) {
+ jQuery( this ).closest( '.society-form' ).find( 'label' ).hide();
}
};
/**
- * Ajout de la classe 'active' au bloc 'navigation-container'.
+ * Remplie la barre de progression.
*
- * @since 6.3.0
- * @version 6.3.0
+ * @since 6.0.0
*
- * @param {TouchEvent} event [description]
- * @return {void}
+ * @param {FocusEvent} event L'état du focus.
*/
-window.eoxiaJS.digirisk.navigation.openNavigationContainer = function( event ) {
- jQuery( '.digirisk-wrap .navigation-container' ).addClass( 'active' );
+window.eoxiaJS.digirisk.installer.fillProgressBar = function( event ) {
+ if ( '' === jQuery( this ).val() ) {
+ jQuery( this ).closest( '.society-form' ).find( 'label' ).show();
+ jQuery( '.wpdigi-installer .bar .loader' ).css( 'width', '0%' );
+ jQuery( '.wpdigi-installer .bar .loader' ).attr( 'data-width', 0 );
+ }
};
/**
- * Enlève la classe 'active' au bloc 'navigation-container'.
+ * Vérifie que le nom de la société ne soit pas vide.
*
- * @since 6.3.0
- * @version 6.3.0
+ * @since 6.0.0
*
- * @param {TouchEvent} event [description]
- * @return {void}
+ * @param {HTMLDivElement} element Le bouton déclenchant la création de la société
*/
-window.eoxiaJS.digirisk.navigation.closeNavigationContainer = function( event ) {
- event.stopPropagation();
+window.eoxiaJS.digirisk.installer.beforeCreateSociety = function( element ) {
+ if ( '' === element.closest( 'form' ).find( 'input[name="title"]' ).val() ) {
+ element.closest( 'form' ).find( 'span.tooltip' ).addClass( 'active' );
+ return false;
+ }
- jQuery( '.digirisk-wrap .navigation-container' ).removeClass( 'active' );
+ element.closest( 'form' ).find( 'span.tooltip.active' ).removeClass( 'active' );
+
+ return true;
};
/**
- * Callback en cas de réussite de la requête Ajax "create_society"
- *
- * @since 6.3.0
- * @version 6.3.0
+ * Le callback en cas de réussite à la requête Ajax "save_society".
+ * Ferme la div "society". Changes l'étape de "Votre société" en "Composants".
+ * Ouvre la div "wpdigi-components".
+ * Appel la méthode "requestInstallComponent".
*
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response {
- * Les données renvoyées par la requête Ajax.
- * @type {Object} data {
- * @type {string} navigation_view La vue de la navigation.
- * @type {string} content_view La vue du contenu principale.
- * }
- * }
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
* @return {void}
+ *
+ * @since 6.0.0
*/
-window.eoxiaJS.digirisk.navigation.createdSocietySuccess = function( triggeredElement, response ) {
- jQuery( '.workunit-list .unit.active' ).removeClass( 'active' );
-
- jQuery( triggeredElement ).closest( '.unit:not(.new)' ).find( '.spacer:first' ).removeClass( 'spacer' ).addClass( 'toggle-unit' ).append(' ');
+window.eoxiaJS.digirisk.installer.savedSociety = function( element, response ) {
+ jQuery( '.wpdigi-installer .bloc-create-society' ).hide();
+ jQuery( '.wpdigi-installer .wpdigi-components' ).show();
+ jQuery( '.wpdigi-installer .start-install' ).hide();
+ jQuery( '.wpdigi-installer .end-install' ).removeClass( 'wpeo-util-hidden' );
+ jQuery( '.wpdigi-installer .bar .loader' ).css( 'width', '30%' );
+ jQuery( '.wpdigi-installer .bar .loader' ).attr( 'data-width', 25 );
+ jQuery( '.wpdigi-installer .step-list .step[data-width="' + 25 + '"]' ).addClass( 'active' );
- if ( jQuery( triggeredElement ).closest( '.sub-list' ).length ) {
- jQuery( triggeredElement ).closest( '.sub-list' ).replaceWith( response.data.navigation_view );
- } else {
- jQuery( triggeredElement ).closest( '.workunit-list' ).replaceWith( response.data.navigation_view );
- }
+ window.eoxiaJS.loader.display( jQuery( '.wpdigi-installer a.end-install' ) );
- jQuery( '.digirisk-wrap .main-container' ).replaceWith( response.data.content_view );
- window.eoxiaJS.digirisk.risk.refresh();
+ window.eoxiaJS.digirisk.installer.requestInstallComponent();
};
/**
- * Callback en cas de réussite de la requête Ajax "load_society"
- * Remplaces le template principale de l'application avec le template reçu dans la réponse de la requête Ajax.
- *
- * @param {HTMLSpanElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
+ * Envoie une requête pour installer les composants nécessaires à l'utilisation de DigiRisk.
*
* @since 6.0.0
- * @version 7.0.0
*/
-window.eoxiaJS.digirisk.navigation.loadedSocietySuccess = function( element, response ) {
- jQuery( '.digirisk-wrap .main-container' ).replaceWith( response.data.view );
- jQuery( '.digirisk-wrap .navigation-container' ).removeClass( 'active' );
- window.eoxiaJS.digirisk.risk.refresh();
+window.eoxiaJS.digirisk.installer.requestInstallComponent = function() {
+ var _wpnonce = jQuery( '.wpdigi-installer .wpdigi-components .nonce-installer-components' ).val();
+ window.eoxiaJS.request.get( undefined, ajaxurl + '?action=installer_components&_wpnonce=' + _wpnonce );
};
-
+
/**
- * Initialise l'objet 'legalDisplay' ainsi que la méthode 'init' obligatoire pour la bibliothèque EoxiaJS.
+ * Le callback en cas de réussite à la requête Ajax "installer_components".
+ * Met le li active en statut "finit" et passes au suivant, tout en relancant la requête pour installer le composant suivant.
+ * Si tous les li sont en statut "finit" passes à l'étape suivante qui est "Création des utilisateurs"
*
- * @since 6.3.0
- * @version 6.4.0
+ * @since 6.0.0
+ *
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
*/
+window.eoxiaJS.digirisk.installer.installedComponentSuccess = function( triggeredElement, response ) {
-window.eoxiaJS.digirisk.pageSorter = {};
-
-window.eoxiaJS.digirisk.pageSorter.init = function() {
- jQuery( document ).on( 'click', '.sorter-page .button.button-primary', function( event ) {
- window.removeEventListener( 'beforeunload', window.eoxiaJS.digirisk.pageSorter.safeExit );
- } );
-
- if ( jQuery( '.sorter-page' ).length ) {
- jQuery( '.treetable' ).treetable( { expandable: true } );
- jQuery( '.treetable' ).treetable( 'expandAll' );
-
- jQuery( '.treetable .digi-workunit, .treetable .digi-group' ).draggable( {
- helper: 'clone',
- opacity: .75,
- refreshPositions: true,
- revert: 'invalid',
- revertDuration: 300,
- scroll: true
- } );
-
- jQuery( '.treetable .digi-group, .digi-society' ).each( function() {
- jQuery( this ).parents( '.treetable tr' ).droppable( {
- accept: '.digi-workunit, .digi-group',
- drop: function( e, ui ) {
- var droppedEl = ui.draggable.parents( 'tr' );
-
- if ( droppedEl.data( 'ttId' ) == jQuery( this ).data( 'ttParentId' ) ) {
- e.preventDefault();
- return false;
- } else {
- window.addEventListener( 'beforeunload', window.eoxiaJS.digirisk.pageSorter.safeExit );
+ // Si l'installation n'est pas terminée, on relance une requête avec les prochains composants à installer.
+ if ( ! response.data.core_option.installed ) {
+ if ( ! response.data.core_option.recommendation_installed && response.data.core_option.danger_installed ) {
+ window.eoxiaJS.digirisk.installer.progressBar( 55 );
+ } else if ( response.data.core_option.recommendation_installed ) {
+ window.eoxiaJS.digirisk.installer.progressBar( 80 );
+ }
+ window.eoxiaJS.digirisk.installer.requestInstallComponent();
+ } else {
+ window.eoxiaJS.digirisk.installer.progressBar( 100 );
- jQuery( 'input[type="submit"]' ).attr( 'disabled', false );
+ jQuery( '.wpdigi-installer .wpdigi-components .next' ).removeClass( 'button-disable' );
+ if ( 0 < jQuery( '#toplevel_page_digi-setup a' ).length ) {
+ jQuery( '#toplevel_page_digi-setup a' ).attr( 'href', jQuery( '#toplevel_page_digi-setup a' ).attr( 'href' ).replace( 'digi-setup', 'digirisk-du' ) );
+ }
- jQuery( 'input[name="menu_item_parent_id[' + droppedEl.data( 'ttId' ) + ']"]' ).val( jQuery( this ).data( 'ttId' ) );
- jQuery( '.treetable' ).treetable( 'move', droppedEl.data( 'ttId' ), jQuery( this ).data( 'ttId' ) );
- }
- },
- hoverClass: 'accept',
- over: function( e, ui ) {
- var droppedEl = ui.draggable.parents( 'tr' );
- if ( this != droppedEl[0] && ! jQuery( this ).is( '.expanded' ) ) {
- jQuery( '.treetable' ).treetable( 'expandNode', jQuery( this ).data( 'ttId' ) );
- }
- }
- });
- });
+ window.eoxiaJS.loader.remove( jQuery( '.wpdigi-installer a' ) );
}
};
/**
- * Vérification avant la fermeture de la page si toutes les données sont enregistrées.
+ * Met à jour la barre de progression.
*
- * @since 6.3.0
- * @version 6.4.0
+ * @since 6.0.0
*
- * @param {WindowEventHandlers} event L'évènement de la fenêtre.
- * @return {string}
+ * @param {integer} pourcent Le pourcentage courant.
*/
-window.eoxiaJS.digirisk.pageSorter.safeExit = function( event ) {
- var confirmationMessage = 'Vos données sont en attentes d\'enregistrement';
+window.eoxiaJS.digirisk.installer.progressBar = function( pourcent ) {
+ clearInterval( window.eoxiaJS.digirisk.installer.progressInterval );
+ window.eoxiaJS.digirisk.installer.progressInterval = undefined;
- event.returnValue = confirmationMessage;
- return confirmationMessage;
+ window.eoxiaJS.digirisk.installer.progressInterval = setInterval( function() {
+ var currentWidth = jQuery( '.wpdigi-installer .bar .loader' ).attr( 'data-width' );
+ currentWidth++;
+
+ jQuery( '.wpdigi-installer .bar .loader' ).css( 'width', currentWidth + '%' );
+ jQuery( '.wpdigi-installer .bar .loader' ).attr( 'data-width', currentWidth );
+
+ jQuery( '.wpdigi-installer .step-list .step[data-width="' + currentWidth + '"]' ).addClass( 'active' );
+
+ if ( jQuery( '.wpdigi-installer .bar .loader' ).attr( 'data-width' ) >= pourcent ) {
+ clearInterval( window.eoxiaJS.digirisk.installer.progressInterval );
+ window.eoxiaJS.digirisk.installer.progressInterval = undefined;
+
+ if ( pourcent === 100 ) {
+ jQuery( '.wpdigi-installer .end-install.button-disable' ).removeClass( 'button-disable' );
+ }
+ }
+ }, 100 );
};
/**
- * Initialise l'objet "permisFeu" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ * Initialise l'objet "legalDisplay" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
*
- * @since 6.6.0
+ * @since 6.0.0
+ * @version 6.4.4
*/
-window.eoxiaJS.digirisk.permisFeu = {};
-/**
- * Gestion des signatures.
- *
- * @type {HTMLCanvasElement}
- */
-window.eoxiaJS.digirisk.permisFeu.canvas;
+window.eoxiaJS.digirisk.legalDisplay = {};
-/**
- * Initialise les évènements.
- *
- * @since 6.6.0
- *
- * @return {void}
- */
-window.eoxiaJS.digirisk.permisFeu.init = function() {
- window.eoxiaJS.digirisk.permisFeu.event();
- window.eoxiaJS.digirisk.permisFeu.refresh();
-};
+window.eoxiaJS.digirisk.legalDisplay.init = function() {};
/**
- * Initialise le canvas, ainsi que owlCarousel.
- *
- * @since 6.6.0
+ * Le callback en cas de réussite à la requête Ajax "save_legal_display".
+ * Actualises la vue en cliquant sur l'onglet "Affichage légal".
*
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
* @return {void}
- */
-window.eoxiaJS.digirisk.permisFeu.refresh = function() {
- jQuery( '.permis-feu-wrap .owl-carousel' ).owlCarousel( {
- 'nav': 1,
- 'loop': 1,
- 'items': 1,
- 'dots' : false,
- 'navText' : [' ',' '],
- } );
-}
-
-/**
- * Initialise les évènements principaux des permisFeu.
- *
- * @since 6.6.0
*
- * @return {void}
+ * @since 6.0.0
*/
-window.eoxiaJS.digirisk.permisFeu.event = function() {
- jQuery( document ).on( 'change', '.digi-permis-feu-parent .information-maitre-oeuvre .wpeo-autocomplete', window.eoxiaJS.digirisk.permisFeu.setMaitreOeuvre );
- jQuery( document ).on( 'change', '.digi-permis-feu-parent .information-intervenant-exterieur .wpeo-autocomplete', window.eoxiaJS.digirisk.permisFeu.setIntervenant );
+window.eoxiaJS.digirisk.legalDisplay.generatedSuccess = function( triggeredElement, response ) {
+ jQuery( '.wpeo-table.table-documents' ).replaceWith( response.data.view );
+ window.scrollTo( 0, 0 );
+};
- // Add Signature check field.
- jQuery( document ).on( 'saved-signature-success', '.digi-permis-feu-parent .information-maitre-oeuvre .button-signature', window.eoxiaJS.digirisk.permisFeu.updatedMaitreOeuvreSignature );
- jQuery( document ).on( 'saved-signature-success', '.digi-permis-feu-parent .information-intervenant-exterieur .button-signature', window.eoxiaJS.digirisk.permisFeu.updatedIntervenantSignature );
+window.eoxiaJS.digirisk.legalDisplay.generateSocietyIndicator = function( focus ) {
+ jQuery( '.main-information-society .bloc-information-society' ).each( function( index ){
+ if( jQuery( this ).find( 'input[name="indicator-id"]' ).length == 0 || jQuery( this ).find( 'input[name="indicator-id"]' ).val() == "" ){
+ return;
+ }else{
+ var id_indicator = jQuery( this ).find( 'input[name="indicator-id"]' ).val();
+ }
- jQuery( document ).on( 'click', '.digi-permis-feu-parent .select-prevention .autocomplete-result', window.eoxiaJS.digirisk.permisFeu.addPreventionToPermisDeFeu );
+ var nbr_total = 1;
+ if( jQuery( this ).find( 'input[name="indicator-nbr-total"]' ).length > 0 ){
+ nbr_total = jQuery( this ).find( 'input[name="indicator-nbr-total"]' ).val();
+ }
- jQuery( document ).on( 'click', '.digi-permis-feu-parent .action-permis-feu-prevention .delete-prevention-from-permis-feu', window.eoxiaJS.digirisk.permisFeu.deletePreventionFromPermisFeu );
+ var nbr_valid = 0;
+ if( jQuery( this ).find( 'input[name="indicator-nbr-valid"]' ).length > 0 ){
+ nbr_valid = jQuery( this ).find( 'input[name="indicator-nbr-valid"]' ).val();
+ }
+ var nbr_unvalid = nbr_total - nbr_valid;
- jQuery( document ).on( 'click', '.digi-permis-feu-parent .end-date-element .button-permis-feu-title', window.eoxiaJS.digirisk.permisFeu.updateEndDatePrevention );
+ var percent = 0;
+ if( jQuery( this ).find( '.bloc-indicator' ).length > 0 ){
+ percent = jQuery( this ).find( '.bloc-indicator' ).attr( 'data-percent' );
+ }
- jQuery( document ).on( 'click', '.digi-permis-feu-parent .unite-de-travail-element .autocomplete-search-list .autocomplete-result', window.eoxiaJS.digirisk.permisFeu.displayButtonUniteDeTravail );
+ // RED, ORANGE, YELLOW, GREEN
+ var color = window.eoxiaJS.digirisk.legalDisplay.getColorFromPercent( percent );
- jQuery( document ).on( 'click', '.digi-permis-feu-parent .readonly .display-modal-unite', window.eoxiaJS.digirisk.permisFeu.displayModalUniteDeTravail );
+ var canvasDonut = document.getElementById( id_indicator ).getContext('2d');
+ var data_canvas_donut = {
+ labels : [ 'Completed', 'Uncompleted' ],
+ datasets: [
+ {
+ backgroundColor: [ color, "rgb(230,230,230)" ],
+ data: [ nbr_valid, nbr_unvalid ],
+ }
+ ],
+ };
- jQuery( document ).on( 'click', '.digi-permis-feu-parent .unite-de-travail-class .worktype-element .dropdown-content .item', window.eoxiaJS.digirisk.permisFeu.selectRisqueInDropdown );
+ if ( 0 == percent ) {
+ data_canvas_donut.datasets[0].backgroundColor = [ color, 'red' ];
+ }
- jQuery( document ).on( 'keyup', '.digi-permis-feu-parent .unite-de-travail-class.edit input[type="text"]', window.eoxiaJS.digirisk.permisFeu.checkIfInterventionCanBeAdd );
- // jQuery( document ).on( 'keyup', '.digi-permis-feu-parent .information-maitre-oeuvre input[type="text"]', window.eoxiaJS.digirisk.permisFeu.permisFeuCanBeFinishMaitreOeuvre );
+ var option = {
+ title: {},
+ tooltips: {
+ custom: function(tooltip) {
+ }
+ },
+ legend: {
+ display: false
+ },
+ elements: {
+ center: {
+ text: percent + '%',
+ }
+ },
+ animation:{
- jQuery( document ).on( 'keyup', '.digi-permis-feu-parent .information-intervenant-exterieur input[type="text"]', window.eoxiaJS.digirisk.permisFeu.permisFeuCanBeFinishIntervenantExterieur );
+ }
+ };
+ if( focus != "" ){
+ option.animation.duration = 0;
+ }
- jQuery( document ).on( 'keyup', '.digi-permis-feu-parent .table-row .update-mail-auto input', window.eoxiaJS.digirisk.preventionPlan.preShotEmailUser );
+ canvasDonut.canvas.width = 80;
+ canvasDonut.canvas.height = 80;
- jQuery( document ).on( 'click', '.wrap-permis-feu .closed-permis-feu .action .delete-this-permis-feu-plan', window.eoxiaJS.digirisk.permisFeu.deleteThisPreventionPlan );
+ new Chart( canvasDonut, {
+ type: 'doughnut',
+ data: data_canvas_donut,
+ options: option
+ });
- jQuery( document ).on( 'click', '.display-line-intervenant', window.eoxiaJS.digirisk.permisFeu.displayFirstLineIntervenant );
+ Chart.pluginService.register({ // ------------
- jQuery( document ).on( 'click', '.display-line-intervention', window.eoxiaJS.digirisk.permisFeu.displayFirstLineIntervention)
-};
+ beforeDraw: function(chart) {
+ var width = chart.chart.width,
+ height = chart.chart.height,
+ ctx = chart.chart.ctx;
-window.eoxiaJS.digirisk.permisFeu.setMaitreOeuvre = function( event, data ){
- var element = jQuery( this );
+ ctx.restore();
+ // var fontSize = (height / 114).toFixed(2);
+ ctx.font = 'italic 20px -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif';
+ ctx.textBaseline = "middle";
- if ( data && data.element ) {
- var request_data = {};
- request_data.action = 'permis_feu_display_maitre_oeuvre';
- request_data.user_id = element.closest( '.information-maitre-oeuvre' ).find( 'input[name="user_id"]' ).val();
- request_data.permis_feu_id = element.closest( '.digi-permis-feu-parent' ).find( 'input[name="permis_feu_id"]' ).val();
+ var centerConfig = chart.config.options.elements.center;
+ var text = centerConfig.text,
+ textX = Math.round((width - ctx.measureText(text).width) / 2),
+ textY = height / 2;
- window.eoxiaJS.loader.display( jQuery( this ) );
- window.eoxiaJS.request.send( jQuery( this ), request_data, function( triggeredElement, response ) {
- triggeredElement.closest( '.information-maitre-oeuvre' ).replaceWith( response.data.view );
- window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishMaitreOeuvre( jQuery( '.information-maitre-oeuvre' ) );
- } );
- }
-}
+ ctx.fillText(text, textX, textY);
+ ctx.save();
+ }
+ }); // ------------
+ } );
+};
-window.eoxiaJS.digirisk.permisFeu.setIntervenant = function( event, data ){
- var element = jQuery( this );
-
- if ( data && data.element ) {
- var request_data = {};
- request_data.action = 'permis_feu_display_intervenant';
- request_data.user_id = element.closest( '.digi-permis-feu-parent' ).find( 'input[name="user_id"]' ).val();
- request_data.permis_feu_id = element.closest( '.digi-permis-feu-parent' ).find( 'input[name="permis_feu_id"]' ).val();
+window.eoxiaJS.digirisk.legalDisplay.getColorFromPercent = function ( percent ){
+ var color = [ 'rgb(255,1,1)', 'rgb(255,153,0)', 'rgb(255,213,0)', 'rgb(71,229,142)' ];
- window.eoxiaJS.loader.display( jQuery( this ) );
- window.eoxiaJS.request.send( jQuery( this ), request_data, function( triggeredElement, response ) {
- triggeredElement.closest( '.information-intervenant-exterieur' ).replaceWith( response.data.view );
- window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishIntervenantExterieur( jQuery( '.information-intervenant-exterieur' ) );
- } );
+ if( percent > 75 ){
+ return color[3];
+ }else if( percent > 50 ){
+ return color[2];
+ }else if( percent > 25 ){
+ return color[1];
+ }else{
+ return color[1];
}
}
+
+/**
+ * Initialise l'objet "listingRisk" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ *
+ * @since 6.5.0
+ */
-window.eoxiaJS.digirisk.permisFeu.updatedMaitreOeuvreSignature = function( triggeredElement, response ) {
- var element = jQuery( this );
- window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishMaitreOeuvre( element );
-};
+window.eoxiaJS.digirisk.listingRisk = {};
-window.eoxiaJS.digirisk.permisFeu.updatedIntervenantSignature = function( triggeredElement, response ) {
- var element = jQuery( this );
- window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishIntervenantExterieur( jQuery( '.permis-feu-wrap' ) );
+/**
+ * Méthode obligatoire pour initialiser l'objet listingRisk avec EO-Framework.
+ *
+ * @since 6.5.0
+ */
+window.eoxiaJS.digirisk.listingRisk.init = function() {
+ window.eoxiaJS.digirisk.listingRisk.event();
};
-window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishMaitreOeuvre = function( element ){
- var parent_element = element.closest( '.digi-permis-feu-parent' );
- var maitre_oeuvre_element = parent_element.find( '.information-maitre-oeuvre' );
-
- var error = false;
- error = window.eoxiaJS.digirisk.permisFeu.checkIfThisChampsIsValid( maitre_oeuvre_element, 'user_id', error );
- error = window.eoxiaJS.digirisk.permisFeu.checkIfThisChampsIsValid( maitre_oeuvre_element, 'user_signature', error );
+/**
+ * Méthode pour initialiser tous les évènements.
+ *
+ * @since 6.5.0
+ */
+window.eoxiaJS.digirisk.listingRisk.event = function() {};
- if ( ! error ) {
- parent_element.find( '.permis-feu-start' ).removeClass( 'button-disable' );
+/**
+ * Le callback en cas de réussite à la requête Ajax "generate_listing_risk".
+ * Cliques sur le bouton "Listing des risques" pour recharger la vue.
+ *
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
+ *
+ * @since 6.5.0
+ */
+window.eoxiaJS.digirisk.listingRisk.generatedListingRiskSuccess = function( triggeredElement, response ) {
+ if ( 'photos' === response.data.type ) {
+ jQuery( '.tab-element[data-target="digi-listing-risk-photo"]' ).click();
} else {
- parent_element.find( '.permis-feu-start' ).addClass( 'button-disable' );
+ jQuery( '.tab-element[data-target="digi-listing-risk-action-corrective"]' ).click();
}
-}
-
-window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishIntervenantExterieur = function( element ){
- var parent_element = jQuery( '.permis-feu-wrap' );
+};
+
+/**
+ * Initialise l'objet "navigation" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ *
+ * @since 6.0.0
+ * @version 7.0.0
+ */
- var error = false;
+window.eoxiaJS.digirisk.navigation = {};
- error = window.eoxiaJS.digirisk.permisFeu.checkIfThisChampsIsValid( parent_element, 'user_id', error );
- error = window.eoxiaJS.digirisk.permisFeu.checkIfThisChampsIsValid( parent_element, 'user_signature', error );
+/**
+ * La méthode appelée automatiquement par la bibliothèque EoxiaJS.
+ *
+ * @return {void}
+ *
+ * @since 6.0.0
+ * @version 6.2.4
+ */
+window.eoxiaJS.digirisk.navigation.init = function() {
+ window.eoxiaJS.digirisk.navigation.event();
+};
- if( ! error ){
- parent_element.find( '.permis-feu-start' ).removeClass( 'button-disable' );
- }else{
- parent_element.find( '.permis-feu-start' ).addClass( 'button-disable' );
- }
-}
+/**
+ * La méthode contenant tous les évènements pour la navigation.
+ *
+ * @since 6.0.0
+ * @version 6.3.0
+ *
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.navigation.event = function() {
+ jQuery( document ).on( 'click', '.digirisk-wrap .navigation-container .unit-container .toggle-unit', window.eoxiaJS.digirisk.navigation.switchToggle );
+ jQuery( document ).on( 'click', '.digirisk-wrap .navigation-container .add-container .wpeo-button, .digirisk-wrap .navigation-container .mobile-add-container .dropdown-item', window.eoxiaJS.digirisk.navigation.displayAddField );
+ jQuery( document ).on( 'click', '.digirisk-wrap .navigation-container .toolbar div', window.eoxiaJS.digirisk.navigation.toggleAll );
+ jQuery( document ).on( 'click', '.digirisk-wrap .navigation-container .unit.new .placeholder-icon', window.eoxiaJS.digirisk.navigation.focusField );
+ jQuery( document ).on( 'keyup', '.digirisk-wrap .navigation-container input[name="title"]', window.eoxiaJS.digirisk.navigation.triggerCreateSociety );
-window.eoxiaJS.digirisk.permisFeu.displaySignatureLastPage = function( triggeredElement, response ){
- var class_parent = '.' + response.data.class_parent;
- var element_parent = triggeredElement.closest( '.digi-permis-feu-parent' );
+ jQuery( document ).on( 'click', '.digirisk-wrap .mobile-navigation', window.eoxiaJS.digirisk.navigation.openNavigationContainer );
+ jQuery( document ).on( 'click', '.digirisk-wrap .navigation-container.active .close-popup', window.eoxiaJS.digirisk.navigation.closeNavigationContainer );
+};
- var element = jQuery( '.digi-permis-feu-parent' ).find( class_parent );
- var a = element.find( '.signature-info-element .signature' );
- a.html( response.data.view );
+/**
+ * Gestion du toggle dans la navigation.
+ *
+ * @since 6.3.0
+ * @version 6.3.0
+ *
+ * @param {MouseEvent} event Les attributs lors du clic.
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.navigation.switchToggle = function( event ) {
+ event.preventDefault();
- if( response.data.class_parent == "information-maitre-oeuvre" ){
- window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishMaitreOeuvre( element_parent );
- }else{
- window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishIntervenantExterieur( element_parent );
+ if ( jQuery( this ).find( '.toggle-icon' ).hasClass( 'fa-chevron-down' ) ) {
+ jQuery(this).find( '.toggle-icon' ).removeClass('fa-chevron-down').addClass('fa-chevron-right');
+ jQuery(this).closest('.unit').removeClass('toggled');
+ } else {
+ jQuery(this).find( '.toggle-icon' ).removeClass('fa-chevron-right').addClass('fa-chevron-down');
+ jQuery(this).closest('.unit').addClass('toggled');
}
-}
+};
-window.eoxiaJS.digirisk.permisFeu.nextStep = function( element, response ) {
- if( response.data.url ){
- window.location.replace( response.data.url );
- } else {
+/**
+ * Affiches le champ pour créer un établissement.
+ *
+ * @since 6.3.0
+ * @version 6.3.0
+ *
+ * @param {MouseEvent} event Les attributs lors du clic.
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.navigation.displayAddField = function( event ) {
+ var closest = jQuery( this ).closest( '.society-header' ).length ? jQuery( this ).closest( '.navigation-container' ) : jQuery( this ).closest( '.unit' );
+ event.preventDefault();
+ event.stopPropagation();
- jQuery('.permis-feu-wrap').replaceWith(response.data.view);
+ // Mobile.
+ jQuery( '.mobile-add-container .content.active' ).removeClass( 'active' );
- var currentStep = response.data.current_step;
- var percent = 0;
+ closest.addClass( 'toggled' );
- if (2 === currentStep) {
- percent = 37;
- } else if (3 === currentStep) {
- percent = 62;
- } else if (4 === currentStep) {
- percent = 100;
- } else {
- percent = 0;
- }
+ if ( 'Group_Class' === jQuery( this ).data( 'type' ) ) {
+ closest.find( '.unit.new:first .placeholder-icon' ).removeClass( 'dashicons-admin-home' );
+ closest.find( '.unit.new:first .placeholder-icon' ).addClass( 'dashicons-admin-multisite' );
+ } else {
+ closest.find( '.unit.new:first .placeholder-icon' ).removeClass( 'dashicons-admin-multisite' );
+ closest.find( '.unit.new:first .placeholder-icon' ).addClass( 'dashicons-admin-home' );
+ }
- if (jQuery('.main-content').hasClass('step-1')) {
- jQuery('.main-content').removeClass('step-1').addClass('step-2');
- } else if (jQuery('.main-content').hasClass('step-2')) {
- jQuery('.main-content').removeClass('step-2').addClass('step-3');
- } else if (jQuery('.main-content').hasClass('step-3')) {
- jQuery('.main-content').removeClass('step-3').addClass('step-4');
- }
+ if ( closest.find( '.unit.new:first' ).hasClass( 'active' ) && closest.find( '.unit.new:first input[name="class"]' ).val() != jQuery( this ).data( 'type' ) ) {
+ } else {
+ closest.find( '.unit.new:first' ).toggleClass( 'active' );
+ }
- jQuery('.permis-feu-wrap .bar .loader').css('width', percent + '%');
- jQuery('.permis-feu-wrap .bar .loader').attr('data-width', percent);
- jQuery('.permis-feu-wrap .step-list .step[data-width="' + percent + '"]').addClass('active');
+ if ( closest.find( '.unit.new:first' ).hasClass( 'active' ) ) {
+ closest.find( '.unit.new:first.active input[type="text"]' ).focus();
}
- // window.eoxiaJS.refresh();
+ closest.find( '.unit.new:first input[name="class"]' ).val( jQuery( this ).data( 'type' ) );
};
+/**
+ * Focus le champ 'title' pour créer un établissement
+ *
+ * @since 6.3.0
+ * @version 6.3.0
+ *
+ * @param {MouseEvent} event Les attributs lors du clic.
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.navigation.focusField = function( event ) {
+ event.preventDefault();
-window.eoxiaJS.digirisk.permisFeu.addPreventionToPermisDeFeu = function( event, data ){
- var element = jQuery( this );
- var parent_element = jQuery( this ).closest( '.select-prevention' );
-
- var request_data = {};
- request_data.action = parent_element.attr( 'data-action' );
- request_data._wpnonce = parent_element.attr( 'data-nonce' );
- request_data.prevention_id = parent_element.find( 'input[name="prevention_id"]' ).val();
- request_data.permis_feu_id = parent_element.find( 'input[name="permis_feu_id"]' ).val();
+ jQuery( this ).closest( '.unit.new' ).find( 'input[type="text"]' ).focus();
+};
- window.eoxiaJS.loader.display( parent_element );
- window.eoxiaJS.request.send( parent_element, request_data );
-}
+/**
+ * Déplies ou replies tous les éléments enfants
+ *
+ * @since 6.3.0
+ * @version 6.3.0
+ *
+ * @param {MouseEvent} event Les attributs lors du clic
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.navigation.toggleAll = function( event ) {
+ event.preventDefault();
-window.eoxiaJS.digirisk.permisFeu.addPreventionToPermisFeuSuccess = function( triggeredElement, response ){
- if( response.data.view != "" ){
- // triggeredElement.closest( '.digi-permis-feu-parent' ).find( '.next-step-need-prevention' ).removeClass( 'button-disable' );
- triggeredElement.closest( '.digi-permis-feu-parent' ).find( '.intervention-prevention-plan' ).html( response.data.pre_i_view );
- triggeredElement.closest( '.wpeo-gridlayout' ).html( response.data.view );
+ if ( jQuery( this ).hasClass( 'toggle-plus' ) ) {
+ jQuery( '.digirisk-wrap .navigation-container .workunit-list .unit .toggle-icon').removeClass( 'fa-chevron-right').addClass( 'fa-chevron-down' );
+ jQuery( '.digirisk-wrap .navigation-container .workunit-list .unit' ).addClass( 'toggled' );
}
-}
-window.eoxiaJS.digirisk.permisFeu.deletePreventionFromPermisFeu = function( event ){
-
- var request_data = {};
- request_data.action = jQuery( this ).attr( 'data-action' );
- request_data._wpnonce = jQuery( this ).attr( 'data-nonce' );
- request_data.id = jQuery( this ).attr( 'data-id' );
-
- if( confirm( jQuery( this ).attr( 'data-message' ) ) ){
- window.eoxiaJS.loader.display( jQuery( this ) );
- window.eoxiaJS.request.send( jQuery( this ), request_data );
- }
-}
-
-window.eoxiaJS.digirisk.permisFeu.deletePreventionFromPermisFeuSuccess = function( triggeredElement, response ){
- if( response.data.view != "" ){
- triggeredElement.closest( '.digi-permis-feu-parent' ).find( '.intervention-prevention-plan' ).html( '' );
- triggeredElement.closest( '.wpeo-gridlayout' ).html( response.data.view );
- }
-}
-
-window.eoxiaJS.digirisk.permisFeu.updateEndDatePrevention = function( event ){
- jQuery( this ).closest( '.end-date-element' ).find( '.wpeo-button' ).removeClass( 'button-blue' ).addClass( 'button-grey' );
- jQuery( this ).removeClass( 'button-grey' ).addClass( 'button-blue' );
- jQuery( this ).closest( '.end-date-element' ).find( 'input[name="date_end__is_define"]' ).val( jQuery( this ).attr( 'data-action' ) );
-
- var form_element = jQuery( this ).closest( '.end-date-element' ).find( '.form-element' );
- if( jQuery( this ).attr( 'data-action' ) == "undefined" ){
- form_element.addClass( 'form-element-disable' );
- }else{
- form_element.removeClass( 'form-element-disable' );
- }
-}
-
-window.eoxiaJS.digirisk.permisFeu.displayButtonUniteDeTravail = function( event ){
- window.eoxiaJS.digirisk.permisFeu.checkIfInterventionCanBeAdd( '', jQuery( this ) );
-}
-
-
-window.eoxiaJS.digirisk.permisFeu.displayButtonUniteDeTravailSuccess = function( trigerredElement, response ){
- trigerredElement.closest( '.unite-de-travail-class' ).find( '.button-unite-de-travail' ).html( response.data.view );
- var error = window.eoxiaJS.digirisk.permisFeu.checkIfInterventionCanBeAdd( '', trigerredElement );
- if( ! error ){
- var parent_element = trigerredElement.closest( '.unite-de-travail-class' );
- parent_element.find( '.button-add-row-intervention' ).removeClass( 'button-disable' ).addClass( 'button-blue' );
- }
-}
-
-window.eoxiaJS.digirisk.permisFeu.displayModalUniteDeTravail = function( event ) {
- jQuery( this ).closest( '.button-unite-de-travail' ).find( '.digirisk-modal-unite' ).addClass( 'modal-active' );
-}
-
-window.eoxiaJS.digirisk.permisFeu.selectRisqueInDropdown = function( event ){
- var parent_element = jQuery( this ).closest( '.form-element' );
- var info_element = parent_element.find( '.category-worktype .dropdown-toggle' );
- info_element.css( 'padding', '0' );
- info_element.find( 'span' ).hide();
- info_element.find( '.button-icon' ).hide();
-
- parent_element.find( '[name="worktype_category_id"]' ).val( jQuery( this ).attr( 'data-id' ) );
- var img_src = jQuery( this ).find( 'img' ).attr( 'src' );
- info_element.find( 'img' ).attr( 'src', img_src );
- info_element.find( 'img' ).removeClass( 'hidden' ).removeClass( 'wpeo-tooltip-event' ).addClass( 'wpeo-tooltip-event' );
-
- info_element.find( 'img' ).attr( 'aria-label', jQuery( this ).attr( 'aria-label' ) );
- var error = window.eoxiaJS.digirisk.permisFeu.checkIfInterventionCanBeAdd( '', jQuery( this ) );
- if( ! error ){
- var parent_element = jQuery( this ).closest( '.unite-de-travail-class' );
- parent_element.find( '.button-add-row-intervention' ).removeClass( 'button-disable' ).addClass( 'button-blue' );
- }
-}
-
-
-window.eoxiaJS.digirisk.permisFeu.checkIfInterventionCanBeAdd = function( event, element ){
- if( ! element ){
- element = jQuery( this );
- }
-
- var parent_element = element.closest( '.unite-de-travail-class' );
- var error = false;
-
- error = window.eoxiaJS.digirisk.permisFeu.checkIfThisChampsIsValid( parent_element, 'unitedetravail', error );
- error = window.eoxiaJS.digirisk.permisFeu.checkIfThisChampsIsValid( parent_element, 'description-des-actions', error );
- error = window.eoxiaJS.digirisk.permisFeu.checkIfThisChampsIsValid( parent_element, 'materiel-utilise', error );
- error = window.eoxiaJS.digirisk.permisFeu.checkIfThisChampsIsValid( parent_element, 'worktype_category_id', error );
-
- if( ! error ){
- parent_element.find( '.button-add-row-intervention' ).removeClass( 'button-disable' ).addClass( 'button-blue' );
- }else{
- parent_element.find( '.button-add-row-intervention' ).removeClass( 'button-blue' ).addClass( 'button-disable' );
- }
-
-
- return error;
-}
-
-window.eoxiaJS.digirisk.permisFeu.checkIfThisChampsIsValid = function( parent_element, element, error ){
- if( error ){
- return true;
- }
-
- var content = parent_element.find( '[name="' + element + '"]').val();
-
- if( content == "" || content == "-1" || content == null ){
- return true;
- }else{
- return false;
- }
-}
-
-window.eoxiaJS.digirisk.permisFeu.addInterventionLinePermisFeuSuccess = function( triggeredElement, response ){
- triggeredElement.closest( '.intervention-content' ).html( response.data.table_view );
-}
-
-window.eoxiaJS.digirisk.permisFeu.editInterventionLineSuccess = function( triggeredElement, response ){
- triggeredElement.closest( '.intervention-row' ).replaceWith( response.data.view );
-}
-
-window.eoxiaJS.digirisk.permisFeu.preventionLoadTabSuccess = function( element, response ){
- element.closest( '.main-content' ).html( response.data.view );
-}
-
-window.eoxiaJS.digirisk.permisFeu.permisFeuCanBeFinishMaitreOeuvre = function( event ){
- window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishMaitreOeuvre( jQuery( this ) );
-}
-
-window.eoxiaJS.digirisk.permisFeu.permisFeuCanBeFinishIntervenantExterieur = function( event ){
- window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishIntervenantExterieur( jQuery( this ) );
-}
-
-window.eoxiaJS.digirisk.permisFeu.addIntervenantToPrevention = function( triggeredElement, response ){
- triggeredElement.closest( '.wpeo-table' ).replaceWith( response.data.view );
-}
-
-window.eoxiaJS.digirisk.permisFeu.editIntervenantPrevention = function( triggeredElement, response ){
- triggeredElement.closest( '.table-row' ).replaceWith( response.data.view );
-}
-
-window.eoxiaJS.digirisk.permisFeu.editThisPreventionSuccess = function( trigerredElement, response ){
- if( response.data.url ){
- window.location.replace( response.data.url );
- }
-}
-
-window.eoxiaJS.digirisk.permisFeu.deleteThisPreventionPlan = function( event ){
- var message = jQuery( this ).attr( 'data-message' );
- if( confirm( message ) ){
- var data = {};
-
- data.action = jQuery( this ).attr( 'data-action' );
- data._wpnonce = jQuery( this ).attr( 'data-nonce' );
- data.id = jQuery( this ).attr( 'data-id' );
-
- window.eoxiaJS.loader.display( jQuery( this ).closest( '.item' ) );
- window.eoxiaJS.request.send( jQuery( this ), data );
+ if ( jQuery( this ).hasClass( 'toggle-minus' ) ) {
+ jQuery( '.digirisk-wrap .navigation-container .workunit-list .unit.toggled' ).removeClass( 'toggled' );
+ jQuery( '.digirisk-wrap .navigation-container .workunit-list .unit .toggle-icon').addClass( 'fa-chevron-right').removeClass( 'fa-chevron-down' );
}
-}
-
-window.eoxiaJS.digirisk.permisFeu.deleteDocumentPermisFeuSuccess = function( trigerredElement, response ){
- trigerredElement.closest( '.main-content' ).html( response.data.dashboard_view );
-}
-
-window.eoxiaJS.digirisk.permisFeu.displayFirstLineIntervenant = function( event ){
- jQuery( this ).closest( '.intervenant-bloc' ).find( '.table-new-line-intervenant' ).show( '200' );
-}
+};
-window.eoxiaJS.digirisk.permisFeu.displayFirstLineIntervention = function( event ){
- console.log( 'oui' );
- jQuery( this ).closest( '.intervention-table' ).find( '.new-line-intervention' ).show( '200' );
-}
-
/**
- * Initialise l'objet "preventionPlan" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ * Ajout la classe 'active' à l'élément.
*
- * @since 6.6.0
+ * @since 6.3.0
+ * @version 6.3.0
+ *
+ * @param {HTMLDivElement} element L'attribut de l'élement.
+ * @return {boolean}
*/
-window.eoxiaJS.digirisk.preventionPlan = {};
+window.eoxiaJS.digirisk.navigation.setUnitActive = function( element ) {
+ jQuery( '.digirisk-wrap .navigation-container .unit.active' ).removeClass( 'active' );
+ jQuery( element ).closest( '.unit' ).addClass( 'active' );
+ return true;
+};
/**
- * Gestion des signatures.
+ * Clic automatiquement sur le 'action-input'.
*
- * @type {HTMLCanvasElement}
+ * @since 6.3.0
+ * @version 6.3.0
+ *
+ * @param {KeyboardEvent} event Les attributs du clavier.
+ * @return {void}
*/
-window.eoxiaJS.digirisk.preventionPlan.canvas;
+window.eoxiaJS.digirisk.navigation.triggerCreateSociety = function( event ) {
+ if ( event.ctrlKey && 13 === event.keyCode ) {
+ jQuery( this ).closest( '.unit.new' ).find( '.action-input' ).click();
+ }
+};
/**
- * Initialise les évènements.
+ * Ajout de la classe 'active' au bloc 'navigation-container'.
*
- * @since 6.6.0
+ * @since 6.3.0
+ * @version 6.3.0
*
+ * @param {TouchEvent} event [description]
* @return {void}
*/
-window.eoxiaJS.digirisk.preventionPlan.init = function() {
- window.eoxiaJS.digirisk.preventionPlan.event();
- // window.eoxiaJS.digirisk.preventionPlan.refresh();
+window.eoxiaJS.digirisk.navigation.openNavigationContainer = function( event ) {
+ jQuery( '.digirisk-wrap .navigation-container' ).addClass( 'active' );
};
/**
- * Initialise les évènements principaux des preventionPlans.
+ * Enlève la classe 'active' au bloc 'navigation-container'.
*
- * @since 6.6.0
+ * @since 6.3.0
+ * @version 6.3.0
*
+ * @param {TouchEvent} event [description]
* @return {void}
*/
-window.eoxiaJS.digirisk.preventionPlan.event = function() {
- jQuery( document ).on( 'change', '.digi-prevention-plan-parent .information-maitre-oeuvre .wpeo-autocomplete', window.eoxiaJS.digirisk.preventionPlan.setMaitreOeuvre );
- jQuery( document ).on( 'saved-signature-success', '.digi-prevention-plan-parent.step-1 .form-element', window.eoxiaJS.digirisk.preventionPlan.updatedMaitreOeuvreSignature );
- jQuery( document ).on( 'saved-signature-success', '.digi-prevention-plan-parent.step-4 .form-element', window.eoxiaJS.digirisk.preventionPlan.updatedIntervenantExterieurSignature );
-
- // Recherche GP/UT
- jQuery( document ).on( 'click', '.digi-prevention-plan-parent .unite-de-travail-element .autocomplete-search-list .autocomplete-result', window.eoxiaJS.digirisk.preventionPlan.displayButtonUniteDeTravail );
+window.eoxiaJS.digirisk.navigation.closeNavigationContainer = function( event ) {
+ event.stopPropagation();
- jQuery( document ).on( 'click', '.digi-prevention-plan-parent .readonly .display-modal-unite', window.eoxiaJS.digirisk.preventionPlan.displayModalUniteDeTravail );
+ jQuery( '.digirisk-wrap .navigation-container' ).removeClass( 'active' );
+};
- /*jQuery( document ).on( 'keyup', '.digi-prevention-plan-parent .information-element-society input', window.eoxiaJS.digirisk.preventionPlan.displayButtonSaveInformation );*/
+/**
+ * Callback en cas de réussite de la requête Ajax "create_society"
+ *
+ * @since 6.3.0
+ * @version 6.3.0
+ *
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response {
+ * Les données renvoyées par la requête Ajax.
+ * @type {Object} data {
+ * @type {string} navigation_view La vue de la navigation.
+ * @type {string} content_view La vue du contenu principale.
+ * }
+ * }
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.navigation.createdSocietySuccess = function( triggeredElement, response ) {
+ jQuery( '.workunit-list .unit.active' ).removeClass( 'active' );
- jQuery( document ).on( 'keyup', '.digi-prevention-plan-parent .update-mail-auto input', window.eoxiaJS.digirisk.preventionPlan.preShotEmailUser );
+ jQuery( triggeredElement ).closest( '.unit:not(.new)' ).find( '.spacer:first' ).removeClass( 'spacer' ).addClass( 'toggle-unit' ).append(' ');
- jQuery( document ).on( 'click', '.digi-prevention-plan-parent .unite-de-travail-class .risque-element .dropdown-content .item', window.eoxiaJS.digirisk.preventionPlan.selectRisqueInDropdown );
+ if ( jQuery( triggeredElement ).closest( '.sub-list' ).length ) {
+ jQuery( triggeredElement ).closest( '.sub-list' ).replaceWith( response.data.navigation_view );
+ } else {
+ jQuery( triggeredElement ).closest( '.workunit-list' ).replaceWith( response.data.navigation_view );
+ }
- jQuery( document ).on( 'keyup', '.digi-prevention-plan-parent .unite-de-travail-class [name="moyen-de-prevention"]', window.eoxiaJS.digirisk.preventionPlan.checkIfInterventionCanBeAdd );
-
- jQuery( document ).on( 'keyup', '.digi-prevention-plan-parent .unite-de-travail-class [name="description-des-actions"]', window.eoxiaJS.digirisk.preventionPlan.checkIfInterventionCanBeAdd );
-
- jQuery( document ).on( 'click', '.digi-prevention-plan-parent .unite-de-travail-class .button-add-row-intervention', window.eoxiaJS.digirisk.preventionPlan.addInterventionLine );
-
- jQuery( document ).on( 'keyup', '.digi-prevention-plan-parent .information-maitre-oeuvre input[type="text"]', window.eoxiaJS.digirisk.preventionPlan.preventionPlanCanBeFinishMaitreOeuvre );
-
- jQuery( document ).on( 'keyup', '.digi-prevention-plan-parent .information-intervenant-exterieur input[type="text"]', window.eoxiaJS.digirisk.preventionPlan.PreventionPlanCanBeFinishIntervenantExterieur );
-
- jQuery( document ).on( 'click', '.wrap-prevention .closed-prevention .avatar-info-prevention .avatar', window.eoxiaJS.digirisk.preventionPlan.displayUserInfo );
+ jQuery( '.digirisk-wrap .main-container' ).replaceWith( response.data.content_view );
+ window.eoxiaJS.digirisk.risk.refresh();
+};
- jQuery( document ).on( 'click', '.wrap-prevention .closed-prevention .action .delete-this-prevention-plan', window.eoxiaJS.digirisk.preventionPlan.deleteThisPreventionPlan );
+/**
+ * Callback en cas de réussite de la requête Ajax "load_society"
+ * Remplaces le template principale de l'application avec le template reçu dans la réponse de la requête Ajax.
+ *
+ * @param {HTMLSpanElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
+ *
+ * @since 6.0.0
+ * @version 7.0.0
+ */
+window.eoxiaJS.digirisk.navigation.loadedSocietySuccess = function( element, response ) {
+ jQuery( '.digirisk-wrap .main-container' ).replaceWith( response.data.view );
+ jQuery( '.digirisk-wrap .navigation-container' ).removeClass( 'active' );
+ window.eoxiaJS.digirisk.risk.refresh();
+};
+
+/**
+ * Initialise l'objet 'legalDisplay' ainsi que la méthode 'init' obligatoire pour la bibliothèque EoxiaJS.
+ *
+ * @since 6.3.0
+ * @version 6.4.0
+ */
- jQuery( document ).on( 'click', '.digi-prevention-plan-parent .end-date-element .action-button-end-date', window.eoxiaJS.digirisk.preventionPlan.updateEndDatePrevention );
+window.eoxiaJS.digirisk.pageSorter = {};
- jQuery( document ).on( 'change', '.start-date', window.eoxiaJS.digirisk.preventionPlan.updateStartDatePrevention );
+window.eoxiaJS.digirisk.pageSorter.init = function() {
+ jQuery( document ).on( 'click', '.sorter-page .button.button-primary', function( event ) {
+ window.removeEventListener( 'beforeunload', window.eoxiaJS.digirisk.pageSorter.safeExit );
+ } );
- jQuery( document ).on('keyup', '.element-phone-input', window.eoxiaJS.digirisk.preventionPlan.regexPhoneNumber );
+ if ( jQuery( '.sorter-page' ).length ) {
+ jQuery( '.treetable' ).treetable( { expandable: true } );
+ jQuery( '.treetable' ).treetable( 'expandAll' );
- jQuery( document ).on( 'click', '.digi-prevention-plan-parent .title-information-option .action-button-title', window.eoxiaJS.digirisk.preventionPlan.updateTitleOption );
-};
+ jQuery( '.treetable .digi-workunit, .treetable .digi-group' ).draggable( {
+ helper: 'clone',
+ opacity: .75,
+ refreshPositions: true,
+ revert: 'invalid',
+ revertDuration: 300,
+ scroll: true
+ } );
-window.eoxiaJS.digirisk.preventionPlan.setMaitreOeuvre = function( event, data ) {
- var element = jQuery( this );
+ jQuery( '.treetable .digi-group, .digi-society' ).each( function() {
+ jQuery( this ).parents( '.treetable tr' ).droppable( {
+ accept: '.digi-workunit, .digi-group',
+ drop: function( e, ui ) {
+ var droppedEl = ui.draggable.parents( 'tr' );
- if ( data && data.element ) {
- var request_data = {};
- request_data.action = 'prevention_display_maitre_oeuvre';
- request_data.user_id = element.closest( '.information-maitre-oeuvre' ).find( 'input[name="user_id"]' ).val();
- request_data.prevention_id = element.closest( '.prevention-plan-wrap' ).find( 'input[name="prevention_id"]' ).val();
+ if ( droppedEl.data( 'ttId' ) == jQuery( this ).data( 'ttParentId' ) ) {
+ e.preventDefault();
+ return false;
+ } else {
+ window.addEventListener( 'beforeunload', window.eoxiaJS.digirisk.pageSorter.safeExit );
- window.eoxiaJS.loader.display( jQuery( this ) );
+ jQuery( 'input[type="submit"]' ).attr( 'disabled', false );
- window.eoxiaJS.request.send( jQuery( this ), request_data, function( triggeredElement, response ) {
- triggeredElement.closest( '.prevention-plan-wrap' ).replaceWith( response.data.view );
- window.eoxiaJS.digirisk.preventionPlan.checkIfPreventionPlanCanBeFinishMaitreOeuvre( jQuery( '.prevention-plan-wrap' ) );
- } );
+ jQuery( 'input[name="menu_item_parent_id[' + droppedEl.data( 'ttId' ) + ']"]' ).val( jQuery( this ).data( 'ttId' ) );
+ jQuery( '.treetable' ).treetable( 'move', droppedEl.data( 'ttId' ), jQuery( this ).data( 'ttId' ) );
+ }
+ },
+ hoverClass: 'accept',
+ over: function( e, ui ) {
+ var droppedEl = ui.draggable.parents( 'tr' );
+ if ( this != droppedEl[0] && ! jQuery( this ).is( '.expanded' ) ) {
+ jQuery( '.treetable' ).treetable( 'expandNode', jQuery( this ).data( 'ttId' ) );
+ }
+ }
+ });
+ });
}
};
-window.eoxiaJS.digirisk.preventionPlan.updatedMaitreOeuvreSignature = function( triggeredElement, response ) {
- var element = jQuery( this );
- window.eoxiaJS.digirisk.preventionPlan.checkIfPreventionPlanCanBeFinishMaitreOeuvre( jQuery( '.prevention-plan-wrap' ) );
-};
+/**
+ * Vérification avant la fermeture de la page si toutes les données sont enregistrées.
+ *
+ * @since 6.3.0
+ * @version 6.4.0
+ *
+ * @param {WindowEventHandlers} event L'évènement de la fenêtre.
+ * @return {string}
+ */
+window.eoxiaJS.digirisk.pageSorter.safeExit = function( event ) {
+ var confirmationMessage = 'Vos données sont en attentes d\'enregistrement';
-window.eoxiaJS.digirisk.preventionPlan.updatedIntervenantExterieurSignature = function( triggeredElement, response ) {
- window.eoxiaJS.digirisk.preventionPlan.checkIfPreventionPlanCanBeFinishIntervenantExterieur( jQuery( '.prevention-plan-wrap' ) );
+ event.returnValue = confirmationMessage;
+ return confirmationMessage;
};
+
+/**
+ * Initialise l'objet "permisFeu" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ *
+ * @since 6.6.0
+ */
+window.eoxiaJS.digirisk.permisFeu = {};
-window.eoxiaJS.digirisk.preventionPlan.nextStep = function( element, response ) {
- if( response.data.url ) {
- window.location = response.data.url;
- } else {
-
- jQuery( '.prevention-plan-wrap' ).replaceWith( response.data.view );
-
- var currentStep = response.data.current_step;
- var percent = 0;
-
- if ( 2 === currentStep ) {
- percent = 50;
- } else if ( 3 === currentStep ) {
- percent = 100;
- }else if( 4 === currentStep ) {
- percent = 100;
- }else{
- percent = 0;
- }
-
- if ( jQuery( '.main-content' ).hasClass( 'step-1' ) ) {
- jQuery( '.main-content' ).removeClass( 'step-1' ).addClass( 'step-2' );
- } else if ( jQuery( '.main-content' ).hasClass( 'step-2' ) ) {
- jQuery( '.main-content' ).removeClass( 'step-2' ).addClass( 'step-3' );
- }else if ( jQuery( '.main-content' ).hasClass( 'step-3' ) ) {
- jQuery( '.main-content' ).removeClass( 'step-3' ).addClass( 'step-4' );
- }
-
- jQuery( '.prevention-wrap .bar .loader' ).css( 'width', percent + '%' );
- jQuery( '.prevention-wrap .bar .loader' ).attr( 'data-width', percent );
- jQuery( '.prevention-wrap .step-list .step[data-width="' + percent + '"]' ).addClass( 'active' );
- }
+/**
+ * Gestion des signatures.
+ *
+ * @type {HTMLCanvasElement}
+ */
+window.eoxiaJS.digirisk.permisFeu.canvas;
- // window.eoxiaJS.refresh();
+/**
+ * Initialise les évènements.
+ *
+ * @since 6.6.0
+ *
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.permisFeu.init = function() {
+ window.eoxiaJS.digirisk.permisFeu.event();
+ window.eoxiaJS.digirisk.permisFeu.refresh();
};
-window.eoxiaJS.digirisk.preventionPlan.preventionLoadTabSuccess = function( element, response ){
- element.closest( '.main-content' ).html( response.data.view );
+/**
+ * Initialise le canvas, ainsi que owlCarousel.
+ *
+ * @since 6.6.0
+ *
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.permisFeu.refresh = function() {
+ jQuery( '.permis-feu-wrap .owl-carousel' ).owlCarousel( {
+ 'nav': 1,
+ 'loop': 1,
+ 'items': 1,
+ 'dots' : false,
+ 'navText' : [' ',' '],
+ } );
}
/**
- * Ajoutes la nouvelle ligne du participant dans le tableau.
+ * Initialise les évènements principaux des permisFeu.
*
* @since 6.6.0
*
- * @param {HTMLDivElement} element Le bouton déclencahd l'action AJAX.
- * @param {Object} response Les données reçu dans le formulaire.
- *
* @return {void}
*/
-window.eoxiaJS.digirisk.preventionPlan.savedParticipant = function( element, response ) {
- jQuery( '.ajax-content' ).html( response.data.view );
+window.eoxiaJS.digirisk.permisFeu.event = function() {
+ jQuery( document ).on( 'change', '.digi-permis-feu-parent .information-maitre-oeuvre .wpeo-autocomplete', window.eoxiaJS.digirisk.permisFeu.setMaitreOeuvre );
+ jQuery( document ).on( 'change', '.digi-permis-feu-parent .information-intervenant-exterieur .wpeo-autocomplete', window.eoxiaJS.digirisk.permisFeu.setIntervenant );
- window.eoxiaJS.digirisk.causerie.checkParticipantsSignature();
+ // Add Signature check field.
+ jQuery( document ).on( 'saved-signature-success', '.digi-permis-feu-parent .information-maitre-oeuvre .button-signature', window.eoxiaJS.digirisk.permisFeu.updatedMaitreOeuvreSignature );
+ jQuery( document ).on( 'saved-signature-success', '.digi-permis-feu-parent .information-intervenant-exterieur .button-signature', window.eoxiaJS.digirisk.permisFeu.updatedIntervenantSignature );
- // window.eoxiaJS.refresh();
-};
+ jQuery( document ).on( 'click', '.digi-permis-feu-parent .select-prevention .autocomplete-result', window.eoxiaJS.digirisk.permisFeu.addPreventionToPermisDeFeu );
-window.eoxiaJS.digirisk.preventionPlan.displayButtonUniteDeTravail = function( event ){
- window.eoxiaJS.digirisk.preventionPlan.checkIfInterventionCanBeAdd( '', jQuery( this ) );
-}
+ jQuery( document ).on( 'click', '.digi-permis-feu-parent .action-permis-feu-prevention .delete-prevention-from-permis-feu', window.eoxiaJS.digirisk.permisFeu.deletePreventionFromPermisFeu );
-window.eoxiaJS.digirisk.preventionPlan.displayButtonUniteDeTravailSuccess = function( trigerredElement, response ){
- trigerredElement.closest( '.unite-de-travail-class' ).find( '.button-unite-de-travail' ).html( response.data.view );
- var error = window.eoxiaJS.digirisk.preventionPlan.checkIfInterventionCanBeAdd( '', trigerredElement );
- if( ! error ){
- var parent_element = trigerredElement.closest( '.unite-de-travail-class' );
- parent_element.find( '.button-add-row-intervention' ).removeClass( 'button-disable' ).addClass( 'button-blue' );
- }
-}
+ jQuery( document ).on( 'click', '.digi-permis-feu-parent .end-date-element .button-permis-feu-title', window.eoxiaJS.digirisk.permisFeu.updateEndDatePrevention );
-window.eoxiaJS.digirisk.preventionPlan.displayModalUniteDeTravail = function( event ){
- jQuery( this ).closest( '.button-unite-de-travail' ).find( '.digirisk-modal-unite' ).addClass( 'modal-active' );
-}
+ jQuery( document ).on( 'click', '.digi-permis-feu-parent .unite-de-travail-element .autocomplete-search-list .autocomplete-result', window.eoxiaJS.digirisk.permisFeu.displayButtonUniteDeTravail );
-/*window.eoxiaJS.digirisk.preventionPlan.displayButtonSaveInformation = function( event ){
- jQuery( this ).closest( '.information-society' ).find( '.button-save-information-society' ).show( 'slow' );
-}*/
+ jQuery( document ).on( 'click', '.digi-permis-feu-parent .readonly .display-modal-unite', window.eoxiaJS.digirisk.permisFeu.displayModalUniteDeTravail );
-window.eoxiaJS.digirisk.preventionPlan.saveUserToSociety = function( trigerredElement, response ){
- trigerredElement.closest( '.wpeo-table' ).replaceWith( response.data.view );
-}
+ jQuery( document ).on( 'click', '.digi-permis-feu-parent .unite-de-travail-class .worktype-element .dropdown-content .item', window.eoxiaJS.digirisk.permisFeu.selectRisqueInDropdown );
-window.eoxiaJS.digirisk.preventionPlan.preShotEmailUser = function( event ){
- var parent_element = jQuery( this ).closest( '.table-row' );
- if (! parent_element.length) {
- parent_element = jQuery( this ).closest( '.wpeo-gridlayout' );
- }
+ jQuery( document ).on( 'keyup', '.digi-permis-feu-parent .unite-de-travail-class.edit input[type="text"]', window.eoxiaJS.digirisk.permisFeu.checkIfInterventionCanBeAdd );
- var name = parent_element.find( 'input[name="name"]' ).length ? parent_element.find( 'input[name="name"]' ).val() : parent_element.find( 'input[name="intervenant-name"]' ).val();
- var lastname = parent_element.find( 'input[name="lastname"]' ).length ? parent_element.find( 'input[name="lastname"]' ).val() : parent_element.find( 'input[name="intervenant-lastname"]' ).val();
- var email = lastname.trim() + '.' + name.trim() + '@demo.com';
+ // jQuery( document ).on( 'keyup', '.digi-permis-feu-parent .information-maitre-oeuvre input[type="text"]', window.eoxiaJS.digirisk.permisFeu.permisFeuCanBeFinishMaitreOeuvre );
- if ( parent_element.find( '[name="mail"]' ).length ) {
- parent_element.find( '[name="mail"]' ).val( email );
- } else if ( parent_element.find( '[name="intervenant-email"]' ).length ) {
- parent_element.find( '[name="intervenant-email"]' ).val( email );
+ jQuery( document ).on( 'keyup', '.digi-permis-feu-parent .information-intervenant-exterieur input[type="text"]', window.eoxiaJS.digirisk.permisFeu.permisFeuCanBeFinishIntervenantExterieur );
- }
-}
+ jQuery( document ).on( 'keyup', '.digi-permis-feu-parent .table-row .update-mail-auto input', window.eoxiaJS.digirisk.preventionPlan.preShotEmailUser );
-window.eoxiaJS.digirisk.preventionPlan.selectRisqueInDropdown = function( event ){
- var parent_element = jQuery( this ).closest( '.form-element' );
- var info_element = parent_element.find( '.category-danger .dropdown-toggle' );
- info_element.css( 'padding', '0' );
- info_element.find( 'span' ).hide();
- info_element.find( '.button-icon' ).hide();
+ jQuery( document ).on( 'click', '.wrap-permis-feu .closed-permis-feu .action .delete-this-permis-feu-plan', window.eoxiaJS.digirisk.permisFeu.deleteThisPreventionPlan );
- parent_element.find( '[name="risk_category_id"]' ).val( jQuery( this ).attr( 'data-id' ) );
- var img_src = jQuery( this ).find( 'img' ).attr( 'src' );
- info_element.find( 'img' ).attr( 'src', img_src );
- info_element.find( 'img' ).removeClass( 'hidden' ).removeClass( 'wpeo-tooltip-event' ).addClass( 'wpeo-tooltip-event' );
+ jQuery( document ).on( 'click', '.display-line-intervenant', window.eoxiaJS.digirisk.permisFeu.displayFirstLineIntervenant );
- info_element.find( 'img' ).attr( 'aria-label', jQuery( this ).attr( 'aria-label' ) );
- var error = window.eoxiaJS.digirisk.preventionPlan.checkIfInterventionCanBeAdd( '', jQuery( this ) );
- if( ! error ){
- var parent_element = jQuery( this ).closest( '.unite-de-travail-class' );
- parent_element.find( '.button-add-row-intervention' ).removeClass( 'button-disable' ).addClass( 'button-blue' );
- }
-}
+ jQuery( document ).on( 'click', '.display-line-intervention', window.eoxiaJS.digirisk.permisFeu.displayFirstLineIntervention)
+};
+window.eoxiaJS.digirisk.permisFeu.setMaitreOeuvre = function( event, data ){
+ var element = jQuery( this );
-window.eoxiaJS.digirisk.preventionPlan.checkIfInterventionCanBeAdd = function( event, element ){
- if ( ! element ) {
- element = "";
- }
+ if ( data && data.element ) {
+ var request_data = {};
+ request_data.action = 'permis_feu_display_maitre_oeuvre';
+ request_data.user_id = element.closest( '.information-maitre-oeuvre' ).find( 'input[name="user_id"]' ).val();
+ request_data.permis_feu_id = element.closest( '.digi-permis-feu-parent' ).find( 'input[name="permis_feu_id"]' ).val();
- if( element == "" ){
- element = jQuery( this );
+ window.eoxiaJS.loader.display( jQuery( this ) );
+ window.eoxiaJS.request.send( jQuery( this ), request_data, function( triggeredElement, response ) {
+ triggeredElement.closest( '.information-maitre-oeuvre' ).replaceWith( response.data.view );
+ window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishMaitreOeuvre( jQuery( '.information-maitre-oeuvre' ) );
+ } );
}
+}
- var parent_element = element.closest( '.unite-de-travail-class' );
- var error = false;
+window.eoxiaJS.digirisk.permisFeu.setIntervenant = function( event, data ){
+ var element = jQuery( this );
- error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( parent_element, 'unitedetravail', error );
- error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( parent_element, 'description-des-actions', error );
- error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( parent_element, 'moyen-de-prevention', error );
- error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( parent_element, 'risk_category_id', error );
+ if ( data && data.element ) {
+ var request_data = {};
+ request_data.action = 'permis_feu_display_intervenant';
+ request_data.user_id = element.closest( '.digi-permis-feu-parent' ).find( 'input[name="user_id"]' ).val();
+ request_data.permis_feu_id = element.closest( '.digi-permis-feu-parent' ).find( 'input[name="permis_feu_id"]' ).val();
- if( ! error ){
- parent_element.find( '.button-add-row-intervention' ).removeClass( 'button-disable' ).addClass( 'button-blue' );
- }else{
- parent_element.find( '.button-add-row-intervention' ).removeClass( 'button-blue' ).addClass( 'button-disable' );
+ window.eoxiaJS.loader.display( jQuery( this ) );
+ window.eoxiaJS.request.send( jQuery( this ), request_data, function( triggeredElement, response ) {
+ triggeredElement.closest( '.information-intervenant-exterieur' ).replaceWith( response.data.view );
+ window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishIntervenantExterieur( jQuery( '.information-intervenant-exterieur' ) );
+ } );
}
+}
+window.eoxiaJS.digirisk.permisFeu.updatedMaitreOeuvreSignature = function( triggeredElement, response ) {
+ var element = jQuery( this );
+ window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishMaitreOeuvre( element );
+};
- return error;
-}
+window.eoxiaJS.digirisk.permisFeu.updatedIntervenantSignature = function( triggeredElement, response ) {
+ var element = jQuery( this );
+ window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishIntervenantExterieur( jQuery( '.permis-feu-wrap' ) );
+};
-window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid = function( parent_element, element, error ){
- if ( error ) {
- return true;
- }
+window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishMaitreOeuvre = function( element ){
+ var parent_element = element.closest( '.digi-permis-feu-parent' );
+ var maitre_oeuvre_element = parent_element.find( '.information-maitre-oeuvre' );
- var content = parent_element.find( '[name="' + element + '"]' ).val();
+ var error = false;
+ error = window.eoxiaJS.digirisk.permisFeu.checkIfThisChampsIsValid( maitre_oeuvre_element, 'user_id', error );
+ error = window.eoxiaJS.digirisk.permisFeu.checkIfThisChampsIsValid( maitre_oeuvre_element, 'user_signature', error );
- if( content == "" || content == "-1" || content == null || content == 0 ){
- return true;
+ if ( ! error ) {
+ parent_element.find( '.permis-feu-start' ).removeClass( 'button-disable' );
} else {
- return false;
+ parent_element.find( '.permis-feu-start' ).addClass( 'button-disable' );
}
}
-window.eoxiaJS.digirisk.preventionPlan.addInterventionLine = function( event ){
- var parent_element = jQuery( this ).closest( '.unite-de-travail-class' );
- var data = {};
- data.unite = parent_element.find( '[name="unitedetravail"]').val();
- data.descriptionaction = parent_element.find( '[name="description-des-actions"]').val();
- data.prevention = parent_element.find( '[name="moyen-de-prevention"]').val();
- data.riskid = parent_element.find( '[name="risk_category_id"]').val();
- data.parentid = jQuery( this ).attr( 'data-parentid' );
- data.id = jQuery( this ).attr( 'data-id' );
- data.action = jQuery( this ).attr( 'data-action' );
- data._wpnonce = jQuery( this ).attr( 'data-nonce' );
+window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishIntervenantExterieur = function( element ){
+ var parent_element = jQuery( '.permis-feu-wrap' );
- window.eoxiaJS.loader.display( parent_element );
- window.eoxiaJS.request.send( jQuery( this ), data );
-}
+ var error = false;
-window.eoxiaJS.digirisk.preventionPlan.addInterventionLineSuccess = function( triggeredElement, response ){
- triggeredElement.closest( '.intervention-content' ).html( response.data.table_view );
-}
+ error = window.eoxiaJS.digirisk.permisFeu.checkIfThisChampsIsValid( parent_element, 'user_id', error );
+ error = window.eoxiaJS.digirisk.permisFeu.checkIfThisChampsIsValid( parent_element, 'user_signature', error );
-window.eoxiaJS.digirisk.preventionPlan.editInterventionLineSuccess = function( triggeredElement, response ){
- triggeredElement.closest( '.intervention-row' ).replaceWith( response.data.view );
+ if( ! error ){
+ parent_element.find( '.permis-feu-start' ).removeClass( 'button-disable' );
+ }else{
+ parent_element.find( '.permis-feu-start' ).addClass( 'button-disable' );
+ }
}
-window.eoxiaJS.digirisk.preventionPlan.addIntervenantToPrevention = function( triggeredElement, response ){
- triggeredElement.closest( '.wpeo-table' ).replaceWith( response.data.view );
-}
+window.eoxiaJS.digirisk.permisFeu.displaySignatureLastPage = function( triggeredElement, response ){
+ var class_parent = '.' + response.data.class_parent;
+ var element_parent = triggeredElement.closest( '.digi-permis-feu-parent' );
-window.eoxiaJS.digirisk.preventionPlan.editIntervenantPrevention = function( triggeredElement, response ){
- triggeredElement.closest( '.table-row' ).replaceWith( response.data.view );
-}
+ var element = jQuery( '.digi-permis-feu-parent' ).find( class_parent );
+ var a = element.find( '.signature-info-element .signature' );
+ a.html( response.data.view );
-window.eoxiaJS.digirisk.preventionPlan.preventionPlanCanBeFinishMaitreOeuvre = function( event ){
- window.eoxiaJS.digirisk.preventionPlan.checkIfPreventionPlanCanBeFinishMaitreOeuvre( jQuery( this ) );
+ if( response.data.class_parent == "information-maitre-oeuvre" ){
+ window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishMaitreOeuvre( element_parent );
+ }else{
+ window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishIntervenantExterieur( element_parent );
+ }
}
-window.eoxiaJS.digirisk.preventionPlan.PreventionPlanCanBeFinishIntervenantExterieur = function( event ){
- window.eoxiaJS.digirisk.preventionPlan.checkIfPreventionPlanCanBeFinishIntervenantExterieur( jQuery( this ) );
-}
+window.eoxiaJS.digirisk.permisFeu.nextStep = function( element, response ) {
+ if( response.data.url ){
+ window.location.replace( response.data.url );
+ } else {
-window.eoxiaJS.digirisk.preventionPlan.checkIfPreventionPlanCanBeFinishMaitreOeuvre = function( element ){
- var parent_element = element;
- var maitre_oeuvre_element = element.find( '.information-maitre-oeuvre' );
+ jQuery('.permis-feu-wrap').replaceWith(response.data.view);
- var error = false;
- error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( maitre_oeuvre_element, 'user_id', error );
- error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( maitre_oeuvre_element, 'user_signature', error );
+ var currentStep = response.data.current_step;
+ var percent = 0;
- if( ! error ) {
- parent_element.find( '.prevention-start' ).removeClass( 'button-disable' );
- } else {
- parent_element.find( '.prevention-start' ).addClass( 'button-disable' );
- }
-}
+ if (2 === currentStep) {
+ percent = 37;
+ } else if (3 === currentStep) {
+ percent = 62;
+ } else if (4 === currentStep) {
+ percent = 100;
+ } else {
+ percent = 0;
+ }
-window.eoxiaJS.digirisk.preventionPlan.checkIfPreventionPlanCanBeFinishIntervenantExterieur = function( element ){
- var parent_element = jQuery( '.digi-prevention-plan-parent' );
+ if (jQuery('.main-content').hasClass('step-1')) {
+ jQuery('.main-content').removeClass('step-1').addClass('step-2');
+ } else if (jQuery('.main-content').hasClass('step-2')) {
+ jQuery('.main-content').removeClass('step-2').addClass('step-3');
+ } else if (jQuery('.main-content').hasClass('step-3')) {
+ jQuery('.main-content').removeClass('step-3').addClass('step-4');
+ }
- var intervenant_exterieur_element = parent_element.find( '.information-intervenant-exterieur' );
- var error = false;
+ jQuery('.permis-feu-wrap .bar .loader').css('width', percent + '%');
+ jQuery('.permis-feu-wrap .bar .loader').attr('data-width', percent);
+ jQuery('.permis-feu-wrap .step-list .step[data-width="' + percent + '"]').addClass('active');
+ }
- error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( intervenant_exterieur_element, 'intervenant-name', error );
- error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( intervenant_exterieur_element, 'intervenant-lastname', error );
- error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( intervenant_exterieur_element, 'intervenant-phone', error );
- error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( intervenant_exterieur_element, 'intervenant-email', error );
- error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( intervenant_exterieur_element, 'user_signature', error );
+ // window.eoxiaJS.refresh();
+};
- if ( ! error ) {
- parent_element.find( '.prevention-start' ).removeClass( 'button-disable' );
- } else {
- parent_element.find( '.prevention-start' ).addClass( 'button-disable' );
- }
-}
-window.eoxiaJS.digirisk.preventionPlan.generateDocumentPreventionSuccess = function( triggeredElement, response ){
- if( response.data.link != "" ){
- var element = document.createElement('a');
- element.setAttribute('href', response.data.link );
- element.setAttribute('download', response.data.filename);
+window.eoxiaJS.digirisk.permisFeu.addPreventionToPermisDeFeu = function( event, data ){
+ var element = jQuery( this );
+ var parent_element = jQuery( this ).closest( '.select-prevention' );
- element.style.display = 'none';
- document.body.appendChild(element);
+ var request_data = {};
+ request_data.action = parent_element.attr( 'data-action' );
+ request_data._wpnonce = parent_element.attr( 'data-nonce' );
+ request_data.prevention_id = parent_element.find( 'input[name="prevention_id"]' ).val();
+ request_data.permis_feu_id = parent_element.find( 'input[name="permis_feu_id"]' ).val();
- element.click();
- document.body.removeChild(element);
- }
+ window.eoxiaJS.loader.display( parent_element );
+ window.eoxiaJS.request.send( parent_element, request_data );
}
-window.eoxiaJS.digirisk.preventionPlan.displayUserInfo = function( event ){
- var element = jQuery( this ).closest( '.avatar-info-prevention' ).find( '.info-text' );
-
- if( jQuery( element ).css( 'display' ) == "none" ){
- element.show();
- }else{
- element.hide();
+window.eoxiaJS.digirisk.permisFeu.addPreventionToPermisFeuSuccess = function( triggeredElement, response ){
+ if( response.data.view != "" ){
+ // triggeredElement.closest( '.digi-permis-feu-parent' ).find( '.next-step-need-prevention' ).removeClass( 'button-disable' );
+ triggeredElement.closest( '.digi-permis-feu-parent' ).find( '.intervention-prevention-plan' ).html( response.data.pre_i_view );
+ triggeredElement.closest( '.wpeo-gridlayout' ).html( response.data.view );
}
-
}
-window.eoxiaJS.digirisk.preventionPlan.deleteThisPreventionPlan = function( event ){
- var message = jQuery( this ).attr( 'data-message' );
- if( confirm( message ) ){
- var data = {};
+window.eoxiaJS.digirisk.permisFeu.deletePreventionFromPermisFeu = function( event ){
- data.action = jQuery( this ).attr( 'data-action' );
- data._wpnonce = jQuery( this ).attr( 'data-nonce' );
- data.id = jQuery( this ).attr( 'data-id' );
+ var request_data = {};
+ request_data.action = jQuery( this ).attr( 'data-action' );
+ request_data._wpnonce = jQuery( this ).attr( 'data-nonce' );
+ request_data.id = jQuery( this ).attr( 'data-id' );
- window.eoxiaJS.loader.display( jQuery( this ).closest( '.item' ) );
- window.eoxiaJS.request.send( jQuery( this ), data );
+ if( confirm( jQuery( this ).attr( 'data-message' ) ) ){
+ window.eoxiaJS.loader.display( jQuery( this ) );
+ window.eoxiaJS.request.send( jQuery( this ), request_data );
}
}
-window.eoxiaJS.digirisk.preventionPlan.deleteDocumentPreventionSuccess = function( trigerredElement, response ){
- trigerredElement.closest( '.main-content' ).html( response.data.dashboard_view );
+window.eoxiaJS.digirisk.permisFeu.deletePreventionFromPermisFeuSuccess = function( triggeredElement, response ){
+ if( response.data.view != "" ){
+ triggeredElement.closest( '.digi-permis-feu-parent' ).find( '.intervention-prevention-plan' ).html( '' );
+ triggeredElement.closest( '.wpeo-gridlayout' ).html( response.data.view );
+ }
}
-window.eoxiaJS.digirisk.preventionPlan.updateEndDatePrevention = function( event ){
+window.eoxiaJS.digirisk.permisFeu.updateEndDatePrevention = function( event ){
jQuery( this ).closest( '.end-date-element' ).find( '.wpeo-button' ).removeClass( 'button-blue' ).addClass( 'button-grey' );
jQuery( this ).removeClass( 'button-grey' ).addClass( 'button-blue' );
jQuery( this ).closest( '.end-date-element' ).find( 'input[name="date_end__is_define"]' ).val( jQuery( this ).attr( 'data-action' ) );
@@ -3114,1057 +3268,1186 @@ window.eoxiaJS.digirisk.preventionPlan.updateEndDatePrevention = function( event
}
}
-window.eoxiaJS.digirisk.preventionPlan.updateStartDatePrevention = function( event ){
- const date = event.target.value.split('/')
- const maximalDate = new Date(date[2], date[1]-1, date[0])
- maximalDate.setFullYear(maximalDate.getFullYear() + 1)
+window.eoxiaJS.digirisk.permisFeu.displayButtonUniteDeTravail = function( event ){
+ window.eoxiaJS.digirisk.permisFeu.checkIfInterventionCanBeAdd( '', jQuery( this ) );
+}
- const formatMaxDate = (date) => `${date.getFullYear()}/${date.getMonth()+1}/${date.getDate()}`
- const formatValue = (date) => new Intl.DateTimeFormat('fr-FR').format(date)
- const formatValueSql = (date) => `${maximalDate.getFullYear()}-${maximalDate.getMonth()+1}-${maximalDate.getDate()}`
- const endDateElementLimit = jQuery(document).find('.maximal-date-prevention')
- endDateElementLimit.attr('max-date', formatMaxDate(maximalDate))
- endDateElementLimit.attr('value', formatValue(maximalDate))
+window.eoxiaJS.digirisk.permisFeu.displayButtonUniteDeTravailSuccess = function( trigerredElement, response ){
+ trigerredElement.closest( '.unite-de-travail-class' ).find( '.button-unite-de-travail' ).html( response.data.view );
+ var error = window.eoxiaJS.digirisk.permisFeu.checkIfInterventionCanBeAdd( '', trigerredElement );
+ if( ! error ){
+ var parent_element = trigerredElement.closest( '.unite-de-travail-class' );
+ parent_element.find( '.button-add-row-intervention' ).removeClass( 'button-disable' ).addClass( 'button-blue' );
+ }
+}
- const endDateElementLimitSql = jQuery(document).find('.maximal-date-prevention-sql')
- endDateElementLimitSql.attr('value', formatValueSql(maximalDate))
+window.eoxiaJS.digirisk.permisFeu.displayModalUniteDeTravail = function( event ) {
+ jQuery( this ).closest( '.button-unite-de-travail' ).find( '.digirisk-modal-unite' ).addClass( 'modal-active' );
}
-window.eoxiaJS.digirisk.preventionPlan.updateTitleOption = function( event ){
- // jQuery( this ).closest( '.title-information-option' ).find( '.wpeo-button' ).removeClass( 'button-blue' ).addClass( 'button-grey' );3
- var type = jQuery( this ).attr( 'data-type' );
- if( jQuery( this ).closest( '.title-information-option' ).find( 'input[name="' + type + '"]' ).val() == "1" ){
- jQuery( this ).closest( '.title-information-option' ).find( 'input[name="' + type + '"]' ).val( '0' );
- jQuery( this ).removeClass( 'button-blue' ).addClass( 'button-grey' );
- jQuery( this ).find( '.button-icon' ).removeClass( 'fa-check-square' ).addClass( 'fa-square' );
- }else{
- jQuery( this ).closest( '.title-information-option' ).find( 'input[name="' + type + '"]' ).val( '1' );
- jQuery( this ).removeClass( 'button-grey' ).addClass( 'button-blue' );
- jQuery( this ).find( 'input[name="' + type + '"]' ).val( '1' );
- jQuery( this ).find( '.button-icon' ).removeClass( 'fa-square' ).addClass( 'fa-check-square' );
+window.eoxiaJS.digirisk.permisFeu.selectRisqueInDropdown = function( event ){
+ var parent_element = jQuery( this ).closest( '.form-element' );
+ var info_element = parent_element.find( '.category-worktype .dropdown-toggle' );
+ info_element.css( 'padding', '0' );
+ info_element.find( 'span' ).hide();
+ info_element.find( '.button-icon' ).hide();
+
+ parent_element.find( '[name="worktype_category_id"]' ).val( jQuery( this ).attr( 'data-id' ) );
+ var img_src = jQuery( this ).find( 'img' ).attr( 'src' );
+ info_element.find( 'img' ).attr( 'src', img_src );
+ info_element.find( 'img' ).removeClass( 'hidden' ).removeClass( 'wpeo-tooltip-event' ).addClass( 'wpeo-tooltip-event' );
+
+ info_element.find( 'img' ).attr( 'aria-label', jQuery( this ).attr( 'aria-label' ) );
+ var error = window.eoxiaJS.digirisk.permisFeu.checkIfInterventionCanBeAdd( '', jQuery( this ) );
+ if( ! error ){
+ var parent_element = jQuery( this ).closest( '.unite-de-travail-class' );
+ parent_element.find( '.button-add-row-intervention' ).removeClass( 'button-disable' ).addClass( 'button-blue' );
}
}
-window.eoxiaJS.digirisk.preventionPlan.editThisPreventionSuccess = function( trigerredElement, response ){
- if( response.data.url ){
- window.location.replace( response.data.url );
+
+window.eoxiaJS.digirisk.permisFeu.checkIfInterventionCanBeAdd = function( event, element ){
+ if( ! element ){
+ element = jQuery( this );
}
-}
-window.eoxiaJS.digirisk.preventionPlan.regexPhoneNumber = function(event) {
+ var parent_element = element.closest( '.unite-de-travail-class' );
+ var error = false;
- if(/^((\+)33|0)[1-9](\d{2}){4}$/.test(event.target.value) == false) {
- jQuery(document).find('.form-element.element-phone').addClass("form-element-error")
- jQuery(document).find('.wpeo-button.prevention-start').addClass("button-disable")
+ error = window.eoxiaJS.digirisk.permisFeu.checkIfThisChampsIsValid( parent_element, 'unitedetravail', error );
+ error = window.eoxiaJS.digirisk.permisFeu.checkIfThisChampsIsValid( parent_element, 'description-des-actions', error );
+ error = window.eoxiaJS.digirisk.permisFeu.checkIfThisChampsIsValid( parent_element, 'materiel-utilise', error );
+ error = window.eoxiaJS.digirisk.permisFeu.checkIfThisChampsIsValid( parent_element, 'worktype_category_id', error );
+
+ if( ! error ){
+ parent_element.find( '.button-add-row-intervention' ).removeClass( 'button-disable' ).addClass( 'button-blue' );
+ }else{
+ parent_element.find( '.button-add-row-intervention' ).removeClass( 'button-blue' ).addClass( 'button-disable' );
}
- else if (jQuery(document).find('.form-element.element-phone').hasClass("form-element-error")) {
- jQuery(document).find('.form-element.element-phone').removeClass("form-element-error")
- jQuery(document).find('.wpeo-button.prevention-start').removeClass("button-disable")
+
+ return error;
+}
+
+window.eoxiaJS.digirisk.permisFeu.checkIfThisChampsIsValid = function( parent_element, element, error ){
+ if( error ){
+ return true;
+ }
+
+ var content = parent_element.find( '[name="' + element + '"]').val();
+
+ if( content == "" || content == "-1" || content == null ){
+ return true;
+ }else{
+ return false;
}
}
-
-window.eoxiaJS.digirisk.recommendation = {};
-window.eoxiaJS.digirisk.recommendation.init = function() {
- window.eoxiaJS.digirisk.recommendation.event();
-};
+window.eoxiaJS.digirisk.permisFeu.addInterventionLinePermisFeuSuccess = function( triggeredElement, response ){
+ triggeredElement.closest( '.intervention-content' ).html( response.data.table_view );
+}
-window.eoxiaJS.digirisk.recommendation.event = function() {
- jQuery( document ).on( 'click', '.wpeo-table.table-recommendation .categorie-container .item', window.eoxiaJS.digirisk.recommendation.selectRecommendation );
-};
+window.eoxiaJS.digirisk.permisFeu.editInterventionLineSuccess = function( triggeredElement, response ){
+ triggeredElement.closest( '.intervention-row' ).replaceWith( response.data.view );
+}
-/**
- * Lors du clic sur une recommendation, remplace le contenu du toggle par l'image de la recommendation sélectionnée.
- *
- * @since 6.0.0
- * @version 7.0.0
- *
- * @param {ClickEvent} event [description]
- * @return {void}
- */
-window.eoxiaJS.digirisk.recommendation.selectRecommendation = function( event ) {
- var element = jQuery( this );
+window.eoxiaJS.digirisk.permisFeu.preventionLoadTabSuccess = function( element, response ){
+ element.closest( '.main-content' ).html( response.data.view );
+}
- element.closest( '.content' ).removeClass( 'active' );
- element.closest( '.table-row' ).find( 'input[name="recommendation_category_id"]' ).val( element.data( 'id' ) );
+window.eoxiaJS.digirisk.permisFeu.permisFeuCanBeFinishMaitreOeuvre = function( event ){
+ window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishMaitreOeuvre( jQuery( this ) );
+}
- element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle span' ).hide();
- element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).show();
- element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).attr( 'src', element.find( 'img' ).attr( 'src' ) );
- element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).attr( 'srcset', '' );
- element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).attr( 'sizes', '' );
- element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).attr( 'aria-label', element.closest( '.tooltip' ).attr( 'aria-label' ) );
+window.eoxiaJS.digirisk.permisFeu.permisFeuCanBeFinishIntervenantExterieur = function( event ){
+ window.eoxiaJS.digirisk.permisFeu.checkIfPermisFeuCanBeFinishIntervenantExterieur( jQuery( this ) );
+}
- element.closest( '.table-row' ).find( '.categorie-container.tooltip' ).removeClass( 'active' );
+window.eoxiaJS.digirisk.permisFeu.addIntervenantToPrevention = function( triggeredElement, response ){
+ triggeredElement.closest( '.wpeo-table' ).replaceWith( response.data.view );
+}
- // Rend le bouton "active".
- element.closest( '.table-row' ).find( '.action .wpeo-button.button-disable' ).removeClass( 'button-disable' );
-};
+window.eoxiaJS.digirisk.permisFeu.editIntervenantPrevention = function( triggeredElement, response ){
+ triggeredElement.closest( '.table-row' ).replaceWith( response.data.view );
+}
-/**
- * Vérifie que le champs "taxonomy[digi-recommendation][] soit différent de -1".
- *
- * @since 6.0.0
- * @version 7.0.0
- *
- * @param {HTMLDivElement} triggeredElement L'élément déclenchant l'action.
- * @return {bool} Si true, le formulaire est envoyé. Si false, on annule l'envoie du formulaire.
- */
-window.eoxiaJS.digirisk.recommendation.beforeSaveRecommendation = function( triggeredElement ) {
+window.eoxiaJS.digirisk.permisFeu.editThisPreventionSuccess = function( trigerredElement, response ){
+ if( response.data.url ){
+ window.location.replace( response.data.url );
+ }
+}
- // Remet à 0 les styles.
- triggeredElement.closest( '.recommendation-row' ).find( '.categorie-container' ).removeClass( 'active' );
+window.eoxiaJS.digirisk.permisFeu.deleteThisPreventionPlan = function( event ){
+ var message = jQuery( this ).attr( 'data-message' );
+ if( confirm( message ) ){
+ var data = {};
- // Vérification du danger.
- if ( '-1' === triggeredElement.closest( '.recommendation-row' ).find( 'input[name="recommendation_category_id"]' ).val() ) {
- triggeredElement.closest( '.recommendation-row' ).find( '.categorie-container' ).addClass( 'active' );
- return false;
+ data.action = jQuery( this ).attr( 'data-action' );
+ data._wpnonce = jQuery( this ).attr( 'data-nonce' );
+ data.id = jQuery( this ).attr( 'data-id' );
+
+ window.eoxiaJS.loader.display( jQuery( this ).closest( '.item' ) );
+ window.eoxiaJS.request.send( jQuery( this ), data );
}
+}
- return true;
-};
+window.eoxiaJS.digirisk.permisFeu.deleteDocumentPermisFeuSuccess = function( trigerredElement, response ){
+ trigerredElement.closest( '.main-content' ).html( response.data.dashboard_view );
+}
+
+window.eoxiaJS.digirisk.permisFeu.displayFirstLineIntervenant = function( event ){
+ jQuery( this ).closest( '.intervenant-bloc' ).find( '.table-new-line-intervenant' ).show( '200' );
+}
+window.eoxiaJS.digirisk.permisFeu.displayFirstLineIntervention = function( event ){
+ console.log( 'oui' );
+ jQuery( this ).closest( '.intervention-table' ).find( '.new-line-intervention' ).show( '200' );
+}
+
/**
- * Le callback en cas de réussite à la requête Ajax "save_recommendation".
- * Remplaces le contenu du tableau "recommendation" par le template renvoyé par la requête Ajax.
- *
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
+ * Initialise l'objet "preventionPlan" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
*
- * @since 1.0
- * @version 6.2.4.0
+ * @since 6.6.0
*/
-window.eoxiaJS.digirisk.recommendation.savedRecommendationSuccess = function( element, response ) {
- jQuery( '.wpeo-table.table-recommendation' ).replaceWith( response.data.template );
- window.eoxiaJS.digirisk.date.init();
-};
+window.eoxiaJS.digirisk.preventionPlan = {};
/**
- * Le callback en cas de réussite à la requête Ajax "load_recommendation".
- * Remplaces le contenu de la ligne du tableau "recommendation" par le template renvoyé par la requête Ajax.
- *
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
+ * Gestion des signatures.
*
- * @since 1.0
- * @version 6.2.4.0
+ * @type {HTMLCanvasElement}
*/
-window.eoxiaJS.digirisk.recommendation.loadedRecommendationSuccess = function( element, response ) {
- jQuery( element ).closest( '.table-row' ).replaceWith( response.data.template );
- window.eoxiaJS.digirisk.date.init();
-};
+window.eoxiaJS.digirisk.preventionPlan.canvas;
/**
- * Le callback en cas de réussite à la requête Ajax "delete_recommendation".
- * Supprimes la ligne du tableau affectée par l'action.
+ * Initialise les évènements.
*
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
+ * @since 6.6.0
*
- * @since 1.0
- * @version 6.2.4.0
+ * @return {void}
*/
-window.eoxiaJS.digirisk.recommendation.deletedRecommendationSuccess = function( element, response ) {
- jQuery( element ).closest( '.table-row' ).fadeOut();
+window.eoxiaJS.digirisk.preventionPlan.init = function() {
+ window.eoxiaJS.digirisk.preventionPlan.event();
+ // window.eoxiaJS.digirisk.preventionPlan.refresh();
};
-
+
/**
- * Initialise l'objet "riskCategory" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ * Initialise les évènements principaux des preventionPlans.
*
- * @since 6.0.0
- * @version 7.0.0
+ * @since 6.6.0
+ *
+ * @return {void}
*/
-window.eoxiaJS.digirisk.riskCategory = {};
+window.eoxiaJS.digirisk.preventionPlan.event = function() {
+ jQuery( document ).on( 'change', '.digi-prevention-plan-parent .information-maitre-oeuvre .wpeo-autocomplete', window.eoxiaJS.digirisk.preventionPlan.setMaitreOeuvre );
+ jQuery( document ).on( 'saved-signature-success', '.digi-prevention-plan-parent.step-1 .form-element', window.eoxiaJS.digirisk.preventionPlan.updatedMaitreOeuvreSignature );
+ jQuery( document ).on( 'saved-signature-success', '.digi-prevention-plan-parent.step-4 .form-element', window.eoxiaJS.digirisk.preventionPlan.updatedIntervenantExterieurSignature );
-window.eoxiaJS.digirisk.riskCategory.init = function() {
- window.eoxiaJS.digirisk.riskCategory.event();
-};
+ // Recherche GP/UT
+ jQuery( document ).on( 'click', '.digi-prevention-plan-parent .unite-de-travail-element .autocomplete-search-list .autocomplete-result', window.eoxiaJS.digirisk.preventionPlan.displayButtonUniteDeTravail );
-window.eoxiaJS.digirisk.riskCategory.event = function() {
- jQuery( document ).on( 'click', '.table .category-danger .item, .wpeo-table .category-danger .item', window.eoxiaJS.digirisk.riskCategory.selectDanger );
-};
+ jQuery( document ).on( 'click', '.digi-prevention-plan-parent .readonly .display-modal-unite', window.eoxiaJS.digirisk.preventionPlan.displayModalUniteDeTravail );
-/**
- * Lors du clic sur un riskCategory, remplaces le contenu du toggle et met l'image du risque sélectionné.
- *
- * @param {MouseEvent} event [description]
- * @return {void}
- *
- * @since 6.0.0
- * @version 7.0.0
- */
-window.eoxiaJS.digirisk.riskCategory.selectDanger = function( event ) {
- var element = jQuery( this );
- var data = {};
- element.closest( '.content' ).removeClass( 'active' );
- element.closest( 'tr, .table-row' ).find( 'input.input-hidden-danger' ).val( element.data( 'id' ) );
- element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle span' ).hide();
- element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).show();
- element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).attr( 'src', element.find( 'img' ).attr( 'src' ) );
- element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).attr( 'srcset', '' );
- element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).attr( 'sizes', '' );
- element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).attr( 'aria-label', element.closest( '.tooltip' ).attr( 'aria-label' ) );
+ /*jQuery( document ).on( 'keyup', '.digi-prevention-plan-parent .information-element-society input', window.eoxiaJS.digirisk.preventionPlan.displayButtonSaveInformation );*/
- window.eoxiaJS.tooltip.remove( element.closest( '.risk-row' ).find( '.category-danger.wpeo-tooltip-event' ) );
+ jQuery( document ).on( 'keyup', '.digi-prevention-plan-parent .update-mail-auto input', window.eoxiaJS.digirisk.preventionPlan.preShotEmailUser );
- // Rend le bouton "active".
- if ( '{}' !== element.closest( '.risk-row' ).find( 'textarea[name="evaluation_variables"]' ).val() ) {
- element.closest( 'tr' ).find( '.action .wpeo-button.button-disable' ).removeClass( 'button-disable' );
- }
+ jQuery( document ).on( 'click', '.digi-prevention-plan-parent .unite-de-travail-class .risque-element .dropdown-content .item', window.eoxiaJS.digirisk.preventionPlan.selectRisqueInDropdown );
- // Si aucune donnée est entrée, on lance la requête.
- if ( element.data( 'is-preset' ) && ! window.eoxiaJS.digirisk.riskCategory.haveDataInInput( element ) ) {
- data.action = 'check_predefined_danger';
- data._wpnonce = element.closest( '.wpeo-dropdown' ).data( 'nonce' );
- data.danger_id = element.data( 'id' );
- data.society_id = element.closest( '.risk-row' ).find( 'input[name="parent_id"] ' ).val();
+ jQuery( document ).on( 'keyup', '.digi-prevention-plan-parent .unite-de-travail-class [name="moyen-de-prevention"]', window.eoxiaJS.digirisk.preventionPlan.checkIfInterventionCanBeAdd );
- window.eoxiaJS.loader.display( jQuery( this ).closest( 'table, .wpeo-table' ) );
+ jQuery( document ).on( 'keyup', '.digi-prevention-plan-parent .unite-de-travail-class [name="description-des-actions"]', window.eoxiaJS.digirisk.preventionPlan.checkIfInterventionCanBeAdd );
- window.eoxiaJS.request.send( jQuery( this ).closest( '.wpeo-dropdown' ), data );
- }
-};
+ jQuery( document ).on( 'click', '.digi-prevention-plan-parent .unite-de-travail-class .button-add-row-intervention', window.eoxiaJS.digirisk.preventionPlan.addInterventionLine );
-window.eoxiaJS.digirisk.riskCategory.haveDataInInput = function( element ) {
- if ( '{}' != element.closest( '.risk-row' ).find( 'textarea[name="evaluation_variables"]' ).val() ) {
- return true;
- }
+ jQuery( document ).on( 'keyup', '.digi-prevention-plan-parent .information-maitre-oeuvre input[type="text"]', window.eoxiaJS.digirisk.preventionPlan.preventionPlanCanBeFinishMaitreOeuvre );
- if ( '' != element.closest( '.risk-row' ).find( 'textarea[name="list_comment[0][content]"]' ).val() ) {
- return true;
- }
+ jQuery( document ).on( 'keyup', '.digi-prevention-plan-parent .information-intervenant-exterieur input[type="text"]', window.eoxiaJS.digirisk.preventionPlan.PreventionPlanCanBeFinishIntervenantExterieur );
- return false;
-};
-
-"use strict";
+ jQuery( document ).on( 'click', '.wrap-prevention .closed-prevention .avatar-info-prevention .avatar', window.eoxiaJS.digirisk.preventionPlan.displayUserInfo );
-var digi_risk_comment = {
- $: undefined,
+ jQuery( document ).on( 'click', '.wrap-prevention .closed-prevention .action .delete-this-prevention-plan', window.eoxiaJS.digirisk.preventionPlan.deleteThisPreventionPlan );
- event: function( $ ) {
- digi_risk_comment.$ = $;
+ jQuery( document ).on( 'click', '.digi-prevention-plan-parent .end-date-element .action-button-end-date', window.eoxiaJS.digirisk.preventionPlan.updateEndDatePrevention );
- digi_risk_comment.$( document ).on( 'click', '.wp-digi-action-comment-delete', function( event ) { digi_risk_comment.delete_comment( event, digi_risk_comment.$( this ) ); } );
- },
+ jQuery( document ).on( 'change', '.start-date', window.eoxiaJS.digirisk.preventionPlan.updateStartDatePrevention );
- delete_comment: function( event, element ) {
- if( window.confirm( window.digi_confirm_delete ) ) {
- var data = {
- action: 'delete_comment',
- _wpnonce: digi_risk_comment.$( element ).data( 'nonce' ),
- risk_id: digi_risk_comment.$( element ).data( 'risk-id' ),
- id: digi_risk_comment.$( element ).data( 'id' ),
- };
- digi_risk_comment.$( element ).closest( 'li' ).remove();
- digi_risk_comment.$.post( window.ajaxurl, data, function() {} );
- }
- },
+ jQuery( document ).on('keyup', '.element-phone-input', window.eoxiaJS.digirisk.preventionPlan.regexPhoneNumber );
- reset_create_form: function() {
- digi_risk_comment.$( '.wp-digi-risk-item-new .wp-digi-risk-comment textarea' ).val('');
- }
+ jQuery( document ).on( 'click', '.digi-prevention-plan-parent .title-information-option .action-button-title', window.eoxiaJS.digirisk.preventionPlan.updateTitleOption );
};
-
-/**
- * Initialise l'objet "risk_page" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
- *
- * @since 6.2.3
- */
-
-window.eoxiaJS.digirisk.risk_page = {};
-window.eoxiaJS.digirisk.risk_page.init = function() {
- window.eoxiaJS.digirisk.risk_page.event();
-};
+window.eoxiaJS.digirisk.preventionPlan.setMaitreOeuvre = function( event, data ) {
+ var element = jQuery( this );
-window.eoxiaJS.digirisk.risk_page.refresh = function() {
- autosize(document.querySelectorAll('textarea'));
-};
+ if ( data && data.element ) {
+ var request_data = {};
+ request_data.action = 'prevention_display_maitre_oeuvre';
+ request_data.user_id = element.closest( '.information-maitre-oeuvre' ).find( 'input[name="user_id"]' ).val();
+ request_data.prevention_id = element.closest( '.prevention-plan-wrap' ).find( 'input[name="prevention_id"]' ).val();
-window.eoxiaJS.digirisk.risk_page.event = function() {
- jQuery( document ).on( 'click', '.risk-page .save-all:not(.grey)', window.eoxiaJS.digirisk.risk_page.saveRisks );
- jQuery( document ).on( 'click', '.risk-page table tr input:not(input[type="checkbox"]), .risk-page .table-row .group-date, .risk-page .table-row .wpeo-dropdown .dropdown-toggle, .risk-page .table-row textarea, .risk-page .table-row .popup, .risk-page .table-row .action, .risk-page .cotation', window.eoxiaJS.digirisk.risk_page.checkTheCheckbox );
- jQuery( document ).on( 'click', '.risk-page .wp-digi-pagination a', window.eoxiaJS.digirisk.risk_page.pagination );
-};
+ window.eoxiaJS.loader.display( jQuery( this ) );
-window.eoxiaJS.digirisk.risk_page.saveRisks = function( event ) {
- if ( event ) {
- event.preventDefault();
+ window.eoxiaJS.request.send( jQuery( this ), request_data, function( triggeredElement, response ) {
+ triggeredElement.closest( '.prevention-plan-wrap' ).replaceWith( response.data.view );
+ window.eoxiaJS.digirisk.preventionPlan.checkIfPreventionPlanCanBeFinishMaitreOeuvre( jQuery( '.prevention-plan-wrap' ) );
+ } );
}
-
- jQuery( '.risk-page .table-row .edit-risk.checked:first' ).click();
- jQuery( '.risk-page .save-all' ).addClass( 'button-disable' );
};
-/**
- * Coches la case à cocher lors de l'action dans une ligne du tableau.
- *
- * @param {ClickEvent} event L'état du clic.
- * @return {void}
- *
- * @since 6.2.3
- */
-window.eoxiaJS.digirisk.risk_page.checkTheCheckbox = function( event ) {
- jQuery( this ).closest( 'tr, .table-row' ).find( 'input[type="checkbox"]' ).prop( 'checked', true );
- jQuery( this ).closest( 'tr, .table-row' ).find( '.edit-risk' ).addClass( 'checked' );
- jQuery( '.risk-page .save-all' ).removeClass( 'button-disable' );
+window.eoxiaJS.digirisk.preventionPlan.updatedMaitreOeuvreSignature = function( triggeredElement, response ) {
+ var element = jQuery( this );
+ window.eoxiaJS.digirisk.preventionPlan.checkIfPreventionPlanCanBeFinishMaitreOeuvre( jQuery( '.prevention-plan-wrap' ) );
};
-window.eoxiaJS.digirisk.risk_page.savedRiskSuccess = function( Trigelement, response ) {
- Trigelement.closest( '.table-row' ).replaceWith( response.data.template );
- window.eoxiaJS.digirisk.risk_page.saveRisks();
+window.eoxiaJS.digirisk.preventionPlan.updatedIntervenantExterieurSignature = function( triggeredElement, response ) {
+ window.eoxiaJS.digirisk.preventionPlan.checkIfPreventionPlanCanBeFinishIntervenantExterieur( jQuery( '.prevention-plan-wrap' ) );
};
-/**
- * Gestion de la pagination des risques dans la page "Risques".
- *
- * @param {ClickEvent} event [description]
- * @return {void}
- *
- * @since 6.2.6
- */
-window.eoxiaJS.digirisk.risk_page.pagination = function( event ) {
- var href = jQuery( this ).attr( 'href' ).split( '&' );
- var nextPage = href[1].replace( 'current_page=', '' );
+window.eoxiaJS.digirisk.preventionPlan.nextStep = function( element, response ) {
+ if( response.data.url ) {
+ window.location = response.data.url;
+ } else {
- jQuery( '.risk-page' ).addClass( 'loading' );
+ jQuery( '.prevention-plan-wrap' ).replaceWith( response.data.view );
- var data = {
- action: 'paginate_risk',
- next_page: nextPage
- };
+ var currentStep = response.data.current_step;
+ var percent = 0;
- event.preventDefault();
+ if ( 2 === currentStep ) {
+ percent = 50;
+ } else if ( 3 === currentStep ) {
+ percent = 100;
+ }else if( 4 === currentStep ) {
+ percent = 100;
+ }else{
+ percent = 0;
+ }
- jQuery.post( window.ajaxurl, data, function( view ) {
- jQuery( '.risk-page' ).replaceWith( view );
- window.eoxiaJS.digirisk.risk_page.refresh();
- } );
+ if ( jQuery( '.main-content' ).hasClass( 'step-1' ) ) {
+ jQuery( '.main-content' ).removeClass( 'step-1' ).addClass( 'step-2' );
+ } else if ( jQuery( '.main-content' ).hasClass( 'step-2' ) ) {
+ jQuery( '.main-content' ).removeClass( 'step-2' ).addClass( 'step-3' );
+ }else if ( jQuery( '.main-content' ).hasClass( 'step-3' ) ) {
+ jQuery( '.main-content' ).removeClass( 'step-3' ).addClass( 'step-4' );
+ }
+
+ jQuery( '.prevention-wrap .bar .loader' ).css( 'width', percent + '%' );
+ jQuery( '.prevention-wrap .bar .loader' ).attr( 'data-width', percent );
+ jQuery( '.prevention-wrap .step-list .step[data-width="' + percent + '"]' ).addClass( 'active' );
+ }
+
+ // window.eoxiaJS.refresh();
};
-
+
+window.eoxiaJS.digirisk.preventionPlan.preventionLoadTabSuccess = function( element, response ){
+ element.closest( '.main-content' ).html( response.data.view );
+}
+
/**
- * Initialise l'objet "risk" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ * Ajoutes la nouvelle ligne du participant dans le tableau.
*
- * @since 6.0.0
- * @version 7.0.0
+ * @since 6.6.0
+ *
+ * @param {HTMLDivElement} element Le bouton déclencahd l'action AJAX.
+ * @param {Object} response Les données reçu dans le formulaire.
+ *
+ * @return {void}
*/
-window.eoxiaJS.digirisk.risk = {};
+window.eoxiaJS.digirisk.preventionPlan.savedParticipant = function( element, response ) {
+ jQuery( '.ajax-content' ).html( response.data.view );
-window.eoxiaJS.digirisk.risk.init = function() {
- window.eoxiaJS.digirisk.risk.refresh();
- window.eoxiaJS.digirisk.risk.event();
-};
+ window.eoxiaJS.digirisk.causerie.checkParticipantsSignature();
-window.eoxiaJS.digirisk.risk.refresh = function() {
- autosize(document.querySelectorAll('textarea'));
+ // window.eoxiaJS.refresh();
};
-window.eoxiaJS.digirisk.risk.event = function() {
- jQuery( document ).on( 'dropdown-before-close', '.risk-row .risk-options .dropdown-move-to .dropdown-item', window.eoxiaJS.digirisk.risk.beforeClose );
- jQuery( document ).on( 'keyup', '.dropdown-move-to input.form-field', window.eoxiaJS.digirisk.risk.searchMoveTo );
-};
+window.eoxiaJS.digirisk.preventionPlan.displayButtonUniteDeTravail = function( event ){
+ window.eoxiaJS.digirisk.preventionPlan.checkIfInterventionCanBeAdd( '', jQuery( this ) );
+}
-window.eoxiaJS.digirisk.risk.beforeClose = function( event, toggle, element, obj ) {
- obj.close = false;
+window.eoxiaJS.digirisk.preventionPlan.displayButtonUniteDeTravailSuccess = function( trigerredElement, response ){
+ trigerredElement.closest( '.unite-de-travail-class' ).find( '.button-unite-de-travail' ).html( response.data.view );
+ var error = window.eoxiaJS.digirisk.preventionPlan.checkIfInterventionCanBeAdd( '', trigerredElement );
+ if( ! error ){
+ var parent_element = trigerredElement.closest( '.unite-de-travail-class' );
+ parent_element.find( '.button-add-row-intervention' ).removeClass( 'button-disable' ).addClass( 'button-blue' );
+ }
+}
- element.closest( '.wpeo-form' ).find( 'input[type="hidden"]' ).val( element.data( 'id' ) );
- element.closest( '.wpeo-form' ).find( 'input[type="text"]' ).val( element.text().trim() );
+window.eoxiaJS.digirisk.preventionPlan.displayModalUniteDeTravail = function( event ){
+ jQuery( this ).closest( '.button-unite-de-travail' ).find( '.digirisk-modal-unite' ).addClass( 'modal-active' );
+}
- element.closest( '.wpeo-dropdown' ).find( '.dropdown-content' ).addClass( 'hidden' );
-};
+/*window.eoxiaJS.digirisk.preventionPlan.displayButtonSaveInformation = function( event ){
+ jQuery( this ).closest( '.information-society' ).find( '.button-save-information-society' ).show( 'slow' );
+}*/
-window.eoxiaJS.digirisk.risk.searchMoveTo = function( event ) {
- jQuery( this ).closest( '.wpeo-dropdown' ).find( '.dropdown-content' ).removeClass( 'hidden' );
+window.eoxiaJS.digirisk.preventionPlan.saveUserToSociety = function( trigerredElement, response ){
+ trigerredElement.closest( '.wpeo-table' ).replaceWith( response.data.view );
+}
- var entries = jQuery( this ).closest( '.wpeo-dropdown' ).find( '.dropdown-content .dropdown-item' );
- entries.show();
+window.eoxiaJS.digirisk.preventionPlan.preShotEmailUser = function( event ){
+ var parent_element = jQuery( this ).closest( '.table-row' );
+ if (! parent_element.length) {
+ parent_element = jQuery( this ).closest( '.wpeo-gridlayout' );
+ }
- var val = jQuery( this ).val().toLowerCase();
+ var name = parent_element.find( 'input[name="name"]' ).length ? parent_element.find( 'input[name="name"]' ).val() : parent_element.find( 'input[name="intervenant-name"]' ).val();
+ var lastname = parent_element.find( 'input[name="lastname"]' ).length ? parent_element.find( 'input[name="lastname"]' ).val() : parent_element.find( 'input[name="intervenant-lastname"]' ).val();
+ var email = lastname.trim() + '.' + name.trim() + '@demo.com';
- for ( var i = 0; i < entries.length; i++ ) {
- if ( jQuery( entries[i] ).text().toLowerCase().indexOf( val ) == -1 ) {
- jQuery( entries[i] ).hide();
- }
- }
-};
+ if ( parent_element.find( '[name="mail"]' ).length ) {
+ parent_element.find( '[name="mail"]' ).val( email );
+ } else if ( parent_element.find( '[name="intervenant-email"]' ).length ) {
+ parent_element.find( '[name="intervenant-email"]' ).val( email );
-window.eoxiaJS.digirisk.risk.deletedRiskSuccess = function( element, response ) {
- element.closest( 'tr, .table-row' ).fadeOut();
-};
+ }
+}
-window.eoxiaJS.digirisk.risk.loadedRiskSuccess = function( element, response ) {
- element.closest( 'tr, .table-row' ).replaceWith( response.data.template );
- window.eoxiaJS.digirisk.risk.refresh();
-};
+window.eoxiaJS.digirisk.preventionPlan.selectRisqueInDropdown = function( event ){
+ var parent_element = jQuery( this ).closest( '.form-element' );
+ var info_element = parent_element.find( '.category-danger .dropdown-toggle' );
+ info_element.css( 'padding', '0' );
+ info_element.find( 'span' ).hide();
+ info_element.find( '.button-icon' ).hide();
-window.eoxiaJS.digirisk.risk.beforeSaveRisk = function( triggeredElement ) {
- // Remet à 0 les styles.
- window.eoxiaJS.tooltip.remove( triggeredElement.closest( '.risk-row' ).find( '.category-danger.wpeo-tooltip-event' ) );
- window.eoxiaJS.tooltip.remove( triggeredElement.closest( '.risk-row' ).find( '.cotation-container.wpeo-tooltip-event' ) );
+ parent_element.find( '[name="risk_category_id"]' ).val( jQuery( this ).attr( 'data-id' ) );
+ var img_src = jQuery( this ).find( 'img' ).attr( 'src' );
+ info_element.find( 'img' ).attr( 'src', img_src );
+ info_element.find( 'img' ).removeClass( 'hidden' ).removeClass( 'wpeo-tooltip-event' ).addClass( 'wpeo-tooltip-event' );
- // Vérification du danger.
- if ( '-1' === triggeredElement.closest( '.risk-row' ).find( 'input[name="risk_category_id"]' ).val() && ! jQuery( '#digi-danger-preset' ).length ) {
- window.eoxiaJS.tooltip.display( triggeredElement.closest( '.risk-row' ).find( '.category-danger.wpeo-tooltip-event' ) );
- return false;
+ info_element.find( 'img' ).attr( 'aria-label', jQuery( this ).attr( 'aria-label' ) );
+ var error = window.eoxiaJS.digirisk.preventionPlan.checkIfInterventionCanBeAdd( '', jQuery( this ) );
+ if( ! error ){
+ var parent_element = jQuery( this ).closest( '.unite-de-travail-class' );
+ parent_element.find( '.button-add-row-intervention' ).removeClass( 'button-disable' ).addClass( 'button-blue' );
}
+}
- // Vérification de la cotation.
- if ( '{}' === triggeredElement.closest( '.risk-row' ).find( 'textarea[name="evaluation_variables"]' ).val() && ! jQuery( '#digi-danger-preset' ).length ) {
- window.eoxiaJS.tooltip.display( triggeredElement.closest( '.risk-row' ).find( '.cotation-container.wpeo-tooltip-event' ) );
- return false;
+
+window.eoxiaJS.digirisk.preventionPlan.checkIfInterventionCanBeAdd = function( event, element ){
+ if ( ! element ) {
+ element = "";
}
- return true;
-};
+ if( element == "" ){
+ element = jQuery( this );
+ }
-/**
- * Le callback en cas de réussite à la requête Ajax "edit_risk".
- * Remplaces le contenu du tableau "risk" par le template renvoyé par la requête Ajax.
- *
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
- *
- * @since 6.0.0
- */
-window.eoxiaJS.digirisk.risk.savedRiskSuccess = function( triggeredElement, response ) {
- triggeredElement.closest( 'table.risk, .wpeo-table.table-risk' ).replaceWith( response.data.template );
-};
+ var parent_element = element.closest( '.unite-de-travail-class' );
+ var error = false;
-/**
- * Le callback en cas de réussite à la requête Ajax "check_predefined_danger".
- *
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
- *
- * @since 6.2.9
- */
-window.eoxiaJS.digirisk.risk.checkedPredefinedDanger = function( triggeredElement, response ) {
- triggeredElement.closest( 'table, .wpeo-table' ).removeClass( 'loading' );
- triggeredElement.closest( '.risk-row' ).replaceWith( response.data.view );
-};
+ error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( parent_element, 'unitedetravail', error );
+ error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( parent_element, 'description-des-actions', error );
+ error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( parent_element, 'moyen-de-prevention', error );
+ error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( parent_element, 'risk_category_id', error );
-/**
- * Le callback en cas de réussite à la requête Ajax "to_society_id".
- *
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
- *
- * @since 7.1.0
- */
-window.eoxiaJS.digirisk.risk.movedRiskSuccess = function( triggeredElement, response ) {
- triggeredElement.closest( '.risk-row' ).fadeOut();
-};
-
-/**
- * Initialise l'objet "setting" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
- *
- * @since 6.0.0
- */
-window.eoxiaJS.digirisk.setting = {};
+ if( ! error ){
+ parent_element.find( '.button-add-row-intervention' ).removeClass( 'button-disable' ).addClass( 'button-blue' );
+ }else{
+ parent_element.find( '.button-add-row-intervention' ).removeClass( 'button-blue' ).addClass( 'button-disable' );
+ }
-window.eoxiaJS.digirisk.setting.init = function() {
- window.eoxiaJS.digirisk.setting.event();
-};
-window.eoxiaJS.digirisk.setting.event = function() {
- jQuery( document ).on( 'click', '#digi-danger-preset .save-all', window.eoxiaJS.digirisk.setting.savePresetRisks );
- jQuery( document ).on( 'click', '#digi-danger-preset .wpeo-table .table-row input:not(input[type="checkbox"]), #digi-danger-preset .table-row .toggle, #digi-danger-preset .dropdown-toggle, #digi-danger-preset .table-row textarea, #digi-danger-preset .table-row .popup, #digi-danger-preset .table-row .action', window.eoxiaJS.digirisk.setting.checkTheCheckbox );
- jQuery( document ).on( 'click', '.digirisk_page_digirisk-setting .list-users .wp-digi-pagination a', window.eoxiaJS.digirisk.setting.pagination );
- jQuery( document ).on( 'click', '.section-capability input[type="checkbox"]', window.eoxiaJS.digirisk.setting.activeSave );
+ return error;
+}
- jQuery( document ).on( 'click', '.wpeo-notification .notification-close', window.eoxiaJS.digirisk.setting.closeWpeo );
- jQuery( document ).on( 'keyup', '#digi-accronym input[type="text"], #digi-htpasswd input', window.eoxiaJS.digirisk.setting.buttonSave );
+window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid = function( parent_element, element, error ){
+ if ( error ) {
+ return true;
+ }
- jQuery( document ).on( 'click', '.section-capability .all', window.eoxiaJS.digirisk.setting.checkAllCapability );
- jQuery( document ).on( 'click', '.section-capability .one', window.eoxiaJS.digirisk.setting.uncheckAllCase );
-};
+ var content = parent_element.find( '[name="' + element + '"]' ).val();
-window.eoxiaJS.digirisk.setting.savePresetRisks = function( event ) {
- if ( event ) {
- event.preventDefault();
+ if( content == "" || content == "-1" || content == null || content == 0 ){
+ return true;
+ } else {
+ return false;
}
+}
- if ( jQuery( '#digi-danger-preset .table-row.risk-row.edit.checked .save.action-input' ).length ) {
- window.eoxiaJS.loader.display( jQuery( '#digi-danger-preset .save-all' ) );
- jQuery( '#digi-danger-preset .table-row.risk-row.edit.checked .save.action-input' ).click();
- }
-};
+window.eoxiaJS.digirisk.preventionPlan.addInterventionLine = function( event ){
+ var parent_element = jQuery( this ).closest( '.unite-de-travail-class' );
+ var data = {};
+ data.unite = parent_element.find( '[name="unitedetravail"]').val();
+ data.descriptionaction = parent_element.find( '[name="description-des-actions"]').val();
+ data.prevention = parent_element.find( '[name="moyen-de-prevention"]').val();
+ data.riskid = parent_element.find( '[name="risk_category_id"]').val();
+ data.parentid = jQuery( this ).attr( 'data-parentid' );
+ data.id = jQuery( this ).attr( 'data-id' );
+ data.action = jQuery( this ).attr( 'data-action' );
+ data._wpnonce = jQuery( this ).attr( 'data-nonce' );
+ window.eoxiaJS.loader.display( parent_element );
+ window.eoxiaJS.request.send( jQuery( this ), data );
+}
-/**
- * Gestion de la pagination des utilisateurs.
- *
- * @param {ClickEvent} event [description]
- *
- * @since 6.4.0
- */
-window.eoxiaJS.digirisk.setting.pagination = function( event ) {
- var href = jQuery( this ).attr( 'href' ).split( '&' );
- var nextPage = href[2].replace( 'current_page=', '' );
+window.eoxiaJS.digirisk.preventionPlan.addInterventionLineSuccess = function( triggeredElement, response ){
+ triggeredElement.closest( '.intervention-content' ).html( response.data.table_view );
+}
- jQuery( '.list-users' ).addClass( 'loading' );
+window.eoxiaJS.digirisk.preventionPlan.editInterventionLineSuccess = function( triggeredElement, response ){
+ triggeredElement.closest( '.intervention-row' ).replaceWith( response.data.view );
+}
- var data = {
- action: 'paginate_setting_page_user',
- next_page: nextPage,
- s: jQuery( '.autocomplete-search-input' ).val()
- };
+window.eoxiaJS.digirisk.preventionPlan.addIntervenantToPrevention = function( triggeredElement, response ){
+ triggeredElement.closest( '.wpeo-table' ).replaceWith( response.data.view );
+}
- event.preventDefault();
+window.eoxiaJS.digirisk.preventionPlan.editIntervenantPrevention = function( triggeredElement, response ){
+ triggeredElement.closest( '.table-row' ).replaceWith( response.data.view );
+}
- jQuery.post( window.ajaxurl, data, function( view ) {
- jQuery( '.settings-users-content' ).replaceWith( view );
- window.eoxiaJS.digirisk.search.renderChanged();
- } );
-};
+window.eoxiaJS.digirisk.preventionPlan.preventionPlanCanBeFinishMaitreOeuvre = function( event ){
+ window.eoxiaJS.digirisk.preventionPlan.checkIfPreventionPlanCanBeFinishMaitreOeuvre( jQuery( this ) );
+}
+window.eoxiaJS.digirisk.preventionPlan.PreventionPlanCanBeFinishIntervenantExterieur = function( event ){
+ window.eoxiaJS.digirisk.preventionPlan.checkIfPreventionPlanCanBeFinishIntervenantExterieur( jQuery( this ) );
+}
-/**
- * Coches la case à cocher lors de l'action dans une ligne du tableau.
- *
- * @param {ClickEvent} event L'état du clic.
- * @return {void}
- *
- * @since 6.2.3
- */
-window.eoxiaJS.digirisk.setting.checkTheCheckbox = function( event ) {
- jQuery( this ).closest( '.table-row.risk-row.edit' ).addClass( 'checked' );
- jQuery( '#digi-danger-preset .save-all' ).removeClass( 'button-disable' ).addClass( 'green' );
-};
+window.eoxiaJS.digirisk.preventionPlan.checkIfPreventionPlanCanBeFinishMaitreOeuvre = function( element ){
+ var parent_element = element;
+ var maitre_oeuvre_element = element.find( '.information-maitre-oeuvre' );
-window.eoxiaJS.digirisk.setting.savedRiskSuccess = function( element, response ) {
- if ( jQuery( '#digi-danger-preset .table-row.risk-row.edit.checked .save.action-input' ).length <= 1 ) {
- window.eoxiaJS.loader.remove( jQuery( '#digi-danger-preset .save-all' ) );
+ var error = false;
+ error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( maitre_oeuvre_element, 'user_id', error );
+ error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( maitre_oeuvre_element, 'user_signature', error );
+
+ if( ! error ) {
+ parent_element.find( '.prevention-start' ).removeClass( 'button-disable' );
+ } else {
+ parent_element.find( '.prevention-start' ).addClass( 'button-disable' );
}
+}
- jQuery( element ).closest( '.table-row' ).replaceWith( response.data.template );
-};
+window.eoxiaJS.digirisk.preventionPlan.checkIfPreventionPlanCanBeFinishIntervenantExterieur = function( element ){
+ var parent_element = jQuery( '.digi-prevention-plan-parent' );
+ var intervenant_exterieur_element = parent_element.find( '.information-intervenant-exterieur' );
+ var error = false;
-/**
- * Le callback en cas de réussite à la requête Ajax "save_capacity".
- * Affiches le message de "success".
- *
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
- *
- * @since 6.4.0
- */
-window.eoxiaJS.digirisk.setting.savedCapability = function( triggeredElement, response ) {
- jQuery( '.section-capability .action-input' ).addClass( 'button-disable' );
-};
+ error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( intervenant_exterieur_element, 'intervenant-name', error );
+ error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( intervenant_exterieur_element, 'intervenant-lastname', error );
+ error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( intervenant_exterieur_element, 'intervenant-phone', error );
+ error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( intervenant_exterieur_element, 'intervenant-email', error );
+ error = window.eoxiaJS.digirisk.preventionPlan.checkIfThisChampsIsValid( intervenant_exterieur_element, 'user_signature', error );
-/**
- * Le callback en cas de réussite à la requête Ajax "general_settings".
- * Affiches le message de "success".
- *
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
- *
- * @since 6.4.0
- */
-window.eoxiaJS.digirisk.setting.generalSettingsSaved = function( triggeredElement, response ) {
- //document.location.href = response.data.url;
-};
+ if ( ! error ) {
+ parent_element.find( '.prevention-start' ).removeClass( 'button-disable' );
+ } else {
+ parent_element.find( '.prevention-start' ).addClass( 'button-disable' );
+ }
+}
-window.eoxiaJS.digirisk.setting.activeSave = function( event ) {
- jQuery( this ).closest( '.section-capability' ).find( '.wpeo-button.button-blue' ).removeClass( 'button-disable' );
+window.eoxiaJS.digirisk.preventionPlan.generateDocumentPreventionSuccess = function( triggeredElement, response ){
+ if( response.data.link != "" ){
+ var element = document.createElement('a');
+ element.setAttribute('href', response.data.link );
+ element.setAttribute('download', response.data.filename);
+
+ element.style.display = 'none';
+ document.body.appendChild(element);
+
+ element.click();
+ document.body.removeChild(element);
+ }
}
-window.eoxiaJS.digirisk.setting.savePrefixSettingsDigiriskSuccess = function( triggeredElement, response ) {
- if( response.data.text_info != "" ){
- var notif_element = triggeredElement.closest( '.tab-content' ).find( '.prefix-response-success' );
- notif_element.show( '50' );
- notif_element.find( '.notification-title' ).html( response.data.text_info );
- triggeredElement.closest( '.tab-content' ).find( '.save-prefix' ).addClass( 'button-disable' );
+window.eoxiaJS.digirisk.preventionPlan.displayUserInfo = function( event ){
+ var element = jQuery( this ).closest( '.avatar-info-prevention' ).find( '.info-text' );
+
+ if( jQuery( element ).css( 'display' ) == "none" ){
+ element.show();
+ }else{
+ element.hide();
}
+
}
-window.eoxiaJS.digirisk.setting.closeWpeo = function( event ){
- jQuery( this ).closest( '.wpeo-notification' ).hide( '200' );
+window.eoxiaJS.digirisk.preventionPlan.deleteThisPreventionPlan = function( event ){
+ var message = jQuery( this ).attr( 'data-message' );
+ if( confirm( message ) ){
+ var data = {};
+
+ data.action = jQuery( this ).attr( 'data-action' );
+ data._wpnonce = jQuery( this ).attr( 'data-nonce' );
+ data.id = jQuery( this ).attr( 'data-id' );
+
+ window.eoxiaJS.loader.display( jQuery( this ).closest( '.item' ) );
+ window.eoxiaJS.request.send( jQuery( this ), data );
+ }
}
-window.eoxiaJS.digirisk.setting.buttonSave = function( event ){
- jQuery( this ).closest( '.tab-content ').find( '.button-disable' ).removeClass( 'button-disable' );
- jQuery( '#digi-accronym .prefix-response-success' ).hide( '200' );
+window.eoxiaJS.digirisk.preventionPlan.deleteDocumentPreventionSuccess = function( trigerredElement, response ){
+ trigerredElement.closest( '.main-content' ).html( response.data.dashboard_view );
+}
+
+window.eoxiaJS.digirisk.preventionPlan.updateEndDatePrevention = function( event ){
+ jQuery( this ).closest( '.end-date-element' ).find( '.wpeo-button' ).removeClass( 'button-blue' ).addClass( 'button-grey' );
+ jQuery( this ).removeClass( 'button-grey' ).addClass( 'button-blue' );
+ jQuery( this ).closest( '.end-date-element' ).find( 'input[name="date_end__is_define"]' ).val( jQuery( this ).attr( 'data-action' ) );
+
+ var form_element = jQuery( this ).closest( '.end-date-element' ).find( '.form-element' );
+ if( jQuery( this ).attr( 'data-action' ) == "undefined" ){
+ form_element.addClass( 'form-element-disable' );
+ }else{
+ form_element.removeClass( 'form-element-disable' );
+ }
+}
+
+window.eoxiaJS.digirisk.preventionPlan.updateStartDatePrevention = function( event ){
+ const date = event.target.value.split('/')
+ const maximalDate = new Date(date[2], date[1]-1, date[0])
+ maximalDate.setFullYear(maximalDate.getFullYear() + 1)
+
+ const formatMaxDate = (date) => `${date.getFullYear()}/${date.getMonth()+1}/${date.getDate()}`
+ const formatValue = (date) => new Intl.DateTimeFormat('fr-FR').format(date)
+ const formatValueSql = (date) => `${maximalDate.getFullYear()}-${maximalDate.getMonth()+1}-${maximalDate.getDate()}`
+
+ const endDateElementLimit = jQuery(document).find('.maximal-date-prevention')
+ endDateElementLimit.attr('max-date', formatMaxDate(maximalDate))
+ endDateElementLimit.attr('value', formatValue(maximalDate))
+
+ const endDateElementLimitSql = jQuery(document).find('.maximal-date-prevention-sql')
+ endDateElementLimitSql.attr('value', formatValueSql(maximalDate))
+}
+
+window.eoxiaJS.digirisk.preventionPlan.updateTitleOption = function( event ){
+ // jQuery( this ).closest( '.title-information-option' ).find( '.wpeo-button' ).removeClass( 'button-blue' ).addClass( 'button-grey' );3
+ var type = jQuery( this ).attr( 'data-type' );
+ if( jQuery( this ).closest( '.title-information-option' ).find( 'input[name="' + type + '"]' ).val() == "1" ){
+ jQuery( this ).closest( '.title-information-option' ).find( 'input[name="' + type + '"]' ).val( '0' );
+ jQuery( this ).removeClass( 'button-blue' ).addClass( 'button-grey' );
+ jQuery( this ).find( '.button-icon' ).removeClass( 'fa-check-square' ).addClass( 'fa-square' );
+ }else{
+ jQuery( this ).closest( '.title-information-option' ).find( 'input[name="' + type + '"]' ).val( '1' );
+ jQuery( this ).removeClass( 'button-grey' ).addClass( 'button-blue' );
+ jQuery( this ).find( 'input[name="' + type + '"]' ).val( '1' );
+ jQuery( this ).find( '.button-icon' ).removeClass( 'fa-square' ).addClass( 'fa-check-square' );
+ }
+}
+
+window.eoxiaJS.digirisk.preventionPlan.editThisPreventionSuccess = function( trigerredElement, response ){
+ if( response.data.url ){
+ window.location.replace( response.data.url );
+ }
+}
+
+window.eoxiaJS.digirisk.preventionPlan.regexPhoneNumber = function(event) {
+
+ if(/^((\+)33|0)[1-9](\d{2}){4}$/.test(event.target.value) == false) {
+ jQuery(document).find('.form-element.element-phone').addClass("form-element-error")
+ jQuery(document).find('.wpeo-button.prevention-start').addClass("button-disable")
+ }
+ else if (jQuery(document).find('.form-element.element-phone').hasClass("form-element-error")) {
+ jQuery(document).find('.form-element.element-phone').removeClass("form-element-error")
+ jQuery(document).find('.wpeo-button.prevention-start').removeClass("button-disable")
+
+ }
}
+
+window.eoxiaJS.digirisk.recommendation = {};
+
+window.eoxiaJS.digirisk.recommendation.init = function() {
+ window.eoxiaJS.digirisk.recommendation.event();
+};
+
+window.eoxiaJS.digirisk.recommendation.event = function() {
+ jQuery( document ).on( 'click', '.wpeo-table.table-recommendation .categorie-container .item', window.eoxiaJS.digirisk.recommendation.selectRecommendation );
+};
/**
- * Le callback en cas de réussite à la requête Ajax "save_htpasswd".
- * Affiches le message de "success".
+ * Lors du clic sur une recommendation, remplace le contenu du toggle par l'image de la recommendation sélectionnée.
+ *
+ * @since 6.0.0
+ * @version 7.0.0
+ *
+ * @param {ClickEvent} event [description]
+ * @return {void}
+ */
+window.eoxiaJS.digirisk.recommendation.selectRecommendation = function( event ) {
+ var element = jQuery( this );
+
+ element.closest( '.content' ).removeClass( 'active' );
+ element.closest( '.table-row' ).find( 'input[name="recommendation_category_id"]' ).val( element.data( 'id' ) );
+
+ element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle span' ).hide();
+ element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).show();
+ element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).attr( 'src', element.find( 'img' ).attr( 'src' ) );
+ element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).attr( 'srcset', '' );
+ element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).attr( 'sizes', '' );
+ element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).attr( 'aria-label', element.closest( '.tooltip' ).attr( 'aria-label' ) );
+
+ element.closest( '.table-row' ).find( '.categorie-container.tooltip' ).removeClass( 'active' );
+
+ // Rend le bouton "active".
+ element.closest( '.table-row' ).find( '.action .wpeo-button.button-disable' ).removeClass( 'button-disable' );
+};
+
+/**
+ * Vérifie que le champs "taxonomy[digi-recommendation][] soit différent de -1".
+ *
+ * @since 6.0.0
+ * @version 7.0.0
+ *
+ * @param {HTMLDivElement} triggeredElement L'élément déclenchant l'action.
+ * @return {bool} Si true, le formulaire est envoyé. Si false, on annule l'envoie du formulaire.
+ */
+window.eoxiaJS.digirisk.recommendation.beforeSaveRecommendation = function( triggeredElement ) {
+
+ // Remet à 0 les styles.
+ triggeredElement.closest( '.recommendation-row' ).find( '.categorie-container' ).removeClass( 'active' );
+
+ // Vérification du danger.
+ if ( '-1' === triggeredElement.closest( '.recommendation-row' ).find( 'input[name="recommendation_category_id"]' ).val() ) {
+ triggeredElement.closest( '.recommendation-row' ).find( '.categorie-container' ).addClass( 'active' );
+ return false;
+ }
+
+ return true;
+};
+
+/**
+ * Le callback en cas de réussite à la requête Ajax "save_recommendation".
+ * Remplaces le contenu du tableau "recommendation" par le template renvoyé par la requête Ajax.
*
* @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
* @param {Object} response Les données renvoyées par la requête Ajax.
* @return {void}
*
- * @since 7.5.0
+ * @since 1.0
+ * @version 6.2.4.0
*/
-window.eoxiaJS.digirisk.setting.savedHtpasswd = function( triggeredElement, response ) {
- jQuery( '.section-htpasswd' ).replaceWith( response.data.view );
+window.eoxiaJS.digirisk.recommendation.savedRecommendationSuccess = function( element, response ) {
+ jQuery( '.wpeo-table.table-recommendation' ).replaceWith( response.data.template );
+ window.eoxiaJS.digirisk.date.init();
};
/**
- * Le callback en cas de réussite à la requête Ajax "delete_parent_site".
- * Affiches le message de "success".
+ * Le callback en cas de réussite à la requête Ajax "load_recommendation".
+ * Remplaces le contenu de la ligne du tableau "recommendation" par le template renvoyé par la requête Ajax.
*
* @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
* @param {Object} response Les données renvoyées par la requête Ajax.
* @return {void}
*
- * @since 7.5.0
+ * @since 1.0
+ * @version 6.2.4.0
*/
-window.eoxiaJS.digirisk.setting.deletedParentSite = function( triggeredElement, response ) {
- triggeredElement.closest( '.table-row' ).fadeOut();
+window.eoxiaJS.digirisk.recommendation.loadedRecommendationSuccess = function( element, response ) {
+ jQuery( element ).closest( '.table-row' ).replaceWith( response.data.template );
+ window.eoxiaJS.digirisk.date.init();
};
-window.eoxiaJS.digirisk.setting.savedChildSettings = function( triggeredElement, response ) {
- window.location.href = response.data.url;
+/**
+ * Le callback en cas de réussite à la requête Ajax "delete_recommendation".
+ * Supprimes la ligne du tableau affectée par l'action.
+ *
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
+ *
+ * @since 1.0
+ * @version 6.2.4.0
+ */
+window.eoxiaJS.digirisk.recommendation.deletedRecommendationSuccess = function( element, response ) {
+ jQuery( element ).closest( '.table-row' ).fadeOut();
};
+
+/**
+ * Initialise l'objet "riskCategory" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ *
+ * @since 6.0.0
+ * @version 7.0.0
+ */
+window.eoxiaJS.digirisk.riskCategory = {};
-window.eoxiaJS.digirisk.setting.checkAllCapability = function( event ) {
- if ( jQuery( this ).is( ':checked' ) ) {
- jQuery(this).closest('.user-row').find('input[type="checkbox"]').each(function () {
- jQuery(this).prop('checked', true);
- } );
- } else {
- jQuery(this).closest('.user-row').find('input[type="checkbox"]').each(function () {
- jQuery(this).prop('checked', false);
- } );
- }
+window.eoxiaJS.digirisk.riskCategory.init = function() {
+ window.eoxiaJS.digirisk.riskCategory.event();
};
-window.eoxiaJS.digirisk.setting.uncheckAllCase = function ( event ) {
- jQuery( this ).closest( '.user-row' ).find( '.all' ).prop( 'checked', false );
+window.eoxiaJS.digirisk.riskCategory.event = function() {
+ jQuery( document ).on( 'click', '.table .category-danger .item, .wpeo-table .category-danger .item', window.eoxiaJS.digirisk.riskCategory.selectDanger );
};
-
-window.eoxiaJS.digirisk.sheet_groupment = {};
-
-window.eoxiaJS.digirisk.sheet_groupment.init = function() {};
/**
- * Le callback en cas de réussite à la requête Ajax "generate_fiche_de_groupement".
- * Cliques sur le bouton "Fiche de groupement" pour recharger la vue.
+ * Lors du clic sur un riskCategory, remplaces le contenu du toggle et met l'image du risque sélectionné.
*
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @param {MouseEvent} event [description]
* @return {void}
*
- * @since 6.1.0
- * @version 6.2.4
+ * @since 6.0.0
+ * @version 7.0.0
*/
-window.eoxiaJS.digirisk.sheet_groupment.generatedSheetGroupment = function( triggeredElement, response ) {
- jQuery( '.tab-element[data-target="digi-fiche-de-groupement"]' ).click();
+window.eoxiaJS.digirisk.riskCategory.selectDanger = function( event ) {
+ var element = jQuery( this );
+ var data = {};
+ element.closest( '.content' ).removeClass( 'active' );
+ element.closest( 'tr, .table-row' ).find( 'input.input-hidden-danger' ).val( element.data( 'id' ) );
+ element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle span' ).hide();
+ element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).show();
+ element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).attr( 'src', element.find( 'img' ).attr( 'src' ) );
+ element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).attr( 'srcset', '' );
+ element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).attr( 'sizes', '' );
+ element.closest( '.wpeo-dropdown' ).find( '.dropdown-toggle img' ).attr( 'aria-label', element.closest( '.tooltip' ).attr( 'aria-label' ) );
+
+ window.eoxiaJS.tooltip.remove( element.closest( '.risk-row' ).find( '.category-danger.wpeo-tooltip-event' ) );
+
+ // Rend le bouton "active".
+ if ( '{}' !== element.closest( '.risk-row' ).find( 'textarea[name="evaluation_variables"]' ).val() ) {
+ element.closest( 'tr' ).find( '.action .wpeo-button.button-disable' ).removeClass( 'button-disable' );
+ }
+
+ // Si aucune donnée est entrée, on lance la requête.
+ if ( element.data( 'is-preset' ) && ! window.eoxiaJS.digirisk.riskCategory.haveDataInInput( element ) ) {
+ data.action = 'check_predefined_danger';
+ data._wpnonce = element.closest( '.wpeo-dropdown' ).data( 'nonce' );
+ data.danger_id = element.data( 'id' );
+ data.society_id = element.closest( '.risk-row' ).find( 'input[name="parent_id"] ' ).val();
+
+ window.eoxiaJS.loader.display( jQuery( this ).closest( 'table, .wpeo-table' ) );
+
+ window.eoxiaJS.request.send( jQuery( this ).closest( '.wpeo-dropdown' ), data );
+ }
};
-
-jQuery( document ).ready(function() {
- jQuery(document).unbind('keydown').bind('keydown', function (event) {
- var doPrevent = false;
- if (event.keyCode === 8) {
- var d = event.srcElement || event.target;
- if ((d.tagName.toUpperCase() === 'INPUT' &&
- (
- d.type.toUpperCase() === 'TEXT' ||
- d.type.toUpperCase() === 'PASSWORD' ||
- d.type.toUpperCase() === 'FILE' ||
- d.type.toUpperCase() === 'SEARCH' ||
- d.type.toUpperCase() === 'EMAIL' ||
- d.type.toUpperCase() === 'NUMBER' ||
- d.type.toUpperCase() === 'DATE' )
- ) ||
- ( d.tagName.toUpperCase() === 'TEXTAREA' ) ||
- d.getAttribute( 'contenteditable' ) ) {
- doPrevent = d.readOnly || d.disabled;
- }
- else {
- doPrevent = true;
- }
- }
- if (doPrevent) {
- event.preventDefault();
- }
-});
-});
+window.eoxiaJS.digirisk.riskCategory.haveDataInInput = function( element ) {
+ if ( '{}' != element.closest( '.risk-row' ).find( 'textarea[name="evaluation_variables"]' ).val() ) {
+ return true;
+ }
+
+ if ( '' != element.closest( '.risk-row' ).find( 'textarea[name="list_comment[0][content]"]' ).val() ) {
+ return true;
+ }
+
+ return false;
+};
-/**
- * Initialise l'objet "societyAdvancedOptions" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
- *
- * @since 6.2.5.0
- * @version 6.2.5.0
- */
-window.eoxiaJS.digirisk.societyAdvancedOptions = {};
+"use strict";
-window.eoxiaJS.digirisk.societyAdvancedOptions.init = function() {};
+var digi_risk_comment = {
+ $: undefined,
-/**
- * Callback en cas de réussite de la requête Ajax "advanced_options_move_to"
- * Remplaces le template principale de l'application avec le template reçu dans la réponse de la requête Ajax.
- *
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
- *
- * @since 6.2.5.0
- * @version 6.2.5.0
- */
-window.eoxiaJS.digirisk.societyAdvancedOptions.savedAdvancedOptionsMoveTo = function( element, response ) {
- jQuery( '.digirisk-wrap' ).replaceWith( response.data.view );
+ event: function( $ ) {
+ digi_risk_comment.$ = $;
+
+ digi_risk_comment.$( document ).on( 'click', '.wp-digi-action-comment-delete', function( event ) { digi_risk_comment.delete_comment( event, digi_risk_comment.$( this ) ); } );
+ },
+
+ delete_comment: function( event, element ) {
+ if( window.confirm( window.digi_confirm_delete ) ) {
+ var data = {
+ action: 'delete_comment',
+ _wpnonce: digi_risk_comment.$( element ).data( 'nonce' ),
+ risk_id: digi_risk_comment.$( element ).data( 'risk-id' ),
+ id: digi_risk_comment.$( element ).data( 'id' ),
+ };
+ digi_risk_comment.$( element ).closest( 'li' ).remove();
+ digi_risk_comment.$.post( window.ajaxurl, data, function() {} );
+ }
+ },
+
+ reset_create_form: function() {
+ digi_risk_comment.$( '.wp-digi-risk-item-new .wp-digi-risk-comment textarea' ).val('');
+ }
};
/**
- * Initialise l'objet "society" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ * Initialise l'objet "risk_page" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
*
- * @since 6.0.0
+ * @since 6.2.3
*/
-window.eoxiaJS.digirisk.society = {};
-window.eoxiaJS.digirisk.society.init = function() {
- window.eoxiaJS.digirisk.society.event();
+window.eoxiaJS.digirisk.risk_page = {};
+
+window.eoxiaJS.digirisk.risk_page.init = function() {
+ window.eoxiaJS.digirisk.risk_page.event();
};
-window.eoxiaJS.digirisk.society.event = function() {
- jQuery( document ).on( 'keyup', '.main-header input[name="title"]', window.eoxiaJS.digirisk.society.keyUpSaveIdentity );
- jQuery( document ).on( 'click', '.main-header .edit', window.eoxiaJS.digirisk.society.focusInputTitle );
- jQuery( document ).on( 'keyup', '.digirisk-wrap .form.society-informations .form-element input, .digirisk-wrap .form.society-informations .form-element textarea', window.eoxiaJS.digirisk.society.enableSaveButton );
- jQuery( document ).on( 'click', '.main-information-society .bloc-information-society', window.eoxiaJS.digirisk.society.requestGetViewEdit )
+window.eoxiaJS.digirisk.risk_page.refresh = function() {
+ autosize(document.querySelectorAll('textarea'));
};
-/**
- * Lorsque qu'on lache une touche dans le champ de texte "title", on fait apparaitre le bouton "Enregistrer".
- * Si la touche laché est "entrée" on appuie sur le bouton "Enregistrer".
- *
- * @param {KeyboardEvent} event L'état du clavier lors du "keyup"
- *
- * @since 6.0.0
- */
-window.eoxiaJS.digirisk.society.keyUpSaveIdentity = function( event ) {
- jQuery( '.digirisk-wrap .main-container .main-header .unit-header .edit' ).hide();
- jQuery( '.digirisk-wrap .main-container .main-header .unit-header .action-input.save' ).addClass( 'active' );
+window.eoxiaJS.digirisk.risk_page.event = function() {
+ jQuery( document ).on( 'click', '.risk-page .save-all:not(.grey)', window.eoxiaJS.digirisk.risk_page.saveRisks );
+ jQuery( document ).on( 'click', '.risk-page table tr input:not(input[type="checkbox"]), .risk-page .table-row .group-date, .risk-page .table-row .wpeo-dropdown .dropdown-toggle, .risk-page .table-row textarea, .risk-page .table-row .popup, .risk-page .table-row .action, .risk-page .cotation', window.eoxiaJS.digirisk.risk_page.checkTheCheckbox );
+ jQuery( document ).on( 'click', '.risk-page .wp-digi-pagination a', window.eoxiaJS.digirisk.risk_page.pagination );
+};
- if ( 13 === event.keyCode ) {
- jQuery( '.digirisk-wrap .main-container .main-header .unit-header .action-input.save' ).click();
+window.eoxiaJS.digirisk.risk_page.saveRisks = function( event ) {
+ if ( event ) {
+ event.preventDefault();
}
+
+ jQuery( '.risk-page .table-row .edit-risk.checked:first' ).click();
+ jQuery( '.risk-page .save-all' ).addClass( 'button-disable' );
};
/**
- * Focus le titre de la société lors du clic sur le bouton "edit".
+ * Coches la case à cocher lors de l'action dans une ligne du tableau.
*
- * @since 6.4.4
+ * @param {ClickEvent} event L'état du clic.
+ * @return {void}
*
- * @param {ClickEvent} event L'état de la souris.
+ * @since 6.2.3
*/
-window.eoxiaJS.digirisk.society.focusInputTitle = function( event ) {
- jQuery( this ).closest( '.main-header' ).find( 'input[name="title"]' ).focus().select();
+window.eoxiaJS.digirisk.risk_page.checkTheCheckbox = function( event ) {
+ jQuery( this ).closest( 'tr, .table-row' ).find( 'input[type="checkbox"]' ).prop( 'checked', true );
+ jQuery( this ).closest( 'tr, .table-row' ).find( '.edit-risk' ).addClass( 'checked' );
+ jQuery( '.risk-page .save-all' ).removeClass( 'button-disable' );
+};
- jQuery( this ).hide();
- jQuery( '.digirisk-wrap .main-container .main-header .unit-header .action-input.save' ).addClass( 'active' );
+window.eoxiaJS.digirisk.risk_page.savedRiskSuccess = function( Trigelement, response ) {
+ Trigelement.closest( '.table-row' ).replaceWith( response.data.template );
+ window.eoxiaJS.digirisk.risk_page.saveRisks();
};
/**
- * Lorsque qu'on lache une touche dans les champs de texte de 'form society-informations', on rend le bouton 'enabled'
+ * Gestion de la pagination des risques dans la page "Risques".
*
- * @param {KeyboardEvent} event L'état du clavier lors du "keyup"
+ * @param {ClickEvent} event [description]
* @return {void}
*
- * @since 6.3.0
+ * @since 6.2.6
*/
-window.eoxiaJS.digirisk.society.enableSaveButton = function( event ) {
- jQuery( '.digirisk-wrap .form.society-informations button.green' ).removeClass( 'disable' );
-};
+window.eoxiaJS.digirisk.risk_page.pagination = function( event ) {
+ var href = jQuery( this ).attr( 'href' ).split( '&' );
+ var nextPage = href[1].replace( 'current_page=', '' );
+
+ jQuery( '.risk-page' ).addClass( 'loading' );
+
+ var data = {
+ action: 'paginate_risk',
+ next_page: nextPage
+ };
+
+ event.preventDefault();
+ jQuery.post( window.ajaxurl, data, function( view ) {
+ jQuery( '.risk-page' ).replaceWith( view );
+ window.eoxiaJS.digirisk.risk_page.refresh();
+ } );
+};
+
/**
- * Callback en cas de réussite de la requête Ajax "save_society"
- * Remplaces le template principale de l'application avec le template reçu dans la réponse de la requête Ajax.
- *
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
+ * Initialise l'objet "risk" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
*
* @since 6.0.0
+ * @version 7.0.0
*/
-window.eoxiaJS.digirisk.society.savedSocietySuccess = function( element, response ) {
- jQuery( '.digirisk-wrap' ).replaceWith( response.data.template );
+window.eoxiaJS.digirisk.risk = {};
+
+window.eoxiaJS.digirisk.risk.init = function() {
+ window.eoxiaJS.digirisk.risk.refresh();
+ window.eoxiaJS.digirisk.risk.event();
};
-/**
- * Callback en cas de réussite de la requête Ajax "delete_society"
- * Remplaces le template principale de l'application avec le template reçu dans la réponse de la requête Ajax.
- *
- * @param {HTMLLiElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
- *
- * @since 6.0.0
- */
-window.eoxiaJS.digirisk.society.deletedSocietySuccess = function( triggeredElement, response ) {
- jQuery( '.digirisk-wrap' ).replaceWith( response.data.template );
+window.eoxiaJS.digirisk.risk.refresh = function() {
+ autosize(document.querySelectorAll('textarea'));
};
-/**
- * Callback en cas de réussite de la requête Ajax "save_groupment_configuration".
- * Remplaces les titres dans la navigation et le header du contenu principale.
- *
- * @param {HTMLLiElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
- *
- * @since 6.0.0
- */
-window.eoxiaJS.digirisk.society.savedSocietyConfigurationSuccess = function( triggeredElement, response ) {
- if ( 'digi-group' === response.data.society.type ) {
- jQuery( '.digirisk-wrap .workunit-navigation .title' ).text( response.data.society.data.unique_identifier + ' - ' + response.data.society.data.title );
- } else if ( 'digi-workunit' === response.data.society.type ) {
- jQuery( '.digirisk-wrap .workunit-list span[data-workunit-id="' + response.data.society.data.id + '"] span' ).text( response.data.society.data.title );
- jQuery( '.digirisk-wrap .workunit-list span[data-workunit-id="' + response.data.society.data.id + '"] span' ).attr( 'title', response.data.society.data.title );
- } else {
- jQuery( '.digirisk-wrap .navigation-container .society-header .title' ).text( response.data.society.data.title );
- }
-
- /*
+window.eoxiaJS.digirisk.risk.event = function() {
+ jQuery( document ).on( 'dropdown-before-close', '.risk-row .risk-options .dropdown-move-to .dropdown-item', window.eoxiaJS.digirisk.risk.beforeClose );
+ jQuery( document ).on( 'keyup', '.dropdown-move-to input.form-field', window.eoxiaJS.digirisk.risk.searchMoveTo );
+};
- jQuery( '.digirisk-wrap .main-container .main-header input[name="title"]' ).val( response.data.society.data.title );
+window.eoxiaJS.digirisk.risk.beforeClose = function( event, toggle, element, obj ) {
+ obj.close = false;
- jQuery( '.digirisk-wrap .main-content' ).replaceWith( response.data.view );
+ element.closest( '.wpeo-form' ).find( 'input[type="hidden"]' ).val( element.data( 'id' ) );
+ element.closest( '.wpeo-form' ).find( 'input[type="text"]' ).val( element.text().trim() );
- if( response.data.view_owner != "" ){
- triggeredElement.closest( '.wpeo-form' ).find( 'input[name="society[owner_id]]"}' ).closest( '.form-element' ).html( '' );
- }*/
+ element.closest( '.wpeo-dropdown' ).find( '.dropdown-content' ).addClass( 'hidden' );
};
-window.eoxiaJS.digirisk.society.deleteOwnerIdSuccess = function( triggeredElement, response ) {
- triggeredElement.closest( '.form-element' ).replaceWith( response.data.view );
-}
+window.eoxiaJS.digirisk.risk.searchMoveTo = function( event ) {
+ jQuery( this ).closest( '.wpeo-dropdown' ).find( '.dropdown-content' ).removeClass( 'hidden' );
-window.eoxiaJS.digirisk.society.requestGetViewEdit = function( event ){
+ var entries = jQuery( this ).closest( '.wpeo-dropdown' ).find( '.dropdown-content .dropdown-item' );
+ entries.show();
- element = jQuery( this ).attr( 'data-element' );
- if( jQuery( this ).attr( 'data-edit' ) == "true" ){
- return;
+ var val = jQuery( this ).val().toLowerCase();
+
+ for ( var i = 0; i < entries.length; i++ ) {
+ if ( jQuery( entries[i] ).text().toLowerCase().indexOf( val ) == -1 ) {
+ jQuery( entries[i] ).hide();
+ }
}
+};
- var data = {};
- data.action = jQuery( this ).attr( 'data-action' );
- data._wpnonce = jQuery( this ).attr( 'data-nonce' );
- data.element = element;
+window.eoxiaJS.digirisk.risk.deletedRiskSuccess = function( element, response ) {
+ element.closest( 'tr, .table-row' ).fadeOut();
+};
- window.eoxiaJS.loader.display( jQuery( this ) );
- window.eoxiaJS.request.send( jQuery( this ), data );
-}
+window.eoxiaJS.digirisk.risk.loadedRiskSuccess = function( element, response ) {
+ element.closest( 'tr, .table-row' ).replaceWith( response.data.template );
+ window.eoxiaJS.digirisk.risk.refresh();
+};
-window.eoxiaJS.digirisk.society.displayEditViewSuccess = function( triggeredElement, response ) {
- var class_element = triggeredElement.closest( '.bloc-information-society' ).attr( 'data-element' );
+window.eoxiaJS.digirisk.risk.beforeSaveRisk = function( triggeredElement ) {
+ // Remet à 0 les styles.
+ window.eoxiaJS.tooltip.remove( triggeredElement.closest( '.risk-row' ).find( '.category-danger.wpeo-tooltip-event' ) );
+ window.eoxiaJS.tooltip.remove( triggeredElement.closest( '.risk-row' ).find( '.cotation-container.wpeo-tooltip-event' ) );
- triggeredElement.closest( '.main-information-society' ).replaceWith( response.data.view );
- if( response.data.element == "" ){
- var parent_element = jQuery( '.digirisk-wrap .tab-container' );
- var element = parent_element.find( '.bloc-information-society[data-element="' + class_element + '"]' );
- element.css( "border", "solid green 1px" );
- }else{
- jQuery( '.tab-content .main-information-society' ).find( '.bloc-information-society[data-edit="true"]' ).removeClass( 'wpeo-tooltip-event' ); // Enleve la POPUP au survol
+ // Vérification du danger.
+ if ( '-1' === triggeredElement.closest( '.risk-row' ).find( 'input[name="risk_category_id"]' ).val() && ! jQuery( '#digi-danger-preset' ).length ) {
+ window.eoxiaJS.tooltip.display( triggeredElement.closest( '.risk-row' ).find( '.category-danger.wpeo-tooltip-event' ) );
+ return false;
}
-}
+
+ // Vérification de la cotation.
+ if ( '{}' === triggeredElement.closest( '.risk-row' ).find( 'textarea[name="evaluation_variables"]' ).val() && ! jQuery( '#digi-danger-preset' ).length ) {
+ window.eoxiaJS.tooltip.display( triggeredElement.closest( '.risk-row' ).find( '.cotation-container.wpeo-tooltip-event' ) );
+ return false;
+ }
+
+ return true;
+};
+
+/**
+ * Le callback en cas de réussite à la requête Ajax "edit_risk".
+ * Remplaces le contenu du tableau "risk" par le template renvoyé par la requête Ajax.
+ *
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
+ *
+ * @since 6.0.0
+ */
+window.eoxiaJS.digirisk.risk.savedRiskSuccess = function( triggeredElement, response ) {
+ triggeredElement.closest( 'table.risk, .wpeo-table.table-risk' ).replaceWith( response.data.template );
+};
+
+/**
+ * Le callback en cas de réussite à la requête Ajax "check_predefined_danger".
+ *
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
+ *
+ * @since 6.2.9
+ */
+window.eoxiaJS.digirisk.risk.checkedPredefinedDanger = function( triggeredElement, response ) {
+ triggeredElement.closest( 'table, .wpeo-table' ).removeClass( 'loading' );
+ triggeredElement.closest( '.risk-row' ).replaceWith( response.data.view );
+};
+
+/**
+ * Le callback en cas de réussite à la requête Ajax "to_society_id".
+ *
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
+ *
+ * @since 7.1.0
+ */
+window.eoxiaJS.digirisk.risk.movedRiskSuccess = function( triggeredElement, response ) {
+ triggeredElement.closest( '.risk-row' ).fadeOut();
+};
/**
- * Initialise l'objet "statistics" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ * Initialise l'objet "setting" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
*
- * @since 7.5.3
- * @version 7.5.3
+ * @since 6.0.0
*/
-window.eoxiaJS.digirisk.statistics = {};
+window.eoxiaJS.digirisk.setting = {};
-window.eoxiaJS.digirisk.statistics.init = function() {
- window.eoxiaJS.digirisk.statistics.event();
+window.eoxiaJS.digirisk.setting.init = function() {
+ window.eoxiaJS.digirisk.setting.event();
};
-window.eoxiaJS.digirisk.statistics.event = function() {
- jQuery( document ).on( 'click', '.tab-list .tab-element[data-target="digi-statistic"]', window.eoxiaJS.digirisk.statistics.loadContent );
+window.eoxiaJS.digirisk.setting.event = function() {
+ jQuery( document ).on( 'click', '#digi-danger-preset .save-all', window.eoxiaJS.digirisk.setting.savePresetRisks );
+ jQuery( document ).on( 'click', '#digi-danger-preset .wpeo-table .table-row input:not(input[type="checkbox"]), #digi-danger-preset .table-row .toggle, #digi-danger-preset .dropdown-toggle, #digi-danger-preset .table-row textarea, #digi-danger-preset .table-row .popup, #digi-danger-preset .table-row .action', window.eoxiaJS.digirisk.setting.checkTheCheckbox );
+ jQuery( document ).on( 'click', '.digirisk_page_digirisk-setting .list-users .wp-digi-pagination a', window.eoxiaJS.digirisk.setting.pagination );
+ jQuery( document ).on( 'click', '.section-capability input[type="checkbox"]', window.eoxiaJS.digirisk.setting.activeSave );
+
+ jQuery( document ).on( 'click', '.wpeo-notification .notification-close', window.eoxiaJS.digirisk.setting.closeWpeo );
+ jQuery( document ).on( 'keyup', '#digi-accronym input[type="text"], #digi-htpasswd input', window.eoxiaJS.digirisk.setting.buttonSave );
+
+ jQuery( document ).on( 'click', '.section-capability .all', window.eoxiaJS.digirisk.setting.checkAllCapability );
+ jQuery( document ).on( 'click', '.section-capability .one', window.eoxiaJS.digirisk.setting.uncheckAllCase );
};
-window.eoxiaJS.digirisk.statistics.loadContent = function() {
- setTimeout( window.eoxiaJS.digirisk.statistics.loadCharts, 100 );
+window.eoxiaJS.digirisk.setting.savePresetRisks = function( event ) {
+ if ( event ) {
+ event.preventDefault();
+ }
+ if ( jQuery( '#digi-danger-preset .table-row.risk-row.edit.checked .save.action-input' ).length ) {
+ window.eoxiaJS.loader.display( jQuery( '#digi-danger-preset .save-all' ) );
+ jQuery( '#digi-danger-preset .table-row.risk-row.edit.checked .save.action-input' ).click();
+ }
};
-window.eoxiaJS.digirisk.statistics.loadCharts = function () {
- let data = {
- action: 'load_data_chart',
- id: jQuery( document ).find( '.tab-element ' ).attr( 'data-id' ),
+/**
+ * Gestion de la pagination des utilisateurs.
+ *
+ * @param {ClickEvent} event [description]
+ *
+ * @since 6.4.0
+ */
+window.eoxiaJS.digirisk.setting.pagination = function( event ) {
+ var href = jQuery( this ).attr( 'href' ).split( '&' );
+ var nextPage = href[2].replace( 'current_page=', '' );
+
+ jQuery( '.list-users' ).addClass( 'loading' );
+
+ var data = {
+ action: 'paginate_setting_page_user',
+ next_page: nextPage,
+ s: jQuery( '.autocomplete-search-input' ).val()
};
- jQuery.ajax(
- {
- type: 'POST',
- url: ajaxurl,
- data: data,
- success: function( response ) {
- for ( let i = 0; i <= 4; i++ ) {
- let background_color_rgba = [];
- let border_color_rgba = [];
- for ( let a = 0; a < response.data.chart[i].data.datasets.data.length; a++ ) {
- background_color_rgba[a] = 'rgba('
- + response.data.chart[i].data.datasets.backgroundColor[0] + ','
- + response.data.chart[i].data.datasets.backgroundColor[1] + ','
- + response.data.chart[i].data.datasets.backgroundColor[2] + ','
- + response.data.chart[i].data.datasets.backgroundColor[3] +
- ')';
+ event.preventDefault();
- border_color_rgba[a] = 'rgba('
- + response.data.chart[i].data.datasets.borderColor[0] + ','
- + response.data.chart[i].data.datasets.borderColor[1] + ','
- + response.data.chart[i].data.datasets.borderColor[2] + ','
- + response.data.chart[i].data.datasets.borderColor[3] +
- ')';
- }
+ jQuery.post( window.ajaxurl, data, function( view ) {
+ jQuery( '.settings-users-content' ).replaceWith( view );
+ window.eoxiaJS.digirisk.search.renderChanged();
+ } );
+};
- let ctx = document.getElementById( 'myChart[' + i + ']' ).getContext( '2d' );
- new Chart(
- ctx,
- {
- type: response.data.chart[i].type,
- data: {
- labels: response.data.chart[i].data.labels,
- datasets: [{
- label: response.data.chart[i].data.datasets.label,
- data: response.data.chart[i].data.datasets.data,
- backgroundColor: background_color_rgba,
- borderColor: border_color_rgba,
- borderWidth: 1
- }]
- },
- options: {
- title: {
- display: response.data.chart[i].options.title.display,
- text: response.data.chart[i].options.title.text,
- fontSize: response.data.chart[i].options.title.fontSize,
- },
- barValueSpacing: response.data.chart[i].options.barValueSpacing,
- scales: {
- xAxes: [{
- stacked: false,
- }],
- yAxes: [{
- stacked: false,
- ticks: {
- beginAtZero: true
- }
- }]
- }
- }
- }
- );
- }
- // var label = [];
- // var data = [];
- // var backgroundColor = [];
- // var borderColor = [];
- //
- // var datasets = {
- // label: label,
- // data: data,
- // backgroundColor: backgroundColor,
- // borderColor: borderColor,
- // };
- //
- // for ( var b = 0; b < response.data.chart[5].data.datasets.length; b++ ) {
- // label[b] = response.data.chart[5].data.datasets[b].label;
- // data[b] = response.data.chart[5].data.datasets[b].data;
- // backgroundColor[b] = response.data.chart[5].data.datasets[b].backgroundColor;
- // borderColor[b] = response.data.chart[5].data.datasets[b].borderColor;
- // datasets[label] = label[b];
- // datasets[data] = data[b];
- // datasets[backgroundColor] = backgroundColor[b];
- // datasets[borderColor] = borderColor[b];
- // // datasets.push( data[b] );
- // // datasets.push( backgroundColor[b] );
- // // datasets.push( borderColor[b] );
- // }
- let ctx2 = document.getElementById('myChart[5]' ).getContext( '2d' );
- new Chart(
- ctx2,
- {
- type: response.data.chart[5].type,
- data: {
- labels: response.data.chart[5].data.labels,
- datasets: [{
- label: response.data.chart[5].data.datasets[0].label,
- data: response.data.chart[5].data.datasets[0].data,
- backgroundColor: "black",
- }, {
- label: response.data.chart[5].data.datasets[1].label,
- data: response.data.chart[5].data.datasets[1].data,
- backgroundColor: "red",
- }, {
- label: response.data.chart[5].data.datasets[2].label,
- data: response.data.chart[5].data.datasets[2].data,
- backgroundColor: "orange",
- }, {
- label: response.data.chart[5].data.datasets[3].label,
- data: response.data.chart[5].data.datasets[3].data,
- backgroundColor: "grey",
- }]
- },
- options: {
- title: {
- display: response.data.chart[5].options.title.display,
- text: response.data.chart[5].options.title.text,
- fontSize: response.data.chart[5].options.title.fontSize,
- },
- barValueSpacing: response.data.chart[5].options.barValueSpacing,
- scales: {
- xAxes: [{
- stacked: false,
- }],
- yAxes: [{
- stacked: false,
- ticks: {
- beginAtZero: true
- }
- }]
- }
- }
- }
- );
- },
- }
- );
+
+/**
+ * Coches la case à cocher lors de l'action dans une ligne du tableau.
+ *
+ * @param {ClickEvent} event L'état du clic.
+ * @return {void}
+ *
+ * @since 6.2.3
+ */
+window.eoxiaJS.digirisk.setting.checkTheCheckbox = function( event ) {
+ jQuery( this ).closest( '.table-row.risk-row.edit' ).addClass( 'checked' );
+ jQuery( '#digi-danger-preset .save-all' ).removeClass( 'button-disable' ).addClass( 'green' );
+};
+
+window.eoxiaJS.digirisk.setting.savedRiskSuccess = function( element, response ) {
+ if ( jQuery( '#digi-danger-preset .table-row.risk-row.edit.checked .save.action-input' ).length <= 1 ) {
+ window.eoxiaJS.loader.remove( jQuery( '#digi-danger-preset .save-all' ) );
+ }
+
+ jQuery( element ).closest( '.table-row' ).replaceWith( response.data.template );
};
+
/**
- * Le callback en cas de réussite à la requête Ajax "export_epi".
- * Exporte la fiche de vie d'un EPI au format ODT.
+ * Le callback en cas de réussite à la requête Ajax "save_capacity".
+ * Affiches le message de "success".
*
- * @since 0.5.0
- * @version 0.5.0
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
+ *
+ * @since 6.4.0
+ */
+window.eoxiaJS.digirisk.setting.savedCapability = function( triggeredElement, response ) {
+ jQuery( '.section-capability .action-input' ).addClass( 'button-disable' );
+};
+
+/**
+ * Le callback en cas de réussite à la requête Ajax "general_settings".
+ * Affiches le message de "success".
+ *
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
+ *
+ * @since 6.4.0
+ */
+window.eoxiaJS.digirisk.setting.generalSettingsSaved = function( triggeredElement, response ) {
+ //document.location.href = response.data.url;
+};
+
+window.eoxiaJS.digirisk.setting.activeSave = function( event ) {
+ jQuery( this ).closest( '.section-capability' ).find( '.wpeo-button.button-blue' ).removeClass( 'button-disable' );
+}
+
+window.eoxiaJS.digirisk.setting.savePrefixSettingsDigiriskSuccess = function( triggeredElement, response ) {
+ if( response.data.text_info != "" ){
+ var notif_element = triggeredElement.closest( '.tab-content' ).find( '.prefix-response-success' );
+ notif_element.show( '50' );
+ notif_element.find( '.notification-title' ).html( response.data.text_info );
+ triggeredElement.closest( '.tab-content' ).find( '.save-prefix' ).addClass( 'button-disable' );
+ }
+}
+
+window.eoxiaJS.digirisk.setting.closeWpeo = function( event ){
+ jQuery( this ).closest( '.wpeo-notification' ).hide( '200' );
+}
+
+window.eoxiaJS.digirisk.setting.buttonSave = function( event ){
+ jQuery( this ).closest( '.tab-content ').find( '.button-disable' ).removeClass( 'button-disable' );
+ jQuery( '#digi-accronym .prefix-response-success' ).hide( '200' );
+}
+
+/**
+ * Le callback en cas de réussite à la requête Ajax "save_htpasswd".
+ * Affiches le message de "success".
*
* @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
* @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
+ *
+ * @since 7.5.0
+ */
+window.eoxiaJS.digirisk.setting.savedHtpasswd = function( triggeredElement, response ) {
+ jQuery( '.section-htpasswd' ).replaceWith( response.data.view );
+};
+
+/**
+ * Le callback en cas de réussite à la requête Ajax "delete_parent_site".
+ * Affiches le message de "success".
*
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
* @return {void}
+ *
+ * @since 7.5.0
*/
-window.eoxiaJS.digirisk.statistics.exportedCSVFileSuccess = function ( triggeredElement, response ) {
- console.log( response );
- var element = document.createElement('a');
- element.setAttribute('href', response.data.link );
- element.setAttribute('download', response.data.filename);
+window.eoxiaJS.digirisk.setting.deletedParentSite = function( triggeredElement, response ) {
+ triggeredElement.closest( '.table-row' ).fadeOut();
+};
- element.style.display = 'none';
- document.body.appendChild(element);
+window.eoxiaJS.digirisk.setting.savedChildSettings = function( triggeredElement, response ) {
+ window.location.href = response.data.url;
+};
- element.click();
+window.eoxiaJS.digirisk.setting.checkAllCapability = function( event ) {
+ if ( jQuery( this ).is( ':checked' ) ) {
+ jQuery(this).closest('.user-row').find('input[type="checkbox"]').each(function () {
+ jQuery(this).prop('checked', true);
+ } );
+ } else {
+ jQuery(this).closest('.user-row').find('input[type="checkbox"]').each(function () {
+ jQuery(this).prop('checked', false);
+ } );
+ }
+};
- document.body.removeChild(element);
+window.eoxiaJS.digirisk.setting.uncheckAllCase = function ( event ) {
+ jQuery( this ).closest( '.user-row' ).find( '.all' ).prop( 'checked', false );
+};
+
+window.eoxiaJS.digirisk.sheet_groupment = {};
+
+window.eoxiaJS.digirisk.sheet_groupment.init = function() {};
+
+/**
+ * Le callback en cas de réussite à la requête Ajax "generate_fiche_de_groupement".
+ * Cliques sur le bouton "Fiche de groupement" pour recharger la vue.
+ *
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
+ *
+ * @since 6.1.0
+ * @version 6.2.4
+ */
+window.eoxiaJS.digirisk.sheet_groupment.generatedSheetGroupment = function( triggeredElement, response ) {
+ jQuery( '.tab-element[data-target="digi-fiche-de-groupement"]' ).click();
};
/**
@@ -4192,1455 +4475,1172 @@ window.eoxiaJS.digirisk.sheet_workunit.generatedFicheDePosteSuccess = function()
jQuery( '.tab-element[data-target="digi-fiche-de-poste"]' ).click();
};
-window.eoxiaJS.digirisk.tools = {};
-
-window.eoxiaJS.digirisk.tools.init = function() {
- window.eoxiaJS.digirisk.tools.event();
-};
-
-window.eoxiaJS.digirisk.tools.event = function() {
- jQuery( document ).on( 'click', '.digi-tools-main-container .nav-tab', window.eoxiaJS.digirisk.tools.tab_switcher );
- jQuery( document ).on( 'click', '.reset-method-evaluation', window.eoxiaJS.digirisk.tools.reset_evaluation_method );
- jQuery( document ).on( 'click', '.element-risk-compilation', window.eoxiaJS.digirisk.tools.risk_fixer );
- jQuery( document ).on( 'click', '.fix-recommendation', window.eoxiaJS.digirisk.tools.recommendation_fixer );
- jQuery( document ).on( 'click', '.fix-doc', window.eoxiaJS.digirisk.tools.doc_fixer );
-};
+jQuery( document ).ready(function() {
+ jQuery(document).unbind('keydown').bind('keydown', function (event) {
+ var doPrevent = false;
+ if (event.keyCode === 8) {
+ var d = event.srcElement || event.target;
+ if ((d.tagName.toUpperCase() === 'INPUT' &&
+ (
+ d.type.toUpperCase() === 'TEXT' ||
+ d.type.toUpperCase() === 'PASSWORD' ||
+ d.type.toUpperCase() === 'FILE' ||
+ d.type.toUpperCase() === 'SEARCH' ||
+ d.type.toUpperCase() === 'EMAIL' ||
+ d.type.toUpperCase() === 'NUMBER' ||
+ d.type.toUpperCase() === 'DATE' )
+ ) ||
+ ( d.tagName.toUpperCase() === 'TEXTAREA' ) ||
+ d.getAttribute( 'contenteditable' ) ) {
+ doPrevent = d.readOnly || d.disabled;
+ }
+ else {
+ doPrevent = true;
+ }
+ }
-window.eoxiaJS.digirisk.tools.tab_switcher = function( event ) {
- event.preventDefault();
+ if (doPrevent) {
+ event.preventDefault();
+ }
+});
+});
+
+/**
+ * Initialise l'objet "societyAdvancedOptions" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ *
+ * @since 6.2.5.0
+ * @version 6.2.5.0
+ */
+window.eoxiaJS.digirisk.societyAdvancedOptions = {};
- /** Remove all calss active on all tabs */
- jQuery( this ).closest( "h2" ).children( ".nav-tab" ).each( function(){
- jQuery( this ).removeClass( "nav-tab-active" );
- });
- /** Add the active class on clicked tab */
- jQuery( this ).addClass( "nav-tab-active" );
+window.eoxiaJS.digirisk.societyAdvancedOptions.init = function() {};
- /** Hide the different container and display the selected container */
- jQuery( this ).closest( ".digi-tools-main-container" ).find( ".tab-content" ).each( function(){
- jQuery( this ).hide();
- });
-
- jQuery( "#" + jQuery( this ).attr( "data-id" ) ).show();
-},
+/**
+ * Callback en cas de réussite de la requête Ajax "advanced_options_move_to"
+ * Remplaces le template principale de l'application avec le template reçu dans la réponse de la requête Ajax.
+ *
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
+ *
+ * @since 6.2.5.0
+ * @version 6.2.5.0
+ */
+window.eoxiaJS.digirisk.societyAdvancedOptions.savedAdvancedOptionsMoveTo = function( element, response ) {
+ jQuery( '.digirisk-wrap' ).replaceWith( response.data.view );
+};
+
+/**
+ * Initialise l'objet "society" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
+ *
+ * @since 6.0.0
+ */
+window.eoxiaJS.digirisk.society = {};
-window.eoxiaJS.digirisk.tools.reset_evaluation_method = function( event ) {
- event.preventDefault();
+window.eoxiaJS.digirisk.society.init = function() {
+ window.eoxiaJS.digirisk.society.event();
+};
- if ( window.confirm( window.digi_tools_confirm ) ) {
- jQuery( this ).addClass( "wp-digi-loading" );
- jQuery( this ).closest( 'div' ).find( 'ul' ).html('');
+window.eoxiaJS.digirisk.society.event = function() {
+ jQuery( document ).on( 'keyup', '.main-header input[name="title"]', window.eoxiaJS.digirisk.society.keyUpSaveIdentity );
+ jQuery( document ).on( 'click', '.main-header .edit', window.eoxiaJS.digirisk.society.focusInputTitle );
+ jQuery( document ).on( 'keyup', '.digirisk-wrap .form.society-informations .form-element input, .digirisk-wrap .form.society-informations .form-element textarea', window.eoxiaJS.digirisk.society.enableSaveButton );
+ jQuery( document ).on( 'click', '.main-information-society .bloc-information-society', window.eoxiaJS.digirisk.society.requestGetViewEdit )
+};
- var li = document.createElement( 'li' );
- li.innerHTML = window.digi_tools_in_progress;
- jQuery( this ).closest( 'div' ).find( 'ul' ).append( li );
+/**
+ * Lorsque qu'on lache une touche dans le champ de texte "title", on fait apparaitre le bouton "Enregistrer".
+ * Si la touche laché est "entrée" on appuie sur le bouton "Enregistrer".
+ *
+ * @param {KeyboardEvent} event L'état du clavier lors du "keyup"
+ *
+ * @since 6.0.0
+ */
+window.eoxiaJS.digirisk.society.keyUpSaveIdentity = function( event ) {
+ jQuery( '.digirisk-wrap .main-container .main-header .unit-header .edit' ).hide();
+ jQuery( '.digirisk-wrap .main-container .main-header .unit-header .action-input.save' ).addClass( 'active' );
- var data = {
- action: 'reset_method_evaluation',
- _wpnonce: jQuery( this ).data( 'nonce' )
- };
+ if ( 13 === event.keyCode ) {
+ jQuery( '.digirisk-wrap .main-container .main-header .unit-header .action-input.save' ).click();
+ }
+};
- window.eoxiaJS.digirisk.tools.exec_request( li, data, this );
- }
-},
+/**
+ * Focus le titre de la société lors du clic sur le bouton "edit".
+ *
+ * @since 6.4.4
+ *
+ * @param {ClickEvent} event L'état de la souris.
+ */
+window.eoxiaJS.digirisk.society.focusInputTitle = function( event ) {
+ jQuery( this ).closest( '.main-header' ).find( 'input[name="title"]' ).focus().select();
-window.eoxiaJS.digirisk.tools.risk_fixer = function( event ) {
- event.preventDefault();
+ jQuery( this ).hide();
+ jQuery( '.digirisk-wrap .main-container .main-header .unit-header .action-input.save' ).addClass( 'active' );
+};
- jQuery( this ).addClass( "wp-digi-loading" );
- jQuery( this ).closest( 'div' ).find( 'ul' ).html('');
+/**
+ * Lorsque qu'on lache une touche dans les champs de texte de 'form society-informations', on rend le bouton 'enabled'
+ *
+ * @param {KeyboardEvent} event L'état du clavier lors du "keyup"
+ * @return {void}
+ *
+ * @since 6.3.0
+ */
+window.eoxiaJS.digirisk.society.enableSaveButton = function( event ) {
+ jQuery( '.digirisk-wrap .form.society-informations button.green' ).removeClass( 'disable' );
+};
- var li = document.createElement( 'li' );
- li.innerHTML = window.digi_tools_in_progress;
- jQuery( this ).closest( 'div' ).find( 'ul' ).append( li );
+/**
+ * Callback en cas de réussite de la requête Ajax "save_society"
+ * Remplaces le template principale de l'application avec le template reçu dans la réponse de la requête Ajax.
+ *
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
+ *
+ * @since 6.0.0
+ */
+window.eoxiaJS.digirisk.society.savedSocietySuccess = function( element, response ) {
+ jQuery( '.digirisk-wrap' ).replaceWith( response.data.template );
+};
- var data = {
- action: 'compil_risk_list',
- _wpnonce: jQuery( this ).data( 'nonce' )
- };
+/**
+ * Callback en cas de réussite de la requête Ajax "delete_society"
+ * Remplaces le template principale de l'application avec le template reçu dans la réponse de la requête Ajax.
+ *
+ * @param {HTMLLiElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
+ *
+ * @since 6.0.0
+ */
+window.eoxiaJS.digirisk.society.deletedSocietySuccess = function( triggeredElement, response ) {
+ jQuery( '.digirisk-wrap' ).replaceWith( response.data.template );
+};
- window.eoxiaJS.digirisk.tools.exec_request( li, data, this );
-},
+/**
+ * Callback en cas de réussite de la requête Ajax "save_groupment_configuration".
+ * Remplaces les titres dans la navigation et le header du contenu principale.
+ *
+ * @param {HTMLLiElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
+ *
+ * @since 6.0.0
+ */
+window.eoxiaJS.digirisk.society.savedSocietyConfigurationSuccess = function( triggeredElement, response ) {
+ if ( 'digi-group' === response.data.society.type ) {
+ jQuery( '.digirisk-wrap .workunit-navigation .title' ).text( response.data.society.data.unique_identifier + ' - ' + response.data.society.data.title );
+ } else if ( 'digi-workunit' === response.data.society.type ) {
+ jQuery( '.digirisk-wrap .workunit-list span[data-workunit-id="' + response.data.society.data.id + '"] span' ).text( response.data.society.data.title );
+ jQuery( '.digirisk-wrap .workunit-list span[data-workunit-id="' + response.data.society.data.id + '"] span' ).attr( 'title', response.data.society.data.title );
+ } else {
+ jQuery( '.digirisk-wrap .navigation-container .society-header .title' ).text( response.data.society.data.title );
+ }
-window.eoxiaJS.digirisk.tools.recommendation_fixer = function( event ) {
- event.preventDefault();
+ /*
- jQuery( this ).addClass( "wp-digi-loading" );
- jQuery( this ).closest( 'div' ).find( 'ul' ).html('');
+ jQuery( '.digirisk-wrap .main-container .main-header input[name="title"]' ).val( response.data.society.data.title );
- var li = document.createElement( 'li' );
- li.innerHTML = window.digi_tools_in_progress;
- jQuery( this ).closest( 'div' ).find( 'ul' ).append( li );
+ jQuery( '.digirisk-wrap .main-content' ).replaceWith( response.data.view );
- var data = {
- action: 'transfert_recommendation',
- _wpnonce: jQuery( this ).data( 'nonce' )
- };
+ if( response.data.view_owner != "" ){
+ triggeredElement.closest( '.wpeo-form' ).find( 'input[name="society[owner_id]]"}' ).closest( '.form-element' ).html( '' );
+ }*/
+};
- window.eoxiaJS.digirisk.tools.exec_request( li, data, this );
-},
+window.eoxiaJS.digirisk.society.deleteOwnerIdSuccess = function( triggeredElement, response ) {
+ triggeredElement.closest( '.form-element' ).replaceWith( response.data.view );
+}
-window.eoxiaJS.digirisk.tools.doc_fixer = function( event ) {
- event.preventDefault();
+window.eoxiaJS.digirisk.society.requestGetViewEdit = function( event ){
- jQuery( this ).addClass( "wp-digi-loading" );
- jQuery( this ).closest( 'div' ).find( 'ul' ).html('');
+ element = jQuery( this ).attr( 'data-element' );
+ if( jQuery( this ).attr( 'data-edit' ) == "true" ){
+ return;
+ }
- var li = document.createElement( 'li' );
- li.innerHTML = window.digi_tools_in_progress;
- jQuery( this ).closest( 'div' ).find( 'ul' ).append( li );
+ var data = {};
+ data.action = jQuery( this ).attr( 'data-action' );
+ data._wpnonce = jQuery( this ).attr( 'data-nonce' );
+ data.element = element;
- var data = {
- action: 'transfert_doc',
- _wpnonce: jQuery( this ).data( 'nonce' )
- };
+ window.eoxiaJS.loader.display( jQuery( this ) );
+ window.eoxiaJS.request.send( jQuery( this ), data );
+}
- window.eoxiaJS.digirisk.tools.exec_request( li, data, this );
-},
+window.eoxiaJS.digirisk.society.displayEditViewSuccess = function( triggeredElement, response ) {
+ var class_element = triggeredElement.closest( '.bloc-information-society' ).attr( 'data-element' );
-window.eoxiaJS.digirisk.tools.exec_request = function( li, data, element ) {
- jQuery.post( window.ajaxurl, data, function() {
- jQuery( element ).removeClass( "wp-digi-loading" );
- li.innerHTML += ' ' + window.digi_tools_done;
- } );
-}
-
-window.eoxiaJS.digirisk.tools.fixedHiddenSociety = function( triggeredElement, response ) {
- jQuery( triggeredElement ).closest( '.tab-content' ).find( 'progress' ).val( 100 );
+ triggeredElement.closest( '.main-information-society' ).replaceWith( response.data.view );
+ if( response.data.element == "" ){
+ var parent_element = jQuery( '.digirisk-wrap .tab-container' );
+ var element = parent_element.find( '.bloc-information-society[data-element="' + class_element + '"]' );
+ element.css( "border", "solid green 1px" );
+ }else{
+ jQuery( '.tab-content .main-information-society' ).find( '.bloc-information-society[data-edit="true"]' ).removeClass( 'wpeo-tooltip-event' ); // Enleve la POPUP au survol
+ }
}
-jQuery( document ).ready( function(){
- /**
- * Transform default form into an ajax form for datas transfer treatment
- */
- jQuery( "#wpdigi-datastransfer-form" ).ajaxForm({
- dataType: "json",
- beforeSubmit: function( formData, jqForm, options ) {
- /** Adding loading class to form button */
- jqForm.children( "button.wp-digi-bton" ).addClass( "wp-digi-loading" );
- },
- success: function( responseText, statusText, xhr, $form ) {
- $form.children( "button.wp-digi-bton" ).removeClass( "wp-digi-loading" );
- if ( !responseText[ 'status' ] && responseText[ 'reload_transfert' ] ) {
- if ( 'element' == responseText[ 'sub_action' ] ) {
- jQuery( ".wpdigi-transfered-element-nb-" + responseText[ 'element_type' ] ).html( responseText[ 'main_element_nb' ] );
- if ( responseText[ 'main_element_nb' ] == jQuery( ".wpdigi-to-transfer-element-nb-" + responseText[ 'element_type' ] ).html() ) {
- jQuery( ".wp-digi-datastransfer-element-type-name-" + responseText[ 'element_type' ] ).addClass( 'dashicons-before dashicons-yes' );
- }
- jQuery( ".wpdigi-transfered-element-nb-" + responseText[ 'sub_element_type' ] ).html( responseText[ 'sub_element_nb' ] );
- if ( responseText[ 'sub_element_nb' ] == jQuery( ".wpdigi-to-transfer-element-nb-" + responseText[ 'sub_element_type' ] ).html() ) {
- jQuery( ".wp-digi-datastransfer-element-type-name-" + responseText[ 'sub_element_type' ] ).addClass( 'dashicons-before dashicons-yes' );
- }
- if ( undefined != ( responseText['treated_tree'] ) ) {
- jQuery( ".wpdigi-tree-check-" + responseText[ 'element_type' ] ).html( responseText['treated_tree'] );
- }
- } else {
- jQuery( ".wpdigi-transfered-element-nb-documents" ).html( responseText[ 'transfered' ] );
- jQuery( ".wpdigi-not-transfered-element-nb-documents" ).html( responseText[ 'not_transfered' ] );
- if ( ( responseText[ 'transfered' ] + responseText[ 'not_transfered' ] ) == jQuery( ".wpdigi-to-transfer-element-nb-wpdigi-to-transfer-element-nb-documents" ).html() ) {
- jQuery( "wp-digi-datastransfer-element-type-name-documents" ).addClass( 'dashicons-before dashicons-yes' );
- }
- }
- if ( 'config_components' == responseText[ 'old_sub_action' ] ) {
- jQuery( ".wp-digi-transfert-components" ).html( responseText[ 'display_components_transfer' ] );
- $form.children( "input[name=action]" ).val( $form.children( "input[name=action]" ).val().replace( '-config_components', '' ) );
- }
- $form.children( "input[name=element_type_to_transfert]" ).val( responseText[ 'element_type' ] );
- $form.children( "input[name=sub_action]" ).val( responseText[ 'sub_action' ] );
- $form.submit();
- }
- else if ( responseText[ 'status' ] ) {
- jQuery( '#wp-digi-transfert-message' ).html( responseText[ "message" ] ).show();
- jQuery( "#wpdigi-datastransfer-form .wp-digi-bton-first" ).hide();
- setTimeout( function(){
- window.location.href = responseText['redirect_to_url'];
- }, '1500' );
- }
- }
- });
-
- jQuery( "input[name=wpdigi-dtrans-userid-behaviour]" ).click( function(){
- if ( jQuery( this ).is( ":checked" ) ) {
- jQuery( ".wp-digi-dtrans-userid-options-container" ).html( "" ).hide();
- }
- else {
- var data = {
- "action": "wpdigi-dtrans-transfert-options-load",
- "element_type": jQuery( this ).closest( "form" ).children( "input[name=element_type_to_transfert]" ).val(),
- };
- jQuery( ".wp-digi-dtrans-userid-options-container" ).load( ajaxurl, data ).show();
- }
- });
-});
-
-/**
- * Get the number of element created during transfer in order to inform user
- */
-function get_treated_element( element ) {
- var data = {
- action: "wpdigi-dtrans-get-done-element",
- element: element,
- };
- jQuery.post( ajaxurl, data, function( response ) {
- var i;
- for (i = 0; i < response['transfert'].length; i++) {
- jQuery( "#digi-datas-transfert-progression-container-" + response['transfert'][ i ][ 'type' ] ).html( response['transfert'][ i ][ 'text' ]);
- }
-
- if ( response[ "auto_reload" ] ) {
- setTimeout( function(){
- get_treated_element( element );
- }, "500");
- }
- }, "json");
-}
-
-"use strict";
-
-var digi_user_import = {
- $: undefined,
-
- init: function( event, $ ) {
- digi_user_import.$ = $;
- if ( event || event === undefined ) {
- digi_user_import.event();
- }
- },
-
- event: function() {
- digi_user_import.$( document ).on( 'submit', '#digi-data-import-user #digi-export-form', function( event ) { digi_user_import.create_export( event, digi_user_import.$( this ) ); } );
- digi_user_import.$( document ).on( 'change', '#digi-data-import-user #digi-import-form input[type="file"]', function( event ) { digi_user_import.make_import( event, digi_user_import.$( this ) ); } );
- },
-
- create_export: function( event, element ) {
- event.preventDefault();
- digi_user_import.$( element ).closest( 'form' ).ajaxSubmit( {
- 'beforeSubmit': function() {
- digi_user_import.$( element ).closest( '.wp-digi-bloc-loader' ).addClass( "wp-digi-bloc-loading" );
- },
- success: function( response ) {
- digi_user_import.$( element ).closest( '.wp-digi-bloc-loader' ).removeClass( "wp-digi-bloc-loading" );
- window.digi_global.download_file( response.data.url_to_file, response.data.filename );
- }
- } );
- },
-
- make_import: function( event, element ) {
- event.preventDefault();
-
- var data = new FormData();
- data.append( 'file', digi_user_import.$( element )[0].files[0] );
- data.append( 'action', 'digi_import_user' );
- data.append( '_wpnonce', digi_user_import.$( element ).closest('form').find( 'input[name="_wpnonce"]' ).val() );
- data.append( 'index_element', 0 );
-
- digi_user_import.request_import( data );
- },
-
- request_import: function( data ) {
- digi_user_import.$.ajax( {
- url: ajaxurl,
- data: data,
- processData: false,
- contentType: false,
- type: 'POST',
- beforeSend: function() {
- digi_user_import.$('.digi-import-detail').html( window.digi_tools_in_progress );
- },
- success: function(response) {
- if ( response.success ) {
- if ( !response.data.end ) {
- var data = new FormData();
- data.append( 'action', 'digi_import_user' );
- data.append( '_wpnonce', digi_user_import.$( '#digi-data-import-user #digi-import-form' ).find( 'input[name="_wpnonce"]' ).val() );
- data.append( 'index_element', response.data.index_element );
- data.append( 'count_element', response.data.count_element );
- data.append( 'path_to_csv', response.data.path_to_csv );
- digi_user_import.$('.digi-import-detail').html( window.digi_tools_in_progress );
- digi_user_import.request_import(data);
- }
- else {
- digi_user_import.$('.digi-import-detail').html( window.digi_tools_done );
- }
-
- digi_user_import.$('progress').attr( 'max', response.data.count_element );
- digi_user_import.$('progress').val( ( response.data.index_element / response.data.count_element ) * response.data.count_element );
-
- }
- else {
- alert( 'Problème lors de l\'importation du modèle' );
- digi_installer.$( '#digi-data-export' ).removeClass( "wp-digi-bloc-loading" );
- }
- }
- } );
- }
-};
-
-jQuery( document ).ready(function( $ ) {
- digi_user_import.init( true, $ );
-});
-
-/**
- * Initialise l'objet "user" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
- *
- * @since 6.0.0
- * @version 6.2.4
- */
-window.eoxiaJS.digirisk.user = {};
-
-window.eoxiaJS.digirisk.user.init = function() {
- window.eoxiaJS.digirisk.user.event();
-};
-
-/**
- * Initialise l'évènement relatif à la pagination.
- *
- * @return {void}
- *
- * @since 6.0.0
- * @version 6.2.4
- */
-window.eoxiaJS.digirisk.user.event = function() {
- jQuery( document ).on( 'click', '.form-edit-user-assign .wp-digi-pagination a', window.eoxiaJS.digirisk.user.pagination );
- jQuery( document ).on( 'keyup', '#digi-phone-number', window.eoxiaJS.digirisk.user.updatePhoneNumber );
-};
-
-/**
- * Le callback en cas de réussite à la requête Ajax "edit_user_assign".
- * Appel la méthode render de l'objet user avec la réponse de la requête Ajax.
- *
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
- *
- * @since 6.0.0
- * @version 6.2.4
- */
-window.eoxiaJS.digirisk.user.editUserAssignSuccess = function( triggeredElement, response ) {
- window.eoxiaJS.digirisk.user.render( response );
-};
-
-/**
- * Le callback en cas de réussite à la requête Ajax "detach_user".
- * Appel la méthode render de l'objet user avec la réponse de la requête Ajax.
- *
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
- *
- * @since 6.0.0
- * @version 6.2.4
- */
-window.eoxiaJS.digirisk.user.detachUserSuccess = function( triggeredElement, response ) {
- window.eoxiaJS.digirisk.user.render( response );
-};
-
-/**
- * Remplaces le contenu de la section ".users" avec la réponse de la requête Ajax de editUserAssignSuccess et detachUserSuccess.
- *
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
- *
- * @since 6.0.0
- * @version 6.2.5.0
- */
-window.eoxiaJS.digirisk.user.render = function( response ) {
- jQuery( 'section.users' ).replaceWith( response.data.template );
- window.eoxiaJS.digirisk.render.call_render_changed();
-};
-
-window.eoxiaJS.digirisk.user.pagination = function( event ) {
- event.preventDefault();
-
- var href = jQuery( this ).attr( 'href' ).split( '&' );
- var next_page = href[1].replace('current_page=', '');
- var element_id = href[2].replace('element_id=', '');
-
- var data = {
- action: 'paginate_user',
- element_id: element_id,
- next_page: next_page
- };
-
- jQuery( '.form-edit-user-assign' ).addClass( 'loading' );
-
- jQuery.post( window.ajaxurl, data, function( view ) {
- jQuery( '.form-edit-user-assign' ).replaceWith( view );
- } );
-};
-
-window.eoxiaJS.digirisk.user.updatePhoneNumber = function( event ) {
- console.log( jQuery( this ) );
- console.log( "------" );
-}
-
-/**
- * Initialise l'objet "userDashboard" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
- *
- * @since 6.0.0
- * @version 6.4.0
- */
-
-window.eoxiaJS.digirisk.userDashboard = {};
-
-window.eoxiaJS.digirisk.userDashboard.init = function() {
- window.eoxiaJS.digirisk.userDashboard.event();
-};
-
-/**
- * Intialise les évènements.
- *
- * @since 6.0.0
- * @version 6.4.0
- *
- * @return {void}
- */
-window.eoxiaJS.digirisk.userDashboard.event = function() {
- jQuery( document ).on( 'keyup', '.user-dashboard .input-domain-mail', window.eoxiaJS.digirisk.userDashboard.keyupUpdateEmail );
- jQuery( document ).on( 'keyup', '.user-dashboard .wpeo-table.users .table-row:last input.lastname', window.eoxiaJS.digirisk.userDashboard.keyupUpdateEmail );
- jQuery( document ).on( 'keyup', '.user-dashboard .wpeo-table.users .table-row:last input.firstname', window.eoxiaJS.digirisk.userDashboard.keyupUpdateEmail );
- jQuery( document ).on( 'keyup', '.user-dashboard .wpeo-table.users .table-row input', window.eoxiaJS.digirisk.userDashboard.keyEnterSendForm );
- jQuery( document ).on( 'keyup', '.user-dashboard .input-domain-mail', window.eoxiaJS.digirisk.userDashboard.keyEnterSendFormDomainMail );
-
- jQuery( document ).on( 'keyup', '.user-dashboard .wpeo-table.users .table-row:last input.lastname', window.eoxiaJS.digirisk.userDashboard.changeColorInputSubmit );
- jQuery( document ).on( 'keyup', '.user-dashboard .wpeo-table.users .table-row:last input.firstname', window.eoxiaJS.digirisk.userDashboard.changeColorInputSubmit );
- jQuery( document ).on( 'keyup', '.user-dashboard .wpeo-table.users .table-row:last input.email', window.eoxiaJS.digirisk.userDashboard.changeColorInputSubmit );
-
- jQuery( document ).on( 'click', '.user-dashboard .wp-digi-action-save-domain-mail', window.eoxiaJS.digirisk.userDashboard.save_domain_mail );
-};
-
-/**
- * Vérifie si le domaine de l'email a un format valide.
- *
- * @param {HTMLDivElement} triggeredElement
- * @return {void}
- *
- * @since 6.2.5
- * @version 6.2.5
- */
-window.eoxiaJS.digirisk.userDashboard.checkDomainEmailValid = function( triggeredElement ) {
- if ( ! window.regex.validateEndEmail( triggeredElement.closest( '.email-domain' ).find( 'input[type="text"]' ).val() ) ) {
- triggeredElement.closest( '.email-domain' ).find( 'label' ).addClass( 'active' );
- return false;
- } else {
- triggeredElement.closest( '.email-domain' ).find( 'label' ).removeClass( 'active' );
- return true;
- }
-};
-
-/**
- * Envoies une requête pour enregister le domaine de l'email.
- *
- * @param {ClickEvent} event L'état de la souris lors du clic sur le bouton.
- *
- * @return {void}
- *
- * @since 6.0.0
- * @version 6.2.5
- */
-window.eoxiaJS.digirisk.userDashboard.save_domain_mail = function( event ) {
- var element = jQuery( this );
- var data = {};
-
- event.preventDefault();
-
- data = {
- action: 'save_domain_mail',
- _wpnonce: element.data( 'nonce' ),
- domain_mail: element.closest( '.form-element' ).find( 'input' ).val()
- };
-
- jQuery.post( window.ajaxurl, data );
-};
-
-/**
- * Lors qu'une touche est en status "keyup" on met à jour le champ de texte "email" avec les données du champs de texte "nom", "prénom" et "Domaine de l'email".
- *
- * @param {KeyEvent} event L'état du clavier lors de l'évènement "keyup"
- * @return {void}
- *
- * @since 6.0.0
- * @version 6.2.5
- */
-window.eoxiaJS.digirisk.userDashboard.keyupUpdateEmail = function( event ) {
- var email = jQuery( '.user-dashboard .wpeo-table.users .table-row:last .email' ).val();
- var firstname = jQuery( '.user-dashboard .wpeo-table.users .table-row:last .firstname' ).val();
- var lastname = jQuery( '.user-dashboard .wpeo-table.users .table-row:last .lastname' ).val();
- var domainMail = jQuery( '.input-domain-mail' ).val();
- var together = window.eoxiaJS.global.removeDiacritics( firstname + '.' + lastname + '@' + domainMail ).toLowerCase();
-
- jQuery( '.user-dashboard .wpeo-table.users .table-row:last input[name="email"]' ).val( together );
-
- // Vérifie que l'évènement n'est pas déclenché dans le champ de texte du domaine de l'email.
- if ( 'input-domain-mail' !== event.target.className ) {
- window.eoxiaJS.digirisk.userDashboard.keyEnterSendForm( event, jQuery( this ) );
- }
-};
-
/**
- * Si la touche "entrée" est appuyé, appuies sur le bouton "plus" pour ajouter un utilisateur.
- *
- * @param {KeyEvent} event L'état du clavier lors de l'évènement "keyup"
- * @return {void}
+ * Initialise l'objet "statistics" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
*
- * @since 6.0.0
- * @version 6.4.0
+ * @since 7.5.3
+ * @version 7.5.3
*/
-window.eoxiaJS.digirisk.userDashboard.keyEnterSendForm = function( event ) {
- if ( 13 === event.keyCode ) {
- jQuery( this ).closest( '.user-row' ).find( '.action-input' ).click();
+window.eoxiaJS.digirisk.statistics = {};
- event.preventDefault();
- return false;
- }
+window.eoxiaJS.digirisk.statistics.init = function() {
+ window.eoxiaJS.digirisk.statistics.event();
};
-/**
- * Si la touche "entrée" est appuyé, appuies sur le bouton "plus" pour enregistrer le domaine de l'email.
- *
- * @param {KeyEvent} event L'état du clavier lors de l'évènement "keyup"
- * @return {void}
- *
- * @since 6.4.0
- * @version 6.4.0
- */
-window.eoxiaJS.digirisk.userDashboard.keyEnterSendFormDomainMail = function( event ) {
- if ( 13 === event.keyCode ) {
- jQuery( this ).closest( '.form' ).find( '.action-input' ).click();
-
- event.preventDefault();
- return false;
- }
+window.eoxiaJS.digirisk.statistics.event = function() {
+ jQuery( document ).on( 'click', '.tab-list .tab-element[data-target="digi-statistic"]', window.eoxiaJS.digirisk.statistics.loadContent );
};
-/**
- * Si la ligne a un contenu, change la couleur du bouton.
- *
- * @param {KeyboardEvent} event L'état du clavier.
- * @return {void}
- *
- * @since 6.2.6
- * @version 6.4.0
- */
-window.eoxiaJS.digirisk.userDashboard.changeColorInputSubmit = function( event ) {
- var row = jQuery( this ).closest( '.table-row' );
+window.eoxiaJS.digirisk.statistics.loadContent = function() {
+ setTimeout( window.eoxiaJS.digirisk.statistics.loadCharts, 100 );
- if ( row.find( 'input[name="firstname"]' ).val() && row.find( 'input[name="lastname"]' ).val() && row.find( 'input[name="email"]' ).val() ) {
- row.find( '.action .wpeo-button.button-disable' ).removeClass( 'button-disable' );
- } else {
- row.find( '.action .wpeo-button' ).addClass( 'button-disable' );
- }
};
-/**
- * Vérifie si les données du formulaire ne soit pas vide.
- * Toutes les données sont obligatoires.
- *
- * @since 6.4.0
- * @version 6.4.0
- *
- * @param {HTMLDivElement} element Le bouton déclenchant l'action.
- * @return {boolean} True ou false.
- */
-window.eoxiaJS.digirisk.userDashboard.checkData = function( element ) {
- var row = element.closest( '.table-row' );
-
- row.find( '.tooltip.active' ).removeClass( 'active' );
-
- if ( '' === row.find( 'input[name="lastname"]' ).val() ) {
- row.find( 'input[name="lastname"]' ).closest( '.tooltip' ).addClass( 'active' );
- return false;
- }
-
- if ( '' === row.find( 'input[name="firstname"]' ).val() ) {
- row.find( 'input[name="firstname"]' ).closest( '.tooltip' ).addClass( 'active' );
- return false;
- }
+window.eoxiaJS.digirisk.statistics.loadCharts = function () {
- if ( '' === row.find( 'input[name="email"]' ).val() ) {
- row.find( 'input[name="email"]' ).closest( '.tooltip' ).addClass( 'active' );
- return false;
- }
+ let data = {
+ action: 'load_data_chart',
+ id: jQuery( document ).find( '.tab-element ' ).attr( 'data-id' ),
+ };
- return true;
-};
+ jQuery.ajax(
+ {
+ type: 'POST',
+ url: ajaxurl,
+ data: data,
+ success: function( response ) {
+ for ( let i = 0; i <= 4; i++ ) {
+ let background_color_rgba = [];
+ let border_color_rgba = [];
+ for ( let a = 0; a < response.data.chart[i].data.datasets.data.length; a++ ) {
+ background_color_rgba[a] = 'rgba('
+ + response.data.chart[i].data.datasets.backgroundColor[0] + ','
+ + response.data.chart[i].data.datasets.backgroundColor[1] + ','
+ + response.data.chart[i].data.datasets.backgroundColor[2] + ','
+ + response.data.chart[i].data.datasets.backgroundColor[3] +
+ ')';
-/**
- * Le callback en cas de réussite à la requête Ajax "delete_user".
- * Supprimes la ligne de l'utilisateur.
- *
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
- *
- * @since 6.0.0
- * @version 6.2.5
- */
-window.eoxiaJS.digirisk.userDashboard.deletedUserSuccess = function( element, response ) {
- element.closest( '.table-row' ).fadeOut();
-};
+ border_color_rgba[a] = 'rgba('
+ + response.data.chart[i].data.datasets.borderColor[0] + ','
+ + response.data.chart[i].data.datasets.borderColor[1] + ','
+ + response.data.chart[i].data.datasets.borderColor[2] + ','
+ + response.data.chart[i].data.datasets.borderColor[3] +
+ ')';
+ }
-/**
- * Le callback en cas de réussite à la requête Ajax "load_user".
- * Remplaces la vue de la ligne.
- *
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
- *
- * @since 6.0.0
- * @version 6.2.5
- */
-window.eoxiaJS.digirisk.userDashboard.loadedUserSuccess = function( element, response ) {
- element.closest( '.table-row' ).replaceWith( response.data.template );
+ let ctx = document.getElementById( 'myChart[' + i + ']' ).getContext( '2d' );
+ new Chart(
+ ctx,
+ {
+ type: response.data.chart[i].type,
+ data: {
+ labels: response.data.chart[i].data.labels,
+ datasets: [{
+ label: response.data.chart[i].data.datasets.label,
+ data: response.data.chart[i].data.datasets.data,
+ backgroundColor: background_color_rgba,
+ borderColor: border_color_rgba,
+ borderWidth: 1
+ }]
+ },
+ options: {
+ title: {
+ display: response.data.chart[i].options.title.display,
+ text: response.data.chart[i].options.title.text,
+ fontSize: response.data.chart[i].options.title.fontSize,
+ },
+ barValueSpacing: response.data.chart[i].options.barValueSpacing,
+ scales: {
+ xAxes: [{
+ stacked: false,
+ }],
+ yAxes: [{
+ stacked: false,
+ ticks: {
+ beginAtZero: true
+ }
+ }]
+ }
+ }
+ }
+ );
+ }
+ // var label = [];
+ // var data = [];
+ // var backgroundColor = [];
+ // var borderColor = [];
+ //
+ // var datasets = {
+ // label: label,
+ // data: data,
+ // backgroundColor: backgroundColor,
+ // borderColor: borderColor,
+ // };
+ //
+ // for ( var b = 0; b < response.data.chart[5].data.datasets.length; b++ ) {
+ // label[b] = response.data.chart[5].data.datasets[b].label;
+ // data[b] = response.data.chart[5].data.datasets[b].data;
+ // backgroundColor[b] = response.data.chart[5].data.datasets[b].backgroundColor;
+ // borderColor[b] = response.data.chart[5].data.datasets[b].borderColor;
+ // datasets[label] = label[b];
+ // datasets[data] = data[b];
+ // datasets[backgroundColor] = backgroundColor[b];
+ // datasets[borderColor] = borderColor[b];
+ // // datasets.push( data[b] );
+ // // datasets.push( backgroundColor[b] );
+ // // datasets.push( borderColor[b] );
+ // }
+ let ctx2 = document.getElementById('myChart[5]' ).getContext( '2d' );
+ new Chart(
+ ctx2,
+ {
+ type: response.data.chart[5].type,
+ data: {
+ labels: response.data.chart[5].data.labels,
+ datasets: [{
+ label: response.data.chart[5].data.datasets[0].label,
+ data: response.data.chart[5].data.datasets[0].data,
+ backgroundColor: "black",
+ }, {
+ label: response.data.chart[5].data.datasets[1].label,
+ data: response.data.chart[5].data.datasets[1].data,
+ backgroundColor: "red",
+ }, {
+ label: response.data.chart[5].data.datasets[2].label,
+ data: response.data.chart[5].data.datasets[2].data,
+ backgroundColor: "orange",
+ }, {
+ label: response.data.chart[5].data.datasets[3].label,
+ data: response.data.chart[5].data.datasets[3].data,
+ backgroundColor: "grey",
+ }]
+ },
+ options: {
+ title: {
+ display: response.data.chart[5].options.title.display,
+ text: response.data.chart[5].options.title.text,
+ fontSize: response.data.chart[5].options.title.fontSize,
+ },
+ barValueSpacing: response.data.chart[5].options.barValueSpacing,
+ scales: {
+ xAxes: [{
+ stacked: false,
+ }],
+ yAxes: [{
+ stacked: false,
+ ticks: {
+ beginAtZero: true
+ }
+ }]
+ }
+ }
+ }
+ );
+ },
+ }
+ );
};
/**
- * Le callback en cas de réussite à la requête Ajax "save_user".
- * Remplaces le contenu du tableau "users" par le template renvoyé par la requête Ajax.
+ * Le callback en cas de réussite à la requête Ajax "export_epi".
+ * Exporte la fiche de vie d'un EPI au format ODT.
*
- * Si response.data.error est égale à true, affiches le tooltip disant "Cette adresse email est déjà utilisée."
+ * @since 0.5.0
+ * @version 0.5.0
*
* @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
* @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
*
- * @since 6.0.0
- * @version 6.4.0
+ * @return {void}
*/
-window.eoxiaJS.digirisk.userDashboard.savedUserSuccess = function( element, response ) {
- jQuery( '.user-dashboard .wpeo-table.users .email-already-used' ).hide();
-
- if ( response.data.error ) {
- jQuery( '.user-dashboard .wpeo-table.users .email-already-used' ).show();
- } else {
- jQuery( '.user-dashboard .wpeo-table.users' ).html( response.data.template );
- jQuery( '.user-dashboard .wpeo-table.users .table-row:last input.lastname' ).focus();
- }
-};
-
-"use strict";
-
-var digi_user_detail = {
- $: undefined,
- event: function($) {
- digi_user_detail.$ = $;
- digi_user_detail.$( document ).on( 'click', '#wp-digi-form-add-staff .wp-digi-action-view-detail', function( event ) { digi_user_detail.load_staff_detail( event, digi_user_detail.$( this ) ); } );
- digi_user_detail.$( document ).on( 'click', '.user-detail .load-data', function (event ) { digi_user_detail.load_data( event, digi_user_detail.$( this ) ); } );
- },
-
- load_staff_detail: function( event, element ) {
- event.preventDefault();
-
- var user_id = digi_user_detail.$( element ).data( 'id' );
- var _wpnonce = digi_user_detail.$( element ).data( 'nonce' );
-
- var data = {
- action: 'load_user_detail',
- _wpnonce: _wpnonce,
- user_id: user_id
- };
-
- digi_user_detail.$( '.user-detail' ).addClass( 'wp-digi-bloc-loading' );
-
- digi_user_detail.$.post( window.ajaxurl, data, function( response ) {
- digi_user_detail.$( '.user-detail' ).replaceWith( response.data.template );
- });
- },
-
- load_data: function( event, element ) {
- var user_id = digi_user_detail.$( element ).closest( 'ul' ).data( 'user-id' );
- var _wpnonce = digi_user_detail.$( element ).closest( 'ul' ).data( 'nonce' );
- var data_name = digi_user_detail.$ (element ).data( 'name' );
+window.eoxiaJS.digirisk.statistics.exportedCSVFileSuccess = function ( triggeredElement, response ) {
+ console.log( response );
+ var element = document.createElement('a');
+ element.setAttribute('href', response.data.link );
+ element.setAttribute('download', response.data.filename);
- var data = {
- action: 'load_data',
- _wpnonce: _wpnonce,
- user_id: user_id,
- data_name: data_name
- };
+ element.style.display = 'none';
+ document.body.appendChild(element);
- digi_user_detail.$( '.user-detail .wp-digi-list' ).addClass( 'wp-digi-bloc-loading' );
+ element.click();
- digi_user_detail.$.post( window.ajaxurl, data, function( response ) {
- digi_user_detail.$( '.user-detail .wp-digi-list' ).replaceWith( response.data.template );
- });
- }
+ document.body.removeChild(element);
};
-window.eoxiaJS.digirisk.worktype = {};
+window.eoxiaJS.digirisk.tools = {};
-window.eoxiaJS.digirisk.worktype.init = function() {
- window.eoxiaJS.digirisk.worktype.event();
+window.eoxiaJS.digirisk.tools.init = function() {
+ window.eoxiaJS.digirisk.tools.event();
};
-/**
- * Initialise deux évènements:
- * -Lorque qu'une touche du clavier est remontée dans le champ de texte pour ajouter une nouvelle unité de travail.
- * -Lorsque qu'un clic est effectué sur unité de travail dans le menu de navigation.
- *
- * @return {void}
- *
- * @since 0.1
- * @version 6.2.4.0
- */
-window.eoxiaJS.digirisk.worktype.event = function() {
-
+window.eoxiaJS.digirisk.tools.event = function() {
+ jQuery( document ).on( 'click', '.digi-tools-main-container .nav-tab', window.eoxiaJS.digirisk.tools.tab_switcher );
+ jQuery( document ).on( 'click', '.reset-method-evaluation', window.eoxiaJS.digirisk.tools.reset_evaluation_method );
+ jQuery( document ).on( 'click', '.element-risk-compilation', window.eoxiaJS.digirisk.tools.risk_fixer );
+ jQuery( document ).on( 'click', '.fix-recommendation', window.eoxiaJS.digirisk.tools.recommendation_fixer );
+ jQuery( document ).on( 'click', '.fix-doc', window.eoxiaJS.digirisk.tools.doc_fixer );
};
-
-window.eoxiaJS.digirisk.workunit = {};
-window.eoxiaJS.digirisk.workunit.init = function() {
- window.eoxiaJS.digirisk.workunit.event();
-};
+window.eoxiaJS.digirisk.tools.tab_switcher = function( event ) {
+ event.preventDefault();
-/**
- * Initialise deux évènements:
- * -Lorque qu'une touche du clavier est remontée dans le champ de texte pour ajouter une nouvelle unité de travail.
- * -Lorsque qu'un clic est effectué sur unité de travail dans le menu de navigation.
- *
- * @return {void}
- *
- * @since 0.1
- * @version 6.2.4.0
- */
-window.eoxiaJS.digirisk.workunit.event = function() {
- jQuery( document ).on( 'keyup', '.digirisk-wrap .workunit-add input[type="text"]', window.eoxiaJS.digirisk.workunit.keyEnterSendForm );
- jQuery( document ).on( 'click', '.digirisk-wrap .workunit-list span[data-action="load_society"]', window.eoxiaJS.digirisk.workunit.setActive );
-};
+ /** Remove all calss active on all tabs */
+ jQuery( this ).closest( "h2" ).children( ".nav-tab" ).each( function(){
+ jQuery( this ).removeClass( "nav-tab-active" );
+ });
+ /** Add the active class on clicked tab */
+ jQuery( this ).addClass( "nav-tab-active" );
-/**
- * Cette méthode clic sur le bouton "add" lorsque la touche "entrée" est remontée afin d'ajouter une unité de travail.
- *
- * @param {KeyboardEvent} event Contient toutes les valeurs du clavier lorsqu'une touche remonte.
- * @return void
- *
- * @since 0.1
- * @version 6.2.4.0
- */
-window.eoxiaJS.digirisk.workunit.keyEnterSendForm = function( event ) {
- if ( 13 === event.keyCode ) {
- jQuery( '.digirisk-wrap .workunit-add .add' ).click();
- }
-};
+ /** Hide the different container and display the selected container */
+ jQuery( this ).closest( ".digi-tools-main-container" ).find( ".tab-content" ).each( function(){
+ jQuery( this ).hide();
+ });
-/**
- * Le callback en cas de réussite à la requête Ajax "save_workunit".
- * Remplace le template de l'application en entier et clique sur la nouvelle unité de travail pour la charger.
- *
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
- *
- * @since 0.1
- * @version 6.2.4.0
- */
-window.eoxiaJS.digirisk.workunit.saved_workunit_success = function( triggeredElement, response ) {
- jQuery( '.digirisk-wrap' ).replaceWith( response.data.template );
- jQuery( '.workunit-list .unit-header[data-workunit-id="' + response.data.id + '"] span[data-action="load_society"]' ).click();
-};
+ jQuery( "#" + jQuery( this ).attr( "data-id" ) ).show();
+},
-/**
- * Ajoutes la classe "active" à l'unité de travail cliquée.
- *
- * @param {ClickEvent} event Contient toutes les valeurs de la souris lors du clic sur l'élément.
- *
- * @since 0.1
- * @version 6.2.4.0
- */
-window.eoxiaJS.digirisk.workunit.setActive = function( event ) {
- jQuery( '.digirisk-wrap .workunit-list li.active' ).removeClass( 'active' );
- jQuery( this ).closest( 'li' ).addClass( 'active' );
-};
-
-window.eoxiaJS.digirisk.ZIP = {};
+window.eoxiaJS.digirisk.tools.reset_evaluation_method = function( event ) {
+ event.preventDefault();
-window.eoxiaJS.digirisk.ZIP.init = function() {
- window.eoxiaJS.digirisk.ZIP.event();
-};
+ if ( window.confirm( window.digi_tools_confirm ) ) {
+ jQuery( this ).addClass( "wp-digi-loading" );
+ jQuery( this ).closest( 'div' ).find( 'ul' ).html('');
-window.eoxiaJS.digirisk.ZIP.event = function() {
-};
-
-/**
- * Initialise l'objet "causerie" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
- *
- * @since 6.6.0
- */
-window.eoxiaJS.digirisk.causerie = {};
+ var li = document.createElement( 'li' );
+ li.innerHTML = window.digi_tools_in_progress;
+ jQuery( this ).closest( 'div' ).find( 'ul' ).append( li );
-/**
- * Gestion des signatures.
- *
- * @type {HTMLCanvasElement}
- */
-window.eoxiaJS.digirisk.causerie.canvas;
+ var data = {
+ action: 'reset_method_evaluation',
+ _wpnonce: jQuery( this ).data( 'nonce' )
+ };
-/**
- * Initialise les évènements.
- *
- * @since 6.6.0
- *
- * @return {void}
- */
-window.eoxiaJS.digirisk.causerie.init = function() {
- window.eoxiaJS.digirisk.causerie.event();
- window.eoxiaJS.digirisk.causerie.refresh();
-};
+ window.eoxiaJS.digirisk.tools.exec_request( li, data, this );
+ }
+},
-/**
- * Initialise le canvas, ainsi que owlCarousel.
- *
- * @since 6.6.0
- *
- * @return {void}
- */
-window.eoxiaJS.digirisk.causerie.refresh = function() {
- jQuery( '.causerie-wrap .owl-carousel' ).owlCarousel( {
- 'nav': 1,
- 'loop': 1,
- 'items': 1,
- 'dots' : false,
- 'navText' : [' ',' '],
- } );
-};
+window.eoxiaJS.digirisk.tools.risk_fixer = function( event ) {
+ event.preventDefault();
-/**
- * Quand on "resize" la fenêtre, adapte le canvas.
- *
- * @since 6.4.0
- *
- * @param {Event} event L'état de l'évènement à ce moment T.
- * @return {void}
- */
-window.eoxiaJS.digirisk.causerie.resizeCanvas = function( event ) {
- var ratio = Math.max( window.devicePixelRatio || 1, 1 );
+ jQuery( this ).addClass( "wp-digi-loading" );
+ jQuery( this ).closest( 'div' ).find( 'ul' ).html('');
- for( var i = 0; i < window.eoxiaJS.digirisk.causerie.canvas.length; i++ ) {
- window.eoxiaJS.digirisk.causerie.canvas[i].width = window.eoxiaJS.digirisk.causerie.canvas[i].offsetWidth * ratio;
- window.eoxiaJS.digirisk.causerie.canvas[i].height = window.eoxiaJS.digirisk.causerie.canvas[i].offsetHeight * ratio;
- window.eoxiaJS.digirisk.causerie.canvas[i].getContext( "2d" ).scale( ratio, ratio );
- window.eoxiaJS.digirisk.causerie.canvas[i].signaturePad.clear();
- }
-};
+ var li = document.createElement( 'li' );
+ li.innerHTML = window.digi_tools_in_progress;
+ jQuery( this ).closest( 'div' ).find( 'ul' ).append( li );
+
+ var data = {
+ action: 'compil_risk_list',
+ _wpnonce: jQuery( this ).data( 'nonce' )
+ };
-/**
- * Initialise les évènements principaux des causeries.
- *
- * @since 6.6.0
- *
- * @return {void}
- */
-window.eoxiaJS.digirisk.causerie.event = function() {
- // Gestion du titre de la modal.
- jQuery( document ).on( 'change', '.digi-causerie-parent .wpeo-autocomplete', window.eoxiaJS.digirisk.causerie.updateModalTitle );
- jQuery( document ).on( 'click', '.digirisk_page_digirisk-causerie .modal-signature .wpeo-button.button-blue', window.eoxiaJS.digirisk.causerie.saveSignatureURL );
+ window.eoxiaJS.digirisk.tools.exec_request( li, data, this );
+},
- jQuery( document ).on( 'click', '.causerie-wrap a.disabled', function( event ) {
- event.preventDefault();
- return false;
- } );
+window.eoxiaJS.digirisk.tools.recommendation_fixer = function( event ) {
+ event.preventDefault();
- jQuery( document ).on( 'click', '.digi-import-add-keyword > .wpeo-button', window.eoxiaJS.digirisk.causerie.addKeywordToTextarea );
+ jQuery( this ).addClass( "wp-digi-loading" );
+ jQuery( this ).closest( 'div' ).find( 'ul' ).html('');
- jQuery( document ).on( 'click', '.digi-import-add-keyword .dropdown-content .item', window.eoxiaJS.digirisk.causerie.itemSelectToTextarea );
+ var li = document.createElement( 'li' );
+ li.innerHTML = window.digi_tools_in_progress;
+ jQuery( this ).closest( 'div' ).find( 'ul' ).append( li );
- jQuery( document ).on( 'keyup', '.digi-import-add-keyword .digi-info-import-link input', window.eoxiaJS.digirisk.causerie.updateImportTextFromUrl );
+ var data = {
+ action: 'transfert_recommendation',
+ _wpnonce: jQuery( this ).data( 'nonce' )
+ };
- // jQuery( document ).on( 'click', '.wpeo-modal .import-git-button', window.eoxiaJS.digirisk.causerie.importGitContent );
+ window.eoxiaJS.digirisk.tools.exec_request( li, data, this );
+},
- jQuery( document ).on( 'click', '.modal-footer .digi-display-view-git .digi-content-git', window.eoxiaJS.digirisk.causerie.txtHiddenGitToTextArea );
+window.eoxiaJS.digirisk.tools.doc_fixer = function( event ) {
+ event.preventDefault();
- jQuery( document ).on( 'click', '.modal-container .digi-import-git-success .digi-picture-download', window.eoxiaJS.digirisk.causerie.importAllPictureToMedia );
+ jQuery( this ).addClass( "wp-digi-loading" );
+ jQuery( this ).closest( 'div' ).find( 'ul' ).html('');
- jQuery( document ).on( 'click', '.modal-container .modal-footer-view-git .digi-footer-git-display ', window.eoxiaJS.digirisk.causerie.displayImportGitInput );
+ var li = document.createElement( 'li' );
+ li.innerHTML = window.digi_tools_in_progress;
+ jQuery( this ).closest( 'div' ).find( 'ul' ).append( li );
- jQuery( document ).on( 'click', '.modal-container .digi-view-execute .digi-view-execute-hide', window.eoxiaJS.digirisk.causerie.displayImportGitFromExecute );
+ var data = {
+ action: 'transfert_doc',
+ _wpnonce: jQuery( this ).data( 'nonce' )
+ };
- jQuery( document ).on( 'click', '.modal-container .digi-footer-execute .digi-import-execute-run', window.eoxiaJS.digirisk.causerie.importModalExecuteIt );
+ window.eoxiaJS.digirisk.tools.exec_request( li, data, this );
+},
- jQuery( document ).on( 'click', '.wrap-causerie .tab-select-redirect .tab-element', window.eoxiaJS.digirisk.causerie.tabSelectRedirect );
+window.eoxiaJS.digirisk.tools.exec_request = function( li, data, element ) {
+ jQuery.post( window.ajaxurl, data, function() {
+ jQuery( element ).removeClass( "wp-digi-loading" );
+ li.innerHTML += ' ' + window.digi_tools_done;
+ } );
+}
+
+window.eoxiaJS.digirisk.tools.fixedHiddenSociety = function( triggeredElement, response ) {
+ jQuery( triggeredElement ).closest( '.tab-content' ).find( 'progress' ).val( 100 );
+}
+
+jQuery( document ).ready( function(){
+ /**
+ * Transform default form into an ajax form for datas transfer treatment
+ */
+ jQuery( "#wpdigi-datastransfer-form" ).ajaxForm({
+ dataType: "json",
+ beforeSubmit: function( formData, jqForm, options ) {
+ /** Adding loading class to form button */
+ jqForm.children( "button.wp-digi-bton" ).addClass( "wp-digi-loading" );
+ },
+ success: function( responseText, statusText, xhr, $form ) {
+ $form.children( "button.wp-digi-bton" ).removeClass( "wp-digi-loading" );
+ if ( !responseText[ 'status' ] && responseText[ 'reload_transfert' ] ) {
+ if ( 'element' == responseText[ 'sub_action' ] ) {
+ jQuery( ".wpdigi-transfered-element-nb-" + responseText[ 'element_type' ] ).html( responseText[ 'main_element_nb' ] );
+ if ( responseText[ 'main_element_nb' ] == jQuery( ".wpdigi-to-transfer-element-nb-" + responseText[ 'element_type' ] ).html() ) {
+ jQuery( ".wp-digi-datastransfer-element-type-name-" + responseText[ 'element_type' ] ).addClass( 'dashicons-before dashicons-yes' );
+ }
+ jQuery( ".wpdigi-transfered-element-nb-" + responseText[ 'sub_element_type' ] ).html( responseText[ 'sub_element_nb' ] );
+ if ( responseText[ 'sub_element_nb' ] == jQuery( ".wpdigi-to-transfer-element-nb-" + responseText[ 'sub_element_type' ] ).html() ) {
+ jQuery( ".wp-digi-datastransfer-element-type-name-" + responseText[ 'sub_element_type' ] ).addClass( 'dashicons-before dashicons-yes' );
+ }
+ if ( undefined != ( responseText['treated_tree'] ) ) {
+ jQuery( ".wpdigi-tree-check-" + responseText[ 'element_type' ] ).html( responseText['treated_tree'] );
+ }
+ } else {
+ jQuery( ".wpdigi-transfered-element-nb-documents" ).html( responseText[ 'transfered' ] );
+ jQuery( ".wpdigi-not-transfered-element-nb-documents" ).html( responseText[ 'not_transfered' ] );
+ if ( ( responseText[ 'transfered' ] + responseText[ 'not_transfered' ] ) == jQuery( ".wpdigi-to-transfer-element-nb-wpdigi-to-transfer-element-nb-documents" ).html() ) {
+ jQuery( "wp-digi-datastransfer-element-type-name-documents" ).addClass( 'dashicons-before dashicons-yes' );
+ }
+ }
+ if ( 'config_components' == responseText[ 'old_sub_action' ] ) {
+ jQuery( ".wp-digi-transfert-components" ).html( responseText[ 'display_components_transfer' ] );
+ $form.children( "input[name=action]" ).val( $form.children( "input[name=action]" ).val().replace( '-config_components', '' ) );
+ }
+ $form.children( "input[name=element_type_to_transfert]" ).val( responseText[ 'element_type' ] );
+ $form.children( "input[name=sub_action]" ).val( responseText[ 'sub_action' ] );
+ $form.submit();
+ }
+ else if ( responseText[ 'status' ] ) {
+ jQuery( '#wp-digi-transfert-message' ).html( responseText[ "message" ] ).show();
+ jQuery( "#wpdigi-datastransfer-form .wp-digi-bton-first" ).hide();
+ setTimeout( function(){
+ window.location.href = responseText['redirect_to_url'];
+ }, '1500' );
+ }
+ }
+ });
- jQuery( document ).on( 'click', '.wrap-causerie .modal-footer-view-textarea .digi-display-textarea', window.eoxiaJS.digirisk.causerie.causerieImportDisplayTextarea );
-};
+ jQuery( "input[name=wpdigi-dtrans-userid-behaviour]" ).click( function(){
+ if ( jQuery( this ).is( ":checked" ) ) {
+ jQuery( ".wp-digi-dtrans-userid-options-container" ).html( "" ).hide();
+ }
+ else {
+ var data = {
+ "action": "wpdigi-dtrans-transfert-options-load",
+ "element_type": jQuery( this ).closest( "form" ).children( "input[name=element_type_to_transfert]" ).val(),
+ };
+ jQuery( ".wp-digi-dtrans-userid-options-container" ).load( ajaxurl, data ).show();
+ }
+ });
+});
/**
- * Met à jour le titre de la modal lors du clic sur le bouton pour que l'utilisateur effectue sa signature.
- *
- * @since 6.6.0
- *
- * @param {MouseEvent} event Les données du clic.
- * @param {Object} data Contient les données de la requête XHR.
+ * Get the number of element created during transfer in order to inform user
*/
-window.eoxiaJS.digirisk.causerie.updateModalTitle = function( event, data ) {
- var title = '';
- var element = jQuery( this );
+function get_treated_element( element ) {
+ var data = {
+ action: "wpdigi-dtrans-get-done-element",
+ element: element,
+ };
+ jQuery.post( ajaxurl, data, function( response ) {
+ var i;
+ for (i = 0; i < response['transfert'].length; i++) {
+ jQuery( "#digi-datas-transfert-progression-container-" + response['transfert'][ i ][ 'type' ] ).html( response['transfert'][ i ][ 'text' ]);
+ }
- if ( data && data.element ) {
- var request_data = {};
- request_data.action = 'causerie_save_former';
- request_data.id = jQuery( this ).closest( '.table-row' ).find( 'input[name="causerie_id"]' ).val();
- request_data.user_id = jQuery( this ).closest( '.table-row' ).find( 'input[name="former_id"]' ).val();
+ if ( response[ "auto_reload" ] ) {
+ setTimeout( function(){
+ get_treated_element( element );
+ }, "500");
+ }
+ }, "json");
+}
+
+"use strict";
- window.eoxiaJS.loader.display( jQuery( this ) );
- window.eoxiaJS.request.send( jQuery( this ), request_data, function( triggeredElement, response ) {
- title = 'Signature de l\'utilisateur: ' + data.element.data( 'result' );
- element.closest( '.table-row' ).find( '.wpeo-modal-event' ).attr( 'data-title', title );
- element.closest( '.table-row' ).find( '.wpeo-modal-event' ).removeClass( 'button-disable' );
- } );
- }
-};
+var digi_user_import = {
+ $: undefined,
-/**
- * Enregistres dans un champ caché
- *
- * @since 6.6.0
- *
- * @param {MouseEvent} event Les données du clic.
- *
- * @TODO: Mieux définir cette méthode.
- */
-window.eoxiaJS.digirisk.causerie.saveSignatureURL = function( event ) {
- event.preventDefault();
- if ( jQuery( '.step-4' ).length ) {
- var allNotEmpty = true;
- jQuery( '.step-4 .signature-image').each(function () {
- if ( jQuery( this ).attr( 'data-url') == '' ) {
- allNotEmpty = false;
+ init: function( event, $ ) {
+ digi_user_import.$ = $;
+ if ( event || event === undefined ) {
+ digi_user_import.event();
+ }
+ },
+
+ event: function() {
+ digi_user_import.$( document ).on( 'submit', '#digi-data-import-user #digi-export-form', function( event ) { digi_user_import.create_export( event, digi_user_import.$( this ) ); } );
+ digi_user_import.$( document ).on( 'change', '#digi-data-import-user #digi-import-form input[type="file"]', function( event ) { digi_user_import.make_import( event, digi_user_import.$( this ) ); } );
+ },
+
+ create_export: function( event, element ) {
+ event.preventDefault();
+ digi_user_import.$( element ).closest( 'form' ).ajaxSubmit( {
+ 'beforeSubmit': function() {
+ digi_user_import.$( element ).closest( '.wp-digi-bloc-loader' ).addClass( "wp-digi-bloc-loading" );
+ },
+ success: function( response ) {
+ digi_user_import.$( element ).closest( '.wp-digi-bloc-loader' ).removeClass( "wp-digi-bloc-loading" );
+ window.digi_global.download_file( response.data.url_to_file, response.data.filename );
}
- });
- if (allNotEmpty) {
- jQuery('.step-4 a.button-disable').removeClass('button-disable');
+ } );
+ },
+
+ make_import: function( event, element ) {
+ event.preventDefault();
+
+ var data = new FormData();
+ data.append( 'file', digi_user_import.$( element )[0].files[0] );
+ data.append( 'action', 'digi_import_user' );
+ data.append( '_wpnonce', digi_user_import.$( element ).closest('form').find( 'input[name="_wpnonce"]' ).val() );
+ data.append( 'index_element', 0 );
+
+ digi_user_import.request_import( data );
+ },
+
+ request_import: function( data ) {
+ digi_user_import.$.ajax( {
+ url: ajaxurl,
+ data: data,
+ processData: false,
+ contentType: false,
+ type: 'POST',
+ beforeSend: function() {
+ digi_user_import.$('.digi-import-detail').html( window.digi_tools_in_progress );
+ },
+ success: function(response) {
+ if ( response.success ) {
+ if ( !response.data.end ) {
+ var data = new FormData();
+ data.append( 'action', 'digi_import_user' );
+ data.append( '_wpnonce', digi_user_import.$( '#digi-data-import-user #digi-import-form' ).find( 'input[name="_wpnonce"]' ).val() );
+ data.append( 'index_element', response.data.index_element );
+ data.append( 'count_element', response.data.count_element );
+ data.append( 'path_to_csv', response.data.path_to_csv );
+ digi_user_import.$('.digi-import-detail').html( window.digi_tools_in_progress );
+ digi_user_import.request_import(data);
+ }
+ else {
+ digi_user_import.$('.digi-import-detail').html( window.digi_tools_done );
+ }
- }
- } else {
- jQuery('.modal-signature').find('canvas').each(function () {
- if (!jQuery(this)[0].signaturePad.isEmpty()) {
- jQuery(this).closest('div').find('input:first').val(jQuery(this)[0].toDataURL());
- jQuery('.step-1 .action-input[data-action="next_step_causerie"]').removeClass('button-disable');
+ digi_user_import.$('progress').attr( 'max', response.data.count_element );
+ digi_user_import.$('progress').val( ( response.data.index_element / response.data.count_element ) * response.data.count_element );
+
+ }
+ else {
+ alert( 'Problème lors de l\'importation du modèle' );
+ digi_installer.$( '#digi-data-export' ).removeClass( "wp-digi-bloc-loading" );
+ }
}
- });
+ } );
}
};
+jQuery( document ).ready(function( $ ) {
+ digi_user_import.init( true, $ );
+});
+
/**
- * Appliques la signature.
- *
- * @since 6.6.0
- *
- * @param {[type]} element [description]
- * @return {boolean} [description]
+ * Initialise l'objet "user" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
*
- * @TODO: Mieux définir cette méthode.
+ * @since 6.0.0
+ * @version 6.2.4
*/
-window.eoxiaJS.digirisk.causerie.applySignature = function( element ) {
- if ( ! element.closest( '.wpeo-modal' ).find( 'canvas' )[0].signaturePad.isEmpty() ) {
- element.closest( '.wpeo-modal' ).find( 'input[name="signature_data"]' ).val( element.closest( '.wpeo-modal' ).find( 'canvas' )[0].toDataURL() );
- }
+window.eoxiaJS.digirisk.user = {};
- return true;
+window.eoxiaJS.digirisk.user.init = function() {
+ window.eoxiaJS.digirisk.user.event();
};
/**
- * Vérifie que la catégorie de risque soit sélectionné avant d'enregistrer la causerie.
- *
- * @since 6.6.0
+ * Initialise l'évènement relatif à la pagination.
*
- * @param {HTMLDivElement} triggeredElement L'élément déclenchant l'action.
+ * @return {void}
*
- * @return {boolean} True pour continuer l'action. False pour stopper l'action.
+ * @since 6.0.0
+ * @version 6.2.4
*/
-window.eoxiaJS.digirisk.causerie.beforeSaveCauserie = function( triggeredElement ) {
- window.eoxiaJS.tooltip.remove( triggeredElement.closest( '.causerie-row' ).find( '.category-danger.wpeo-tooltip-event' ) );
-
- // Vérification du danger.
- if ( '-1' === triggeredElement.closest( '.causerie-row' ).find( 'input[name="risk_category_id"]' ).val() ) {
- window.eoxiaJS.tooltip.display( triggeredElement.closest( '.causerie-row' ).find( '.category-danger.wpeo-tooltip-event' ) );
- return false;
- }
-
- return true;
+window.eoxiaJS.digirisk.user.event = function() {
+ jQuery( document ).on( 'click', '.form-edit-user-assign .wp-digi-pagination a', window.eoxiaJS.digirisk.user.pagination );
+ jQuery( document ).on( 'keyup', '#digi-phone-number', window.eoxiaJS.digirisk.user.updatePhoneNumber );
};
/**
- * Le callback en cas de réussite à la requête Ajax "edit_causerie".
- * Remplaces le contenu du tableau par la vue renvoyée par la réponse Ajax.
- *
- * @since 6.6.0
+ * Le callback en cas de réussite à la requête Ajax "edit_user_assign".
+ * Appel la méthode render de l'objet user avec la réponse de la requête Ajax.
*
* @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
* @param {Object} response Les données renvoyées par la requête Ajax.
* @return {void}
- */
-window.eoxiaJS.digirisk.causerie.editedCauserieSuccess = function( triggeredElement, response ) {
- triggeredElement.closest( '.tab-content' ).html( response.data.view );
-};
-
-/**
- * Le callback en cas de réussite à la requête Ajax "load_causerie".
- * Remplaces le contenu de la ligne du tableau "causerie" par le template renvoyé par la requête Ajax.
- *
- * @since 6.6.0
*
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
- * @return {void}
+ * @since 6.0.0
+ * @version 6.2.4
*/
-window.eoxiaJS.digirisk.causerie.loadedCauserieSuccess = function( element, response ) {
- jQuery( element ).closest( '.table-row' ).replaceWith( response.data.view );
+window.eoxiaJS.digirisk.user.editUserAssignSuccess = function( triggeredElement, response ) {
+ window.eoxiaJS.digirisk.user.render( response );
};
/**
- * Le callback en cas de réussite à la requête Ajax "delete_causerie".
- * Supprimes la ligne du tableau.
- *
- * @since 6.6.0
+ * Le callback en cas de réussite à la requête Ajax "detach_user".
+ * Appel la méthode render de l'objet user avec la réponse de la requête Ajax.
*
* @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
* @param {Object} response Les données renvoyées par la requête Ajax.
* @return {void}
+ *
+ * @since 6.0.0
+ * @version 6.2.4
*/
-window.eoxiaJS.digirisk.causerie.deletedCauserieSuccess = function( element, response ) {
- element.closest( '.table-row' ).fadeOut();
+window.eoxiaJS.digirisk.user.detachUserSuccess = function( triggeredElement, response ) {
+ window.eoxiaJS.digirisk.user.render( response );
};
/**
- * Le callback en cas de réussite à la requête Ajax "save_final_causerie_step_1".
- *
- * @since 6.6.0
+ * Remplaces le contenu de la section ".users" avec la réponse de la requête Ajax de editUserAssignSuccess et detachUserSuccess.
*
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
* @return {void}
+ *
+ * @since 6.0.0
+ * @version 6.2.5.0
*/
-window.eoxiaJS.digirisk.causerie.nextStep = function( element, response ) {
- jQuery( '.ajax-content' ).html( response.data.view );
+window.eoxiaJS.digirisk.user.render = function( response ) {
+ jQuery( 'section.users' ).replaceWith( response.data.template );
+ window.eoxiaJS.digirisk.render.call_render_changed();
+};
- var currentStep = response.data.current_step;
- var percent = 0;
+window.eoxiaJS.digirisk.user.pagination = function( event ) {
+ event.preventDefault();
- if ( 2 === currentStep ) {
- percent = 37;
- } else if ( 3 === currentStep ) {
- percent = 62;
- }else if( 4 === currentStep ) {
- percent = 100;
- }else{
- percent = 0;
- }
+ var href = jQuery( this ).attr( 'href' ).split( '&' );
+ var next_page = href[1].replace('current_page=', '');
+ var element_id = href[2].replace('element_id=', '');
- if ( jQuery( '.main-content' ).hasClass( 'step-1' ) ) {
- jQuery( '.main-content' ).removeClass( 'step-1' ).addClass( 'step-2' );
- } else if ( jQuery( '.main-content' ).hasClass( 'step-2' ) ) {
- jQuery( '.main-content' ).removeClass( 'step-2' ).addClass( 'step-3' );
- }else if ( jQuery( '.main-content' ).hasClass( 'step-3' ) ) {
- jQuery( '.main-content' ).removeClass( 'step-3' ).addClass( 'step-4' );
- }
+ var data = {
+ action: 'paginate_user',
+ element_id: element_id,
+ next_page: next_page
+ };
- jQuery( '.causerie-wrap .bar .loader' ).css( 'width', percent + '%' );
- jQuery( '.causerie-wrap .bar .loader' ).attr( 'data-width', percent );
- jQuery( '.causerie-wrap .step-list .step[data-width="' + percent + '"]' ).addClass( 'active' );
+ jQuery( '.form-edit-user-assign' ).addClass( 'loading' );
- window.eoxiaJS.refresh();
+ jQuery.post( window.ajaxurl, data, function( view ) {
+ jQuery( '.form-edit-user-assign' ).replaceWith( view );
+ } );
};
-
+
+window.eoxiaJS.digirisk.user.updatePhoneNumber = function( event ) {
+ console.log( jQuery( this ) );
+ console.log( "------" );
+}
+
/**
- * Ajoutes la nouvelle ligne du participant dans le tableau.
- *
- * @since 6.6.0
- *
- * @param {HTMLDivElement} element Le bouton déclencahd l'action AJAX.
- * @param {Object} response Les données reçu dans le formulaire.
+ * Initialise l'objet "userDashboard" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
*
- * @return {void}
+ * @since 6.0.0
+ * @version 6.4.0
*/
-window.eoxiaJS.digirisk.causerie.savedParticipant = function( element, response ) {
- jQuery( '.ajax-content' ).html( response.data.view );
- window.eoxiaJS.digirisk.causerie.checkParticipantsSignature();
+window.eoxiaJS.digirisk.userDashboard = {};
- // window.eoxiaJS.refresh();
+window.eoxiaJS.digirisk.userDashboard.init = function() {
+ window.eoxiaJS.digirisk.userDashboard.event();
};
/**
- * Vérifie si toutes les signatures sont présentes dans le tableau.
- * Si toutes les signatures sont présentes, le bouton pour cloturer la causerie est cliquable.
- * Sinon, si une signature est manquante, le bouton est grisé.
+ * Intialise les évènements.
*
- * @since 6.6.0
+ * @since 6.0.0
+ * @version 6.4.0
*
- * @return {boolean}
+ * @return {void}
*/
-window.eoxiaJS.digirisk.causerie.checkParticipantsSignature = function() {
- var allSignature = true
+window.eoxiaJS.digirisk.userDashboard.event = function() {
+ jQuery( document ).on( 'keyup', '.user-dashboard .input-domain-mail', window.eoxiaJS.digirisk.userDashboard.keyupUpdateEmail );
+ jQuery( document ).on( 'keyup', '.user-dashboard .wpeo-table.users .table-row:last input.lastname', window.eoxiaJS.digirisk.userDashboard.keyupUpdateEmail );
+ jQuery( document ).on( 'keyup', '.user-dashboard .wpeo-table.users .table-row:last input.firstname', window.eoxiaJS.digirisk.userDashboard.keyupUpdateEmail );
+ jQuery( document ).on( 'keyup', '.user-dashboard .wpeo-table.users .table-row input', window.eoxiaJS.digirisk.userDashboard.keyEnterSendForm );
+ jQuery( document ).on( 'keyup', '.user-dashboard .input-domain-mail', window.eoxiaJS.digirisk.userDashboard.keyEnterSendFormDomainMail );
- if ( '.step-4 input[name="signature_data"]'.length ) {
- jQuery( '.step-4 input[name="signature_data"]' ).each( function() {
- if ( ! jQuery( this ).val() ) {
- allSignature = false;
- return false;
- }
- } );
- }
+ jQuery( document ).on( 'keyup', '.user-dashboard .wpeo-table.users .table-row:last input.lastname', window.eoxiaJS.digirisk.userDashboard.changeColorInputSubmit );
+ jQuery( document ).on( 'keyup', '.user-dashboard .wpeo-table.users .table-row:last input.firstname', window.eoxiaJS.digirisk.userDashboard.changeColorInputSubmit );
+ jQuery( document ).on( 'keyup', '.user-dashboard .wpeo-table.users .table-row:last input.email', window.eoxiaJS.digirisk.userDashboard.changeColorInputSubmit );
- if ( allSignature ) {
- jQuery( '.step-4 a.disabled' ).removeClass( 'disabled wpeo-tooltip-event' );
- } else {
- jQuery( '.step-4 a.disabled' ).addClass( 'disabled wpeo-tooltip-event' );
- }
+ jQuery( document ).on( 'click', '.user-dashboard .wp-digi-action-save-domain-mail', window.eoxiaJS.digirisk.userDashboard.save_domain_mail );
};
/**
- * Remplaces le contenu de la ligne déclenchant cette action.
- * Cette action est déclenché lorsqu'un participant signe dans la modal.
- *
- * Cette méthode appelle la méthode "checkParticipantsSignature" afin de vérifier
- * si le bouton "cloturer la causerie" peut être cliquable.
- *
- * @since 6.6.0
- * @version 6.6.0
- *
- * @param {HTMLDivElement} element Le bouton déclenchant l'action.
- * @param {Object} response La réponse de la requête avec la vue.
+ * Vérifie si le domaine de l'email a un format valide.
*
+ * @param {HTMLDivElement} triggeredElement
* @return {void}
+ *
+ * @since 6.2.5
+ * @version 6.2.5
*/
-window.eoxiaJS.digirisk.causerie.savedSignature = function( element, response ) {
- element.closest( '.table-row' ).replaceWith( response.data.view );
-
- window.eoxiaJS.digirisk.causerie.checkParticipantsSignature();
-
- // window.eoxiaJS.digirisk.causerie.refresh();
+window.eoxiaJS.digirisk.userDashboard.checkDomainEmailValid = function( triggeredElement ) {
+ if ( ! window.regex.validateEndEmail( triggeredElement.closest( '.email-domain' ).find( 'input[type="text"]' ).val() ) ) {
+ triggeredElement.closest( '.email-domain' ).find( 'label' ).addClass( 'active' );
+ return false;
+ } else {
+ triggeredElement.closest( '.email-domain' ).find( 'label' ).removeClass( 'active' );
+ return true;
+ }
};
/**
- * Remplaces le contenu de la ligne déclenchant cette action.
- * Cette action est déclenché lorsqu'un participant signe dans la modal.
- *
- * Cette méthode appelle la méthode "checkParticipantsSignature" afin de vérifier
- * si le bouton "cloturer la causerie" peut être cliquable.
- *
- * @since 6.6.0
- * @version 6.6.0
+ * Envoies une requête pour enregister le domaine de l'email.
*
- * @param {HTMLDivElement} element Le bouton déclenchant l'action.
- * @param {Object} response La réponse de la requête avec la vue.
+ * @param {ClickEvent} event L'état de la souris lors du clic sur le bouton.
*
* @return {void}
+ *
+ * @since 6.0.0
+ * @version 6.2.5
*/
-window.eoxiaJS.digirisk.causerie.savedFormerSignature = function( element, response ) {
- element.closest( '.table-row' ).find( '.signature' ).replaceWith( response.data.view );
+window.eoxiaJS.digirisk.userDashboard.save_domain_mail = function( event ) {
+ var element = jQuery( this );
+ var data = {};
- // window.eoxiaJS.digirisk.causerie.refresh();
+ event.preventDefault();
+
+ data = {
+ action: 'save_domain_mail',
+ _wpnonce: element.data( 'nonce' ),
+ domain_mail: element.closest( '.form-element' ).find( 'input' ).val()
+ };
+
+ jQuery.post( window.ajaxurl, data );
};
/**
- * Vérifie que l'utilisateur et que la signature soit bien présente dans le formulaire.
- *
- * @since 6.6.0
+ * Lors qu'une touche est en status "keyup" on met à jour le champ de texte "email" avec les données du champs de texte "nom", "prénom" et "Domaine de l'email".
*
- * @param {[type]} element [description]
+ * @param {KeyEvent} event L'état du clavier lors de l'évènement "keyup"
* @return {void}
+ *
+ * @since 6.0.0
+ * @version 6.2.5
*/
-window.eoxiaJS.digirisk.causerie.checkAllData = function( element ) {
- jQuery( '.step-1 .former-tooltip' ).removeClass( 'active' );
- jQuery( '.step-1 .signature-tooltip' ).removeClass( 'active' );
+window.eoxiaJS.digirisk.userDashboard.keyupUpdateEmail = function( event ) {
+ var email = jQuery( '.user-dashboard .wpeo-table.users .table-row:last .email' ).val();
+ var firstname = jQuery( '.user-dashboard .wpeo-table.users .table-row:last .firstname' ).val();
+ var lastname = jQuery( '.user-dashboard .wpeo-table.users .table-row:last .lastname' ).val();
+ var domainMail = jQuery( '.input-domain-mail' ).val();
+ var together = window.eoxiaJS.global.removeDiacritics( firstname + '.' + lastname + '@' + domainMail ).toLowerCase();
- if ( ! jQuery( '.step-1 input[name="former_id"]' ).val() ) {
- jQuery( '.step-1 .former-tooltip' ).addClass( 'active' );
+ jQuery( '.user-dashboard .wpeo-table.users .table-row:last input[name="email"]' ).val( together );
- return false;
+ // Vérifie que l'évènement n'est pas déclenché dans le champ de texte du domaine de l'email.
+ if ( 'input-domain-mail' !== event.target.className ) {
+ window.eoxiaJS.digirisk.userDashboard.keyEnterSendForm( event, jQuery( this ) );
}
+};
- if ( ! jQuery( '.step-1 input[name="have_signature"]' ).length ) {
- jQuery( '.step-1 .signature-tooltip' ).addClass( 'active' );
+/**
+ * Si la touche "entrée" est appuyé, appuies sur le bouton "plus" pour ajouter un utilisateur.
+ *
+ * @param {KeyEvent} event L'état du clavier lors de l'évènement "keyup"
+ * @return {void}
+ *
+ * @since 6.0.0
+ * @version 6.4.0
+ */
+window.eoxiaJS.digirisk.userDashboard.keyEnterSendForm = function( event ) {
+ if ( 13 === event.keyCode ) {
+ jQuery( this ).closest( '.user-row' ).find( '.action-input' ).click();
+ event.preventDefault();
return false;
}
-
- return true;
};
/**
- * Vérifie que l'ID de l'utilisateur soit bien présente dans le formulaire.
- *
- * @since 6.6.0
+ * Si la touche "entrée" est appuyé, appuies sur le bouton "plus" pour enregistrer le domaine de l'email.
*
- * @param {HTMLDivElement} element Le bouton déclenchant cette méthode.
+ * @param {KeyEvent} event L'état du clavier lors de l'évènement "keyup"
+ * @return {void}
*
- * @return {boolean} True si le formateur à été choisi, sinon false pour stopper la requête XHR.
+ * @since 6.4.0
+ * @version 6.4.0
*/
-window.eoxiaJS.digirisk.causerie.checkUserID = function( element ) {
- element.closest( '.table-row' ).find( '.user-tooltip' ).removeClass( 'active' );
-
- if ( ! element.closest( '.table-row' ).find( 'input[name="participant_id"]' ).val() ) {
- element.closest( '.table-row' ).find( '.user-tooltip' ).addClass( 'active' );
+window.eoxiaJS.digirisk.userDashboard.keyEnterSendFormDomainMail = function( event ) {
+ if ( 13 === event.keyCode ) {
+ jQuery( this ).closest( '.form' ).find( '.action-input' ).click();
+ event.preventDefault();
return false;
}
-
- return true;
};
-window.eoxiaJS.digirisk.causerie.addKeywordToTextarea = function( event ){
- var importContent = jQuery( this ).closest( '.digi-import-causeries.modal-active' ).find( 'textarea' );
- if( jQuery( this ).attr( 'data-type' ) == "link" ){
- window.eoxiaJS.digirisk.causerie.buttonLinkExternalText( jQuery( this ), importContent );
- }else{
- if( jQuery( this ).attr( 'data-type' ) != "" && jQuery( this ).attr( 'data-type' ) != null ){
- var keyword = '%' + jQuery( this ).attr( 'data-type' ) + '% ';
- importContent.focus().val( importContent.val() + '\r\n' + keyword );
- }
- }
-}
-
-window.eoxiaJS.digirisk.causerie.itemSelectToTextarea = function( event ){
- var keyword = jQuery( this ).attr( 'aria-label' );
- var importContent = jQuery( this ).closest( '.digi-import-causeries.modal-active' ).find( 'textarea' );
- importContent.val( importContent.val() + '\r\n' + '%risque%' + keyword );
-}
-
-window.eoxiaJS.digirisk.causerie.buttonLinkExternalText = function( element, importContent ){
-
- if( element.closest( '.digi-import-add-keyword' ).find( '.digi-info-import-link input' ).attr( 'data-import' ) == "true" ){
- var data = {};
- data.action = 'get_text_from_url';
- data.content = element.closest( '.digi-import-add-keyword' ).find( '.digi-info-import-link input' ).val(); // On recupere le contenu
-
- window.eoxiaJS.loader.display( jQuery( '.digi-import-add-keyword' ) );
- window.eoxiaJS.request.send( element, data );
- }else{
- if( element.attr( 'data-link' ) == "no"){
- element.find( '.digi_save_backup' ).val( importContent.val() ); // On recupere le contenu
-
- var next_step = 'yes';
- element.removeClass( 'button-grey' ).addClass( 'button-green' );
- element.closest( '.digi-import-add-keyword' ).find( '.digi-info-import-link' ).show( '200' );
- }else{
- importContent.focus().val( element.find( '.digi_save_backup' ).val() );
-
- var next_step = 'no';
- element.removeClass( 'button-green' ).addClass( 'button-grey' );
- element.closest( '.digi-import-add-keyword' ).find( '.digi-info-import-link' ).hide( '200' );
- }
- element.attr( 'data-link', next_step );
- element.find( '.digi_link_external' ).val( next_step );
- }
-}
-
-window.eoxiaJS.digirisk.causerie.updateImportTextFromUrl = function( event ){
- if( jQuery( this ).val().trim() != "" ){
- jQuery( this ).closest( '.digi-import-add-keyword' ).find( '.digi-icon-import-from-url' ).removeClass( 'fa-link' ).addClass( 'fa-file-import' );
- jQuery( this ).attr( 'data-import', "true" );
- }else{
- jQuery( this ).closest( '.digi-import-add-keyword' ).find( '.digi-icon-import-from-url' ).removeClass( 'fa-file-import' ).addClass( 'fa-link' );
- jQuery( this ).attr( 'data-import', "false" );
- }
-}
-
-window.eoxiaJS.digirisk.causerie.get_content_from_url_to_import_textarea = function( element, response ){
- if( response.data.error == "" ){
- element.closest( '.tm-import-tasks.modal-active' ).find( 'textarea' ).val( response.data.content );
- }
-
- element.closest( '.digi-import-add-keyword' ).find( '.digi-info-import-link input' ).val( '' );
- element.removeClass( 'button-green' ).addClass( 'button-grey' );
- element.closest( '.digi-import-add-keyword' ).find( '.digi-info-import-link' ).hide( '200' );
-
- element.attr( 'data-link', "no" );
- element.find( '.digi_link_external' ).val( "no" );
-}
/**
- * Le callback en cas de réussite à la requête Ajax "delete_started_causerie".
- * Remplaces le contenu du tableau par la vue renvoyée par la réponse Ajax.
- *
- * @since 7.3.0
+ * Si la ligne a un contenu, change la couleur du bouton.
*
- * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
- * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @param {KeyboardEvent} event L'état du clavier.
* @return {void}
+ *
+ * @since 6.2.6
+ * @version 6.4.0
*/
-window.eoxiaJS.digirisk.causerie.deletedStartedCauserie = function( triggeredElement, response ) {
- triggeredElement.closest( '.causerie-row' ).fadeOut();
-};
-
-window.eoxiaJS.digirisk.causerie.getContentFromUrl = function( triggeredElement, response ){
- var data = response.data.response_git;
-
- if( data.success ){
- triggeredElement.closest( '.modal-container' ).find( '.digi-view-git' ).html( response.data.view );
-
- }else{
- triggeredElement.closest( '.modal-footer-view-git' ).find( '.digi-info-git-error' ).show();
- triggeredElement.closest( '.modal-footer-view-git' ).find( '.digi-info-git-error .notice-title' ).html( response.data.error );
- }
-}
-
-window.eoxiaJS.digirisk.causerie.importGitContent = function( event ){
- var url = jQuery( this ).closest( '.digi-import-add-keyword' ).find( '.import-git-input input[type="text"]' );
- var textarea_element = jQuery( this ).closest( '.digi-view-textarea' );
-
- var data = {};
- data.url = url;
- data.action = jQuery( this ).attr( 'data-action' );
- data._wpnonce = jQuery( this ).attr( 'data-nonce' );
- data.url = jQuery( this ).attr( 'data-url' );
-
- window.eoxiaJS.loader.display( jQuery( this ).parent() );
- window.eoxiaJS.request.send( jQuery( this ), data );
-}
-
-window.eoxiaJS.digirisk.causerie.importPictureToMediaSuccess = function( triggeredElement, response ){
- var success_element = triggeredElement.closest( '.modal-container' ).find( '.digi-info-git-success' );
- if( response.data.id > 0 ){
- triggeredElement.removeClass( 'action-attribute' );
- triggeredElement.removeClass( 'button-green' ).addClass( 'button-grey' );
- triggeredElement.html( ' ' );
- triggeredElement.closest( '.table-row' ).css( 'border', 'solid 2px green' );
-
- var id = " (#" + response.data.id + ")";
- success_element.html( ' ' + response.data.text_info + id + ' ' );
- success_element.show();
-
- triggeredElement.closest( '.modal-container' ).find( '.modal-footer-view-git .digi-footer-git-import' ).hide();
- triggeredElement.closest( '.modal-container' ).find( '.modal-footer-view-git .digi-footer-git-display' ).show();
-
-
-
- triggeredElement.closest( '.modal-container' ).find( '.digi-display-view-git [data-display="git"]' ).attr( 'data-buttongit', true );
- var str = triggeredElement.closest( '.modal-container' ).find( '.digi-display-view-git [name="contentgit"]' ).val();
- triggeredElement.closest( '.modal-container' ).find( '.digi-display-view-git [name="contentgit"]' ).val( str + '\r\n' + response.data.content );
-
- triggeredElement.attr( 'data-alreadydl', 'true' );
-
- var nbr = triggeredElement.closest( '.modal-container' ).find( '.digi-import-git-success .digi-number-picture' ).html();
- nbr = parseInt( nbr ) - 1;
- if( nbr > 0 ){
- triggeredElement.closest( '.modal-container' ).find( '.digi-import-git-success .digi-number-picture' ).html( nbr );
- }else{
- triggeredElement.closest( '.modal-container' ).find( '.digi-import-git-success .digi-picture-download' ).hide( '200' );
- }
+window.eoxiaJS.digirisk.userDashboard.changeColorInputSubmit = function( event ) {
+ var row = jQuery( this ).closest( '.table-row' );
+ if ( row.find( 'input[name="firstname"]' ).val() && row.find( 'input[name="lastname"]' ).val() && row.find( 'input[name="email"]' ).val() ) {
+ row.find( '.action .wpeo-button.button-disable' ).removeClass( 'button-disable' );
+ } else {
+ row.find( '.action .wpeo-button' ).addClass( 'button-disable' );
}
-}
-
-window.eoxiaJS.digirisk.causerie.importTxtToTextareaSuccess = function( triggeredElement, response ){
- triggeredElement.closest( '.modal-content' ).find( '.digi-view-textarea [name="content"]' ).val( response.data.content );
-
- var success_element = triggeredElement.closest( '.modal-container' ).find( '.digi-info-git-success' );
+};
- success_element.html( response.data.text_info );
- success_element.show();
-}
+/**
+ * Vérifie si les données du formulaire ne soit pas vide.
+ * Toutes les données sont obligatoires.
+ *
+ * @since 6.4.0
+ * @version 6.4.0
+ *
+ * @param {HTMLDivElement} element Le bouton déclenchant l'action.
+ * @return {boolean} True ou false.
+ */
+window.eoxiaJS.digirisk.userDashboard.checkData = function( element ) {
+ var row = element.closest( '.table-row' );
-window.eoxiaJS.digirisk.causerie.txtHiddenGitToTextArea = function( event ){
- var gitstr = jQuery( this ).find( '[name ="contentgit"]' ).val();
- var str = jQuery( this ).closest( '.modal-container').find( '.digi-view-textarea textarea[ name="content" ]' ).val();
- jQuery( this ).closest( '.modal-container').find( '.digi-view-textarea textarea[ name="content" ]' ).val( str + gitstr );
-}
+ row.find( '.tooltip.active' ).removeClass( 'active' );
-window.eoxiaJS.digirisk.causerie.importAllPictureToMedia = function( event ){
- var button_element = jQuery( this );
- jQuery( this ).closest( '.digi-view-git' ).find( '.digi-display-response-git .table-row .digi-this-is-a-picture' ).each( function( e ){
- if( jQuery( this ).attr( 'data-alreadydl' ) == "false" ){
- jQuery( this ).attr( 'data-alreadydl', 'true' );
+ if ( '' === row.find( 'input[name="lastname"]' ).val() ) {
+ row.find( 'input[name="lastname"]' ).closest( '.tooltip' ).addClass( 'active' );
+ return false;
+ }
- var data = {};
- data.filename = jQuery( this ).attr( 'data-filename' );
- data.url = jQuery( this ).attr( 'data-url' );
- data.action = jQuery( this ).attr( 'data-action' );
- data._wpnonce = jQuery( this ).attr( 'data-nonce' );
- data.url = jQuery( this ).attr( 'data-url' );
+ if ( '' === row.find( 'input[name="firstname"]' ).val() ) {
+ row.find( 'input[name="firstname"]' ).closest( '.tooltip' ).addClass( 'active' );
+ return false;
+ }
- window.eoxiaJS.loader.display( jQuery( this ).parent() );
- window.eoxiaJS.request.send( jQuery( this ), data );
- }
- })
-}
+ if ( '' === row.find( 'input[name="email"]' ).val() ) {
+ row.find( 'input[name="email"]' ).closest( '.tooltip' ).addClass( 'active' );
+ return false;
+ }
-window.eoxiaJS.digirisk.causerie.displayImportGitInput = function( event ){
- jQuery( this ).closest( '.modal-footer' ).find( '.modal-footer-view-git .digi-footer-git-import' ).show();
- jQuery( this ).closest( '.modal-footer' ).find( '.modal-footer-view-git .digi-info-git-success' ).hide();
- jQuery( this ).hide();
-}
+ return true;
+};
-window.eoxiaJS.digirisk.causerie.executeTxtToTextareaSuccess = function( triggeredElement, response ){
- triggeredElement.closest( '.modal-container' ).find( '.view-git-element' ).hide( '200' );
- triggeredElement.closest( '.modal-container' ).find( '.digi-view-execute' ).show();
- triggeredElement.closest( '.modal-container' ).find( '.digi-content-execute' ).html( response.data.view );
- triggeredElement.closest( '.modal-container' ).find( '.digi-footer-execute' ).html( response.data.view_footer );
-}
+/**
+ * Le callback en cas de réussite à la requête Ajax "delete_user".
+ * Supprimes la ligne de l'utilisateur.
+ *
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
+ *
+ * @since 6.0.0
+ * @version 6.2.5
+ */
+window.eoxiaJS.digirisk.userDashboard.deletedUserSuccess = function( element, response ) {
+ element.closest( '.table-row' ).fadeOut();
+};
-window.eoxiaJS.digirisk.causerie.displayImportGitFromExecute = function( event ){
- jQuery( this ).closest( '.modal-container' ).find( '.view-git-element' ).show( '200' );
- jQuery( this ).closest( '.modal-container' ).find( '.digi-view-execute' ).hide();
-}
+/**
+ * Le callback en cas de réussite à la requête Ajax "load_user".
+ * Remplaces la vue de la ligne.
+ *
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
+ *
+ * @since 6.0.0
+ * @version 6.2.5
+ */
+window.eoxiaJS.digirisk.userDashboard.loadedUserSuccess = function( element, response ) {
+ element.closest( '.table-row' ).replaceWith( response.data.template );
+};
+/**
+ * Le callback en cas de réussite à la requête Ajax "save_user".
+ * Remplaces le contenu du tableau "users" par le template renvoyé par la requête Ajax.
+ *
+ * Si response.data.error est égale à true, affiches le tooltip disant "Cette adresse email est déjà utilisée."
+ *
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
+ * @return {void}
+ *
+ * @since 6.0.0
+ * @version 6.4.0
+ */
+window.eoxiaJS.digirisk.userDashboard.savedUserSuccess = function( element, response ) {
+ jQuery( '.user-dashboard .wpeo-table.users .email-already-used' ).hide();
-window.eoxiaJS.digirisk.causerie.importModalExecuteIt = function ( event ){
+ if ( response.data.error ) {
+ jQuery( '.user-dashboard .wpeo-table.users .email-already-used' ).show();
+ } else {
+ jQuery( '.user-dashboard .wpeo-table.users' ).html( response.data.template );
+ jQuery( '.user-dashboard .wpeo-table.users .table-row:last input.lastname' ).focus();
+ }
+};
+
+"use strict";
- var content = '';
- jQuery( this ).closest( '.modal-container' ).find('.digi-view-execute .digi-import-execute-success' ).each( function( e ){
- content += jQuery( this ).find( 'span' ).html();
- })
+var digi_user_detail = {
+ $: undefined,
+ event: function($) {
+ digi_user_detail.$ = $;
+ digi_user_detail.$( document ).on( 'click', '#wp-digi-form-add-staff .wp-digi-action-view-detail', function( event ) { digi_user_detail.load_staff_detail( event, digi_user_detail.$( this ) ); } );
+ digi_user_detail.$( document ).on( 'click', '.user-detail .load-data', function (event ) { digi_user_detail.load_data( event, digi_user_detail.$( this ) ); } );
+ },
- var request_data = {};
- request_data.action = 'execute_git_txt';
- request_data.content = content;
- request_data._wpnonce = jQuery( this ).attr( 'data-nonce' );
+ load_staff_detail: function( event, element ) {
+ event.preventDefault();
- window.eoxiaJS.loader.display( jQuery( this ) );
- window.eoxiaJS.request.send( jQuery( this ), request_data );
-}
+ var user_id = digi_user_detail.$( element ).data( 'id' );
+ var _wpnonce = digi_user_detail.$( element ).data( 'nonce' );
-window.eoxiaJS.digirisk.causerie.executeGitTxtSuccess = function ( triggeredElement, response ){
- triggeredElement.closest( '.modal-container' ).find( '.tab-content' ).html( response.data.view );
-}
+ var data = {
+ action: 'load_user_detail',
+ _wpnonce: _wpnonce,
+ user_id: user_id
+ };
-window.eoxiaJS.digirisk.causerie.tabSelectRedirect = function( event ){
- var url = jQuery( this ).attr( 'data-url' );
- window.location.href = url;
-}
+ digi_user_detail.$( '.user-detail' ).addClass( 'wp-digi-bloc-loading' );
+ digi_user_detail.$.post( window.ajaxurl, data, function( response ) {
+ digi_user_detail.$( '.user-detail' ).replaceWith( response.data.template );
+ });
+ },
-window.eoxiaJS.digirisk.causerie.deletedAccidentSuccess = function( triggeredElement, response ){
- triggeredElement.closest( '.causerie-row' ).hide( '200' );
-}
+ load_data: function( event, element ) {
+ var user_id = digi_user_detail.$( element ).closest( 'ul' ).data( 'user-id' );
+ var _wpnonce = digi_user_detail.$( element ).closest( 'ul' ).data( 'nonce' );
+ var data_name = digi_user_detail.$ (element ).data( 'name' );
-window.eoxiaJS.digirisk.causerie.causerieImportTxtFromUrl = function( triggeredElement, response ){
- if( response.data.view != "" ){
- var parent_element = triggeredElement.closest( '.digi-view-textarea' );
- parent_element.find( '.digi-import-add-keyword' ).hide();
- parent_element.find( '.digi-import-modal-content-main' ).hide();
- parent_element.find( '.digi-import-modal-content-main textarea' ).val( response.data.content );
+ var data = {
+ action: 'load_data',
+ _wpnonce: _wpnonce,
+ user_id: user_id,
+ data_name: data_name
+ };
- parent_element.find( '.digi-import-modal-content-git' ).show();
- parent_element.find( '.digi-import-modal-content-git' ).html( response.data.view );
+ digi_user_detail.$( '.user-detail .wp-digi-list' ).addClass( 'wp-digi-bloc-loading' );
- triggeredElement.closest( '.modal-container' ).find( '.digi-button-import-git' ).show();
- triggeredElement.closest( '.modal-container' ).find( '.digi-button-import' ).hide();
+ digi_user_detail.$.post( window.ajaxurl, data, function( response ) {
+ digi_user_detail.$( '.user-detail .wp-digi-list' ).replaceWith( response.data.template );
+ });
}
-}
+};
+
+window.eoxiaJS.digirisk.worktype = {};
-window.eoxiaJS.digirisk.causerie.causerieImportDisplayTextarea = function( event ){
- jQuery( this ).closest( '.modal-container' ).find( '.digi-import-modal-content-main' ).show();
- jQuery( this ).closest( '.modal-container' ).find( '.digi-import-add-keyword' ).show();
- jQuery( this ).closest( '.modal-container' ).find( '.digi-button-import' ).show();
+window.eoxiaJS.digirisk.worktype.init = function() {
+ window.eoxiaJS.digirisk.worktype.event();
+};
- jQuery( this ).closest( '.modal-container' ).find( '.digi-import-modal-content-git' ).hide();
- jQuery( this ).closest( '.modal-container' ).find( '.digi-button-import-git' ).hide();
-}
+/**
+ * Initialise deux évènements:
+ * -Lorque qu'une touche du clavier est remontée dans le champ de texte pour ajouter une nouvelle unité de travail.
+ * -Lorsque qu'un clic est effectué sur unité de travail dans le menu de navigation.
+ *
+ * @return {void}
+ *
+ * @since 0.1
+ * @version 6.2.4.0
+ */
+window.eoxiaJS.digirisk.worktype.event = function() {
+
+};
+
+window.eoxiaJS.digirisk.workunit = {};
+window.eoxiaJS.digirisk.workunit.init = function() {
+ window.eoxiaJS.digirisk.workunit.event();
+};
/**
- * Clear le canvas.
+ * Initialise deux évènements:
+ * -Lorque qu'une touche du clavier est remontée dans le champ de texte pour ajouter une nouvelle unité de travail.
+ * -Lorsque qu'un clic est effectué sur unité de travail dans le menu de navigation.
*
- * @since 6.4.0
+ * @return {void}
*
- * @param {Event} event L'état de l'évènement à ce moment T.
+ * @since 0.1
+ * @version 6.2.4.0
+ */
+window.eoxiaJS.digirisk.workunit.event = function() {
+ jQuery( document ).on( 'keyup', '.digirisk-wrap .workunit-add input[type="text"]', window.eoxiaJS.digirisk.workunit.keyEnterSendForm );
+ jQuery( document ).on( 'click', '.digirisk-wrap .workunit-list span[data-action="load_society"]', window.eoxiaJS.digirisk.workunit.setActive );
+};
+
+/**
+ * Cette méthode clic sur le bouton "add" lorsque la touche "entrée" est remontée afin d'ajouter une unité de travail.
+ *
+ * @param {KeyboardEvent} event Contient toutes les valeurs du clavier lorsqu'une touche remonte.
+ * @return void
+ *
+ * @since 0.1
+ * @version 6.2.4.0
+ */
+window.eoxiaJS.digirisk.workunit.keyEnterSendForm = function( event ) {
+ if ( 13 === event.keyCode ) {
+ jQuery( '.digirisk-wrap .workunit-add .add' ).click();
+ }
+};
+
+/**
+ * Le callback en cas de réussite à la requête Ajax "save_workunit".
+ * Remplace le template de l'application en entier et clique sur la nouvelle unité de travail pour la charger.
+ *
+ * @param {HTMLDivElement} triggeredElement L'élement HTML déclenchant la requête Ajax.
+ * @param {Object} response Les données renvoyées par la requête Ajax.
* @return {void}
+ *
+ * @since 0.1
+ * @version 6.2.4.0
*/
-window.eoxiaJS.digirisk.causerie.clearCanvas = function( event ) {
- var canvas = jQuery( this ).closest( '.wpeo-modal' ).find( 'canvas' );
- canvas[0].signaturePad.clear();
+window.eoxiaJS.digirisk.workunit.saved_workunit_success = function( triggeredElement, response ) {
+ jQuery( '.digirisk-wrap' ).replaceWith( response.data.template );
+ jQuery( '.workunit-list .unit-header[data-workunit-id="' + response.data.id + '"] span[data-action="load_society"]' ).click();
+};
+
+/**
+ * Ajoutes la classe "active" à l'unité de travail cliquée.
+ *
+ * @param {ClickEvent} event Contient toutes les valeurs de la souris lors du clic sur l'élément.
+ *
+ * @since 0.1
+ * @version 6.2.4.0
+ */
+window.eoxiaJS.digirisk.workunit.setActive = function( event ) {
+ jQuery( '.digirisk-wrap .workunit-list li.active' ).removeClass( 'active' );
+ jQuery( this ).closest( 'li' ).addClass( 'active' );
+};
+
+window.eoxiaJS.digirisk.ZIP = {};
+
+window.eoxiaJS.digirisk.ZIP.init = function() {
+ window.eoxiaJS.digirisk.ZIP.event();
+};
+
+window.eoxiaJS.digirisk.ZIP.event = function() {
};
diff --git a/digirisk.config.json b/digirisk.config.json
index bf5579b2..b80e5034 100644
--- a/digirisk.config.json
+++ b/digirisk.config.json
@@ -1,7 +1,7 @@
{
"name": "Digirisk",
"slug": "digirisk",
- "version": "7.7.4",
+ "version": "7.7.5",
"description": "L'application Digirisk",
"insert_scripts_pages_js": [
"digirisk-welcome",
diff --git a/digirisk.php b/digirisk.php
index 46187c89..ea389557 100644
--- a/digirisk.php
+++ b/digirisk.php
@@ -3,7 +3,7 @@
* Plugin Name: Digirisk
* Plugin URI: http://www.evarisk.com/document-unique-logiciel
* Description: Avec le plugin Digirisk vous pourrez réaliser, de façon simple et intuitive, le ou les documents uniques de vos entreprises et gérer toutes les données liées à la sécurité de votre personnel.
- * Version: 7.7.4
+ * Version: 7.7.5
* Author: Evarisk
* Author URI: http://www.evarisk.com
* License: AGPLv3
diff --git a/modules/export_import/action/export.action.php b/modules/export_import/action/export.action.php
index 5f91b422..d9d6b362 100644
--- a/modules/export_import/action/export.action.php
+++ b/modules/export_import/action/export.action.php
@@ -30,6 +30,8 @@ public function __construct() {
add_action( 'wp_ajax_digi_export_data', array( $this, 'callback_export_data' ) );
add_action( 'wp_ajax_digi_export_tree_data', array( $this, 'callback_export_tree_data' ) );
add_action( 'wp_ajax_digi_export_risks_data', array( $this, 'callback_export_risks_data' ) );
+ add_action( 'wp_ajax_digi_export_risksigns_data', array( $this, 'callback_export_risksigns_data' ) );
+ add_action( 'wp_ajax_digi_export_global_data', array( $this, 'callback_export_global_data' ) );
}
/**
@@ -73,6 +75,34 @@ public function callback_export_risks_data() {
wp_send_json_success( $response );
}
+
+ /**
+ * Fonction de rappel pour l'export des données des signalisations
+ *
+ * @since 7.7.5
+ * @version 7.7.5
+ */
+ public function callback_export_risksigns_data() {
+ check_ajax_referer( 'digi_export_risksigns_data' );
+
+ $response = Export_Class::g()->exec_risksigns();
+
+ wp_send_json_success( $response );
+ }
+
+ /**
+ * Fonction de rappel pour l'export des données des signalisations
+ *
+ * @since 7.7.5
+ * @version 7.7.5
+ */
+ public function callback_export_global_data() {
+ check_ajax_referer( 'digi_export_global_data' );
+
+ $response = Export_Class::g()->exec_global();
+
+ wp_send_json_success( $response );
+ }
}
new export_action();
diff --git a/modules/export_import/asset/js/export_import.backend.js b/modules/export_import/asset/js/export_import.backend.js
index 65803639..db700600 100644
--- a/modules/export_import/asset/js/export_import.backend.js
+++ b/modules/export_import/asset/js/export_import.backend.js
@@ -38,7 +38,7 @@ window.eoxiaJS.digirisk.export.init = function() {
* @return {void}
*/
window.eoxiaJS.digirisk.export.event = function() {
- jQuery( document ).on( 'submit', '#digi-data-export #digi-export-form, #digi-data-export #digi-export-tree, #digi-data-export #digi-export-risks', window.eoxiaJS.digirisk.export.create_export );
+ jQuery( document ).on( 'submit', '#digi-data-export #digi-export-form, #digi-data-export #digi-export-tree, #digi-data-export #digi-export-risks, #digi-data-export #digi-export-risksigns, #digi-data-export #digi-export-global', window.eoxiaJS.digirisk.export.create_export );
jQuery( document ).on( 'change', '#digi-data-export #digi-import-form input[type="file"]', window.eoxiaJS.digirisk.export.make_import );
};
diff --git a/modules/export_import/class/export.class.php b/modules/export_import/class/export.class.php
index cf0954a3..3b96cf63 100644
--- a/modules/export_import/class/export.class.php
+++ b/modules/export_import/class/export.class.php
@@ -87,6 +87,34 @@ public function exec_risks() {
return $this->generate_zip( $data_to_export, 'risques');
}
+ /**
+ * Appelles différentes méthodes pour récupérer toutes les données pour exporter le DigiRisk
+ *
+ * @since 6.1.5
+ * @version 6.4.1
+ *
+ * @return array
+ */
+ public function exec_risksigns() {
+ $data_to_export = $this->export_all_risksigns();
+ return $this->generate_zip( $data_to_export, 'signalisations');
+ }
+
+ /**
+ * Appelles différentes méthodes pour récupérer toutes les données pour exporter le DigiRisk
+ *
+ * @since 6.1.5
+ * @version 6.4.1
+ *
+ * @return array
+ */
+ public function exec_global() {
+ $data_to_export = $this->export_groupments(0,false);
+ $data_to_export[] = $this->export_all_risks();
+ $data_to_export[] = $this->export_all_risksigns();
+ return $this->generate_zip( $data_to_export, 'global');
+ }
+
/**
* Exportes tout le contenu d'un groupement
*
@@ -122,6 +150,41 @@ public function export_all_risks( $parent_id = 0) {
return $list_data_exported;
}
+ /**
+ * Exportes tout le contenu d'un groupement
+ *
+ * @since 6.1.5
+ * @version 6.5.0
+ *
+ * @param integer $parent_id (optional) Le groupement parent.
+ *
+ * @return array
+ */
+ public function export_all_risksigns( $parent_id = 0) {
+ $society = Society_Class::get_current_society();
+
+ $risksigns = get_posts(
+ array(
+ 'numberposts' => -1,
+ 'post_parent' => $society['id'],
+ 'post_status' => array( 'publish', 'inherit' ),
+ 'post_type' => 'digi-recommendation',
+ )
+ );
+
+ $list_data_exported = array();
+
+ if ( ! empty( $risksigns ) ) {
+ foreach ( $risksigns as $element ) {
+ // Récupères les signalisations du groupement.
+ $element->list_risksign = Recommendation::g()->get( array( 'id' => $element->ID ) );
+ $list_data_exported[] = array_shift($this->export_risksigns( $element->list_risksign ));
+ }
+ }
+
+ return $list_data_exported;
+ }
+
/**
* Exportes tout le contenu d'un groupement
*
@@ -278,6 +341,39 @@ public function export_risks( $risks ) {
return $data_risks_to_export;
}
+ /**
+ * Exportes les champs nécessaires d'une signalisation.
+ *
+ * @since 7.7.5
+ * @version 7.7.5
+ *
+ * @param array $risksigns Le tableau des signalisations.
+ * @return array
+ */
+ public function export_risksigns( $risksigns ) {
+ $data_risksigns_to_export = array();
+
+ if ( ! empty( $risksigns ) ) {
+ foreach ( $risksigns as $element ) {
+ $tmp_risksign_data = array(
+ 'title' => $element->data['title'],
+ 'slug' => $element->data['slug'],
+ 'status' => $element->data['status'],
+ 'content' => $element->data['content'],
+ 'link' => $element->data['link'],
+ 'id' => $element->data['id'],
+ 'parent_id' => $element->data['parent_id'],
+ 'recommendation_category' => $this->export_risksign_category( $element ), // Element car on a besoin $element->recommendation_category et $element->recommendation.
+ 'comment' => array_shift( $this->export_comments( $element->data['comment'] )),
+ );
+
+ $data_risksigns_to_export[] = $tmp_risksign_data;
+ }
+ }
+
+ return $data_risksigns_to_export;
+ }
+
/**
* Exportes la catégorie de danger et le danger d'un risque.
*
@@ -297,6 +393,25 @@ public function export_danger_category( $element ) {
return $danger_category_data;
}
+ /**
+ * Exportes la catégorie de danger et le danger d'un risque.
+ *
+ * @since 6.1.5
+ * @version 6.4.1
+ *
+ * @param Risk_Model $element Le risque.
+ * @return array
+ */
+ public function export_risksign_category( $element ) {
+ $risksign_category_data = array(
+ 'name' => $element->data['recommendation_category']->data['name'],
+ 'slug' => $element->data['recommendation_category']->data['slug'],
+ 'parent_id' => $element->data['recommendation_category']->data['parent_id'],
+ );
+
+ return $risksign_category_data;
+ }
+
/**
* Exportes l'évaluation d'un risque.
*
diff --git a/modules/export_import/shortcode/export.shortcode.php b/modules/export_import/shortcode/export.shortcode.php
index 63bcf286..c3bfe630 100644
--- a/modules/export_import/shortcode/export.shortcode.php
+++ b/modules/export_import/shortcode/export.shortcode.php
@@ -30,6 +30,8 @@ public function __construct() {
add_shortcode( 'digi-import', array( $this, 'callback_import_interface' ) );
add_shortcode( 'digi-export-tree', array( $this, 'callback_export_tree_interface' ) );
add_shortcode( 'digi-export-risks', array( $this, 'callback_export_risks_interface' ) );
+ add_shortcode( 'digi-export-risksigns', array( $this, 'callback_export_risksigns_interface' ) );
+ add_shortcode( 'digi-export-global', array( $this, 'callback_export_global_interface' ) );
}
/**
@@ -99,6 +101,40 @@ public function callback_export_risks_interface( $param ) {
/** Affichage du formulaire d'export / Display export form */
\eoxia\View_Util::exec( 'digirisk', 'export_import', 'export-risks', array( 'element_id' => $element_id, 'element' => $element ) );
}
+
+ /**
+ * Interface d'export / Export Interface filter callback
+ *
+ * @param array $param Les paramètres du shortcode / Shortcode parameters
+ */
+ public function callback_export_risksigns_interface( $param ) {
+ $element_id = $element = null;
+ /** On vérifie si il y a un élément défini pour l'affichage du shortcode / Check if there is an element specified for shortcode usage */
+ if ( !empty( $param ) && !empty( $param[ 'post_id' ] ) && is_int( (int)$param[ 'post_id' ] ) ) {
+ $element_id = $param[ 'post_id' ];
+ $element = society_class::g()->show_by_type( $element_id );
+ }
+
+ /** Affichage du formulaire d'export / Display export form */
+ \eoxia\View_Util::exec( 'digirisk', 'export_import', 'export-risksigns', array( 'element_id' => $element_id, 'element' => $element ) );
+ }
+
+ /**
+ * Interface d'export / Export Interface filter callback
+ *
+ * @param array $param Les paramètres du shortcode / Shortcode parameters
+ */
+ public function callback_export_global_interface( $param ) {
+ $element_id = $element = null;
+ /** On vérifie si il y a un élément défini pour l'affichage du shortcode / Check if there is an element specified for shortcode usage */
+ if ( !empty( $param ) && !empty( $param[ 'post_id' ] ) && is_int( (int)$param[ 'post_id' ] ) ) {
+ $element_id = $param[ 'post_id' ];
+ $element = society_class::g()->show_by_type( $element_id );
+ }
+
+ /** Affichage du formulaire d'export / Display export form */
+ \eoxia\View_Util::exec( 'digirisk', 'export_import', 'export-global', array( 'element_id' => $element_id, 'element' => $element ) );
+ }
}
new export_shortcode();
diff --git a/modules/export_import/view/export-form.view.php b/modules/export_import/view/export-form.view.php
index 20229f6d..26b4e455 100644
--- a/modules/export_import/view/export-form.view.php
+++ b/modules/export_import/view/export-form.view.php
@@ -35,6 +35,9 @@
+
+
+
diff --git a/modules/export_import/view/export-global.view.php b/modules/export_import/view/export-global.view.php
new file mode 100644
index 00000000..51529ae9
--- /dev/null
+++ b/modules/export_import/view/export-global.view.php
@@ -0,0 +1,45 @@
+
+ * @since 6.1.9
+ * @version 6.5.0
+ * @copyright 2015-2018 Evarisk
+ * @package DigiRisk
+ */
+
+namespace digi;
+
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+} ?>
+
+
diff --git a/modules/export_import/view/export-risksigns.view.php b/modules/export_import/view/export-risksigns.view.php
new file mode 100644
index 00000000..dc5b53e0
--- /dev/null
+++ b/modules/export_import/view/export-risksigns.view.php
@@ -0,0 +1,36 @@
+
+ * @since 6.1.9
+ * @version 6.5.0
+ * @copyright 2015-2018 Evarisk
+ * @package DigiRisk
+ */
+
+namespace digi;
+
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+} ?>
+
+
diff --git a/modules/tools/view/main.view.php b/modules/tools/view/main.view.php
index 08416366..ba48ab93 100644
--- a/modules/tools/view/main.view.php
+++ b/modules/tools/view/main.view.php
@@ -55,6 +55,18 @@
+
+
+
+
diff --git a/readme.txt b/readme.txt
index 1e94d90b..85440e5d 100644
--- a/readme.txt
+++ b/readme.txt
@@ -3,8 +3,8 @@ Contributors: Evarisk
Tags: Evaluation des risques, document unique, risques professionnels, audit risques, risques humains, digirisk, digi risk, evarisk, eva risk, risk, risks, risque, risques
Donate link: http://www.evarisk.com/document-unique-logiciel
Requires at least: 4.4
-Tested up to: 5.8.1
-Stable tag: 7.7.4
+Tested up to: 6.0.0
+Stable tag: 7.7.5
License: AGPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -77,6 +77,11 @@ Lors de l'installation de l'extension Digirisk si vous aviez déjà installé la
* Veillez à bien sauvegarder vos données avant d'effectuer une mise à jour du plugin
+= Version 7.7.5 =
+
+- Add : Exportation global de Digirisk WP vers Digirisk Dolibarr.
+- Add : Exportation des signalisations de Digirisk WP vers Digirisk Dolibarr.
+
= Version 7.7.4 =
- fix : Fichier JS manquant pour exécuter l'action de téléchargement des fichiers d'exportation.