From 50bb754d8fc403b5bce68200233783aa2d5eaaf1 Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Thu, 10 Oct 2024 00:40:34 +0200 Subject: [PATCH 01/31] chore: Move year selector into its own component --- src/pages/policy/input/ParameterEditor.jsx | 48 ++++++++++++++-------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/pages/policy/input/ParameterEditor.jsx b/src/pages/policy/input/ParameterEditor.jsx index b0038bbaf..eaf1ec2be 100644 --- a/src/pages/policy/input/ParameterEditor.jsx +++ b/src/pages/policy/input/ParameterEditor.jsx @@ -254,22 +254,6 @@ function PeriodSetter(props) { dateSelectButtonLabel = `from ${moment(startDate).year()} to ${moment(endDate).year()}:`; } - const yearSelector = ( - { - setStartDate(yearStrings[0].concat("-01-01")); - setEndDate(yearStrings[1].concat("-12-31")); - }} - disabledDate={(date) => - date.isBefore(minPossibleDate) || date.isAfter(maxPossibleDate) - } - separator="→" - /> - ); - const dateSelector = ( - {visibleDateSelector === "yearly" ? yearSelector : dateSelector} + {visibleDateSelector === "yearly" ? + + : dateSelector} ); @@ -331,6 +325,26 @@ function PeriodSetter(props) { ); } +function YearSetter(props) { + const { startDate, endDate, setStartDate, setEndDate, minPossibleDate, maxPossibleDate, isEndForever } = props; + + return ( + { + setStartDate(yearStrings[0].concat("-01-01")); + setEndDate(yearStrings[1].concat("-12-31")); + }} + disabledDate={(date) => + date.isBefore(minPossibleDate) || date.isAfter(maxPossibleDate) + } + separator="→" + /> + ) +} + function ValueSetter(props) { const { startDate, From c9167457ba954ed1b4324e7308c03475192fcf29 Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Thu, 17 Oct 2024 23:49:04 +0200 Subject: [PATCH 02/31] feat: Add input settings button (non-functional) --- src/pages/policy/input/ParameterEditor.jsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/pages/policy/input/ParameterEditor.jsx b/src/pages/policy/input/ParameterEditor.jsx index eaf1ec2be..f7829f197 100644 --- a/src/pages/policy/input/ParameterEditor.jsx +++ b/src/pages/policy/input/ParameterEditor.jsx @@ -25,7 +25,7 @@ import { import { IntervalMap } from "algorithms/IntervalMap"; import { cmpDates, nextDay, prevDay } from "lang/stringDates"; import moment from "dayjs"; -import { LeftOutlined, RightOutlined, UndoOutlined } from "@ant-design/icons"; +import { LeftOutlined, RightOutlined, SettingOutlined, UndoOutlined } from "@ant-design/icons"; import style from "../../../style"; const { RangePicker } = DatePicker; @@ -135,7 +135,7 @@ export default function ParameterEditor(props) {

+
{!parameter.economy && ( @@ -530,6 +531,20 @@ function AdvancedValueSetter(props) { ); } +function SettingsButton() { + return ( + + + + ); +} + /** * Checks whether or not an input date is a boundary date - * the first or last day of a fixed period (e.g., Jan. 1 or From 4d2d93809b65143d43b734fe77a0ada2b8b0cc52 Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Fri, 18 Oct 2024 00:09:52 +0200 Subject: [PATCH 03/31] feat: SettingsPanel (non-functional) --- src/pages/policy/input/ParameterEditor.jsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/pages/policy/input/ParameterEditor.jsx b/src/pages/policy/input/ParameterEditor.jsx index f7829f197..180d01ed8 100644 --- a/src/pages/policy/input/ParameterEditor.jsx +++ b/src/pages/policy/input/ParameterEditor.jsx @@ -172,7 +172,7 @@ export default function ParameterEditor(props) { reformMap={reformMap} baseMap={baseMap} /> - + {!parameter.economy && ( @@ -531,9 +531,13 @@ function AdvancedValueSetter(props) { ); } -function SettingsButton() { +function SettingsPanel() { return ( - + Test value

} + placement="bottomRight" + trigger="click" + > -
+ ); } From 0ba35f2ec67c45024124f793f270e0267be16ebd Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Fri, 18 Oct 2024 00:38:23 +0200 Subject: [PATCH 04/31] feat: Re-enable year selector --- src/pages/policy/input/ParameterEditor.jsx | 81 ++++++++++++++++------ 1 file changed, 60 insertions(+), 21 deletions(-) diff --git a/src/pages/policy/input/ParameterEditor.jsx b/src/pages/policy/input/ParameterEditor.jsx index 180d01ed8..8c5d194bf 100644 --- a/src/pages/policy/input/ParameterEditor.jsx +++ b/src/pages/policy/input/ParameterEditor.jsx @@ -6,7 +6,6 @@ import { DatePicker, InputNumber, Popover, - Segmented, Space, Switch, Tooltip, @@ -38,6 +37,14 @@ const { RangePicker } = DatePicker; * @param {String} props.parameterName * @returns {import("react-markdown/lib/react-markdown").ReactElement} */ + +const DATE_INPUT_MODES = { + DEFAULT: "default", + YEARLY: "yearly", + DATE: "date", + TEN_YEAR: "ten-year" +}; + export default function ParameterEditor(props) { const { metadata, policy, parameterName } = props; const parameter = metadata.parameters[parameterName]; @@ -57,6 +64,7 @@ export default function ParameterEditor(props) { const [startDate, setStartDate] = useState(defaultStartDate); const [endDate, setEndDate] = useState(defaultEndDate); const [paramChartWidth, setParamChartWidth] = useState(0); + const [dateInputMode, setDateInputMode] = useState(DATE_INPUT_MODES.YEARLY); useEffect(() => { if (chartContainerRef.current) { @@ -150,6 +158,7 @@ export default function ParameterEditor(props) { endDate={endDate} setStartDate={setStartDate} setEndDate={setEndDate} + inputMode={dateInputMode} /> {startDate !== defaultStartDate || endDate !== defaultEndDate ? (