diff --git a/controllers/contactPersonController.js b/controllers/contactPersonController.js index 67e2831..6cc0c1b 100644 --- a/controllers/contactPersonController.js +++ b/controllers/contactPersonController.js @@ -3,7 +3,16 @@ const { Op } = require('sequelize'); const getAllContactPersons = async (req, res) => { try { + const today = new Date(); + today.setHours(0, 0, 0, 0); + const contactPersons = await ContactPerson.findAll({ + where: { + [Op.or]: [ + { expiryDate: null }, + { expiryDate: { [Op.gte]: today } } + ] + }, include: [ { model: Position, @@ -79,6 +88,14 @@ const filterContactPersons = async (req, res) => { const where = {}; const having = []; + // Filter für nicht abgelaufene Kontaktpersonen + const today = new Date(); + today.setHours(0, 0, 0, 0); + where[Op.or] = [ + { expiryDate: null }, + { expiryDate: { [Op.gte]: today } } + ]; + if (config.selection.id && config.selection.id === 'all') { // No additional filter needed for "all" } else if (config.selection.id) { diff --git a/models/ContactPerson.js b/models/ContactPerson.js index 7a6915f..847b21d 100644 --- a/models/ContactPerson.js +++ b/models/ContactPerson.js @@ -25,6 +25,10 @@ module.exports = (sequelize) => { email: { type: DataTypes.STRING, allowNull: true + }, + expiryDate: { + type: DataTypes.DATEONLY, + allowNull: true } }, { tableName: 'contact_persons', diff --git a/sql/add_expiry_date_to_contact_persons.sql b/sql/add_expiry_date_to_contact_persons.sql new file mode 100644 index 0000000..0ae063c --- /dev/null +++ b/sql/add_expiry_date_to_contact_persons.sql @@ -0,0 +1,4 @@ +-- Ablaufdatum zu Kontaktpersonen hinzufügen +ALTER TABLE `contact_persons` +ADD COLUMN `expiryDate` DATE NULL AFTER `email`; + diff --git a/src/components/ContactPersonForm.vue b/src/components/ContactPersonForm.vue index 8b2477b..bb6da8f 100644 --- a/src/components/ContactPersonForm.vue +++ b/src/components/ContactPersonForm.vue @@ -20,6 +20,9 @@ Email: + Ablaufdatum (optional): + + Positionen: - {{ contact.name }} + {{ contact.name }} (bis {{ formatDate(contact.expiryDate) }}) Telefon: {{ contact.phone }} Straße: {{ contact.street }} Postleitzahl: {{ contact.zipcode }} @@ -13,7 +13,7 @@ - {{ contact.name }} + {{ contact.name }} (bis {{ formatDate(contact.expiryDate) }}) , Telefon: {{ contact.phone }} , Straße: {{ contact.street }} , Postleitzahl: {{ contact.zipcode }} @@ -58,6 +58,17 @@ export default { this.loading = false; } }, + methods: { + formatDate(dateString) { + if (!dateString) return ''; + const date = new Date(dateString); + return date.toLocaleDateString('de-DE', { + day: '2-digit', + month: '2-digit', + year: 'numeric' + }); + } + } }; @@ -68,4 +79,9 @@ export default { .bottom-margin { margin-bottom: 1rem; } +.expiry-date { + font-size: 0.9em; + color: #666; + font-style: italic; +} \ No newline at end of file diff --git a/src/components/EventRender.vue b/src/components/EventRender.vue index 9490e42..aa10a12 100644 --- a/src/components/EventRender.vue +++ b/src/components/EventRender.vue @@ -11,7 +11,7 @@ formatTime(event.endTime) }} Uhr {{ event.eventPlace?.name }} {{ event.description }} - {{event.contactPersons.map(cp => cp.name).join(', ')}} + {{event.contactPersons.map(cp => formatContactPerson(cp)).join(', ')}} {{ event.institution?.name }} {{ event.eventType?.caption }} @@ -28,7 +28,7 @@ formatTime(events[0].endTime) }} Uhr {{ events[0].eventPlace?.name }} {{ events[0].description }} - {{events[0].contactPersons.map(cp => cp.name).join(', ')}} + {{events[0].contactPersons.map(cp => formatContactPerson(cp)).join(', ')}} {{ events[0].institution?.name }} {{ events[0].eventType?.caption }} @@ -102,6 +102,18 @@ export default { const path = '/images/uploads/' + response.data.filename; console.log(path); return path; + }, + formatContactPerson(contactPerson) { + if (!contactPerson.expiryDate) { + return contactPerson.name; + } + const date = new Date(contactPerson.expiryDate); + const formattedDate = date.toLocaleDateString('de-DE', { + day: '2-digit', + month: '2-digit', + year: 'numeric' + }); + return `${contactPerson.name} (bis ${formattedDate})`; } } }; diff --git a/src/content/admin/ContactPersonManagement.vue b/src/content/admin/ContactPersonManagement.vue index f31f252..341bcb4 100644 --- a/src/content/admin/ContactPersonManagement.vue +++ b/src/content/admin/ContactPersonManagement.vue @@ -33,6 +33,7 @@ export default { zipcode: '', city: '', email: '', + expiryDate: null, positions: [] }, positions: []
{{ contact.name }}
{{ contact.name }} (bis {{ formatDate(contact.expiryDate) }})
Telefon: {{ contact.phone }}
Straße: {{ contact.street }}
Postleitzahl: {{ contact.zipcode }}