Corrections on MusicFolderSettingsController.

master
Rémi Cocula 8 years ago
parent a0ab86a6ac
commit b2b4384387
  1. 30
      libresonic-main/src/main/java/org/libresonic/player/controller/MusicFolderSettingsController.java
  2. 1
      libresonic-main/src/main/webapp/WEB-INF/jsp/musicFolderSettings.jsp

@ -64,7 +64,12 @@ public class MusicFolderSettingsController {
private MediaFileDao mediaFileDao;
@RequestMapping(method = RequestMethod.GET)
protected String formBackingObject(@RequestParam(value = "scanNow",required = false) String scanNow,
protected String displayForm() throws Exception {
return "musicFolderSettings";
}
@ModelAttribute
protected void formBackingObject(@RequestParam(value = "scanNow",required = false) String scanNow,
@RequestParam(value = "expunge",required = false) String expunge,
@RequestParam(value = "reload",required = false) String reload,
Model model) throws Exception {
@ -88,9 +93,9 @@ public class MusicFolderSettingsController {
command.setReload(reload != null || scanNow != null);
model.addAttribute("command",command);
return "musicFolderSettings";
}
private void expunge() {
artistDao.expunge();
albumDao.expunge();
@ -106,17 +111,15 @@ public class MusicFolderSettingsController {
}
@RequestMapping(method = RequestMethod.POST)
protected String onSubmit(@ModelAttribute MusicFolderSettingsCommand command, Model model) throws Exception {
if (command.getMusicFolders() != null) {
for (MusicFolderSettingsCommand.MusicFolderInfo musicFolderInfo : command.getMusicFolders()) {
if (musicFolderInfo.isDelete()) {
settingsService.deleteMusicFolder(musicFolderInfo.getId());
} else {
MusicFolder musicFolder = musicFolderInfo.toMusicFolder();
if (musicFolder != null) {
settingsService.updateMusicFolder(musicFolder);
}
protected String onSubmit(@ModelAttribute("command") MusicFolderSettingsCommand command, Model model) throws Exception {
for (MusicFolderSettingsCommand.MusicFolderInfo musicFolderInfo : command.getMusicFolders()) {
if (musicFolderInfo.isDelete()) {
settingsService.deleteMusicFolder(musicFolderInfo.getId());
} else {
MusicFolder musicFolder = musicFolderInfo.toMusicFolder();
if (musicFolder != null) {
settingsService.updateMusicFolder(musicFolder);
}
}
}
@ -133,7 +136,6 @@ public class MusicFolderSettingsController {
settingsService.save();
mediaScannerService.schedule();
model.addAttribute("command",command);
return "redirect:musicFolderSettings.view";
}

@ -38,7 +38,6 @@
<c:forEach items="${command.musicFolders}" var="folder" varStatus="loopStatus">
<tr>
<form:hidden path="musicFolders[${loopStatus.count-1}].id"/>
<td><form:input path="musicFolders[${loopStatus.count-1}].name" size="20"/></td>
<td><form:input path="musicFolders[${loopStatus.count-1}].path" size="40"/></td>
<td align="center" style="padding-left:1em"><form:checkbox path="musicFolders[${loopStatus.count-1}].enabled" cssClass="checkbox"/></td>

Loading…
Cancel
Save