Advertisement
Guest User

HTML FORM definition

a guest
Mar 10th, 2022
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.15 KB | None | 0 0
  1. <%@ include file="/WEB-INF/template/include.jsp"%>
  2. <%
  3. pageContext.setAttribute("tagWarnings", session.getAttribute("tagWarnings"));
  4. session.removeAttribute("tagWarnings");
  5. %>
  6.  
  7. <openmrs:require privilege="Manage Forms" otherwise="/login.htm" redirect="/module/htmlformentry/htmlForm.list" />
  8.  
  9. <c:set var="DO_NOT_INCLUDE_JQUERY" value="true"/>
  10.  
  11. <%@ include file="/WEB-INF/template/header.jsp"%>
  12. <%@ include file="localHeader.jsp" %>
  13.  
  14. <openmrs:htmlInclude file="/moduleResources/htmlformentry/jquery-ui-1.9.2.custom.min.css" />
  15. <openmrs:htmlInclude file="/moduleResources/htmlformentry/jquery-1.8.3.min.js" />
  16. <openmrs:htmlInclude file="/moduleResources/htmlformentry/jquery-ui-1.9.2.custom.min.js" />
  17. <openmrs:htmlInclude file="/moduleResources/htmlformentry/handlebars.min.js" />
  18. <openmrs:htmlInclude file="/moduleResources/htmlformentry/htmlForm.js" />
  19. <openmrs:htmlInclude file="/dwr/util.js" />
  20.  
  21.  
  22. <script>
  23. $j = jQuery.noConflict();
  24.  
  25. function updateRetiredReasonDisplay(b) {
  26. if (b)
  27. $j('#retiredReasonRow').show();
  28. else
  29. $j('#retiredReasonRow').hide();
  30. }
  31.  
  32. $j(document).ready(function() {
  33. updateRetiredReasonDisplay($j('#retired').checked);
  34. <c:choose>
  35. <c:when test="${empty htmlForm.id}">
  36. $j('.show-later').hide();
  37. $j('.show-sometimes').hide();
  38. </c:when>
  39. <c:otherwise>
  40. $j('.show-first').hide();
  41. $j('.show-sometimes').hide();
  42. $j('#toggle-all-fields').click(function() {
  43. $j('.show-first').toggle();
  44. $j('.show-sometimes').toggle();
  45. });
  46. </c:otherwise>
  47. </c:choose>
  48.  
  49.  
  50. htmlForm.initialize();
  51. });
  52.  
  53.  
  54. // clear toggle container's inputs but saves the input values until form is submitted/validated in case the user
  55. // re-clicks the trigger checkbox. Note: These "saved" input values will be lost if the form fails validation on submission.
  56. function clearContainerInputs($container) {
  57. if (!initInd) {
  58. $container.find('input:text, input:password, input:file, select, textarea').each( function() {
  59. $j(this).data('origVal',this.value);
  60. $j(this).val("");
  61. });
  62. $container.find('input:radio, input:checkbox').each( function() {
  63. if ($j(this).is(":checked")) {
  64. $j(this).data('origState','checked');
  65. $j(this).removeAttr("checked");
  66. } else {
  67. $j(this).data('origState','unchecked');
  68. }
  69. });
  70. }
  71. }
  72.  
  73. // restores toggle container's inputs from the last time the trigger checkbox was unchecked
  74. function restoreContainerInputs($container) {
  75. $container.find('input:text, input:password, input:file, select, textarea').each( function() {
  76. $j(this).val($j(this).data('origVal'));
  77. });
  78. $container.find('input:radio, input:checkbox').each( function() {
  79. if ($j(this).data('origState') == 'checked') {
  80. $j(this).attr("checked", "checked");
  81. } else {
  82. $j(this).removeAttr("checked");
  83. }
  84. });
  85. }
  86.  
  87.  
  88. </script>
  89.  
  90. <h2>
  91. <c:choose>
  92. <c:when test="${empty htmlForm.id}">
  93. <spring:message code="htmlformentry.HtmlForm.create.title" />
  94. </c:when>
  95. <c:otherwise>
  96. <spring:message code="htmlformentry.HtmlForm.edit.title" />
  97. </c:otherwise>
  98. </c:choose>
  99. </h2>
  100.  
  101. <openmrs:extensionPoint pointId="org.openmrs.module.htmlformentry.designer">
  102. <openmrs:portlet url="${extension.portletUrl}" moduleId="${extension.moduleId}" />
  103. </openmrs:extensionPoint>
  104.  
  105. <spring:hasBindErrors name="htmlForm">
  106. <spring:message code="fix.error"/>
  107. <div class="error">
  108. <c:forEach items="${errors.allErrors}" var="error">
  109. <spring:message code="${error.code}" text="${error.code}"/><br/><!-- ${error} -->
  110. </c:forEach>
  111. </div>
  112. <br />
  113. </spring:hasBindErrors>
  114.  
  115. <c:if test="${not empty htmlForm.id}">
  116. <a id="toggle-all-fields" onmouseover="document.body.style.cursor='pointer'" onmouseout="document.body.style.cursor='default'"><spring:message code="htmlformentry.toggleAllFields"/></a>
  117. </c:if>
  118.  
  119. <form method="post">
  120. <table style="width:100%">
  121. <tr class="show-later">
  122. <td><spring:message code="general.id"/></td>
  123. <td>${htmlForm.id}</td>
  124. </tr>
  125. <tr>
  126. <td><spring:message code="general.name"/></td>
  127. <td>
  128. <spring:bind path="htmlForm.form.name">
  129. <input type="text" name="${status.expression}" value="<c:out value="${status.value}"/>" size="35" />
  130. <c:if test="${status.errorMessage != ''}">
  131. <span class="error">${status.errorMessage}</span>
  132. </c:if>
  133. </spring:bind>
  134. </td>
  135. </tr>
  136. <tr class="show-first">
  137. <td valign="top"><spring:message code="general.description"/></td>
  138. <td valign="top">
  139. <spring:bind path="htmlForm.form.description">
  140. <textarea name="${status.expression}" rows="3" cols="40" type="_moz"><c:out value="${status.value}"/></textarea>
  141. <c:if test="${status.errorMessage != ''}">
  142. <span class="error">${status.errorMessage}</span>
  143. </c:if>
  144. </spring:bind>
  145. </td>
  146. </tr>
  147. <tr class="show-first">
  148. <td><spring:message code="Form.version"/></td>
  149. <td>
  150. <spring:bind path="htmlForm.form.version">
  151. <input type="text" name="${status.expression}" value="<c:out value="${status.value}"/>" size="5" />
  152. <c:if test="${status.errorMessage != ''}">
  153. <span class="error">${status.errorMessage}</span>
  154. </c:if>
  155. </spring:bind>
  156. </td>
  157. </tr>
  158. <tr class="show-first">
  159. <td><spring:message code="Encounter.type"/></td>
  160. <td>
  161. <spring:bind path="htmlForm.form.encounterType">
  162. <select name="${status.expression}">
  163. <option value=""></option>
  164. <c:forEach items="${encounterTypes}" var="type">
  165. <option value="${type.encounterTypeId}" <c:if test="${type.encounterTypeId == status.value}">selected</c:if>><c:out value="${type.name}"/></option>
  166. </c:forEach>
  167. </select>
  168. <c:if test="${status.errorMessage != ''}">
  169. <span class="error">${status.errorMessage}</span>
  170. </c:if>
  171. </spring:bind>
  172. </td>
  173. </tr>
  174. <tr class="show-sometimes">
  175. <td><spring:message code="general.createdBy"/></td>
  176. <td>
  177. <c:out value="${htmlForm.form.creator.personName}"/> -
  178. <openmrs:formatDate date="${htmlForm.form.dateCreated}" type="long" />
  179. </td>
  180. </tr>
  181. <tr class="show-sometimes">
  182. <td><spring:message code="general.changedBy"/></td>
  183. <td>
  184. <c:out value="${htmlForm.form.changedBy.personName}"/> -
  185. <openmrs:formatDate date="${htmlForm.form.dateChanged}" type="long" />
  186. </td>
  187. </tr>
  188. <tr class="show-later">
  189. <td><spring:message code="Form.published"/></td>
  190. <td>
  191. <spring:bind path="htmlForm.form.published">
  192. <input type="hidden" name="_${status.expression}">
  193. <input type="checkbox" name="${status.expression}"
  194. id="${status.expression}"
  195. <c:if test="${status.value == true}">checked</c:if>
  196. />
  197. </spring:bind>
  198. </td>
  199. </tr>
  200. <tr class="show-later">
  201. <td><spring:message code="general.retired"/></td>
  202. <td>
  203. <spring:bind path="htmlForm.form.retired">
  204. <input type="hidden" name="_${status.expression}">
  205. <input type="checkbox" name="${status.expression}"
  206. id="retired"
  207. <c:if test="${status.value == true}">checked</c:if>
  208. onchange="updateRetiredReasonDisplay(this.checked)"
  209. />
  210. </spring:bind>
  211. <span id="retiredReasonRow">
  212. <spring:message code="general.retiredReason"/>
  213. <spring:bind path="htmlForm.form.retireReason">
  214. <input type="text" name="${status.expression}" id="retiredReason" value="<c:out value="${status.value}"/>" />
  215. <c:if test="${status.errorMessage != ''}">
  216. <span class="error">${status.errorMessage}</span>
  217. </c:if>
  218. </spring:bind>
  219. </span>
  220. </td>
  221. </tr>
  222. <c:if test="${htmlForm.form.retired}">
  223. <tr class="show-later">
  224. <td><spring:message code="general.retiredBy"/></td>
  225. <td>
  226. <c:out value="${htmlForm.form.retiredBy.personName}"/> -
  227. <openmrs:formatDate date="${htmlForm.form.dateRetired}" type="long" />
  228. </td>
  229. </tr>
  230. </c:if>
  231. <tr class="show-later">
  232. <td><spring:message code="Form.formSchema"/>:</td>
  233. <td>
  234. <c:if test="${!empty htmlForm.xmlData}">
  235. <a href="htmlFormSchema.form?id=${htmlForm.id}" target="_blank"><spring:message code="general.view"/></a>
  236. </c:if>
  237. </td>
  238. </tr>
  239. <tr class="show-later">
  240. <td valign="top"><spring:message code="htmlformentry.HtmlForm.html"/>:</td>
  241. <td style="width:100%">
  242. <spring:bind path="htmlForm.xmlData" htmlEscape="false">
  243. <textarea id="xmlData" rows="20" style="width:100%" name="${status.expression}"><c:out value="${status.value}" escapeXml="true"/></textarea>
  244. <c:if test="${status.errorMessage != ''}">
  245. <span class="error">${status.errorMessage}</span>
  246. </c:if>
  247. </spring:bind>
  248. <c:if test="${tagWarnings != null}">
  249. <c:forEach items="${tagWarnings}" var="tagWarning">
  250. <br/><span>${tagWarning}</span>
  251. </c:forEach>
  252. </c:if>
  253. </td>
  254. </tr>
  255. <tr>
  256. <td></td>
  257. <td>
  258. <input type="submit" value="<spring:message code='general.save'/>" />
  259. </td>
  260. </tr>
  261. </table>
  262. </form>
  263.  
  264. <c:if test="${ not empty previewHtml }">
  265.  
  266. <script>
  267. var propertyAccessorInfo = new Array();
  268. var beforeValidation = new Array(); // a list of functions that will be executed before the validation of a form
  269. var beforeSubmit = new Array(); // a list of functions that will be executed before the submission of a form
  270. </script>
  271.  
  272. <openmrs:htmlInclude file="/moduleResources/htmlformentry/htmlFormEntry.js" />
  273. <openmrs:htmlInclude file="/moduleResources/htmlformentry/htmlFormEntry.css" />
  274. <openmrs:htmlInclude file="/moduleResources/htmlformentry/htmlForm.js" />
  275. <openmrs:htmlInclude file="/moduleResources/htmlformentry/orderWidget.css" />
  276. <openmrs:htmlInclude file="/moduleResources/htmlformentry/orderWidget.js" />
  277.  
  278. <br/>
  279. <br/>
  280.  
  281. <hr/>
  282. <b><u>Preview</u></b><br/>
  283. <hr/>
  284. ${ previewHtml }
  285. </c:if>
  286.  
  287. <%--
  288. <tr>
  289. <th align="right"><spring:message code="general.createdBy"/>:</th>
  290. <td>
  291. ${command.creator} ${command.dateCreated}
  292. </td>
  293. </tr>
  294. <tr>
  295. <th align="right"><spring:message code="general.changedBy"/>:</th>
  296. <td>
  297. ${command.changedBy} ${command.dateChanged}
  298. </td>
  299. </tr>
  300. --%>
  301.  
  302. <%@ include file="/WEB-INF/template/footer.jsp"%>
  303.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement