Mercurial > gemma
changeset 4474:063f7a48904e
FWA_dialogue: date picking more robust
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 24 Sep 2019 17:03:25 +0200 |
parents | 3543af71d04c |
children | b74d98fc82a5 |
files | client/src/components/fairway/AvailableFairwayDepthDialogue.vue |
diffstat | 1 files changed, 38 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/fairway/AvailableFairwayDepthDialogue.vue Tue Sep 24 16:39:06 2019 +0200 +++ b/client/src/components/fairway/AvailableFairwayDepthDialogue.vue Tue Sep 24 17:03:25 2019 +0200 @@ -680,14 +680,46 @@ return setQuarter(new Date(year, 1, 1), quarter); }, calcStart() { - this.fromDate = isoFormat( - startOfMonth(new Date(this.startYear, this.startMonth - 1)) - ); + switch (this.selectedFrequency) { + case this.$options.FREQUENCIES.monthly: + this.fromDate = isoFormat( + startOfMonth(new Date(this.startYear, this.startMonth - 1, 1)) + ); + break; + case this.$options.FREQUENCIES.quarterly: + this.fromDate = isoFormat( + startOfQuarter( + this.quarterToDate(this.startYear, this.startQuarter) + ) + ); + break; + case this.$options.FREQUENCIES.yearly: + this.fromDate = isoFormat(new Date(this.startYear, 0, 1)); + break; + default: + throw new Error("undefined frequency"); + } }, calcEnd() { - this.toDate = isoFormat( - endOfMonth(new Date(this.endYear, this.endMonth - 1)) - ); + switch (this.selectedFrequency) { + case this.$options.FREQUENCIES.monthly: + this.toDate = isoFormat( + endOfMonth(new Date(this.endYear, this.endMonth - 1, 1)) + ); + break; + case this.$options.FREQUENCIES.quarterly: + this.toDate = isoFormat( + isoFormat( + endOfQuarter(this.quarterToDate(this.endYear, this.endQuarter)) + ) + ); + break; + case this.$options.FREQUENCIES.yearly: + this.toDate = isoFormat(endOfYear(new Date(this.endYear, 11, 31))); + break; + default: + throw new Error("undefined frequency"); + } }, initDates() { const endDate = new Date();