<%
	//Fixed by Phuong 12/08/2006	
	import org.exoplatform.webui.organization.UIGroupMembershipSelector;
	import org.exoplatform.webui.core.UIPopupWindow; 
	import org.exoplatform.webui.form.UIForm;
	
	def uiForm = uicomponent.getAncestorOfType(UIForm.class);
	def permission =	uicomponent.getPermission();
	def rcontext = _ctx.getRequestContext();

	def popupId = uicomponent.getChild(UIPopupWindow.class).getId();
	def btn = "#UIPermissionSelector .uiAction .btn";
	rcontext.getJavascriptManager().require("SHARED/jquery", "\$").require("SHARED/uiPopupWindow", "uiPopupWindow")
			  .addScripts("\$('$btn').eq(1).click(function() {uiPopupWindow.show('$popupId', true)});");
%>
<div class="uiPermissionSelector" id="UIPermissionSelector">
	
		<%uicomponent.renderChildren();%>
	 
		<%/*Begin UIToolbarContentContainer*/%>
		
			<div class="form-horizontal" style="display:block;">
				<div class="control-group">
					<strong class="control-label"><i class="uiIconInformation uiIconBlue"> </i> <%=_ctx.appRes(uicomponent.getId() + ".label.currentSelectedPermissionInfo")%></strong>
				</div>
				<div class="control-group">
					<label class="control-label"><%=_ctx.appRes(uicomponent.getId() + ".label.groupId")%> :</label>
					<% 
					def groupId = permission.getGroupId();
					if(groupId.length() < 60) {
					%>
							<div class="controls"><%=permission.getGroupId() %></div>
					<% } else { %>
							<div class="controls" title="$groupId"><%=groupId.substring(0,57) + "..." %></div>
					<% } %>
				</div>				 
				<div class="control-group">
					<label class="control-label"><%=_ctx.appRes(uicomponent.getId() + ".label.membershipMember")%> :</label>
					<div class="controls"><%=permission.getMembership()%></div>
				</div>
			
			</div>	
			
			<% if(uicomponent.isEditable()) { %>	
				<div class="uiAction uiActionBorder">
					
					<%/*Click on this action button will pop up the permission selector*/%>
					<%
					String deletePermissionEvent = "javascript:void(0)";
					if(permission.getExpression() != null && permission.getExpression().length() > 0) {
						deletePermissionEvent = uiForm.event("DeletePermission", uicomponent.getId(), "");
					} 
					%>
				 	
						<a class="btn" onclick="<%=deletePermissionEvent%>" class="DeletePermissionIcon"><%=_ctx.appRes(uicomponent.getId() + ".action.DeletePermission")%></a>
						<a class="btn" href="javascript:void(0);" class="SelectPermissionIcon"><%=_ctx.appRes(uicomponent.getId() + ".action.SelectPermission")%></a>
				</div>
			<% } %>
		
		<%/*End UIToolbarContentContainer*/%>
	
</div>