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 +4 -4
- data/README.md +2 -1
- data/app/assets/javascript/trestle/{mobility_fields.js → mobility.js} +0 -0
- data/app/assets/stylesheets/trestle/mobility.scss +8 -0
- data/app/views/trestle/mobility/_check_box.html.erb +22 -0
- data/app/views/trestle/mobility/_text_area.html.erb +13 -11
- data/app/views/trestle/mobility/_text_field.html.erb +15 -13
- data/config/initializers/trestle.rb +8 -7
- data/lib/trestle/mobility/engine.rb +1 -1
- data/lib/trestle/mobility/fields/check_box.rb +21 -0
- data/lib/trestle/mobility/fields/text_area.rb +23 -0
- data/lib/trestle/mobility/fields/text_field.rb +21 -0
- data/lib/trestle/mobility/version.rb +1 -1
- metadata +8 -5
- data/lib/trestle/mobility/text_area.rb +0 -19
- data/lib/trestle/mobility/text_field.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 321983d8b2ced10b0bfcf36a909b5503b3bd35dac0bb1bd7ba72ef1eea860645
|
4
|
+
data.tar.gz: 5be8fc9e56a4a004549e2ee14a907e170d323daab6909afee3496a7cd8e7015d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 `
|
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
|
```
|
File without changes
|
@@ -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="
|
2
|
-
<
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
</
|
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="
|
2
|
-
<div class="input-group-
|
3
|
-
<
|
4
|
-
<
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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/
|
2
|
-
require "trestle/mobility/
|
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(:
|
6
|
-
|
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 :
|
10
|
-
config.form_field :
|
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
|
@@ -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
|
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.
|
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-
|
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/
|
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/
|
106
|
-
- lib/trestle/mobility/
|
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
|