Skip to content

Commit

Permalink
Merge pull request #601 from maebeale/display-inexhaustible-if-relevant
Browse files Browse the repository at this point in the history
Display inexhaustible icon on Contributions, Matches, Respond
  • Loading branch information
maebeale authored Jul 30, 2020
2 parents 9ada393 + 2660e37 commit 7f8d213
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [Unreleased]
### Enhancements
* Display inexhaustible icon on Contributions, Matches, Respond #601

## [0.2.6] - 2020-07-25
### Enhancements
* Allow custom questions to be added to Ask and Offer forms #597
Expand Down
2 changes: 1 addition & 1 deletion app/blueprints/contribution_blueprint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ContributionBlueprint < Blueprinter::Base
association :urgency, blueprint: DefaultBlueprint do |contribution, _options|
UrgencyLevel.find(contribution.urgency_level_id)
end
fields :title, :description
fields :title, :description, :inexhaustible
field :created_at do |contribution, _options|
contribution.created_at.to_f * 1000 # Javascript wants miliseconds, not seconds
end
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/components/MappedIconList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const iconNameMapping = {
WhatsApp: 'whatsapp',
Call: 'phone',
Ask: 'hand-sparkles',
Offer: 'hand-holding-heart'
Offer: 'hand-holding-heart',
Inexhaustible: 'hourglass-half has-text-primary'
}
export default {
Expand Down
8 changes: 6 additions & 2 deletions app/javascript/pages/browse/ListBrowser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
<!-- <th>Details</th>-->
</tr>
<tr v-for="contribution in contributions" :key="contribution.id">
<td><MappedIconList :iconTypes="[{name: contribution.contribution_type}]" /></td>
<td><TagList :tags="contribution.category_tags" /></td>
<td>
<MappedIconList :iconTypes="contribution.inexhaustible ? [{name: contribution.contribution_type}, {name: 'Inexhaustible'}] : [{name: contribution.contribution_type}]" />
</td>
<td>
<TagList :tags="contribution.category_tags" />
</td>
<td>
<b-tag v-if="contribution.urgency" :class="!(contribution.urgency && contribution.urgency.id > 1) ? 'is-light is-warning' : ''" size="is-small" >
<b-icon v-if="!(contribution.urgency && contribution.urgency.id > 1)" icon="exclamation-triangle" />
Expand Down
6 changes: 5 additions & 1 deletion app/javascript/pages/browse/TileListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div class="body">
<div class="row left">
<SingleIcon :iconType="contribution_type" klass="" />
<MappedIconList :iconTypes="contact_types" />
<MappedIconList :iconTypes="iconList" />
<span class="has-text-right">
<b-tag v-if="urgency" :class="urgencyColor">
<b-icon v-if="showUrgentIcon" icon="exclamation-triangle" size="is-small" />
Expand Down Expand Up @@ -52,6 +52,7 @@ export default {
category_tags: {type: Array, default: () => []},
service_area: {type: Object, default: null},
title: String,
inexhaustible: Boolean,
description: String,
created_at: Number,
urgency: Object,
Expand All @@ -69,6 +70,9 @@ export default {
showUrgentIcon() {
return !(this.urgency && this.urgency.id > 1)
},
iconList() {
return this.inexhaustible ? [ ...this.contact_types, {name: 'Inexhaustible'} ] : this.contact_types
},
urgencyColor() {
return this.showUrgentIcon ? 'is-light is-warning' : ''
},
Expand Down
6 changes: 6 additions & 0 deletions app/views/contributions/respond.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
<%#= edit(@contribution) %><!-- # TODO - add update action back in once we have moved controllers-->
</div>
<div class="created_at">Created on <%= shorthand_display(@contribution.created_at) %></div>
<% if @contribution.inexhaustible %>
<br>
<%= "<br>".html_safe if @contribution.title.present? %>
<span class="has-text-primary"><span class="fa fa-hourglass-half"></span>&nbsp;INHEXHAUSTIBLE (can be matched repeatedly)</span>
<%= "<br>".html_safe if @contribution.title.present? %>
<% end %>
<%= "<br>".html_safe if @contribution.title.present? || @contribution.description.present? %>
<div class="subtitle is-5"><%= @contribution.title %></div>
<div class="description"><%= @contribution.description %></div>
Expand Down
3 changes: 3 additions & 0 deletions app/views/matches/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<td><%= shorthand_display(match.created_at) %></td>
<td><%= shorthand_display(match.updated_at) %></td>
<td>
<% if match.receiver.inexhaustible? %>
<span class="fa fa-hourglass-half has-text-primary"></span>&nbsp;
<% end %>
<% match.receiver&.all_tags_unique&.each do |tag_name| %>
<span class="tag is-info is-light has-text-weight-bold"><%= tag_name.upcase %></span>
<% end %>
Expand Down
1 change: 1 addition & 0 deletions spec/blueprints/contribution_blueprint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"id" => contribution.id,
"contribution_type" => "Ask",
"category_tags" => [{"id" => expected_category_id, "name" => expected_category}],
"inexhaustible" => contribution.inexhaustible,
"urgency" => {"id" => 1, "name" => "Within 1-2 days"},
# # TODO: not yet implemented:
# "availability" => [{"id" => 1, "name" => "AM"}],
Expand Down

0 comments on commit 7f8d213

Please sign in to comment.