create_item.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. {% extends "base.html" %}
  2. {% block title %}
  3. Create {{ type|name_by_type(False) }}
  4. {% endblock %}
  5. {% block content %}
  6. <main>
  7. <!-- bread crumb -->
  8. <nav aria-label="breadcrumb">
  9. <ol class="breadcrumb">
  10. <li class="breadcrumb-item"><a href="/">Home</a></li>
  11. <li class="breadcrumb-item"><a href="/{{ type }}">{{ type|name_by_type }}</a></li>
  12. <li class="breadcrumb-item active" aria-current="page">New</li>
  13. </ol>
  14. </nav>
  15. <!-- flash messages -->
  16. {% with messages = get_flashed_messages(with_categories=true) %}
  17. {% for category, msg in messages %}
  18. <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
  19. {{ msg }}
  20. <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  21. <span aria-hidden="true">&times;</span>
  22. </button>
  23. </div>
  24. {% endfor %}
  25. {% endwith %}
  26. <div class="container mt-5">
  27. <div class="border-bottom pt-3">
  28. <h1 >Create new {{ type|name_by_type(False) }}</h1>
  29. </div>
  30. <form class="pr-5" method="post" onsubmit="get_chips()" action="/{{ type }}/new">
  31. {{ form.hidden_tag() }}
  32. {% for field in form %}
  33. {% if field.name != "csrf_token" %}
  34. <!-- error message -->
  35. {% for error in field.errors %}
  36. <p class="text-danger">{{ error }}</p>
  37. {% endfor %}
  38. {% if field.name == 'value' %}
  39. <div class="input-group mt-3">
  40. <div class="input-group-prepend w-60 ml-0">
  41. {{ form.value.label(class="input-group-text w-80") }}
  42. {{ form.comparision.label(class="input-group-text w-40") }}
  43. </div>
  44. <div class="input-group-append w-40">
  45. {{ form.value2.label(class="input-group-text w-100") }}
  46. </div>
  47. </div>
  48. <div class="input-group mb-3">
  49. <div class="input-group w-40">
  50. {{ form.value(class="form-control w-50") }}
  51. </div>
  52. <div class="input-group w-20">
  53. {{ form.comparision(class="form-control") }}
  54. </div>
  55. <div class="input-group w-40">
  56. {{ form.value2(class="form-control") }}
  57. </div>
  58. </div>
  59. {% elif field.name != 'comparision' and field.name != 'value2' %}
  60. <div class="input-group my-3">
  61. <div class="input-group-prepend">
  62. {{ field.label(class="input-group-text fixed-label") }}
  63. </div>
  64. {% if field.name in chips %}
  65. <!-- choices for chips -->
  66. <input type="text" class="form-control" list="{{ field.name }}Opt" data-name="{{ field.name }}"
  67. onkeyup="filter_options(this)" oninput="add_chip(this, '{{ field.name }}')">
  68. <datalist id="{{ field.name }}Opt">
  69. {% for option in field.choices %}
  70. <option>
  71. {{ option.1 }}
  72. </option>
  73. {% endfor %}
  74. </datalist>
  75. {% else %}
  76. <!-- other fields -->
  77. {{ field(class="form-control") }}
  78. {% endif %}
  79. </div>
  80. <!-- chips area -->
  81. {% if field.name in chips %}
  82. <!-- hidden multi-select -->
  83. <select class="d-none" id="{{ field.name }}" name="{{ field.name }}" multiple>
  84. {% for option in field.choices %}
  85. <option value="{{ option.0 }}">
  86. {{ option.1 }}
  87. </option>
  88. {% endfor %}
  89. </select>
  90. <!-- chips -->
  91. <div id="chips_{{ field.name }}">
  92. </div>
  93. {% endif %}
  94. {% endif %}
  95. {% endif %}
  96. {% endfor %}
  97. <p>
  98. <button class="btn btn-primary px-5 my-3" type="submit">Create</button>
  99. </p>
  100. </form>
  101. </div>
  102. </main>
  103. {% endblock %}