-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix DateRange fields' names #62
base: master
Are you sure you want to change the base?
Conversation
Thanks, not sure about this, as a matter of principle the Julia implementation should not mimic the frontend names, especially if they are bad names (like in the case). The reason is, what if next month we decide to implement a non-quasar DateRange that is better, do we change the Stipple implementation in a breaking way to match that? The objective of StippleUI is to provide a Julian wrapper, abstracting away the JS layer, and improve where possible (and Can you please explain the background of this? I understand that in your situation it was simply a documentation issue? Why not contributing to improve the DateRange docs instead? |
It isn't related to docs. @reactive mutable struct Model <: ReactiveModel
daterange::R{DateRange} = DateRange()
end
textfield("", Symbol("daterange.start")) The textfield("", Symbol("daterange.from")) It looks like there need to be some feedback when the render Julia type rendered differently to JS, or the name should be synchronized on both Julia & JS side. |
Thanks - ah I see, you're looking to access the JS side of the property. OK, in this case it's a powerful reason to keep the same names. |
The issue is though that julia> dr = StepRange{Date,Day}
StepRange{Date, Day}
julia> fieldnames(dr)
(:start, :step, :stop) |
Why do you need specific names for the range type? From Julia side, any type can be itertateble if |
The overarching principle is to have a Julia implementation where the frontend is abstracted away and invisible. So if a struct is called a julia> dr = Date(2014,1,29):Day(1):Date(2014,2,3)
Date("2014-01-29"):Day(1):Date("2014-02-03")
julia> typeof(dr)
StepRange{Date, Day}
julia> typeof(dr) |> supertype
OrdinalRange{Date, Day}
julia> typeof(dr) |> supertype |> supertype
AbstractRange{Date} So while the issue you raise is valid, I don't think the proposed approach is the way to go - and nor is the change necessary. For instance, this is how I implemented textfield("Start date", :filter_startdate, clearable = true, filled = true, [
icon(name = "event", class = "cursor-pointer", style = "height: 100%;", [
popup_proxy(cover = true, transitionshow = "scale", transitionhide = "scale", [
datepicker(:filter_startdate, mask = "YYYY-MM-DD", navmaxyearmonth = "$(Dates.year(now()))/$(Dates.month(now()))")
])
])
]) Another way (which is something I have considered and would be useful for other use case too) is to someday offer an object API, in addition to the functional one. Ex now we have |
I reworked date range to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be very helpful to include a minimum working example that we can use to set up a test.
src/DatePickers.jl
Outdated
@@ -133,17 +121,23 @@ function Base.parse(::Type{Date}, d::String) :: Date | |||
end | |||
|
|||
function Stipple.render(dr::DateRange, _::Union{Symbol,Nothing} = nothing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this will work as you removed DateRange
src/DatePickers.jl
Outdated
@@ -133,17 +121,23 @@ function Base.parse(::Type{Date}, d::String) :: Date | |||
end | |||
|
|||
function Stipple.render(dr::DateRange, _::Union{Symbol,Nothing} = nothing) | |||
Dict(:from => dr.start, :to => dr.stop) | |||
Dict(:from => dr.from, :to => dr.to) | |||
end | |||
|
|||
function Stipple.render(vdr::Vector{DateRange}, _::Union{Symbol,Nothing} = nothing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, you removed the DateRange
definition.
Thanks, I have merged that into Stipple.jl - but this PR here does not look 100% right, I commented. An example/test would help to ensure all works as expected and so we can use as docs too. |
The docstring for I could also fix DatePickers example so it would work with this update. |
Sorry, missed the updates - will review and follow back. |
I think with the current version of |
As the DatePicker element original comes from Quasar, where the date range specified by from & to model properties. We need to set the same names in the corresponding wrapper Julia type to harmonize names.
Fixes Stipple.jl/#117