Mercurial > gemma
comparison client/src/store/fairwayavailability.js @ 4468:130e929bab8f
available_fairway_depth_dialogue: more intuitive date selection
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Mon, 23 Sep 2019 16:16:42 +0200 |
parents | a075da82e875 |
children | 987a56071402 |
comparison
equal
deleted
inserted
replaced
4467:1518289c5168 | 4468:130e929bab8f |
---|---|
15 /*eslint no-unused-vars: ["error", { "varsIgnorePattern": "_" }]*/ | 15 /*eslint no-unused-vars: ["error", { "varsIgnorePattern": "_" }]*/ |
16 | 16 |
17 import { HTTP } from "@/lib/http"; | 17 import { HTTP } from "@/lib/http"; |
18 import { | 18 import { |
19 format, | 19 format, |
20 subYears, | |
21 startOfMonth, | 20 startOfMonth, |
22 endOfMonth, | 21 endOfMonth, |
23 startOfYear, | 22 startOfYear, |
24 endOfYear, | 23 endOfYear, |
25 startOfQuarter, | 24 startOfQuarter, |
39 | 38 |
40 const FREQUENCIES = { | 39 const FREQUENCIES = { |
41 MONTHLY: "monthly", | 40 MONTHLY: "monthly", |
42 QUARTERLY: "quarterly", | 41 QUARTERLY: "quarterly", |
43 YEARLY: "yearly" | 42 YEARLY: "yearly" |
44 }; | |
45 | |
46 const isoFormat = date => { | |
47 return format(date, "YYYY-MM-DD"); | |
48 }; | 43 }; |
49 | 44 |
50 const getIntervallBorders = (start, end, frequency) => { | 45 const getIntervallBorders = (start, end, frequency) => { |
51 switch (frequency) { | 46 switch (frequency) { |
52 case FREQUENCIES.MONTHLY: | 47 case FREQUENCIES.MONTHLY: |
58 default: | 53 default: |
59 throw new Error("Boom!"); | 54 throw new Error("Boom!"); |
60 } | 55 } |
61 }; | 56 }; |
62 | 57 |
58 const isoFormat = date => { | |
59 return format(date, "YYYY-MM-DD"); | |
60 }; | |
61 | |
63 const init = () => { | 62 const init = () => { |
64 return { | 63 return { |
65 type: TYPES.BOTTLENECK, | 64 type: TYPES.BOTTLENECK, |
66 selectedFairwayAvailabilityFeature: null, | 65 selectedFairwayAvailabilityFeature: null, |
67 to: isoFormat(new Date()), | 66 to: null, |
68 from: isoFormat(subYears(new Date(), 1)), | 67 from: null, |
69 frequency: FREQUENCIES.MONTHLY, | 68 frequency: FREQUENCIES.MONTHLY, |
70 limitingFactor: null, | 69 limitingFactor: null, |
71 depthlimit1: 230, | 70 depthlimit1: 230, |
72 depthlimit2: 250, | 71 depthlimit2: 250, |
73 widthlimit1: null, | 72 widthlimit1: null, |