input_box.twig 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. {# Get inputbox based on different column types (Foreign key, geometrical, enum) #}
  2. {% if foreigners and Relation_searchColumnInForeigners(foreigners, column_name) %}
  3. {% if foreign_data['disp_row'] is iterable %}
  4. <select name="criteriaValues[{{ column_index }}]"
  5. id="{{ column_id }}{{ column_index }}">
  6. {{ Relation_foreignDropdown(
  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. {{- Url_getCommon({'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 Util_getGISDatatypes() %}
  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' ~ Url_getCommon() %}
  38. {% set edit_str = Util_getIcon('b_edit', 'Edit/Insert'|trans) %}
  39. <span class="open_search_gis_editor">
  40. {{ Util_linkOrButton(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. size="40"
  92. class="{{ the_class }}"
  93. id="{{ column_id }}{{ column_index }}"
  94. {% if criteria_values[column_index] is defined %}
  95. value="{{ criteria_values[column_index] }}"
  96. {%- endif %} />
  97. {% endif %}