Revize e9236d13
Přidáno uživatelem Jan Čarnogurský před téměř 4 roky(ů)
src/main/java/vldc/aswi/web/controller/AssemblyController.java | ||
---|---|---|
87 | 87 |
/** Title text for new assembly form. */ |
88 | 88 |
private String assemblyNewTitleText = "Vytvoření nové sestavy"; |
89 | 89 |
|
90 |
/** Name of thymeleaf parameter, which will contain error text from validator. */ |
|
91 |
private String assemblyErrorName = "errorText"; |
|
92 |
|
|
93 | 90 |
/** |
94 | 91 |
* Bind assembly validator. |
95 | 92 |
* @param binder Binder. |
... | ... | |
167 | 164 |
@RequestParam(required=false, value="generateTable") String generateTable, |
168 | 165 |
@RequestParam(required=false, value="exportXls") String exportXls, |
169 | 166 |
@RequestParam(required=false, value="exportPdf") String exportPdf, |
170 |
@RequestParam(required=false, value="saveConfiguration") String saveConfiguration) |
|
167 |
@RequestParam(required=false, value="saveConfiguration") String saveConfiguration, |
|
168 |
RedirectAttributes redirectAttributes) |
|
171 | 169 |
{ |
172 | 170 |
|
173 | 171 |
ModelAndView modelAndView = new ModelAndView(); |
... | ... | |
210 | 208 |
|
211 | 209 |
initializeFields(configuration); |
212 | 210 |
|
211 |
redirectAttributes.addFlashAttribute(assemblySuccessName, "Šablona byla úspěšně uložena"); |
|
212 |
|
|
213 | 213 |
modelAndView.setViewName("redirect:/configuration?configurationID=" + configuration.getId()); |
214 | 214 |
} |
215 | 215 |
|
... | ... | |
237 | 237 |
* @return ModelAndView for index. |
238 | 238 |
*/ |
239 | 239 |
@GetMapping("/assembly_delete") |
240 |
public ModelAndView assemblyDeleteGet(@RequestParam("assemblyID") String id) { |
|
240 |
public ModelAndView assemblyDeleteGet(@RequestParam("assemblyID") String id, RedirectAttributes redirectAttributes) {
|
|
241 | 241 |
ModelAndView modelAndView = new ModelAndView("redirect:/"); |
242 | 242 |
|
243 | 243 |
Long assemblyId = Utils.tryParseLong(id); |
244 | 244 |
|
245 | 245 |
if (assemblyId == null) { |
246 |
// TODO: print error in index.
|
|
246 |
redirectAttributes.addFlashAttribute(assemblyErrorName, "Sestavu se nepodařilo odstranit.");
|
|
247 | 247 |
} |
248 | 248 |
boolean success = this.assemblyManager.deleteAssembly(assemblyId); |
249 |
// TODO: check success. |
|
249 |
|
|
250 |
if (success) |
|
251 |
{ |
|
252 |
redirectAttributes.addFlashAttribute(assemblySuccessName, "Sestava byla úspěšně odstraněna"); |
|
253 |
} |
|
254 |
else |
|
255 |
{ |
|
256 |
redirectAttributes.addFlashAttribute(assemblyErrorName, "Sestavu se nepodařilo odstranit"); |
|
257 |
} |
|
250 | 258 |
|
251 | 259 |
return modelAndView; |
252 | 260 |
} |
... | ... | |
311 | 319 |
|
312 | 320 |
modelMap.addAttribute("assembly", updatedAssembly); |
313 | 321 |
modelMap.addAttribute(assemblyTitleName, assemblyEditTitleText + " " + updatedAssembly.getName()); |
322 |
modelMap.addAttribute(assemblySuccessName, "Úspěšně uloženo"); |
|
314 | 323 |
} |
315 | 324 |
|
316 | 325 |
modelMap.addAttribute("allRoles", this.roleManager.getRoles()); |
... | ... | |
371 | 380 |
this.parameterManager.addParameters(assemblyId, assembly.getParameters()); |
372 | 381 |
|
373 | 382 |
modelAndView.setViewName("redirect:/assembly_edit?assemblyID=" + assemblyId); |
383 |
modelMap.addAttribute(assemblySuccessName, "Sestava byla úspěšně vytvořena"); |
|
374 | 384 |
} |
375 | 385 |
|
376 | 386 |
modelMap.addAttribute("allRoles", this.roleManager.getRoles()); |
Také k dispozici: Unified diff
re #8150 - added success/error messages