Prepare for version 5.1.3
[phpmyadmin.git] / templates / table / index_form.twig
blob3c4363528f40e542d4d5e22534e93e0333131ce2
1 <form action="{{ url('/table/indexes') }}"
2     method="post"
3     name="index_frm"
4     id="index_frm"
5     class="ajax">
7     {{ get_hidden_inputs(form_params) }}
9     <fieldset id="index_edit_fields">
10         <div class="index_info">
11             <div>
12                 <div class="label">
13                     <strong>
14                         <label for="input_index_name">
15                             {% trans 'Index name:' %}
16                             {{ show_hint('"PRIMARY" <b>must</b> be the name of and <b>only of</b> a primary key!'|trans) }}
17                         </label>
18                     </strong>
19                 </div>
21                 <input type="text"
22                     name="index[Key_name]"
23                     id="input_index_name"
24                     size="25"
25                     maxlength="64"
26                     value="{{ index.getName() }}"
27                     onfocus="this.select()">
28             </div>
30             <div>
31                 <div class="label">
32                     <strong>
33                         <label for="select_index_choice">
34                             {% trans 'Index choice:' %}
35                             {{ show_mysql_docu('ALTER_TABLE') }}
36                         </label>
37                     </strong>
38                 </div>
40               <select name="index[Index_choice]" id="select_index_choice"{{ create_edit_table ? ' disabled' }}>
41                 {% if index.getChoice() == 'PRIMARY' or not index.hasPrimary() %}
42                   <option value="PRIMARY"{{ index.getChoice() == 'PRIMARY' ? ' selected' }}>PRIMARY</option>
43                 {% endif %}
44                 <option value="INDEX"{{ index.getChoice() == 'INDEX' ? ' selected' }}>INDEX</option>
45                 <option value="UNIQUE"{{ index.getChoice() == 'UNIQUE' ? ' selected' }}>UNIQUE</option>
46                 <option value="SPATIAL"{{ index.getChoice() == 'SPATIAL' ? ' selected' }}>SPATIAL</option>
47                 <option value="FULLTEXT"{{ index.getChoice() == 'FULLTEXT' ? ' selected' }}>FULLTEXT</option>
48               </select>
49             </div>
51             <div id="indexoptions"{% if default_sliders_state != 'disabled' -%}
52                 {{- default_sliders_state == 'closed' ? ' style="display: none; overflow:auto;"' }} class="pma_auto_slider" title="{% trans 'Advanced options' %}"
53             {%- endif %}>
55             <div>
56                 <div class="label">
57                     <strong>
58                         <label for="input_key_block_size">
59                             {% trans 'Key block size:' %}
60                         </label>
61                     </strong>
62                 </div>
64                 <input type="text"
65                     name="index[Key_block_size]"
66                     id="input_key_block_size"
67                     size="30"
68                     value="{{ index.getKeyBlockSize() }}">
69             </div>
71             <div>
73                 <div class="label">
74                     <strong>
75                         <label for="select_index_type">
76                             {% trans 'Index type:' %}
77                             {{ show_mysql_docu('ALTER_TABLE') }}
78                         </label>
79                     </strong>
80                 </div>
82               <select name="index[Index_type]" id="select_index_type">
83                 {% for index_type in ['', 'BTREE', 'HASH'] %}
84                   <option value="{{ index_type }}"{{ index.getType() == index_type ? ' selected' }}>{{ index_type }}</option>
85                 {% endfor %}
86               </select>
87             </div>
89             <div>
90                 <div class="label">
91                     <strong>
92                         <label for="input_parser">
93                             {% trans 'Parser:' %}
94                         </label>
95                     </strong>
96                 </div>
98                 <input type="text"
99                     name="index[Parser]"
100                     id="input_parse"
101                     size="30"
102                     value="{{ index.getParser() }}">
103             </div>
105             <div>
106                 <div class="label">
107                     <strong>
108                         <label for="input_index_comment">
109                             {% trans 'Comment:' %}
110                         </label>
111                     </strong>
112                 </div>
114                 <input type="text"
115                     name="index[Index_comment]"
116                     id="input_index_comment"
117                     size="30"
118                     maxlength="1024"
119                     value="{{ index.getComment() }}">
120             </div>
121         </div>
122         <!-- end of indexoptions div -->
124         <div class="clearfloat"></div>
126         <table class="pma-table" id="index_columns">
127             <thead>
128                 <tr>
129                     <th></th>
130                     <th>
131                         {% trans 'Column' %}
132                     </th>
133                     <th>
134                         {% trans 'Size' %}
135                     </th>
136                 </tr>
137             </thead>
138             {% set spatial_types = [
139                 'geometry',
140                 'point',
141                 'linestring',
142                 'polygon',
143                 'multipoint',
144                 'multilinestring',
145                 'multipolygon',
146                 'geomtrycollection'
147             ] %}
148             <tbody>
149                 {% for column in index.getColumns() %}
150                     <tr class="noclick">
151                         <td>
152                             <span class="drag_icon" title="{% trans 'Drag to reorder' %}"></span>
153                         </td>
154                         <td>
155                             <select name="index[columns][names][]">
156                                 <option value="">
157                                     -- {% trans 'Ignore' %} --
158                                 </option>
159                                 {% for field_name, field_type in fields %}
160                                     {% if (index.getChoice() != 'FULLTEXT'
161                                             or field_type matches '/(char|text)/i')
162                                         and (index.getChoice() != 'SPATIAL'
163                                             or field_type in spatial_types) %}
165                                         <option value="{{ field_name }}"
166                                             {%- if field_name == column.getName() %}
167                                                 selected="selected"
168                                             {%- endif %}>
169                                             {{ field_name }} [{{ field_type }}]
170                                         </option>
171                                     {% endif %}
172                                 {% endfor %}
173                             </select>
174                         </td>
175                         <td>
176                             <input type="text"
177                                 size="5"
178                                 onfocus="this.select()"
179                                 name="index[columns][sub_parts][]"
180                                 value="{{ index.getChoice() != 'SPATIAL' ?
181                                     column.getSubPart() }}">
182                         </td>
183                     </tr>
184                 {% endfor %}
185                 {% if add_fields > 0 %}
186                     {% for i in range(1, add_fields) %}
187                         <tr class="noclick">
188                             <td>
189                                 <span class="drag_icon" title="{% trans 'Drag to reorder' %}"></span>
190                             </td>
191                             <td>
192                                 <select name="index[columns][names][]">
193                                     <option value="">-- {% trans 'Ignore' %} --</option>
194                                     {% set j = 0 %}
195                                     {% for field_name, field_type in fields %}
196                                         {% if create_edit_table %}
197                                             {% set col_index = field_type[1] %}
198                                             {% set field_type = field_type[0] %}
199                                         {% endif %}
200                                         {% set j = j + 1 %}
201                                         <option value="{{ col_index is defined ?
202                                             col_index : field_name }}"
203                                             {{- j == i ? ' selected="selected"' }}>
204                                             {{ field_name }} [{{ field_type }}]
205                                         </option>
206                                     {% endfor %}
207                                 </select>
208                             </td>
209                             <td>
210                                 <input type="text"
211                                     size="5"
212                                     onfocus="this.select()"
213                                     name="index[columns][sub_parts][]"
214                                     value="">
215                             </td>
216                         </tr>
217                     {% endfor %}
218                 {% endif %}
219             </tbody>
220         </table>
221         <div class="add_more">
223             <div class="slider"></div>
224             <div class="add_fields hide">
225                 <input class="btn btn-secondary" type="submit"
226                     id="add_fields"
227                     value="{{ 'Add %s column(s) to index'|trans|format(1) }}">
228             </div>
229         </div>
230         </div>
231     </fieldset>
232     <fieldset class="tblFooters">
233         <button class="btn btn-secondary" type="submit" id="preview_index_frm">{% trans 'Preview SQL' %}</button>
234     </fieldset>
235 </form>