<%
/**
 * Created by The eXo Platform SARL
 * Author : Dang Van Minh
 *					minh.dang@exoplatform.com
 * @version $Id$
 * Oct 9, 2006	
 */
%>
<%
	import org.exoplatform.webui.form.UIFormRadioBoxInput;
%>
<div class="$uicomponent.id">
	<div class="UIFormInputSet">
		<div class="UIFormInputSetWithAction">
			<%
				def formName = uicomponent.getFormName();
				def actions = uicomponent.getInputSetActions();
				def actionValues = uicomponent.getActionValues();
				def isShowAction = uicomponent.isShowActionInfo()
				String confirm = _ctx.appRes("UIFormInputSetWithAction.msg.confirm-delete");
				for(inputEntry in uicomponent.getChildren()) {
					if(inputEntry.isRendered()) {
			%>
					<div class="FormContainer">
					   <%
						    String label = _ctx.appRes(formName + ".label." + inputEntry.getId());
						%>
						<table class="UIFormGrid" summary="<%= label %> form">
							<tbody>
								<tr>
									<%
										if(!label.equals(inputEntry.getId())) {
									%>
										<td class="FieldLabel portlet-form-label" scope="row"><%=label%></td>
									<%}%>
									<td class="FieldComponent portlet-input-field">
									<% 
										if(inputEntry instanceof UIFormRadioBoxInput) {
											println "<div class=\"MultiRadioInput\">";
												uicomponent.renderUIComponent(inputEntry); 
											println "</div>";
										} else {
											uicomponent.renderUIComponent(inputEntry); 
										}
										String infor = uicomponent.getInfoField(inputEntry.getName());
										def listInfor = uicomponent.getListInfoField(inputEntry.getName());
										def actionInfo = uicomponent.getActionInfo(inputEntry.getName());
										boolean isView = uicomponent.isView();
										if(listInfor != null && listInfor.size() > 0 && actionInfo != null) { %>
											<div class="InforArea">
										<%for(j in 0..listInfor.size()-1) {
												if(uicomponent.isDeleteOnly()) { %>
													<div class="InforField">
														<span class="ActionField"><%=listInfor[j]%></span>	
														<img onclick="if(confirm('<%=confirm%>')) eXo.webui.UIForm.submitEvent('<%=formName%>', '<%=actionInfo[1]%>', '&objectId=<%=arrInfor[i]%>');" alt="" class="DeleteIconInfo" src="/eXoResources/skin/DefaultSkin/background/Blank.gif"/>
													</div>	
										<%
												}
											}
										%>
											</div>
									<%}
										if(infor != null && actionInfo != null) {
											def arrInfor = infor.split(",");
											if(arrInfor.length > 0) {
											println "<div class=\"clearfix\">";
												println "<div class=\"pull-left\" style=\"overflow:hidden;\">";
												for(i in 0..arrInfor.length -1) {
													if(arrInfor[i].length() > 0) { 
														if(!isView) { 
															if(uicomponent.isDeleteOnly()) { %>
																<div class="ActionField">
																	<%=arrInfor[i]%>
																</div>									
																<img onclick="if(confirm('<%=confirm%>')) eXo.webui.UIForm.submitEvent('<%=formName%>', '<%=actionInfo[0]%>', '&objectId=<%=arrInfor[i]%>');" alt="" class="DeleteIconInfo" src="/eXoResources/skin/DefaultSkin/background/Blank.gif"/>										 
														<%} else { %>
															<div class="clearfix">
																<div class="ActionField pull-left">
																	[ <a href="javascript:void(0);" onclick="javascript:eXo.webui.UIForm.submitEvent('<%=formName%>', '<%=actionInfo[0]%>', '&objectId=<%=arrInfor[i]%>');">
																			<%=arrInfor[i]%>
																	</a> ]
																</div>
																	<img onclick="if(confirm('<%=confirm%>')) eXo.webui.UIForm.submitEvent('<%=formName%>', '<%=actionInfo[1]%>', '&objectId=<%=arrInfor[i]%>');" alt="" class="DeleteIconInfo" src="/eXoResources/skin/DefaultSkin/background/Blank.gif"/>								
																</div>
														<%
															}
														} else {
														%>
														<div class="ActionFieldContainer">
															<div class="ActionField">
																[ <a href="javascript:void(0);" onclick="javascript:eXo.webui.UIForm.submitEvent('<%=formName%>', '<%=actionInfo[0]%>', '&objectId=<%=arrInfor[i]%>');">
																	<%=arrInfor[i]%>
																</a> ]
															</div>	
														 </div>
													<%
														}								
													}
												}
											 println "</div>";
											 println "</div>";
											}
										} else if(infor != null && uicomponent.isShowOnly()) {
											def arrInfor = infor.split(",");
											if(arrInfor.length > 0) {
												println "<div class=\"clearfix\">";
												println "<div class=\"pull-left\" style=\"overflow:hidden;\">";
													for(i in 0..arrInfor.length -1) { 
														if(arrInfor[i].length() > 0) { %>
															<div class="clearfix">
																<div class="ActionField">[ <%=arrInfor[i]%> ]</div>	
															</div>
														<%
														}								
													}
											 	println "</div>";
											 	println "</div>";
											}
										} 
										if(infor == null && listInfor == null) {
											def actionField = uicomponent.getActionInfo(inputEntry.getName());
											if(actionField != null && actionField.length > 0) {
												for(i in 0..actionField.length -1) {
										%>			
														<img onclick="eXo.webui.UIForm.submitForm('<%=formName%>', '<%=actionField[i]%>', true)" class="AddIcon16x16 <%=actionField[i]%>Icon" alt="<%=_ctx.appRes(uicomponent.getId() + ".title." + actionField[i])%>" src="/eXoResources/skin/DefaultSkin/background/Blank.gif"/>
										<%
												}
											}
										} else if(isShowAction) {											 
											for(String action : uicomponent.getFieldActions(inputEntry.getName())) {
										%>			
												<img onclick="eXo.webui.UIForm.submitForm('<%=formName%>', '<%=action%>', true)" class="AddIcon16x16 <%=action%>Icon" alt="<%=_ctx.appRes(uicomponent.getId() + ".title." + action)%>" src="/eXoResources/skin/DefaultSkin/background/Blank.gif"/>
										<%
											}
										}
										if(uicomponent.getMsgKey(inputEntry.getName()) != null) { %>
											<span class="Introduction"><%=_ctx.appRes(uicomponent.getMsgKey(inputEntry.getName()))%></span>											
										<%}%>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
			<%
					}
				}
			%>
			<%if(actions != null && actions.length > 0) { %>
				<div class="UIAction">
					<%for(i in 0..actions.length -1) { 
							if(actionValues != null && actionValues.length > 0) { 
								if(actionValues[i] != null) { %>
									<a href="javascript:void(0);" class="ActionButton LightBlueStyle" onclick="javascript:eXo.webui.UIForm.submitEvent('<%=formName%>','<%=actions[i]%>','&objectId=<%=actionValues[i]%>');"><%=_ctx.appRes(formName + ".action." + actions[i])%></a>
							<%} else { %>
									<a href="javascript:void(0);" class="ActionButton LightBlueStyle" onclick="javascript:eXo.webui.UIForm.submitForm('<%=formName%>','<%=actions[i]%>', true);"><%=_ctx.appRes(formName + ".action." + actions[i])%></a>		 
					 	 <%
								}
							} else { 
							%>
								<a href="javascript:void(0);" class="ActionButton LightBlueStyle" onclick="javascript:eXo.webui.UIForm.submitForm('<%=formName%>','<%=actions[i]%>', true);"><%=_ctx.appRes(formName + ".action." + actions[i])%></a>		 
						<%}%>
					<%} %>
				</div>
			<%} %>
		</div>
	</div>
</div>		
