trestle-mobility 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea74e7c4f517865a447984c1f812e5d670fac6ea36ffd2042677d187d2199269
4
- data.tar.gz: 118ec2ec169c0e7466916496ccfb6774a1e5f45990d575dd1655956eb0690709
3
+ metadata.gz: b024ad069d14e6c5e42fb4a0cfc42d6e5469316f4ab1c3c3bb1e4274f34b044a
4
+ data.tar.gz: 1b0ea2bb3aeac07751382ba28b6ba151fee47c3da098d948c4624b0e4deabf4e
5
5
  SHA512:
6
- metadata.gz: 8172808f3a88c0303150814fb7e0df65eff2c75e332ba6b1defb4bd488cbe15d92379e5dbded7ec563d435e2fa28950c09c9386ed2bb8619a2ee30ff645c5352
7
- data.tar.gz: 64f25a7533b02e041ae478d89ea519fc794b12893b587cf67a62607a068e9f73756f000e20fed7c666f4272496da932797b578c80ebc1ace6abf9c002e17c840
6
+ metadata.gz: dcbce616ed0a7a43c1b79877da54c7804fd7634054870d1a41f46f89fd7b684b4cd4a120dc0e0af14d280c8863e8727b3ae90b39532efcdae1fdef71a557a801
7
+ data.tar.gz: dcbf2ea3f704dfa59fc25a2cd6c7537ec3f467bd0f5792e673ed01979450e9f1aa7a5d7cb0abec29570791cc9feec91785af4a67e804eeadfccca15e1cfa83db
data/README.md CHANGED
@@ -6,9 +6,11 @@
6
6
 
7
7
  ## Features / problems
8
8
 
9
- - [ ] Manage Mobility translations with a tabbed interface in trestle
10
- - [ ] Supports Postgres container back-end
11
- - [ ] Probably works with other back-ends but has not been tested
9
+ - Manage Mobility translations with a tabbed interface in trestle
10
+ - Supports Postgres container back-end
11
+ - Probably works with other back-ends but has not been tested
12
+
13
+ ![Trestle Mobility screenshot](/screenshot.png?raw=true "Trestle Mobility screenshot")
12
14
 
13
15
  ## Usage
14
16
 
@@ -26,6 +28,18 @@ Trestle.resource(:posts) do
26
28
  end
27
29
  ```
28
30
 
31
+ ### Specifying locales
32
+
33
+ By default Trestle Mobility uses `I18n.available_locales` to generate the form fields, but you can specify this on a per-field basis:
34
+
35
+ ```ruby
36
+ mobility_text_field :title, locales: %w(nl de fr)
37
+ ```
38
+
39
+ Quoting from Mobility's README:
40
+
41
+ > (Note however that Mobility will complain if you have I18n.enforce_available_locales set to true and you try accessing a locale not present in I18n.available_locales; set it to false if you want to allow any locale.)
42
+
29
43
  ## Installation
30
44
 
31
45
  These instructions assume you have a working Trestle application. To integrate trestle-mobility, first add it to your application's Gemfile:
@@ -7,13 +7,11 @@
7
7
  <% end %>
8
8
  </ul>
9
9
 
10
- <div class="main-content">
11
- <div class="tab-content">
12
- <% locales.each.with_index do |locale, index| %>
13
- <div role="tabpanel" class="tab-pane<%= " active" if index.zero? %>" id="<%= "#{field_name}_#{locale}" %>">
14
- <%= form.text_area "#{field_name}_#{locale}" %>
15
- </div>
16
- <% end %>
17
- </div>
10
+ <div class="tab-content">
11
+ <% locales.each.with_index do |locale, index| %>
12
+ <div role="tabpanel" class="tab-pane<%= " active" if index.zero? %>" id="<%= "#{field_name}_#{locale}" %>">
13
+ <%= form.text_area "#{field_name}_#{locale}", label: false, placeholder: "#{field_name.capitalize} (#{locale.upcase})", rows: rows %>
14
+ </div>
15
+ <% end %>
18
16
  </div>
19
17
  </div>
@@ -7,13 +7,11 @@
7
7
  <% end %>
8
8
  </ul>
9
9
 
10
- <div class="main-content">
11
- <div class="tab-content">
12
- <% locales.each.with_index do |locale, index| %>
13
- <div role="tabpanel" class="tab-pane<%= " active" if index.zero? %>" id="<%= "#{field_name}_#{locale}" %>">
14
- <%= form.text_field "#{field_name}_#{locale}" %>
15
- </div>
16
- <% end %>
17
- </div>
10
+ <div class="tab-content">
11
+ <% locales.each.with_index do |locale, index| %>
12
+ <div role="tabpanel" class="tab-pane<%= " active" if index.zero? %>" id="<%= "#{field_name}_#{locale}" %>">
13
+ <%= form.text_field "#{field_name}_#{locale}", label: false, placeholder: "#{field_name.capitalize} (#{locale.upcase})" %>
14
+ </div>
15
+ <% end %>
18
16
  </div>
19
17
  </div>
@@ -3,10 +3,11 @@ module Trestle
3
3
  class TextArea < Trestle::Form::Field
4
4
  def field
5
5
  instance = builder.object
6
- locales = instance.translations.keys
6
+ locales = options[:locales] || I18n.available_locales.sort
7
+ rows = options[:rows] || 5
7
8
 
8
9
  @template.render partial: "trestle/mobility/text_area",
9
- locals: { field_name: name, locales: locales }
10
+ locals: { field_name: name, locales: locales, rows: rows }
10
11
  end
11
12
  end
12
13
  end
@@ -3,7 +3,7 @@ module Trestle
3
3
  class TextField < Trestle::Form::Field
4
4
  def field
5
5
  instance = builder.object
6
- locales = I18n.available_locales.sort
6
+ locales = options[:locales] || I18n.available_locales.sort
7
7
 
8
8
  @template.render partial: "trestle/mobility/text_field",
9
9
  locals: { field_name: name, locales: locales }
@@ -1,5 +1,5 @@
1
1
  module Trestle
2
2
  module Mobility
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
data/screenshot.png ADDED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trestle-mobility
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Venneman
@@ -89,6 +89,7 @@ files:
89
89
  - lib/trestle/mobility/text_area.rb
90
90
  - lib/trestle/mobility/text_field.rb
91
91
  - lib/trestle/mobility/version.rb
92
+ - screenshot.png
92
93
  - trestle-mobility.gemspec
93
94
  homepage: https://github.com/richardvenneman/trestle-mobility
94
95
  licenses: