main.twig 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. {# getHtmlForAddNewColumn #}
  2. <div id="add_col_div" class="topmargin">
  3. <a href="#">
  4. <span>{{ (total_rows > 0) ? '+' : '-' }}</span>{% trans 'Add new column' %}
  5. </a>
  6. <form id="add_new" class="new_central_col{{ (total_rows != 0) ? ' hide' : ''}}"
  7. method="post" action="{{ url('/database/central-columns') }}">
  8. {{ get_hidden_inputs(db) }}
  9. <input type="hidden" name="add_new_column" value="add_new_column">
  10. <div class="table-responsive">
  11. <table class="table table-light w-auto">
  12. <thead class="thead-light">
  13. <tr>
  14. <th></th>
  15. <th class="" title="" data-column="name">
  16. {% trans 'Name' %}
  17. <div class="sorticon"></div>
  18. </th>
  19. <th class="" title="" data-column="type">
  20. {% trans 'Type' %}
  21. <div class="sorticon"></div>
  22. </th>
  23. <th class="" title="" data-column="length">
  24. {% trans 'Length/Value' %}
  25. <div class="sorticon"></div>
  26. </th>
  27. <th class="" title="" data-column="default">
  28. {% trans 'Default' %}
  29. <div class="sorticon"></div>
  30. </th>
  31. <th class="" title="" data-column="collation">
  32. {% trans 'Collation' %}
  33. <div class="sorticon"></div>
  34. </th>
  35. <th class="" title="" data-column="attribute">
  36. {% trans 'Attribute' %}
  37. <div class="sorticon"></div>
  38. </th>
  39. <th class="" title="" data-column="isnull">
  40. {% trans 'Null' %}
  41. <div class="sorticon"></div>
  42. </th>
  43. <th class="" title="" data-column="extra">
  44. {% trans 'A_I' %}
  45. <div class="sorticon"></div>
  46. </th>
  47. <th></th>
  48. </tr>
  49. </thead>
  50. <tbody>
  51. <tr>
  52. <td></td>
  53. <td name="col_name" class="nowrap">
  54. {% include 'columns_definitions/column_name.twig' with {
  55. 'column_number': 0,
  56. 'ci': 0,
  57. 'ci_offset': 0,
  58. 'column_meta': {},
  59. 'cfg_relation': {
  60. 'centralcolumnswork': false
  61. },
  62. 'max_rows': max_rows,
  63. } only %}
  64. </td>
  65. <td name="col_type" class="nowrap">
  66. <select class="column_type" name="field_type[0]" id="field_0_1">
  67. {{ get_supported_datatypes(true) }}
  68. </select>
  69. </td>
  70. <td class="nowrap" name="col_length">
  71. <input id="field_0_2" type="text" name="field_length[0]" size="8" value="" class="textfield">
  72. <p class="enum_notice" id="enum_notice_0_2">
  73. <a href="#" class="open_enum_editor">{% trans 'Edit ENUM/SET values' %}</a>
  74. </p>
  75. </td>
  76. <td class="nowrap" name="col_default">
  77. <select name="field_default_type[0]" id="field_0_3" class="default_type">
  78. <option value="NONE">{% trans %}None{% context %}for default{% endtrans %}</option>
  79. <option value="USER_DEFINED">{% trans 'As defined:' %}</option>
  80. <option value="NULL">NULL</option>
  81. <option value="CURRENT_TIMESTAMP">CURRENT_TIMESTAMP</option>
  82. </select>
  83. {% if char_editing == 'textarea' %}
  84. <textarea name="field_default_value[0]" cols="15" class="textfield default_value"></textarea>
  85. {% else %}
  86. <input type="text" name="field_default_value[0]" size="12" value="" class="textfield default_value">
  87. {% endif %}
  88. </td>
  89. <td name="collation" class="nowrap">
  90. <select lang="en" dir="ltr" name="field_collation[0]" id="field_0_4">
  91. <option value=""></option>
  92. {% for charset in charsets %}
  93. <optgroup label="{{ charset.name }}" title="{{ charset.description }}">
  94. {% for collation in charset.collations %}
  95. <option value="{{ collation.name }}" title="{{ collation.description }}">
  96. {{- collation.name -}}
  97. </option>
  98. {% endfor %}
  99. </optgroup>
  100. {% endfor %}
  101. </select>
  102. </td>
  103. <td class="nowrap" name="col_attribute">
  104. {% include 'columns_definitions/column_attribute.twig' with {
  105. 'column_number': 0,
  106. 'ci': 5,
  107. 'ci_offset': 0,
  108. 'extracted_columnspec': {},
  109. 'column_meta': {},
  110. 'submit_attribute': false,
  111. 'attribute_types': attribute_types,
  112. } only %}
  113. </td>
  114. <td class="nowrap" name="col_isNull">
  115. <input name="field_null[0]" id="field_0_6" type="checkbox" value="YES" class="allow_null">
  116. </td>
  117. <td class="nowrap" name="col_extra">
  118. <input name="col_extra[0]" id="field_0_7" type="checkbox" value="auto_increment">
  119. </td>
  120. <td>
  121. <input id="add_column_save" class="btn btn-primary" type="submit" value="Save">
  122. </td>
  123. </tr>
  124. </tbody>
  125. </table>
  126. </div>
  127. </form>
  128. </div>
  129. {% if total_rows <= 0 %}
  130. <fieldset>
  131. {% trans 'The central list of columns for the current database is empty' %}
  132. </fieldset>
  133. {% else %}
  134. <table class="table table-borderless table-sm w-auto d-inline-block navigation">
  135. <tr>
  136. <td class="navigation_separator"></td>
  137. {% if pos - max_rows >= 0 %}
  138. <td>
  139. <form action="{{ url('/database/central-columns') }}" method="post">
  140. {{ get_hidden_inputs(db) }}
  141. <input type="hidden" name="pos" value="{{ pos - max_rows }}">
  142. <input type="hidden" name="total_rows" value="{{ total_rows }}">
  143. <input class="btn btn-secondary ajax" type="submit" name="navig" value="&lt">
  144. </form>
  145. </td>
  146. {% endif %}
  147. {% if tn_nbTotalPage > 1 %}
  148. <td>
  149. <form action="{{ url('/database/central-columns') }}" method="post">
  150. {{ get_hidden_inputs(db) }}
  151. <input type="hidden" name="total_rows" value="{{ total_rows }}">
  152. {{ tn_page_selector | raw }}
  153. </form>
  154. </td>
  155. {% endif %}
  156. {% if pos + max_rows < total_rows %}
  157. <td>
  158. <form action="{{ url('/database/central-columns') }}" method="post">
  159. {{ get_hidden_inputs(db) }}
  160. <input type="hidden" name="pos" value="{{ pos + max_rows }}">
  161. <input type="hidden" name="total_rows" value="{{ total_rows }}">
  162. <input class="btn btn-secondary ajax" type="submit" name="navig" value="&gt">
  163. </form>
  164. </td>
  165. {% endif %}
  166. <td class="navigation_separator"></td>
  167. <td>
  168. <span>{% trans 'Filter rows' %}:</span>
  169. <input type="text" class="filter_rows" placeholder="{% trans 'Search this table' %}">
  170. </td>
  171. <td class="navigation_separator"></td>
  172. </tr>
  173. </table>
  174. {% endif %}
  175. <table class="table table-borderless table-sm w-auto d-inline-block navigation">
  176. <tr>
  177. <td class="navigation_separator largescreenonly"></td>
  178. <td class="central_columns_navigation">
  179. {{ get_icon('centralColumns_add', 'Add column' | trans)|raw }}
  180. <form id="add_column" action="{{ url('/database/central-columns') }}" method="post">
  181. {{ get_hidden_inputs(db) | raw }}
  182. <input type="hidden" name="add_column" value="add">
  183. <input type="hidden" name="pos" value="{{ pos }}">
  184. <input type="hidden" name="total_rows" value="{{ total_rows }}">
  185. {# getHtmlForTableDropdown #}
  186. <select name="table-select" id="table-select">
  187. <option value="" disabled="disabled" selected="selected">
  188. {% trans 'Select a table' %}
  189. </option>
  190. {% for table in tables %}
  191. <option value="{{ table|e }}">{{ table|e }}</option>
  192. {% endfor %}
  193. </select>
  194. <select name="column-select" id="column-select">
  195. <option value="" selected="selected">{% trans 'Select a column.' %}</option>
  196. </select>
  197. <input class="btn btn-primary" type="submit" value="{% trans 'Add' %}">
  198. </form>
  199. </td>
  200. <td class="navigation_separator largescreenonly"></td>
  201. </tr>
  202. </table>
  203. {% if total_rows > 0 %}
  204. <form method="post" id="del_form" action="{{ url('/database/central-columns') }}">
  205. {{ get_hidden_inputs(db) }}
  206. <input id="del_col_name" type="hidden" name="col_name" value="">
  207. <input type="hidden" name="pos" value="{{ pos }}">
  208. <input type="hidden" name="delete_save" value="delete">
  209. </form>
  210. <div id="tableslistcontainer">
  211. <form name="tableslistcontainer">
  212. <table id="table_columns" class="table table-light table-striped table-hover tablesorter w-auto">
  213. {% set class = 'column_heading' %}
  214. {% set title = 'Click to sort.' | trans %}
  215. <thead class="thead-light">
  216. <tr>
  217. <th class="{{ class }}"></th>
  218. <th class="hide"></th>
  219. <th class="column_action" colspan="2">{% trans 'Action' %}</th>
  220. <th class="{{ class }}" title="{{ title }}" data-column="name">
  221. {% trans 'Name' %}
  222. <div class="sorticon"></div>
  223. </th>
  224. <th class="{{ class }}" title="{{ title }}" data-column="type">
  225. {% trans 'Type' %}
  226. <div class="sorticon"></div>
  227. </th>
  228. <th class="{{ class }}" title="{{ title }}" data-column="length">
  229. {% trans 'Length/Value' %}
  230. <div class="sorticon"></div>
  231. </th>
  232. <th class="{{ class }}" title="{{ title }}" data-column="default">
  233. {% trans 'Default' %}
  234. <div class="sorticon"></div>
  235. </th>
  236. <th class="{{ class }}" title="{{ title }}" data-column="collation">
  237. {% trans 'Collation' %}
  238. <div class="sorticon"></div>
  239. </th>
  240. <th class="{{ class }}" title="{{ title }}" data-column="attribute">
  241. {% trans 'Attribute' %}
  242. <div class="sorticon"></div>
  243. </th>
  244. <th class="{{ class }}" title="{{ title }}" data-column="isnull">
  245. {% trans 'Null' %}
  246. <div class="sorticon"></div>
  247. </th>
  248. <th class="{{ class }}" title="{{ title }}" data-column="extra">
  249. {% trans 'A_I' %}
  250. <div class="sorticon"></div>
  251. </th>
  252. </tr>
  253. </thead>
  254. <tbody>
  255. {% set row_num = 0 %}
  256. {% for row in rows_list %}
  257. {# getHtmlForTableRow #}
  258. <tr data-rownum="{{ row_num }}" id="{{ 'f_' ~ row_num }}">
  259. {{ get_hidden_inputs(db) }}
  260. <input type="hidden" name="edit_save" value="save">
  261. <td class="nowrap">
  262. <input type="checkbox" class="checkall" name="selected_fld[]"
  263. value="{{ row['col_name'] }}" id="{{ 'checkbox_row_' ~ row_num }}">
  264. </td>
  265. <td id="{{ 'edit_' ~ row_num }}" class="edit text-center">
  266. <a href="#"> {{ get_icon('b_edit', 'Edit' | trans) | raw }}</a>
  267. </td>
  268. <td class="del_row" data-rownum = "{{ row_num }}">
  269. <a hrf="#">{{ get_icon('b_drop', 'Delete' | trans) }}</a>
  270. <input type="submit" data-rownum = "{{ row_num }}" class="btn btn-secondary edit_cancel_form" value="{{ 'Cancel'|trans }}">
  271. </td>
  272. <td id="{{ 'save_' ~ row_num }}" class="hide">
  273. <input type="submit" data-rownum="{{ row_num }}" class="btn btn-primary edit_save_form" value="{{ 'Save'|trans }}">
  274. </td>
  275. <td name="col_name" class="nowrap">
  276. <span>{{ row['col_name'] }}</span>
  277. <input name="orig_col_name" type="hidden" value="{{ row['col_name'] }}">
  278. {% include 'columns_definitions/column_name.twig' with {
  279. 'column_number': row_num,
  280. 'ci': 0,
  281. 'ci_offset': 0,
  282. 'column_meta': {
  283. 'Field': row['col_name']
  284. },
  285. 'cfg_relation': {
  286. 'centralcolumnswork': false
  287. },
  288. 'max_rows': max_rows
  289. } only %}
  290. </td>
  291. <td name = "col_type" class="nowrap">
  292. <span>{{ row['col_type'] }}</span>
  293. <select class="column_type" name="field_type[{{ row_num }}]" id="field_{{ row_num }}_1">
  294. {{ get_supported_datatypes(true, types_upper[row_num]) }}
  295. </select>
  296. </td>
  297. <td class="nowrap" name="col_length">
  298. <span>{{ (row['col_length']?(row['col_length']):'') }}</span>
  299. <input id="field_{{ row_num }}_2" type="text" name="field_length[{{ row_num }}]" size="8" value="{{ row['col_length'] }}" class="textfield">
  300. <p class="enum_notice" id="enum_notice_{{ row_num }}_2">
  301. <a href="#" class="open_enum_editor">{% trans 'Edit ENUM/SET values' %}</a>
  302. </p>
  303. </td>
  304. <td class="nowrap" name="col_default">
  305. {% if row['col_default'] is defined %}
  306. <span>{{ row['col_default'] }}</span>
  307. {% else %}
  308. <span>{% trans 'None' %}</span>
  309. {% endif %}
  310. <select name="field_default_type[{{ row_num }}]" id="field_{{ row_num }}_3" class="default_type">
  311. <option value="NONE"{{ rows_meta[row_num]['DefaultType'] is defined and rows_meta[row_num]['DefaultType'] == 'NONE' ? ' selected' }}>
  312. {% trans %}None{% context %}for default{% endtrans %}
  313. </option>
  314. <option value="USER_DEFINED"{{ rows_meta[row_num]['DefaultType'] is defined and rows_meta[row_num]['DefaultType'] == 'USER_DEFINED' ? ' selected' }}>
  315. {% trans 'As defined:' %}
  316. </option>
  317. <option value="NULL"{{ rows_meta[row_num]['DefaultType'] is defined and rows_meta[row_num]['DefaultType'] == 'NULL' ? ' selected' }}>
  318. NULL
  319. </option>
  320. <option value="CURRENT_TIMESTAMP"{{ rows_meta[row_num]['DefaultType'] is defined and rows_meta[row_num]['DefaultType'] == 'CURRENT_TIMESTAMP' ? ' selected' }}>
  321. CURRENT_TIMESTAMP
  322. </option>
  323. </select>
  324. {% if char_editing == 'textarea' %}
  325. <textarea name="field_default_value[{{ row_num }}]" cols="15" class="textfield default_value">{{ default_values[row_num] }}</textarea>
  326. {% else %}
  327. <input type="text" name="field_default_value[{{ row_num }}]" size="12" value="{{ default_values[row_num] }}" class="textfield default_value">
  328. {% endif %}
  329. </td>
  330. <td name="collation" class="nowrap">
  331. <span>{{ row['col_collation'] }}</span>
  332. <select lang="en" dir="ltr" name="field_collation[{{ row_num }}]" id="field_{{ row_num }}_4">
  333. <option value=""></option>
  334. {% for charset in charsets %}
  335. <optgroup label="{{ charset.name }}" title="{{ charset.description }}">
  336. {% for collation in charset.collations %}
  337. <option value="{{ collation.name }}" title="{{ collation.description }}"
  338. {{- collation.name == row['col_collation'] ? ' selected' }}>
  339. {{- collation.name -}}
  340. </option>
  341. {% endfor %}
  342. </optgroup>
  343. {% endfor %}
  344. </select>
  345. </td>
  346. <td class="nowrap" name="col_attribute">
  347. <span>{{ row['col_attribute']?(row['col_attribute']):"" }}</span>
  348. {% include 'columns_definitions/column_attribute.twig' with {
  349. 'column_number': row_num,
  350. 'ci': 5,
  351. 'ci_offset': 0,
  352. 'extracted_columnspec': {},
  353. 'column_meta': row['col_attribute'],
  354. 'submit_attribute': false,
  355. 'attribute_types': attribute_types,
  356. } only %}
  357. </td>
  358. <td class="nowrap" name="col_isNull">
  359. <span>{{ row['col_isNull'] ? 'Yes' | trans : 'No' | trans }}</span>
  360. <input name="field_null[{{ row_num }}]" id="field_{{ row_num }}_6" type="checkbox" value="YES" class="allow_null"
  361. {{- row['col_isNull'] is not empty and row['col_isNull'] != 'NO' and row['col_isNull'] != 'NOT NULL' ? ' checked' }}>
  362. </td>
  363. <td class="nowrap" name="col_extra">
  364. <span>{{ row['col_extra'] }}</span>
  365. <input name="col_extra[{{ row_num }}]" id="field_{{ row_num }}_7" type="checkbox" value="auto_increment"
  366. {{- row['col_extra'] is not empty and row['col_extra'] == 'auto_increment' ? ' checked' }}>
  367. </td>
  368. </tr>
  369. {% set row_num = row_num + 1 %}
  370. {% endfor %}
  371. </tbody>
  372. </table>
  373. {% include 'select_all.twig' with {
  374. 'theme_image_path': theme_image_path,
  375. 'text_dir' : text_dir,
  376. 'form_name' : 'tableslistcontainer',
  377. } only %}
  378. <button class="btn btn-link mult_submit change_central_columns" type="submit" name="edit_central_columns"
  379. value="edit central columns" title="{% trans 'Edit' %}">
  380. {{ get_icon('b_edit', 'Edit'|trans) }}
  381. </button>
  382. <button class="btn btn-link mult_submit" type="submit" name="delete_central_columns"
  383. value="remove_from_central_columns" title="{% trans 'Delete' %}">
  384. {{ get_icon('b_drop', 'Delete'|trans) }}
  385. </button>
  386. </form>
  387. </div>
  388. {% endif %}