added missing pages

This commit is contained in:
Torsten Schulz
2024-06-24 11:55:59 +02:00
parent 8b89d8b800
commit bc5a606176
15 changed files with 250 additions and 30 deletions

View File

@@ -77,25 +77,25 @@ const filterContactPersons = async (req, res) => {
console.log(configString, typeof configString);
const config = JSON.parse(configString);
const where = {};
const having = [];
console.log(config, typeof config);
console.log(config.selection);
if (config.selection.id && config.selection.id === 'all') {
// No additional filter needed for "all"
} else if (config.selection.id) {
where.id = config.selection.id;
} else {
const filters = [];
if (config.selection.types && config.selection.types.length > 0) {
filters.push({ '$positions.id$': { [Op.in]: config.selection.types } });
having.push({ '$positions.id$': { [Op.in]: config.selection.types } });
}
if (config.selection.places && config.selection.places.length > 0) {
filters.push({ '$events.eventPlaceId$': { [Op.in]: config.selection.places } });
having.push({ '$events.eventPlaceId$': { [Op.in]: config.selection.places } });
}
if (filters.length > 0) {
where[Op.and] = filters;
if (config.selection.positions && config.selection.positions.length > 0) {
having.push({ '$positions.id$': { [Op.in]: config.selection.positions } });
}
}
@@ -106,13 +106,16 @@ const filterContactPersons = async (req, res) => {
model: Position,
as: 'positions',
through: { attributes: [] },
required: true, // Ensure only contact persons with matching positions are included
},
{
model: Event,
as: 'events',
through: { attributes: [] },
required: false,
},
],
having: having.length > 0 ? { [Op.and]: having } : undefined,
});
res.json(contactPersons);