# HG changeset patch # User Thomas Junk # Date 1569337405 -7200 # Node ID 063f7a48904edff7fce3dc055e5b57029580d9f5 # Parent 3543af71d04c6c472dff93453b1bf6accb699984 FWA_dialogue: date picking more robust diff -r 3543af71d04c -r 063f7a48904e client/src/components/fairway/AvailableFairwayDepthDialogue.vue --- 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();