index_form.twig 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <form action="{{ url('/table/indexes') }}"
  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. <select name="index[Index_choice]" id="select_index_choice"{{ create_edit_table ? ' disabled' }}>
  36. {% if index.getChoice() == 'PRIMARY' or not index.hasPrimary() %}
  37. <option value="PRIMARY"{{ index.getChoice() == 'PRIMARY' ? ' selected' }}>PRIMARY</option>
  38. {% endif %}
  39. <option value="INDEX"{{ index.getChoice() == 'INDEX' ? ' selected' }}>INDEX</option>
  40. <option value="UNIQUE"{{ index.getChoice() == 'UNIQUE' ? ' selected' }}>UNIQUE</option>
  41. <option value="SPATIAL"{{ index.getChoice() == 'SPATIAL' ? ' selected' }}>SPATIAL</option>
  42. <option value="FULLTEXT"{{ index.getChoice() == 'FULLTEXT' ? ' selected' }}>FULLTEXT</option>
  43. </select>
  44. </div>
  45. <div id="indexoptions"{% if default_sliders_state != 'disabled' -%}
  46. {{- default_sliders_state == 'closed' ? ' style="display: none; overflow:auto;"' }} class="pma_auto_slider" title="{% trans 'Advanced options' %}"
  47. {%- endif %}>
  48. <div>
  49. <div class="label">
  50. <strong>
  51. <label for="input_key_block_size">
  52. {% trans 'Key block size:' %}
  53. </label>
  54. </strong>
  55. </div>
  56. <input type="text"
  57. name="index[Key_block_size]"
  58. id="input_key_block_size"
  59. size="30"
  60. value="{{ index.getKeyBlockSize() }}">
  61. </div>
  62. <div>
  63. <div class="label">
  64. <strong>
  65. <label for="select_index_type">
  66. {% trans 'Index type:' %}
  67. {{ show_mysql_docu('ALTER_TABLE') }}
  68. </label>
  69. </strong>
  70. </div>
  71. <select name="index[Index_type]" id="select_index_type">
  72. {% for index_type in ['', 'BTREE', 'HASH'] %}
  73. <option value="{{ index_type }}"{{ index.getType() == index_type ? ' selected' }}>{{ index_type }}</option>
  74. {% endfor %}
  75. </select>
  76. </div>
  77. <div>
  78. <div class="label">
  79. <strong>
  80. <label for="input_parser">
  81. {% trans 'Parser:' %}
  82. </label>
  83. </strong>
  84. </div>
  85. <input type="text"
  86. name="index[Parser]"
  87. id="input_parse"
  88. size="30"
  89. value="{{ index.getParser() }}">
  90. </div>
  91. <div>
  92. <div class="label">
  93. <strong>
  94. <label for="input_index_comment">
  95. {% trans 'Comment:' %}
  96. </label>
  97. </strong>
  98. </div>
  99. <input type="text"
  100. name="index[Index_comment]"
  101. id="input_index_comment"
  102. size="30"
  103. maxlength="1024"
  104. value="{{ index.getComment() }}">
  105. </div>
  106. </div>
  107. <!-- end of indexoptions div -->
  108. <div class="clearfloat"></div>
  109. <table class="pma-table" id="index_columns">
  110. <thead>
  111. <tr>
  112. <th></th>
  113. <th>
  114. {% trans 'Column' %}
  115. </th>
  116. <th>
  117. {% trans 'Size' %}
  118. </th>
  119. </tr>
  120. </thead>
  121. {% set spatial_types = [
  122. 'geometry',
  123. 'point',
  124. 'linestring',
  125. 'polygon',
  126. 'multipoint',
  127. 'multilinestring',
  128. 'multipolygon',
  129. 'geomtrycollection'
  130. ] %}
  131. <tbody>
  132. {% for column in index.getColumns() %}
  133. <tr class="noclick">
  134. <td>
  135. <span class="drag_icon" title="{% trans 'Drag to reorder' %}"></span>
  136. </td>
  137. <td>
  138. <select name="index[columns][names][]">
  139. <option value="">
  140. -- {% trans 'Ignore' %} --
  141. </option>
  142. {% for field_name, field_type in fields %}
  143. {% if (index.getChoice() != 'FULLTEXT'
  144. or field_type matches '/(char|text)/i')
  145. and (index.getChoice() != 'SPATIAL'
  146. or field_type in spatial_types) %}
  147. <option value="{{ field_name }}"
  148. {%- if field_name == column.getName() %}
  149. selected="selected"
  150. {%- endif %}>
  151. {{ field_name }} [{{ field_type }}]
  152. </option>
  153. {% endif %}
  154. {% endfor %}
  155. </select>
  156. </td>
  157. <td>
  158. <input type="text"
  159. size="5"
  160. onfocus="this.select()"
  161. name="index[columns][sub_parts][]"
  162. value="{{ index.getChoice() != 'SPATIAL' ?
  163. column.getSubPart() }}">
  164. </td>
  165. </tr>
  166. {% endfor %}
  167. {% if add_fields > 0 %}
  168. {% for i in range(1, add_fields) %}
  169. <tr class="noclick">
  170. <td>
  171. <span class="drag_icon" title="{% trans 'Drag to reorder' %}"></span>
  172. </td>
  173. <td>
  174. <select name="index[columns][names][]">
  175. <option value="">-- {% trans 'Ignore' %} --</option>
  176. {% set j = 0 %}
  177. {% for field_name, field_type in fields %}
  178. {% if create_edit_table %}
  179. {% set col_index = field_type[1] %}
  180. {% set field_type = field_type[0] %}
  181. {% endif %}
  182. {% set j = j + 1 %}
  183. <option value="{{ col_index is defined ?
  184. col_index : field_name }}"
  185. {{- j == i ? ' selected="selected"' }}>
  186. {{ field_name }} [{{ field_type }}]
  187. </option>
  188. {% endfor %}
  189. </select>
  190. </td>
  191. <td>
  192. <input type="text"
  193. size="5"
  194. onfocus="this.select()"
  195. name="index[columns][sub_parts][]"
  196. value="">
  197. </td>
  198. </tr>
  199. {% endfor %}
  200. {% endif %}
  201. </tbody>
  202. </table>
  203. <div class="add_more">
  204. <div class="slider"></div>
  205. <div class="add_fields hide">
  206. <input class="btn btn-secondary" type="submit"
  207. id="add_fields"
  208. value="{{ 'Add %s column(s) to index'|trans|format(1) }}">
  209. </div>
  210. </div>
  211. </div>
  212. </fieldset>
  213. <fieldset class="tblFooters">
  214. <button class="btn btn-secondary" type="submit" id="preview_index_frm">{% trans 'Preview SQL' %}</button>
  215. </fieldset>
  216. </form>