<%
/**
 * 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.ecm.webui.component.explorer.popup.actions.UITaggingForm;

	def context = _ctx.getRequestContext() ;
	context.getJavascriptManager().importJavascript('eXo.ecm.AutoComplete','/ecmexplorer/javascript/') ;
	context.getJavascriptManager().addOnLoadJavascript("eXo.ecm.AutoComplete.disposeCount"); 
%>
<div class="$uicomponent.id">
 <div class="UIFormInputSet">
  <div class="UIFormInputSetWithAction">
    <%
      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()) {
        	if (inputEntry.getName().equals(UITaggingForm.TAG_NAME_LIST)) { %>		
        		<div class="FormContainer UIFormTextAreaInput"> 
        			<select><%
    					for (tagName in uicomponent.getTagNames()) { %>
    						<option class="Item" style="height:20px;" value="$tagName">
    							<%=tagName%>
    						</option>  <%
  						} %>
  						</select>
    				</div> <% 
  				} else {
	        	if (inputEntry.getName().equals(UITaggingForm.TAG_NAMES)) {	%>
    					<div class="FormContainer UITagNameInput" onkeydown="eXo.ecm.AutoComplete.createTags(event, this)"> <%
    	   	} else { %>
    	      <div class="FormContainer">  <%		
  	      }	%>
          <table class="UIFormGrid">
            <tbody>
              <tr >
               <%
                String label = _ctx.appRes(formName + ".label." + inputEntry.getId()) ;
                if(!label.equals(inputEntry.getId())) {
              %>
                  <td class="FieldLabel"><label for="<%=inputEntry.getId()%>"><%=label%></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="<%=actionInfo[0]%>" />
                     </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="ClearFix">
                          <div class="ActionField FL">
                            <a 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="<%=actionInfo[1]%>"/>                
                       </a>
                     </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>  
                      
                     <%
                     }               
                   }
                }
              } 
              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="<%=_ctx.appRes(uicomponent.getId() + ".title." + actionField[i])%>" />
             <%
                  }
               }
              } 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="<%=_ctx.appRes(uicomponent.getId() + ".title." + action)%>" />
             <%
                }
              }
              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 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>
 </div>
</div>