view src/main/webapp/methods/addSectionToTopic.jsp @ 62:824b808a7481

improvements and bug fixed
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 18 Jul 2016 17:35:32 +0200
parents b8ad346e39a0
children
line wrap: on
line source

<%@page import="de.mpiwg.gazetteer.bo.LGTopic"%>
<%@page import="de.mpiwg.gazetteer.db.DBSection"%>
<%@page import="de.mpiwg.gazetteer.utils.DBService"%>
<%@page import="de.mpiwg.gazetteer.utils.DataProvider"%>


<jsp:useBean id="sessionBean" class="de.mpiwg.web.jsp.SessionBean" scope="session" />
	
<%
	if (sessionBean == null || sessionBean.getUser() == null) { %>
		<form name="timeoutForm"
			action="<%=sessionBean.getApplicationBean().getRootServer()%>/proxy.jsp"
			method="post">
			<input name="bean" type="hidden" value="loginBean" />
			
			<h3>Timeout or Logout at another page! Please Login again.</h3>
			<input type="image" width="40" height="40"
					onclick="setAction('logout', 'timeoutForm');" 
					src="<%=sessionBean.getApplicationBean().getOkImage() %>"/>
		
		</form> 
<% } else if (sessionBean.getTopicListPage().getCompleteTopicList() == null) {
		sessionBean.getTopicListPage().loadParameters(request, response);
		sessionBean.getTopicListPage().reloadTopics();
	}
%>
		
		<form name="addSectionToTopicForm" id="addSectionToTopicForm"
				action="<%= sessionBean.getApplicationBean().getRootServer()%>/proxy.jsp"
				method="post">
				<input name="bean" type="hidden" value="topicBean" /> 
				<input name="sourceBean" type="hidden" value="<%=request.getParameter("sourceBean")%>" /> 
				
						
				<table class="dialogTable">
					<tr>
						<td><label style="font-weight: bold;">Topic Id</label></td>
						<td><label style="font-weight: bold;">Name</label></td>
					</tr>
					
					
					<% 
						Long userId = sessionBean.getUser().getId();
					
						for (LGTopic topic : sessionBean.getTopicListPage().getCompleteTopicList() ) {
							// should show only the topic that current user has access to (is the creator or in contributorList)
							if (Long.compare(topic.getUserId(), userId) == 0 || topic.getContributorsList().contains(userId) ) {
		
					%>
							<tr>	
								<td><%=topic.getId() %></td>
								<td>
									<%=topic.getNameEn() %>(<%=topic.getNameCh() %>)
								
									<% if(request.getParameter("sectionId") != null) {
										Long sectionId = Long.parseLong(request.getParameter("sectionId"));
									%>
										<!-- add section to selected topic -->
										<input name="selectedSectionId" type="hidden" value="<%=request.getParameter("sectionId") %>" />
			
										<input type="image"
												onclick="setAction0('addSection', 'addSectionToTopicForm', 'selectedTopicId', '<%=topic.getId() %>');"
												src="<%=sessionBean.getApplicationBean().getPlusImage() %>" width="20" height="20"/>
									
								 	<% } else if (request.getParameter("addAllSections") != null) { %>	
										<input type="image"
												onclick="setAction0('addAllSections', 'addSectionToTopicForm', 'selectedTopicId', '<%=topic.getId() %>');"
												src="<%=sessionBean.getApplicationBean().getPlusImage() %>" width="20" height="20"/>
										
									<% } %>	
				 								
								</td>						
							</tr>
						<% 
						} 
					}
					%>
				</table>
			
			</form>