No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

editable_component.html 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <!--
  2. This file is part of Lodel 2 (https://github.com/OpenEdition)
  3. Copyright (C) 2015-2017 Cléo UMS-3287
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. -->
  15. {% macro input(fieldname, field, value='') -%}
  16. <label for="field_input_{{fieldname}}" class="col-sm-2 control-label">{{fieldname}}</label>
  17. <div class="col-xs-6">
  18. {% if value == None %}
  19. {% set value = '' %}
  20. {% endif %}
  21. {% if field.base_type == 'bool' %}
  22. <input id="field_input_{{fieldname}}" class="form-control" name="field_input_{{fieldname}}" type="checkbox" {% if value %}checked="checked"{% endif %} >
  23. {% elif field.base_type == 'password' %}
  24. <input id="{{fieldname}}" name="field_input_{{fieldname}}" class="form-control" type="password" value="{{sval}}" >
  25. {% elif field.base_type == 'char' or field.base_type == 'int' %}
  26. <input id="{{fieldname}}" class="form-control" name="field_input_{{fieldname}}" type="text" value="{{value}}" >
  27. {% elif field.base_type == 'text' %}
  28. <textarea class="form-control" name="field_input_{{fieldname}}">{{value}}</textarea>
  29. {% elif field.base_type == 'datetime' %}
  30. <!-- Handle date fields - Date format for datepicker is YY/MM/DD - TODO set this format with field.datetime_format (default is '%Y-%m-%d') -->
  31. <input class="form-control" type="text" id="field_input_{{fieldname}}" name="field_input_{{fieldname}}" />
  32. <script type="text/javascript">
  33. $(document).ready(function() {
  34. $('#field_input_{{fieldname}}')
  35. .datepicker({
  36. autoclose: true,
  37. format: 'yyyy/mm/dd'
  38. });
  39. });
  40. </script>
  41. {% elif field.base_type == 'ref' %}
  42. {% if value is iterable %}
  43. {% set sval=value|join(',') %}
  44. {% else %}
  45. {% set sval = value %}
  46. {% endif %}
  47. {% if field.directly_editable %}
  48. <input id="{{fieldname}}" class="form-control" name="field_input_{{fieldname}}" type="text" value="{{sval}}" >
  49. {% set l_classe = field.allowed_classes %}
  50. <p> Please enter uids to instances of {{ l_classe.__name__ }} separated by commas </p>
  51. {% else %}
  52. <input id="{{fieldname}}" class="form-control" name="field_input_{{fieldname}}" type="text" value="{{sval}}">
  53. {% endif %}
  54. {% else %}
  55. Unsupported base type "{{field.base_type}}" <br>
  56. {% endif %}
  57. </div>
  58. {%- endmacro %}