123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: HTS
- (C) Copyright IBM Corp. 2005, 2020
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:hts="http://developer.cognos.com/myinbox/common/hts_ui" >
- <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
- <xsl:variable name="report_output_tooltip"><xts:string id="IDS_REPORT_OUTPUT_TOOLTIP"/></xsl:variable>
- <xsl:variable name="report_tooltip"><xts:string id="IDS_REPORT_TOOLTIP"/></xsl:variable>
- <xsl:template match="/">
- <xsl:call-template name="renderUI"/>
- </xsl:template>
- <xsl:template name="renderUI">
- <xsl:param name="path"/>
- <xsl:param name="channel"/>
- <script type="text/javascript">
- dojo.require("dojox.collections.Dictionary");
- dojo.require("dojo.html");
- var _THIS_userId = "<xsl:value-of select="xtsext:javascriptencode(string(/root/interactions/param[@name='user_id']))"/>";
- var _THIS_userName = "<xsl:value-of select="xtsext:javascriptencode(string(/root/interactions/param[@name='user_name']))"/>";
- //hold the details of an attachment/link when clicked, key=id, value=object with properties id,objectClass,title
- var _THIS_outputDetails = new dojox.collections.Dictionary();
- //create the style object for the clist
- var _THIS_uiStyle = new CUIStyle("CList_li", "CList_over", "CList_selected", "", null);
-
- /*
- create the clist object with the optional button mode (default is toggle)
- the clist object has two modes 1. 'toggle' where each item acts like a toggle button and multiple items can be selected 2. 'button' where each item acts like a normal button
- In 'button' mode the on click handler MUST be set by calling setSingleClickFunc(...)
- */
- var _THIS_cListGenTask = new CList("myCList",true, "CList_ul",_THIS_uiStyle,'button');
-
- //create the links object
- var _THIS_htsLinks = new HTSLinks(_THIS_cListGenTask,$('_THIS_linksDivGen'));
- _THIS_cListGenTask.setSingleClickFunc(_THIS_view);
- _THIS_cListGenTask.setKeyPressFunc(_THIS_view);
- function _THIS_disableAll() {
- var utils = new hts_utils();
- var content =$(_THIS_.div);
- utils.setUIState(content,true);
- }
- function _THIS_view(evt,listItem) {
- var nodelist = dojo.query("div[id]",listItem)
- if (nodelist.length > 0) {
- var id = nodelist.at(0).attr("id");
- if (id=="") {
- alert('<xts:string id="IDS_FRAG_NO_EVENT_LIST" encode="javascript"/>');
- return;
- }
- var details = _THIS_outputDetails.item(id);
-
- var eventList=details.eventList;
- var objectClass = details.objectClass;
-
- /*
- * open the universal viewer in a new window. customize the appearance by maximizing the fragment and removing the viewer's toolbar
- */
- var sViewerURL = _F_Config.gateway + "?objRef="+id;
- window.open(sViewerURL,'_THIS_'+"viewerWindow","location=no,status=no,resizable=yes");
- }
- else {
- alert('<xts:string id="IDS_FRAG_NO_EVENT_LIST" encode="javascript"/>');
- return;
- }
-
- }
- </script>
- <xsl:variable name="previews">
- <xsl:call-template name="getFilteredAgentTaskPreviews">
- <xsl:with-param name="path" select="$path"/>
- </xsl:call-template>
- </xsl:variable>
- <!-- check if we have any links or attachments -->
- <xsl:if test="count($previews/filteredAgentPreview/*[local-name()='agentTaskPreview']/*[local-name()='taskRunPreview']/*[local-name()='outputInfos']) >0 or count(//logic/outputInfo) >0">
- <div class="wrapper">
- <!-- have to pass the preferences into the template - we switch trees in the call -->
- <xsl:variable name="userFormat" select="/root/*[local-name()='biBusHeader']/*[local-name()='userPreferenceVars']/item[./name='format']/value"/>
- <xsl:variable name="userLocale" select="/root/preferences/param[@name='contentLocale']"/>
- <!-- one 'outputsInfo' for each agent task-->
- <hts:script type="text/javascript">
- <xsl:for-each select="$previews/filteredAgentPreview/*[local-name()='agentTaskPreview']/*[local-name()='taskRunPreview']/*[local-name()='outputInfos']">
- <xsl:call-template name="generateOutputUI">
- <xsl:with-param name="displayName" select="../../../display"/>
- <xsl:with-param name="format" select="../../../format"/>
- <xsl:with-param name="locale" select="../../../locale"/>
- <xsl:with-param name="output" select="."/>
- <!-- pass the preferences down too -->
- <xsl:with-param name="userFormatPreference" select="$userFormat"/>
- <xsl:with-param name="userLocalePreference" select="$userLocale"/>
- </xsl:call-template>
- </xsl:for-each>
- <!-- render links too -->
- <xsl:for-each select="//logic/outputInfo">
- <xsl:call-template name="generateLinkUI">
- <xsl:with-param name="output" select="."/>
- </xsl:call-template>
- </xsl:for-each>
- //update the dom when all attachments/links have been added
- _THIS_htsLinks.commit('_THIS_linksDivGen');
- </hts:script>
- <div id="_THIS_linksDivGen"/>
- </div>
- </xsl:if>
- </xsl:template>
- <xsl:template name="getAcceptText">
- <xsl:param name="input"/>
- <xsl:choose>
- <xsl:when test="$input/*[local-name()='approveText']=''">
- <xts:string id="IDS_FRAG_DEFAULT_APPROVE_TEXT"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$input/*[local-name()='approveText']"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="getRejectText">
- <xsl:param name="input"/>
- <xsl:choose>
- <xsl:when test="$input/*[local-name()='rejectText']=''">
- <xts:string id="IDS_FRAG_DEFAULT_REJECT_TEXT"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$input/*[local-name()='rejectText']"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="generateLinkUI">
- <xsl:param name="output"/>
- <xsl:call-template name="generateFormatUI">
- <xsl:with-param name="output" select="$output"/>
- <xsl:with-param name="displayName" select="$output/name"/>
- </xsl:call-template>
- </xsl:template>
- <xsl:template name="generateOutputUI">
- <xsl:param name="output"/>
- <xsl:param name="displayName"/>
- <xsl:param name="format"/>
- <xsl:param name="locale"/>
- <xsl:param name="userFormatPreference"/>
- <xsl:param name="userLocalePreference"/>
- <!-- have to find the correct ./outputInfo based on what's there and the preferences - can't just output all of them -->
- <xsl:variable name="bestMatchFormat">
- <xsl:call-template name="findBestFormat">
- <xsl:with-param name="output" select="$output"/>
- <xsl:with-param name="formatPreference" select="$userFormatPreference"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="bestMatchLocale">
- <xsl:call-template name="findBestLocale">
- <xsl:with-param name="output" select="$output"/>
- <xsl:with-param name="localePreference" select="$userLocalePreference"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="$output/outputInfo[./format = $format and ./locale = $locale]">
- <xsl:call-template name="generateFormatUI">
- <xsl:with-param name="output" select="$output/outputInfo[./format = $format and ./locale = $locale]"/>
- <xsl:with-param name="displayName" select="$displayName"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="generateFormatUI">
- <xsl:with-param name="output" select="$output/outputInfo[./format = $bestMatchFormat and ./locale = $bestMatchLocale]"/>
- <xsl:with-param name="displayName" select="$displayName"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!-- template to find the best format -->
- <xsl:template name="findBestFormat">
- <xsl:param name="output"/>
- <xsl:param name="formatPreference"/>
- <!-- use the prefered format if it's available !-->
- <xsl:choose>
- <xsl:when test="$output/outputInfo[./format = $formatPreference]">
- <xsl:value-of select="$formatPreference"/>
- </xsl:when>
- <!-- otherwise we have to pick one of the formats - just make sure it's not MHT or layoutDataXML-->
- <xsl:otherwise>
- <xsl:value-of select="$output/outputInfo[./format != 'MHT' and ./format!='layoutDataXML'][1]/format"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!-- template to find best match locale -->
- <xsl:template name="findBestLocale">
- <xsl:param name="output"/>
- <xsl:param name="localePreference"/>
- <!-- use the prefered locale if it's available !-->
- <xsl:choose>
- <xsl:when test="$output/outputInfo[./locale = $localePreference]">
- <xsl:value-of select="$localePreference"/>
- </xsl:when>
- <!-- if we have a variant try to match on language and country only -->
- <xsl:when test="substring-after(substring-after($localePreference, '-'),'-') != '' and $output/outputInfo[./locale = concat(substring-before($localePreference, '-'), '-', substring-before(substring-after($localePreference, '-'),'-'))]">
- <xsl:value-of select="$output/outputInfo[./locale = concat(substring-before($localePreference, '-'), '-', substring-before(substring-after($localePreference, '-'),'-'))][1]/locale"/>
- </xsl:when>
- <!-- if we have a country - try to match on language only -->
- <xsl:when test="substring-before($localePreference,'-') !='' and $output/outputInfo[./locale = substring-before($localePreference,'-')]">
- <xsl:value-of select="$output/outputInfo[./locale = substring-before($localePreference,'-')][1]/locale"/>
- </xsl:when>
- <!-- try to find a match where the user preference is a subset of the locale generated -->
- <xsl:when test="$output/outputInfo[starts-with(./locale,$localePreference)]">
- <xsl:value-of select="$output/outputInfo[starts-with(./locale,$localePreference)][1]/locale"/>
- </xsl:when>
- <!-- can't find a match even on just the language - pick any -->
- <xsl:otherwise>
- <xsl:value-of select="$output/outputInfo[1]/locale"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="generateFormatUI">
- <xsl:param name="output"/>
- <xsl:param name="displayName"/>
- <xsl:variable name="id" select="$output/@id"/>
- <xsl:variable name="format" select="$output/format"/>
- <xsl:variable name="icon">
- <xsl:choose>
- <xsl:when test="$format = 'HTML'">
- <xsl:value-of select="concat('_THIS?frag-resource=/ps/portal/images/', 'icon_result_html.gif', '/THIS_')"/>
- </xsl:when>
- <xsl:when test="$format = 'singleXLS'">
- <xsl:value-of select="concat('_THIS?frag-resource=/ps/portal/images/', 'icon_result_excel_single.gif', '/THIS_')"/>
- </xsl:when>
- <xsl:when test="$format = 'PDF'">
- <xsl:value-of select="concat('_THIS?frag-resource=/ps/portal/images/', 'icon_result_pdf.gif', '/THIS_')"/>
- </xsl:when>
- <xsl:when test="$format= 'XLS'">
- <xsl:value-of select="concat('_THIS?frag-resource=/ps/portal/images/','icon_result_excel.gif', '/THIS_')"/>
- </xsl:when>
- <xsl:when test="$format = 'XLWA'">
- <xsl:value-of select="concat('_THIS?frag-resource=/ps/portal/images/','icon_result_excel_web_arch.gif', '/THIS_')"/>
- </xsl:when>
- <xsl:when test="$format = 'spreadsheetML'">
- <xsl:value-of select="concat('_THIS?frag-resource=/ps/portal/images/','icon_result_excel_2007.gif', '/THIS_')"/>
- </xsl:when>
- <xsl:when test="$format = 'xlsxData'">
- <xsl:value-of select="concat('_THIS?frag-resource=/ps/portal/images/','icon_result_xlsxdata_32.gif', '/THIS_')"/>
- </xsl:when>
- <xsl:otherwise>
- <!-- need to convert the format to lowercase for linux -->
- <xsl:variable name="convertedFormat">
- <xsl:value-of select="translate( $format, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz' )"/>
- </xsl:variable>
- <xsl:value-of select="concat('_THIS?frag-resource=/ps/portal/images/','icon_result_', $convertedFormat,'_32.gif', '/THIS_')"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="encDisplayName" select="xtsext:javascriptencode(string($displayName))"/>
- var _THIS_entry = new Object();
- _THIS_entry.defaultName="<xsl:value-of select="$encDisplayName"/>";
- _THIS_entry.key="<xsl:value-of select="$id"/>";
- _THIS_entry.objectClass="<xsl:value-of select="$output/objectClass"/>";
- <xsl:choose>
- <xsl:when test="$output/img">
- _THIS_entry.img='<xsl:copy-of select="$output/img"/>';
- var _THIS_linkTitle="<xts:string id="IDS_FRAG_LINK" encode="javascript"><xts:param name="displayName"><xsl:value-of select="$encDisplayName"/></xts:param></xts:string>";
- </xsl:when>
- <xsl:otherwise>
- _THIS_entry.img="<img alt='<xsl:value-of select="$encDisplayName"/>' title='<xsl:value-of select="$encDisplayName"/>' src='<xsl:value-of select="$icon"/>'/>";
- var _THIS_linkTitle='<xts:string id="IDS_FRAG_ATTACHMENT" encode="javascript"><xts:param name="displayName"><xsl:value-of select="$encDisplayName"/></xts:param></xts:string>';
- </xsl:otherwise>
- </xsl:choose>
- _THIS_entry.linkTitle=_THIS_linkTitle;
- _THIS_htsLinks.append(_THIS_entry);
-
- var _THIS_output = new Object();
- _THIS_output.id=_THIS_entry.key;
- _THIS_output.title=_THIS_entry.defaultName;
- _THIS_output.objectClass=_THIS_entry.objectClass;
- _THIS_outputDetails.add(_THIS_output.id,_THIS_output);
- </xsl:template>
- <xsl:template name="getFilteredAgentTaskPreviews">
- <xsl:param name="taskLinks" select="/root/input[@name='dep']/queryResponse/*[local-name()='manualTask']/*[local-name()='taskLinksList']/*[local-name()='taskLink']"/>
- <xsl:param name="path"/>
- <xsl:choose>
- <xsl:when test="/root/input[@name='dep']/queryResponse/*[local-name()='manualTask']/*[local-name()='taskLinksList']/*[local-name()='taskLink']/*[local-name()='id'][1]='*'">
- <xsl:for-each select="$path/*[local-name()='agentTaskPreview']">
- <filteredAgentPreview>
- <display>
- <xsl:value-of select="./@name"/>
- </display>
- <xsl:copy-of select="."/>
- </filteredAgentPreview>
- </xsl:for-each>
- </xsl:when>
- <xsl:otherwise>
- <xsl:for-each select="$taskLinks">
- <xsl:variable name="id">
- <xsl:value-of select="./*[local-name()='id']"/>
- </xsl:variable>
- <xsl:if test="$path/*[local-name()='agentTaskPreview'][@targetStoreId=$id or @name=$id]!=''">
- <filteredAgentPreview>
- <display>
- <xsl:value-of select="./*[local-name()='display']"/>
- </display>
- <format>
- <xsl:value-of select="./*[local-name()='format']"/>
- </format>
- <locale>
- <xsl:value-of select="./*[local-name()='locale']"/>
- </locale>
- <xsl:copy-of select="$path/*[local-name()='agentTaskPreview'][@targetStoreId=$id or @name=$id]"/>
- </filteredAgentPreview>
- </xsl:if>
- </xsl:for-each>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- </xsl:stylesheet>
|