feat(TrainingGroup): add excludeFromQuickDiaryCreate feature and update related logic
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 44s
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 44s
- Introduced a new boolean field `excludeFromQuickDiaryCreate` in the TrainingGroup model to control group visibility in quick diary creation. - Updated the `updateTrainingGroup` service method to handle the new field, allowing for dynamic updates based on user input. - Enhanced the TrainingTimesTab component to include a checkbox for excluding groups from quick diary creation, improving user interaction. - Updated localization files to include new strings related to the exclude feature, ensuring clarity in multiple languages. - Refactored logic in DiaryView and mobile app to consider the new exclusion criteria when suggesting training slots.
This commit is contained in:
@@ -159,9 +159,11 @@ class TrainingGroupService {
|
||||
return group;
|
||||
}
|
||||
|
||||
async updateTrainingGroup(userToken, clubId, groupId, name, sortOrder) {
|
||||
async updateTrainingGroup(userToken, clubId, groupId, body = {}) {
|
||||
await checkAccess(userToken, clubId);
|
||||
|
||||
|
||||
const { name, sortOrder, excludeFromQuickDiaryCreate } = body;
|
||||
|
||||
const group = await TrainingGroup.findOne({
|
||||
where: { id: groupId, clubId },
|
||||
});
|
||||
@@ -169,25 +171,31 @@ class TrainingGroupService {
|
||||
throw new HttpError('Gruppe nicht gefunden', 404);
|
||||
}
|
||||
|
||||
// Preset-Gruppen können nicht umbenannt werden
|
||||
if (group.isPreset && name !== group.name) {
|
||||
throw new HttpError('Vorgaben-Gruppen können nicht umbenannt werden', 400);
|
||||
}
|
||||
|
||||
// Prüfe, ob bereits eine andere Gruppe mit diesem Namen existiert
|
||||
if (name !== group.name) {
|
||||
const existing = await TrainingGroup.findOne({
|
||||
where: { clubId, name, id: { [Op.ne]: groupId } },
|
||||
});
|
||||
if (existing) {
|
||||
throw new HttpError('Eine Gruppe mit diesem Namen existiert bereits', 409);
|
||||
if (name !== undefined && name !== null) {
|
||||
// Preset-Gruppen können nicht umbenannt werden
|
||||
if (group.isPreset && name !== group.name) {
|
||||
throw new HttpError('Vorgaben-Gruppen können nicht umbenannt werden', 400);
|
||||
}
|
||||
|
||||
if (name !== group.name) {
|
||||
const existing = await TrainingGroup.findOne({
|
||||
where: { clubId, name, id: { [Op.ne]: groupId } },
|
||||
});
|
||||
if (existing) {
|
||||
throw new HttpError('Eine Gruppe mit diesem Namen existiert bereits', 409);
|
||||
}
|
||||
}
|
||||
group.name = name;
|
||||
}
|
||||
|
||||
group.name = name;
|
||||
if (sortOrder !== undefined) {
|
||||
if (sortOrder !== undefined && sortOrder !== null) {
|
||||
group.sortOrder = sortOrder;
|
||||
}
|
||||
|
||||
if (excludeFromQuickDiaryCreate !== undefined) {
|
||||
group.excludeFromQuickDiaryCreate = Boolean(excludeFromQuickDiaryCreate);
|
||||
}
|
||||
|
||||
await group.save();
|
||||
return group;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user