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

Commit

Permalink
Consolidate badge detail tables into a single partial
Browse files Browse the repository at this point in the history
  • Loading branch information
stenington committed Nov 20, 2012
1 parent a1991ad commit d26993d
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 205 deletions.
7 changes: 6 additions & 1 deletion static/js/backpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,12 @@ Details.View = Backbone.View.extend({
},

render: function () {
this.el = template('badge-details.html', this.model.attributes);
this.el = template('badge-details.html', {
badge: {
attributes: this.model.attributes
},
disownable: true
});
this.setElement(this.el);
this.$el.data('view', this);
return this;
Expand Down
71 changes: 71 additions & 0 deletions views/badge-data.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<table class='information'>
<colgroup>
<col class="imageCol">
<col class="fieldLabelCol">
<col class="dataCol">
</colgroup>
<tbody>
<tr>
<td rowspan="100" class='image'>
<img src="{{badge.attributes.image_path}}">
{% if disownable %}
<button class='btn btn-danger disown'>Disown this Badge</button>
{% endif %}
</td>

<td class='section-head' colspan='2'>Issuer Details</td>
</tr>
<tr>
<td class='fieldlabel issuer-name'>Name</td>
<td>{{badge.attributes.body.badge.issuer.name}}</td>
</tr>
<tr>
<td class='fieldlabel issuer-name'>URL</td>
<td><a href="{{badge.attributes.body.badge.issuer.origin}}">{{badge.attributes.body.badge.issuer.origin}}</a></td>
</tr>
{% if badge.attributes.body.badge.issuer.org %}
<tr>
<td class='fieldlabel issuer-name'>Organization</td>
<td>{{badge.attributes.body.badge.issuer.org}}</td>
</tr>
{% endif %}

<tr>
<td class='section-head' colspan='2'>Badge Details</td>
</tr>
<tr>
<td class='fieldlabel'>Name</td>
<td>{{badge.attributes.body.badge.name|escape}}</td>
</tr>
<tr>
<td class='fieldlabel'>Description</td>
<td>{{badge.attributes.body.badge.description|escape}}</td>
</tr>
<tr>
<td class='fieldlabel'>Criteria</td>
<td><a href='{{badge.attributes.body.badge.criteria}}'>{{badge.attributes.body.badge.criteria}}</a></td>
</tr>

{% if badge.attributes.body.evidence %}
<tr>
<td class='fieldlabel evidence'>Evidence</td>
<td><a href='{{badge.attributes.body.evidence}}'>{{badge.attributes.body.evidence}}</a></td>
</tr>
{% endif %}

{% if badge.attributes.body.issued_on %}
<tr>
<td class='fieldlabel'>Issued</td>
<td>{{badge.attributes.body.issued_on}}</td>
</tr>
{% endif %}

{% if badge.attributes.body.expires %}
<tr>
<td class='fieldlabel'>Expiration</td>
<td>{{badge.attributes.body.expires}}</td>
</tr>
{% endif %}
</tbody>
</table>

80 changes: 3 additions & 77 deletions views/badge-details.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class='lightbox' data-id='{{id}}'>
<div class='contents badge-details'>
<header>
<h2>{{body.badge.name}}</h2>
<h2>{{badge.attributes.body.badge.name}}</h2>
<span class='close'>&times;</span>
</header>
<div class='body'>
Expand All @@ -11,7 +11,7 @@ <h2>{{body.badge.name}}</h2>
This will remove the badge from your account. It will also be
removed from all groups. The only way to get this badge back will be
to go to the place where it was issued
(<a href='{{body.badge.issuer.origin}}'>{{body.badge.issuer.name}}</a>)
(<a href='{{badge.attributes.body.badge.issuer.origin}}'>{{badge.attributes.body.badge.issuer.name}}</a>)
and get it re-issued.
</p>

Expand All @@ -20,81 +20,7 @@ <h2>{{body.badge.name}}</h2>
<button class='btn yep btn-danger'>Yes, remove this badge</button>
</div>
</div>

<table class='information table'>
<colgroup>
<col class="imageCol">
<col class="fieldLabelCol">
<col class="dataCol">
</colgroup>
<tbody>
<tr>
<td rowspan="100" class='image'>
<img src="{{image_path}}" class='badge-image'>
<button class='btn btn-danger disown'>Disown this Badge</button>
</td>

<td class='section-head' colspan='2'>Issuer Details</td>
</tr>
<tr>
<td class='fieldlabel issuer-name'>Name</td>
<td>{{body.badge.issuer.name}}</td>
</tr>
<tr>
<td class='fieldlabel issuer-name'>URL</td>
<td><a href="{{body.badge.issuer.origin}}">{{body.badge.issuer.origin}}</a></td>
</tr>
{% if body.badge.issuer.org %}
<tr>
<td class='fieldlabel issuer-name'>Organization</td>
<td>{{body.badge.issuer.org}}</td>
</tr>
{% endif %}

<tr>
<td class='section-head' colspan='2'>Badge Details</td>
</tr>
<tr>
<td class='fieldlabel'>Name</td>
<td>{{body.badge.name}}</td>
</tr>
<tr>
<td class='fieldlabel'>Description</td>
<td>{{body.badge.description}}</td>
</tr>
<tr>
<td class='fieldlabel'>Criteria</td>
<td><a href='{{body.badge.criteria}}'>{{body.badge.criteria}}</a></td>
</tr>

<tr>
<td class='section-head' colspan='2'>Issuance Details</td>
</tr>
<tr>
<td class='fieldlabel recipient'>Recipient</td>
<td>{{body.recipient}}</td>
</tr>
{% if body.evidence %}
<tr>
<td class='fieldlabel evidence'>Evidence</td>
<td><a href='{{body.evidence}}'>{{body.evidence}}</a></td>
</tr>
{% endif %}
{% if body.issued_on %}
<tr>
<td class='fieldlabel'>Issued On</td>
<td>{{body.issued_on}}</td>
</tr>
{% endif %}

{% if body.expires %}
<tr>
<td class='fieldlabel'>Expiration Date</td>
<td>{{body.expires}}</td>
</tr>
{% endif %}
</tbody>
</table>
{% include 'badge-data.html' %}
</div>
</div>
</div>
61 changes: 1 addition & 60 deletions views/portfolio-editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,66 +17,7 @@ <h3>{{badge.attributes.body.badge.name}}</h3>

<textarea name='stories[{{badge.attributes.body.id}}]' tabindex=1 class='story' placeholder='some information about this badge'>{{badge.attributes.body._userStory}}</textarea>

<table class='information'>
<tr>
<td rowspan="100" class='image'>
<img src="{{badge.attributes.image_path}}">
</td>
<td class='section-head' colspan='2'>Issuer Details</td>
</tr>
<tr>
<td class='fieldlabel issuer-name'>Name</td>
<td>{{badge.attributes.body.badge.issuer.name}}</td>
</tr>
<tr>
<td class='fieldlabel issuer-name'>URL</td>
<td><a href="{{badge.attributes.body.badge.issuer.origin}}">{{badge.attributes.body.badge.issuer.origin}}</a></td>
</tr>
{% if badge.attributes.body.badge.issuer.org %}
<tr>
<td class='fieldlabel issuer-name'>Organization</td>
<td>{{badge.attributes.body.badge.issuer.org}}</td>
</tr>
{% endif %}

<tr>
<td class='section-head' colspan='2'>Badge Details</td>
</tr>
<tr>
<td class='fieldlabel'>Name</td>
<td>{{badge.attributes.body.badge.name|escape}}</td>
</tr>
<tr>
<td class='fieldlabel'>Description</td>
<td>{{badge.attributes.body.badge.description|escape}}</td>
</tr>
<tr>
<td class='fieldlabel'>Criteria</td>
<td><a href='{{badge.attributes.body.badge.criteria}}'>{{badge.attributes.body.badge.criteria}}</a></td>
</tr>

{% if evidence %}
<tr>
<td class='fieldlabel evidence'>Evidence</td>
<td><a href='{{badge.attributes.body.evidence}}'>{{badge.attributes.body.evidence}}</a></td>
</tr>
{% endif %}

{% if issued_on %}
<tr>
<td class='fieldlabel'>Issued</td>
<td>{{badge.attributes.body.issued_on}}</td>
</tr>
{% endif %}

{% if expires %}
<tr>
<td class='fieldlabel'>Expiration</td>
<td>{{badge.attributes.body.expires}}</td>
</tr>
{% endif %}

</table>
{% include 'badge-data.html' %}
</li>
{% endfor %}
</ul>
Expand Down
68 changes: 1 addition & 67 deletions views/portfolio.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,73 +35,7 @@ <h3>{{badge.attributes.body.badge.name}}</h3>

<p class='story'>{{badge.attributes.body._userStory}}</p>

<table class='information'>
<colgroup>
<col class="imageCol">
<col class="fieldLabelCol">
<col class="dataCol">
</colgroup>
<tbody>
<tr>
<td rowspan="100" class='image'>
<img src="{{badge.attributes.image_path}}">
</td>

<td class='section-head' colspan='2'>Issuer Details</td>
</tr>
<tr>
<td class='fieldlabel issuer-name'>Name</td>
<td>{{badge.attributes.body.badge.issuer.name}}</td>
</tr>
<tr>
<td class='fieldlabel issuer-name'>URL</td>
<td><a href="{{badge.attributes.body.badge.issuer.origin}}">{{badge.attributes.body.badge.issuer.origin}}</a></td>
</tr>
{% if badge.attributes.body.badge.issuer.org %}
<tr>
<td class='fieldlabel issuer-name'>Organization</td>
<td>{{badge.attributes.body.badge.issuer.org}}</td>
</tr>
{% endif %}

<tr>
<td class='section-head' colspan='2'>Badge Details</td>
</tr>
<tr>
<td class='fieldlabel'>Name</td>
<td>{{badge.attributes.body.badge.name|escape}}</td>
</tr>
<tr>
<td class='fieldlabel'>Description</td>
<td>{{badge.attributes.body.badge.description|escape}}</td>
</tr>
<tr>
<td class='fieldlabel'>Criteria</td>
<td><a href='{{badge.attributes.body.badge.criteria}}'>{{badge.attributes.body.badge.criteria}}</a></td>
</tr>

{% if badge.attributes.body.evidence %}
<tr>
<td class='fieldlabel evidence'>Evidence</td>
<td><a href='{{badge.attributes.body.evidence}}'>{{badge.attributes.body.evidence}}</a></td>
</tr>
{% endif %}

{% if badge.attributes.body.issued_on %}
<tr>
<td class='fieldlabel'>Issued</td>
<td>{{badge.attributes.body.issued_on}}</td>
</tr>
{% endif %}

{% if badge.attributes.body.expires %}
<tr>
<td class='fieldlabel'>Expiration</td>
<td>{{badge.attributes.body.expires}}</td>
</tr>
{% endif %}
</tbody>
</table>
{% include 'badge-data.html' %}
</li>
{% endfor %}
</ul>
Expand Down

0 comments on commit d26993d

Please sign in to comment.