~evanj/cms

ref: 40c0e4fc7f8f794524c1f37f2c5d7355b4985475 cms/internal/s/tmpl/html/contenttype.html -rw-r--r-- 9.1 KiB
40c0e4fcEvan M Jones Chore(readme): Removing tag line. 1 year, 6 months ago
                                                                                
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!DOCTYPE html>
<html lang=en>

<head>
  {{ template "html/_head.html" }}
  <title>CMS | {{ .Space.Name }} | {{ .ContentType.Name }}</title>
</head>

<body class=contenttype style='max-width: 800px;'>
  <style>{{ template "css/main.css" }}</style>
  <main>
    {{ template "html/_header.html" $ }}
    <hr/>
    <article>
      <h1>{{ .Space.Name }}, {{ .ContentType.Name }}</h1>
      <details>
        <summary>Create a {{ .ContentType.Name }} Content</summary>
        <form method=POST action='/content/new' enctype='multipart/form-data'>
          <input required type=hidden name=space value="{{ .Space.ID }}" />
          <input required type=hidden name=contenttype value="{{ .ContentType.ID }}" />

          <br>
          <fieldset>
          {{ range .ContentType.Fields }}

            <label for="create-{{ .Type }}-{{ .Name }}">{{ .Name }}</label>
            <br>
            {{ if eq .Type "StringSmall" }}
              <input id="create-{{ .Type }}-{{ .Name }}" required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" />
            {{ end }}
            {{ if eq .Type "StringBig" }}
              <textarea id="create-{{ .Type }}-{{ .Name }}" required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" ></textarea>
            {{ end }}
            {{ if eq .Type "InputHTML" }}
              <textarea id="create-{{ .Type }}-{{ .Name }}" class='input-html' required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" ></textarea>
            {{ end }}
            {{ if eq .Type "InputMarkdown" }}
              <textarea id="create-{{ .Type }}-{{ .Name }}" class='input-markdown' required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" ></textarea>
            {{ end }}
            {{ if eq .Type "File" }}
              <input id="create-{{ .Type }}-{{ .Name }}" required type=file name="{{ .Type }}-{{ .Name }}" multiple=false />
            {{ end }}
            {{ if eq .Type "Date" }}
              <input id="create-{{ .Type }}-{{ .Name }}" required type=date name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" />
            {{ end }}
            {{ if eq .Type "Reference" }}
              <input id="create-{{ .Type }}-{{ .Name }}" class='output-ref' required type=hidden name="{{ .Type }}-{{ .Name }}" />
              <input class='input-ref' type=button value=Open />
              <dialog>
                <menu>
                  <div>
                    <p>Search for content to use as reference.</p>
                    <label for='search-ct'>Content type</label>
                    <br>
                    <input id='search-ct' autofocus class='input-contenttype' type=text placeholder='Search by content type' />
                    <br>
                    <br>
                    <label for='search-c'>Content name</label>
                    <br>
                    <input id='search-c' disabled class='input-content' type=text placeholder='Search by content name' />
                  </div>
                </menu>
              </dialog>
            {{ end }}
            {{ if eq .Type "ReferenceList" }}
              <input id="create-{{ .Type }}-{{ .Name }}" class='output-ref' required type=hidden name="{{ .Type }}-{{ .Name }}" />
              <input class='input-ref' type=button value=Open />
              <dialog>
                <menu>
                  <div>
                    <center>
                      <p>Search for content to use as reference.</p>
                    </center>
                    <input autofocus class='input-contenttype' type=text placeholder='Search by content type' />
                    <input disabled class='input-content' type=text placeholder='Search by content name' />
                    <div>
                      <input class=left type=button value=Clear />
                      <input class=right type=button value=Done />
                    </div>
                  </div>
                </menu>
              </dialog>
            {{ end }}
            <br>
            <br>
          {{ end }}
          <input type=submit value=Create />
          </fieldset>
          <br>
        </form>
      </details>

      <details>
        <summary>Update {{ .ContentType.Name }} Content Type</summary>
        <form method=POST action='/contenttype/update' enctype='multipart/form-data'>
          <input required type=hidden name=space value="{{ .Space.ID }}" />
          <input required type=hidden name=contenttype value="{{ .ContentType.ID }}" />
          <br>
          <fieldset>
            <legend>Content type name</legend>
            <label for='update-name'>Name</label>
            <br>
            <input id='update-name' autofocus required type=text name=name placeholder="name" value="{{ .ContentType.Name }}" />
          </fieldset>
          <br>
          <fieldset>
          <legend>Fields</legend>
          {{ range $index, $item := .ContentType.Fields }}

            {{ if eq $index 0 }}
              <div id='first-fieldset'>
                <input required type=hidden name="field_update_id_{{ inc $index }}" value="{{ .ID }}" />
                <input readonly="readonly" required type=text name="field_update_name_{{ inc $index }}" value="{{ .Name }}" />
                <select value="{{ .Type }}" readonly="readonly" required name="field_update_type_{{ inc $index }}">
                  <option disabled value>Field Type</option>
                  <option selected value="StringSmall">String Small</option>
                  <option disabled value="StringBig">String Big</option>
                  <option disabled value="InputHTML">HTML</option>
                  <option disabled value="InputMarkdown">Markdown</option>
                  <option disabled value="File">File</option>
                  <option disabled value="Date">Date</option>
                  <option disabled value="Reference">Reference</option>
                  <option disabled value="ReferenceList">ReferenceList</option>
                </select>
                <input disabled type=button value='Remove Field' />
              </div>
            {{ else }}
              <div>
                <input required type=hidden name="field_update_id_{{ inc $index }}" value="{{ .ID }}" />
                <input required type=text name="field_update_name_{{ inc $index }}" value="{{ .Name }}" />
                <select value="{{ .Type }}" readonly="readonly" required name="field_update_type_{{ inc $index }}">
                  <option disabled value>Field Type</option>
                  <option {{ if eq .Type "StringSmall" }}   selected {{ else }} disabled {{ end }} value="StringSmall">String Small</option>
                  <option {{ if eq .Type "StringBig" }}     selected {{ else }} disabled {{ end }} value="StringBig">String Big</option>
                  <option {{ if eq .Type "InputHTML" }}     selected {{ else }} disabled {{ end }} value="InputHTML">HTML</option>
                  <option {{ if eq .Type "InputMarkdown" }} selected {{ else }} disabled {{ end }} value="InputMarkdown">Markdown</option>
                  <option {{ if eq .Type "File" }}          selected {{ else }} disabled {{ end }} value="File">File</option>
                  <option {{ if eq .Type "Date" }}          selected {{ else }} disabled {{ end }} value="Date">Date</option>
                  <option {{ if eq .Type "Reference" }}     selected {{ else }} disabled {{ end }} value="Reference">Reference</option>
                  <option {{ if eq .Type "ReferenceList" }} selected {{ else }} disabled {{ end }} value="ReferenceList">ReferenceList</option>
                </select>
                <input type=button value='Remove Field' />
              </div>
            {{ end }}
            <br>
          {{ end }}
          <input type=button id='add-fieldbtn' value='Add Another Field' />
          <input type=submit value=Update />
          </fieldset>
          <br>
        </form>
      </details>

      <details>
        <summary>Delete {{ .ContentType.Name }} Content Type</summary>
        <form method=POST action='/contenttype/delete' enctype='multipart/form-data'>
          <input required type=hidden name=space value="{{ .Space.ID }}" />
          <input required type=hidden name=contenttype value="{{ .ContentType.ID }}" />
          <br>
          <fieldset>
            <input type=submit value=Delete />
          </fieldset>
          <br>
        </form>
      </details>

      <h2>Browse {{ .ContentType.Name }} Content</h2>
      {{ if .ContentList }}
        <ul>
          {{ range .ContentList }}
            <li> 
              <a href='/content/{{ $.Space.ID }}/{{ $.ContentType.ID }}/{{ .ID }}'>
                {{ (.MustValueByName "name").Value }}
              </a>
            </li>
          {{ end }}
        </ul>
      {{ else }}
        <p>No content has been created with a content type of {{ .ContentType.Name }}</p>
      {{ end }}

    </article>
    <hr/>
    {{ template "html/_footer.html" }}
  </main>
  <script src='//unpkg.com/tinymce@5.2.0/tinymce.min.js'></script>
  <script src='//unpkg.com/autocomplete.js@0.37.1/dist/autocomplete.min.js'></script>
  <script>{{ template "js/space.js" }}</script>
  <script>{{ template "js/content.js" $ }}</script>
</body>

</html>