Skip to content

Commit

Permalink
auto generate travel name
Browse files Browse the repository at this point in the history
  • Loading branch information
david-loe committed Jun 28, 2023
1 parent 860e920 commit 378e006
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 6 deletions.
5 changes: 5 additions & 0 deletions backend/routes/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 2 additions & 1 deletion backend/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"toleranceStageDatesToApprovedTravelDates": 3,
"baseCurrency": {"_id": "EUR", "symbol": ""},
"allowSpouseRefund": true,
"refundPerKM" : 0.3
"refundPerKM" : 0.3,
"version": 0
}
17 changes: 16 additions & 1 deletion common/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
17 changes: 16 additions & 1 deletion common/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/Elements/TravelApplication.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<script>
import StatePipeline from './StatePipeline.vue'
import PlaceElement from './PlaceElement.vue'
import { getMoneyString, datetoDateString } from '../../common/scripts.js'
import { getMoneyString, datetoDateStringWithYear, getDiffInDays } from '../../common/scripts.js'
export default {
name: 'TravelApply',
data() {
Expand All @@ -66,8 +66,9 @@ export default {
displayKey(key) {
switch (key) {
case 'startDate':
return datetoDateStringWithYear(this.travel[key])
case 'endDate':
return datetoDateString(this.travel[key])
return datetoDateStringWithYear(this.travel[key]) + ' (' + (getDiffInDays(this.travel.startDate, this.travel.endDate) + 1) + ' ' + this.$t('labels.days') + ')'
case 'state':
return this.$t('states.' + this.travel[key])
case 'editor':
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Elements/TravelCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="card-body">
<div class="row">
<div class="col">
<h5 class="card-title">{{ travel.name ? travel.name : travel.reason }}</h5>
<h5 class="card-title">{{ travel.name }}</h5>
</div>
<div class="col-auto">
<ProgressCircle v-if="['approved', 'underExamination'].indexOf(travel.state) !== -1" :progress="travel.progress"></ProgressCircle>
Expand Down

0 comments on commit 378e006

Please sign in to comment.