Füge Ablaufdatum zu Kontaktpersonen hinzu: Implementiere die Möglichkeit, ein Ablaufdatum für Kontaktpersonen zu speichern und anzuzeigen. Aktualisiere die Filterlogik, um nur nicht abgelaufene Kontaktpersonen anzuzeigen, und passe die Benutzeroberfläche an, um das Ablaufdatum darzustellen.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -25,6 +25,10 @@ module.exports = (sequelize) => {
|
||||
email: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true
|
||||
},
|
||||
expiryDate: {
|
||||
type: DataTypes.DATEONLY,
|
||||
allowNull: true
|
||||
}
|
||||
}, {
|
||||
tableName: 'contact_persons',
|
||||
|
||||
4
sql/add_expiry_date_to_contact_persons.sql
Normal file
4
sql/add_expiry_date_to_contact_persons.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
-- Ablaufdatum zu Kontaktpersonen hinzufügen
|
||||
ALTER TABLE `contact_persons`
|
||||
ADD COLUMN `expiryDate` DATE NULL AFTER `email`;
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
<label for="email">Email:</label>
|
||||
<input type="email" id="email" v-model="localContactPerson.email">
|
||||
|
||||
<label for="expiryDate">Ablaufdatum (optional):</label>
|
||||
<input type="date" id="expiryDate" v-model="localContactPerson.expiryDate">
|
||||
|
||||
<label for="positions">Positionen:</label>
|
||||
<multiselect
|
||||
v-model="selectedPositions"
|
||||
@@ -57,6 +60,7 @@ export default {
|
||||
zipcode: '',
|
||||
city: '',
|
||||
email: '',
|
||||
expiryDate: null,
|
||||
positions: []
|
||||
})
|
||||
},
|
||||
@@ -111,6 +115,7 @@ export default {
|
||||
zipcode: '',
|
||||
city: '',
|
||||
email: '',
|
||||
expiryDate: null,
|
||||
positions: []
|
||||
};
|
||||
this.selectedPositions = [];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div v-if="config && config.style === 'box' && contacts && contacts.length && contacts.length > 0">
|
||||
<div v-for="contact in contacts" :key="contact.id" class="contact-box bottom-margin">
|
||||
<p>{{ contact.name }}</p>
|
||||
<p>{{ contact.name }} <span v-if="contact.expiryDate" class="expiry-date">(bis {{ formatDate(contact.expiryDate) }})</span></p>
|
||||
<p v-if="displayOptions.includes('phone')">Telefon: {{ contact.phone }}</p>
|
||||
<p v-if="displayOptions.includes('street')">Straße: {{ contact.street }}</p>
|
||||
<p v-if="displayOptions.includes('zipcode')">Postleitzahl: {{ contact.zipcode }}</p>
|
||||
@@ -13,7 +13,7 @@
|
||||
</div>
|
||||
<span v-else-if="config.style === 'float' && contacts && contacts.length && contacts.length > 0">
|
||||
<span v-for="contact in contacts" :key="contact.id" class="bottom-margin">
|
||||
{{ contact.name }}
|
||||
{{ contact.name }}<span v-if="contact.expiryDate" class="expiry-date"> (bis {{ formatDate(contact.expiryDate) }})</span>
|
||||
<span v-if="displayOptions.includes('phone')">, Telefon: {{ contact.phone }}</span>
|
||||
<span v-if="displayOptions.includes('street')">, Straße: {{ contact.street }}</span>
|
||||
<span v-if="displayOptions.includes('zipcode')">, Postleitzahl: {{ contact.zipcode }}</span>
|
||||
@@ -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'
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -68,4 +79,9 @@ export default {
|
||||
.bottom-margin {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.expiry-date {
|
||||
font-size: 0.9em;
|
||||
color: #666;
|
||||
font-style: italic;
|
||||
}
|
||||
</style>
|
||||
@@ -11,7 +11,7 @@
|
||||
formatTime(event.endTime) }}</span> Uhr</div>
|
||||
<div v-if="shouldDisplay('place')">{{ event.eventPlace?.name }}</div>
|
||||
<div v-if="shouldDisplay('description')" class="description">{{ event.description }}</div>
|
||||
<div v-if="shouldDisplay('contactPerson')">{{event.contactPersons.map(cp => cp.name).join(', ')}}
|
||||
<div v-if="shouldDisplay('contactPerson')">{{event.contactPersons.map(cp => formatContactPerson(cp)).join(', ')}}
|
||||
</div>
|
||||
<div v-if="shouldDisplay('institution')">{{ event.institution?.name }}</div>
|
||||
<div v-if="shouldDisplay('type')">{{ event.eventType?.caption }}</div>
|
||||
@@ -28,7 +28,7 @@
|
||||
formatTime(events[0].endTime) }}</span> Uhr</div>
|
||||
<div v-if="shouldDisplay('place')">{{ events[0].eventPlace?.name }}</div>
|
||||
<div v-if="shouldDisplay('description')" class="description">{{ events[0].description }}</div>
|
||||
<div v-if="shouldDisplay('contactPerson')">{{events[0].contactPersons.map(cp => cp.name).join(', ')}}
|
||||
<div v-if="shouldDisplay('contactPerson')">{{events[0].contactPersons.map(cp => formatContactPerson(cp)).join(', ')}}
|
||||
</div>
|
||||
<div v-if="shouldDisplay('institution')">{{ events[0].institution?.name }}</div>
|
||||
<div v-if="shouldDisplay('type')">{{ events[0].eventType?.caption }}</div>
|
||||
@@ -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})`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -33,6 +33,7 @@ export default {
|
||||
zipcode: '',
|
||||
city: '',
|
||||
email: '',
|
||||
expiryDate: null,
|
||||
positions: []
|
||||
},
|
||||
positions: []
|
||||
|
||||
Reference in New Issue
Block a user