<%
	import org.exoplatform.faq.service.Watch ;
%>

<div class="UIWatchManager $uicomponent.id" style="padding:8px;">
		<% uiform.begin() %>
		<div class="UIForm">
 			<div class="UIHorizontalLayout">
 				<div class="UIPermissionManager">
 					<div class="UIPermissionInfo">
 						<table class="UIGrid">
 							<thead>
 								<tr>
	 								<th><%= _ctx.appRes("UIWatchManager.label.user"); %></th>
	 								<th><%= _ctx.appRes("UIWatchManager.label.email"); %></th>
	 								<th style="width:85px;"><%= _ctx.appRes("UIWatchManager.label.action"); %></th>
 								</tr>
 							</thead>
 							<tbody>
 							<% 
	 							String categoryId = uicomponent.getCategoryID() ;
	 							List watchs = uicomponent.getListWatch() ;
	 							String user = "";
	 							String email = "";
	 							String total = "";
	 							String linkDelete = "";
	 							String linkEdit = "";
	 							if(watchs.size() > 0){
	 								for(Watch watch : watchs ) {
	 									user = watch.getUser() ;
	 									email = watch.getEmails() ;
	 									total = user + " (" + email + ")" ;
 										linkEdit = uicomponent.event("EditEmail", user);
 										linkDelete = uicomponent.event("DeleteEmail", "$uicomponent.id", user);
	 							 %>
		 								<tr>
		 									<td valign="top" align="left">$user</td>
		 									<td valign="top" align="left">
		 										<% 
		 										for(String str : email.split(",")){%>
		 											<div style="margin-bottom:3px;">$str</div>
		 									<%}
		 										%>
		 									</td>
		 									<td align="center" valign="top">
		 										<%		 										
						 							String linkCurrent = uicomponent.event("OpenCategory", categoryId)
						 						%>
		 										<div onclick="$linkCurrent" title="<%= _ctx.appRes("UIWatchManager.title.link"); %>" style="float:left; cursor:pointer;">
		 											<div class="LinkWatchIcon"><span></span></div>
		 										</div>		 										
		 										<div onclick="$linkEdit" title="<%= _ctx.appRes("UIWatchManager.title.edit-watch"); %>" style="float:left; cursor:pointer;">
		 											<div class="EditWatchIcon"><span></span></div>
		 										</div>
		 										<div onclick="$linkDelete" title="<%= _ctx.appRes("UIWatchManager.title.delete-watch"); %>" style="float:left; cursor:pointer;">
		 											<div class="DeleteWatchIcon"><span></span></div>
		 										</div>
		 									</td>
		 								</tr>
	 								<% 
	 									}
	 								} else {
	 									   %>
		 							<tr class="EvenRow">
										<td class="Tdbox" colspan="3" align="center"><%= _ctx.appRes("UIWatchManager.title.no-matches"); %></td>
		  						</tr>
								<%}%>
 							</tbody>
 						</table>
 						<% 
 							long totalPages = uicomponent.getTotalpages("LIST_EMAILS_WATCH") ;
					    if(totalPages > 1) {
					   %>
 							<div style="overflow:auto;">
								<% uicomponent.renderChild(uicomponent.LIST_EMAILS_WATCH) ; %>
								<div style="clear:both;"><span></span></div>
							</div>
					<% } %>
 					</div>
 				</div>
 			</div>
 		</div>
		 <div class="UIAction">
      <a href="javascript:void(0);" onclick="<%=uicomponent.event("Cancel");%>" class="ActionButton LightBlueStyle"><%=_ctx.appRes("UIAnswersPortlet.action.Close");%></a>
      <a href="javascript:void(0);" onclick="<%=uicomponent.event("EditEmail", uicomponent.ADD);%>" class="ActionButton LightBlueStyle"><%=_ctx.appRes("UIWatchManager.title.add-watch");%></a>
    </div>
		<%uiform.end()%>
</div>