trestle-mobility 0.3.2 → 0.4.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: b05239931214566a6ce7e2cbac8b7bb2d4b46a60e65083fd506fd9b93ff0fd0d
4
- data.tar.gz: 9851a708fc474bb2fa098066531c6e6ef581d92fd32132e65574e24d890b0e0d
3
+ metadata.gz: 321983d8b2ced10b0bfcf36a909b5503b3bd35dac0bb1bd7ba72ef1eea860645
4
+ data.tar.gz: 5be8fc9e56a4a004549e2ee14a907e170d323daab6909afee3496a7cd8e7015d
5
5
  SHA512:
6
- metadata.gz: 1f5e49982d087161b97a19e5f1502c3f6f48b9bf9ce9a73bd51af7632599ffa4f1d81092ab23f0b7f45c46dbc927784c99596a17e9113b09ced12707c40adf66
7
- data.tar.gz: 3533c5cfd6ece4fc6c0099bddd52a6c72e53a27d0f5aceb99d2e922459cbaf7f618091f573ec0a734702c937e47ccf035e2034e0589f846df0e7eed95ea23051
6
+ metadata.gz: 5f57c749ce315c62befd711d087c24c220057b2c96f75489965ec16f5e7096a9792fcf2e32bb21029e3e6617b45cbb302bf869c4ee27fee5c007962c9313f28b
7
+ data.tar.gz: bb2974fe1ec3be058228357629021e5ceae82a65d20f8ab42749ea3f666012b44d27bd56a9aa3fb065217d44ea6a302070558142cdcfa75dc0cbc39afa32f0ba
data/README.md CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  Trestle Mobility requires you to enable [Mobility's `locale_accessors` plugin](https://github.com/shioyama/mobility#getset).
18
18
 
19
- Assuming you've setup your models with Mobility's `translates` directives, you can use the `mobility_text_field` and `mobility_text_area` field types:
19
+ Assuming you've setup your models with Mobility's `translates` directives, you can use the `mobility_text_field`, `mobility_text_area` and `mobility_check_box` field types:
20
20
 
21
21
  ```ruby
22
22
  Trestle.resource(:posts) do
@@ -24,6 +24,7 @@ Trestle.resource(:posts) do
24
24
  mobility_text_field :title
25
25
  mobility_text_field :subtitle
26
26
  mobility_text_area :content
27
+ mobility_check_box :published
27
28
  end
28
29
  end
29
30
  ```
@@ -0,0 +1,8 @@
1
+ .mobility-checkbox {
2
+ display: flex;
3
+ align-items:center;
4
+ }
5
+
6
+ .mobility-checkbox__label {
7
+ margin-left: 8px;
8
+ }
@@ -0,0 +1,22 @@
1
+ <div class="form-group">
2
+ <div class="input-group mobility" data-active="<%= selected %>">
3
+ <div class="input-group-btn">
4
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
5
+ <span class="mobility-active"><%= "#{EmojiFlag.new(selected)} #{selected.upcase}" %></span> <span class="caret"></span>
6
+ </button>
7
+ <ul class="dropdown-menu">
8
+ <% locales.each do |locale| %>
9
+ <li><a href="#<%= "#{field_name}_#{locale}" %>" class="dropdown-item" data-locale="<%= locale %>"><%= "#{EmojiFlag.new(locale)} #{locale.upcase}" %></a></li>
10
+ <% end %>
11
+ </ul>
12
+ </div>
13
+ <% locales.each do |locale| %>
14
+ <%=
15
+ content_tag(:div, "#{field_name.to_s.humanize} (#{locale.upcase})", { class: "form-control mobility-checkbox mobility-field#{locale == selected ? '' : ' hidden'}", data: { locale: locale } }) do
16
+ form.raw_check_box("#{field_name}_#{locale}", { class: "mobility-checkbox__input" }, "1", "0") +
17
+ form.label("#{field_name}_#{locale}", "#{label} (#{locale.upcase})", class: "mobility-checkbox__label")
18
+ end
19
+ %>
20
+ <% end %>
21
+ </div>
22
+ </div>
@@ -1,13 +1,15 @@
1
- <div class="input-group mobility" data-active="<%= selected %>">
2
- <button type="button" class="btn btn-default dropdown-toggle input-group-addon" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
3
- <span class="mobility-active"><%= "#{EmojiFlag.new(selected)} #{selected.upcase}" %></span> <span class="caret"></span>
4
- </button>
5
- <ul class="dropdown-menu">
6
- <% locales.each do |locale| %>
7
- <li><a href="#<%= "#{field_name}_#{locale}" %>" class="dropdown-item" data-locale="<%= locale %>"><%= "#{EmojiFlag.new(locale)} #{locale.upcase}" %></a></li>
1
+ <div class="form-group">
2
+ <div class="input-group mobility" data-active="<%= selected %>">
3
+ <button type="button" class="btn btn-default dropdown-toggle input-group-addon" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
4
+ <span class="mobility-active"><%= "#{EmojiFlag.new(selected)} #{selected.upcase}" %></span> <span class="caret"></span>
5
+ </button>
6
+ <ul class="dropdown-menu">
7
+ <% locales.each do |locale| %>
8
+ <li><a href="#<%= "#{field_name}_#{locale}" %>" class="dropdown-item" data-locale="<%= locale %>"><%= "#{EmojiFlag.new(locale)} #{locale.upcase}" %></a></li>
9
+ <% end %>
10
+ </ul>
11
+ <% locales.each do |locale, index| %>
12
+ <%= form.raw_text_area "#{field_name}_#{locale}", class: "form-control mobility-field#{locale == selected ? '' : ' hidden'}", placeholder: "#{label} (#{locale.upcase})", rows: rows, data: { locale: locale } %>
8
13
  <% end %>
9
- </ul>
10
- <% locales.each do |locale, index| %>
11
- <%= form.raw_text_area "#{field_name}_#{locale}", class: "form-control mobility-field#{locale == selected ? '' : ' hidden'}", placeholder: "#{field_name.to_s.humanize} (#{locale.upcase})", rows: rows, data: { locale: locale } %>
12
- <% end %>
14
+ </div>
13
15
  </div>
@@ -1,15 +1,17 @@
1
- <div class="input-group mobility" data-active="<%= selected %>">
2
- <div class="input-group-btn">
3
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
4
- <span class="mobility-active"><%= "#{EmojiFlag.new(selected)} #{selected.upcase}" %></span> <span class="caret"></span>
5
- </button>
6
- <ul class="dropdown-menu">
7
- <% locales.each do |locale| %>
8
- <li><a href="#<%= "#{field_name}_#{locale}" %>" class="dropdown-item" data-locale="<%= locale %>"><%= "#{EmojiFlag.new(locale)} #{locale.upcase}" %></a></li>
9
- <% end %>
10
- </ul>
1
+ <div class="form-group">
2
+ <div class="input-group mobility" data-active="<%= selected %>">
3
+ <div class="input-group-btn">
4
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
5
+ <span class="mobility-active"><%= "#{EmojiFlag.new(selected)} #{selected.upcase}" %></span> <span class="caret"></span>
6
+ </button>
7
+ <ul class="dropdown-menu">
8
+ <% locales.each do |locale| %>
9
+ <li><a href="#<%= "#{field_name}_#{locale}" %>" class="dropdown-item" data-locale="<%= locale %>"><%= "#{EmojiFlag.new(locale)} #{locale.upcase}" %></a></li>
10
+ <% end %>
11
+ </ul>
12
+ </div>
13
+ <% locales.each do |locale| %>
14
+ <%= form.raw_text_field "#{field_name}_#{locale}", class: "form-control mobility-field#{locale == selected ? '' : ' hidden'}", placeholder: "#{label} (#{locale.upcase})", data: { locale: locale } %>
15
+ <% end %>
11
16
  </div>
12
- <% locales.each do |locale| %>
13
- <%= form.raw_text_field "#{field_name}_#{locale}", class: "form-control mobility-field#{locale == selected ? '' : ' hidden'}", placeholder: "#{field_name.to_s.humanize} (#{locale.upcase})", data: { locale: locale } %>
14
- <% end %>
15
17
  </div>
@@ -1,11 +1,12 @@
1
- require "trestle/mobility/text_area"
2
- require "trestle/mobility/text_field"
1
+ require "trestle/mobility/fields/check_box"
2
+ require "trestle/mobility/fields/text_area"
3
+ require "trestle/mobility/fields/text_field"
3
4
 
4
5
  Trestle.configure do |config|
5
- config.hook(:javascripts) do
6
- javascript_include_tag('trestle/mobility_fields.js')
7
- end
6
+ config.hook(:stylesheets) { stylesheet_link_tag "trestle/mobility" }
7
+ config.hook(:javascripts) { javascript_include_tag "trestle/mobility" }
8
8
 
9
- config.form_field :mobility_text_area, Trestle::Mobility::TextArea
10
- config.form_field :mobility_text_field, Trestle::Mobility::TextField
9
+ config.form_field :mobility_check_box, Trestle::Mobility::Fields::CheckBox
10
+ config.form_field :mobility_text_area, Trestle::Mobility::Fields::TextArea
11
+ config.form_field :mobility_text_field, Trestle::Mobility::Fields::TextField
11
12
  end
@@ -1,7 +1,7 @@
1
1
  module Trestle
2
2
  module Mobility
3
3
  class Engine < Rails::Engine
4
- config.assets.precompile << 'trestle/mobility_fields.js'
4
+ config.assets.precompile << "trestle/mobility.css" << "trestle/mobility.js"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,21 @@
1
+ module Trestle
2
+ module Mobility
3
+ module Fields
4
+ class CheckBox < Trestle::Form::Fields::CheckBox
5
+ def field
6
+ label = options[:label] || name.to_s.humanize
7
+ locales = options[:locales] || I18n.available_locales.sort
8
+ selected = options[:selected] || Trestle.config.mobility.selected || locales.first
9
+
10
+ @template.render partial: "trestle/mobility/check_box",
11
+ locals: {
12
+ field_name: name,
13
+ label: label,
14
+ locales: locales,
15
+ selected: selected
16
+ }
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ module Trestle
2
+ module Mobility
3
+ module Fields
4
+ class TextArea < Trestle::Form::Field
5
+ def field
6
+ label = options[:label] || name.to_s.humanize
7
+ locales = options[:locales] || I18n.available_locales.sort
8
+ selected = options[:selected] || Trestle.config.mobility.selected || locales.first
9
+ rows = options[:rows] || 5
10
+
11
+ @template.render partial: "trestle/mobility/text_area",
12
+ locals: {
13
+ field_name: name,
14
+ label: label,
15
+ locales: locales,
16
+ selected: selected,
17
+ rows: rows
18
+ }
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ module Trestle
2
+ module Mobility
3
+ module Fields
4
+ class TextField < Trestle::Form::Field
5
+ def field
6
+ label = options[:label] || name.to_s.humanize
7
+ locales = options[:locales] || I18n.available_locales.sort
8
+ selected = options[:selected] || Trestle.config.mobility.selected || locales.first
9
+
10
+ @template.render partial: "trestle/mobility/text_field",
11
+ locals: {
12
+ field_name: name,
13
+ label: label,
14
+ locales: locales,
15
+ selected: selected
16
+ }
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  module Trestle
2
2
  module Mobility
3
- VERSION = "0.3.2"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trestle-mobility
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Venneman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-06 00:00:00.000000000 Z
11
+ date: 2019-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: emoji_flag
@@ -93,7 +93,9 @@ files:
93
93
  - LICENSE.md
94
94
  - README.md
95
95
  - Rakefile
96
- - app/assets/javascript/trestle/mobility_fields.js
96
+ - app/assets/javascript/trestle/mobility.js
97
+ - app/assets/stylesheets/trestle/mobility.scss
98
+ - app/views/trestle/mobility/_check_box.html.erb
97
99
  - app/views/trestle/mobility/_text_area.html.erb
98
100
  - app/views/trestle/mobility/_text_field.html.erb
99
101
  - bin/console
@@ -102,8 +104,9 @@ files:
102
104
  - lib/trestle/mobility.rb
103
105
  - lib/trestle/mobility/configuration.rb
104
106
  - lib/trestle/mobility/engine.rb
105
- - lib/trestle/mobility/text_area.rb
106
- - lib/trestle/mobility/text_field.rb
107
+ - lib/trestle/mobility/fields/check_box.rb
108
+ - lib/trestle/mobility/fields/text_area.rb
109
+ - lib/trestle/mobility/fields/text_field.rb
107
110
  - lib/trestle/mobility/version.rb
108
111
  - screenshot.png
109
112
  - trestle-mobility.gemspec
@@ -1,19 +0,0 @@
1
- module Trestle
2
- module Mobility
3
- class TextArea < Trestle::Form::Field
4
- def field
5
- locales = options[:locales] || I18n.available_locales.sort
6
- selected = options[:selected] || Trestle.config.mobility.selected || locales.first
7
- rows = options[:rows] || 5
8
-
9
- @template.render partial: "trestle/mobility/text_area",
10
- locals: {
11
- field_name: name,
12
- locales: locales,
13
- selected: selected,
14
- rows: rows
15
- }
16
- end
17
- end
18
- end
19
- end
@@ -1,17 +0,0 @@
1
- module Trestle
2
- module Mobility
3
- class TextField < Trestle::Form::Field
4
- def field
5
- locales = options[:locales] || I18n.available_locales.sort
6
- selected = options[:selected] || Trestle.config.mobility.selected || locales.first
7
-
8
- @template.render partial: "trestle/mobility/text_field",
9
- locals: {
10
- field_name: name,
11
- locales: locales,
12
- selected: selected
13
- }
14
- end
15
- end
16
- end
17
- end