implement feature #324
This commit is contained in:
parent
79f958c505
commit
fbd945cf6d
10
Gemfile.lock
10
Gemfile.lock
@ -17,10 +17,10 @@ GIT
|
||||
|
||||
GIT
|
||||
remote: git://github.com/locomotivecms/custom_fields.git
|
||||
revision: ec157c3941d1530eb49d08ee385d25c3d3f34f15
|
||||
revision: e54c3ddfce0e24668d02c372c6143a722718e215
|
||||
branch: 2.0.0.rc
|
||||
specs:
|
||||
custom_fields (2.0.0.rc7)
|
||||
custom_fields (2.0.0.rc8)
|
||||
activesupport (~> 3.2.1)
|
||||
carrierwave-mongoid (~> 0.1.3)
|
||||
mongoid (~> 2.4.5)
|
||||
@ -36,7 +36,7 @@ PATH
|
||||
carrierwave-mongoid (~> 0.1.3)
|
||||
cells (~> 3.8.0)
|
||||
codemirror-rails (~> 2.21)
|
||||
custom_fields (~> 2.0.0.rc7)
|
||||
custom_fields (~> 2.0.0.rc8)
|
||||
devise (~> 1.5.3)
|
||||
dragonfly (~> 0.9.8)
|
||||
flash_cookie_session (~> 1.1.1)
|
||||
@ -146,7 +146,7 @@ GEM
|
||||
orm_adapter (~> 0.0.3)
|
||||
warden (~> 1.1)
|
||||
diff-lcs (1.1.3)
|
||||
dragonfly (0.9.10)
|
||||
dragonfly (0.9.11)
|
||||
rack
|
||||
ejs (1.0.0)
|
||||
erubis (2.7.0)
|
||||
@ -217,7 +217,7 @@ GEM
|
||||
mongo (~> 1.3)
|
||||
tzinfo (~> 0.3.22)
|
||||
multi_json (1.0.4)
|
||||
multi_xml (0.4.1)
|
||||
multi_xml (0.4.2)
|
||||
net-scp (1.0.4)
|
||||
net-ssh (>= 1.99.1)
|
||||
net-ssh (2.3.0)
|
||||
|
@ -78,6 +78,12 @@ ul.list {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
span.untranslated {
|
||||
@include label;
|
||||
top: -1px;
|
||||
left: 5px;
|
||||
}
|
||||
|
||||
div.more {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
@ -212,6 +218,12 @@ ul.list {
|
||||
|
||||
&.hidden a { font-style: italic; font-weight: normal; }
|
||||
|
||||
span.untranslated {
|
||||
@include label;
|
||||
top: 3px;
|
||||
left: 5px;
|
||||
}
|
||||
|
||||
.more {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
|
@ -55,3 +55,18 @@
|
||||
border-bottom: 1px dotted #efe4a5;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin label {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
|
||||
background-color: #858585;
|
||||
@include border-radius(3px);
|
||||
padding: 1px 3px 2px;
|
||||
|
||||
line-height: 16px;
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
@include single-text-shadow(rgba(0, 0, 0, 0.6), 0px, -1px, 0px);
|
||||
}
|
||||
|
@ -48,6 +48,14 @@ module Locomotive
|
||||
value.respond_to?(:to_label) ? value.to_label : value
|
||||
end
|
||||
|
||||
def translated?
|
||||
if self.respond_to?(:"#{self._label_field_name}_translations")
|
||||
self.send(:"#{self._label_field_name}_translations").key?(::Mongoid::Fields::I18n.locale.to_s) #rescue false
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
def next
|
||||
next_or_previous :gt
|
||||
end
|
||||
|
@ -12,7 +12,6 @@ module Locomotive
|
||||
|
||||
## callbacks ##
|
||||
after_validation :add_default_locale
|
||||
# after_validation :add_missing_locales_for_all_pages
|
||||
|
||||
end
|
||||
|
||||
|
@ -71,6 +71,10 @@ module Locomotive
|
||||
self.cache_strategy != 'none'
|
||||
end
|
||||
|
||||
def translated?
|
||||
self.title_translations.key?(::Mongoid::Fields::I18n.locale.to_s) rescue false
|
||||
end
|
||||
|
||||
def to_liquid
|
||||
Locomotive::Liquid::Drops::Page.new(self)
|
||||
end
|
||||
|
@ -6,7 +6,11 @@
|
||||
%li.item{ :id => "entry-#{entry._id}" }
|
||||
%span.handle
|
||||
= image_tag 'locomotive/form/icons/drag.png'
|
||||
|
||||
%strong= link_to entry_label(content_type, entry), edit_content_entry_url(content_type.slug, entry)
|
||||
|
||||
- unless entry.translated?
|
||||
%span.untranslated= t('locomotive.shared.list.untranslated')
|
||||
.more
|
||||
%span
|
||||
!= t('locomotive.content_entries.index.updated_at')
|
||||
|
@ -17,6 +17,9 @@
|
||||
|
||||
= link_to truncate(page.title, :length => 80), edit_page_url(page)
|
||||
|
||||
- unless page.translated?
|
||||
%span.untranslated= t('locomotive.shared.list.untranslated')
|
||||
|
||||
.more
|
||||
%span!= t('.updated_at')
|
||||
= l page.updated_at, :format => :short
|
||||
|
@ -48,6 +48,8 @@ en:
|
||||
create: Create
|
||||
update: Save
|
||||
send: Send
|
||||
list:
|
||||
untranslated: untranslated
|
||||
footer:
|
||||
who_is_behind: "LocomotiveCMS is developed by %{development} and designed by <a href=\"http://www.sachagreif.com\">Sacha Greif</a> — <small>version</small> %{version}"
|
||||
|
||||
|
@ -48,6 +48,8 @@ fr:
|
||||
account: Mon compte
|
||||
site: Site
|
||||
theme_assets: Fichiers Thème
|
||||
list:
|
||||
untranslated: non traduit
|
||||
footer:
|
||||
who_is_behind: "Produit développé par %{development} et désigné par <a href=\"http://www.sachagreif.com\">Sacha Greif</a> — <small>version</small> %{version}"
|
||||
form_actions:
|
||||
|
@ -30,7 +30,7 @@ Gem::Specification.new do |s|
|
||||
s.add_dependency 'mongoid', '~> 2.4.5'
|
||||
s.add_dependency 'locomotive-mongoid-tree', '~> 0.6.2'
|
||||
|
||||
s.add_dependency 'custom_fields', '~> 2.0.0.rc7'
|
||||
s.add_dependency 'custom_fields', '~> 2.0.0.rc8'
|
||||
|
||||
s.add_dependency 'kaminari', '~> 0.13.0'
|
||||
|
||||
|
@ -67,6 +67,27 @@ describe Locomotive::ContentEntry do
|
||||
end
|
||||
end
|
||||
|
||||
context '#i18n' do
|
||||
|
||||
before(:each) do
|
||||
localize_content_type @content_type
|
||||
::Mongoid::Fields::I18n.locale = 'en'
|
||||
@content_entry = build_content_entry(:title => 'Hello world')
|
||||
::Mongoid::Fields::I18n.locale = 'fr'
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
::Mongoid::Fields::I18n.locale = 'en'
|
||||
end
|
||||
|
||||
it 'tells if an entry has been translated or not' do
|
||||
@content_entry.translated?.should be_false
|
||||
@content_entry.title = 'Bonjour'
|
||||
@content_entry.translated?.should be_true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#navigation" do
|
||||
before(:each) do
|
||||
@content_type.save
|
||||
@ -214,8 +235,13 @@ describe Locomotive::ContentEntry do
|
||||
|
||||
end
|
||||
|
||||
def localize_content_type(content_type)
|
||||
content_type.entries_custom_fields.first.localized = true
|
||||
content_type.save
|
||||
end
|
||||
|
||||
def build_content_entry(options = {})
|
||||
@content_type.entries.build({ :title => 'Locomotive', :description => 'Lorem ipsum....' }.merge(options))
|
||||
@content_type.entries.build({ :title => 'Locomotive', :description => 'Lorem ipsum....', :_label_field_name => 'title' }.merge(options))
|
||||
end
|
||||
|
||||
def fake_bson_id(id)
|
||||
|
@ -74,6 +74,12 @@ describe Locomotive::Page do
|
||||
@page.errors[:title].should == ["can't be blank"]
|
||||
end
|
||||
|
||||
it 'tells if a page has been translated or not' do
|
||||
@page.translated?.should be_false
|
||||
@page.title = 'Hello world'
|
||||
@page.translated?.should be_true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user