Replies: 4 comments 3 replies
-
Function style properties of Quasar classes are not supported. import justpy as jp
import datetime
def set_events(date):
date_list = []
for i in range(-30, 30):
date_i = date + datetime.timedelta(days=i)
if date_i.day % 2 == 0:
date_list.append(date_i.strftime('%Y/%m/%d'))
return str(date_list)
def date_test():
wp = jp.QuasarPage()
dt = jp.QDate(a=wp, style='margin: 40px')
dt.events_date = set_events(datetime.datetime.now())
return wp
jp.justpy(date_test) |
Beta Was this translation helpful? Give feedback.
-
In principle, it should work as an evaluated_prop. That is how I implemented rules in QInput (https://quasar.dev/vue-components/input#internal-validation). If you add a prop to the evaluated_prop list it gets evaluated (see the python implementation of QInput and the quasar_component.js ). For some reason this does not work with events_date. I would need to look into the Quasar implementation to figure out why. |
Beta Was this translation helpful? Give feedback.
-
I just looked at the code in quasar_components.js and I think there is a bug in line 28. You use j as index variable for the inner loop but then compare/increment i which is the index variable of the outer loop. Please doublecheck. |
Beta Was this translation helpful? Give feedback.
-
In order to use a function-style property with QDate, the following is necessary: qd = jp.QDate()
qd.events_date = "(date) => {return date[9] %3 === 0}"
qd.evaluate_prop.append('events') This made it work for me. Note that the mapping of property names is a little bit tricky. In Quasar, the property is named QDate.events. However the evaluate_prop list is only analyzed in the JS domain, where the property name is 'events' |
Beta Was this translation helpful? Give feedback.
-
Quasar's QDate class has a property events (in JP it's called events_date to avoid name conflict with built-in events property)
According to Quasar documentation, events can be either an array of date strings or a js function.
This one works in JustPy as expected:
However, this doesn't work (should mark all even days, but doesn't mark any)
I cannot figure out my mistake and didn't find anything in the docs about how to use function-style properties of Quasar classes.
Any hint?
Beta Was this translation helpful? Give feedback.
All reactions