<div class="UIFormWithTitle">
  <div class="TitleBar"><%=_ctx.appRes(uicomponent.getId() + ".title")%></div>
	<% uiform.begin() %>
  <div class="HorizontalLayout">	
  	<table class="UIFormGrid">
				<tr>
				  <td class="FieldLabel" style="display:none"><label for="id"><%=_ctx.appRes("SendMail.dialog.label.id")%></label></td>
				  <td class="FieldComponent" style="display:none">
				  <%
					 String[] fieldId = ["jcrPath=/node", "mixintype=mix:affectedNodeTypes", "editable=false", "visible=if-not-null"] ;
					 uicomponent.addMixinField("id", fieldId) ;  
				  %>				  		      
				  </td>
				</tr>				
				<tr>
				  <td class="FieldLabel"><label for="actionName"><%=_ctx.appRes("SendMail.dialog.label.name")%></label></td>
				  <td class="FieldComponent">				  
				  <% 
						String[] fieldName = ["jcrPath=/node/exo:name", "validate=empty,XSSValidator"];
						uicomponent.addTextField("actionName", _ctx.appRes("SendMail.dialog.label.name"), fieldName);
				  %>
				  </td>
				</tr>				
				<tr>
				  <td class="FieldLabel"><label for="lifecycle"><%=_ctx.appRes("SendMail.dialog.label.lifecycle")%></label></td>
				  <td class="FieldComponent">				  
				  <% 
						String[] fieldLifecycle = ["jcrPath=/node/exo:lifecyclePhase", 
						                           "options=read,schedule,node_added,node_removed,property_added,property_removed,property_changed",
						                           "multiValues=true", "onchange=true","size=5","validate=empty"] ;
						uicomponent.addSelectBoxField("lifecycle", fieldLifecycle) ;
				  %>				  
				  </td>
				</tr>
								
				<%
					def selectValue = uicomponent.getSelectBoxFieldValue("lifecycle") ;					
					if(selectValue != null) {		
						if(selectValue.contains("schedule")) { 
				%>		<tr>
							  <td class="FieldLabel"><label for="scheduleType"><%=_ctx.appRes("SendMail.dialog.label.schedule-type")%></label></td>	          					
							  <td class="FieldComponent">	
							  <% 
									String[] fieldScheduleType = ["jcrPath=/node/exo:scheduleType", "options=cron,period", "onchange=true"] ;
									uicomponent.addSelectBoxField("scheduleType", fieldScheduleType) ;
							  %>
							  </td>
							</tr>
						<%
							String ScheduleType = uicomponent.getSelectBoxFieldValue("scheduleType") ;
							if(ScheduleType.equals("period")) {%>
								<tr>  					
								  <td class="FieldLabel"><label for="startTime"><%=_ctx.appRes("SendMail.dialog.label.start-time")%></label></td>
								  <td class="FieldComponent">	
								  <% 
										String[] fieldStartTime = ["jcrPath=/node/exo:startTime", "options=displaytime", "validate=datetime", "visible=true"];
										uicomponent.addCalendarField("startTime", fieldStartTime) ;
								  %>
								  </td>
								</tr>								
								<tr>		          					
								  <td class="FieldLabel"><label for="endTime"><%=_ctx.appRes("SendMail.dialog.label.end-time")%></label></td>
								  <td class="FieldComponent">	
								  <% 
								  	String[] fieldEndTime = ["jcrPath=/node/exo:endTime", "options=displaytime", "validate=datetime", "visible=true"];
										uicomponent.addCalendarField("endTime", fieldEndTime) ;
								  %>
								  </td>
								</tr>								
								<tr>		          					
								  <td class="FieldLabel"><label for="repeatCount"><%=_ctx.appRes("SendMail.dialog.label.repeat-count")%></label></td>
								  <td class="FieldComponent">	
								  <% 
										String[] fieldRepeatCount= ["jcrPath=/node/exo:repeatCount", "-1", "validate=repeatCountValidator"] ;
										uicomponent.addTextField("repeatCount", fieldRepeatCount) ;
								  %>
								  </td>
								</tr>
								<tr>		          					
								  <td class="FieldLabel"><label for="timeInterval"><%=_ctx.appRes("SendMail.dialog.label.time-inteval")%></label></td>
								  <td class="FieldComponent">	
								  <% 
										String[] fieldTimeInterval = ["jcrPath=/node/exo:timeInterval", "1", "validate=repeatIntervalValidator"] ;
										uicomponent.addTextField("timeInterval", fieldTimeInterval) ;
								  %>
								  </td>
								</tr>
								<% uicomponent.removeChildById("cronExpression") ; %>
						<%} else {%>
								<tr>		          					
								  <td class="FieldLabel"><label for="cronExpression"><%=_ctx.appRes("SendMail.dialog.label.cron-expression")%></label></td>
								  <td class="FieldComponent">	
								  <% 
										String[] fieldCronExpression = ["jcrPath=/node/exo:cronExpression","validate=cronExpressionValidator"] ;
										uicomponent.addTextField("cronExpression", fieldCronExpression) ;
								  %>
								  </td>
								</tr>
								<% 
								  uicomponent.removeChildById("startTime") ; 
								  uicomponent.removeChildById("endTime") ; 
								  uicomponent.removeChildById("repeatCount") ; 
								  uicomponent.removeChildById("timeInterval") ; 
								%>
			 <%			}	
					  } else {
					    uicomponent.removeChildById("startTime") ; 
						  uicomponent.removeChildById("endTime") ; 
						  uicomponent.removeChildById("repeatCount") ; 
						  uicomponent.removeChildById("timeInterval") ;
						  uicomponent.removeChildById("cronExpression") ;
					  }
				  }
			 %>	
			<tr>		          					
			  <td class="FieldLabel"><label for="isDeep"><%=_ctx.appRes("SendMail.dialog.label.isDeep")%></label></td>
			  <td class="FieldComponent">	
			  <% 
					String[] fieldDeep = ["jcrPath=/node/exo:isDeep", "defaultValues=true"];         
					uicomponent.addCheckBoxField("isDeep", fieldDeep);
			  %>
			  </td>
			</tr>
			<tr>		          					
  			<td class="FieldLabel"><label for="nodetypes"><%=_ctx.appRes("SendMail.dialog.label.nodetypes")%></label></td>
  			<td class="FieldComponent">	
  			<% 
    			String[] fieldnodetypes = ["jcrPath=/node/exo:nodeTypeName", "selectorAction=selectNodeTypes", "multiValues=true", "selectorClass=org.exoplatform.ecm.webui.nodetype.selector.UINodeTypeSelector", "selectorIcon=SelectPath24x24Icon", "validate=empty", "editable=false"];         
    			uicomponent.addActionField("nodetypes", fieldnodetypes);
  			%>
  			</td>
			</tr>
			<tr>		          					
			<td class="FieldLabel"><label for="description"><%=_ctx.appRes("SendMail.dialog.label.description")%></label></td>
			<td class="FieldComponent">	
			<% 
			String[] fieldDescription = ["jcrPath=/node/exo:description"];         
			uicomponent.addTextAreaField("description", fieldDescription);
			%>
			</td>
			</tr>
      <tr>                       
  			<td class="FieldLabel"><label for="affectedNodetypes"><%=_ctx.appRes("SendMail.dialog.label.affectedNodeTypeNames")%></label></td>
        <td class="FieldComponent">
        <% 
          String[] fieldAffectedNodetypes = ["jcrPath=/node/exo:affectedNodeTypeNames", "selectorAction=selectAffectedNodeTypes", "multiValues=true", "selectorClass=org.exoplatform.ecm.webui.nodetype.selector.UINodeTypeSelector", "selectorIcon=SelectPath24x24Icon", "validate=empty", "editable=false"];
          uicomponent.addActionField("affectedNodetypes", fieldAffectedNodetypes);
        %>
      </tr>		          					
			<tr>		          					
			  <td class="FieldLabel"><label for="to"><%=_ctx.appRes("SendMail.dialog.label.mail-to")%></label></td>
			  <td class="FieldComponent">
			  <% 
					String[] fieldMailTo = ["jcrPath=/node/exo:to", "validate=empty,email"];
					uicomponent.addTextField("to", fieldMailTo) ;
			  %>
			  </td>
			</tr>		
	</table>	
	<%/* start render action*/%>
	<%uiform.processRenderAction()%>
	<%/* end render action*/%>
  </div>
  <%uiform.end()%>
</div>