giovedì 8 aprile 2010

UCM: Modify the check-in menu

To modify the "New check in" menu structure in UCM you have to customize the dynamic include "custom_finish_layout_init" using component wizard.

After creating the new resource and the new include use the javascript "navBuilder" object to modify the structure of the menu; use "navBuilder.getNodeById("NEW_CHECK_IN").childNodes" method to search the leafs of the node.

The leaf IDs of the new check in menu are usually named "MY_PERSONAL_CHECKINS_[n]" (with n starting from 0).


<$include super.custom_finish_layout_init$>
APChilds = new Array();
ARChilds = new Array();
var children = navBuilder.getNodeById("NEW_CHECK_IN").childNodes;
for (var i = 0; i < children.length; i++)
{
TEXT = children[i].getAttribute("label") ;
if (TEXT.match(/\bAR\b/i) != null)
{ arrLength =ARChilds.push(children[i].getAttribute("id")); }
if (TEXT.match(/\bAP\b/i) != null) {
arrLength =APChilds.push(children[i].getAttribute("id")); }}



Then you can add new nodes or collections using:

navBuilder.addChildNodeTo("NEW_CHECK_IN","collection","id==ACCOUNT_PAYABLES","label==Account payables","url==");

navBuilder.addChildNodeTo("NEW_CHECK_IN","item","id==ACCOUNT_PAYABLES","label==Account payables","url==http://oramack.blogspot.com");


If trying to add a new collection you can choose the position of the leaf specifying the sibling node:


navBuilder.addPrevSiblingNodeTo("MY_PERSONAL_CHECKINS_0","collection","id==ACCOUNT_RECEIVABLES","label==<$lc("wwACCOUNT_RECEIVABLES")$>","url==");

navBuilder.addPrevSiblingNodeTo("MY_PERSONAL_CHECKINS_0","collection","id==ACCOUNT_PAYABLES","label==<$lc("wwACCOUNT_PAYABLES")$>","url==");


then move check in profile into the newly created collections:


i=0;
while(i navBuilder.moveItemInto("ACCOUNT_RECEIVABLES",ARChilds[i]); i++;
}

i=0;
while(i navBuilder.moveItemInto("ACCOUNT_PAYABLES",APChilds[i]); i++;
}


Note: use the IDOC function "lc" for getting translation; example: <$lc("wwACCOUNT_RECEIVABLES")$>

Here is the include full code:


<$include super.custom_finish_layout_init$>


APChilds = new Array();
ARChilds = new Array();

var children = navBuilder.getNodeById("NEW_CHECK_IN").childNodes;
for (var i = 0; i < children.length; i++)
{
TEXT = children[i].getAttribute("label") ;
if (TEXT.match(/\bAR\b/i) != null) {
arrLength =ARChilds.push(children[i].getAttribute("id"));
}
if (TEXT.match(/\bAP\b/i) != null) {
arrLength =APChilds.push(children[i].getAttribute("id"));
}
}

navBuilder.addPrevSiblingNodeTo("MY_PERSONAL_CHECKINS_0","collection","id==ACCOUNT_RECEIVABLES","label==<$lc("wwACCOUNT_RECEIVABLES")$>","url==");
navBuilder.addPrevSiblingNodeTo("MY_PERSONAL_CHECKINS_0","collection","id==ACCOUNT_PAYABLES","label==<$lc("wwACCOUNT_PAYABLES")$>","url==");

i=0;
while(i navBuilder.moveItemInto("ACCOUNT_RECEIVABLES",ARChilds[i]); i++;
}

i=0;
while(i navBuilder.moveItemInto("ACCOUNT_PAYABLES",APChilds[i]); i++;
}


Nessun commento: