PageRenderTime 53ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/portal-web/docroot/html/taglib/ui/search_iterator/lexicon/list.jsp

https://github.com/ambrinchaudhary/liferay-portal
JavaServer Pages | 382 lines | 273 code | 96 blank | 13 comment | 52 complexity | e1c6befc4ca0cc4fa02afab3df94e833 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <%--
  2. /**
  3. * Copyright (c) 2000-present 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="/html/taglib/ui/search_iterator/init.jsp" %>
  17. <%@ include file="/html/taglib/ui/search_iterator/lexicon/top.jspf" %>
  18. <%
  19. if (searchResultCssClass == null) {
  20. searchResultCssClass = "show-quick-actions-on-hover table table-autofit table-heading-nowrap table-list";
  21. }
  22. List<ResultRowSplitterEntry> resultRowSplitterEntries = new ArrayList<ResultRowSplitterEntry>();
  23. if (resultRowSplitter != null) {
  24. resultRowSplitterEntries = resultRowSplitter.split(searchContainer.getResultRows());
  25. }
  26. else if (!resultRows.isEmpty()) {
  27. resultRowSplitterEntries.add(new ResultRowSplitterEntry(StringPool.BLANK, resultRows));
  28. }
  29. List<com.liferay.portal.kernel.dao.search.ResultRow> firstResultRows = Collections.emptyList();
  30. if (!resultRowSplitterEntries.isEmpty()) {
  31. ResultRowSplitterEntry firstResultRowSplitterEntry = resultRowSplitterEntries.get(0);
  32. firstResultRows = firstResultRowSplitterEntry.getResultRows();
  33. }
  34. if (fixedHeader) {
  35. searchResultCssClass += " lfr-search-iterator-fixed-header-table";
  36. }
  37. %>
  38. <div class="table-responsive">
  39. <table class="<%= searchResultCssClass %>">
  40. <c:if test="<%= Validator.isNotNull(summary) %>">
  41. <caption class="sr-only"><%= summary %></caption>
  42. </c:if>
  43. <c:if test="<%= ListUtil.isNotNull(headerNames) %>">
  44. <liferay-util:buffer
  45. var="theadContent"
  46. >
  47. <%
  48. List entries = Collections.emptyList();
  49. if (!firstResultRows.isEmpty()) {
  50. com.liferay.portal.kernel.dao.search.ResultRow row = firstResultRows.get(0);
  51. entries = row.getEntries();
  52. }
  53. for (int i = 0; i < headerNames.size(); i++) {
  54. String cssClass = StringPool.BLANK;
  55. String headerName = headerNames.get(i);
  56. String normalizedHeaderName = null;
  57. if (i < normalizedHeaderNames.size()) {
  58. normalizedHeaderName = normalizedHeaderNames.get(i);
  59. }
  60. if (Validator.isNotNull(normalizedHeaderName)) {
  61. cssClass = (normalizedHeaderName.equals("rowChecker")) ? "lfr-checkbox-column" : "lfr-" + normalizedHeaderName + "-column";
  62. }
  63. else {
  64. normalizedHeaderName = String.valueOf(i + 1);
  65. cssClass = "lfr-entry-action-column";
  66. }
  67. boolean truncate = false;
  68. if (!entries.isEmpty()) {
  69. if (rowChecker != null) {
  70. if (i != 0) {
  71. com.liferay.portal.kernel.dao.search.SearchEntry entry = (com.liferay.portal.kernel.dao.search.SearchEntry)entries.get(i - 1);
  72. if (entry != null) {
  73. cssClass += " " + entry.getCssClass();
  74. if (entry.isTruncate()) {
  75. truncate = true;
  76. cssClass += " table-cell-content";
  77. }
  78. if (!Validator.isBlank(entry.getAlign())) {
  79. cssClass += " text-" + entry.getAlign();
  80. }
  81. if (!Validator.isBlank(entry.getValign())) {
  82. cssClass += " text-" + entry.getValign();
  83. }
  84. }
  85. }
  86. }
  87. else {
  88. com.liferay.portal.kernel.dao.search.SearchEntry entry = (com.liferay.portal.kernel.dao.search.SearchEntry)entries.get(i);
  89. if (entry != null) {
  90. cssClass += " " + entry.getCssClass();
  91. if (entry.isTruncate()) {
  92. truncate = true;
  93. cssClass += " table-cell-content";
  94. }
  95. }
  96. }
  97. }
  98. %>
  99. <th class="<%= cssClass %>" id="<%= namespace + id %>_col-<%= normalizedHeaderName %>">
  100. <%
  101. String headerNameValue = null;
  102. if ((rowChecker == null) || (i > 0)) {
  103. headerNameValue = LanguageUtil.get(resourceBundle, HtmlUtil.escape(headerName));
  104. }
  105. else {
  106. headerNameValue = headerName;
  107. }
  108. if (Validator.isNull(headerNameValue)) {
  109. headerNameValue = StringPool.NBSP;
  110. }
  111. String helpMessage = null;
  112. if (helpMessages != null) {
  113. helpMessage = helpMessages.get(headerName);
  114. }
  115. %>
  116. <c:choose>
  117. <c:when test="<%= (rowChecker != null) && (i == 0) %>">
  118. <span class="sr-only">
  119. <%= LanguageUtil.get(request, "selected-item") %>
  120. </span>
  121. </c:when>
  122. <c:when test="<%= truncate %>">
  123. <span class="text-truncate">
  124. <%= headerNameValue %>
  125. <c:if test="<%= Validator.isNotNull(helpMessage) %>">
  126. <liferay-ui:icon-help message="<%= helpMessage %>" />
  127. </c:if>
  128. </span>
  129. </c:when>
  130. <c:otherwise>
  131. <%= headerNameValue %>
  132. <c:if test="<%= Validator.isNotNull(helpMessage) %>">
  133. <liferay-ui:icon-help message="<%= helpMessage %>" />
  134. </c:if>
  135. </c:otherwise>
  136. </c:choose>
  137. </th>
  138. <%
  139. }
  140. %>
  141. </liferay-util:buffer>
  142. <thead>
  143. <tr>
  144. <%= theadContent %>
  145. </tr>
  146. <c:if test="<%= fixedHeader %>">
  147. <tr aria-hidden="true" class="hide lfr-search-iterator-fixed-header" id="<%= namespace + id %>fixedHeader">
  148. <th>
  149. <div class="lfr-search-iterator-fixed-header-inner-wrapper">
  150. <table>
  151. <thead>
  152. <tr>
  153. <%= theadContent %>
  154. </tr>
  155. </thead>
  156. </table>
  157. </div>
  158. </th>
  159. </tr>
  160. </c:if>
  161. </thead>
  162. </c:if>
  163. <tbody>
  164. <%
  165. for (ResultRowSplitterEntry resultRowSplitterEntry : resultRowSplitterEntries) {
  166. List<com.liferay.portal.kernel.dao.search.ResultRow> curResultRows = resultRowSplitterEntry.getResultRows();
  167. %>
  168. <c:if test="<%= Validator.isNotNull(resultRowSplitterEntry.getTitle()) %>">
  169. <tr class="table-divider">
  170. <td colspan="<%= (headerNames != null) ? headerNames.size() : StringPool.BLANK %>">
  171. <liferay-ui:message key="<%= resultRowSplitterEntry.getTitle() %>" />
  172. </td>
  173. </tr>
  174. </c:if>
  175. <%
  176. boolean allRowsIsChecked = true;
  177. for (int i = 0; i < curResultRows.size(); i++) {
  178. com.liferay.portal.kernel.dao.search.ResultRow row = curResultRows.get(i);
  179. primaryKeysJSONArray.put(row.getPrimaryKey());
  180. request.setAttribute(WebKeys.SEARCH_CONTAINER_RESULT_ROW, row);
  181. List entries = row.getEntries();
  182. boolean rowIsChecked = false;
  183. boolean rowIsDisabled = false;
  184. if (rowChecker != null) {
  185. rowIsChecked = rowChecker.isChecked(row.getObject());
  186. rowIsDisabled = rowChecker.isDisabled(row.getObject());
  187. if (!rowIsChecked) {
  188. allRowsIsChecked = false;
  189. }
  190. TextSearchEntry textSearchEntry = new TextSearchEntry();
  191. textSearchEntry.setAlign(rowChecker.getAlign());
  192. textSearchEntry.setColspan(rowChecker.getColspan());
  193. textSearchEntry.setCssClass(rowChecker.getCssClass());
  194. textSearchEntry.setName(rowChecker.getRowCheckBox(request, row));
  195. textSearchEntry.setValign(rowChecker.getValign());
  196. row.addSearchEntry(0, textSearchEntry);
  197. String rowSelector = rowChecker.getRowSelector();
  198. if (Validator.isNull(rowSelector)) {
  199. Map<String, Object> rowData = row.getData();
  200. if (rowData == null) {
  201. rowData = new HashMap<String, Object>();
  202. }
  203. rowData.put("selectable", !rowIsDisabled);
  204. row.setData(rowData);
  205. }
  206. }
  207. request.setAttribute("liferay-ui:search-container-row:rowId", id.concat(StringPool.UNDERLINE.concat(row.getRowId())));
  208. Map<String, Object> data = row.getData();
  209. if (data == null) {
  210. data = new HashMap<String, Object>();
  211. }
  212. %>
  213. <tr class="<%= GetterUtil.getString(row.getClassName()) %> <%= row.getCssClass() %> <%= row.getState() %> <%= rowIsChecked ? "active" : StringPool.BLANK %>" data-qa-id="row" <%= AUIUtil.buildData(data) %>>
  214. <%
  215. for (int j = 0; j < entries.size(); j++) {
  216. com.liferay.portal.kernel.dao.search.SearchEntry entry = (com.liferay.portal.kernel.dao.search.SearchEntry)entries.get(j);
  217. entry.setIndex(j);
  218. request.setAttribute(WebKeys.SEARCH_CONTAINER_RESULT_ROW_ENTRY, entry);
  219. boolean truncate = false;
  220. String columnClassName = entry.getCssClass();
  221. if (!Validator.isBlank(entry.getAlign())) {
  222. columnClassName += " text-" + entry.getAlign();
  223. }
  224. if (!Validator.isBlank(entry.getValign())) {
  225. columnClassName += " text-" + entry.getValign();
  226. }
  227. if (entry.isTruncate()) {
  228. truncate = true;
  229. columnClassName += " table-cell-content";
  230. }
  231. String normalizedColumnName = null;
  232. if (j < normalizedHeaderNames.size()) {
  233. normalizedColumnName = normalizedHeaderNames.get(j);
  234. if (!Validator.isBlank(normalizedColumnName)) {
  235. columnClassName += (normalizedColumnName.equals("rowChecker")) ? " lfr-checkbox-column" : " lfr-" + normalizedColumnName + "-column";
  236. }
  237. }
  238. if (Validator.isNull(normalizedColumnName)) {
  239. columnClassName += " lfr-entry-action-column";
  240. }
  241. %>
  242. <td class="<%= columnClassName %>" colspan="<%= entry.getColspan() %>">
  243. <c:choose>
  244. <c:when test="<%= truncate %>">
  245. <span class="text-truncate">
  246. <%
  247. entry.print(pageContext.getOut(), request, response);
  248. %>
  249. </span>
  250. </c:when>
  251. <c:otherwise>
  252. <%
  253. entry.print(pageContext.getOut(), request, response);
  254. %>
  255. </c:otherwise>
  256. </c:choose>
  257. </td>
  258. <%
  259. }
  260. %>
  261. </tr>
  262. <%
  263. request.removeAttribute(WebKeys.SEARCH_CONTAINER_RESULT_ROW);
  264. request.removeAttribute(WebKeys.SEARCH_CONTAINER_RESULT_ROW_ENTRY);
  265. request.removeAttribute("liferay-ui:search-container-row:rowId");
  266. }
  267. }
  268. %>
  269. <c:if test="<%= headerNames != null %>">
  270. <tr class="lfr-template">
  271. <%
  272. for (int i = 0; i < headerNames.size(); i++) {
  273. %>
  274. <td></td>
  275. <%
  276. }
  277. %>
  278. </tr>
  279. </c:if>
  280. </tbody>
  281. </table>
  282. </div>
  283. <%
  284. String rowHtmlTag = "tr";
  285. %>
  286. <%@ include file="/html/taglib/ui/search_iterator/lexicon/bottom.jspf" %>