From 378e0061f84d2645cc141f2b2e08e8e6fbed093c Mon Sep 17 00:00:00 2001 From: David Loe Date: Wed, 28 Jun 2023 12:22:30 +0200 Subject: [PATCH] auto generate travel name --- backend/routes/routes.js | 5 +++++ backend/settings.json | 3 ++- common/locales/de.json | 17 ++++++++++++++++- common/locales/en.json | 17 ++++++++++++++++- .../components/Elements/TravelApplication.vue | 5 +++-- frontend/src/components/Elements/TravelCard.vue | 2 +- 6 files changed, 43 insertions(+), 6 deletions(-) diff --git a/backend/routes/routes.js b/backend/routes/routes.js index 5a437af9..dca1706a 100644 --- a/backend/routes/routes.js +++ b/backend/routes/routes.js @@ -319,6 +319,11 @@ router.post('/travel/appliedFor', async (req, res) => { delete req.body.stages delete req.body.expenses delete req.body.professionalShare + + if(!req.body.name){ + var date = new Date(req.body.startDate) + req.body.name = req.body.destinationPlace.place + ' ' + i18n.t('monthsShort.' + date.getUTCMonth(), {lng: user.settings.language}) + ' ' + date.getUTCFullYear() + } const check = async (oldObject) => { return oldObject.state === 'appliedFor' || oldObject.state === 'rejected' diff --git a/backend/settings.json b/backend/settings.json index 2b9c7199..48b64f45 100644 --- a/backend/settings.json +++ b/backend/settings.json @@ -10,5 +10,6 @@ "toleranceStageDatesToApprovedTravelDates": 3, "baseCurrency": {"_id": "EUR", "symbol": "€"}, "allowSpouseRefund": true, - "refundPerKM" : 0.3 + "refundPerKM" : 0.3, + "version": 0 } \ No newline at end of file diff --git a/common/locales/de.json b/common/locales/de.json index 81a594d8..512e9e7f 100755 --- a/common/locales/de.json +++ b/common/locales/de.json @@ -104,7 +104,8 @@ "invoiceDate": "Rechnungsdatum", "description": "Beschreibung", "receiptNumber" : "Beleg Nr.", - "date": "Datum" + "date": "Datum", + "days": "Tage" }, "alerts": { "noStagesPresent": "Es sind noch keine Etappen vorhanden. Füge eine hinzu.", @@ -195,6 +196,20 @@ "5": "Fr", "6": "Sa" }, + "monthsShort": { + "0": "Jan", + "1": "Feb", + "2": "März", + "3": "Apr", + "4": "Mai", + "5": "Jun", + "6": "Jul", + "7": "Aug", + "8": "Sept", + "9": "Okt", + "10": "Nov", + "11": "Dez" + }, "states":{ "rejected": "Abgelehnt", "appliedFor": "Beantragt", diff --git a/common/locales/en.json b/common/locales/en.json index ffd4eb86..c44644bf 100755 --- a/common/locales/en.json +++ b/common/locales/en.json @@ -104,7 +104,8 @@ "invoiceDate": "Date of invoice", "description": "Description", "receiptNumber" : "Receipt No.", - "date": "Date" + "date": "Date", + "days": "Days" }, "alerts": { "noStagesPresent": "There are no stages present jet.", @@ -196,6 +197,20 @@ "5": "Fri", "6": "Sat" }, + "monthsShort": { + "0": "Jan", + "1": "Feb", + "2": "Mar", + "3": "Apr", + "4": "May", + "5": "June", + "6": "July", + "7": "Aug", + "8": "Sept", + "9": "Oct", + "10": "Nov", + "11": "Dec" + }, "states":{ "rejected": "Rejected", "appliedFor": "Applied for", diff --git a/frontend/src/components/Elements/TravelApplication.vue b/frontend/src/components/Elements/TravelApplication.vue index 5dc812a7..44f6facc 100644 --- a/frontend/src/components/Elements/TravelApplication.vue +++ b/frontend/src/components/Elements/TravelApplication.vue @@ -48,7 +48,7 @@