dolibarr 24.0.0-beta
input-feedback.php
1<?php
2/*
3 * Copyright (C) 2024 Anthony Damhet <a.damhet@progiseize.fr>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20// Load Dolibarr environment
21require '../../../../main.inc.php';
22
30// Protection if external user
31if ($user->socid > 0) {
33}
34
35// Includes
36require_once DOL_DOCUMENT_ROOT . '/admin/tools/ui/class/documentation.class.php';
37
38// Load documentation translations
39$langs->load('uxdocumentation');
40
41//
42$documentation = new Documentation($db);
43$group = 'ExperimentalUx';
44$experimentName = 'ExperimentalUxInputAjaxFeedback';
45
46$experimentAssetsPath = $documentation->baseUrl . '/experimental/experiments/input-feedback/assets/';
47$js = [
48 '/includes/ace/src/ace.js',
49 '/includes/ace/src/ext-statusbar.js',
50 '/includes/ace/src/ext-language_tools.js',
51];
52$css = [
53
54];
55
56// Output html head + body - Param is Title
57$documentation->docHeader($langs->trans($experimentName, $group), $js, $css);
58
59// Set view for menu and breadcrumb
60$documentation->view = [$group, $experimentName];
61
62// Output sidebar
63$documentation->showSidebar(); ?>
64
65<div class="doc-wrapper">
66
67 <?php $documentation->showBreadCrumb(); ?>
68
69 <div class="doc-content-wrapper">
70
71 <h1 class="documentation-title"><?php echo $langs->trans($experimentName); ?></h1>
72
73 <?php $documentation->showSummary(); ?>
74
75 <div class="documentation-section" >
76 <h2 class="documentation-title" >Input Feedback</h2>
77
78 <p>
79 This feature provides visual feedback on input fields based on their processing state.
80 </p>
81
82 <h3>How It Works</h3>
83 <ul>
84 <li><strong>Processing:</strong> The <code>.processing-feedback</code> class is applied while an action is being processed.</li>
85 <li><strong>Success:</strong> Once successfully completed, the <code>.success-feedback</code> class is applied.</li>
86 <li><strong>Failure:</strong> In case of an error, the <code>.fail-feedback</code> class is applied.</li>
87 </ul>
88
89 <h3>Live Demo</h3>
90
91 <div class="documentation-example">
92 <input type="text" id="test-input-01" placeholder="Type something..." />
93 <button id="btn-process-fail" type="button" class="button" >Processing will fail</button>
94 <button id="btn-process-success" type="button" class="button" >Processing will success</button>
95 <script>
96 document.getElementById('btn-process-success').addEventListener('click', function () {
97 let input = document.getElementById('test-input-01');
98 input.classList.add('processing-feedback');
99
100 setTimeout(() => {
101 input.classList.remove('processing-feedback');
102 input.classList.add('success-feedback');
103 setTimeout(() => {
104 input.classList.remove('success-feedback');
105 }, 1000);
106 }, 1500);
107 });
108
109
110 document.getElementById('btn-process-fail').addEventListener('click', function () {
111 let input = document.getElementById('test-input-01');
112 input.classList.add('processing-feedback');
113
114 setTimeout(() => {
115 input.classList.remove('processing-feedback');
116 input.classList.add('fail-feedback');
117 setTimeout(() => {
118 input.classList.remove('fail-feedback');
119 }, 1000);
120 }, 1500);
121 });
122 </script>
123 </div>
124 <?php
125 $lines = array(
126 '<script>',
127 'document.getElementById(\'btn-process-success\').addEventListener(\'click\', function () {
128 let input = document.getElementById(\'test-input-01\');
129 input.classList.add(\'processing-feedback\');
130
131 setTimeout(() => {
132 input.classList.remove(\'processing-feedback\');
133 input.classList.add(\'success-feedback\');
134 setTimeout(() => {
135 input.classList.remove(\'success-feedback\');
136 }, 1000);
137 }, 1500);
138});
139
140
141document.getElementById(\'btn-process-fail\').addEventListener(\'click\', function () {
142 let input = document.getElementById(\'test-input-01\');
143 input.classList.add(\'processing-feedback\');
144
145 setTimeout(() => {
146 input.classList.remove(\'processing-feedback\');
147 input.classList.add(\'fail-feedback\');
148 setTimeout(() => {
149 input.classList.remove(\'fail-feedback\');
150 }, 1000);
151 }, 1500);
152});',
153 '</script>',
154 );
155 $documentation->showCode($lines); ?>
156 </div>
157
158
159 </div>
160
161</div>
162<?php
163// Output close body + html
164$documentation->docFooter();
165?>
while( $i< $imaxinloop)
The main.inc.php has been included so the following variable are now defined:
Definition list.php:548
Class to manage UI documentation.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.