Login Register

DnD Form Editor: Export works

Last week before getting sick, I worked on making it possible to export the created form. I've been procrastinating on this part of the app for a while because I was stumped on how to make it easy to use, because exportable data exists on different levels: some parts are on the object I use to wrap each form element (soc.Element), and other parts are on the element being wrapped (the dijits).

My solution is to perform all attribute lookups through the soc.Element.getattr function, which defers the lookup to the wrapped object under certain conditions. The only condition at this point is: did soc.Element inherit this attribute from a superclass or mixin? My assumption is that the user won't care about any of the attributes inherited from dijit._Widget or dijit._Templated, so we should pass the lookup to the underlying dijit.

I got a bit sidetracked and wrote a Set class to help with the lookup decisions; probably not necessary, but it was fun.

The names to be exported are set on soc.Canvas when it is created, so it's configurable in the normal dijit way. The export function returns an array of objects, which could then be converted to JSON or XML or Protocol Buffers, whatever you want. The form editor isn't involved in that part, it just gives you the raw data.

The test page now has an export button, which sends the output to the console. There's still a couple things to be tweaked, like letting the export function take arguments so it's easy to decide what to export on-the-fly.