Skip to content

Commit

Permalink
Merge pull request #59 from cryptape/fix-show-dapp-page-not-rollback
Browse files Browse the repository at this point in the history
Fix show DApp info page not acts i18n rollback
  • Loading branch information
ashchan authored Dec 18, 2018
2 parents f199d76 + 658d86d commit a2f03a7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
12 changes: 12 additions & 0 deletions app/models/dapp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,16 @@ class Dapp < ApplicationRecord
exchange: 30,
}

def name_or_default
name.blank? ? name_zh_cn : name
end

def intro_or_default
intro.blank? ? intro_zh_cn : intro
end

def desc_or_default
desc.blank? ? desc_zh_cn : desc
end

end
4 changes: 4 additions & 0 deletions app/models/dapp_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ class DappType < ApplicationRecord
globalize_accessors

scope :default_order, -> { order(id: :asc) }

def name_or_default
name.blank? ? name_zh_cn : name
end
end
10 changes: 5 additions & 5 deletions app/views/dapps/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<% @page_title = @dapp.name || @dapp.name_zh_cn %>
<% @page_title = @dapp.name_or_default %>

<div id='id-store' class='storeinfo'
data-category=<%= @dapp.dapp_type.name || @dapp.dapp_type.name_zh_cn %>
data-name=<%= @dapp.name || @dapp.name_zh_cn %>
data-category=<%= @dapp.dapp_type.name_or_default %>
data-name=<%= @dapp.name_or_default %>
></div>

<div id='id-page-info' class='dappsContainer'>
<div id='id-container-main'>
<img class="mainimg" src=<%= @dapp.logo_url %> alt="mainimg">
<div class="title"><%= @dapp.name || @dapp.name_zh_cn %></div>
<div class="title"><%= @dapp.name_or_default %></div>
<a class="link" href=<%= @dapp.marketing_url %>><%= @dapp.url_address %></a>
<div id='id-div-stars'>
<% @star.times do |i| %>
Expand All @@ -24,7 +24,7 @@
<div id='id-container-intro'>
<div class="title"><%= t("overview") %></div>
<div class="intro">
<%= @dapp.intro || @dapp.intro_zh_cn %>
<%= @dapp.intro_or_default %>
</div>
<div class="time">
<%= t("submitted_at") %>: <%= @dapp.publish_at&.strftime("%Y-%m-%d") %>
Expand Down

0 comments on commit a2f03a7

Please sign in to comment.