input_box.twig 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. {# Get inputbox based on different column types (Foreign key, geometrical, enum) #}
  2. {% if foreigners and search_column_in_foreigners(foreigners, column_name) %}
  3. {% if foreign_data['disp_row'] is iterable %}
  4. <select name="criteriaValues[{{ column_index }}]"
  5. id="{{ column_id }}{{ column_index }}">
  6. {{ foreign_dropdown(
  7. foreign_data['disp_row'],
  8. foreign_data['foreign_field'],
  9. foreign_data['foreign_display'],
  10. '',
  11. foreign_max_limit
  12. ) }}
  13. </select>
  14. {% elseif foreign_data['foreign_link'] == true %}
  15. <input type="text"
  16. id="{{ column_id }}{{ column_index }}"
  17. name="criteriaValues[{{ column_index }}]"
  18. id="field_{{ column_name_hash }}[{{ column_index }}]"
  19. class="textfield"
  20. {% if criteria_values[column_index] is defined %}
  21. value="{{ criteria_values[column_index] }}"
  22. {% endif %}>
  23. <a class="ajax browse_foreign" href="browse_foreigners.php" data-post="
  24. {{- get_common({'db': db, 'table': table}, '') -}}
  25. &amp;field={{ column_name|url_encode }}&amp;fieldkey=
  26. {{- column_index }}&amp;fromsearch=1">
  27. {{ titles['Browse']|replace({"'": "\\'"})|raw }}
  28. </a>
  29. {% endif %}
  30. {% elseif column_type in get_gis_datatypes() %}
  31. <input type="text"
  32. name="criteriaValues[{{ column_index }}]"
  33. size="40"
  34. class="textfield"
  35. id="field_{{ column_index }}">
  36. {% if in_fbs %}
  37. {% set edit_url = 'gis_data_editor.php' ~ get_common() %}
  38. {% set edit_str = get_icon('b_edit', 'Edit/Insert'|trans) %}
  39. <span class="open_search_gis_editor">
  40. {{ link_or_button(edit_url, edit_str, [], '_blank') }}
  41. </span>
  42. {% endif %}
  43. {% elseif column_type starts with 'enum'
  44. or (column_type starts with 'set' and in_zoom_search_edit) %}
  45. {% set in_zoom_search_edit = false %}
  46. {% set value = column_type|e|slice(5, -1)|replace({'&#039;': ''})|split(', ') %}
  47. {% set cnt_value = value|length %}
  48. {#
  49. Enum in edit mode --> dropdown
  50. Enum in search mode --> multiselect
  51. Set in edit mode --> multiselect
  52. Set in search mode --> input (skipped here, so the 'else' section would handle it)
  53. #}
  54. {% if (column_type starts with 'enum' and not in_zoom_search_edit)
  55. or (column_type starts with 'set' and in_zoom_search_edit) %}
  56. <select name="criteriaValues[{{ column_index }}]"
  57. id="{{ column_id }}{{ column_index }}">
  58. {% else %}
  59. <select name="criteriaValues[{{ column_index }}]"
  60. id="{{ column_id }}{{ column_index }}"
  61. multiple="multiple"
  62. size="{{ min(3, cnt_value) }}">
  63. {% endif %}
  64. {# Add select options #}
  65. <option value=""></option>
  66. {% for i in 0..cnt_value - 1 %}
  67. {% if criteria_values[column_index] is defined
  68. and criteria_values[column_index] is iterable
  69. and value[i] in criteria_values[column_index] %}
  70. <option value="{{ value[i]|raw }}" selected>
  71. {{ value[i]|raw }}
  72. </option>
  73. {% else %}
  74. <option value="{{ value[i]|raw }}">
  75. {{ value[i]|raw }}
  76. </option>
  77. {% endif %}
  78. {% endfor %}
  79. </select>
  80. {% else %}
  81. {% set the_class = 'textfield' %}
  82. {% if column_type == 'date' %}
  83. {% set the_class = the_class ~ ' datefield' %}
  84. {% elseif column_type == 'datetime' or column_type starts with 'timestamp' %}
  85. {% set the_class = the_class ~ ' datetimefield' %}
  86. {% elseif column_type starts with 'bit' %}
  87. {% set the_class = the_class ~ ' bit' %}
  88. {% endif %}
  89. <input type="text"
  90. name="criteriaValues[{{ column_index }}]"
  91. data-type="{{ column_type }}"
  92. {{ html_attributes|raw }}
  93. size="40"
  94. class="{{ the_class }}"
  95. id="{{ column_id }}{{ column_index }}"
  96. {% if criteria_values[column_index] is defined %}
  97. value="{{ criteria_values[column_index] }}"
  98. {%- endif %}>
  99. {% endif %}