home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2003 July
/
CMCD0703.ISO
/
Software
/
Freeware
/
Programare
/
bugzero
/
jsp
/
_issueform.jspf
< prev
next >
Wrap
Text File
|
2003-06-09
|
11KB
|
259 lines
<%
String projectId = person.getProject();
String title = null;
String description = null;
String requiredMark = "<font color=red>*</font>";
Issue issue = null;
if (issueId > 0) { //edit.jsp
title = label.get("view_edit", projectId);
description = new StringBuffer()
.append(label.get("issue_response", projectId))
.append(requiredMark)
.append("<font size =-1>")
.append("<br>")
.append(label.get("issue_response_detail", projectId))
.append("</font>").toString();
try {
issue = Issue.load(projectId, issueId);
} catch (Exception e) {
out.print("<center><font color=red><b>");
out.print(e.getMessage());
out.print("</b></font></center>");
return;
}
} else { //create.jsp
title = label.get("create_new", projectId);
description = new StringBuffer()
.append(label.get("issue_description", projectId))
.append(requiredMark)
.append("<font size =-1>")
.append("<br>")
.append(label.get("issue_description_detail", projectId))
.append("</font>").toString();
}
String formId = request.getParameter("formId");
IssueForm issueForm = null;
if (formId == null) {
formId = IdGenerator.getId();
if (issue != null) {
issueForm = new IssueForm(issue); //edit.jsp
// the issueForm below is for the original issue, need a different instance.
session.setAttribute("issue"+issueId, new IssueForm(issue));
} else {
issueForm = new IssueForm(projectId); //create.jsp
}
session.setAttribute("issueForm"+formId, issueForm);
} else {
issueForm = (IssueForm)session.getAttribute("issueForm"+formId);
}
if (issueForm == null) {
out.print("<center><font color=red><b>");
out.print(MessageCode.get("servlet.issue.state_invalid"));
out.print("</b></font></center>");
return;
}
Project conf = Project.getInstance(projectId);
String[] nextAllowed = null;
String forbiddenState = null;
if (issue != null) { //we need these only for edit.jsp
nextAllowed = conf.getWorkflow().nextAllowed(issue.get("state"), person.getGroup());
forbiddenState=issue.get("state");
for (int i=0; i<nextAllowed.length; i++) {
if (forbiddenState.equalsIgnoreCase(nextAllowed[i])) {
forbiddenState=null;
break;
}
}
}
String synopsis = issueForm.get("synopsis");
String project_area = issueForm.get("project_area");
String current_assigned = issueForm.get("responsible");
com.websina.util.Field field;
String[] optionList;
%>
<center>
<p>
<form method="POST" action="<%=contextPath%>/servlet/issue" name="issueForm"
onSubmit="if(action.value=='attachment') {
return true;
} else {
if(isEmpty(synopsis,'Please fill in the <%=label.getEscaped("synopsis", projectId)%> field'))return false;
<% if (issue != null) { %>
if(!assert(state.options[state.selectedIndex].value != '<%=forbiddenState%>','Please change the <%=label.getEscaped("state")%> appropriately'))return false;
<% } %>
if(!validEmailList(cc_mail))return false;
if(isEmpty(issue_description,'Please fill in the <%=label.getEscaped("issue_response", projectId)%> field'))return false;
}">
<input type="hidden" name="action">
<input type="hidden" name="formId" value="<%=formId%>">
<% if (issue != null) { %>
<input type="hidden" name="issue_id" value="<%=issueId%>">
<% if (current_assigned != null) { %>
<input type="hidden" name="current_assigned" value="<%=current_assigned%>">
<% } } %>
<table cellspacing=1 cellpadding=1 border=0>
<tr><td colspan=2>
<font size=+0><b><%=title%></b></font>
<% if (issue != null) { %>
(<%=label.get("issue_id", projectId)%> <font color=red><b><%=issueId%></b></font>)
<% } %>
</td></tr>
<tr><td colspan=2 bgcolor="#006688">
<font size=-1 color="#ffffff"><b><%=label.get("required_field_asterisks")%></b></font>
</td></tr>
<% if( (field=conf.getField("project_area")) != null && (optionList=field.getValue()) != null) { %>
<tr><td bgcolor="#e0e0e0"><%=label.get("project_area", projectId)%>
</td><td bgcolor="#efefef">
<select name=project_area>
<%=ListMaker.makeOptionList(optionList, project_area) %>
</select> </td></tr>
<% } %>
<% for (int i=1; i<=CUSTOM_FIELDS; i++) {
String fieldName = "field_"+i;
if( (field = conf.getField(fieldName)) != null && (optionList=field.getValue()) != null) { %>
<tr><td bgcolor="#e0e0e0"><%=label.get(fieldName, projectId)%>
</td><td bgcolor="#efefef">
<% if (field.isTextAreaField()) { %>
<textarea name="<%=fieldName%>" rows=4 cols=60 style="width: 100%;"><%=HtmlParser.escapeTag(issueForm.get(fieldName))%></textarea></td></tr>
<% } else if (field.isTextField()) { %>
<input name="<%=fieldName%>"
value="<%=HtmlParser.escapeQuotation(issueForm.get(fieldName))%>" size=80 maxlength=255></td></tr>
<% } else { %>
<select name=<%=fieldName%>>
<%=ListMaker.makeOptionList(optionList, issueForm.get(fieldName)) %>
</select> </td></tr>
<% }}} %>
<% if((optionList=conf.getField("issue_type").getValue()) != null) { %>
<tr><td bgcolor="#e0e0e0"><%=label.get("issue_type", projectId)%>
</td><td bgcolor="#efefef">
<select name=issue_type>
<%=ListMaker.makeOptionList(optionList, issueForm.get("issue_type")) %>
</select> </td></tr>
<% } %>
<% if (issue != null) { %>
<tr><td bgcolor="#e0e0e0"><%=label.get("state", projectId)%>
</td><td bgcolor="#efefef">
<select name=state>
<% if (nextAllowed.length==0) {%>
<option value="<%=issueForm.get("state")%>"><%=issueForm.get("state")%></option>
<% } else { %>
<%=ListMaker.makeOptionList(nextAllowed, issueForm.get("state")) %>
<% } %>
</select></td></tr>
<% } %>
<% if((optionList=conf.getField("severity").getValue()) != null) { %>
<tr><td bgcolor="#e0e0e0"><%=label.get("severity", projectId)%>
</td><td bgcolor="#efefef">
<select name=severity>
<%=ListMaker.makeOptionList(optionList, issueForm.get("severity")) %>
</select></td></tr>
<% } %>
<% if ( !Group.isGuest(person.getGroup()) ) { // this is for non-guest
// Users of group guest are not allowed to manually assign or re-assign
// priority/responsible by default.
// You can change this policy by editing this block of the code
if((optionList=conf.getField("priority").getValue()) != null) { %>
<tr><td bgcolor="#e0e0e0"><%=label.get("priority", projectId)%>
</td><td bgcolor="#efefef">
<select name=priority>
<%=ListMaker.makeOptionList(optionList, issueForm.get("priority")) %>
</select></td></tr>
<% } %>
<tr><td bgcolor="#e0e0e0"><%=label.get("responsible", projectId)%>
</td><td bgcolor="#efefef">
<select name=responsible>
<%=ListMaker.makeOptionList(conf.getAccess().getUsers("edit"), current_assigned) %>
</select></td></tr>
<% } else {
if((optionList=conf.getField("priority").getValue()) != null) {
if (issue != null) { %>
<tr><td bgcolor="#e0e0e0"><%=label.get("priority", projectId)%>
</td><td bgcolor="#efefef">
<select name=priority>
<option value="<%=issueForm.get("priority")%>" selected><%=issueForm.get("priority")%></option>
</select></td></tr>
<% } else { //create.jsp, add a hidden NA %>
<input type="hidden" name="priority" value="NA">
<% } }
if (issue != null) { //edit.jsp, show only the current responsible %>
<tr><td bgcolor="#e0e0e0"><%=label.get("responsible", projectId)%>
</td><td bgcolor="#efefef">
<select name=responsible>
<option value="<%=current_assigned%>" selected>
<%=conf.getAccess().getDisplay(current_assigned)%></option>
</select></td></tr>
<% } } //code block ends here %>
<tr>
<td bgcolor="#e0e0e0"><%=label.get("synopsis", projectId)%><%=requiredMark%></td>
<td bgcolor="#efefef"><input name="synopsis" value="<%=HtmlParser.escapeQuotation(synopsis)%>" size=80 maxlength=255>
</td></tr>
<tr>
<td bgcolor="#e0e0e0" valign=center width=120>
<%=description%>
</td>
<td bgcolor="#efefef">
<textarea name=issue_description rows=8 cols=60 style="width: 100%;"><%=HtmlParser.escapeTag(issueForm.get("issue_description"))%></textarea></td></tr>
<tr>
<td bgcolor="#e0e0e0"><%=label.get("attachment", projectId)%></td>
<td align=right width=500 bgcolor="#efefef">
<% Attachment attachment = issueForm.getAttachment();
if (attachment != null) {
String[] filenames = attachment.getFilenames();
if (filenames != null) {
for (int i=0; i<filenames.length; i++) {
if (i > 0) out.print(";");
out.print(filenames[i]);
}
}
}
%>
<input type="button" value="Attach Files" onClick="do_attachment(issueForm, <%=formId%>)"></td></tr>
<tr>
<% String cc_mail = issueForm.get("cc_mail");
// if you want the original submitter always get the email, uncomment the following block.
/*
if (issue != null) { // only for edit.jsp
String submitter_email = conf.getAccess().getEmail(issue.get("author"));
if (submitter_email != null) {
if (cc_mail == null) {
cc_mail = submitter_email;
} else if (cc_mail.indexOf(submitter_email)==-1) {
cc_mail = submitter_email+';'+cc_mail;
}
}
}
*/
%>
<td bgcolor="#e0e0e0"><%=label.get("cc_mail", projectId)%></td>
<td bgcolor="#efefef">
<input type=text size=80 maxlength=255 name=cc_mail value="<%=HtmlParser.escapeQuotation(cc_mail)%>"></td></tr>
<tr>
<td align=center colspan=2 height=32>
<% if (issue==null || nextAllowed.length > 0) {
String checked = "";
if (issueForm.get("no_email") != null) {
checked = "checked";
} %>
No email notification
<input type="checkbox" name="no_email" value="checked" <%=checked%>>
<input type=submit value="<%=label.get("submit_button", projectId)%>">
<input type=reset value="<%=label.get("reset_button")%>">
<% } else { %>
<font color=red><%=HtmlParser.escapeTag(MessageCode.get("jsp.no_allowed_state"))%></font>
<% } %>
</td></tr>
</table>
</form>
</center>