@@ -65,13 +65,30 @@ public function indexAction(EventLogService $eventLogService, Request $request):
65
65
}
66
66
}
67
67
}
68
+ $ before = $ this ->config ->all ();
68
69
$ errors = $ this ->config ->saveChanges ($ data , $ eventLogService , $ this ->dj , $ options );
70
+ $ after = $ this ->config ->all ();
71
+
72
+ // Compile a list of differences.
73
+ $ diffs = [];
74
+ foreach ($ before as $ key => $ value ) {
75
+ if (!array_key_exists ($ key , $ after )) {
76
+ $ diffs [$ key ] = ['before ' => $ value , 'after ' => null ];
77
+ } elseif ($ value !== $ after [$ key ]) {
78
+ $ diffs [$ key ] = ['before ' => $ value , 'after ' => $ after [$ key ]];
79
+ }
80
+ }
81
+ foreach ($ after as $ key => $ value ) {
82
+ if (!array_key_exists ($ key , $ before )) {
83
+ $ diffs [$ key ] = ['before ' => null , 'after ' => $ value ];
84
+ }
85
+ }
69
86
70
87
if (empty ($ errors )) {
71
88
$ this ->addFlash ('scoreboard_refresh ' , 'After changing specific ' .
72
89
'settings, you might need to refresh the scoreboard. ' );
73
90
74
- return $ this ->redirectToRoute ('jury_config ' );
91
+ return $ this ->redirectToRoute ('jury_config ' , [ ' diffs ' => json_encode ( $ diffs )] );
75
92
} else {
76
93
$ this ->addFlash ('danger ' , 'Some errors occurred while saving configuration, ' .
77
94
'please check the data you entered. ' );
@@ -114,10 +131,15 @@ public function indexAction(EventLogService $eventLogService, Request $request):
114
131
'data ' => $ data
115
132
];
116
133
}
134
+ $ diffs = $ request ->query ->get ('diffs ' );
135
+ if ($ diffs !== null ) {
136
+ $ diffs = json_decode ($ diffs , true );
137
+ }
117
138
return $ this ->render ('jury/config.html.twig ' , [
118
139
'options ' => $ allData ,
119
140
'errors ' => $ errors ?? [],
120
141
'activeCategory ' => $ activeCategory ?? 'Scoring ' ,
142
+ 'diffs ' => $ diffs ,
121
143
]);
122
144
}
123
145
0 commit comments