Last Updated Feb 07, 2013 — Enterprise Agile Planning expert
The VersionOne MetaMorformizr App // Using the VersionOne REST Meta and Localization APIs to GET Serious
Enterprise Agile PlanningDeveloping Custom VersionOne Apps 101 Series GuideLast time, in Understand Backbone Forms and Backbone.Model's Two/Way Data Binding by Playing Around in the Chrome Developer Console, you got to play around in the Chrome Console with some awesome, and extremely powerful features of Backbone Forms and Backbone.Model // like simplified DTO creation and two way data binding. But, so far in this series, we've only used the VersionOne REST Data API, but there are two other APIs, Meta and Localization. Let's use them now.
And, since every respectable library or web site of the past ten years has dispensed with using the letter e at the end of its name, we'll create the MetaMorformizr, because it will transform VersionOne meta data into HTML forms.
MetaMorformizr: into the wild blue yonder!As just mentioned, there's another aspect to the VersionOne API that can take us up to an even higher level of abstraction and mastery. Right now, you might feel like you're still in a cocoon, like a caterpillar, eager to fly.With the VersionOne Meta and Localization APIs you can break free. You can undergo metamorphosis!
VersionOne Meta APIThe VersionOne Meta API allows us to query information about the VersionOne Information Model. Quoting from the main documenatation source:
The Meta API provides a facility for retrieving information about the VersionOne business objects. This includes getting information about the asset types, attribute definitions, relationships and operations.So, here's a URL you can type in your browser's address bar to get the meta information for the
Storyasset type: http://evel.versionone.net/platformtest/meta.v1/Story?accept=application/jsonDistilled down to our normal three stooges,
Name, Description, Estimate, we have: [gist id=4685990 file=gistfile6.json]
VersionOne Localization APIThe
Name, Description, Estimateattributes are all one word identifiers, so they can serve as nice titles for fields too, but what if we want to add the
RequestedByattribute? Do you, as a programmer, want to search and prefix capital letters, after the first character, with a space? You might say, "Hey, that should be easy, let me try it out!", like I did: [gist id=4685990 file=gistfile2.js]
Sure, but no. How to use Localization for real?Notice the property
DisplayNamefrom the JSON meta output above: AttributeDefinition'Name'StoryThis value can be passed to the Localization API to get the label for the field title. But, let's try it with RequestedBy: http://eval.versionone.net/platformtest/loc.v1?AttributeDefinition%27RequestedBy%27StoryIt returns "Requested By". There's a lot more to the Localization API, including getting language/specific strings, so check out the documentation for more information.
Let the transformation beginArmed with this, we can now dynamically create even the
formSchemaitself that we built by hand last time. And, what's more, we can even dynamically supply the field names on the query string or from a select list.