optimized privileges management

This commit is contained in:
Jottyfan
2025-11-16 23:03:45 +01:00
parent a1fc517911
commit f2d327de2e
6 changed files with 21 additions and 6 deletions

View File

@@ -8,7 +8,7 @@ plugins {
} }
group = 'de.jottyfan.camporganizer' group = 'de.jottyfan.camporganizer'
version = '1.0.0' version = '1.0.1'
description = """CampOrganizer2""" description = """CampOrganizer2"""

View File

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import de.jottyfan.camporganizer.db.jooq.enums.EnumModule; import de.jottyfan.camporganizer.db.jooq.enums.EnumModule;
import de.jottyfan.camporganizer.module.admin.model.CampBean; import de.jottyfan.camporganizer.module.admin.model.CampBean;
@@ -54,6 +55,7 @@ public class AdminPrivilegesController extends CommonController {
model.addAttribute("selected", role); model.addAttribute("selected", role);
model.addAttribute("container", service.getPersonCampMappingByModule(EnumModule.valueOf(role))); model.addAttribute("container", service.getPersonCampMappingByModule(EnumModule.valueOf(role)));
model.addAttribute("pagedest", "_admin_privileges_rolebased_" + role); model.addAttribute("pagedest", "_admin_privileges_rolebased_" + role);
model.addAttribute("module", role);
return "/admin/privileges/rolebased"; return "/admin/privileges/rolebased";
} }
@@ -70,6 +72,7 @@ public class AdminPrivilegesController extends CommonController {
model.addAttribute("selected", campname); model.addAttribute("selected", campname);
model.addAttribute("container", service.getPersonModuleMappingByCamp(campid)); model.addAttribute("container", service.getPersonModuleMappingByCamp(campid));
model.addAttribute("pagedest", "_admin_privileges_campbased_" + campid); model.addAttribute("pagedest", "_admin_privileges_campbased_" + campid);
model.addAttribute("fkCamp", campid);
return "/admin/privileges/campbased"; return "/admin/privileges/campbased";
} }
@@ -86,6 +89,7 @@ public class AdminPrivilegesController extends CommonController {
model.addAttribute("selected", selected); model.addAttribute("selected", selected);
model.addAttribute("container", service.getModuleCampMappingByPerson(userid)); model.addAttribute("container", service.getModuleCampMappingByPerson(userid));
model.addAttribute("pagedest", "_admin_privileges_userbased_" + userid); model.addAttribute("pagedest", "_admin_privileges_userbased_" + userid);
model.addAttribute("fkProfile", userid);
return "/admin/privileges/userbased"; return "/admin/privileges/userbased";
} }
@@ -96,9 +100,12 @@ public class AdminPrivilegesController extends CommonController {
} }
@GetMapping("/admin/privileges/add/{pagedest}") @GetMapping("/admin/privileges/add/{pagedest}")
public String prepareAdd(Model model, @PathVariable("pagedest") String pagedest) { public String prepareAdd(Model model, @PathVariable("pagedest") String pagedest,
@RequestParam(name = "fkCamp", required = false) Integer fkCamp,
@RequestParam(name = "fkProfile", required = false) Integer fkProfile,
@RequestParam(name = "module", required = false) String module) {
model.addAttribute("pagedest", pagedest); model.addAttribute("pagedest", pagedest);
model.addAttribute("bean", new CampProfileBean()); model.addAttribute("bean", CampProfileBean.of(fkCamp, fkProfile, module));
model.addAttribute("profiles", service.getProfiles()); model.addAttribute("profiles", service.getProfiles());
model.addAttribute("camps", service.getAllCamps()); model.addAttribute("camps", service.getAllCamps());
model.addAttribute("modules", service.getAllModules()); model.addAttribute("modules", service.getAllModules());

View File

@@ -22,6 +22,14 @@ public class CampProfileBean implements Serializable {
@NotBlank @NotBlank
private String module; private String module;
public static final CampProfileBean of(Integer fkCamp, Integer fkProfile, String module) {
CampProfileBean bean = new CampProfileBean();
bean.setFkCamp(fkCamp);
bean.setFkProfile(fkProfile);
bean.setModule(module);
return bean;
}
/** /**
* @return the pk * @return the pk
*/ */

View File

@@ -51,7 +51,7 @@
</tbody> </tbody>
<tfoot> <tfoot>
<tr> <tr>
<td colspan="2" style="text-align: center"><a th:href="@{/admin/privileges/add/{d}(d=${pagedest})}" class="btn btn-outline-primary">neue Berechtigung vergeben</a></td> <td colspan="2" style="text-align: center"><a th:href="@{/admin/privileges/add/{d}?fkCamp={c}(d=${pagedest},c=${fkCamp})}" class="btn btn-outline-primary">neue Berechtigung vergeben</a></td>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>

View File

@@ -46,7 +46,7 @@
</tbody> </tbody>
<tfoot> <tfoot>
<tr> <tr>
<td colspan="2" style="text-align: center"><a th:href="@{/admin/privileges/add/{d}(d=${pagedest})}" class="btn btn-outline-primary">neue Berechtigung vergeben</a></td> <td colspan="2" style="text-align: center"><a th:href="@{/admin/privileges/add/{d}?module={m}(d=${pagedest},m=${module})}" class="btn btn-outline-primary">neue Berechtigung vergeben</a></td>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>

View File

@@ -51,7 +51,7 @@
</tbody> </tbody>
<tfoot> <tfoot>
<tr> <tr>
<td colspan="2" style="text-align: center"><a th:href="@{/admin/privileges/add/{d}(d=${pagedest})}" class="btn btn-outline-primary">neue Berechtigung vergeben</a></td> <td colspan="2" style="text-align: center"><a th:href="@{/admin/privileges/add/{d}?fkProfile={u}(d=${pagedest},u=${fkProfile})}" class="btn btn-outline-primary">neue Berechtigung vergeben</a></td>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>