update templates

Former-commit-id: 0a3ca3a149
pull/726/head
Henrique Dias 2016-12-31 10:53:48 +00:00
parent eed8a9a28d
commit b6f42cc806
2 changed files with 70 additions and 75 deletions

View File

@ -1,34 +1,33 @@
{{ define "content" }} {{ define "content" }}
{{ with .Data }} {{ with .Data }}
<div id="editor" class="container" data-kind="{{ .Class }}"> <div id="editor" class="container" data-kind="{{ .Class }}">
<form method="POST" action="./"> <form method="POST" action="./">
{{ if or (eq .Class "frontmatter-only") (eq .Class "complete") }} {{- if or (eq .Class "frontmatter-only") (eq .Class "complete") }}
<div class="frontmatter" data-type="parent"> <div class="frontmatter" data-type="parent">
{{ template "blocks" .FrontMatter }} {{- template "blocks" .FrontMatter }}
<div class="button add">Add field</div> <div class="button add">Add field</div>
</div> </div>
{{ end }} {{- end }}
{{ if or (eq .Class "content-only") (eq .Class "complete") }} {{ if or (eq .Class "content-only") (eq .Class "complete") }}
{{ if (eq .Class "complete")}}
<h3>Body</h3>
{{ end }}
<div class="content">
<div id="editor-source" data-mode="{{ .Mode }}"></div>
<textarea name="content">{{ .Content }}</textarea>
</div>
{{ end }}
{{ if (eq .Class "complete")}} <div>
<h3>Body</h3> <button id="submit" type="submit" data-type="{{ .Class }}">
{{ end }} <span>
<div class="content"> <i class="material-icons" title="Save">save</i>
<div id="editor-source" data-mode="{{ .Mode }}"></div> </span>
<textarea name="content">{{ .Content }}</textarea> <span>save</span>
</div> </button>
{{ end }} </div>
</form>
<div>
<button id="submit" type="submit" data-type="{{ .Class }}">
<span>
<i class="material-icons" title="Save">save</i>
</span>
<span>save</span>
</button>
</div>
</form>
</div> </div>
{{ end }} {{ end }}

View File

@ -1,60 +1,56 @@
{{ define "blocks" }} {{ define "blocks" }}
{{ if .Fields }} {{ if .Fields }}<div class="group">{{ end }}
<div class="group"> {{- range $key, $value := .Fields }}
{{ end }} {{- if eq $value.Parent.Type "array" }}
{{ range $key, $value := .Fields }} <div id="{{ $value.Name }}-{{ $key }}" data-type="array-item">
{{ if eq $value.Parent.Type "array" }} {{- template "value" $value }}
<div id="{{ $value.Name }}-{{ $key }}" data-type="array-item"> <div class="action delete" data-delete="{{ $value.Name }}-{{ $key }}">
{{ template "value" $value }} <i class="material-icons" title="Close">close</i>
<div class="action delete" data-delete="{{ $value.Name }}-{{ $key }}"> </div>
<i class="material-icons" title="Close">close</i> </div>
</div> {{- else }}
</div> <div class="block" id="block-{{ $value.Name }}" data-content="{{ $value.Name }}">
{{ else }} <label for="{{ $value.Name }}">{{ $value.Title }}</label>
<div class="block" id="block-{{ $value.Name }}" data-content="{{ $value.Name }}"> {{ template "value" $value }}
<label for="{{ $value.Name }}">{{ $value.Title }}</label> <div class="action delete" data-delete="block-{{ $value.Name }}">
{{ template "value" $value }} <i class="material-icons" title="Close">close</i>
<div class="action delete" data-delete="block-{{ $value.Name }}"> </div>
<i class="material-icons" title="Close">close</i> </div>
</div> {{- end }}
</div> {{- end }}
{{ end }} {{- if .Fields }}</div>{{ end }}
{{ end }}
{{ if .Fields }}
</div>
{{ end }}
{{ range $key, $value := .Arrays }} {{- range $key, $value := .Arrays }}
{{ template "fielset" $value }} {{- template "fielset" $value }}
{{ end }} {{- end }}
{{ range $key, $value := .Objects }} {{- range $key, $value := .Objects }}
{{ template "fielset" $value }} {{- template "fielset" $value }}
{{ end }} {{- end }}
{{ end }} {{ end }}
{{ define "value" }} {{ define "value" }}
{{ if eq .HTMLType "textarea" }} {{- if eq .HTMLType "textarea" }}
<textarea class="scroll" name="{{ .Name }}" id="{{.Name }}" data-parent-type="{{ .Parent.Type }}">{{ .Content.Other }}</textarea> <textarea class="scroll" name="{{ .Name }}" id="{{.Name }}" data-parent-type="{{ .Parent.Type }}">{{ .Content.Other }}</textarea>
{{ else if eq .HTMLType "datetime" }} {{- else if eq .HTMLType "datetime" }}
<input name="{{ .Name }}" id="{{ .Name }}" value="{{ .Content.Other.Format "2006-01-02T15:04" }}" type="datetime-local" data-parent-type="{{ .Parent.Type }}"></input> <input name="{{ .Name }}" id="{{ .Name }}" value="{{ .Content.Other.Format "2006-01-02T15:04" }}" type="datetime-local" data-parent-type="{{ .Parent.Type }}"></input>
{{ else }} {{- else }}
<input name="{{ .Name }}" id="{{ .Name }}" value="{{ .Content.Other }}" type="{{ .HTMLType }}" data-parent-type="{{ .Parent.Type }}"></input> <input name="{{ .Name }}" id="{{ .Name }}" value="{{ .Content.Other }}" type="{{ .HTMLType }}" data-parent-type="{{ .Parent.Type }}"></input>
{{ end }} {{- end }}
{{ end }} {{ end }}
{{ define "fielset" }} {{ define "fielset" }}
<fieldset id="{{ .Name }}" data-type="{{ .Type }}"> <fieldset id="{{ .Name }}" data-type="{{ .Type }}">
{{ if not (eq .Title "") }} {{- if not (eq .Title "") }}
<h3>{{ .Title }}</h3> <h3>{{ .Title }}</h3>
{{ end }} {{- end }}
<div class="action add"> <div class="action add">
<i class="material-icons" title="Add">add</i> <i class="material-icons" title="Add">add</i>
</div> </div>
<div class="action delete" data-delete="{{ .Name }}"> <div class="action delete" data-delete="{{ .Name }}">
<i class="material-icons" title="Close">close</i> <i class="material-icons" title="Close">close</i>
</div> </div>
{{ template "blocks" .Content }} {{- template "blocks" .Content }}
</fieldset> </fieldset>
{{ end }} {{ end }}