fae-rails 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/app/assets/javascripts/fae/form/_ajax.js +21 -1
- data/app/assets/javascripts/fae/form/_cancel.js +1 -0
- data/app/assets/javascripts/fae/form/_validator.js +22 -12
- data/app/assets/javascripts/fae/form/inputs/_color.js +2 -1
- data/app/assets/javascripts/fae/vendor/jqColorPicker.min.js +0 -1
- data/app/controllers/fae/application_controller.rb +15 -1
- data/app/controllers/fae/users_controller.rb +8 -0
- data/app/helpers/fae/form_helper.rb +13 -4
- data/app/helpers/fae/view_helper.rb +76 -31
- data/app/models/concerns/fae/user_concern.rb +10 -1
- data/app/models/fae/static_page.rb +7 -2
- data/app/models/fae/user.rb +2 -3
- data/app/uploaders/fae/file_uploader.rb +1 -1
- data/app/uploaders/fae/image_uploader.rb +1 -1
- data/app/views/fae/application/_file_uploader.html.slim +4 -1
- data/app/views/fae/application/_global_search_results.html.slim +1 -1
- data/app/views/fae/application/_header.slim +8 -8
- data/app/views/fae/application/_markdown_helper.slim +17 -17
- data/app/views/fae/application/_mobilenav.slim +6 -6
- data/app/views/fae/application/_user_log.html.slim +2 -2
- data/app/views/fae/images/_image_uploader.html.slim +1 -1
- data/app/views/fae/options/_form.html.slim +6 -6
- data/app/views/fae/pages/activity_log.html.slim +11 -11
- data/app/views/fae/pages/disabled_environment.html.slim +2 -2
- data/app/views/fae/pages/error404.html.slim +5 -3
- data/app/views/fae/pages/home.html.slim +9 -8
- data/app/views/fae/setup/first_user.html.slim +3 -3
- data/app/views/fae/shared/_form_header.html.slim +3 -3
- data/app/views/fae/shared/_index_header.html.slim +3 -2
- data/app/views/fae/shared/_nested_table.html.slim +1 -1
- data/app/views/fae/shared/_recent_changes.html.slim +6 -6
- data/app/views/fae/shared/_shared_nested_table.html.slim +1 -1
- data/app/views/fae/static_pages/index.html.slim +2 -2
- data/app/views/fae/users/_form.html.slim +8 -12
- data/app/views/fae/users/index.html.slim +6 -6
- data/config/locales/devise.cs.yml +59 -0
- data/config/locales/fae.cs.yml +125 -0
- data/config/locales/fae.en.yml +109 -0
- data/config/locales/fae.zh-CN.yml +109 -0
- data/lib/fae/version.rb +1 -1
- data/lib/generators/fae/base_generator.rb +46 -3
- data/lib/generators/fae/nested_index_scaffold_generator.rb +1 -0
- data/lib/generators/fae/nested_scaffold_generator.rb +1 -0
- data/lib/generators/fae/page_generator.rb +8 -0
- data/lib/generators/fae/scaffold_generator.rb +1 -0
- data/lib/generators/fae/templates/graphql/graphql_page_type.rb +17 -0
- data/lib/generators/fae/templates/graphql/graphql_type.rb +13 -0
- metadata +9 -5
data/lib/fae/version.rb
CHANGED
@@ -9,6 +9,7 @@ module Fae
|
|
9
9
|
@@attribute_names = []
|
10
10
|
@@association_names = []
|
11
11
|
@@attachments = []
|
12
|
+
@@graphql_attributes = []
|
12
13
|
@@has_position = false
|
13
14
|
@@display_field = ''
|
14
15
|
|
@@ -28,18 +29,21 @@ module Fae
|
|
28
29
|
@@attributes_flat << "#{arg.name}:#{arg.type}"
|
29
30
|
end
|
30
31
|
|
31
|
-
if arg
|
32
|
-
@@association_names << arg.name.gsub(
|
32
|
+
if is_association(arg)
|
33
|
+
@@association_names << arg.name.gsub(/_id$/, '')
|
33
34
|
elsif !is_attachment(arg)
|
34
35
|
@@attribute_names << arg.name
|
35
36
|
end
|
36
37
|
@@has_position = true if arg.name === 'position'
|
38
|
+
|
39
|
+
@@graphql_attributes << graphql_object(arg)
|
37
40
|
end
|
38
41
|
|
39
42
|
@@attributes_flat = @@attributes_flat.uniq.join(' ')
|
40
43
|
@@association_names.uniq!
|
41
44
|
@@attribute_names.uniq!
|
42
45
|
@@attachments.uniq!
|
46
|
+
@@graphql_attributes.uniq!
|
43
47
|
end
|
44
48
|
end
|
45
49
|
|
@@ -74,7 +78,7 @@ module Fae
|
|
74
78
|
end
|
75
79
|
|
76
80
|
def add_route
|
77
|
-
inject_into_file "config/routes.rb", after: "namespace :#{options.namespace} do\n" do <<-RUBY
|
81
|
+
inject_into_file "config/routes.rb", after: "namespace :#{options.namespace} do\n", force: true do <<-RUBY
|
78
82
|
resources :#{plural_file_name}
|
79
83
|
RUBY
|
80
84
|
end
|
@@ -148,6 +152,45 @@ RUBY
|
|
148
152
|
inject_into_file 'app/models/concerns/fae/navigation_concern.rb', line, before: '# scaffold inject marker'
|
149
153
|
end
|
150
154
|
|
155
|
+
def graphql_object(arg)
|
156
|
+
if is_association(arg)
|
157
|
+
assoc_name = arg.name.gsub(/_id$/, '')
|
158
|
+
assoc_type = "Types::#{assoc_name.classify}Type"
|
159
|
+
{ attr: assoc_name.to_sym, type: assoc_type }
|
160
|
+
else
|
161
|
+
{ attr: arg.name.to_sym, type: graphql_type(arg.type) }
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def graphql_type(type)
|
166
|
+
case type.to_s
|
167
|
+
when 'integer'
|
168
|
+
'Integer'
|
169
|
+
when 'boolean'
|
170
|
+
'Boolean'
|
171
|
+
when 'image'
|
172
|
+
'Types::FaeImageType'
|
173
|
+
when 'file'
|
174
|
+
'Types::FaeFileType'
|
175
|
+
else
|
176
|
+
'String'
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def generate_graphql_type
|
181
|
+
return unless uses_graphql
|
182
|
+
@graphql_attributes = @@graphql_attributes
|
183
|
+
template "graphql/graphql_type.rb", "app/graphql/types/#{file_name}_type.rb"
|
184
|
+
end
|
185
|
+
|
186
|
+
def uses_graphql
|
187
|
+
defined?(GraphQL)
|
188
|
+
end
|
189
|
+
|
190
|
+
def is_association(arg)
|
191
|
+
arg.name.end_with?('_id') || arg.type.to_s == 'references'
|
192
|
+
end
|
193
|
+
|
151
194
|
def is_attachment(arg)
|
152
195
|
[:image,:file].include?(arg.type)
|
153
196
|
end
|
@@ -11,6 +11,7 @@ module Fae
|
|
11
11
|
if attributes.present?
|
12
12
|
attributes.each do |attr|
|
13
13
|
@@attributes[attr.name.to_sym] = convert_attr_type(attr.type)
|
14
|
+
@@graphql_attributes << graphql_object(attr)
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
@@ -18,6 +19,7 @@ module Fae
|
|
18
19
|
def go
|
19
20
|
generate_static_page_controller
|
20
21
|
generate_static_page_model
|
22
|
+
generate_graphql_type
|
21
23
|
generate_static_page_view
|
22
24
|
end
|
23
25
|
|
@@ -37,6 +39,12 @@ module Fae
|
|
37
39
|
template "models/pages_model.rb", "app/models/#{file_name}_page.rb"
|
38
40
|
end
|
39
41
|
|
42
|
+
def generate_graphql_type
|
43
|
+
return unless uses_graphql
|
44
|
+
@graphql_attributes = @@graphql_attributes
|
45
|
+
template "graphql/graphql_page_type.rb", "app/graphql/types/#{file_name}_page_type.rb"
|
46
|
+
end
|
47
|
+
|
40
48
|
def generate_static_page_view
|
41
49
|
@attributes = @@attributes
|
42
50
|
template "views/static_page_form.html.#{options.template}", "app/views/#{options.namespace}/content_blocks/#{file_name}.html.#{options.template}"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Types::<%= class_name %>PageType < Types::BaseObject
|
2
|
+
|
3
|
+
graphql_name '<%= class_name %>Page'
|
4
|
+
|
5
|
+
field :title, String, null: false
|
6
|
+
<% if @graphql_attributes.present? -%>
|
7
|
+
<% @graphql_attributes.each do |graphql_object| -%>
|
8
|
+
<% if graphql_object[:type]['Types::'] -%>
|
9
|
+
field :<%= graphql_object[:attr] %>, <%= graphql_object[:type] %>, null: true
|
10
|
+
<% else -%>
|
11
|
+
field :<%= graphql_object[:attr] %>, <%= graphql_object[:type] %>,
|
12
|
+
null: true,
|
13
|
+
method: :<%= graphql_object[:attr] %>_content
|
14
|
+
<% end -%>
|
15
|
+
<% end -%>
|
16
|
+
<% end -%>
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Types::<%= class_name %>Type < Types::BaseObject
|
2
|
+
|
3
|
+
graphql_name '<%= class_name %>'
|
4
|
+
|
5
|
+
field :id, ID, null: false
|
6
|
+
<% if @graphql_attributes.present? -%>
|
7
|
+
<% @graphql_attributes.each do |graphql_object| -%>
|
8
|
+
field :<%= graphql_object[:attr] %>, <%= graphql_object[:type] %>, null: true
|
9
|
+
<% end -%>
|
10
|
+
<% end -%>
|
11
|
+
field :created_at, String, null: false
|
12
|
+
field :updated_at, String, null: false
|
13
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fae-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FINE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 4.
|
131
|
+
version: 4.6.2
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 4.
|
138
|
+
version: 4.6.2
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: jquery-ui-rails
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -610,8 +610,10 @@ files:
|
|
610
610
|
- config/initializers/kaminari_config.rb
|
611
611
|
- config/initializers/simple_form.rb
|
612
612
|
- config/initializers/time_formats.rb
|
613
|
+
- config/locales/devise.cs.yml
|
613
614
|
- config/locales/devise.en.yml
|
614
615
|
- config/locales/devise.zh-CN.yml
|
616
|
+
- config/locales/fae.cs.yml
|
615
617
|
- config/locales/fae.en.yml
|
616
618
|
- config/locales/fae.zh-CN.yml
|
617
619
|
- config/locales/simple_form.en.yml
|
@@ -647,6 +649,8 @@ files:
|
|
647
649
|
- lib/generators/fae/templates/controllers/nested_scaffold_controller.rb
|
648
650
|
- lib/generators/fae/templates/controllers/scaffold_controller.rb
|
649
651
|
- lib/generators/fae/templates/controllers/static_pages_controller.rb
|
652
|
+
- lib/generators/fae/templates/graphql/graphql_page_type.rb
|
653
|
+
- lib/generators/fae/templates/graphql/graphql_type.rb
|
650
654
|
- lib/generators/fae/templates/initializers/fae.rb
|
651
655
|
- lib/generators/fae/templates/initializers/fae_fine.rb
|
652
656
|
- lib/generators/fae/templates/initializers/judge.rb
|
@@ -685,7 +689,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
685
689
|
version: '0'
|
686
690
|
requirements: []
|
687
691
|
rubyforge_project:
|
688
|
-
rubygems_version: 2.
|
692
|
+
rubygems_version: 2.5.2.3
|
689
693
|
signing_key:
|
690
694
|
specification_version: 4
|
691
695
|
summary: CMS for Rails. For Reals.
|