PropertiesPanel.xsl 8.35 KB
Newer Older
Thitichaipun Wutthisak committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	version="2.0" 
	xmlns:html="http://www.w3.org/TR/REC-html40"
    xmlns:msg="org.pentaho.messages.Messages"
	exclude-result-prefixes="html msg">

	<xsl:output method="html" encoding="UTF-8" />
	<xsl:param name="baseUrl" select="''"/>
	
	<xsl:template match="input-page">

		<xsl:variable name="untitled">
			<xsl:value-of select="msg:getString('PropertiesPanelUIComponent.USER_UNTITLED')"/>
		</xsl:variable>

		<div id="itemdiv" style="border-right:1px solid #808080;position:absolute;top:0px;left:0px;width:380px;height:520px;overflow:default;padding-left:5px;padding-right:5px">
		<form method="post" id="propform">
			<xsl:attribute name="action"><xsl:value-of select="$baseUrl" />PropertiesPanel?path=<xsl:value-of select="./file-path/text()"/>&amp;action=update</xsl:attribute>
						
			<span class="portlet-subsection-header" style="font-size:0.85em"><xsl:value-of select="msg:getString('UI.PROPS_PANEL.FILE')"/> <xsl:value-of select="./display-path/text()"/></span>

			<table width="100%" border="0" cellspacing="0" cellpadding="0" style="padding-top:5px;width:100%">
				<tr>
					<td class="portlet-table-header"><xsl:value-of select="msg:getString('UI.PROPS_PANEL.DELETE')"/></td>
					<td class="portlet-table-header"><xsl:value-of select="msg:getString('UI.PROPS_PANEL.ROLE')"/></td>
				
					<xsl:for-each select="./permission-names/name">
						<td class="portlet-table-header"><xsl:value-of select="./text()"/></td>
					</xsl:for-each>
				</tr>
				<xsl:for-each select="./ac-list/access-control">
					<xsl:variable name="recipientName" select="./recipient/text()"/>
					<xsl:variable name="recipientType" select="./recipient/@type" />
					<xsl:variable name="pos" select="position()"/>
				    <tr>
				    	<td class="portlet-table-text" style="text-align:center">
				    		<INPUT type="checkbox">
				    			<xsl:attribute name="name">delete_<xsl:value-of select="$recipientName"/></xsl:attribute>
				    		</INPUT>
				    	</td>
				    	<td class="portlet-table-text">
									<xsl:value-of select="$recipientName"/>
									<input type="hidden">
										<xsl:attribute name="name"><xsl:value-of select="$recipientType"/>_<xsl:value-of select="$recipientName"/>_<xsl:value-of select="$pos"/></xsl:attribute>
										<xsl:attribute name="value"><xsl:value-of select="$recipientName"/></xsl:attribute>
									</input>
				    	</td>
				    	<xsl:for-each select="./permission">
				    		<td class="portlet-table-text" style="text-align:center">
							
				    			<INPUT type="checkbox">
				    				<xsl:attribute name="name">perm_<xsl:value-of select="./name/text()"/>_<xsl:value-of select="$pos"/></xsl:attribute>
				    				<xsl:if test="./permitted/text()='true'" >
				    					<xsl:attribute name="checked" />
				    				</xsl:if>
								<!-- xsl:if test="$disable='true'">
									<xsl:attribute name="disabled"><xsl:value-of select="$disable"/></xsl:attribute>
								</xsl:if -->
				    			</INPUT>

				    		</td>
				    	</xsl:for-each>
				    </tr>
		    	</xsl:for-each>

				<tr><td colspan="10">
	    	<xsl:if test="count(./ac-list/access-control) &gt; 0">
				<input name="updateBtn2" id="props-update" type="button">
					<xsl:attribute name="value"><xsl:value-of select="msg:getString('UI.USER_UPDATE')"/></xsl:attribute>
					<xsl:attribute name="onclick">document.getElementById('updateBtn').value="yes"; document.forms['propform'].submit() ;return false;</xsl:attribute>
				</input>
				<input name="resetBtn" type="reset">		
					<xsl:attribute name="value"><xsl:value-of select="msg:getString('UI.USER_RESET')"/></xsl:attribute>
				</input>
			</xsl:if>
			<input name="addBtn" type="button">
				<xsl:attribute name="value"><xsl:value-of select="msg:getString('UI.USER_ADD')"/></xsl:attribute>
				<xsl:attribute name="onclick">document.getElementById('adddiv').style.display='block';</xsl:attribute>
			</input>

			<br />
			<!-- 
			<xsl:if test="./is-directory/text()='true'" >
				<INPUT type="checkbox" name="appy-recursively"/><span class="text"><xsl:value-of select="msg:getString('UI.PROPS_PANEL.RECURSE')"/></span>
			</xsl:if>
			-->
				</td></tr>

		</table>
			<input type="hidden" name="updateBtn" id="updateBtn" value=""/>
    	</form>
		</div>

				<xsl:call-template name="addContent">
				</xsl:call-template>

	</xsl:template>

	<xsl:template name="addContent">
	
		<div id="adddiv" style="padding-left:5px;position:absolute;top:0px;left:390px;width:275px;height:500px;overflow:default;display:none">
		
		<form method="post" id="propaddform">

			<span class="portlet-subsection-header" style="font-size:0.85em"><xsl:value-of select="msg:getString('UI.USER_PERMISSION_ADD_NEW')"/></span>

		<table width="100%" border="0" style="padding-top:5px">

		<tr>
			<td class="portlet-table-header" colspan="10"><xsl:value-of select="msg:getString('UI.PROPS_PANEL.ROLE')"/></td>
		</tr>
		<tr>
			<td colspan="10">
					    	<SELECT class="text" size="23" style="width:265px" multiple="true">
					    		<xsl:attribute name="name">add_name</xsl:attribute>
					    		<xsl:attribute name="id">add_name</xsl:attribute>
								
								<OPTGROUP label="Roles" />
					    		<xsl:for-each select="//recipients/role">
								
					    			<xsl:variable name="aRole" select="./text()"/>
									<xsl:variable name="ok">
										<xsl:for-each select="../../ac-list/access-control">
											<xsl:if test="$aRole=./recipient/text()">no</xsl:if>
										</xsl:for-each>
									</xsl:variable>
									<xsl:if test="$ok=''">
						    			<OPTION>
						    				<xsl:attribute name="value">role_<xsl:value-of select="$aRole" /></xsl:attribute>
						    				<xsl:value-of select="$aRole"/>
						    			</OPTION>
									</xsl:if>
					    		</xsl:for-each>
					    		<OPTGROUP label="Users" />
					    		<xsl:for-each select="//recipients/user">
					    			<xsl:variable name="aUser" select="./text()"/>
									<xsl:variable name="ok">
										<xsl:for-each select="../../ac-list/access-control">
											<xsl:if test="$aUser=./recipient/text()">no</xsl:if>
										</xsl:for-each>
									</xsl:variable>
									<xsl:if test="$ok=''">
						    			<OPTION>
						    				<xsl:attribute name="value">user_<xsl:value-of select="$aUser" /></xsl:attribute>
						    				<xsl:value-of select="$aUser"/>
						    			</OPTION>
									</xsl:if>
					    		</xsl:for-each>
					    	</SELECT>

			</td>
		</tr>
		<tr>
				
			<xsl:for-each select="./permission-names/name">
				<td class="portlet-table-header"><xsl:value-of select="./text()"/></td>
			</xsl:for-each>
		</tr>

		<tr>
					
			<xsl:for-each select="./permission-names/name">
						<td align="center" valign="top">
							<INPUT type="checkbox">
			    				<xsl:attribute name="name">perm_Untitled-0#<xsl:value-of select="./text()"/></xsl:attribute>
							</INPUT>
						</td>
			</xsl:for-each>

		</tr>

		<tr>
			<td colspan="10">

				<xsl:variable name="permCount" select="count(//ac-list/access-control[position()=1]/permission)"/>

			<input name="addBtn2" type="submit">
				<xsl:attribute name="value"><xsl:value-of select="msg:getString('UI.USER_ADD')"/></xsl:attribute>
				<xsl:attribute name="onclick">if(document.getElementById('add_name').selectedIndex==-1) { return false; } document.getElementById('name_Untitled-0').value = document.getElementById('add_name').value; return true;</xsl:attribute>
			</input>

				<input name="cancelBtn" type="button">
					<xsl:attribute name="value"><xsl:value-of select="msg:getString('UI.USER_CANCEL')"/></xsl:attribute>
					<xsl:attribute name="onclick">document.getElementById('adddiv').style.display='none';</xsl:attribute>
					<!-- xsl:attribute name="onclick">document.getElementById('delete_<xsl:value-of select="$addpos"/>').disabled = false; document.getElementById('delete_<xsl:value-of select="$addpos"/>').value = 'on'; document.getElementById('updateBtn').value="yes"; document.forms['propform'].submit() ;return false;</xsl:attribute -->
				</input>
			</td>
		</tr>
		
				</table>
				<input type="hidden" name="name_Untitled-0" id="name_Untitled-0" value=""/>
				<input type="hidden" name="action" value="update"/>
				<input type="hidden" name="addBtn" value="Add"/>
    	</form>

			</div>
		
	</xsl:template>
	
	<xsl:template match="no-file-path">
		<xsl:value-of select="./text()"/>
	</xsl:template>	
  
    <xsl:template match="no-acls">
        <xsl:value-of select="./text()"/>
    </xsl:template>

</xsl:stylesheet>