PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/portal-web/docroot/html/portlet/expando/edit_expando.jsp

http://github.com/liferay/liferay-portal
JavaServer Pages | 294 lines | 228 code | 53 blank | 13 comment | 12 complexity | 364baf9015e1d3cda8f9baafdb7aca9e MD5 | raw file
Possible License(s): LGPL-2.0
  1. <%--
  2. /**
  3. * Copyright (c) 2000-2012 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/portlet/expando/init.jsp" %>
  17. <%
  18. String redirect = ParamUtil.getString(request, "redirect");
  19. String modelResource = ParamUtil.getString(request, "modelResource");
  20. String modelResourceName = ResourceActionsUtil.getModelResource(pageContext, modelResource);
  21. ExpandoColumn column = (ExpandoColumn)request.getAttribute(WebKeys.EXPANDO_COLUMN);
  22. long columnId = BeanParamUtil.getLong(column, request, "columnId");
  23. int type = BeanParamUtil.getInteger(column, request, "type");
  24. ExpandoBridge expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(company.getCompanyId(), modelResource);
  25. UnicodeProperties properties = new UnicodeProperties(true);
  26. Serializable defaultValue = null;
  27. if (column != null) {
  28. properties = expandoBridge.getAttributeProperties(column.getName());
  29. defaultValue = expandoBridge.getAttributeDefault(column.getName());
  30. }
  31. boolean propertyHidden = GetterUtil.getBoolean(properties.get(ExpandoColumnConstants.PROPERTY_HIDDEN));
  32. boolean propertyVisibleWithUpdatePermission = GetterUtil.getBoolean(properties.get(ExpandoColumnConstants.PROPERTY_VISIBLE_WITH_UPDATE_PERMISSION));
  33. int propertyIndexType = GetterUtil.getInteger(properties.get(ExpandoColumnConstants.INDEX_TYPE));
  34. boolean propertySecret = GetterUtil.getBoolean(properties.get(ExpandoColumnConstants.PROPERTY_SECRET));
  35. int propertyHeight = GetterUtil.getInteger(properties.get(ExpandoColumnConstants.PROPERTY_HEIGHT));
  36. int propertyWidth = GetterUtil.getInteger(properties.get(ExpandoColumnConstants.PROPERTY_WIDTH));
  37. String propertyDisplayType = GetterUtil.getString(properties.get(ExpandoColumnConstants.PROPERTY_DISPLAY_TYPE));
  38. PortletURL portletURL = renderResponse.createRenderURL();
  39. portletURL.setParameter("struts_action", "/expando/view_attributes");
  40. portletURL.setParameter("redirect", redirect);
  41. portletURL.setParameter("modelResource", modelResource);
  42. %>
  43. <liferay-ui:header
  44. backURL="<%= redirect %>"
  45. localizeTitle="<%= false %>"
  46. title='<%= modelResourceName + ": " + ((column == null) ? LanguageUtil.get(locale, "new-custom-field") : column.getName()) %>'
  47. />
  48. <portlet:actionURL var="editExpandoURL">
  49. <portlet:param name="struts_action" value="/expando/edit_expando" />
  50. </portlet:actionURL>
  51. <aui:form action="<%= editExpandoURL %>" method="post" name="fm" onSubmit='<%= "event.preventDefault(); " + renderResponse.getNamespace() + "saveExpando();" %>'>
  52. <aui:input name="<%= Constants.CMD %>" type="hidden" />
  53. <aui:input name="redirect" type="hidden" value="<%= redirect %>" />
  54. <aui:input name="columnId" type="hidden" value="<%= columnId %>" />
  55. <aui:input name="modelResource" type="hidden" value="<%= modelResource %>" />
  56. <liferay-ui:error exception="<%= ColumnNameException.class %>" message="please-enter-a-valid-name" />
  57. <liferay-ui:error exception="<%= ColumnTypeException.class %>" message="please-select-a-valid-type" />
  58. <liferay-ui:error exception="<%= DuplicateColumnNameException.class %>" message="please-enter-a-unique-name" />
  59. <liferay-ui:error exception="<%= ValueDataException.class %>" message="please-enter-a-valid-value" />
  60. <aui:fieldset>
  61. <c:choose>
  62. <c:when test="<%= column != null %>">
  63. <aui:field-wrapper helpMessage="custom-field-key-help" label="key">
  64. <aui:input name="name" type="hidden" value="<%= column.getName() %>" />
  65. <%= HtmlUtil.escape(column.getName()) %>
  66. </aui:field-wrapper>
  67. </c:when>
  68. <c:otherwise>
  69. <aui:input helpMessage="custom-field-key-help" label="key" name="name" />
  70. </c:otherwise>
  71. </c:choose>
  72. <c:choose>
  73. <c:when test="<%= column != null %>">
  74. <aui:field-wrapper label="type">
  75. <aui:input name="type" type="hidden" value="<%= type %>" />
  76. <liferay-ui:message key="<%= ExpandoColumnConstants.getTypeLabel(type) %>" />
  77. </aui:field-wrapper>
  78. </c:when>
  79. <c:otherwise>
  80. <aui:select helpMessage="custom-field-type-help" name="type">
  81. <optgroup label="<liferay-ui:message key="presets" />">
  82. <aui:option label="selection-of-integer-values" value="PresetSelectionIntegerArray()" />
  83. <aui:option label="selection-of-decimal-values" value="PresetSelectionDoubleArray()" />
  84. <aui:option label="selection-of-text-values" value="PresetSelectionStringArray()" />
  85. <aui:option label="text-box" value="PresetTextBox()" />
  86. <aui:option label="text-box-indexed" value="PresetTextBoxIndexed()" />
  87. <aui:option label="text-field-secret" value="PresetTextFieldSecret()" />
  88. <aui:option label="text-field-indexed" selected="<%= true %>" value="PresetTextFieldIndexed()" />
  89. </optgroup>
  90. <optgroup label="<liferay-ui:message key="primitives" />">
  91. <%
  92. for (int curType : ExpandoColumnConstants.TYPES) {
  93. if ((curType == ExpandoColumnConstants.BOOLEAN_ARRAY) || (curType == ExpandoColumnConstants.DATE_ARRAY)) {
  94. continue;
  95. }
  96. %>
  97. <aui:option label="<%= ExpandoColumnConstants.getTypeLabel(curType) %>" value="<%= curType %>" />
  98. <%
  99. }
  100. %>
  101. </optgroup>
  102. </aui:select>
  103. </c:otherwise>
  104. </c:choose>
  105. <c:if test="<%= column != null %>">
  106. <c:choose>
  107. <c:when test="<%= type == ExpandoColumnConstants.BOOLEAN %>">
  108. <%
  109. boolean curValue = ((Boolean)defaultValue).booleanValue();
  110. %>
  111. <aui:select name="defaultValue">
  112. <aui:option label="<%= true %>" selected="<%= curValue %>" value="true" />
  113. <aui:option label="<%= false %>" selected="<%= !curValue %>" value="false" />
  114. </aui:select>
  115. </c:when>
  116. <c:when test="<%= type == ExpandoColumnConstants.BOOLEAN_ARRAY %>">
  117. </c:when>
  118. <c:when test="<%= type == ExpandoColumnConstants.DATE %>">
  119. <%
  120. Calendar defaultValueDate = CalendarFactoryUtil.getCalendar(timeZone, locale);
  121. if (defaultValue != null) {
  122. defaultValueDate.setTime((Date)defaultValue);
  123. }
  124. %>
  125. <aui:field-wrapper label="default-value">
  126. <liferay-ui:input-date
  127. dayParam="defaultValueDay"
  128. dayValue="<%= defaultValueDate.get(Calendar.DATE) %>"
  129. disabled="<%= false %>"
  130. firstDayOfWeek="<%= defaultValueDate.getFirstDayOfWeek() - 1 %>"
  131. monthParam="defaultValueMonth"
  132. monthValue="<%= defaultValueDate.get(Calendar.MONTH) %>"
  133. yearParam="defaultValueYear"
  134. yearRangeEnd="<%= defaultValueDate.get(Calendar.YEAR) + 100 %>"
  135. yearRangeStart="<%= defaultValueDate.get(Calendar.YEAR) - 100 %>"
  136. yearValue="<%= defaultValueDate.get(Calendar.YEAR) %>"
  137. />
  138. <liferay-ui:input-time
  139. amPmParam="defaultValueAmPm"
  140. amPmValue="<%= defaultValueDate.get(Calendar.AM_PM) %>"
  141. disabled="<%= false %>"
  142. hourParam="defaultValueHour"
  143. hourValue="<%= defaultValueDate.get(Calendar.HOUR) %>"
  144. minuteInterval="<%= 1 %>"
  145. minuteParam="defaultValueMinute"
  146. minuteValue="<%= defaultValueDate.get(Calendar.MINUTE) %>"
  147. />
  148. </aui:field-wrapper>
  149. </c:when>
  150. <c:when test="<%= type == ExpandoColumnConstants.DATE_ARRAY %>">
  151. </c:when>
  152. <c:when test="<%= type == ExpandoColumnConstants.DOUBLE_ARRAY %>">
  153. <aui:input cssClass="lfr-textarea-container" name="defaultValue" type="textarea" value="<%= StringUtil.merge((double[])defaultValue, StringPool.NEW_LINE) %>" />
  154. </c:when>
  155. <c:when test="<%= type == ExpandoColumnConstants.FLOAT_ARRAY %>">
  156. <aui:input cssClass="lfr-textarea-container" name="defaultValue" type="textarea" value="<%= StringUtil.merge((float[])defaultValue, StringPool.NEW_LINE) %>" />
  157. </c:when>
  158. <c:when test="<%= type == ExpandoColumnConstants.INTEGER_ARRAY %>">
  159. <aui:input cssClass="lfr-textarea-container" name="defaultValue" type="textarea" value="<%= StringUtil.merge((int[])defaultValue, StringPool.NEW_LINE) %>" />
  160. </c:when>
  161. <c:when test="<%= type == ExpandoColumnConstants.LONG_ARRAY %>">
  162. <aui:input cssClass="lfr-textarea-container" name="defaultValue" type="textarea" value="<%= StringUtil.merge((long[])defaultValue, StringPool.NEW_LINE) %>" />
  163. </c:when>
  164. <c:when test="<%= type == ExpandoColumnConstants.NUMBER_ARRAY %>">
  165. <aui:input cssClass="lfr-textarea-container" name="defaultValue" type="textarea" value="<%= StringUtil.merge((Number[])defaultValue, StringPool.NEW_LINE) %>" />
  166. </c:when>
  167. <c:when test="<%= type == ExpandoColumnConstants.SHORT_ARRAY %>">
  168. <aui:input cssClass="lfr-textarea-container" name="defaultValue" type="textarea" value="<%= StringUtil.merge((short[])defaultValue, StringPool.NEW_LINE) %>" />
  169. </c:when>
  170. <c:when test="<%= type == ExpandoColumnConstants.STRING_ARRAY %>">
  171. <aui:input cssClass="lfr-textarea-container" name="defaultValue" type="textarea" value="<%= StringUtil.merge((String[])defaultValue, StringPool.NEW_LINE) %>" />
  172. </c:when>
  173. <c:otherwise>
  174. <aui:input cssClass="lfr-input-text-container" name="defaultValue" type="text" value="<%= String.valueOf(defaultValue) %>" />
  175. </c:otherwise>
  176. </c:choose>
  177. </c:if>
  178. </aui:fieldset>
  179. <c:if test="<%= column != null %>">
  180. <aui:fieldset label="properties">
  181. <aui:input name="PropertyName--hidden--" type="hidden" value="hidden" />
  182. <aui:select helpMessage="custom-field-hidden-help" label="hidden" name="Property--hidden--">
  183. <aui:option label="<%= true %>" selected="<%= propertyHidden %>" value="1" />
  184. <aui:option label="<%= false %>" selected="<%= !propertyHidden %>" value="0" />
  185. </aui:select>
  186. <aui:input name="PropertyName--visible-with-update-permission--" type="hidden" value="visible-with-update-permission" />
  187. <aui:select helpMessage="custom-field-visible-with-update-permission-help" label="visible-with-update-permission" name="Property--visible-with-update-permission--">
  188. <aui:option label="<%= true %>" selected="<%= propertyVisibleWithUpdatePermission %>" value="1" />
  189. <aui:option label="<%= false %>" selected="<%= !propertyVisibleWithUpdatePermission %>" value="0" />
  190. </aui:select>
  191. <aui:input name="PropertyName--index-type--" type="hidden" value="index-type" />
  192. <aui:select helpMessage="custom-field-index-type-help" label="searchability" name="Property--index-type--">
  193. <aui:option label="not-searchable" selected="<%= propertyIndexType == ExpandoColumnConstants.INDEX_TYPE_NONE %>" value="<%= ExpandoColumnConstants.INDEX_TYPE_NONE %>" />
  194. <c:if test="<%= (type == ExpandoColumnConstants.STRING) || (type == ExpandoColumnConstants.STRING_ARRAY) %>">
  195. <aui:option label="as-text" selected="<%= propertyIndexType == ExpandoColumnConstants.INDEX_TYPE_TEXT %>" value="<%= ExpandoColumnConstants.INDEX_TYPE_TEXT %>" />
  196. </c:if>
  197. <aui:option label="as-keyword" selected="<%= propertyIndexType == ExpandoColumnConstants.INDEX_TYPE_KEYWORD %>" value="<%= ExpandoColumnConstants.INDEX_TYPE_KEYWORD %>" />
  198. </aui:select>
  199. <c:if test="<%= (type == ExpandoColumnConstants.DOUBLE_ARRAY) || (type == ExpandoColumnConstants.FLOAT_ARRAY) || (type == ExpandoColumnConstants.INTEGER_ARRAY) || (type == ExpandoColumnConstants.LONG_ARRAY) || (type == ExpandoColumnConstants.NUMBER_ARRAY) || (type == ExpandoColumnConstants.SHORT_ARRAY) || (type == ExpandoColumnConstants.STRING_ARRAY) %>">
  200. <aui:input name="PropertyName--display-type--" type="hidden" value="display-type" />
  201. <aui:select helpMessage="custom-field-display-type-help" label="display-type" name="Property--display-type--">
  202. <aui:option label="checkbox" selected="<%= propertyDisplayType.equals(ExpandoColumnConstants.PROPERTY_DISPLAY_TYPE_CHECKBOX) %>" value="<%= ExpandoColumnConstants.PROPERTY_DISPLAY_TYPE_CHECKBOX %>" />
  203. <aui:option label="radio" selected="<%= propertyDisplayType.equals(ExpandoColumnConstants.PROPERTY_DISPLAY_TYPE_RADIO) %>" value="<%= ExpandoColumnConstants.PROPERTY_DISPLAY_TYPE_RADIO %>" />
  204. <aui:option label="selection-list" selected="<%= propertyDisplayType.equals(ExpandoColumnConstants.PROPERTY_DISPLAY_TYPE_SELECTION_LIST) %>" value="<%= ExpandoColumnConstants.PROPERTY_DISPLAY_TYPE_SELECTION_LIST %>" />
  205. <aui:option label="text-box" selected="<%= propertyDisplayType.equals(ExpandoColumnConstants.PROPERTY_DISPLAY_TYPE_TEXT_BOX) %>" value="<%= ExpandoColumnConstants.PROPERTY_DISPLAY_TYPE_TEXT_BOX %>" />
  206. </aui:select>
  207. </c:if>
  208. <c:if test="<%= type == ExpandoColumnConstants.STRING %>">
  209. <aui:input name="PropertyName--secret--" type="hidden" value="secret" />
  210. <aui:select helpMessage="custom-field-secret-help" label="secret" name="Property--secret--">
  211. <aui:option label="<%= true %>" selected="<%= propertySecret %>" value="1" />
  212. <aui:option label="<%= false %>" selected="<%= !propertySecret %>" value="0" />
  213. </aui:select>
  214. <aui:input name="PropertyName--height--" type="hidden" value="height" />
  215. <aui:input cssClass="lfr-input-text short-input-text" helpMessage="custom-field-height-help" label="height" name="Property--height--" type="text" value="<%= propertyHeight %>" />
  216. <aui:input name="PropertyName--width--" type="hidden" value="width" />
  217. <aui:input cssClass="lfr-input-text short-input-text" helpMessage="custom-field-height-help" label="width" name="Property--width--" type="text" value="<%= propertyWidth %>" />
  218. </c:if>
  219. </aui:fieldset>
  220. </c:if>
  221. <aui:button-row>
  222. <aui:button type="submit" />
  223. <aui:button href="<%= redirect %>" type="cancel" />
  224. </aui:button-row>
  225. </aui:form>
  226. <aui:script>
  227. function <portlet:namespace />saveExpando(options) {
  228. document.<portlet:namespace />fm.<portlet:namespace /><%= Constants.CMD %>.value = "<%= (column == null) ? Constants.ADD : Constants.UPDATE %>";
  229. submitForm(document.<portlet:namespace />fm);
  230. }
  231. <c:if test="<%= windowState.equals(WindowState.MAXIMIZED) && (column == null) %>">
  232. Liferay.Util.focusFormField(document.<portlet:namespace />fm.<portlet:namespace />name);
  233. </c:if>
  234. </aui:script>
  235. <%
  236. PortalUtil.addPortletBreadcrumbEntry(request, modelResourceName, portletURL.toString());
  237. if (column != null) {
  238. PortalUtil.addPortletBreadcrumbEntry(request, column.getName(), null);
  239. }
  240. PortalUtil.addPortletBreadcrumbEntry(request, LanguageUtil.get(pageContext, ((column == null) ? "add-attribute" : "edit")), currentURL);
  241. %>