summaryrefslogtreecommitdiff
path: root/themes/okadmin/templates/partials/inputs.liquid
blob: e79ff1432f96e9db1b75538e6abb8484bc82eae0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{% for pair in resource.spec %}
  {% assign name = pair[0] %}
  {% assign spec = pair[1] %}
  {% assign type = spec.type %}

  <div class="property {% if spec.disabled %}hidden{% endif %}">
    <label for="{{name}}">{{name | capitalize}}</label>

    {% if type == 'string' %}
      <input
        {% if spec.disabled %}
          disabled="true"
        {% endif %}
          name="{{name}}" type="text" value="{{spec.value}}">
    {% elsif type == 'text' %}
      <textarea
        {% if spec.disabled %}
          disabled="true"
        {% endif %}
        name="{{name}}">{{spec.value}}</textarea>
    {% elsif type == 'enum' %}
      <select
        {% if spec.disabled %}
          disabled="true"
        {% endif %}
        name="{{name}}">
        {% for option in spec.options %}
          <option value="{{option}}" {% if option == spec.value %}selected{% endif %}>{{option}}</option>
        {% endfor %}
      </select>
    {% elsif type == 'video' %}
      <div class="video group {% if spec.value.url %}loaded{% endif %}">
        <input name="{{name}}[url]" type="text" value="{{spec.value.url}}" class="url" placeholder="Enter a video URL">
        <input name="{{name}}[type]" type="text" value="{{spec.value.type}}" class="video-type" hidden>
        <input name="{{name}}[token]" type="text" value="{{spec.value.token}}" class="video-token" hidden>
        <label>Title</label>
        <input name="{{name}}[title]" type="text" value="{{spec.value.title}}" class="video-title">
        <label>Thumbnail</label>
        <input name="{{name}}[thumb]" type="text" value="{{spec.value.thumb}}" class="video-thumb">
      </div>
    {% elsif type == 'images' %}
      <div class="images">
        {% for image in spec.value %}
          <div class="image group">
            <input name="{{name}}[][url]" type="text" value="{{image.url}}" class="image-url">
            <label>Caption</label>
            <input name="{{name}}[][title]" type="text" value="{{image.title}}" class="image-title" placeholder="Title">
          </div>
        {% endfor %}
      </div>
      <script type="text/html" id="images-template">
        <div class="image group loaded">
          <input name="{{name}}[][url]" type="text" value="" class="url">
          <label>Caption</label>
          <input name="{{name}}[][title]" type="text" value="" class="caption">
        </div>
      </script>
      <input type="file" id="file" multiple>
    {% else %}
      <p><pre style="color: red">Admin template doesn't support '{{type}}' properties!</pre></p>
    {% endif %}
  </div>

{% endfor %}