tenantlogic.xsl 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: ps
  5. (C) Copyright IBM Corp. 2013
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <xsl:stylesheet version="1.0"
  9. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  10. xmlns:send="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/brl/1/"
  11. xmlns:reqhelpers="http://developer.cognos.com/schemas/xts-cm/1/reqhelpers"
  12. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  13. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  14. xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  15. xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  16. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:out="dummy-uri"
  17. xmlns:lyt="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/layout/"
  18. xmlns:dp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/presentation/"
  19. xmlns:df="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/framework/"
  20. xmlns:cf="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/framework/"
  21. xmlns:cp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/presentation/"
  22. xmlns:utml="http://developer.cognos.com/schemas/xts/logicsheet/xslt/formlogic/"
  23. exclude-result-prefixes="xsl send reqhelpers xts bus lyt dp df cf cp utml">
  24. <xsl:output method="xml" version="1.0" encoding="UTF-8"
  25. indent="no" />
  26. <xsl:namespace-alias stylesheet-prefix="out"
  27. result-prefix="xsl" />
  28. <xsl:template match="tenantSelectionUIDojoInit">
  29. <link id="themeStyles" rel="stylesheet" href="{{$webcontent}}/../dojo16/dijit/themes/tundra/tundra.css" />
  30. <script src="{{$webRoot}}/dojo16/dojo/dojo.js" />
  31. </xsl:template>
  32. <xsl:template match="tenantSelectionUI">
  33. <lyt:section>
  34. <out:if test="key('env-param','m_new_class') != 'tenant'">
  35. <out:variable name="parent_is_public" select="$the-object/cm:tenantID=''" />
  36. <out:variable name="has_read_permission" select="true()" />
  37. <out:variable name="tenantID">
  38. <out:choose>
  39. <out:when test="key('env-param','m_p_tenantID') and key('env-param', 'm_p_tenantID') != ''">
  40. <out:value-of select="key('env-param', 'm_p_tenantID')" />
  41. </out:when>
  42. <out:when test="string($the-object/cm:tenantID)!='' and (not(key('env-param', 'changed_m_p_tenantID')) or key('env-param', 'changed_m_p_tenantID') != '1')">
  43. <out:value-of select="string($the-object/cm:tenantID)" />
  44. </out:when>
  45. <out:otherwise>
  46. <out:value-of select="key('session-param', 'e_tenantID')"/>
  47. </out:otherwise>
  48. </out:choose>
  49. </out:variable>
  50. <out:variable name="tenantName">
  51. <out:choose>
  52. <out:when test="key('env-param','objTenantName') != ''">
  53. <out:value-of select="key('env-param','objTenantName')" />
  54. </out:when>
  55. <out:when test="/root/tenantObjInfo//*/cm:defaultName != ''">
  56. <out:value-of select="/root/tenantObjInfo//*/cm:defaultName" />
  57. </out:when>
  58. <out:when test="boolean(key('session-param', 'e_writeTenantName'))">
  59. <out:choose>
  60. <out:when test="key('session-param', 'e_writeTenantName') != ''">
  61. <out:value-of select="key('session-param', 'e_writeTenantName')"/>
  62. </out:when>
  63. <out:otherwise>
  64. <xts:string id="IDS_NONE"/>
  65. </out:otherwise>
  66. </out:choose>
  67. <out:value-of select="key('session-param', 'e_writeTenantName')"/>
  68. </out:when>
  69. <out:when test="key('session-param', 'e_tenantDisplayName') != ''">
  70. <out:value-of select="key('session-param', 'e_tenantDisplayName')"/>
  71. </out:when>
  72. <out:otherwise>
  73. <xts:string id="IDS_NONE"/>
  74. </out:otherwise>
  75. </out:choose>
  76. </out:variable>
  77. <out:variable name="isAccountObject"
  78. select="$the-object/cm:objectClass='account'" />
  79. <out:variable name="isTenantObject"
  80. select="$the-object/cm:objectClass='tenant' or $the-object/cm:objectClass='tenants'" />
  81. <out:variable name="tenantInfo">
  82. <out:choose>
  83. <out:when test="$isTenantObject">
  84. <label>
  85. <xts:string id="IDS_PROP_TENANTID" />
  86. </label>
  87. <text>
  88. <out:value-of select="$the-object/cm:tenantID" />
  89. </text>
  90. </out:when>
  91. <out:otherwise>
  92. <label>
  93. <xts:string id="IDS_PROP_TENANT_NAME" />
  94. </label>
  95. <text>
  96. <out:value-of select="$tenantName" />
  97. </text>
  98. </out:otherwise>
  99. </out:choose>
  100. </out:variable>
  101. <out:if test="not($isTenantObject) and key('session-param', 'e_showTenantInfo')='true' and $has_read_permission">
  102. <dp:list width="50%">
  103. <dp:input>
  104. <dp:section1>
  105. <utml:input type="hidden" name="changed_genprop" value="0" />
  106. <utml:input type="hidden" id="tenantID" name="m_p_tenantID" class="pInput" maxlength="100" size="30">
  107. <utml:value>
  108. <out:value-of select="$tenantID" />
  109. </utml:value>
  110. </utml:input>
  111. <utml:input type="hidden" name="changed_m_p_tenantID" class="pInput" maxlength="100" size="30">
  112. <utml:value>
  113. <out:value-of select="'1'" />
  114. </utml:value>
  115. </utml:input>
  116. </dp:section1>
  117. </dp:input>
  118. <out:if test="key('session-param', 'e_showTenantInfo')='true' and $has_read_permission">
  119. <dp:section>
  120. <dp:label valign="top" width="1%" tabindex="0">
  121. <out:value-of select="$tenantInfo/label" />
  122. </dp:label>
  123. <dp:text width="1%">
  124. <out:value-of select="xtsext:enforceBTD($tenantInfo/text, $baseTextDirection, $productLocale, boolean($isBidiEnabled='true'))" />
  125. </dp:text>
  126. <out:if test="key('session-param', 'e_isSysAdmin')='true' or key('session-param', 'e_isTenantAdmin')='true'">
  127. <dp:link>
  128. <out:if test="/root/tenantChanged">
  129. <script language="javascript">
  130. dojo.addOnLoad(function()
  131. {
  132. alert('<xts:string id="IDS_TENANT_CHANGED_WARNING" encode="javascript"/>' );
  133. }
  134. );
  135. </script>
  136. </out:if>
  137. <out:if test="not($tenantID ='' and ($isAccountObject or $isTenantObject)) and $parent_is_public">
  138. <script language="javascript">
  139. function utmlSubmitForm(formName, targetPage, operation, dovalid) {
  140. if( dovalid != '' &amp;&amp; window.validate ) {
  141. if( !validate() )
  142. return;
  143. }
  144. formName.ps_nav_op.value = operation;
  145. if (targetPage != '')
  146. formName.m.value = targetPage;
  147. else if (operation == 'pop' || operation == 'drop')
  148. formName.m.value = '';
  149. formName.submit();
  150. }
  151. dojo.require("dijit.form.FilteringSelect");
  152. dojo.require("dojo.data.ItemFileReadStore");
  153. var g_select;
  154. dojo.addOnLoad(function() {
  155. // create store instance referencing data from listTenants.xts
  156. var tenantStore = new dojo.data.ItemFileReadStore({
  157. url: "<out:value-of select="concat($gateway,'?b_action=xts.run&amp;m=',$app,'/tenants/listTenants.xts')" />"
  158. });
  159. g_select = new dijit.form.FilteringSelect({
  160. name: "selectedTenantName",
  161. placeHolder: "<xts:string id="IDS_SELECT_THE_TENANTID" encode="javascript" />",
  162. value: "<out:value-of select="xtsext:javascriptencode($tenantName)"/>",
  163. store: tenantStore
  164. }, "selectedTenantName");
  165. g_select.startup();
  166. });
  167. function showTenantDlg() {
  168. selectTenantDialog.show();
  169. setTimeout('setTenantFocus()', 11);
  170. }
  171. function setTenantFocus(){
  172. if (selectTenantDialog.className = "visible")
  173. g_select.focus();
  174. }
  175. function updateTenantID(newTenantID, newTenantName) {
  176. setFormInputElement('newTenantID',newTenantID);
  177. setFormInputElement('newTenantName',newTenantName);
  178. setFormInputElement('tenantChanged','true');
  179. setPropertiesChanged();
  180. utmlSubmitForm(document.pform,'<out:value-of select="xtsext:javascriptencode(string($app))"/>/<out:value-of select="xtsext:javascriptencode(string($mname))"/>','maintain','');
  181. }
  182. function setNewTenantID() {
  183. if (g_select.isValid()) {
  184. updateTenantID(g_select.item.id, g_select.item.name);
  185. javascript:selectTenantDialog.hide();
  186. }
  187. }
  188. function makeTenantIDPublic() {
  189. updateTenantID('','<xts:string id="IDS_NONE" encode="javascript"/>');
  190. }
  191. function setPropertiesChanged() {
  192. document.pform['changed_genprop'].value='1';
  193. }
  194. </script>
  195. <out:if test="not($isTenantObject)">
  196. <out:choose>
  197. <out:when test="$tenantID !=''">
  198. <dp:text>
  199. <a href="javascript:showTenantDlg();">
  200. <out:text />
  201. <xts:string id="IDS_EDIT_THE_TENANTID" />
  202. <out:text />
  203. </a>
  204. </dp:text>
  205. <out:if test="not($isAccountObject)">
  206. <dp:text>
  207. <a href="javascript:makeTenantIDPublic();">
  208. <out:text />
  209. <xts:string id="IDS_MAKE_PUBLIC" />
  210. <out:text />
  211. </a>
  212. </dp:text>
  213. </out:if>
  214. </out:when>
  215. <out:otherwise>
  216. <dp:text>
  217. <a href="javascript:showTenantDlg();">
  218. <out:text />
  219. <xts:string id="IDS_SELECT_THE_TENANTID" />
  220. <out:text />
  221. </a>
  222. </dp:text>
  223. </out:otherwise>
  224. </out:choose>
  225. </out:if>
  226. <div>
  227. <cp:genericDialog id="selectTenantDialog"
  228. rootContainerId="pform" interactive="true" align="left"
  229. width="300" positionVertical="true" positionHorizontal="true"
  230. helpid="tenantHelp" focusidOnShiftTab="tenantCancel">
  231. <cp:param name="title">
  232. <xts:string id="IDS_SELECT_TENANTID_TITLE" />
  233. </cp:param>
  234. <cp:param name="body">
  235. <lyt:layout style="1" lyt:kbA11y="true">
  236. <lyt:section>
  237. <dp:list>
  238. <dp:section>
  239. <dp:text>
  240. <xts:string id="IDS_SELECT_TENANTID_INTRO" />
  241. </dp:text>
  242. </dp:section>
  243. <dp:section>
  244. <dp:text />
  245. </dp:section>
  246. <dp:section>
  247. <dp:input dp:kbA11y="true">
  248. <dp:section1>
  249. <Label for="selectedTenantName">
  250. <xts:string id="IDS_PROP_TENANT_NAME" />
  251. </Label>
  252. </dp:section1>
  253. <dp:section2>
  254. <table><tr><td><input id="selectedTenantName"/></td></tr></table>
  255. </dp:section2>
  256. </dp:input>
  257. </dp:section>
  258. <dp:section>
  259. <dp:text />
  260. </dp:section>
  261. </dp:list>
  262. </lyt:section>
  263. </lyt:layout>
  264. </cp:param>
  265. <cp:param name="footer">
  266. <!-- NOTE: onkeydown required to force navigation within the
  267. popup element -->
  268. <dp:simpleFooter>
  269. <td>
  270. <table cellpadding="0" cellspacing="0" role="presentation">
  271. <tr>
  272. <td>
  273. <cp:cmdButton defaultState="active" id="tenantOK">
  274. <cp:cmdButtonText>
  275. <xts:string id="IDS_OK" />
  276. </cp:cmdButtonText>
  277. <cp:cmdButtonEvents>
  278. <cp:cmdButtonEvent name="onclick">setNewTenantID();
  279. </cp:cmdButtonEvent>
  280. </cp:cmdButtonEvents>
  281. </cp:cmdButton>
  282. </td>
  283. <td>
  284. <cp:cmdButton defaultState="active" id="tenantCancel">
  285. <cp:cmdButtonText>
  286. <xts:string id="IDS_CANCEL" />
  287. </cp:cmdButtonText>
  288. <cp:cmdButtonEvents>
  289. <cp:cmdButtonEvent name="onclick">javascript:selectTenantDialog.hide();
  290. </cp:cmdButtonEvent>
  291. <cp:cmdButtonEvent name="onkeydown">
  292. javascript:if(event.keyCode==9)
  293. <out:text>{</out:text>
  294. if(event.shiftKey==true) return true; else
  295. <out:text>{</out:text>
  296. if(document.getElementById("tenantHelp"))
  297. <out:text>{</out:text>
  298. document.getElementById("tenantHelp").focus();
  299. return false;
  300. <out:text>}</out:text>
  301. <out:text>}</out:text>
  302. <out:text>}</out:text>
  303. return true;
  304. </cp:cmdButtonEvent>
  305. </cp:cmdButtonEvents>
  306. </cp:cmdButton>
  307. </td>
  308. </tr>
  309. </table>
  310. </td>
  311. </dp:simpleFooter>
  312. </cp:param>
  313. </cp:genericDialog>
  314. </div>
  315. </out:if>
  316. </dp:link>
  317. </out:if>
  318. </dp:section>
  319. </out:if>
  320. </dp:list>
  321. </out:if>
  322. </out:if>
  323. </lyt:section>
  324. </xsl:template>
  325. <xsl:template match="*">
  326. <xsl:copy>
  327. <xsl:copy-of select="@*" />
  328. <xsl:apply-templates />
  329. </xsl:copy>
  330. </xsl:template>
  331. </xsl:stylesheet>