Refine HTML layout

This commit improves the page structure and unifies the layout. Some
reusable parts of the HTML code have been moved into
page_fragments.html.
main 0.6.0
Jan Dittberner 5 years ago
parent 1f32b6d25b
commit ea9641cfb1

@ -219,7 +219,9 @@ func motionListHandler(w http.ResponseWriter, r *http.Request) {
templateContext.PrevPage = params.Page - 1 templateContext.PrevPage = params.Page - 1
} }
renderTemplate(w, r, []string{"motions.html", "motion_fragments.html", "header.html", "footer.html"}, templateContext) renderTemplate(w, r, []string{
"motions.html", "motion_fragments.html", "page_fragments.html", "header.html", "footer.html",
}, templateContext)
} }
func motionHandler(w http.ResponseWriter, r *http.Request) { func motionHandler(w http.ResponseWriter, r *http.Request) {
@ -252,7 +254,7 @@ func motionHandler(w http.ResponseWriter, r *http.Request) {
} }
templateContext.Decision = decision templateContext.Decision = decision
templateContext.PageTitle = fmt.Sprintf("Motion %s: %s", decision.Tag, decision.Title) templateContext.PageTitle = fmt.Sprintf("Motion %s: %s", decision.Tag, decision.Title)
renderTemplate(w, r, []string{"motion.html", "motion_fragments.html", "header.html", "footer.html"}, templateContext) renderTemplate(w, r, []string{"motion.html", "motion_fragments.html", "page_fragments.html", "header.html", "footer.html"}, templateContext)
} }
func singleDecisionHandler(w http.ResponseWriter, r *http.Request, tag string, handler func(http.ResponseWriter, *http.Request)) { func singleDecisionHandler(w http.ResponseWriter, r *http.Request, tag string, handler func(http.ResponseWriter, *http.Request)) {
@ -326,7 +328,7 @@ func (a *withDrawMotionAction) Handle(w http.ResponseWriter, r *http.Request) {
http.Error(w, http.StatusText(http.StatusPreconditionFailed), http.StatusPreconditionFailed) http.Error(w, http.StatusText(http.StatusPreconditionFailed), http.StatusPreconditionFailed)
return return
} }
templates := []string{"withdraw_motion_form.html", "header.html", "footer.html", "motion_fragments.html"} templates := []string{"withdraw_motion_form.html", "header.html", "footer.html", "motion_fragments.html", "page_fragments.html"}
var templateContext struct { var templateContext struct {
PageTitle string PageTitle string
Decision *DecisionForDisplay Decision *DecisionForDisplay
@ -366,7 +368,7 @@ func (h *newMotionHandler) Handle(w http.ResponseWriter, r *http.Request) {
http.Error(w, http.StatusText(http.StatusPreconditionFailed), http.StatusPreconditionFailed) http.Error(w, http.StatusText(http.StatusPreconditionFailed), http.StatusPreconditionFailed)
} }
templates := []string{"create_motion_form.html", "header.html", "footer.html"} templates := []string{"create_motion_form.html", "page_fragments.html", "header.html", "footer.html"}
var templateContext struct { var templateContext struct {
Form NewDecisionForm Form NewDecisionForm
PageTitle string PageTitle string
@ -428,7 +430,7 @@ func (a editMotionAction) Handle(w http.ResponseWriter, r *http.Request) {
http.Error(w, http.StatusText(http.StatusPreconditionFailed), http.StatusPreconditionFailed) http.Error(w, http.StatusText(http.StatusPreconditionFailed), http.StatusPreconditionFailed)
return return
} }
templates := []string{"edit_motion_form.html", "header.html", "footer.html"} templates := []string{"edit_motion_form.html", "page_fragments.html", "header.html", "footer.html"}
var templateContext struct { var templateContext struct {
Form EditDecisionForm Form EditDecisionForm
PageTitle string PageTitle string
@ -560,7 +562,7 @@ func (h *directVoteHandler) Handle(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/motions/", http.StatusMovedPermanently) http.Redirect(w, r, "/motions/", http.StatusMovedPermanently)
default: default:
templates := []string{"direct_vote_form.html", "header.html", "footer.html", "motion_fragments.html"} templates := []string{"direct_vote_form.html", "header.html", "footer.html", "motion_fragments.html", "page_fragments.html"}
var templateContext struct { var templateContext struct {
Decision *DecisionForDisplay Decision *DecisionForDisplay
VoteChoice VoteChoice VoteChoice VoteChoice
@ -601,7 +603,7 @@ func (h *proxyVoteHandler) Handle(w http.ResponseWriter, r *http.Request) {
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return return
} }
templates := []string{"proxy_vote_form.html", "header.html", "footer.html", "motion_fragments.html"} templates := []string{"proxy_vote_form.html", "header.html", "footer.html", "motion_fragments.html", "page_fragments.html"}
var templateContext struct { var templateContext struct {
Form ProxyVoteForm Form ProxyVoteForm
Decision *DecisionForDisplay Decision *DecisionForDisplay

@ -1,74 +1,66 @@
{{ template "header.html" . }} {{ template "header.html" . }}
<div class="column"> {{ template "return_header" . }}
<div class="ui basic segment"> <div class="ui raised segment">
<div class="ui floated right secondary menu"> <form action="/newmotion/" method="post">
<a href="/motions/" class="item" title="Show all votes">Back to motions</a>
</div>
</div>
</div>
<div class="column">
<div class="ui raised segment">
<form action="/newmotion/" method="post">
{{ csrfField }} {{ csrfField }}
<div class="ui form{{ if .Form.Errors }} error{{ end }}"> <div class="ui form{{ if .Form.Errors }} error{{ end }}">
<div class="three fields"> <div class="three fields">
<div class="field"> <div class="field">
<label>ID:</label> <label>ID:</label>
(generated on submit) (generated on submit)
</div>
<div class="field">
<label>Proponent:</label>
{{ .Voter.Name }}
</div>
<div class="field">
<label>Proposed date/time:</label>
(auto filled to current date/time)
</div>
</div> </div>
<div class="required field{{ if .Form.Errors.Title }} error{{ end }}"> <div class="field">
<label for="Title">Title:</label> <label>Proponent:</label>
<input id="Title" name="Title" type="text" value="{{ .Form.Title }}"> {{ .Voter.Name }}
</div> </div>
<div class="required field{{ if .Form.Errors.Content }} error{{ end }}"> <div class="field">
<label for="Content">Text:</label> <label>Proposed date/time:</label>
<textarea id="Content" name="Content">{{ .Form.Content }}</textarea> (auto filled to current date/time)
</div> </div>
<div class="two fields"> </div>
<div class="required field{{ if .Form.Errors.VoteType }} error{{ end }}"> <div class="required field{{ if .Form.Errors.Title }} error{{ end }}">
<label for="VoteType">Vote type:</label> <label for="Title">Title:</label>
<select id="VoteType" name="VoteType"> <input id="Title" name="Title" type="text" value="{{ .Form.Title }}">
<option value="0" </div>
{{ if eq "0" .Form.VoteType }}selected{{ end }}> <div class="required field{{ if .Form.Errors.Content }} error{{ end }}">
Motion <label for="Content">Text:</label>
</option> <textarea id="Content" name="Content">{{ .Form.Content }}</textarea>
<option value="1" </div>
{{ if eq "1" .Form.VoteType }}selected{{ end }}> <div class="two fields">
Veto <div class="required field{{ if .Form.Errors.VoteType }} error{{ end }}">
</option> <label for="VoteType">Vote type:</label>
</select> <select id="VoteType" name="VoteType">
</div> <option value="0"
<div class="required field{{ if .Form.Errors.Due }} error{{ end }}"> {{ if eq "0" .Form.VoteType }}selected{{ end }}>
<label for="Due">Due: (autofilled from chosen Motion
option)</label> </option>
<select id="Due" name="Due"> <option value="1"
<option value="+3 days">In 3 Days</option> {{ if eq "1" .Form.VoteType }}selected{{ end }}>
<option value="+7 days">In 1 Week</option> Veto
<option value="+14 days">In 2 Weeks</option> </option>
<option value="+28 days">In 4 Weeks</option> </select>
</select>
</div>
</div> </div>
{{ with .Form.Errors }} <div class="required field{{ if .Form.Errors.Due }} error{{ end }}">
<label for="Due">Due: (autofilled from chosen
option)</label>
<select id="Due" name="Due">
<option value="+3 days">In 3 Days</option>
<option value="+7 days">In 1 Week</option>
<option value="+14 days">In 2 Weeks</option>
<option value="+28 days">In 4 Weeks</option>
</select>
</div>
</div>
{{ with .Form.Errors }}
<div class="ui error message"> <div class="ui error message">
{{ with .Title }}<p>{{ . }}</p>{{ end }} {{ with .Title }}<p>{{ . }}</p>{{ end }}
{{ with .Content }}<p>{{ . }}</p>{{ end }} {{ with .Content }}<p>{{ . }}</p>{{ end }}
{{ with .VoteType }}<p>{{ . }}</p>{{ end }} {{ with .VoteType }}<p>{{ . }}</p>{{ end }}
{{ with .Due }}<p>{{ . }}</p>{{ end }} {{ with .Due }}<p>{{ . }}</p>{{ end }}
</div> </div>
{{ end }} {{ end }}
<button class="ui button" type="submit">Propose</button> <button class="ui button" type="submit">Propose</button>
</div> </div>
</form> </form>
</div>
</div> </div>
{{ template "footer.html" . }} {{ template "footer.html" . }}

@ -1,17 +1,23 @@
{{ template "header.html" . }} {{ template "header.html" . }}
<div class="column"> <div class="ui container">
<div class="ui negative message"> <div class="ui negative icon message">
<div class="header.html">You are not authorized to act here!</div> <i class="ban icon "></i>
<p>If you think this is in error, please contact the administrator.</p> <div class="content">
<p>If you don't know who that is, it is definitely not an error ;)</p> <div class="header">You are not authorized to act here!</div>
{{ if .Emails }} <p>If you think this is in error, please contact the administrator.</p>
<p>The following addresses were present in your certificate:<p> <p>If you don't know who that is, it is definitely not an error ;)</p>
<ul> {{ if .Emails }}
{{ range .Emails }} <p>The following addresses were present in your certificate:<p>
<li>{{ . }}</li> <div class="ui list">
{{ range .Emails }}
<div class="item">
<i class="address card outline icon"></i>
<div class="content">{{ . }}</div>
</div>
{{ end }}
</div>
{{ end }} {{ end }}
</ul> </div>
{{ end }}
</div> </div>
</div> </div>
{{ template "footer.html" . }} {{ template "footer.html" . }}

@ -1,31 +1,23 @@
{{ template "header.html" . }} {{ template "header.html" . }}
<div class="column"> {{ template "return_header" . }}
<div class="ui basic segment">
<div class="ui floated right secondary menu">
<a href="/motions/" class="item" title="Show all votes">Back to motions</a>
</div>
</div>
</div>
{{ with .Decision }} {{ with .Decision }}
<div class="column">
<div class="ui raised segment"> <div class="ui raised segment">
{{ template "motion_fragment" . }} {{ template "motion_fragment" . }}
</div> </div>
</div>
{{ end }} {{ end }}
<form action="/vote/{{ .Decision.Tag }}/{{ .VoteChoice }}" method="post"> <form action="/vote/{{ .Decision.Tag }}/{{ .VoteChoice }}" method="post">
{{ csrfField }} {{ csrfField }}
<div class="ui form"> <div class="ui form">
{{ if eq 1 .VoteChoice }} {{ if eq 1 .VoteChoice }}
<button class="ui right labeled green icon button" type="submit"><i class="check circle icon"></i> <button class="ui right labeled green icon button" type="submit"><i class="check circle icon"></i>
Vote {{ .VoteChoice }}</button> Vote {{ .VoteChoice }}</button>
{{ else if eq -1 .VoteChoice }} {{ else if eq -1 .VoteChoice }}
<button class="ui right labeled red icon button" type="submit"><i class="minus circle icon"></i> <button class="ui right labeled red icon button" type="submit"><i class="minus circle icon"></i>
Vote {{ .VoteChoice }}</button> Vote {{ .VoteChoice }}</button>
{{ else }} {{ else }}
<button class="ui right labeled grey icon button" type="submit"><i class="circle icon"></i> <button class="ui right labeled grey icon button" type="submit"><i class="circle icon"></i>
Vote {{ .VoteChoice }}</button> Vote {{ .VoteChoice }}</button>
{{ end }} {{ end }}
</div> </div>
</form> </form>
{{ template "footer.html" . }} {{ template "footer.html" . }}

@ -1,72 +1,66 @@
{{ template "header.html" . }} {{ template "header.html" . }}
<div class="column"> {{ template "return_header" . }}
<div class="ui floated right secondary menu"> <div class="ui raised segment">
<a href="/motions/" class="item" title="Show all votes">Back to <form action="/motions/{{ .Form.Decision.Tag }}/edit" method="post">
motions</a> {{ csrfField }}
</div> <div class="ui form{{ if .Form.Errors }} error{{ end }}">
</div> <div class="three fields">
<div class="column"> <div class="field">
<div class="ui raised segment"> <label>ID:</label>
<form action="/motions/{{ .Form.Decision.Tag }}/edit" method="post"> <a href="/motions/{{ .Form.Decision.Tag }}">{{ .Form.Decision.Tag }}</a>
<div class="ui form{{ if .Form.Errors }} error{{ end }}">
<div class="three fields">
<div class="field">
<label>ID:</label>
<a href="/motions/{{ .Form.Decision.Tag }}">{{ .Form.Decision.Tag }}</a>
</div>
<div class="field">
<label>Proponent:</label>
{{ .Voter.Name }}
</div>
<div class="field">
<label>Proposed date/time:</label>
{{ .Form.Decision.Proposed|date "2006-01-02 15:04:05 UTC" }}
</div>
</div> </div>
<div class="required field{{ if .Form.Errors.Title }} error{{ end }}"> <div class="field">
<label for="Title">Title:</label> <label>Proponent:</label>
<input name="Title" type="text" value="{{ .Form.Title }}"> {{ .Voter.Name }}
</div> </div>
<div class="required field{{ if .Form.Errors.Content }} error{{ end }}"> <div class="field">
<label for="Content">Text:</label> <label>Proposed date/time:</label>
<textarea name="Content">{{ .Form.Content }}</textarea> {{ .Form.Decision.Proposed|date "2006-01-02 15:04:05 UTC" }}
</div> </div>
<div class="two fields"> </div>
<div class="required field{{ if .Form.Errors.VoteType }} error{{ end }}"> <div class="required field{{ if .Form.Errors.Title }} error{{ end }}">
<label for="VoteType">Vote type:</label> <label for="Title">Title:</label>
<select name="VoteType"> <input name="Title" type="text" value="{{ .Form.Title }}">
<option value="0" </div>
{{ if eq "0" .Form.VoteType }}selected{{ end }}> <div class="required field{{ if .Form.Errors.Content }} error{{ end }}">
Motion <label for="Content">Text:</label>
</option> <textarea name="Content">{{ .Form.Content }}</textarea>
<option value="1" </div>
{{ if eq "1" .Form.VoteType }}selected{{ end }}> <div class="two fields">
Veto <div class="required field{{ if .Form.Errors.VoteType }} error{{ end }}">
</option> <label for="VoteType">Vote type:</label>
</select> <select name="VoteType">
</div> <option value="0"
<div class="required field{{ if .Form.Errors.Due }} error{{ end }}"> {{ if eq "0" .Form.VoteType }}selected{{ end }}>
<label for="Due">Due: (autofilled from chosen Motion
option)</label> </option>
<select name="Due"> <option value="1"
<option value="+3 days">In 3 Days</option> {{ if eq "1" .Form.VoteType }}selected{{ end }}>
<option value="+7 days">In 1 Week</option> Veto
<option value="+14 days">In 2 Weeks</option> </option>
<option value="+28 days">In 4 Weeks</option> </select>
</select>
</div>
</div> </div>
{{ with .Form.Errors }} <div class="required field{{ if .Form.Errors.Due }} error{{ end }}">
<label for="Due">Due: (autofilled from chosen
option)</label>
<select name="Due">
<option value="+3 days">In 3 Days</option>
<option value="+7 days">In 1 Week</option>
<option value="+14 days">In 2 Weeks</option>
<option value="+28 days">In 4 Weeks</option>
</select>
</div>
</div>
{{ with .Form.Errors }}
<div class="ui error message"> <div class="ui error message">
{{ with .Title }}<p>{{ . }}</p>{{ end }} {{ with .Title }}<p>{{ . }}</p>{{ end }}
{{ with .Content }}<p>{{ . }}</p>{{ end }} {{ with .Content }}<p>{{ . }}</p>{{ end }}
{{ with .VoteType }}<p>{{ . }}</p>{{ end }} {{ with .VoteType }}<p>{{ . }}</p>{{ end }}
{{ with .Due }}<p>{{ . }}</p>{{ end }} {{ with .Due }}<p>{{ . }}</p>{{ end }}
</div> </div>
{{ end }} {{ end }}
<button class="ui button" type="submit">Propose</button> <button class="ui button" type="submit">Propose</button>
</div> </div>
</form> </form>
</div>
</div> </div>
{{ template "footer.html" . }} {{ template "footer.html" . }}

@ -1,12 +1,12 @@
{{ define "footer.html" }} {{ define "footer.html" }}
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function () {
$('.message .close').on('click', function() { $('.message .close').on('click', function () {
$(this).closest('.message').transition('fade'); $(this).closest('.message').transition('fade');
}); });
}); });
</script> </script>
</body> </body>
</html> </html>
{{ end }} {{ end }}

@ -7,20 +7,35 @@
<link rel="stylesheet" type="text/css" href="/static/semantic.min.css"/> <link rel="stylesheet" type="text/css" href="/static/semantic.min.css"/>
<script type="text/javascript" src="/static/jquery.min.js"></script> <script type="text/javascript" src="/static/jquery.min.js"></script>
<script type="text/javascript" src="/static/semantic.min.js"></script> <script type="text/javascript" src="/static/semantic.min.js"></script>
<link rel="icon" href="/static/images/favicon.ico">
</head> </head>
<body class="site"> <body id="cacert-boardvoting">
<div class="pusher">
<div class="ui vertical masthead center aligned segment">
<div class="ui left secondary container">
<img src="/static/images/CAcert-logo-colour.svg" alt="CAcert" height="40rem"/>
</div>
<div class="ui text container">
<h1 class="ui header">
{{ template "pagetitle" . }}
{{ if .Voter }}
<div class="ui left pointing label">Authenticated as {{ .Voter.Name }} &lt;{{ .Voter.Reminder }}&gt;
</div>{{ end }}
</h1>
</div>
</div>
</div>
<div class="ui container"> <div class="ui container">
<h1 class="ui header">{{ template "pagetitle" . }}{{ if .Voter }}<div class="ui left pointing label">Authenticated as {{ .Voter.Name }} &lt;{{ .Voter.Reminder }}&gt;</div>{{ end }}</h1>
{{ with .Flashes }} {{ with .Flashes }}
<div class="ui info message"> <div class="basic segment">
<i class="close icon"></i> <div class="ui info message">
<div class="ui list"> <i class="close icon"></i>
{{ range . }} <div class="ui list">
<div class="ui item">{{ . }}</div> {{ range . }}
{{ end }} <div class="ui item">{{ . }}</div>
{{ end }}
</div>
</div> </div>
</div> </div>
{{ end }} {{ end }}
</div>
<div class="ui one column grid container">
{{ end }} {{ end }}

@ -1,19 +1,20 @@
{{ template "header.html" . }} {{ template "header.html" . }}
{{ $voter := .Voter }} {{ $voter := .Voter }}
<div class="column"> <div class="ui basic segment">
<div class="ui basic segment"> <div class="ui secondary pointing menu">
<div class="ui floated right secondary menu"> <a href="/motions/" class="item" title="Show all votes">All votes</a>
<a href="/motions/" class="item" title="Show all votes">All votes</a> {{ if $voter }}
{{ if $voter }}<a href="/motions/?unvoted=1" class="item" title="Show my outstanding votes">My outstanding votes</a>{{ end }} <a href="/motions/?unvoted=1" class="item" title="Show my outstanding votes">My outstanding votes</a>
</div> <div class="right item">
<a class="ui primary button" href="/newmotion/">New motion</a>
</div>
{{ end }}
</div> </div>
</div> </div>
{{ with .Decision }} {{ with .Decision }}
<div class="column">
<div class="ui raised segment"> <div class="ui raised segment">
{{ template "motion_fragment" . }} {{ template "motion_fragment" . }}
{{ if $voter }}{{ template "motion_actions" . }}{{ end }} {{ if $voter }}{{ template "motion_actions" . }}{{ end }}
</div> </div>
</div>
{{ end}} {{ end}}
{{ template "footer.html" . }} {{ template "footer.html" . }}

@ -1,64 +1,68 @@
{{ define "motion_fragment" }} {{ define "motion_fragment" }}
<span class="ui {{ template "status_class" .Status }} ribbon label">{{ .Status|toString|title }}</span> <span class="ui {{ template "status_class" .Status }} ribbon label">{{ .Status|toString|title }}</span>
<span class="header.html">{{ .Modified|date "2006-01-02 15:04:05 UTC" }}</span> <span class="header.html">{{ .Modified|date "2006-01-02 15:04:05 UTC" }}</span>
<h3 class="header.html"><a href="/motions/{{ .Tag }}">{{ .Tag }}: {{ .Title }}</a></h3> <h3 class="header.html"><a href="/motions/{{ .Tag }}">{{ .Tag }}: {{ .Title }}</a></h3>
<p>{{ wrap 76 .Content | nl2br }}</p> <p>{{ wrap 76 .Content | nl2br }}</p>
<table class="ui small definition table"> <table class="ui small definition table">
<tbody> <tbody>
<tr> <tr>
<td>Due</td> <td>Due</td>
<td>{{.Due|date "2006-01-02 15:04:05 UTC"}}</td> <td>{{.Due|date "2006-01-02 15:04:05 UTC"}}</td>
</tr> </tr>
<tr> <tr>
<td>Proposed</td> <td>Proposed</td>
<td>{{.Proposer}} ({{.Proposed|date "2006-01-02 15:04:05 UTC"}})</td> <td>{{.Proposer}} ({{.Proposed|date "2006-01-02 15:04:05 UTC"}})</td>
</tr> </tr>
<tr> <tr>
<td>Vote type:</td> <td>Vote type:</td>
<td>{{ .VoteType|toString|title }}</td> <td>{{ .VoteType|toString|title }}</td>
</tr> </tr>
<tr> <tr>
<td>Votes:</td> <td>Votes:</td>
<td> <td>
<div class="ui labels"> <div class="ui labels">
<div class="ui basic label green"><i <div class="ui basic label green"><i
class="check circle icon"></i>Aye class="check circle icon"></i>Aye
<div class="detail">{{.Ayes}}</div> <div class="detail">{{.Ayes}}</div>
</div>
<div class="ui basic label red"><i
class="minus circle icon"></i>Naye
<div class="detail">{{.Nayes}}</div>
</div>
<div class="ui basic label grey"><i class="circle icon"></i>Abstain
<div class="detail">{{.Abstains}}</div>
</div>
</div> </div>
<div class="ui basic label red"><i {{ if .Votes }}
class="minus circle icon"></i>Naye <div class="list">
<div class="detail">{{.Nayes}}</div> {{ range .Votes }}
</div> <div class="item">{{ .Name }}: {{ .Vote.Vote }}</div>
<div class="ui basic label grey"><i class="circle icon"></i>Abstain {{ end }}
<div class="detail">{{.Abstains}}</div> </div>
</div> <a href="/motions/{{ .Tag }}">Hide Votes</a>
</div> {{ else if or ((ne 0 .Ayes) (ne 0 .Nayes) (ne 0 .Abstains)) }}
{{ if .Votes }} <a href="/motions/{{ .Tag }}?showvotes=1">Show Votes</a>
<div class="list">
{{ range .Votes }}
<div class="item">{{ .Name }}: {{ .Vote.Vote }}</div>
{{ end }} {{ end }}
</div> </td>
<a href="/motions/{{ .Tag }}">Hide Votes</a> </tr>
{{ else if or ((ne 0 .Ayes) (ne 0 .Nayes) (ne 0 .Abstains)) }} </tbody>
<a href="/motions/{{ .Tag }}?showvotes=1">Show Votes</a> </table>
{{ end }}
</td>
</tr>
</tbody>
</table>
{{ end }} {{ end }}
{{ define "status_class" }}{{ if eq . 0 }}blue{{ else if eq . 1 }}green{{ else if eq . -1 }}red{{ else if eq . -2 }}grey {{ define "status_class" }}{{ if eq . 0 }}blue{{ else if eq . 1 }}green{{ else if eq . -1 }}red{{ else if eq . -2 }}grey{{ end }}{{ end }}
{{ end }}{{ end }}
{{ define "motion_actions" }} {{ define "motion_actions" }}
{{ if eq .Status 0 }} {{ if eq .Status 0 }}
<a class="ui compact right labeled green icon button" href="/vote/{{ .Tag }}/aye"><i class="check circle icon"></i> Aye</a> <a class="ui compact right labeled green icon button" href="/vote/{{ .Tag }}/aye"><i
<a class="ui compact right labeled red icon button" href="/vote/{{ .Tag }}/naye"><i class="minus circle icon"></i> Naye</a> class="check circle icon"></i> Aye</a>
<a class="ui compact right labeled grey icon button" href="/vote/{{ .Tag }}/abstain"><i class="circle icon"></i> Abstain</a> <a class="ui compact right labeled red icon button" href="/vote/{{ .Tag }}/naye"><i
<a class="ui compact left labeled icon button" href="/proxy/{{ .Tag }}"><i class="users icon"></i> Proxy Vote</a> class="minus circle icon"></i> Naye</a>
<a class="ui compact left labeled icon button" href="/motions/{{ .Tag }}/edit"><i class="edit icon"></i> Modify</a> <a class="ui compact right labeled grey icon button" href="/vote/{{ .Tag }}/abstain"><i class="circle icon"></i>
<a class="ui compact left labeled icon button" href="/motions/{{ .Tag }}/withdraw"><i class="trash icon"></i> Withdraw</a> Abstain</a>
{{ end }} <a class="ui compact left labeled icon button" href="/proxy/{{ .Tag }}"><i class="users icon"></i> Proxy
Vote</a>
<a class="ui compact left labeled icon button" href="/motions/{{ .Tag }}/edit"><i class="edit icon"></i> Modify</a>
<a class="ui compact left labeled icon button" href="/motions/{{ .Tag }}/withdraw"><i class="trash icon"></i>
Withdraw</a>
{{ end }}
{{ end }} {{ end }}

@ -1,52 +1,45 @@
{{ template "header.html" . }} {{ template "header.html" . }}
{{ $voter := .Voter }} {{ $voter := .Voter }}
<div class="column"> {{ $page := . }}
<div class="ui basic segment"> <div class="ui basic segment">
<div class="ui floated right secondary menu"> <div class="ui secondary pointing menu">
<a href="/motions/" class="{{ if not .Params.Flags.Unvoted }}active {{ end }}item" title="Show all votes">All
<a href="/motions/" class="{{ if not .Params.Flags.Unvoted }}active {{ end }}item" title="Show all votes">All votes</a> votes</a>
{{ if $voter }}<a href="/motions/?unvoted=1" class="{{ if .Params.Flags.Unvoted }}active {{ end}}item" title="Show my outstanding votes">My outstanding votes</a>{{ end }} {{ if $voter }}
</div> <a href="/motions/?unvoted=1" class="{{ if .Params.Flags.Unvoted }}active {{ end}}item"
{{ if $voter }}<a class="ui primary button" href="/newmotion/">New motion</a>{{ end }} title="Show my outstanding votes">My outstanding votes</a>
{{ if .PrevPage -}} <div class="right item">
<a href="?page={{ .PrevPage }}{{ if .Params.Flags.Unvoted }}&unvoted=1{{ end }}" <a class="ui primary button" href="/newmotion/">New motion</a>
class="ui left labeled icon button" title="newer motions"><i class="left arrow icon"></i> newer</a> </div>
{{- end }} {{ end }}
{{ if .NextPage -}}
<a href="?page={{ .NextPage }}{{ if .Params.Flags.Unvoted }}&unvoted=1{{ end }}"
class="ui right labeled icon button" title="older motions"><i class="right arrow icon"></i> older</a>
{{- end }}
</div> </div>
</div> </div>
{{ if .Decisions }} {{ if .Decisions }}
<div class="ui labeled icon menu">
{{ template "pagination_fragment" $page }}
</div>
{{ range .Decisions }} {{ range .Decisions }}
<div class="column">
<div class="ui raised segment"> <div class="ui raised segment">
{{ template "motion_fragment" . }} {{ template "motion_fragment" . }}
{{ if $voter }}{{ template "motion_actions" . }}{{ end }} {{ if $voter }}{{ template "motion_actions" . }}{{ end }}
</div> </div>
</div>
{{ end }} {{ end }}
<div class="column"> <div class="ui labeled icon menu">
<div class="ui basic segment"> {{ template "pagination_fragment" $page }}
{{ if $voter }}<a class="ui primary button" href="/newmotion/">New motion</a>{{ end }}
{{ if .PrevPage -}}
<a href="?page={{ .PrevPage }}{{ if .Params.Flags.Unvoted }}&unvoted=1{{ end }}"
class="ui left labeled icon button" title="newer motions">
<i class="left arrow icon"></i> newer</a>
{{- end }}
{{ if .NextPage -}}
<a href="?page={{ .NextPage }}{{ if .Params.Flags.Unvoted }}&unvoted=1{{ end }}"
class="ui right labeled icon button" title="older motions">
<i class="right arrow icon"></i> older</a>
{{- end }}
</div> </div>
</div>
{{ else }} {{ else }}
{{ if .Params.Flags.Unvoted }} <div class="ui basic segment">
<p>There are no motions requiring a vote from you.</p> <div class="ui icon message">
{{ else }} <i class="inbox icon"></i>
<p>There are no motions in the system yet.</p> <div class="content">
{{ end }} <div class="header">No motions available</div>
{{ if .Params.Flags.Unvoted }}
<p>There are no motions requiring a vote from you.</p>
{{ else }}
<p>There are no motions in the system yet.</p>
{{ end }}
</div>
</div>
</div>
{{ end }} {{ end }}
{{ template "footer.html" . }} {{ template "footer.html" . }}

@ -0,0 +1,20 @@
{{ define "pagination_fragment" }}
{{ if .PrevPage -}}
<a class="item" href="?page={{ .PrevPage }}{{ if .Params.Flags.Unvoted }}&unvoted=1{{ end }}">
<i class="left arrow icon"></i> newer
</a>
{{- end }}
{{ if .NextPage -}}
<a class="right item" href="?page={{ .NextPage }}{{ if .Params.Flags.Unvoted }}&unvoted=1{{ end }}">
<i class="right arrow icon"></i> older
</a>
{{- end }}
{{ end }}
{{ define "return_header" }}
<div class="ui basic segment">
<div class="ui secondary pointing menu">
<a href="/motions/" class="item" title="Show all votes">Back to motions</a>
</div>
</div>
{{ end }}

@ -1,56 +1,47 @@
{{ template "header.html" . }} {{ template "header.html" . }}
{{ template "return_header" . }}
{{ $form := .Form }} {{ $form := .Form }}
<div class="column"> <div class="ui raised segment">
<div class="ui basic segment">
<div class="ui floated right secondary menu">
<a href="/motions/" class="item" title="Show all votes">Back to
motions</a>
</div>
</div>
</div>
<div class="column">
<div class="ui raised segment">
{{ with .Decision }} {{ with .Decision }}
{{ template "motion_fragment" . }} {{ template "motion_fragment" . }}
{{ end }} {{ end }}
<form action="/proxy/{{ .Decision.Tag }}" method="post"> <form action="/proxy/{{ .Decision.Tag }}" method="post">
{{ csrfField }} {{ csrfField }}
<div class="ui form{{ if .Form.Errors }} error{{ end }}"> <div class="ui form{{ if .Form.Errors }} error{{ end }}">
<div class="two fields"> <div class="two fields">
<div class="required field{{ if .Form.Errors.Voter }} error{{ end }}"> <div class="required field{{ if .Form.Errors.Voter }} error{{ end }}">
<label for="Voter">Voter</label> <label for="Voter">Voter</label>
<select name="Voter"> <select name="Voter">
{{ range .Voters }} {{ range .Voters }}
<option value="{{ .Id }}" <option value="{{ .Id }}"
{{ if eq (.Id | print) $form.Voter }} {{ if eq (.Id | print) $form.Voter }}
selected{{ end }}>{{ .Name }}</option> selected{{ end }}>{{ .Name }}</option>
{{ end }} {{ end }}
</select> </select>
</div>
<div class="required field{{ if .Form.Errors.Vote }} error{{ end }}">
<label for="Vote">Vote</label>
<select name="Vote">
<option value="1"{{ if eq .Form.Vote "1" }} selected{{ end }}>Aye</option>
<option value="0"{{ if eq .Form.Vote "0" }} selected{{ end }}>Abstain</option>
<option value="-1"{{ if eq .Form.Vote "-1" }} selected{{ end }}>Naye</option>
</select>
</div>
</div> </div>
<div class="required field{{ if .Form.Errors.Justification }} error{{ end }}"> <div class="required field{{ if .Form.Errors.Vote }} error{{ end }}">
<label for="Justification">Justification</label> <label for="Vote">Vote</label>
<textarea name="Justification" rows="2">{{ .Form.Justification }}</textarea> <select name="Vote">
<option value="1"{{ if eq .Form.Vote "1" }} selected{{ end }}>Aye</option>
<option value="0"{{ if eq .Form.Vote "0" }} selected{{ end }}>Abstain</option>
<option value="-1"{{ if eq .Form.Vote "-1" }} selected{{ end }}>Naye</option>
</select>
</div> </div>
</div>
<div class="required field{{ if .Form.Errors.Justification }} error{{ end }}">
<label for="Justification">Justification</label>
<textarea name="Justification" rows="2">{{ .Form.Justification }}</textarea>
</div>
{{ with .Form.Errors }} {{ with .Form.Errors }}
<div class="ui error message"> <div class="ui error message">
{{ with .Voter }}<p>{{ . }}</p>{{ end }} {{ with .Voter }}<p>{{ . }}</p>{{ end }}
{{ with .Vote }}<p>{{ . }}</p>{{ end }} {{ with .Vote }}<p>{{ . }}</p>{{ end }}
{{ with .Justification }}<p>{{ . }}</p>{{ end }} {{ with .Justification }}<p>{{ . }}</p>{{ end }}
</div> </div>
{{ end }} {{ end }}
<button class="ui primary left labeled icon button" type="submit"><i class="users icon"></i> Proxy Vote <button class="ui primary left labeled icon button" type="submit"><i class="users icon"></i> Proxy Vote
</button> </button>
</div> </div>
</form> </form>
</div>
</div> </div>
{{ template "footer.html" . }} {{ template "footer.html" . }}

@ -1,22 +1,17 @@
{{ template "header.html" . }} {{ template "header.html" . }}
<div class="column"> {{ template "return_header" . }}
<div class="ui basic segment">
<div class="ui floated right secondary menu">
<a href="/motions/" class="item" title="Show all votes">Back to motions</a>
</div>
</div>
</div>
{{ with .Decision }} {{ with .Decision }}
<div class="column">
<div class="ui raised segment"> <div class="ui raised segment">
{{ template "motion_fragment" . }} {{ template "motion_fragment" . }}
</div> </div>
</div>
{{ end }} {{ end }}
<form action="/motions/{{ .Decision.Tag }}/withdraw" method="post"> <div class="ui basic segment">
{{ csrfField }} <form action="/motions/{{ .Decision.Tag }}/withdraw" method="post">
<div class="ui form"> {{ csrfField }}
<button class="ui primary left labeled icon button" type="submit"><i class="trash icon"></i> Withdraw</button> <div class="ui form">
</div> <button class="ui primary left labeled icon button" type="submit"><i class="trash icon"></i> Withdraw
</form> </button>
{{ template "footer.html" . }} </div>
</form>
</div>
{{ template "footer.html" . }}
Loading…
Cancel
Save