PageRenderTime 25ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/portlets/tasks-portlet/docroot/edit_task.jsp

https://github.com/l15k4/liferay-plugins
JavaServer Pages | 281 lines | 212 code | 56 blank | 13 comment | 22 complexity | 8873a542193c6e3aea2a3a84daee9934 MD5 | raw file
  1. <%--
  2. /**
  3. * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
  4. *
  5. * This library is free software; you can redistribute it and/or modify it under
  6. * the terms of the GNU Lesser General Public License as published by the Free
  7. * Software Foundation; either version 2.1 of the License, or (at your option)
  8. * any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12. * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  13. * details.
  14. */
  15. --%>
  16. <%@ include file="/init.jsp" %>
  17. <%
  18. String tabs1 = ParamUtil.getString(request, "tabs1", tabs1Default);
  19. String tabs2 = ParamUtil.getString(request, "tabs2", "open");
  20. long tasksEntryId = ParamUtil.getLong(request, "tasksEntryId");
  21. TasksEntry tasksEntry = null;
  22. try {
  23. tasksEntry = TasksEntryLocalServiceUtil.getTasksEntry(tasksEntryId);
  24. }
  25. catch (NoSuchTasksEntryException nstee) {
  26. }
  27. long priority = BeanParamUtil.getLong(tasksEntry, request, "priority", TasksEntryConstants.PRIORITY_NORMAL);
  28. long assigneeUserId = BeanParamUtil.getLong(tasksEntry, request, "assigneeUserId");
  29. Calendar dueDate = CalendarFactoryUtil.getCalendar(timeZone, locale);
  30. boolean neverDue = true;
  31. if (tasksEntry != null) {
  32. if (tasksEntry.getDueDate() != null) {
  33. dueDate.setTime(tasksEntry.getDueDate());
  34. neverDue = false;
  35. }
  36. }
  37. int status = BeanParamUtil.getInteger(tasksEntry, request, "status", TasksEntryConstants.STATUS_ALL);
  38. long javaScriptLastModified = ServletContextUtil.getLastModified(application, "/html/js/", true);
  39. %>
  40. <script src="<%= HtmlUtil.escape(PortalUtil.getStaticResourceURL(request, themeDisplay.getPathJavaScript() + "/liferay/service.js", javaScriptLastModified)) %>" type="text/javascript"></script>
  41. <form action="<portlet:actionURL name="updateTasksEntry" />" method="post" name="<portlet:namespace />fm1">
  42. <input name="<portlet:namespace />tasksEntryId" type="hidden" value="<%= tasksEntryId %>" />
  43. <input name="<portlet:namespace />userId" type="hidden" value="<%= user.getUserId() %>" />
  44. <input name="<portlet:namespace />resolverUserId" type="hidden" value="<%= user.getUserId() %>" />
  45. <liferay-ui:header title='<%= (tasksEntry == null) ? "add-task" : "update-task" %>' />
  46. <table class="lfr-table">
  47. <tr>
  48. <td class="lfr-label">
  49. <liferay-ui:message key="description" />
  50. </td>
  51. <td>
  52. <liferay-ui:input-field model="<%= TasksEntry.class %>" bean="<%= tasksEntry %>" field="title" />
  53. </td>
  54. </tr>
  55. <tr>
  56. <td colspan="2">
  57. <br />
  58. </td>
  59. </tr>
  60. <tr>
  61. <td class="lfr-label">
  62. <liferay-ui:message key="assignee" />
  63. </td>
  64. <td>
  65. <select name="<portlet:namespace />assigneeUserId">
  66. <c:choose>
  67. <c:when test="<%= group.isUser() %>">
  68. <option <%= (assigneeUserId == user.getUserId()) ? "selected" : StringPool.BLANK %> value="<%= user.getUserId() %>"><%= HtmlUtil.escape(user.getFullName()) %></option>
  69. <optgroup label="<liferay-ui:message key="contacts" />">
  70. </c:when>
  71. <c:otherwise>
  72. <option <%= (assigneeUserId == 0) ? "selected" : StringPool.BLANK %> value="0"></option>
  73. <option <%= (assigneeUserId == user.getUserId()) ? "selected" : StringPool.BLANK %> value="<%= user.getUserId() %>"><%= HtmlUtil.escape(user.getFullName()) %></option>
  74. <c:if test="<%= (tasksEntry != null) && (assigneeUserId > 0) && (assigneeUserId != user.getUserId()) %>">
  75. <option selected value="<%= assigneeUserId %>"><%= PortalUtil.getUserName(assigneeUserId, tasksEntry.getAssigneeFullName()) %></option>
  76. </c:if>
  77. <optgroup label="<liferay-ui:message key="members" />">
  78. </c:otherwise>
  79. </c:choose>
  80. <%
  81. List<User> users = null;
  82. if (group.isUser()) {
  83. users = UserLocalServiceUtil.getSocialUsers(group.getClassPK(), QueryUtil.ALL_POS, QueryUtil.ALL_POS, new ContactFirstNameComparator(true));
  84. }
  85. else {
  86. LinkedHashMap userParams = new LinkedHashMap();
  87. userParams.put("usersGroups", new Long(themeDisplay.getScopeGroupId()));
  88. users = UserLocalServiceUtil.search(company.getCompanyId(), StringPool.BLANK, WorkflowConstants.STATUS_APPROVED, userParams, QueryUtil.ALL_POS, QueryUtil.ALL_POS, new ContactFirstNameComparator(true));
  89. }
  90. long defaultUserId = themeDisplay.getDefaultUserId();
  91. for (User curUser : users) {
  92. long curUserId = curUser.getUserId();
  93. if ((curUserId == user.getUserId()) || (assigneeUserId == curUserId)) {
  94. continue;
  95. }
  96. %>
  97. <option <%= (assigneeUserId == curUserId) ? "selected" : StringPool.BLANK %> value="<%= curUserId %>"><%= HtmlUtil.escape(curUser.getFullName()) %></option>
  98. <%
  99. }
  100. %>
  101. </optgroup>
  102. </select>
  103. </td>
  104. </tr>
  105. <tr>
  106. <td class="lfr-label">
  107. <liferay-ui:message key="priority" />
  108. </td>
  109. <td>
  110. <select name="<portlet:namespace />priority">
  111. <option value="1" <%= (priority == 1) ? "selected" : StringPool.BLANK %>><liferay-ui:message key="high" /></option>
  112. <option value="2" <%= (priority == 2) ? "selected" : StringPool.BLANK %>><liferay-ui:message key="normal" /></option>
  113. <option value="3" <%= (priority == 3) ? "selected" : StringPool.BLANK %>><liferay-ui:message key="low" /></option>
  114. </select>
  115. </td>
  116. </tr>
  117. <tr>
  118. <td colspan="2">
  119. <br />
  120. </td>
  121. </tr>
  122. <tr>
  123. <td class="lfr-label">
  124. <liferay-ui:message key="due-date" />
  125. </td>
  126. <td>
  127. <liferay-ui:input-field model="<%= TasksEntry.class %>" bean="<%= tasksEntry %>" field="dueDate" defaultValue="<%= dueDate %>" disabled="<%= neverDue %>" />
  128. <div style="clear: both;">
  129. <%
  130. String taglibNeverReviewOnClick = renderResponse.getNamespace() + "disableInputDate('dueDate', this.checked);";
  131. %>
  132. <aui:input inlineLabel="left" label="never-due" name="neverDue" value="<%= neverDue %>" onClick="<%= taglibNeverReviewOnClick %>" type="checkbox" />
  133. </div>
  134. </td>
  135. </tr>
  136. <c:if test="<%= tasksEntry != null %>">
  137. <tr>
  138. <td colspan="2">
  139. <br />
  140. </td>
  141. </tr>
  142. <tr>
  143. <td class="lfr-label">
  144. <liferay-ui:message key="status" />
  145. </td>
  146. <td>
  147. <select name="<portlet:namespace />status">
  148. <%
  149. for (int curStatus : TasksEntryConstants.STATUSES) {
  150. %>
  151. <option value="<%= curStatus %>" <%= (status == curStatus) ? "selected" : StringPool.BLANK %>><liferay-ui:message key="<%= TasksEntryConstants.getStatusLabel(curStatus) %>" /></option>
  152. <%
  153. }
  154. %>
  155. </select>
  156. </td>
  157. </tr>
  158. </c:if>
  159. <tr>
  160. <td colspan="2">
  161. <br />
  162. </td>
  163. </tr>
  164. <tr>
  165. <td class="lfr-label">
  166. <liferay-ui:message key="tags" />
  167. </td>
  168. <td>
  169. <%
  170. long classPK = 0;
  171. if (tasksEntry != null) {
  172. classPK = tasksEntry.getTasksEntryId();
  173. }
  174. %>
  175. <liferay-ui:asset-tags-selector
  176. className="<%= TasksEntry.class.getName() %>"
  177. classPK="<%= classPK %>"
  178. contentCallback='<%= renderResponse.getNamespace() + "getSuggestionsContent" %>'
  179. />
  180. </td>
  181. </tr>
  182. </table>
  183. <div class="task-action">
  184. <input id="<portlet:namespace />submit" type="submit" value="<liferay-ui:message key="save" />" />
  185. <c:if test="<%= tasksEntryId > 0 %>">
  186. <input type="button" value="<liferay-ui:message key="cancel" />" onClick="Liferay.Tasks.openTask('<portlet:renderURL windowState="<%= LiferayWindowState.EXCLUSIVE.toString() %>"><portlet:param name="jspPage" value="/view_task.jsp" /><portlet:param name="tasksEntryId" value="<%= String.valueOf(tasksEntry.getTasksEntryId()) %>" /></portlet:renderURL>');" />
  187. </c:if>
  188. <div class="task-action-right">
  189. <input type="button" value="<liferay-ui:message key="close" />" onClick="Liferay.Tasks.closePopup();" />
  190. </div>
  191. </div>
  192. </form>
  193. <aui:script>
  194. function <portlet:namespace />getSuggestionsContent() {
  195. var content = document.<portlet:namespace />fm1.<portlet:namespace/>title.value;
  196. return content;
  197. }
  198. function <portlet:namespace />disableInputDate(date, checked) {
  199. eval("document.<portlet:namespace />fm1.<portlet:namespace />" + date + "Month.disabled = " + checked + ";");
  200. eval("document.<portlet:namespace />fm1.<portlet:namespace />" + date + "Day.disabled = " + checked + ";");
  201. eval("document.<portlet:namespace />fm1.<portlet:namespace />" + date + "Year.disabled = " + checked + ";");
  202. eval("document.<portlet:namespace />fm1.<portlet:namespace />" + date + "Hour.disabled = " + checked + ";");
  203. eval("document.<portlet:namespace />fm1.<portlet:namespace />" + date + "Minute.disabled = " + checked + ";");
  204. eval("document.<portlet:namespace />fm1.<portlet:namespace />" + date + "AmPm.disabled = " + checked + ";");
  205. }
  206. </aui:script>
  207. <aui:script use="aui-base">
  208. form = A.one(document.<portlet:namespace />fm1);
  209. form.on(
  210. 'submit',
  211. function(event) {
  212. event.preventDefault();
  213. var popup = Liferay.Tasks.getPopup();
  214. popup.io.set('form', {id: form.getDOM()});
  215. popup.io.set('uri', form.getAttribute('action'));
  216. popup.io.once(
  217. 'success',
  218. function() {
  219. Liferay.Tasks.updateTaskList();
  220. }
  221. );
  222. popup.io.start();
  223. }
  224. );
  225. </aui:script>