From 71a090388b9dc6d1bfbc61945eea6d095ab043e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 13 Dec 2025 13:47:19 +0100 Subject: [PATCH] Debug v23, the cancel button was lost. --- htdocs/admin/modules.php | 11 ++++- htdocs/core/js/lib_head.js.php | 79 ++++++++++++++++++++------------ htdocs/theme/eldy/global.inc.php | 14 +++--- htdocs/theme/md/style.css.php | 11 ++++- 4 files changed, 77 insertions(+), 38 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index f7623cf5dde..6233644e3f9 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -1121,6 +1121,8 @@ if ($mode == 'common' || $mode == 'commonkanban') { } else { // Module qualified for activation $warningmessage = ''; + $disableCancel = 0; + if (!empty($arrayofwarnings[$modName])) { $codeenabledisable .= ''."\n"; foreach ($arrayofwarnings[$modName] as $keycountry => $cursorwarningmessage) { @@ -1129,7 +1131,12 @@ if ($mode == 'common' || $mode == 'commonkanban') { $cursorwarningmessage = array($cursorwarningmessage); } foreach ($cursorwarningmessage as $messagetoshow) { - // TODO Use replacement instead of always adding param module name and country code to the string message + if (preg_match('/:1$/', $messagetoshow)) { + $disableCancel = 1; + } + $messagetoshow = preg_replace('/:1$/', '', $messagetoshow); + + // TODO Use a replacement instead of always adding the module name and the country code to the string message ? $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($messagetoshow, $objMod->getName(), $mysoc->country_code); } } @@ -1167,7 +1174,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { $codeenabledisable .= ''."\n"; $codeenabledisable .= 'numero.'\', '.$popupwidth.');"'; + $codeenabledisable .= ' onclick="return confirmDolibarr(\''.dol_escape_js($warningmessage).'\', \'idqualified'.$objMod->numero.'\', '.$popupwidth.', '.$disableCancel.');"'; } $codeenabledisable .= '>'; $codeenabledisable .= img_picto($langs->trans("Disabled"), 'switch_off'); diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index f0d8eb97624..8695818c991 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -191,24 +191,24 @@ $(document).ready(function() { }); jQuery(function($){ - $.datepicker.regional['defaultlang ?>'] = { - closeText: 'trans("Close2") ?>', - prevText: 'trans("Previous") ?>', - nextText: 'trans("Next") ?>', - currentText: 'trans("Now") ?>', + $.datepicker.regional['defaultlang) ?>'] = { + closeText: 'trans("Close2")) ?>', + prevText: 'trans("Previous")) ?>', + nextText: 'trans("Next")) ?>', + currentText: 'trans("Now")) ?>', monthNames: tradMonths, monthNamesShort: tradMonthsShort, dayNames: tradDays, dayNamesShort: tradDaysShort, dayNamesMin: tradDaysMin, - weekHeader: 'trans("Week"); ?>', - dateFormat: 'trans("FormatDateShortJQuery"); ?>', /* Note dd/mm/yy means year on 4 digit in jquery format */ + weekHeader: 'trans("Week")); ?>', + dateFormat: 'trans("FormatDateShortJQuery")); ?>', /* Note dd/mm/yy means year on 4 digit in jquery format */ firstDay: , isRTL: trans("DIRECTION") == 'rtl' ? 'true' : 'false'); ?>, showMonthAfterYear: false, /* TODO add specific to country */ yearSuffix: '' /* TODO add specific to country */ }; - $.datepicker.setDefaults($.datepicker.regional['defaultlang ?>']); + $.datepicker.setDefaults($.datepicker.regional['defaultlang) ?>']); }); @@ -566,29 +566,49 @@ function cleanSerialize(expr) { /* - * ================================================================= - * Purpose: Fonction to open a confirm popup on a clie of a link + * Purpose: Fonction to open a confirm popup on a click of a link * Input: msg - * Input: width + * Input: id + * Input: popupWidth + * Input: disableCancelButton * Licence: GPL - * ================================================================== + * See also document_preview() that also maje a dialogforpopup.dialog(). + * See also newpopup that use window.open. */ -function confirmDolibarr(msg, id, width = 400) { - let alink = document.getElementById(id); - if (alink.getAttribute("data-alreadyclicked") === "0") { - new Promise(res => { - $("#dialogforpopup").text(msg).dialog({ - modal: true, - width: width, - buttons: { - OK() { $(this).dialog("close"); res(false); alink.setAttribute("data-alreadyclicked", "1"); alink.click(); }, - } +function confirmDolibarr(msg, id, popupWidth = 400, disableCancelButton = 0) { + let alink = document.getElementById(id); + let popupHeight = 200; + let title = 'trans("Note")); ?>'; + + if (alink.getAttribute("data-alreadyclicked") === "1") { + return true; + } + + console.log("Call confirmDolibarr disableCancelButton="+disableCancelButton); + + let buttons = {}; + if (disableCancelButton === 0) { + buttons.Cancel = function () { + $(this).dialog("close"); + }; + } + buttons.OK = function () { + console.log("We click OK"); $(this).dialog("close"); alink.setAttribute("data-alreadyclicked", "1"); alink.click(); return false; + }; + + new Promise(res => { + $("#dialogforpopup").text(msg).dialog({ + closeOnEscape: true, + resizable: true, + modal: true, + width: popupWidth, + height: popupHeight, + title: title, + buttons: buttons + }); }); - }); - return false; - } else { - return true; - } + + return false; } @@ -1015,7 +1035,7 @@ function copyToClipboard(text,text2) * @param url Url * @param title Title of popup * @return boolean False - * @see document_preview() + * @see document_preview() and confirmDolibarr() */ function newpopup(url, title) { var argv = newpopup.arguments; @@ -1040,7 +1060,8 @@ function newpopup(url, title) { * @param type Mime file type ("image/jpeg", "application/pdf", "text/html") * @param title Title of popup * @return void - * @see newpopup() + * @see also confirmDolibarr() that also make a dialogforpopup.dialog() + * @see also newpopup()that use window.open */ function document_preview(file, type, title) { diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index edc5f9b0cf2..2474566770c 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -2738,9 +2738,10 @@ div.fiche { margin-: dol_optimize_smallscreen) ? '24' : '6')); ?>px; margin-top: 0px; } - .page-modulehelp div.fiche { width: 100%; + margin-left: 15px; + margin-right: 20px; } body.onlinepaymentbody div.fiche { /* For online payment page */ margin: 20px !important; @@ -2748,6 +2749,7 @@ body.onlinepaymentbody div.fiche { /* For online payment page */ div.fiche>table:first-child { margin-bottom: 15px; } + div.fichecenter { width: 100%; clear: both; /* This is to have div fichecenter that are true rectangles */ @@ -5922,7 +5924,10 @@ div#card-errors { /* Form confirmation (When Ajax JQuery is used) and Dialog popups */ /* ============================================================================== */ -.ui-dialog-titlebar { +button.ui-button-icon-only.ui-dialog-titlebar-close { + padding: 12px; + margin-top: -15px; + margin-right: 15px; } .ui-dialog-content { margin-bottom: 10px; /* same than .ui-widget-header */ @@ -5950,13 +5955,10 @@ div#card-errors { border-bottom: 1px solid #AAA; margin-bottom: 12px; } -button.ui-button-icon-only.ui-dialog-titlebar-close { - padding: 12px; - margin-top: -15px; -} .ui-dialog.ui-corner-all.ui-widget.ui-widget-content.ui-front.ui-dialog-buttons.ui-draggable { box-shadow: 5px 5px 20px #AAA; } + .ui-dialog .ui-dialog-buttonpane { padding: .5em 1em .3em .4em; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 3cbaeba16ec..11fb28c8667 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2822,6 +2822,12 @@ body.onlinepaymentbody div.fiche { /* For online payment page */ div.fiche>table:first-child { margin-bottom: 15px !important; } +.page-modulehelp div.fiche { + width: 100%; + margin-left: 15px; + margin-right: 20px; +} + div.fichecenter { width: 100%; clear: both; /* This is to have div fichecenter that are true rectangles */ @@ -5843,7 +5849,10 @@ div#card-errors { /* Form confirmation (When Ajax JQuery is used) and Dialog popups */ /* ============================================================================== */ -.ui-dialog-titlebar { +button.ui-button-icon-only.ui-dialog-titlebar-close { + padding: 12px; + margin-top: -15px; + margin-right: 15px; } .ui-dialog-content { maring-bottom: 10px; /* same than .ui-widget-header */