Skip to content
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

nested model properties #117

Closed
cwiese opened this issue Jun 16, 2022 · 14 comments · May be fixed by GenieFramework/StippleUI.jl#62
Closed

nested model properties #117

cwiese opened this issue Jun 16, 2022 · 14 comments · May be fixed by GenieFramework/StippleUI.jl#62

Comments

@cwiese
Copy link

cwiese commented Jun 16, 2022

my model has a daterange

@reactive mutable struct Pages <: ReactiveModel
    daterange::R{DateRange} = DateRange(today(), (today() + Day(3)))
emnd

how do I refer to a nested properties ( :daterange.start will not work of course)

cell([div(
        class = "q-pa-md",
        style = "max-width: 300px",
        [textfield(
            "",
            :daterange.start,
...'
@hhaensel
Copy link
Member

R"date.start" or Symbol("date.start") should go the job.

@cwiese
Copy link
Author

cwiese commented Jun 17, 2022

does not seem to work - here is a simple example

using Stipple, StippleUI

@reactive mutable struct Model <: ReactiveModel
  daterange::R{DateRange} = DateRange()
end

function ui(model)
    page(
        model,
        textfield("t2", Symbol("daterange.start"), "", placeholder = "no output yet ...", label = "DataRange", :outlined, :filled, type = "textfield")
        #textfield("t2", :daterange, "", placeholder = "no output yet ...", label = "DataRange", :outlined, :filled, type = "textfield")
      )
end
  

route("/") do
    hs_model = Model |> init |> ui
end 

up()

@hhaensel
Copy link
Member

I'll have a look when I'm back at my computer. Currently only on my mobile. I think, the point is string to date conversion. I know there are date pi kers ...
Maybe you could try that

@cwiese
Copy link
Author

cwiese commented Jun 17, 2022

Oddly in the datepicker example - they use a Text Field to show a date - in the popup button. I want to show a range.

inputdate::R{Date} = today()

@essenciary
Copy link
Member

It's possible to show a range:
https://v1.quasar.dev/vue-components/date#example--single-range

But it's not very easy to integrate from Julia. See here I opted for 2 inputs instead: https://pkgs.genieframework.com

@cwiese
Copy link
Author

cwiese commented Jun 17, 2022

I am using DateRange (single) .. and the date is in the model (start and stop)

 model.daterange.start = 2022-06-17

when I access the "nested" model property to display in textfield is when I see blank

 textfield("t2", Symbol("daterange.start"), "", placeholder = "no output yet ...", label = "DataRange", :outlined, :filled, type = "textfield")

@cwiese
Copy link
Author

cwiese commented Jun 17, 2022

maybe I will switch to 2 dates

@wildart
Copy link
Contributor

wildart commented Jun 20, 2022

The date isn't showing because render function for DateRange renames fields to from & to:
https://github.com/GenieFramework/StippleUI.jl/blob/231c7aca8cd8e03288f483477271b815c10186ec/src/DatePickers.jl#L135-L137

When you define field name as Symbol("daterange.from") in textfield call, the date is showed correctly.

@cwiese
Copy link
Author

cwiese commented Jun 20, 2022

Thank you Art - I need to dig more.

@AbhimanyuAryan
Copy link
Member

Thanks, Art. @cwiese did it work for you?

@wildart
Copy link
Contributor

wildart commented Jun 21, 2022

Why are the names different? It's confusing.

@AbhimanyuAryan
Copy link
Member

AbhimanyuAryan commented Jun 21, 2022

@wildart will discuss this with @essenciary @hhaensel and if there's no specific reason for different names. We can use start stop

@hhaensel
Copy link
Member

I would also tend to use the same names

@essenciary
Copy link
Member

While it's good to keep the same names in principle, I'm not sure here:
1/ Quasar does not always make the best naming decisions, and this is one example
2/ Stipple abstracts away and improves the Quasar API (where possible) making the API "julian" - many names don't translate well to Julia
3/ Why do we even need to know how props are called in Quasar? This should be a standalone element with its own docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants