Added UI boxes

This commit is contained in:
Joe Buhlig 2016-02-17 13:11:37 -06:00
parent c2999ceb71
commit 1a59d08a12
6 changed files with 82 additions and 5 deletions

View File

@ -0,0 +1,16 @@
{{#if showExtraInfo}}
{{#if topic.can_vote}}
<div class="voting header-voting">
<div class="voting-wrapper">
<div class="vote-count">{{topic.vote_count}}</div>
<div class="vote-label">
{{#if topic.single_vote}}
{{i18n 'feature_voting.vote.one'}}
{{else}}
{{i18n 'feature_voting.vote.multiple'}}
{{/if}}
</div>
</div>
</div>
{{/if}}
{{/if}}

View File

@ -1,3 +0,0 @@
{{#if model.can_vote}}
<div class="voting">hello world</div>
{{/if}}

View File

@ -0,0 +1,15 @@
{{#if model.can_vote}}
<div class="voting">
<div class="voting-wrapper">
<div class="vote-count">{{model.vote_count}}</div>
<div class="vote-label">
{{#if model.single_vote}}
{{i18n 'feature_voting.vote.one'}}
{{else}}
{{i18n 'feature_voting.vote.multiple'}}
{{/if}}
</div>
</div>
<div class="vote-button">{{i18n 'feature_voting.vote_title'}}</div>
</div>
{{/if}}

View File

@ -0,0 +1,28 @@
.voting{
min-width: 70px;
float: left;
text-align: center;
margin: 0px 20px 0px 0px;
max-width: 10%;
}
.voting-wrapper{
border: 3px solid #e9e9e9;
}
.vote-count{
height:20px;
line-height:20px;
font-weight: bold;
}
.vote-label{
height:20px;
line-height:20px;
}
.header-voting{
margin: 0px 20px 0px 5px;
}
.vote-button{
background-color: $tertiary;
margin-top: 5px;
padding: 2px 0px;
color: #ffffff;
}

View File

@ -2,4 +2,8 @@ en:
js:
feature_voting:
allow_topic_voting: "Allow users to vote on topics in this category"
title: "Vote"
vote_title: "Vote"
unvote_title: "Unvote"
vote:
one: "vote"
multiple: "votes"

View File

@ -16,11 +16,28 @@ after_initialize do
require_dependency 'topic_view_serializer'
class ::TopicViewSerializer
attributes :can_vote
attributes :can_vote, :single_vote, :vote_count
def can_vote
return object.topic.category.custom_fields["enable_topic_voting"]
end
def single_vote
if object.topic.custom_fields["vote_count"] == 1
return true
else
return false
end
end
def vote_count
if object.topic.custom_fields["vote_count"]
return object.topic.custom_fields["vote_count"]
else
return 0
end
end
end
class ::Category