From 04469966f48ea2c22d0bac10ba5e1550b394dd9d Mon Sep 17 00:00:00 2001 From: Danielwhyte Date: Tue, 1 May 2018 12:33:14 +0100 Subject: [PATCH 1/3] keeps selectDate correct after cancel/clear --- src/DatePicker.elm | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/DatePicker.elm b/src/DatePicker.elm index ae29289..eb4f058 100644 --- a/src/DatePicker.elm +++ b/src/DatePicker.elm @@ -450,10 +450,28 @@ update msg (DatePicker model) = DatePicker ({ model | overDate = date }) CancelDates -> - DatePicker ({ model | from = Nothing, to = Nothing, single = Nothing, open = False, selectDate = From }) + let + selection = + case model.selectDate of + Only -> + Only + + _ -> + From + in + DatePicker ({ model | from = Nothing, to = Nothing, single = Nothing, open = False, selectDate = selection }) ClearDates -> - DatePicker ({ model | from = Nothing, to = Nothing, single = Nothing, selectDate = From }) + let + selection = + case model.selectDate of + Only -> + Only + + _ -> + From + in + DatePicker ({ model | from = Nothing, to = Nothing, single = Nothing, selectDate = selection }) {-| Get the `from` date in a selected range From 9ac2de042e94d01d1ffa62e6741351d9039edc60 Mon Sep 17 00:00:00 2001 From: Danielwhyte Date: Tue, 1 May 2018 12:33:53 +0100 Subject: [PATCH 2/3] exposes getSelectedDate function --- src/DatePicker.elm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DatePicker.elm b/src/DatePicker.elm index eb4f058..45e8f8e 100644 --- a/src/DatePicker.elm +++ b/src/DatePicker.elm @@ -13,6 +13,7 @@ module DatePicker , isOpen , getMonth , getNextMonth + , getSelectedDate , clearDates , toggleCalendar , cancelDates @@ -30,7 +31,7 @@ module DatePicker These functions allow you to access data from the DatePicker model. -@docs getFrom, getTo, getMonth, getNextMonth, isOpen +@docs getFrom, getTo, getMonth, getNextMonth, isOpen, getSelectedDate # API Functions From 19b8622e69769946a4c111c3d5701ed0d53b68ae Mon Sep 17 00:00:00 2001 From: Danielwhyte Date: Tue, 1 May 2018 12:34:30 +0100 Subject: [PATCH 3/3] 2.1.0 --- elm-package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elm-package.json b/elm-package.json index 84b00e3..ddaa1e2 100644 --- a/elm-package.json +++ b/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "2.1.0", "summary": "A customisable date picker written in Elm", "repository": "https://github.com/dwyl/elm-datepicker.git", "license": "BSD3",