input_box.twig 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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}, '', false) -}}
  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_str = Util_getIcon('b_edit', 'Edit/Insert'|trans) %}
  38. <span class="open_search_gis_editor">
  39. {{ Util_linkOrButton('gis_data_editor.php', [], edit_str, [], '_blank') }}
  40. </span>
  41. {% endif %}
  42. {% elseif column_type starts with 'enum'
  43. or (column_type starts with 'set' and in_zoom_search_edit) %}
  44. {% set in_zoom_search_edit = false %}
  45. {% set value = column_type|e|slice(5, -1)|replace({'&#039;': ''})|split(', ') %}
  46. {% set cnt_value = value|length %}
  47. {#
  48. Enum in edit mode --> dropdown
  49. Enum in search mode --> multiselect
  50. Set in edit mode --> multiselect
  51. Set in search mode --> input (skipped here, so the 'else' section would handle it)
  52. #}
  53. {% if (column_type starts with 'enum' and not in_zoom_search_edit)
  54. or (column_type starts with 'set' and in_zoom_search_edit) %}
  55. <select name="criteriaValues[{{ column_index }}]"
  56. id="{{ column_id }}{{ column_index }}">
  57. {% else %}
  58. <select name="criteriaValues[{{ column_index }}]"
  59. id="{{ column_id }}{{ column_index }}"
  60. multiple="multiple"
  61. size="{{ min(3, cnt_value) }}">
  62. {% endif %}
  63. {# Add select options #}
  64. <option value=""></option>
  65. {% for i in 0..cnt_value - 1 %}
  66. {% if criteria_values[column_index] is defined
  67. and criteria_values[column_index] is iterable
  68. and value[i] in criteria_values[column_index] %}
  69. <option value="{{ value[i]|raw }}" selected>
  70. {{ value[i]|raw }}
  71. </option>
  72. {% else %}
  73. <option value="{{ value[i]|raw }}">
  74. {{ value[i]|raw }}
  75. </option>
  76. {% endif %}
  77. {% endfor %}
  78. </select>
  79. {% else %}
  80. {% set the_class = 'textfield' %}
  81. {% if column_type == 'date' %}
  82. {% set the_class = the_class ~ ' datefield' %}
  83. {% elseif column_type == 'datetime' or column_type starts with 'timestamp' %}
  84. {% set the_class = the_class ~ ' datetimefield' %}
  85. {% elseif column_type starts with 'bit' %}
  86. {% set the_class = the_class ~ ' bit' %}
  87. {% endif %}
  88. <input type="text"
  89. name="criteriaValues[{{ column_index }}]"
  90. size="40"
  91. class="{{ the_class }}"
  92. id="{{ column_id }}{{ column_index }}"
  93. {% if criteria_values[column_index] is defined %}
  94. value="{{ criteria_values[column_index] }}"
  95. {%- endif %} />
  96. {% endif %}