basic registration feature

This commit is contained in:
Jottyfan
2024-12-01 19:16:05 +01:00
parent bf88306d85
commit 634c0d7b1c
32 changed files with 556 additions and 69 deletions

View File

@ -19,7 +19,7 @@
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17/"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21/"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer">
<attributes>

View File

@ -0,0 +1,4 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
org.eclipse.jdt.core.compiler.compliance=21
org.eclipse.jdt.core.compiler.source=21

View File

@ -1,14 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="BiCO">
<property name="context-root" value="BiCO"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
</wb-module>
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="BiCO">
<property name="context-root" value="BiCO"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
</wb-module>
</project-modules>

View File

@ -3,5 +3,5 @@
<fixed facet="jst.java"/>
<fixed facet="jst.web"/>
<installed facet="jst.web" version="2.4"/>
<installed facet="jst.java" version="17"/>
<installed facet="jst.java" version="21"/>
</faceted-project>

View File

@ -8,7 +8,7 @@ plugins {
}
group = 'de.jottyfan.bico'
version = '0.1.5'
version = '0.1.6'
description = """BibleClassOrganizer"""
@ -18,8 +18,8 @@ java {
}
}
sourceCompatibility = 17
targetCompatibility = 17
sourceCompatibility = 21
targetCompatibility = 21
mainClassName = "de.jottyfan.bico.Main"
@ -47,7 +47,7 @@ war {
}
dependencies {
implementation 'de.jottyfan:bicolib:4'
implementation 'de.jottyfan:bicolib:5'
implementation 'org.mnode.ical4j:ical4j:4.0.4'

View File

@ -1,5 +1,7 @@
package de.jottyfan.bico;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
@ -13,6 +15,8 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
@SpringBootApplication
public class Main extends SpringBootServletInitializer {
public static final Logger LOGGER = LogManager.getLogger(Main.class);
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Main.class);

View File

@ -0,0 +1,74 @@
package de.jottyfan.bico.modules.camp;
import java.security.Principal;
import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import de.jottyfan.bico.db.camp.enums.EnumSex;
import de.jottyfan.bico.modules.CommonController;
import de.jottyfan.bico.modules.camp.model.RegistrationBean;
import jakarta.validation.Valid;
/**
*
* @author jotty
*
*/
@Controller
public class RegistrationController extends CommonController {
@Autowired
private RegistrationService service;
@GetMapping("/camp/registration")
public String loadForm(Model model, Principal principal) {
model.addAttribute("registrations", service.getRegistrations(principal));
model.addAttribute("bean", new RegistrationBean());
model.addAttribute("sexes", EnumSex.values());
return "/camp/registration";
}
@PostMapping("/camp/registration/submit")
public String submitAddForm(@Valid @ModelAttribute("bean") RegistrationBean bean, BindingResult bindingResult,
Model model, Principal principal) {
if (bindingResult.hasErrors()) {
model.addAttribute("registrations", new ArrayList<RegistrationBean>()); // hack to make "Neue Anmeldung" appear
model.addAttribute("sexes", EnumSex.values());
return "/camp/registration";
}
service.save(bean, principal);
return "redirect:/camp/registration";
}
@GetMapping("/camp/registration/edit/{id}")
public String loadEditForm(@PathVariable("id") Integer id, Model model, Principal principal) {
model.addAttribute("bean", service.getBeanOfPrincipal(id, principal));
model.addAttribute("sexes", EnumSex.values());
return "/camp/edit";
}
@GetMapping("/camp/registration/delete/{id}")
public String delete(@PathVariable("id") Integer id, Model model, Principal principal) {
service.delete(id, principal);
return "redirect:/camp/registration";
}
@PostMapping("/camp/registration/correct")
public String submitEditForm(@Valid @ModelAttribute("bean") RegistrationBean bean, BindingResult bindingResult,
Model model, Principal principal) {
if (bindingResult.hasErrors()) {
model.addAttribute("sexes", EnumSex.values());
return "/camp/registration";
}
service.save(bean, principal);
return "redirect:/camp/registration";
}
}

View File

@ -0,0 +1,120 @@
package de.jottyfan.bico.modules.camp;
import static de.jottyfan.bico.db.camp.Tables.T_REGISTRATION;
import java.util.List;
import org.jooq.DSLContext;
import org.jooq.DeleteConditionStep;
import org.jooq.InsertValuesStep5;
import org.jooq.SelectConditionStep;
import org.jooq.UpdateConditionStep;
import org.jooq.impl.DSL;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import de.jottyfan.bico.Main;
import de.jottyfan.bico.db.camp.enums.EnumCamp;
import de.jottyfan.bico.db.camp.enums.EnumSex;
import de.jottyfan.bico.db.camp.tables.records.TRegistrationRecord;
import de.jottyfan.bico.modules.camp.model.RegistrationBean;
import jakarta.validation.Valid;
/**
*
* @author jotty
*
*/
@Repository
public class RegistrationRepository {
@Autowired
private DSLContext jooq;
/**
* save the validated bean
*
* @param bean the bean
* @param registrator the principal name
*/
public void save(@Valid RegistrationBean bean, String registrator) {
jooq.transaction(t -> {
if (bean.getPkRegistration() == null) {
InsertValuesStep5<TRegistrationRecord, EnumCamp, String, String, String, EnumSex> sql = DSL.using(t)
// @formatter:off
.insertInto(T_REGISTRATION,
T_REGISTRATION.CAMP,
T_REGISTRATION.REGISTRATOR,
T_REGISTRATION.FORENAME,
T_REGISTRATION.SURNAME,
T_REGISTRATION.SEX)
.values(EnumCamp.Gemeindefreizeit_2025, registrator, bean.getForename(), bean.getSurname(), EnumSex.lookupLiteral(bean.getSex()));
// @formatter:on
Main.LOGGER.trace(sql);
sql.execute();
} else {
UpdateConditionStep<TRegistrationRecord> sql = DSL.using(t)
// @formatter:off
.update(T_REGISTRATION)
.set(T_REGISTRATION.FORENAME, bean.getForename())
.set(T_REGISTRATION.SURNAME, bean.getSurname())
.set(T_REGISTRATION.SEX, EnumSex.lookupLiteral(bean.getSex()))
.set(T_REGISTRATION.REGISTRATOR, registrator)
.where(T_REGISTRATION.PK_REGISTRATION.eq(bean.getPkRegistration()));
// @formatter:on
Main.LOGGER.trace(sql);
sql.execute();
}
});
}
/**
* get all registrations of name
*
* @param name the name
* @return the registrations
*/
public List<RegistrationBean> getRegistrations(String name) {
SelectConditionStep<TRegistrationRecord> sql = jooq
// @formatter:off
.selectFrom(T_REGISTRATION)
.where(T_REGISTRATION.REGISTRATOR.eq(name));
// @formatter:on
Main.LOGGER.trace(sql);
return sql.fetchInto(RegistrationBean.class);
}
/**
* get the registration of id if the creator is the name; null else
*
* @param id the id
* @param name the name
* @return the bean or null
*/
public RegistrationBean getBean(Integer id, String name) {
SelectConditionStep<TRegistrationRecord> sql = jooq
// @formatter:off
.selectFrom(T_REGISTRATION)
.where(T_REGISTRATION.PK_REGISTRATION.eq(id))
.and(T_REGISTRATION.REGISTRATOR.eq(name));
// @formatter:on
Main.LOGGER.trace(sql);
return sql.fetchOneInto(RegistrationBean.class);
}
/**
* delete the registration if the name is the creator
*
* @param id the id
* @param name the name
*/
public void delete(Integer id, String name) {
DeleteConditionStep<TRegistrationRecord> sql = jooq
// @formatter:off
.deleteFrom(T_REGISTRATION)
.where(T_REGISTRATION.PK_REGISTRATION.eq(id))
.and(T_REGISTRATION.REGISTRATOR.eq(name));
// @formatter:on
Main.LOGGER.trace(sql);
sql.execute();
}
}

View File

@ -0,0 +1,62 @@
package de.jottyfan.bico.modules.camp;
import java.security.Principal;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import de.jottyfan.bico.modules.camp.model.RegistrationBean;
import jakarta.validation.Valid;
/**
*
* @author jotty
*
*/
@Service
public class RegistrationService {
@Autowired
private RegistrationRepository repository;
/**
* save the bean content
*
* @param bean the bean
*/
public void save(@Valid RegistrationBean bean, Principal principal) {
repository.save(bean, principal.getName());
}
/**
* get the registrations of principal
*
* @param principal the principal
* @return the registrations
*/
public List<RegistrationBean> getRegistrations(Principal principal) {
return repository.getRegistrations(principal.getName());
}
/**
* get the registration if the principal was the creator
*
* @param id the ID of the registration
* @param principal the principal
* @return the bean or null if not found or allowed
*/
public RegistrationBean getBeanOfPrincipal(Integer id, Principal principal) {
return repository.getBean(id, principal.getName());
}
/**
* delete the registration if the principal was the creator
*
* @param id the ID of the registration
* @param principal the principal
*/
public void delete(Integer id, Principal principal) {
repository.delete(id, principal.getName());
}
}

View File

@ -0,0 +1,78 @@
package de.jottyfan.bico.modules.camp.model;
import java.io.Serializable;
import jakarta.validation.constraints.NotBlank;
/**
*
* @author jotty
*
*/
public class RegistrationBean implements Serializable {
private static final long serialVersionUID = 1L;
private Integer pkRegistration;
@NotBlank
private String forename;
@NotBlank
private String surname;
@NotBlank
private String sex;
/**
* @return the forename
*/
public String getForename() {
return forename;
}
/**
* @param forename the forename to set
*/
public void setForename(String forename) {
this.forename = forename;
}
/**
* @return the surname
*/
public String getSurname() {
return surname;
}
/**
* @param surname the surname to set
*/
public void setSurname(String surname) {
this.surname = surname;
}
/**
* @return the sex
*/
public String getSex() {
return sex;
}
/**
* @param sex the sex to set
*/
public void setSex(String sex) {
this.sex = sex;
}
/**
* @return the pkRegistration
*/
public Integer getPkRegistration() {
return pkRegistration;
}
/**
* @param pkRegistration the pkRegistration to set
*/
public void setPkRegistration(Integer pkRegistration) {
this.pkRegistration = pkRegistration;
}
}

View File

@ -1,6 +1,6 @@
package de.jottyfan.bico.modules.download;
import static de.jottyfan.bico.db.Tables.V_CALENDAR;
import static de.jottyfan.bico.db.public_.Tables.V_CALENDAR;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -9,7 +9,7 @@ import org.jooq.SelectWhereStep;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import de.jottyfan.bico.db.tables.records.VCalendarRecord;
import de.jottyfan.bico.db.public_.tables.records.VCalendarRecord;
/**
*

View File

@ -20,7 +20,7 @@ public class IcalController extends CommonController{
@GetMapping("/ical")
public void getIcalExport(HttpServletResponse response) throws Exception {
response.setHeader("Content-Disposition", "attachment; filename=bico.ical");
response.setHeader("Content-Disposition", "attachment; filename=bico.ics");
response.setContentType("application/octet-stream");
response.setHeader("Content-Transfer-Encoding", "binary");
response.setHeader("Accept-Ranges", "bytes");

View File

@ -1,6 +1,6 @@
package de.jottyfan.bico.modules.ical;
import static de.jottyfan.bico.db.Tables.V_CALENDAR;
import static de.jottyfan.bico.db.public_.Tables.V_CALENDAR;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -9,7 +9,7 @@ import org.jooq.SelectWhereStep;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import de.jottyfan.bico.db.tables.records.VCalendarRecord;
import de.jottyfan.bico.db.public_.tables.records.VCalendarRecord;
/**
*

View File

@ -8,7 +8,7 @@ import java.time.LocalTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import de.jottyfan.bico.db.tables.records.VCalendarRecord;
import de.jottyfan.bico.db.public_.tables.records.VCalendarRecord;
import net.fortuna.ical4j.data.CalendarOutputter;
import net.fortuna.ical4j.model.Calendar;
import net.fortuna.ical4j.model.component.VEvent;

View File

@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import de.jottyfan.bico.db.tables.records.TLessonRecord;
import de.jottyfan.bico.db.public_.tables.records.TLessonRecord;
import de.jottyfan.bico.modules.CommonController;
/**
*

View File

@ -1,8 +1,8 @@
package de.jottyfan.bico.modules.lesson;
import static de.jottyfan.bico.db.Tables.T_LESSON;
import static de.jottyfan.bico.db.Tables.T_PERSON;
import static de.jottyfan.bico.db.Tables.T_SLOT;
import static de.jottyfan.bico.db.public_.Tables.T_LESSON;
import static de.jottyfan.bico.db.public_.Tables.T_PERSON;
import static de.jottyfan.bico.db.public_.Tables.T_SLOT;
import java.time.LocalDate;
import java.util.List;
@ -19,8 +19,8 @@ import org.jooq.UpdateConditionStep;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import de.jottyfan.bico.db.tables.records.TLessonRecord;
import de.jottyfan.bico.db.tables.records.TPersonRecord;
import de.jottyfan.bico.db.public_.tables.records.TLessonRecord;
import de.jottyfan.bico.db.public_.tables.records.TPersonRecord;
/**
*

View File

@ -6,8 +6,8 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import de.jottyfan.bico.db.tables.records.TLessonRecord;
import de.jottyfan.bico.db.tables.records.TPersonRecord;
import de.jottyfan.bico.db.public_.tables.records.TLessonRecord;
import de.jottyfan.bico.db.public_.tables.records.TPersonRecord;
/**
*

View File

@ -1,6 +1,6 @@
package de.jottyfan.bico.modules.next;
import static de.jottyfan.bico.db.Tables.V_CALENDAR;
import static de.jottyfan.bico.db.public_.Tables.V_CALENDAR;
import java.time.LocalDate;
import java.util.ArrayList;

View File

@ -1,6 +1,6 @@
package de.jottyfan.bico.modules.profile;
import static de.jottyfan.bico.db.Tables.T_PROFILE;
import static de.jottyfan.bico.db.public_.Tables.T_PROFILE;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -10,7 +10,7 @@ import org.jooq.SelectConditionStep;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import de.jottyfan.bico.db.tables.records.TProfileRecord;
import de.jottyfan.bico.db.public_.tables.records.TProfileRecord;
import de.jottyfan.bico.modules.profile.model.ProfileBean;
/**

View File

@ -1,6 +1,6 @@
package de.jottyfan.bico.modules.sheet;
import static de.jottyfan.bico.db.Tables.V_CALENDAR;
import static de.jottyfan.bico.db.public_.Tables.V_CALENDAR;
import java.util.List;
@ -11,7 +11,7 @@ import org.jooq.SelectWhereStep;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import de.jottyfan.bico.db.tables.records.VCalendarRecord;
import de.jottyfan.bico.db.public_.tables.records.VCalendarRecord;
/**
*

View File

@ -5,7 +5,7 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import de.jottyfan.bico.db.tables.records.VCalendarRecord;
import de.jottyfan.bico.db.public_.tables.records.VCalendarRecord;
/**
*

View File

@ -1,7 +1,7 @@
package de.jottyfan.bico.modules.slot;
import static de.jottyfan.bico.db.Tables.T_LESSON;
import static de.jottyfan.bico.db.Tables.T_SLOT;
import static de.jottyfan.bico.db.public_.Tables.T_LESSON;
import static de.jottyfan.bico.db.public_.Tables.T_SLOT;
import java.util.Iterator;
@ -15,8 +15,8 @@ import org.jooq.UpdateConditionStep;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import de.jottyfan.bico.db.tables.records.TLessonRecord;
import de.jottyfan.bico.db.tables.records.TSlotRecord;
import de.jottyfan.bico.db.public_.tables.records.TLessonRecord;
import de.jottyfan.bico.db.public_.tables.records.TSlotRecord;
import de.jottyfan.bico.modules.slot.model.SlotBean;
/**

View File

@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import de.jottyfan.bico.db.tables.records.TSubjectRecord;
import de.jottyfan.bico.db.public_.tables.records.TSubjectRecord;
import de.jottyfan.bico.modules.CommonController;
/**

View File

@ -1,9 +1,9 @@
package de.jottyfan.bico.modules.subject;
import static de.jottyfan.bico.db.Tables.T_LESSON_SUBJECT;
import static de.jottyfan.bico.db.Tables.T_SOURCE;
import static de.jottyfan.bico.db.Tables.T_SUBJECT;
import static de.jottyfan.bico.db.Tables.V_LESSON;
import static de.jottyfan.bico.db.public_.Tables.T_LESSON_SUBJECT;
import static de.jottyfan.bico.db.public_.Tables.T_SOURCE;
import static de.jottyfan.bico.db.public_.Tables.T_SUBJECT;
import static de.jottyfan.bico.db.public_.Tables.V_LESSON;
import java.util.List;
@ -19,9 +19,9 @@ import org.jooq.UpdateConditionStep;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import de.jottyfan.bico.db.tables.records.TSourceRecord;
import de.jottyfan.bico.db.tables.records.TSubjectRecord;
import de.jottyfan.bico.db.tables.records.VLessonRecord;
import de.jottyfan.bico.db.public_.tables.records.TSourceRecord;
import de.jottyfan.bico.db.public_.tables.records.TSubjectRecord;
import de.jottyfan.bico.db.public_.tables.records.VLessonRecord;
/**
*

View File

@ -5,9 +5,9 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import de.jottyfan.bico.db.tables.records.TSourceRecord;
import de.jottyfan.bico.db.tables.records.TSubjectRecord;
import de.jottyfan.bico.db.tables.records.VLessonRecord;
import de.jottyfan.bico.db.public_.tables.records.TSourceRecord;
import de.jottyfan.bico.db.public_.tables.records.TSubjectRecord;
import de.jottyfan.bico.db.public_.tables.records.VLessonRecord;
/**
*

View File

@ -2,7 +2,7 @@ package de.jottyfan.bico.modules.subject.model;
import java.io.Serializable;
import de.jottyfan.bico.db.tables.records.TSubjectRecord;
import de.jottyfan.bico.db.public_.tables.records.TSubjectRecord;
/**
*

View File

@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import de.jottyfan.bico.db.tables.records.TLessonRecord;
import de.jottyfan.bico.db.public_.tables.records.TLessonRecord;
import de.jottyfan.bico.modules.CommonController;
import jakarta.servlet.http.HttpServletRequest;

View File

@ -1,10 +1,10 @@
package de.jottyfan.bico.modules.theme;
import static de.jottyfan.bico.db.Tables.T_LESSON;
import static de.jottyfan.bico.db.Tables.T_LESSON_SUBJECT;
import static de.jottyfan.bico.db.Tables.T_SLOT;
import static de.jottyfan.bico.db.Tables.T_SOURCE;
import static de.jottyfan.bico.db.Tables.T_SUBJECT;
import static de.jottyfan.bico.db.public_.Tables.T_LESSON;
import static de.jottyfan.bico.db.public_.Tables.T_LESSON_SUBJECT;
import static de.jottyfan.bico.db.public_.Tables.T_SLOT;
import static de.jottyfan.bico.db.public_.Tables.T_SOURCE;
import static de.jottyfan.bico.db.public_.Tables.T_SUBJECT;
import java.time.LocalDate;
import java.util.ArrayList;
@ -25,8 +25,8 @@ import org.jooq.impl.DSL;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import de.jottyfan.bico.db.tables.records.TLessonRecord;
import de.jottyfan.bico.db.tables.records.TLessonSubjectRecord;
import de.jottyfan.bico.db.public_.tables.records.TLessonRecord;
import de.jottyfan.bico.db.public_.tables.records.TLessonSubjectRecord;
import de.jottyfan.bico.modules.theme.model.KeyValueBean;
import de.jottyfan.bico.modules.theme.model.ThemeBean;

View File

@ -6,7 +6,7 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import de.jottyfan.bico.db.tables.records.TLessonRecord;
import de.jottyfan.bico.db.public_.tables.records.TLessonRecord;
import de.jottyfan.bico.modules.theme.model.KeyValueBean;
import de.jottyfan.bico.modules.theme.model.ThemeBean;

View File

@ -0,0 +1,61 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" layout:decorate="~{template}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<body>
<th:block layout:fragment="content">
<div class="borderdist">
<div class="container">
<div class="row g-2">
<div class="col-sm-12">
<h2>Anmeldung zur Gemeindefreizeit 2025 bearbeiten</h2>
</div>
</div>
<div class="alert alert-danger" th:unless="${bean}">Sie haben keine Berechtigung, die Anmeldung mit dieser URL zu ändern.</div>
<form th:action="@{/camp/registration/correct}" method="post" th:object="${bean}" th:if="${bean}">
<input type="hidden" th:field="*{pkRegistration}" />
<div class="row g-3">
<div class="col-sm-3">Vorname</div>
<div class="col-sm-9">
<span th:if="${#fields.hasErrors('forename')}" th:errors="*{forename}" class="text-danger"></span> <input type="text" th:field="*{forename}" class="form-control" />
</div>
<div class="col-sm-3">Surname</div>
<div class="col-sm-9">
<span th:if="${#fields.hasErrors('surname')}" th:errors="*{surname}" class="text-danger"></span> <input type="text" th:field="*{surname}" class="form-control" />
</div>
<div class="col-sm-3">Geschlecht</div>
<div class="col-sm-9">
<span th:if="${#fields.hasErrors('sex')}" th:errors="*{sex}" class="text-danger"></span> <select th:field="*{sex}" class="form-select">
<option value="">--- bitte wählen ---</option>
<option th:each="s : ${sexes}" th:value="${s}" th:text="${s}"></option>
</select>
</div>
<div class="col-sm-3"></div>
<div class="col-sm-9">
<button type="submit" class="btn btn-outline-success">Korrigeren</button>
&nbsp; <a th:href="@{/camp/registration}" class="btn btn-outline-secondary">Abbrechen</a> &nbsp;
<button type="button" class="btn btn-outline-danger" data-bs-toggle="modal" data-bs-target="#deleteModal">Stornieren</button>
<div class="modal fade" id="deleteModal" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="deleteModalLabel">Löschen einer Anmeldung</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
Soll die Anmeldung von <span th:text="${bean.forename}"></span>&nbsp;<span th:text="${bean.surname}"></span>&nbsp;wirklich gelöscht werden?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Abbrechen</button>
<a th:href="@{/camp/registration/delete/{id}(id=${bean.pkRegistration})}" class="btn btn-outline-danger">Endgültig löschen</a>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</th:block>
</body>
</html>

View File

@ -0,0 +1,89 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" layout:decorate="~{template}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<body>
<th:block layout:fragment="content">
<div class="borderdist">
<div class="container">
<div class="row g-2">
<div class="col-sm-12">
<h2>Anmeldung zur Gemeindefreizeit 2025</h2>
</div>
</div>
<script th:inline="javascript">
function toggleTo(opener, name) {
$('.nav-opener').removeClass('active');
$('.tabpanel').hide();
$(opener).addClass('active');
$(name).show();
}
$(document).ready(function() {
var regsize = parseInt(/*[[${registrations.size()}]]*/"0");
if (regsize < 1) {
$("#open_new").addClass("active");
$("#new").show();
$("#open_found").removeClass("active");
$("#found").hide();
} else {
$("#open_new").removeClass("active");
$("#new").hide();
$("#open_found").addClass("active");
$("#found").show();
}
});
</script>
<ul class="nav nav-tabs">
<li class="nav-item"><a id="open_new" class="nav-link active nav-opener" aria-current="page" href="#" onclick="toggleTo(this, '#new')">Neue Anmeldung</a></li>
<li class="nav-item"><a id="open_found" class="nav-link nav-opener" href="#" onclick="toggleTo(this, '#found')">Bisherige Anmeldungen</a></li>
</ul>
<div class="tab-content">
<div id="new" class="tabpanel">
<form th:action="@{/camp/registration/submit}" method="post" th:object="${bean}">
<div class="row g-3">
<div class="col-sm-3">Vorname</div>
<div class="col-sm-9">
<span th:if="${#fields.hasErrors('forename')}" th:errors="*{forename}" class="text-danger"></span> <input type="text" th:field="*{forename}" class="form-control" />
</div>
<div class="col-sm-3">Surname</div>
<div class="col-sm-9">
<span th:if="${#fields.hasErrors('surname')}" th:errors="*{surname}" class="text-danger"></span> <input type="text" th:field="*{surname}" class="form-control" />
</div>
<div class="col-sm-3">Geschlecht</div>
<div class="col-sm-9">
<span th:if="${#fields.hasErrors('sex')}" th:errors="*{sex}" class="text-danger"></span> <select th:field="*{sex}" class="form-select">
<option value="">--- bitte wählen ---</option>
<option th:each="s : ${sexes}" th:value="${s}" th:text="${s}"></option>
</select>
</div>
<div class="col-sm-3"></div>
<div class="col-sm-9">
<button type="submit" class="btn btn-outline-success">Speichern</button>
&nbsp; <a th:href="@{/camp/registration}" class="btn btn-outline-secondary">Abbrechen</a>&nbsp;
</div>
</div>
</form>
</div>
<div id="found" class="tabpanel">
<table class="table table-striped">
<thead>
<tr>
<th>Vorname</th>
<th>Nachname</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<tr th:each="r : ${registrations}">
<td th:text="${r.forename}"></td>
<td th:text="${r.surname}"></td>
<td><a th:href="@{/camp/registration/edit/{id}(id=${r.pkRegistration})}" class="btn btn-outline-secondary"><i class="bi bi-pencil"></i></a></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</th:block>
</body>
</html>

View File

@ -25,14 +25,15 @@
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent" style="margin-right: 20px">
<ul class="navbar-nav mb-2 mb-lg-0" th:if="${hasAnyRole}">
<li class="nav-item"><a class="btn btn-outline-secondary" th:href="@{/next}" style="margin-left: 12px">Dienstplan</a></li>
<li class="nav-item"><a class="btn btn-outline-secondary" th:href="@{/camp/registration}" style="margin-left: 12px">Anmeldung Gemeindefreizeit</a></li>
<li class="nav-item"><a class="btn btn-outline-secondary" th:href="@{/next}" style="margin-left: 12px" th:if="${hasDateRole || hasBUrole}">Dienstplan</a></li>
<li class="nav-item"><a class="btn btn-outline-secondary" th:href="@{/sheet}" style="margin-left: 12px" th:if="${hasBUrole}">Einteilung</a></li>
<li class="nav-item"><a class="btn btn-outline-secondary" th:href="@{/subject/list}" style="margin-left: 12px" th:if="${hasBUrole}">Themen</a></li>
<li class="nav-item"><a class="btn btn-outline-secondary" th:href="@{/download}" style="margin-left: 12px" th:if="${hasBUrole}">Download</a></li>
</ul>
<ul layout:fragment="header"></ul>
<ul class="nav navbar-nav ms-auto">
<li class="nav-item">
<li class="nav-item" th:if="${hasDateRole}">
<a th:href="@{/ical}" class="btn btn-outline-secondary"><i class="bi bi-calendar-week"></i></a>
</li>
<li class="nav-item">