@@ -146,21 +146,24 @@ static function showSurvey(CommonGLPI $item, $preview = false) {
146146 if ($ preview ) {
147147 echo "<div class='spaced' id='tabsbody'> " ;
148148 } else {
149- echo "<div class='card-body d-flex flex-wrap' > " ;
149+ echo "<div> " ;
150150 }
151151
152+ echo "<table class='tab_cadre_fixe'> " ;
153+ echo "<tbody> " ;
154+
152155 //list survey questions
153156 $ squestion_obj = new PluginSatisfactionSurveyQuestion ;
154157 foreach ($ squestion_obj ->find ([PluginSatisfactionSurveyQuestion::$ items_id => $ plugin_satisfaction_surveys_id ]) as $ question ) {
155- echo "<div class='row flex-row col-12 col-sm-12'> " ;
158+ echo "<tr> " ;
159+ echo "<td class='w-50'> " ;
156160 $ name = $ question ['name ' ];
157161 if (PluginSatisfactionSurveyTranslation::hasTranslation ($ question ["plugin_satisfaction_surveys_id " ], $ question ["id " ])) {
158162 $ name = PluginSatisfactionSurveyTranslation::getTranslation ($ question ["plugin_satisfaction_surveys_id " ], $ question ["id " ]);
159163 }
160- echo "<div class='row flex-rowform-field row col-12 col-sm-6 mb-2'> " ;
161164 echo nl2br ($ name );
162- echo "</div > " ;
163- echo "<div class='row flex-rowform-field row col-12 col-sm-6 mb-2' > " ;
165+ echo "</td > " ;
166+ echo "<td > " ;
164167 if (isset ($ sanswer_obj ->fields ['answer ' ][$ question ['id ' ]])) {
165168 $ value = $ sanswer_obj ->fields ['answer ' ][$ question ['id ' ]];
166169 } else {
@@ -173,11 +176,34 @@ static function showSurvey(CommonGLPI $item, $preview = false) {
173176 }
174177 }
175178 self ::displayAnswer ($ question , $ value );
176- echo "</div > " ;
177- echo "</div > " ;
179+ echo "</td > " ;
180+ echo "</tr > " ;
178181 }
179182
183+ echo "</tbody> " ;
184+ echo "</table> " ;
180185 echo "</div> " ;
186+
187+ echo Html::scriptBlock ("
188+ // Isolate variables in a self calling function
189+ (function(){
190+ // Set table content width
191+ const setTableWidth = function() {
192+ $('#mainformtable td').addClass('w-50');
193+ };
194+
195+ // Throttled function to avoid spamming the function on repeated events
196+ const setTableWidthDebounced = _.throttle(setTableWidth, 500, false);
197+
198+ // Run once immediatly
199+ setTableWidth();
200+
201+ // Run the function on each container change, to make sure it is applied to all rows
202+ $('#mainformtable').on('DOMSubtreeModified', function() {
203+ setTableWidthDebounced();
204+ });
205+ })();
206+ " );
181207 }
182208
183209
0 commit comments