Skip to content

Commit 70c0d3c

Browse files
committed
refactor: miglioria indicazione moduli personalizzati
1 parent 5e5fdc0 commit 70c0d3c

3 files changed

Lines changed: 170 additions & 86 deletions

File tree

assets/src/css/style.css

Lines changed: 117 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,6 @@ input.small-width {
14591459
padding: 2px 4px;
14601460
border-radius: 3px;
14611461
font-weight: bold;
1462-
text-decoration: line-through;
14631462
}
14641463

14651464
.diff-unchanged {
@@ -2226,7 +2225,123 @@ table.dataTable {
22262225
background: rgba(255, 49, 21, .3);
22272226
}
22282227

2229-
kbd{
2228+
/* ===== Modulo Aggiornamenti ===== */
2229+
2230+
.module-aggiornamenti .query-container {
2231+
position: relative;
2232+
}
2233+
2234+
.module-aggiornamenti .query-toggle {
2235+
font-size: 11px;
2236+
padding: 2px 8px;
2237+
border-radius: 3px;
2238+
transition: all 0.2s ease;
2239+
}
2240+
2241+
.module-aggiornamenti .query-toggle:hover {
2242+
background-color: #007bff;
2243+
color: #fff;
2244+
border-color: #007bff;
2245+
}
2246+
2247+
.module-aggiornamenti .query-toggle i {
2248+
font-size: 10px;
2249+
margin-right: 3px;
2250+
}
2251+
2252+
.module-aggiornamenti .query-toggle-container {
2253+
text-align: left;
2254+
}
2255+
2256+
.module-aggiornamenti .query-cell {
2257+
max-width: 300px;
2258+
word-wrap: break-word;
2259+
}
2260+
2261+
.module-aggiornamenti .query-preview code,
2262+
.module-aggiornamenti .query-full code {
2263+
font-size: 11px;
2264+
line-height: 1.3;
2265+
background-color: #f8f9fa;
2266+
border: 1px solid #e9ecef;
2267+
border-radius: 3px;
2268+
padding: 8px;
2269+
display: block;
2270+
}
2271+
2272+
.module-aggiornamenti .btn-xs {
2273+
padding: 4px 8px;
2274+
font-size: 11px;
2275+
line-height: 1.3;
2276+
border-radius: 3px;
2277+
font-weight: 600;
2278+
border: 1px solid #007bff;
2279+
color: #007bff;
2280+
background-color: #fff;
2281+
transition: all 0.2s ease;
2282+
}
2283+
2284+
.module-aggiornamenti .btn-xs i {
2285+
font-size: 10px;
2286+
margin-right: 3px;
2287+
}
2288+
2289+
.module-aggiornamenti .btn-xs:hover {
2290+
background-color: #007bff;
2291+
color: #fff;
2292+
border-color: #007bff;
2293+
transform: translateY(-1px);
2294+
box-shadow: 0 2px 4px rgba(0, 123, 255, 0.2);
2295+
}
2296+
2297+
.module-aggiornamenti .table td {
2298+
padding: 12px 8px !important;
2299+
vertical-align: top;
2300+
}
2301+
2302+
.module-aggiornamenti .table th {
2303+
padding: 10px 8px !important;
2304+
}
2305+
2306+
.module-aggiornamenti td a {
2307+
text-decoration: none;
2308+
color: inherit;
2309+
}
2310+
2311+
.module-aggiornamenti td a:hover {
2312+
text-decoration: none;
2313+
color: #007bff;
2314+
}
2315+
2316+
.module-aggiornamenti td a:hover strong {
2317+
color: #007bff;
2318+
}
2319+
2320+
.module-aggiornamenti td a:hover code {
2321+
color: #007bff;
2322+
background-color: #e3f2fd;
2323+
}
2324+
2325+
.module-aggiornamenti .fa-external-link {
2326+
opacity: 0.6;
2327+
transition: opacity 0.2s ease;
2328+
}
2329+
2330+
.module-aggiornamenti td a:hover .fa-external-link {
2331+
opacity: 1;
2332+
}
2333+
2334+
.module-aggiornamenti .diff-removed {
2335+
background-color: #f8d7da;
2336+
color: #721c24;
2337+
}
2338+
2339+
.module-aggiornamenti .diff-added {
2340+
background-color: #d4edda;
2341+
color: #155724;
2342+
}
2343+
2344+
kbd {
22302345
background: #ccc;
22312346
color: #333;
22322347
font-size: 1.3em;

modules/aggiornamenti/edit.php

Lines changed: 32 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -42,68 +42,8 @@ function base_dir()
4242
$module = Module::find($id_module);
4343

4444
// Aggiunta della classe per il modulo
45-
echo '<div class="module-aggiornamenti">
46-
47-
<style>
48-
.query-preview,
49-
.query-full {
50-
font-size: 11px;
51-
line-height: 1.3;
52-
background-color: #f8f9fa;
53-
border: 1px solid #e9ecef;
54-
border-radius: 3px;
55-
padding: 8px;
56-
display: block;
57-
white-space: pre-wrap;
58-
word-break: break-all;
59-
}
60-
61-
.btn-xs {
62-
padding: 4px 8px;
63-
font-size: 11px;
64-
line-height: 1.3;
65-
border-radius: 3px;
66-
font-weight: 600;
67-
border: 1px solid #007bff;
68-
color: #007bff;
69-
background-color: white;
70-
transition: all 0.2s ease;
71-
}
72-
73-
.btn-xs i {
74-
font-size: 10px;
75-
margin-right: 3px;
76-
}
77-
78-
.btn-xs:hover {
79-
background-color: #007bff;
80-
color: white;
81-
border-color: #007bff;
82-
transform: translateY(-1px);
83-
box-shadow: 0 2px 4px rgba(0,123,255,0.2);
84-
}
85-
86-
/* Padding per le celle della tabella */
87-
.table td {
88-
padding: 12px 8px !important;
89-
vertical-align: top;
90-
}
91-
92-
.table th {
93-
padding: 10px 8px !important;
94-
}
95-
</style>';
45+
echo '<div class="module-aggiornamenti">';
9646

97-
if (!function_exists('normalizeForDiff')) {
98-
function normalizeForDiff($text)
99-
{
100-
$text = preg_replace('/<br\s*\/?>/i', '', (string) $text);
101-
$text = preg_replace('/\s+/', ' ', (string) $text);
102-
$text = str_replace(['"', "'"], "'", $text);
103-
$text = html_entity_decode($text, ENT_QUOTES | ENT_HTML5, 'UTF-8');
104-
return trim($text);
105-
}
106-
}
10747

10848
function createCollapsibleQuery($query_content, $row_id, $column_type) {
10949
if (empty($query_content) || $query_content === '<span class="text-muted">-</span>') {
@@ -153,8 +93,8 @@ function highlightDifferences($current, $expected) {
15393
];
15494
}
15595

156-
$current_normalized = normalizeForDiff($current);
157-
$expected_normalized = normalizeForDiff($expected);
96+
$current_normalized = normalizeModuleOptions($current);
97+
$expected_normalized = normalizeModuleOptions($expected);
15898

15999
$current_words = preg_split('/(\s+|[(),\'"`]|<[^>]*>)/', $current_normalized, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
160100
$expected_words = preg_split('/(\s+|[(),\'"`]|<[^>]*>)/', $expected_normalized, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
@@ -169,22 +109,39 @@ function highlightDifferences($current, $expected) {
169109
$current_highlighted = '';
170110
$expected_highlighted = '';
171111

172-
$i = 0; $j = 0;
173-
while ($i < count($current_words) || $j < count($expected_words)) {
174-
if ($i < count($current_words) && $j < count($expected_words) && $current_words[$i] === $expected_words[$j]) {
112+
$current_count = count($current_words);
113+
$expected_count = count($expected_words);
114+
115+
$lcs = array_fill(0, $current_count + 1, array_fill(0, $expected_count + 1, 0));
116+
117+
for ($i = $current_count - 1; $i >= 0; --$i) {
118+
for ($j = $expected_count - 1; $j >= 0; --$j) {
119+
if ($current_words[$i] === $expected_words[$j]) {
120+
$lcs[$i][$j] = $lcs[$i + 1][$j + 1] + 1;
121+
} else {
122+
$lcs[$i][$j] = max($lcs[$i + 1][$j], $lcs[$i][$j + 1]);
123+
}
124+
}
125+
}
126+
127+
$i = 0;
128+
$j = 0;
129+
while ($i < $current_count || $j < $expected_count) {
130+
if ($i < $current_count && $j < $expected_count && $current_words[$i] === $expected_words[$j]) {
175131
// Parti uguali: mostra senza evidenziazione
176132
$word = htmlspecialchars($current_words[$i]);
177133
$current_highlighted .= $word;
178134
$expected_highlighted .= $word;
179-
$i++; $j++;
180-
} elseif ($i < count($current_words) && ($j >= count($expected_words) || $current_words[$i] !== $expected_words[$j])) {
181-
// Parti aggiunte nel current: evidenzia in verde
182-
$current_highlighted .= '<span class="diff-added" style="background-color: #d4edda; color: #155724;">' . htmlspecialchars($current_words[$i]) . '</span>';
183-
$i++;
184-
} elseif ($j < count($expected_words)) {
185-
// Parti rimosse (presenti nell'expected ma non nel current): evidenzia in rosso
186-
$expected_highlighted .= '<span class="diff-removed" style="background-color: #f8d7da; color: #721c24;">' . htmlspecialchars($expected_words[$j]) . '</span>';
187-
$j++;
135+
++$i;
136+
++$j;
137+
} elseif ($i < $current_count && ($j >= $expected_count || $lcs[$i + 1][$j] >= $lcs[$i][$j + 1])) {
138+
$current_highlighted .= '<span class="diff-removed">'.htmlspecialchars($current_words[$i]).'</span>';
139+
++$i;
140+
} elseif ($j < $expected_count) {
141+
$expected_highlighted .= '<span class="diff-added">'.htmlspecialchars($expected_words[$j]).'</span>';
142+
++$j;
143+
} else {
144+
break;
188145
}
189146
}
190147

modules/aggiornamenti/modutil.php

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,20 @@ function customViewsNotStandard()
309309
if (is_array($views_data)) {
310310
// Il file views.json è organizzato per nome modulo
311311
foreach ($views_data as $module_name => $module_views) {
312-
if (is_array($module_views)) {
313-
foreach ($module_views as $view_name => $view_query) {
314-
$standard_views[$module_name][$view_name] = $view_query;
312+
$module_key = trim((string) $module_name);
313+
314+
if ($module_key === '' || !is_array($module_views)) {
315+
continue;
316+
}
317+
318+
foreach ($module_views as $view_name => $view_query) {
319+
$view_key = trim((string) $view_name);
320+
321+
if ($view_key === '') {
322+
continue;
315323
}
324+
325+
$standard_views[$module_key][$view_key] = $view_query;
316326
}
317327
}
318328
}
@@ -339,10 +349,10 @@ function customViewsNotStandard()
339349
$reason = '';
340350
$expected_query = '';
341351

342-
$module_name = $view['module_name'];
343-
$view_name = $view['name'];
352+
$module_name = trim((string) $view['module_name']);
353+
$view_name = trim((string) $view['name']);
344354

345-
if (empty($view_name) || empty(trim($view_name))) {
355+
if ($view_name === '') {
346356
$custom_views[] = [
347357
'id' => $view['id'],
348358
'name' => '', // Nome vuoto
@@ -411,9 +421,11 @@ function customViewsNotStandard()
411421

412422
$db_views_by_module = [];
413423
foreach ($all_views as $view) {
414-
$module_name = $view['module_name'];
415-
if (!empty($module_name)) {
416-
$db_views_by_module[$module_name][$view['name']] = true;
424+
$module_name = trim((string) $view['module_name']);
425+
$view_name = trim((string) $view['name']);
426+
427+
if ($module_name !== '' && $view_name !== '') {
428+
$db_views_by_module[$module_name][$view_name] = true;
417429
}
418430
}
419431

0 commit comments

Comments
 (0)