~evanj/cms

ref: 40c0e4fc7f8f794524c1f37f2c5d7355b4985475 cms/internal/s/tmpl/html/content.html -rw-r--r-- 9.8 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
193
194
195
<!DOCTYPE html>
<html lang=en>
<head>
  {{ template "html/_head.html" }}
  <title>CMS | {{ .Space.Name }} | {{ .ContentType.Name }} | {{ (.Content.MustValueByName "name").Value }}</title>
</head>
<body class=content style='max-width: 800px;'>
  <style>{{ template "css/main.css" }}</style>
  <main>
    {{ template "html/_header.html" $ }}
    <hr/>
    <article>
      <h1>{{ .Space.Name }}, {{ .ContentType.Name }}, {{ (.Content.MustValueByName "name").Value }}</h1>
      <details>
        <summary>Update Content</summary>
        <form method=POST action='/content/update' enctype='multipart/form-data'>
          <input required type=hidden name=space value="{{ .Space.ID }}" />
          <input required type=hidden name=contenttype value="{{ .ContentType.ID }}" />
          <input required type=hidden name=content value="{{ .Content.ID }}" />

          <br>
          <fieldset>
          {{ range $index, $item := .ContentType.Fields }}
            {{ $val := $.Content.MustValueByName ( $item.Name ) }}

            {{ if $val }} 
              {{ if eq $index 0 }}
              {{ else }}
              <br>
              {{ end }}

              <label for="value_update_{{ $val.Type }}-{{ $val.ID }}">{{ $val.Name }}</label>
              <br>

              {{ if eq $val.Type "StringSmall" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" value="{{ $val.Value }}" required type=text name="value_update_{{ $val.Type }}-{{ $val.ID }}" placeholder="{{ $val.Name }}" />
              {{ end }}

              {{ if eq $val.Type "StringBig" }}
                <textarea {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" required type=text name="value_update_{{ $val.Type }}-{{ $val.ID }}" placeholder="{{ $val.Name }}">{{ $val.Value }}</textarea>
              {{ end }}

              {{ if eq $val.Type "InputHTML" }}
                <textarea {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" class='input-html' value="{{ $val.Value }}" required type=text name="value_update_{{ $val.Type }}-{{ $val.ID }}" placeholder="{{ $val.Name }}">{{ $val.Value }}</textarea>
              {{ end }}

              {{ if eq $val.Type "InputMarkdown" }}
                <textarea {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" class='input-markdown' value="{{ $val.Value }}" required type=text name="value_update_{{ $val.Type }}-{{ $val.ID }}" placeholder="{{ $val.Name }}">{{ $val.Value }}</textarea>
              {{ end }}

              {{ if eq $val.Type "File" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" value="{{ $val.Value }}" type=file name="value_update_{{ $val.Type }}-{{ $val.ID }}" multiple=false />
              {{ end }}

              {{ if eq $val.Type "Date" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" value="{{ $val.Value }}" required type=date name="value_update_{{ $val.Type }}-{{ $val.ID }}" placeholder="{{ $val.Name }}" />
              {{ end }}

              {{ if eq $val.Type "Reference" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" class='output-ref' required type=hidden value="{{ $val.Value }}" name="value_update_{{ $val.Type }}-{{ $val.ID}}" />
                <input class='input-ref' type=button value="{{ if  $val.RefName }}{{ $val.RefName }}{{ else }}Open{{ end}}"/>
                <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>
                  </menu>
                </dialog>
              {{ end }}

              {{ if eq $val.Type "ReferenceList" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" class='output-ref' required type=hidden value="{{ $val.Value }}" name="value_update_{{ $val.Type }}-{{ $val.ID }}" />
                <input class='input-ref' type=button value="{{ if  $val.RefListNames }}{{ $val.RefListNames }}{{ else }}Open{{ end}}"/>
                <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>
            {{ else }}
              {{ if eq $index 0 }}
              {{ else }}
              <br>
              {{ end }}
              <label for="value_update_{{ $val.Type }}-{{ $val.ID }}">{{ .Name }}</label>
              <br>

              {{ if eq .Type "StringSmall" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" />
              {{ end }}

              {{ if eq .Type "StringBig" }}
                <textarea {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" ></textarea>
              {{ end }}

              {{ if eq .Type "InputHTML" }}
                <textarea {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" class='input-html' required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" ></textarea>
              {{ end }}

              {{ if eq .Type "InputMarkdown" }}
                <textarea {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" class='input-markdown' required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" ></textarea>
              {{ end }}

              {{ if eq .Type "File" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" required type=file name="{{ .Type }}-{{ .Name }}" multiple=false />
              {{ end }}

              {{ if eq .Type "Date" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" required type=date name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" />
              {{ end }}

              {{ if eq .Type "Reference" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" 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>
                  </menu>
                </dialog>
              {{ end }}

              {{ if eq .Type "ReferenceList" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" 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>
            {{ end }}
          {{ end}}

          <input type=submit value=Update />
          </fieldset>
          <br>
        </form>
      </details>

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

    </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/content.js" $ }}</script>
</body>

</html>