From d4fab1ceb39144c54bbc9dfecc32a9b89614d9e8 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Tue, 7 Oct 2025 17:45:45 +0200 Subject: [PATCH] =?UTF-8?q?F=C3=BCge=20Ablaufdatum=20zu=20Kontaktpersonen?= =?UTF-8?q?=20hinzu:=20Implementiere=20die=20M=C3=B6glichkeit,=20ein=20Abl?= =?UTF-8?q?aufdatum=20f=C3=BCr=20Kontaktpersonen=20zu=20speichern=20und=20?= =?UTF-8?q?anzuzeigen.=20Aktualisiere=20die=20Filterlogik,=20um=20nur=20ni?= =?UTF-8?q?cht=20abgelaufene=20Kontaktpersonen=20anzuzeigen,=20und=20passe?= =?UTF-8?q?=20die=20Benutzeroberfl=C3=A4che=20an,=20um=20das=20Ablaufdatum?= =?UTF-8?q?=20darzustellen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/contactPersonController.js | 17 ++++++++++++++++ models/ContactPerson.js | 4 ++++ sql/add_expiry_date_to_contact_persons.sql | 4 ++++ src/components/ContactPersonForm.vue | 5 +++++ src/components/ContactRender.vue | 20 +++++++++++++++++-- src/components/EventRender.vue | 16 +++++++++++++-- src/content/admin/ContactPersonManagement.vue | 1 + 7 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 sql/add_expiry_date_to_contact_persons.sql 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 @@ + + +
-

{{ 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: []