21require
'../../../../main.inc.php';
31if ($user->socid > 0) {
36require_once DOL_DOCUMENT_ROOT .
'/admin/tools/ui/class/documentation.class.php';
39$langs->load(
'uxdocumentation');
43$group =
'UxDolibarrContext';
44$experimentName =
'UxDolibarrContextKnowsHooks';
47 '/includes/ace/src/ace.js',
48 '/includes/ace/src/ext-statusbar.js',
49 '/includes/ace/src/ext-language_tools.js'
54$documentation->docHeader($langs->trans($experimentName, $group), $js, $css);
57$documentation->view = [$group,
'UxDolibarrContext', $experimentName];
60$documentation->showSidebar(); ?>
62<div
class=
"doc-wrapper">
64 <?php $documentation->showBreadCrumb(); ?>
66 <div
class=
"doc-content-wrapper">
68 <h1
class=
"documentation-title"><?php echo $langs->trans($experimentName); ?></h1>
70 <?php $documentation->showSummary(); ?>
72 <div
class=
"documentation-section">
73 <h2
id=
"titlesection-basicusage" class=
"documentation-title">Introduction</h2>
76 Some hooks are not natively triggered by Dolibarr; instead, they rely on external modules. Therefore, we document them here to ensure everyone uses the same method of triggering them, until we provide a standardized native trigger, which does not yet exist.<br/>
77 Please refer to the
"How it works" section
for further details.
82 <div
class=
"documentation-section">
83 <h2
id=
"reloadDocumentLine" class=
"documentation-title">
Hook : reloadDocumentLine</h2>
85 Next, let’s focus on the “reloadDocumentLine” hook. First, it’s important to note that
this hook is not triggered automatically by Dolibarr.
86 <br/>Instead, it must be activated via external modules. In the future, we plan to introduce a
class directly tied to the object within Dolibarr tools, allowing this hook to be triggered natively. However, although Dolibarr does not currently initiate the trigger itself, it does listen for it.
87 <br/>This is because it uses this trigger to reload certain elements on the lines, particularly the drag-and-drop system for rearranging line items in the document.
90 In the meantime, here is how you can use the event listener.
91 <br/>The process involves two steps: first, you trigger the event, and then you handle it with an event listener.
92 <br/>Below, you will find a code example of how to implement this.
95 <div class="documentation-example">
99 'Dolibarr.on(\'reloadDocumentLine\',',
100 ' /** @param {{lineId:number, lineElement:string}} data */',
101 ' function (data) {',
107 $documentation->showCode($lines, 'php');
111 <h4>Trigger event</h4>
112 <div class="documentation-example">
116 ' const rowSelector = \'#row-\' + lineId;',
117 ' const $row = $(rowSelector);',
119 ' // newRow is the newly created row element that will replace the existing row',
120 ' $row.replaceWith(newRow);',
122 ' // Trigger the hook to dispatch reloaded line event.',
123 ' // This hook will by used to rebuild drag and drop lines order system for example ',
124 ' Dolibarr.executeHook(\'reloadDocumentLine\', {lineId, lineElement});',
126 ' // Trigger initNewContent for all common Dom reloaded content. This will reload tooltips system for example ',
127 ' // This will reload tooltips system for example ',
128 ' Dolibarr.initNewContent(rowSelector);',
131 $documentation->showCode($lines, 'php');
142$documentation->docFooter();
Class to manage UI documentation.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.