123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: cpscrn
- (C) Copyright IBM Corp. 2005, 2011
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <!--
- Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
- Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
- This stylesheet uses the following global variables:
- $interactions
- $metaData
- -->
- <xsl:stylesheet version="1.0"
- xmlns:layout="http://developer.cognos.com/common/layout"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/"
- xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
- xmlns:xts="http://developer.cognos.com/schemas/xts/"
- xmlns:cmobj="http://developer.cognos.com/fragments/extensions/cm/1/"
- xmlns:pick="http://developer.cognos.com/fragments/extensions/picker/1/"
- xmlns:val="http://developer.cognos.com/schemas/validator/1/">
- <xsl:template name="generateSelectorControl">
- <xsl:param name="hasResponse" select="false()"/>
- <xsl:param name="propName"/>
- <xsl:param name="propValue"/>
- <xsl:param name="displayField"/>
- <xsl:param name="matchControlId" select="''"/>
- <layout:section format="select-dialog">
- <xsl:choose>
- <xsl:when test="$hasResponse = true()">
- <xsl:copy-of select="$displayField"/>
- </xsl:when>
- <xsl:otherwise>
- <layout:row format="select">
- <layout:text><xts:string id="IDS_PROP_OBJECT_NONE"/></layout:text>
- </layout:row>
- </xsl:otherwise>
- </xsl:choose>
- <layout:row>
- <layout:link href="javascript:_F_Config.emptyFunction()" onclick="_THIS_chooseSelection(_THIS_control{$propName});return false;"><xts:string id="IDS_PROP_OBJECT_SELECT_CAPTION"/></layout:link>
- <xsl:if test="$hasResponse = true()">
- <layout:link href="javascript:_F_Config.emptyFunction()" onclick="_THIS_clearSelection(_THIS_control{$propName});return false;"><xts:string id="IDS_PROP_OBJECT_RESET_CAPTION"/></layout:link>
- </xsl:if>
- </layout:row>
- </layout:section>
- <layout:script>
- var _THIS_control<xsl:value-of select="$propName"/> =
- {
- name: "<xsl:value-of select="$propName"/>",
- hasresponse: <xsl:value-of select="string($hasResponse=true())"/>,
- controlset: "<xsl:if test="$matchControlId != ''">_THIS_<xsl:value-of select="$matchControlId"/></xsl:if>",
- controlreset: "<xsl:if test="string(control/@resetsTo) != ''">_THIS__<xsl:value-of select="control/@resetsTo"/></xsl:if>",
- selectionParams: new Array()
- };
- with(_THIS_control<xsl:value-of select="$propName"/>.selectionParams)
- { <xsl:text/>
- <xsl:text>var temp = new Object().href="_THIS?frag-urlType=gatewayproxy/THIS_";push({name: "so.return.gateway", value: temp});</xsl:text>
- <xsl:text>push({name: "so.return.domain", value: document.domain});</xsl:text>
- <xsl:text>push({name: "so.return.m", value: "/fragments/common/dialog/callback.xts"});</xsl:text>
- <xsl:text>push({name: "so.return.b_action", value: "xts.run"});</xsl:text>
- <xsl:text>push({name: "md.displayOptions", value: "h1"});</xsl:text>
-
- <xsl:for-each select="control/extension/*/pick:picker/pick:param">
- <xsl:text>	push({name: "</xsl:text>
- <xsl:value-of select="xtsext:javascriptencode(@name)"/>
- <xsl:text>", value: "</xsl:text>
- <xsl:choose>
- <xsl:when test="not(pick:custom)">
- <xsl:value-of select="xtsext:javascriptencode(.)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="custParamName" select="pick:custom/@name"/>
- <xsl:variable name="actualValue">
- <xsl:choose>
- <xsl:when test="$interactions/param[@name = concat('p_',$custParamName)]">
- <xsl:value-of select="$interactions/param[@name = concat('p_',$custParamName)]"/>
- </xsl:when>
- <xsl:when test="$interactions/param[@name = $custParamName]">
- <xsl:value-of select="$interactions/param[@name = $custParamName]"/>
- </xsl:when>
- <xsl:when test="starts-with($metaData/customProperties[@name = $custParamName]/default/value,'path:')">
- <xsl:value-of select="substring-after($metaData/customProperties[@name = $custParamName]/default/value,'path:')"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$metaData/customProperties[@name = $custParamName]/default/value"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:value-of select="xtsext:javascriptencode($actualValue)"/>
- <xsl:text>", type: "custom", customName: "</xsl:text>
- <xsl:value-of select="xtsext:javascriptencode($custParamName)"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text>"}); </xsl:text>
- </xsl:for-each>
- <xsl:text>} _THIS_control</xsl:text>
- <xsl:value-of select="$propName"/>
- <xsl:text>.selectionParams.defaultStartLocations = new Array(); </xsl:text>
- <xsl:for-each select="control/extension/*/pick:picker/pick:defaultStartLocation">
- <xsl:text>_THIS_control</xsl:text>
- <xsl:value-of select="$propName"/>
- <xsl:text>.selectionParams.defaultStartLocations.push("</xsl:text>
- <xsl:value-of select="xtsext:javascriptencode(.)"/>
- <xsl:text>"); </xsl:text>
- </xsl:for-each>
- <xsl:text>_THIS_control</xsl:text>
- <xsl:value-of select="$propName"/>
- <xsl:text>.selectionParams.xPathToResponse = "</xsl:text>
- <xsl:value-of select="xtsext:javascriptencode(control/extension/*/pick:picker/pick:xPathToResponse)"/>
- <xsl:text>"; </xsl:text>
- </layout:script>
- </xsl:template>
- <xsl:template name="generateCleanupItems">
- <xsl:param name="propName"/>
- <xsl:param name="dependentItems"/>
- <xsl:text>_THIS_dependencyCleanup["</xsl:text>
- <xsl:value-of select="xtsext:javascriptencode($propName)"/>
- <xsl:text>"] = new Array(); with(_THIS_dependencyCleanup["</xsl:text>
- <xsl:value-of select="xtsext:javascriptencode($propName)"/>
- <xsl:text>"]) { </xsl:text>
- <xsl:for-each select="$dependentItems">
- <xsl:text>push("</xsl:text>
- <xsl:value-of select="xtsext:javascriptencode(parent::*/parent::*/parent::*/parent::*/@name)"/>
- <xsl:text>"); </xsl:text>
- </xsl:for-each>
- <xsl:text> } </xsl:text>
- </xsl:template>
- <xsl:template name="generatePickerScripts">
- var ccModalCallBack;
- var _THIS_currentCallbackResultPath;
- var _THIS_currentControl = null;
- function _THIS_reloadAfterSelectObject(response)
- {
- response = xmldecode(response);
- var form = _F_Form.find(_THIS_currentForm);
- var xml = new XMLBuilderLoadXMLFromString(response);
- if (form !== undefined && xml && _THIS_currentForm != "" && _THIS_currentControl)
- {
- var idNode = _F_DOM.selectSingleNode(xml, _THIS_currentCallbackResultPath);
- var id = _F_DOM.text(idNode);
- form["p_" + _THIS_currentControl.name].value = id;
- _THIS_resetDependents(form, _THIS_currentControl);
- _THIS_.addEventListener("fragment.retrieve.after","_THIS_closeSelectDialogEvent",false);
- form.submit();
- }
- else
- {
- window.alert("BUG: no response or missing parameters");
- }
- }
- function _THIS_closeSelectDialog()
- {
- _THIS_modalDialog.destroy();
- _THIS_modalDialog = null;
- }
- function _THIS_closeSelectDialogEvent(evt)
- {
- if(evt.eventPhase == evt.AT_TARGET)
- {
- _THIS_closeSelectDialog();
- _THIS_.removeEventListener("fragment.retrieve.after","_THIS_closeSelectDialogEvent",false);
- }
- }
- function _THIS_clearSelection(ctrl)
- {
- var form = _F_Form.find(_THIS_currentForm);
- if (form !== undefined)
- {
- if (_THIS_validateFields())
- {
- _THIS_clearObject(form, ctrl);
- form.submit();
- }
- }
- else
- {
- window.alert("BUG: no response or missing parameters");
- }
- }
- function _THIS_clearObject(form, ctrl)
- {
- form["p_" + ctrl.name].value = "";
- if (ctrl && ctrl.controlreset != '')
- {
- var ctrlset = $(ctrl.controlset);
- if (ctrlset && ctrlset.checked)
- {
- var ctrlreset = $(ctrl.controlreset);
- if (ctrlreset && ctrl.controlset != ctrl.controlreset)
- ctrlreset.checked=true;
- else
- ctrlset.checked=false;
- }
- }
- _THIS_resetDependents(form, ctrl);
- }
- function _THIS_resetDependents(form, ctrl)
- {
- if (_THIS_dependencyCleanup !== undefined && _THIS_dependencyCleanup[ctrl.name] != null)
- {
- var deps = _THIS_dependencyCleanup[ctrl.name];
- for (var index=0;index < deps.length;index++)
- {
- var ctrl = window["_THIS_control" + deps[index]];
- _THIS_clearObject(form, ctrl);
- }
- }
- }
- function _THIS_ccModalCallBack(cmd,sResponse)
- {
- var save = (cmd == 'ok' && sResponse);
- if(_THIS_currentControl) {
- if(_THIS_currentControl.controlset != "") {
- if (save) {
- $(_THIS_currentControl.controlset).checked = true;
- } else if (_THIS_currentControl.hasresponse != true &&
- _THIS_currentControl.controlreset != "" &&
- $(_THIS_currentControl.controlset).checked) {
- $(_THIS_currentControl.controlreset).checked = true;
- }
- }
- }
- if (save) {
- _THIS_reloadAfterSelectObject(sResponse);
- }else {
- setTimeout('_THIS_closeSelectDialog()', 1);
- }
-
- return;
- }
- function _THIS_chooseSelection(ctrl){
- if (_THIS_validateFields())
- {
- if (_THIS_modalDialog != null)
- {
- _THIS_modalDialog.destroy();
- _THIS_modalDialog = null;
- }
- _THIS_validatedChooseSelection(ctrl);
- }
- }
- function _THIS_validatedChooseSelection(ctrl)
- {
- _THIS_currentControl = ctrl;
- var pickerParamsArray = _THIS_currentControl.selectionParams;
-
- var pickerFormAction = _THIS_currentControl.pickerFormAction;
- if ( !pickerFormAction ){
- pickerFormAction = _THIS_defaultPickerAction;
-
- var additionalQuery = null;
- var queryIndex = pickerFormAction.indexOf('?');
- if (queryIndex != -1){
- additionalQuery = pickerFormAction.substring(queryIndex + 1);
- var currentPickerForm = getPickerForm("_THIS_pickerForm");
- pickerFormAction = pickerFormAction.substring(0,queryIndex);
- }
- _THIS_currentControl.pickerFormAction = pickerFormAction;
-
- if (additionalQuery != null){
- var params = additionalQuery.split('&');
- for (var i = 0; i< params.length; ++i)
- {
- var param = params[i];
- if (param.length > 0)
- {
- var eq_index = param.indexOf("=");
- var additionalParam = new Object();
- additionalParam.type="";
- if (eq_index != -1)
- {
- additionalParam.name = decodeURIComponent(param.substring(0, eq_index));
- additionalParam.value = decodeURIComponent(param.substring(eq_index + 1));
- }
- else
- {
- additionalParam.name = decodeURIComponent(param);
- additionalParam.value = "";
- }
- pickerParamsArray.push(additionalParam);
- }
- }
- }
- }
-
- recreatePickerForm("_THIS_pickerForm", pickerFormAction);
-
- var currentPickerForm = getPickerForm("_THIS_pickerForm");
- //now update the form with the correct elements
- for (var index=0; index < pickerParamsArray.length; index++)
- {
- <!--
- // Ignore the md.callBack and md.backURL parameters, we will use return url to communicate with the caller
- // javascript callback will not work because in 3rd party portal the caller is in a different domain
- -->
- if ("md.callBack" == pickerParamsArray[index].name || "md.backURL" == pickerParamsArray[index].name )
- continue;
-
- var value = pickerParamsArray[index].value;
- //if it is custom then we should update the value based on the most current value for that property
- if (pickerParamsArray[index].type == "custom")
- {
- var custEl = $("_THIS_p_" + pickerParamsArray[index].customName);
- if (custEl != null)
- {
- value = getValueFromSimpleElement(custEl);
- createPickerInput(currentPickerForm,"picker_" + index, pickerParamsArray[index].name, value);
- }
- else if (!getSelectElements(pickerParamsArray[index].name, pickerParamsArray[index].customName, currentPickerForm))
- {
- if (!getSelect1Elements(pickerParamsArray[index].name, pickerParamsArray[index].customName, currentPickerForm)){
- getMultiLingualElements(pickerParamsArray[index].name, pickerParamsArray[index].customName, currentPickerForm, $("_THIS_Selector"), $("_THIS_" + pickerParamsArray[index].customName));
- }
- }
- }
- else
- {
- createPickerInput(currentPickerForm, "picker_" + index, pickerParamsArray[index].name, value);
- }
- }
- ccModalCallBack = _THIS_ccModalCallBack;
- _THIS_currentCallbackResultPath = pickerParamsArray.xPathToResponse;
- var iframeStaticHeight = parseInt(xClientHeight() * .75);
- var iframeStaticWidth = parseInt(xClientWidth() * .75);
- //open the dialog to an empty url and submit the form as the form is targeted to the modal dialog
- var url = "about:blank";
- if (_THIS_modalDialog == null)
- {
- _THIS_modalDialog = new ui_dialog("_THIS_modalDialogViewer", '<xts:string id="IDS_GEN_SELECTION_TITLE" encode="javascript"/>', ui_dialog.style.BTN_NOBUTTONS | ui_dialog.style.CENTER | ui_dialog.style.IFRAME, -1, -1, iframeStaticWidth, iframeStaticHeight, _THIS_.div, url);
- }
- _THIS_modalDialog.show();
- currentPickerForm.target = _THIS_modalDialog.iframeName;
- currentPickerForm.submit();
- }
- if (window._THIS_modalDialog === undefined){
- var _THIS_modalDialog = null;
- var _THIS_currentPickControl = null;
- }
- </xsl:template>
-
- </xsl:stylesheet>
- <!-- $Header$ -->
- <!-- $DateTime$ -->
- <!-- $Change$ -->
|