<%
/**
 * 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 ;
  import org.exoplatform.webui.form.UIFormCheckBoxInput;
%>
<div class="$uicomponent.id UIFormInputSetWithAction  UIFormInputSet">
  <table class="UIFormGrid FormContainer">
	<tbody>
            
    <%
      def formName = uicomponent.getFormName() ;
    	def parentFormName = uicomponent.getParent().getName();
      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()) {
    %>
          <tr >
               <%
                String label = _ctx.appRes(formName + ".label." + inputEntry.getId()) ;
                if(!label.equals(inputEntry.getId()) || inputEntry instanceof UIFormCheckBoxInput) {
              %>
                  <td class="FieldLabel"><%=label%></td>
               <%}%>
                <td class="FieldComponent">
                <% 
              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>  
                     <a href="javascript:eXo.webui.UIForm.submitEvent('<%=formName%>', '<%=actionInfo[0]%>', '&objectId=<%=j%>');" onclick="return confirm('<%=confirm%>');">
                        <img class="DeleteIconInfo" src="/eXoResources/skin/DefaultSkin/background/Blank.gif" alt="">
                     </a>
                   </div> 
              <%
                   }
                }
              %>
                </div>
             <%}
              if(infor != null && actionInfo != null) {
                def arrInfor = infor.split(",") ;
                if(arrInfor.length > 0) {
                  for(i in 0..arrInfor.length -1) {
                    if(arrInfor[i].length() > 0) { 
                      if(!isView) { 
                       if(uicomponent.isDeleteOnly()) { %>
                        <div class="ActionField">
                          <%=arrInfor[i]%>
                        </div>                 
	                      <a href="javascript:eXo.webui.UIForm.submitEvent('<%=formName%>', '<%=actionInfo[0]%>', '&objectId=<%=arrInfor[i]%>');" onclick="return confirm('<%=confirm%>');">
	                        <div class="DeleteIconInfo"><span></span></div>                    
	                      </a>
                     <%} else { %>
                          <div class="ActionField FL" >
                            <a title="<%=arrInfor[i].trim()%>" href="javascript:eXo.webui.UIForm.submitEvent('<%=formName%>', '<%=actionInfo[0]%>', '&objectId=<%=arrInfor[i]%>');">
                              <%=arrInfor[i].trim()%>
                          </a>
                        </div>
                       <a href="javascript:eXo.webui.UIForm.submitEvent('<%=formName%>', '<%=actionInfo[1]%>', '&objectId=<%=arrInfor[i]%>');" onclick="return confirm('<%=confirm%>');">
                         <img class="DeleteIconInfo" src="/eXoResources/skin/DefaultSkin/background/Blank.gif" alt=""/>                
                       </a>
                       <div class="ClearLeft"><span></span></div>
                     <%
                       }
                      } else {
                      %>
                      <div class="ActionFieldContainer">
                       <div class="ActionField">
                         [ 
                           <a onclick="javascript:eXo.webui.UIForm.submitEvent('<%=formName%>', '<%=actionInfo[0]%>', '&objectId=<%=arrInfor[i]%>');" href="javascript:void(0);"><%=arrInfor[i]%></a>
                          ]
                       </div>  
                      </div>
                    <%
                      }               
                    }
                  }
                }
              } else if(infor != null && uicomponent.isShowOnly()) {
               def arrInfor = infor.split(",") ;
                if(arrInfor.length > 0) {
                   for(i in 0..arrInfor.length -1) { 
                     if(arrInfor[i].length() > 0) { %>
                      <div class="ActionField" >[ <%=arrInfor[i]%> ]</div>  
                       <div class="ClearLeft"><span></span></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="javascript:eXo.webui.UIForm.submitForm('<%=formName%>', '<%=actionField[i]%>', true)" title="<%=_ctx.appRes(uicomponent.getId() + ".title." + actionField[i])%>" class="AddIcon16x16 <%=actionField[i]%>Icon" src="/eXoResources/skin/DefaultSkin/background/Blank.gif" alt="" />
             <%
                  }
               }
              } else if(isShowAction) {                
               for(String action : uicomponent.getFieldActions(inputEntry.getName())) {
             %>      
                      <img onclick="javascript:eXo.webui.UIForm.submitForm('<%=formName%>', '<%=action%>', true)" title="<%=_ctx.appRes(uicomponent.getId() + ".title." + action)%>" class="AddIcon16x16 <%=action%>Icon" class="AddIcon16x16 <%=action%>Icon" src="/eXoResources/skin/DefaultSkin/background/Blank.gif" alt="" />
             <%
                }
              }
              if(uicomponent.getMsgKey(inputEntry.getName()) != null) { %>
                      <span class="Introduction"><%=_ctx.appRes(uicomponent.getMsgKey(inputEntry.getName()))%></span>                
              <%}%>
                </td>
				 </tr>
     
    <%
        }
      }
	  
    %>

	</tbody>
  </table>
  
    <%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 class="ActionButton LightBlueStyle" onclick="javascript:eXo.webui.UIForm.submitEvent('<%=formName%>','<%=actions[i]%>','&objectId=<%=actionValues[i]%>');" href="javascript:void(0);"><%=_ctx.appRes(formName + ".action." + actions[i])%></a>   
            			<%} else { %> 
                    <a class="ActionButton LightBlueStyle" onclick="javascript:eXo.webui.UIForm.submitForm('<%=formName%>','<%=actions[i]%>', true);" href="javascript:void(0);"><%=_ctx.appRes(formName + ".action." + actions[i])%></a>   
                  <%
                     }
               } else { 
               %>
               <a class="ActionButton LightBlueStyle" onclick="javascript:eXo.webui.UIForm.submitForm('<%=formName%>','<%=actions[i]%>', true);" href="javascript:void(0);"><%=_ctx.appRes(formName + ".action." + actions[i])%></a>
            <%}%>                         
                <%} %>          
        </div>
    <%} %>

</div>