Skip to content
This repository has been archived by the owner on Aug 3, 2022. It is now read-only.

Commit

Permalink
[#740] Simplify template conditional and format
Browse files Browse the repository at this point in the history
  • Loading branch information
brew committed Jul 25, 2016
1 parent 10afcf4 commit 28fe2e5
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions census/views/_snippets/form.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
{% macro currentEntryValue(qu) %}
{% if current %}
{% if current.answers[qu.id] %}
{{current.answers[qu.id]}}
{% else %}
{{ gettext("No entry") }}
{% endif %}
{% if current and current.answers[qu.id] %}
{{ current.answers[qu.id] }}
{% else %}
{{ gettext("No entry") }}
{% endif %}
{%- endmacro %}

{% macro currentEntry(qu) %}
<div class="current-entry">
<label>{{gettext("Current Entry")}}</label>
<label>{{ gettext("Current Entry") }}</label>
<div class="current-entry-value" title="{{ currentEntryValue(qu) }}">
{{ currentEntryValue(qu) }}
</div>
Expand All @@ -22,25 +18,25 @@
{% macro question(qu) -%}
<div class="span6">
<h4 class="submission-label">{{qu.question}}</h4>
<input type="{{qu.type}}" title="{{qu.placeholder}}" name="{{qu.id}}" value="{% if formData %}{{ formData[qu.id] }}{% elif current %}{{current.answers[qu.id]}}{% endif %}" {% if canReview != true or reviewClosed %}disabled="disabled"{% endif %} placeholder="{{qu.placeholder}}" {% if qu.id=='format' %} list="formats" {% endif %} />
<input type="{{ qu.type }}" title="{{ qu.placeholder }}" name="{{ qu.id }}" value="{% if formData %}{{ formData[qu.id] }}{% elif current %}{{ current.answers[qu.id] }}{% endif %}" {% if canReview != true or reviewClosed %}disabled="disabled"{% endif %} placeholder="{{ qu.placeholder }}" {% if qu.id=='format' %} list="formats" {% endif %} />
</div>
<div class="span6">
{{ currentEntry(qu) }}
</div>
<div class="span12">
<span class="help-block">{{qu.description}}</span>
<span class="help-block">{{ qu.description }}</span>
</div>
{%- endmacro %}

<fieldset>
<div class="row-fluid submission-row head">
<div class="span12">
<div class="submission-question">Question</div>
<div class="submission-option">{{gettext("Yes")}}</div>
<div class="submission-option">{{gettext("No")}}</div>
<div class="submission-option">{{gettext("Unsure")}}</div>
<div class="submission-current">{{gettext("Current")}}</div>
<div class="submission-info">{{gettext("Information")}}</div>
<div class="submission-option">{{ gettext("Yes") }}</div>
<div class="submission-option">{{ gettext("No") }}</div>
<div class="submission-option">{{ gettext("Unsure") }}</div>
<div class="submission-current">{{ gettext("Current") }}</div>
<div class="submission-info">{{ gettext("Information") }}</div>
</div>
</div>

Expand All @@ -56,7 +52,7 @@ <h4 class="submission-label">{{qu.question}}</h4>
{"type": null, "string": "null", "display": "Unsure"}
] %}
<div class="submission-option">
<input type="radio" name="{{qu.id}}" value="{{ val.string }}" {% if formData %}{% if formData[qu.id] == val.string %}checked="true"{% endif %}{% else %}{% if (current and current.answers[qu.id] == val.type) %}checked="true" {% endif %}{% endif %}class="{{ val.string }}"{% if canReview != true or reviewClosed %} disabled="disabled"{% endif %} required>
<input type="radio" name="{{ qu.id }}" value="{{ val.string }}" {% if formData %}{% if formData[qu.id] == val.string %}checked="true"{% endif %}{% else %}{% if (current and current.answers[qu.id] == val.type) %}checked="true" {% endif %}{% endif %}class="{{ val.string }}"{% if canReview != true or reviewClosed %} disabled="disabled"{% endif %} required>
</div>
{% endfor %}
<div class="submission-current">
Expand All @@ -70,7 +66,7 @@ <h4 class="submission-label">{{qu.question}}</h4>
{{ currentDisplay }}
</div>
<div class="submission-info">
<span class="help-block readmore">{{qu.description}}</span>
<span class="help-block readmore">{{ qu.description }}</span>
</div>
{% if qu.dependants %}
{% for dependant in qu.dependants %}
Expand All @@ -92,13 +88,13 @@ <h4 class="submission-label">{{qu.question}}</h4>
<div class="row">
<div class="span12">
<hr />
<h4>{{addDetails.question}}</h4>
<span class="help-block">{{addDetails.description}}</span>
<h4>{{ addDetails.question }}</h4>
<span class="help-block">{{ addDetails.description }}</span>
</div>
<div class="span6">
<div class="wmd-panel">
<div id="wmd-button-bar"></div>
<textarea class="wmd-input" id="wmd-input" name="details" {% if canReview != true or reviewClosed %}disabled="disabled"{% endif %} style="min-height: 150px;">{{formData.details or current.details}}</textarea>
<textarea class="wmd-input" id="wmd-input" name="details" {% if canReview != true or reviewClosed %}disabled="disabled"{% endif %} style="min-height: 150px;">{{ formData.details or current.details }}</textarea>
</div>
</div>
<div class="span6">
Expand Down

0 comments on commit 28fe2e5

Please sign in to comment.