ToscaWidgets is a web widget toolkit for Python to aid in the creation, packaging and distribution of common view elements normally used in the web.
tw2.dynforms includes dynamic form building widgets that use JavaScript.
Dynamic forms with JavaScript, for ToscaWidgets 2
License: Other
Christoph created a patch(93d8338) for GrowingGridLayout that would graceful degrade when javascript is not available.
See if there are other widgets in dynforms that need graceful degredation and implement it.
Hiding Checkboxes return lists as values. HidingContainerMixin._validate needs to check if the value is a list and then update the "show" list with mapped controls for each independent value in the list. I propose the below code added to HidingContainerMixin._validate
line 150 if isinstance(c, TwdHidingComponentMixin):
if isinstance(data[c.id],list):
for val in data[c.id]:
show.update(c.mapping.get(val,[]))
else:
show.update(c.mapping.get(data[c.id], []))
I notice that when a field is in the hidden state (not displayed on the form), that HidingContainerMixin._validate automatically sets this value to None. I would think that if a field is hidden in a form it is because you don't want that data to even be considered by the server side. This has led to nasty errors like fields in the database being set to null when this wasn't actually specified in the form. Does it make sense to just not set data[c.id] if the field is hdden? Let me know if you there is a reson for doing this.
See line 142 in tw2.dynforms.widgets.py
if c.id in self.hiding_ctrls and c.id not in show:
data[c.id] = None
Is this where dynforms is currently being maintained?
Recommend the below changes to HidingContainer._validate() function. This will allow multi select widget support (show/ hide based on multiply selected items). This also has a fix to compare the mapping property keys with the original value rather than the validated value. The validated value has been, in many cases transformed and thus would not match up with the item in the mapping.
if isinstance(c, HidingComponentMixin):
#Support Multiselect List widgets
#Show widgets based on pre-validated value
if isinstance(data[c.id],list):
for i,item in enumerate(data[c.id]):
show.update(c.mapping.get(value.get(c.id)[i],[]))
else:
show.update(c.mapping.get(value.get(c.id), []))
tw2.forms.MultipleSelectionWidget
has a property item_validator
which validates the single entries in the widget.
I think it would be appropriate to have something similar for tw2.dynforms.GrowindGridLayout
.
What do the others think?
Since updating to tw2.core>=2.1.2
, GrowingGridLayout
's fields don't get validated correctly anmore...
An example is at https://github.com/moschlar/SAUCE/blob/feature/simpleusers/sauce/widgets/judgement.py#L17
request.POST:
MultiDict([('judgement:assignment_id', u''), ('judgement:submission_id', u''), ('line', u''), ('comment', u''), ('line', u''), ('comment', u''), ('judgement:comment', u''), ('judgement:corrected_source', u''), ('judgement:grade', u'')])
After validation:
{'comment': u"[u'', u'2', u'']", 'submission_id': 1, 'assignment_id': 1, 'grade': None, 'corrected_source': u'', 'annotations': []}
The problem seems to be that id and name are not the same anymore.
@ralphbean confirmed the diversion between those in the rendered html.
We have Calendar*Picker
s in tw2.forms and in tw2.dynforms...
There are numerous changes in development branch.
Some of then are fixing breaking (on Python3) problems (for example: 1e77ae8).
When are you planning to merge development changes to master and to create a new version release to PYPI?
Last time release happened was 2012-05-03 (tw2.dynforms-2.0.1.tar.gz).
Did development/release stop, because there is a better alternative solution? In this case could you please advise?
Thanks,
Albert
Please update pip with last commitment in order to make the module working with python3, otherwise the version installed with pip is broken because of the relative import in init.py
Thanx
Best regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.