Difference between revisions of "Extending Admin UI"

Line 14: Line 14:
     function HelloWorldExtension() {
     function HelloWorldExtension() {}
HelloWorldExtension.AccountXFormModifier = function (xFormObject) {
HelloWorldExtension.AccountXFormModifier = function (xFormObject) {

Revision as of 01:21, 25 February 2006

The API for extending Admin UI is similar to Zimlets. Extensions for Admin UI are deployed using the same utility. The easiest way to understand how to create extensions for Admin UI is by example. So, lets create a sample "Hello World" extension. The example will one tab to the Accounts view. The tab will be called "Hello World" and it will have some text.

The extension will consist of two files: helloworld.xml - XML definition of the extention helloworld.js - JavaScript code of the extension helloworld.xml:

<zimlet name="helloworld" version="1.0" description="Sample Extension for Admin UI" extension="true"> <include>helloworld.js</include> </zimlet>

That's it. It is that short. It defines the name of the extension, description and included JS files. Note, that unlike Zimlet definition files it has a parameter extension="true". This is what tells zimlet utility that this is not a regular Zimlet, but an extension for Admin UI. So, moving forward. helloworld.js

   function HelloWorldExtension() {}

HelloWorldExtension.AccountXFormModifier = function (xFormObject) { //find _TAB_BAR_ element for(i = 0; i <cnt; i++) { if(xFormObject.items[i].type=="tab_bar") break; }

//add a tab xFormObject.items[i].choices.push({value:"helloworld", label:"Hello World"});

//define a form for my new tab. This ahs to be a _CASE_ element var myTab = {type:_CASE_, relevant: "instance[ZaModel.currentTab] == "helloworld",items: [{type:_OUTPUT_, label:_NONE_, value:"Hello World!"}]};

//find SWITCH element for(i = 0; i <cnt; i++) { if(xFormObject.items[i].type=="switch") break; }

//add my tab to the form xFormObject.items[i].items.push(myTab); } ZaTabView.XFormModifiers["ZaAccountXFormView"].push(HelloWorldExtension.AccountXFormModifier);

Jump to: navigation, search