Mercurial > gemma
changeset 5439:a857d6ae1264 marking-single-beam
PDFTool now supports new template parameter {surveydate}.
In case there is a surveydate active and visible
{surveydate} shows the date when the survey took place.
Otherwise it behaves like {date-minor}
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 13 Jul 2021 13:00:41 +0200 |
parents | 4d1b1df61f71 |
children | 0fa20662ca66 |
files | client/src/lib/mixins.js |
diffstat | 1 files changed, 21 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/lib/mixins.js Tue Jul 13 12:24:45 2021 +0200 +++ b/client/src/lib/mixins.js Tue Jul 13 13:00:41 2021 +0200 @@ -440,6 +440,17 @@ if (text.includes("{date}")) { text = text.replace("{date}", new Date().toLocaleString(locale2)); } + const shortDate = d => { + return ( + (d.getDate() < 10 ? "0" : "") + + d.getDate() + + "." + + (d.getMonth() + 1 < 10 ? "0" : "") + + (d.getMonth() + 1) + + "." + + d.getFullYear() + ); + }; const hasVisibleSurvey = this.soundingInfo && this.bottleneckForPrint && @@ -447,23 +458,18 @@ this.openLayersMap() .getLayer("BOTTLENECKISOLINE") .getVisible(); + if (text.includes("{surveydate}") && hasVisibleSurvey) { + const dateFromSurvey = new Date(this.selectedSurvey["date_info"]); + let dt = shortDate(dateFromSurvey); + text = text.replace("{surveydate}", dt.toLocaleString(locale2)); + } else { + let dt = shortDate(new Date()); + text = text.replace("{surveydate}", dt.toLocaleString(locale2)); + } // get only day,month and year from the Date object if (text.includes("{date-minor}")) { - var date; - if (hasVisibleSurvey) { - date = new Date(this.selectedSurvey["date_info"]); - } else { - date = new Date(); - } - - var dt = - (date.getDate() < 10 ? "0" : "") + - date.getDate() + - "." + - (date.getMonth() + 1 < 10 ? "0" : "") + - (date.getMonth() + 1) + - "." + - date.getFullYear(); + var date = new Date(); + let dt = shortDate(date); text = text.replace("{date-minor}", dt.toLocaleString(locale2)); } if (text.includes("{user}")) {