From 20073f693a6793191e0324c40644b936a4f1aecd Mon Sep 17 00:00:00 2001 From: Nicolas Date: Fri, 22 Apr 2022 17:02:26 +0200 Subject: [PATCH] [JS] add: check/uncheck all box in import shared risk --- js/digiriskdolibarr.js.php | 28 +++++++++++++++++-- view/digiriskelement/digiriskelement_risk.php | 2 ++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/js/digiriskdolibarr.js.php b/js/digiriskdolibarr.js.php index bec80ac17..5953109f6 100644 --- a/js/digiriskdolibarr.js.php +++ b/js/digiriskdolibarr.js.php @@ -1592,6 +1592,7 @@ $( document ).on( 'click', '.risk-create:not(.button-disable)', window.eoxiaJS.risk.createRisk ); $( document ).on( 'click', '.risk-save', window.eoxiaJS.risk.saveRisk ); $( document ).on( 'click', '.risk-unlink-shared', window.eoxiaJS.risk.unlinkSharedRisk ); + $( document ).on( 'click', '#select_all_shared_risks', window.eoxiaJS.risk.SelectAllSharedRisk ); }; /** @@ -1830,10 +1831,10 @@ }; /** - * Action save risk. + * Action unlink shared risk. * - * @since 1.0.0 - * @version 9.0.0 + * @since 9.2.0 + * @version 9.2.0 * * @return {void} */ @@ -1883,6 +1884,27 @@ }); }; +/** + * Action select All shared risk. + * + * @since 9.2.0 + * @version 9.2.0 + * + * @return {void} + */ +window.eoxiaJS.risk.SelectAllSharedRisk = function ( event ) { + if(this.checked) { + // Iterate each checkbox + $(':checkbox').each(function() { + this.checked = true; + }); + } else { + $(':checkbox').each(function() { + this.checked = false; + }); + } +}; + /** * Initialise l'objet "evaluation" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS. * diff --git a/view/digiriskelement/digiriskelement_risk.php b/view/digiriskelement/digiriskelement_risk.php index b88a51cc0..5319a41a2 100644 --- a/view/digiriskelement/digiriskelement_risk.php +++ b/view/digiriskelement/digiriskelement_risk.php @@ -240,6 +240,8 @@ 'text' => '' . $langs->trans("ConfirmImportSharedRisks"), ); + $formquestionimportsharedrisks[] = array('type' => 'checkbox', 'name' =>'select_all_shared_risks', 'value' => 1); + foreach ($allrisks as $key => $risks) { $digiriskelementtmp->fetch($risks->fk_element); $digiriskelementtmp->element = 'digiriskdolibarr';