~evanj/cms

ref: 715dccc30b27b8e6bdd6330ff3d106e66f577087 cms/internal/s/tmpl/html/contenttype.html -rw-r--r-- 16.8 KiB
715dccc3Evan M Jones Fix(new*List): Remove error, remove panic when list is of size zero. 1 year, 2 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<!DOCTYPE html>
<html lang=en>

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

<body class='contenttype bg-light'>
  <style>{{ template "css/main.css" }}</style>
  <main>
    {{ template "html/_header.html" $ }}
    <div class="pricing-header px-3 py-3 pt-md-5 pb-md-4 mx-auto text-center">
      <h1 class="display-4">{{.ContentType.Name}}</h1>
    </div>
    <article>
      <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 }}" />
        <div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
          <div class="modal-dialog modal-dialog-scrollable">
            <div class="modal-content">
              <div class="modal-header">
                <h5 class="modal-title" id="deleteModalLabel">Delete {{.ContentType.Name}}</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span>
                </button>
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                <button type="submit" class="btn btn-primary">Go</button>
              </div>
            </div>
          </div>
        </div>
      </form>

      <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 }}" />
        <div class="modal fade" id="createModal" tabindex="-1" role="dialog" aria-labelledby="createModalLabel" aria-hidden="true">
          <div class="modal-lg modal-dialog modal-dialog-scrollable">
            <div class="modal-content">
              <div class="modal-header">
                <h5 class="modal-title" id="createModalLabel">Create a new {{.ContentType.Name}} content</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span>
                </button>
              </div>
              <div class="modal-body">
                {{ range $index := .ContentType.Fields }}
                  <div class='form-group mb-3'>
                    <label for="create-{{ .Type }}-{{ .Name }}">{{title .Name}}</label>
                    {{ if eq .Type "StringSmall" }}
                      <input class="form-control" id="create-{{ .Type }}-{{ .Name }}" required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ title .Name }}" />
                    {{ end }}
                    {{ if eq .Type "StringBig" }}
                      <textarea class="form-control" id="create-{{ .Type }}-{{ .Name }}" required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ title .Name }}" ></textarea>
                    {{ end }}
                    {{ if eq .Type "InputHTML" }}
                      <textarea class="form-control input-html" id="create-{{ .Type }}-{{ .Name }}" required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ title .Name }}" ></textarea>
                    {{ end }}
                    {{ if eq .Type "InputMarkdown" }}
                      <textarea class="form-control input-markdown" id="create-{{ .Type }}-{{ .Name }}" required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ title .Name }}" ></textarea>
                    {{ end }}
                    {{ if eq .Type "File" }}
                      <div class="form-file mb-3">
                        <input name="{{ .Type }}-{{ .Name }}" multiple=false id="create-{{ .Type }}-{{ .Name }}" required type="file" class="form-file-input" id="inputGroupFileAddon{{ $index }}">
                        <label class="form-file-label" for="inputGroupFileAddon{{ $index }}">
                          <span class="form-file-text">Choose file...</span>
                          <span class="form-file-button">Browse</span>
                        </label>
                      </div>
                    {{ end }}
                    {{ if eq .Type "Date" }}
                      <input class="form-control" id="create-{{ .Type }}-{{ .Name }}" required type=date name="{{ .Type }}-{{ .Name }}" placeholder="{{ title .Name }}" />
                    {{ end }}
                    {{ if eq .Type "Reference" }}
                      <div class='ref-modal'>
                        <input id="create-{{ .Type }}-{{ .Name }}" class='output-ref' required type=hidden name="{{ .Type }}-{{ .Name }}" />
                        <input data-toggle="modal" data-target="#ref-modal-{{ .Type }}-{{ .Name }}" class="form-control input-ref w-auto" type=button value=Open />
                        <div data-focus="false" class="modal fade" id="ref-modal-{{ .Type }}-{{ .Name }}" tabindex="-1" role="dialog" aria-labelledby="refModalLabel" aria-hidden="true">
                          <div class="modal-dialog modal-dialog-centered">
                            <div class="modal-content">
                              <div class="modal-header">
                                <h5 class="modal-title" id="ref-modal-label-{{ .Type }}-{{ .Name }}">Find Content for Reference</h5>
                                <button type="button" class="close" data-dismiss-inner="modal" aria-label="Close">
                                  <span aria-hidden="true">&times;</span>
                                </button>
                              </div>
                              <div class='modal-body overflow-initial'>
                                <label for='search-ct-{{ .Type }}-{{ .Name }}' class='d-block'>Content Type</label>
                                <input id='search-ct-{{ .Type }}-{{ .Name }}' class='mb-3 form-control input-contenttype' type=text placeholder='Search by Content Type' />
                                <label for='search-c-{{ .Type }}-{{ .Name }}' class='d-block'>Content Name</label>
                                <input id='search-c-{{ .Type }}-{{ .Name }}' disabled class='mb-3 form-control input-content' type=text placeholder='Search by Content Name' />
                              </div>
                              <div class="modal-footer">
                                <button type="button" class="btn btn-secondary btn-clear">Clear</button>
                                <button type="button" class="btn btn-primary" data-dismiss-inner="modal">Go</button>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    {{ end }}
                    {{ if eq .Type "ReferenceList" }}
                      <div class='ref-modal ref-list'>
                        <input id="create-{{ .Type }}-{{ .Name }}" class='output-ref' required type=hidden name="{{ .Type }}-{{ .Name }}" />
                        <input data-toggle="modal" data-target="#ref-modal-{{ .Type }}-{{ .Name }}" class="form-control input-ref w-auto" type=button value=Open />
                        <div data-focus="false" class="modal fade" id="ref-modal-{{ .Type }}-{{ .Name }}" tabindex="-1" role="dialog" aria-labelledby="refModalLabel" aria-hidden="true">
                          <div class="modal-dialog modal-dialog-centered">
                            <div class="modal-content">
                              <div class="modal-header">
                                <h5 class="modal-title" id="ref-modal-label-{{ .Type }}-{{ .Name }}">Find Content for Reference</h5>
                                <button type="button" class="close" data-dismiss-inner="modal" aria-label="Close">
                                  <span aria-hidden="true">&times;</span>
                                </button>
                              </div>
                              <div class='modal-body overflow-initial'>
                                <label for='search-ct-{{ .Type }}-{{ .Name }}' class='d-block'>Content Type</label>
                                <input id='search-ct-{{ .Type }}-{{ .Name }}' class='mb-3 form-control input-contenttype' type=text placeholder='Search by Content Type' />
                                <label for='search-c-{{ .Type }}-{{ .Name }}' class='d-block'>Content Name</label>
                                <input id='search-c-{{ .Type }}-{{ .Name }}' disabled class='mb-3 form-control input-content' type=text placeholder='Search by Content Name' />
                              </div>
                              <div class="modal-footer">
                                <button type="button" class="btn btn-secondary btn-clear">Clear</button>
                                <button type="button" class="btn btn-primary" data-dismiss-inner="modal">Go</button>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    {{ end }}
                  </div>
                {{ end }}
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                <button type="submit" class="btn btn-primary">Go</button>
              </div>
            </div>
          </div>
        </div>
      </form>

      <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 }}" />
        <div class="modal fade" id="updateModal" tabindex="-1" role="dialog" aria-labelledby="Update {{.ContentType.Name}}" aria-hidden="true">
          <div class="modal-dialog modal-dialog-scrollable">
            <div class="modal-content">
              <div class="modal-header">
                <h5 class="modal-title" id="contenttypeModalLabel">Update {{.ContentType.Name}}</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span>
                </button>
              </div>
              <div class="modal-body">
                <label for="contenttypeName">Name</label>
                <input value="{{.ContentType.Name}}" name=name type=text id="contenttypeName" class="mb-3 form-control" placeholder="Name" required>
                <div>
                  {{ range $index, $item := .ContentType.Fields }}
                    {{ if eq $index 0 }}
                      <div id='first-fieldset' class='container-fluid px-0 mb-3'>
                        <label for="fieldsetFirst">Fields</label>
                        <input required type=hidden name="field_update_id_{{ inc $index }}" value="{{ .ID }}" />
                        <input class="mb-3 form-control" readonly="readonly" required type=text name="field_update_name_{{ inc $index }}" value="{{ .Name }}" />
                        <div class='form-group row'>
                          <div class='col-6'>
                            <select class="w-100 form-control" 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>
                          </div>
                          <div class='col-6'>
                            <button class='w-100 btn btn-primary' disabled type=button>Remove Field</button>
                          </div>
                        </div>
                      </div>
                    {{ else }}
                      <div class='container-fluid px-0 mb-3'>
                        <input required type=hidden name="field_update_id_{{ inc $index }}" value="{{ .ID }}" />
                        <input class="mb-3 form-control" required type=text name="field_update_name_{{ inc $index }}" value="{{ .Name }}" />
                        <div class='form-group row'>
                          <div class='col-6'>
                            <select class="w-100 form-control" 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>
                          </div>
                          <div class='col-6'>
                            <button class='w-100 btn btn-primary btn-remove' type=button>Remove Field</button>
                          </div>
                        </div>
                      </div>
                    {{ end }}
                  {{ end }}
                </div>

                <a href='#' class='btn btn-link' id='add-fieldbtn'>Add Another Field</a>
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                <button type="submit" class="btn btn-primary">Go</button>
              </div>
            </div>
          </div>
        </div>
      </form>

      <div class="container">
        <div class='row'>
          <div class='offset-lg-3 col-lg-6'>
            <div class="my-3 p-3 bg-white rounded shadow-sm">
                <small class="d-block text-right float-right" data-toggle="modal" data-target="#createModal">
                  <a href="#">Create a new content</a>
                </small>
                <h6 class="border-bottom border-gray pb-2 mb-0">Your {{.ContentType.Name}} content</h6>
              {{ if .ContentList.List }}
                {{ range .ContentList.List }}
                <div class="media text-muted pt-3">
                  <a href='/content/{{ $.Space.ID }}/{{ $.ContentType.ID }}/{{ .ID }}'  class="d-block media-body pb-3 mb-0 small lh-125 border-bottom border-gray">
                    <strong class="d-block text-gray-dark">
                      {{ (.MustValueByName "name").Value }}
                    </strong>
                  </a>
                </div>
                {{ end }}
                {{ if .ContentList.More }}
                <small class="d-block text-right mt-3">
                  <a href="/contenttype/{{ .Space.ID }}/{{ .ContentType.ID }}?before={{ .ContentList.Last.ID }}">Load more</a>
                </small>
                {{ end }}
              {{ else }}
                <div class="mt-3 alert alert-primary" role="alert">
                  You haven't created any content yet. 
                </div>
              {{ end }}
            </div>
          </div>
        </div>
      </div>
    </article>
    {{ template "html/_footer.html" }}
  </main>
  {{ template "html/_scripts.html" }}
  <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/main.js" $ }}</script>
  <script>{{ template "js/space.js" $ }}</script>
  <script>{{ template "js/content.js" $ }}</script>
</body>

</html>