index_form.twig 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <form action="tbl_indexes.php"
  2. method="post"
  3. name="index_frm"
  4. id="index_frm"
  5. class="ajax">
  6. {{ get_hidden_inputs(form_params) }}
  7. <fieldset id="index_edit_fields">
  8. <div class="index_info">
  9. <div>
  10. <div class="label">
  11. <strong>
  12. <label for="input_index_name">
  13. {% trans 'Index name:' %}
  14. {{ show_hint('"PRIMARY" <b>must</b> be the name of and <b>only of</b> a primary key!'|trans) }}
  15. </label>
  16. </strong>
  17. </div>
  18. <input type="text"
  19. name="index[Key_name]"
  20. id="input_index_name"
  21. size="25"
  22. maxlength="64"
  23. value="{{ index.getName() }}"
  24. onfocus="this.select()">
  25. </div>
  26. <div>
  27. <div class="label">
  28. <strong>
  29. <label for="select_index_choice">
  30. {% trans 'Index choice:' %}
  31. {{ show_mysql_docu('ALTER_TABLE') }}
  32. </label>
  33. </strong>
  34. </div>
  35. {{ index.generateIndexChoiceSelector(create_edit_table)|raw }}
  36. </div>
  37. {% include 'div_for_slider_effect.twig' with {
  38. 'id': 'indexoptions',
  39. 'message': 'Advanced Options'|trans,
  40. 'initial_sliders_state': default_sliders_state
  41. } only %}
  42. <div>
  43. <div class="label">
  44. <strong>
  45. <label for="input_key_block_size">
  46. {% trans 'Key block size:' %}
  47. </label>
  48. </strong>
  49. </div>
  50. <input type="text"
  51. name="index[Key_block_size]"
  52. id="input_key_block_size"
  53. size="30"
  54. value="{{ index.getKeyBlockSize() }}">
  55. </div>
  56. <div>
  57. <div class="label">
  58. <strong>
  59. <label for="select_index_type">
  60. {% trans 'Index type:' %}
  61. {{ show_mysql_docu('ALTER_TABLE') }}
  62. </label>
  63. </strong>
  64. </div>
  65. {{ index.generateIndexTypeSelector()|raw }}
  66. </div>
  67. <div>
  68. <div class="label">
  69. <strong>
  70. <label for="input_parser">
  71. {% trans 'Parser:' %}
  72. </label>
  73. </strong>
  74. </div>
  75. <input type="text"
  76. name="index[Parser]"
  77. id="input_parse"
  78. size="30"
  79. value="{{ index.getParser() }}">
  80. </div>
  81. <div>
  82. <div class="label">
  83. <strong>
  84. <label for="input_index_comment">
  85. {% trans 'Comment:' %}
  86. </label>
  87. </strong>
  88. </div>
  89. <input type="text"
  90. name="index[Index_comment]"
  91. id="input_index_comment"
  92. size="30"
  93. maxlength="1024"
  94. value="{{ index.getComment() }}">
  95. </div>
  96. </div>
  97. <!-- end of indexoptions div -->
  98. <div class="clearfloat"></div>
  99. <table id="index_columns">
  100. <thead>
  101. <tr>
  102. <th></th>
  103. <th>
  104. {% trans 'Column' %}
  105. </th>
  106. <th>
  107. {% trans 'Size' %}
  108. </th>
  109. </tr>
  110. </thead>
  111. {% set spatial_types = [
  112. 'geometry',
  113. 'point',
  114. 'linestring',
  115. 'polygon',
  116. 'multipoint',
  117. 'multilinestring',
  118. 'multipolygon',
  119. 'geomtrycollection'
  120. ] %}
  121. <tbody>
  122. {% for column in index.getColumns() %}
  123. <tr class="noclick">
  124. <td>
  125. <span class="drag_icon" title="{% trans 'Drag to reorder' %}"></span>
  126. </td>
  127. <td>
  128. <select name="index[columns][names][]">
  129. <option value="">
  130. -- {% trans 'Ignore' %} --
  131. </option>
  132. {% for field_name, field_type in fields %}
  133. {% if (index.getChoice() != 'FULLTEXT'
  134. or field_type matches '/(char|text)/i')
  135. and (index.getChoice() != 'SPATIAL'
  136. or field_type in spatial_types) %}
  137. <option value="{{ field_name }}"
  138. {%- if field_name == column.getName() %}
  139. selected="selected"
  140. {%- endif %}>
  141. {{ field_name }} [{{ field_type }}]
  142. </option>
  143. {% endif %}
  144. {% endfor %}
  145. </select>
  146. </td>
  147. <td>
  148. <input type="text"
  149. size="5"
  150. onfocus="this.select()"
  151. name="index[columns][sub_parts][]"
  152. value="{{ index.getChoice() != 'SPATIAL' ?
  153. column.getSubPart() }}">
  154. </td>
  155. </tr>
  156. {% endfor %}
  157. {% if add_fields > 0 %}
  158. {% for i in range(1, add_fields) %}
  159. <tr class="noclick">
  160. <td>
  161. <span class="drag_icon" title="{% trans 'Drag to reorder' %}"></span>
  162. </td>
  163. <td>
  164. <select name="index[columns][names][]">
  165. <option value="">-- {% trans 'Ignore' %} --</option>
  166. {% set j = 0 %}
  167. {% for field_name, field_type in fields %}
  168. {% if create_edit_table %}
  169. {% set col_index = field_type[1] %}
  170. {% set field_type = field_type[0] %}
  171. {% endif %}
  172. {% set j = j + 1 %}
  173. <option value="{{ col_index is defined ?
  174. col_index : field_name }}"
  175. {{- j == i ? ' selected="selected"' }}>
  176. {{ field_name }} [{{ field_type }}]
  177. </option>
  178. {% endfor %}
  179. </select>
  180. </td>
  181. <td>
  182. <input type="text"
  183. size="5"
  184. onfocus="this.select()"
  185. name="index[columns][sub_parts][]"
  186. value="">
  187. </td>
  188. </tr>
  189. {% endfor %}
  190. {% endif %}
  191. </tbody>
  192. </table>
  193. <div class="add_more">
  194. <div class="slider"></div>
  195. <div class="add_fields hide">
  196. <input class="btn btn-secondary" type="submit"
  197. id="add_fields"
  198. value="{{ 'Add %s column(s) to index'|trans|format(1) }}">
  199. </div>
  200. </div>
  201. </fieldset>
  202. <fieldset class="tblFooters">
  203. <button class="btn btn-secondary" type="submit" id="preview_index_frm">{% trans 'Preview SQL' %}</button>
  204. <input class="btn btn-primary" type="submit" id="save_index_frm" value="{% trans 'Go' %}">
  205. </fieldset>
  206. </form>