fae-rails 2.1.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -2
  3. data/app/assets/config/fae/manifest.js +2 -0
  4. data/app/assets/javascripts/fae/_contrast.js +50 -0
  5. data/app/assets/javascripts/fae/_deploy.js +198 -0
  6. data/app/assets/javascripts/fae/_modals.js +94 -0
  7. data/app/assets/javascripts/fae/application.js +7 -1
  8. data/app/assets/javascripts/fae/form/_ajax.js +17 -5
  9. data/app/assets/javascripts/fae/form/_filtering.js +34 -0
  10. data/app/assets/javascripts/fae/form/_form.js +5 -2
  11. data/app/assets/javascripts/fae/form/_form_manager.js +295 -0
  12. data/app/assets/javascripts/fae/form/_slugger.js.erb +2 -2
  13. data/app/assets/javascripts/fae/form/_validator.js +224 -55
  14. data/app/assets/javascripts/fae/form/drag_drop.js +109 -0
  15. data/app/assets/javascripts/fae/form/inputs/_select.js +10 -4
  16. data/app/assets/javascripts/fae/form/inputs/_text.js +23 -9
  17. data/app/assets/javascripts/fae/vendor/simplemde/codemirror-4.inline-attachment.js +95 -0
  18. data/app/assets/javascripts/fae/vendor/simplemde/inline-attachment.js +405 -0
  19. data/app/assets/stylesheets/fae/application.css +1 -0
  20. data/app/assets/stylesheets/fae/base.scss +7 -3
  21. data/app/assets/stylesheets/fae/globals/_tags.scss +1 -1
  22. data/app/assets/stylesheets/fae/globals/imports/_variables.scss +1 -0
  23. data/app/assets/stylesheets/fae/globals/layout/_base.scss +9 -4
  24. data/app/assets/stylesheets/fae/globals/layout/_content-header.scss +14 -4
  25. data/app/assets/stylesheets/fae/globals/legacy/_pre-1.3.scss +1 -1
  26. data/app/assets/stylesheets/fae/globals/navigation/_footer.scss +1 -1
  27. data/app/assets/stylesheets/fae/globals/navigation/_header.scss +3 -3
  28. data/app/assets/stylesheets/fae/globals/navigation/_multi-col-subnav.scss +50 -0
  29. data/app/assets/stylesheets/fae/globals/navigation/_sidenav.scss +2 -2
  30. data/app/assets/stylesheets/fae/globals/navigation/_utility.scss +1 -1
  31. data/app/assets/stylesheets/fae/modules/_buttons.scss +11 -0
  32. data/app/assets/stylesheets/fae/modules/_deploy.scss +25 -0
  33. data/app/assets/stylesheets/fae/modules/_errors-bar.scss +19 -0
  34. data/app/assets/stylesheets/fae/modules/_modal.scss +25 -0
  35. data/app/assets/stylesheets/fae/modules/_toggles.scss +39 -23
  36. data/app/assets/stylesheets/fae/modules/forms/_asset-actions.scss +1 -1
  37. data/app/assets/stylesheets/fae/modules/forms/_base.scss +14 -1
  38. data/app/assets/stylesheets/fae/modules/forms/_checkbox.scss +1 -1
  39. data/app/assets/stylesheets/fae/modules/forms/_date.scss +20 -4
  40. data/app/assets/stylesheets/fae/modules/forms/_form-manager.scss +82 -0
  41. data/app/assets/stylesheets/fae/modules/forms/_hints.scss +1 -1
  42. data/app/assets/stylesheets/fae/modules/forms/_label.scss +1 -1
  43. data/app/assets/stylesheets/fae/modules/forms/_radio.scss +1 -1
  44. data/app/assets/stylesheets/fae/modules/forms/_select.scss +9 -8
  45. data/app/assets/stylesheets/fae/modules/forms/_simple-mde.scss +72 -1
  46. data/app/assets/stylesheets/fae/modules/forms/_textarea.scss +1 -1
  47. data/app/assets/stylesheets/fae/modules/tables/_base.scss +1 -1
  48. data/app/assets/stylesheets/fae/modules/tables/_filters.scss +4 -0
  49. data/app/assets/stylesheets/fae/modules/tables/_pagination.scss +2 -2
  50. data/app/assets/stylesheets/fae/pages/_error.scss +1 -1
  51. data/app/assets/stylesheets/fae/pages/_login.scss +5 -1
  52. data/app/assets/stylesheets/fae/simplemde_override.scss +32 -0
  53. data/app/controllers/fae/application_controller.rb +9 -2
  54. data/app/controllers/fae/base_controller.rb +6 -2
  55. data/app/controllers/fae/deploy_controller.rb +24 -0
  56. data/app/controllers/fae/deploy_hooks_controller.rb +71 -0
  57. data/app/controllers/fae/form_managers_controller.rb +19 -0
  58. data/app/controllers/fae/options_controller.rb +1 -0
  59. data/app/controllers/fae/setup_controller.rb +2 -2
  60. data/app/controllers/fae/static_pages_controller.rb +6 -1
  61. data/app/controllers/fae/users_controller.rb +11 -1
  62. data/app/controllers/fae/utilities_controller.rb +18 -6
  63. data/app/helpers/fae/application_helper.rb +36 -2
  64. data/app/helpers/fae/form_helper.rb +26 -2
  65. data/app/helpers/fae/view_helper.rb +26 -9
  66. data/app/models/concerns/fae/base_model_concern.rb +17 -0
  67. data/app/models/concerns/fae/seo_set_concern.rb +1 -0
  68. data/app/models/fae/change.rb +20 -6
  69. data/app/models/fae/deploy_hook.rb +12 -0
  70. data/app/models/fae/form_manager.rb +24 -0
  71. data/app/models/fae/option.rb +1 -0
  72. data/app/models/fae/seo_set.rb +14 -0
  73. data/app/models/fae/user.rb +2 -2
  74. data/app/services/fae/netlify_api.rb +213 -0
  75. data/app/uploaders/fae/file_uploader.rb +1 -1
  76. data/app/uploaders/fae/image_uploader.rb +2 -2
  77. data/app/views/devise/unlocks/new.html.slim +5 -9
  78. data/app/views/fae/application/_content_form.html.slim +16 -11
  79. data/app/views/fae/application/_file_uploader.html.slim +7 -2
  80. data/app/views/fae/application/_global_search_results.html.slim +1 -1
  81. data/app/views/fae/application/_header.slim +4 -1
  82. data/app/views/fae/application/_mobilenav.slim +3 -0
  83. data/app/views/fae/application/_seo_set_form.html.slim +12 -0
  84. data/app/views/fae/deploy/index.html.slim +40 -0
  85. data/app/views/fae/deploy_hooks/_form.html.slim +18 -0
  86. data/app/views/fae/deploy_hooks/_table.html.slim +28 -0
  87. data/app/views/fae/deploy_hooks/edit.html.slim +3 -0
  88. data/app/views/fae/deploy_hooks/new.html.slim +3 -0
  89. data/app/views/fae/images/_image_uploader.html.slim +12 -3
  90. data/app/views/fae/options/_form.html.slim +6 -2
  91. data/app/views/fae/pages/activity_log.html.slim +7 -3
  92. data/app/views/fae/pages/home.html.slim +3 -4
  93. data/app/views/fae/shared/_errors.slim +0 -3
  94. data/app/views/fae/shared/_form_header.html.slim +20 -12
  95. data/app/views/fae/shared/_nested_table.html.slim +5 -2
  96. data/app/views/fae/shared/_recent_changes.html.slim +1 -1
  97. data/app/views/fae/shared/_shared_nested_table.html.slim +9 -3
  98. data/app/views/layouts/fae/application.html.slim +2 -1
  99. data/config/deploy.rb +3 -1
  100. data/config/initializers/carrierwave.rb +41 -2
  101. data/config/initializers/devise.rb +6 -6
  102. data/config/initializers/fae_judge.rb +4 -2
  103. data/config/locales/fae.en.yml +49 -4
  104. data/config/locales/fae.zh-CN.yml +2 -2
  105. data/config/puma.rb +82 -0
  106. data/config/routes.rb +9 -1
  107. data/db/migrate/20140809222030_add_user_table.rb +1 -1
  108. data/db/migrate/20190925153222_create_fae_form_managers.rb +11 -0
  109. data/db/migrate/20220118192729_create_fae_publish_hooks.rb +10 -0
  110. data/db/migrate/20220128133730_rename_publish_hooks.rb +5 -0
  111. data/db/migrate/20220202153607_add_position_to_deploy_hooks.rb +6 -0
  112. data/db/migrate/20221118161833_create_fae_seo_sets.rb +13 -0
  113. data/lib/fae/concerns/models/base.rb +2 -0
  114. data/lib/fae/engine.rb +3 -3
  115. data/lib/fae/options.rb +18 -18
  116. data/lib/fae/version.rb +1 -1
  117. data/lib/generators/fae/base_generator.rb +28 -5
  118. data/lib/generators/fae/controller_generator.rb +0 -1
  119. data/lib/generators/fae/install_generator.rb +1 -1
  120. data/lib/generators/fae/model_generator.rb +1 -2
  121. data/lib/generators/fae/nested_index_scaffold_generator.rb +1 -2
  122. data/lib/generators/fae/nested_scaffold_generator.rb +23 -2
  123. data/lib/generators/fae/page_generator.rb +1 -2
  124. data/lib/generators/fae/scaffold_generator.rb +1 -1
  125. data/lib/generators/fae/templates/assets/fae.js +1 -1
  126. data/lib/generators/fae/templates/controllers/nested_scaffold_controller.rb +13 -1
  127. data/lib/generators/fae/templates/controllers/scaffold_controller.rb +7 -0
  128. data/lib/generators/fae/templates/initializers/fae.rb +16 -1
  129. data/lib/generators/fae/templates/views/_form.html.slim +12 -1
  130. data/lib/generators/fae/templates/views/_form_index_nested.html.slim +15 -1
  131. data/lib/generators/fae/templates/views/_form_nested.html.slim +22 -2
  132. data/lib/generators/fae/templates/views/static_page_form.html.slim +13 -1
  133. metadata +53 -24
  134. data/config/deploy/dev.rb +0 -19
  135. data/config/deploy/prod.rb +0 -19
  136. data/config/deploy/stage.rb +0 -19
  137. /data/app/assets/javascripts/fae/vendor/{simplemde.min.js → simplemde/simplemde.min.js} +0 -0
data/config/routes.rb CHANGED
@@ -11,8 +11,10 @@ Fae::Engine.routes.draw do
11
11
  get 'logout' => '/devise/sessions#destroy', as: :destroy_user_session
12
12
  end
13
13
  resources :users
14
+ resources :deploy_hooks
14
15
 
15
16
  get 'settings' => 'users#settings', as: 'settings'
17
+ get 'deploy' => 'deploy#index', as: 'deploy'
16
18
  get 'help' => 'pages#help', as: 'help'
17
19
  get 'activity' => 'pages#activity_log', as: 'activity_log'
18
20
  post 'activity/filter' => 'pages#activity_log_filter', as: 'activity_log_filter'
@@ -38,7 +40,13 @@ Fae::Engine.routes.draw do
38
40
  get 'content_blocks/:slug' => '/admin/content_blocks#edit', as: 'edit_content_block'
39
41
  match 'content_blocks/:slug/update' => '/admin/content_blocks#update', via: [:put, :patch], as: 'update_content_block'
40
42
 
41
- # catch all 404
43
+ get 'form_managers/fields' => 'form_managers#fields', as: 'form_managers_fields'
44
+ post 'form_managers/update' => 'form_managers#update', as: 'form_managers_update'
45
+
46
+ get 'deploy/deploys_list' => 'deploy#deploys_list', as: 'deploy_deploys_list'
47
+ post 'deploy/deploy_site' => 'deploy#deploy_site', as: 'deploy_deploy_site'
48
+
49
+ ## catch all 404
42
50
  match "*path" => 'pages#error404', via: [:get, :post]
43
51
 
44
52
  end
@@ -34,7 +34,7 @@ class AddUserTable < ActiveRecord::Migration[4.2]
34
34
  t.string :first_name
35
35
  t.string :last_name
36
36
  t.integer :role_id
37
- t.boolean :active
37
+ t.boolean :active, :default => true, :null => false
38
38
  t.string :language
39
39
 
40
40
  t.timestamps
@@ -0,0 +1,11 @@
1
+ class CreateFaeFormManagers < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :fae_form_managers do |t|
4
+ t.string :form_manager_model_name, index: true
5
+ t.integer :form_manager_model_id, index: true
6
+ t.text :fields
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ class CreateFaePublishHooks < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :fae_publish_hooks do |t|
4
+ t.string :url
5
+ t.string :environment, index: true
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ class RenamePublishHooks < ActiveRecord::Migration[5.2]
2
+ def change
3
+ rename_table :fae_publish_hooks, :fae_deploy_hooks
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ class AddPositionToDeployHooks < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :fae_deploy_hooks, :position, :integer
4
+ add_index :fae_deploy_hooks, :position
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+ class CreateFaeSeoSets < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :fae_seo_sets do |t|
4
+ t.string :seo_title
5
+ t.text :seo_description
6
+ t.string :social_media_title
7
+ t.text :social_media_description
8
+ t.references :seo_setable, polymorphic: true, index: true
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,5 @@
1
+ # TODO - can we remove this/do we need backwards compaitibility?
2
+
1
3
  # moved to app/models/concerns/fae/base_model_concern.rb
2
4
  # keep for backwards compatibility
3
5
  module Fae::Concerns::Models::Base
data/lib/fae/engine.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'devise'
2
-
3
2
  module Fae
4
3
  class Engine < ::Rails::Engine
5
4
  isolate_namespace Fae
@@ -15,8 +14,9 @@ module Fae
15
14
  require 'slim'
16
15
  require 'kaminari'
17
16
  require 'fae/version'
17
+ require "sprockets/railtie"
18
18
 
19
- config.autoload_paths += %W(#{config.root}/lib)
19
+ config.eager_load_paths += %W(#{config.root}/app)
20
20
 
21
21
  config.to_prepare do
22
22
  # Require decorators from main application
@@ -29,7 +29,7 @@ module Fae
29
29
 
30
30
  config.generators do |g|
31
31
  g.test_framework :rspec, fixture: false
32
- g.fixture_replacement :factory_girl, dir: 'spec/factories'
32
+ g.fixture_replacement :factory_bot, dir: 'spec/factories'
33
33
  g.assets false
34
34
  g.helper false
35
35
  end
data/lib/fae/options.rb CHANGED
@@ -4,24 +4,24 @@ require_relative 'validation_helper_collection'
4
4
 
5
5
  module Fae
6
6
  # configurable defaults
7
- class << self
8
- mattr_accessor :devise_secret_key, :devise_mailer_sender, :dashboard_exclusions, :max_image_upload_size, :max_file_upload_size, :languages, :recreate_versions, :validation_helpers, :track_changes, :tracker_history_length, :slug_separator, :disabled_environments, :per_page, :use_cache
7
+ mattr_accessor :devise_secret_key, :devise_mailer_sender, :dashboard_exclusions, :max_image_upload_size, :max_file_upload_size, :languages, :recreate_versions, :validation_helpers, :track_changes, :tracker_history_length, :slug_separator, :disabled_environments, :per_page, :use_cache, :use_form_manager, :netlify
9
8
 
10
- self.devise_secret_key = ''
11
- self.devise_mailer_sender = 'change-me@example.com'
12
- self.dashboard_exclusions = []
13
- self.max_image_upload_size = 2
14
- self.max_file_upload_size = 5
15
- self.languages = {}
16
- self.recreate_versions = false
17
- self.validation_helpers = ValidationHelperCollection.new
18
- self.track_changes = true
19
- self.tracker_history_length = 15
20
- self.slug_separator = '-'
21
- self.disabled_environments = []
22
- self.per_page = 25
23
- self.use_cache = false
24
- end
9
+ self.devise_secret_key = ''
10
+ self.devise_mailer_sender = 'change-me@example.com'
11
+ self.dashboard_exclusions = []
12
+ self.max_image_upload_size = 2
13
+ self.max_file_upload_size = 5
14
+ self.languages = {}
15
+ self.recreate_versions = false
16
+ self.validation_helpers = ValidationHelperCollection.new
17
+ self.track_changes = true
18
+ self.tracker_history_length = 15
19
+ self.slug_separator = '-'
20
+ self.disabled_environments = []
21
+ self.per_page = 25
22
+ self.use_cache = false
23
+ self.use_form_manager = false
24
+ self.netlify = {}
25
25
 
26
26
  # this function maps the vars from your app into your engine
27
27
  def self.setup(&block)
@@ -32,4 +32,4 @@ module Fae
32
32
  Devise.mailer_sender = Fae.devise_mailer_sender
33
33
  Kaminari.config.default_per_page = Fae.per_page
34
34
  end
35
- end
35
+ end
data/lib/fae/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fae
2
- VERSION = '2.1.0'
2
+ VERSION = '3.0.0'
3
3
  end
@@ -4,6 +4,9 @@ module Fae
4
4
  argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
5
5
  class_option :namespace, type: :string, default: 'admin', desc: 'Sets the namespace of the generator'
6
6
  class_option :template, type: :string, default: 'slim', desc: 'Sets the template engine of the generator'
7
+ class_option :polymorphic, type: :boolean, default: false, desc: 'Makes the model and scaffolding polymorphic. parent-model is ignored if passed.'
8
+
9
+ Rails::Generators::GeneratedAttribute::DEFAULT_TYPES += ['image', 'file', 'seo_set']
7
10
 
8
11
  @@attributes_flat = []
9
12
  @@attribute_names = []
@@ -21,12 +24,15 @@ module Fae
21
24
  def set_globals
22
25
  if attributes.present?
23
26
  attributes.each do |arg|
24
- # :image and :file args get used to generate association defs and form elements
25
- # we don't want them in attributes_flat or attribute_names as they are not real model generator field options
27
+ # prevent these from being in attributes_flat or attribute_names as they are not real model generator field options
26
28
  if is_attachment(arg)
27
29
  @@attachments << arg
28
30
  else
29
- @@attributes_flat << "#{arg.name}:#{arg.type}"
31
+ @@attributes_flat << "#{arg.name}:#{arg.type}" + (arg.has_index? ? ":index" : "")
32
+ end
33
+
34
+ if options.polymorphic
35
+ @@attributes_flat << "#{polymorphic_name}:references{polymorphic}"
30
36
  end
31
37
 
32
38
  if is_association(arg)
@@ -71,6 +77,7 @@ module Fae
71
77
  @attachments = @@attachments
72
78
  @has_position = @@has_position
73
79
  @display_field = @@display_field
80
+ @polymorphic_name = polymorphic_name
74
81
  template "views/index.html.#{options.template}", "app/views/#{options.namespace}/#{plural_file_name}/index.html.#{options.template}"
75
82
  template "views/_form.html.#{options.template}", "app/views/#{options.namespace}/#{plural_file_name}/_form.html.#{options.template}"
76
83
  copy_file "views/new.html.#{options.template}", "app/views/#{options.namespace}/#{plural_file_name}/new.html.#{options.template}"
@@ -137,6 +144,12 @@ RUBY
137
144
  has_fae_image :#{attachment.name}\n
138
145
  RUBY
139
146
  end
147
+ elsif attachment.type == :seo_set
148
+ inject_into_file "app/models/#{file_name}.rb", after: "include Fae::BaseModelConcern\n" do
149
+ <<-RUBY
150
+ has_fae_seo_set :#{attachment.name}\n
151
+ RUBY
152
+ end
140
153
  elsif attachment.type == :file
141
154
  inject_into_file "app/models/#{file_name}.rb", after: "include Fae::BaseModelConcern\n" do
142
155
  <<-RUBY
@@ -172,6 +185,8 @@ RUBY
172
185
  'Types::FaeImageType'
173
186
  when 'file'
174
187
  'Types::FaeFileType'
188
+ when 'seo_set'
189
+ 'Types::FaeSeoSetType'
175
190
  else
176
191
  'String'
177
192
  end
@@ -192,8 +207,16 @@ RUBY
192
207
  end
193
208
 
194
209
  def is_attachment(arg)
195
- [:image,:file].include?(arg.type)
210
+ [:image, :file, :seo_set].include?(arg.type)
211
+ end
212
+
213
+ def polymorphic_name
214
+ "#{file_name.underscore}able"
215
+ end
216
+
217
+ def polymorphic_name
218
+ "#{file_name.underscore}able"
196
219
  end
197
220
 
198
221
  end
199
- end
222
+ end
@@ -1,4 +1,3 @@
1
- require_relative 'base_generator'
2
1
  module Fae
3
2
  class ControllerGenerator < Fae::BaseGenerator
4
3
  source_root ::File.expand_path('../templates', __FILE__)
@@ -58,4 +58,4 @@ RUBY
58
58
  end
59
59
 
60
60
  end
61
- end
61
+ end
@@ -1,4 +1,3 @@
1
- require_relative 'base_generator'
2
1
  module Fae
3
2
  class ModelGenerator < Fae::BaseGenerator
4
3
  source_root ::File.expand_path('../templates', __FILE__)
@@ -8,4 +7,4 @@ module Fae
8
7
  end
9
8
 
10
9
  end
11
- end
10
+ end
@@ -1,4 +1,3 @@
1
- require_relative 'base_generator'
2
1
  module Fae
3
2
  class NestedIndexScaffoldGenerator < Fae::BaseGenerator
4
3
  source_root ::File.expand_path('../templates', __FILE__)
@@ -34,4 +33,4 @@ module Fae
34
33
  end
35
34
 
36
35
  end
37
- end
36
+ end
@@ -21,10 +21,12 @@ module Fae
21
21
  inject_model_attachments
22
22
  inject_position_scope
23
23
  inject_parent_info if options.parent_model.present?
24
+ inject_polymorphic_info if options.polymorphic
24
25
  end
25
26
 
26
27
  def generate_nested_controller_file
27
28
  @attachments = @@attachments
29
+ @polymorphic_name = polymorphic_name
28
30
  template "controllers/nested_scaffold_controller.rb", "app/controllers/#{options.namespace}/#{file_name.pluralize}_controller.rb"
29
31
  end
30
32
 
@@ -39,11 +41,30 @@ module Fae
39
41
 
40
42
  def inject_parent_info
41
43
  inject_into_file "app/models/#{file_name}.rb", after: "BaseModelConcern\n" do <<-RUBY
42
- \n belongs_to :#{options.parent_model.underscore}, touch: true
44
+ \n belongs_to :#{options.parent_model.underscore}, touch: true
45
+ def fae_nested_parent
46
+ :#{options.parent_model.underscore}
47
+ end
48
+ RUBY
49
+ end
50
+ end
51
+
52
+ def inject_polymorphic_info
53
+ inject_into_file "app/models/#{file_name}.rb", after: "BaseModelConcern\n" do <<-RUBY
54
+ def fae_nested_parent
55
+ :#{polymorphic_name}
56
+ end
57
+ RUBY
58
+ end
59
+ end
60
+
61
+ def inject_polymorphic_info
62
+ inject_into_file "app/models/#{file_name}.rb", after: "BaseModelConcern\n" do <<-RUBY
43
63
 
44
64
  def fae_nested_parent
45
- :#{options.parent_model.underscore}
65
+ :#{polymorphic_name}
46
66
  end
67
+
47
68
  RUBY
48
69
  end
49
70
  end
@@ -1,5 +1,4 @@
1
1
  require_relative 'base_generator'
2
-
3
2
  module Fae
4
3
  class PageGenerator < Fae::BaseGenerator
5
4
  desc 'Creates model with dependancies for Fae Static Pages'
@@ -70,4 +69,4 @@ module Fae
70
69
  end
71
70
  end
72
71
  end
73
- end
72
+ end
@@ -13,4 +13,4 @@ module Fae
13
13
  end
14
14
 
15
15
  end
16
- end
16
+ end
@@ -3,4 +3,4 @@
3
3
  // or just add your javascript directly to this file
4
4
 
5
5
  // Uncomment the following line if you want to use Trumbowyg HTML Editor
6
- // //= require fae/vendor/trumbowyg
6
+ // //= require fae/vendor/trumbowyg
@@ -1,5 +1,17 @@
1
1
  module <%= options.namespace.capitalize %>
2
2
  class <%= class_name.pluralize %>Controller < Fae::NestedBaseController
3
+
4
+ <% if options.polymorphic %>
5
+ def new
6
+ @item = @klass.new
7
+ raise_undefined_parent if @item.fae_nested_foreign_key.blank?
8
+ item_id = params[:item_id].to_i || nil
9
+ item_class = params[:item_class] || nil
10
+ @item.send("<%= @polymorphic_name %>_id=", item_id)
11
+ @item.send("<%= @polymorphic_name %>_type=", item_class)
12
+ build_assets
13
+ end
14
+ <% end %>
3
15
  <% if @attachments.present? %>
4
16
  private
5
17
 
@@ -10,4 +22,4 @@ module <%= options.namespace.capitalize %>
10
22
  end
11
23
  <% end %>
12
24
  end
13
- end
25
+ end
@@ -5,7 +5,14 @@ module <%= options.namespace.capitalize %>
5
5
 
6
6
  def build_assets
7
7
  <% @attachments.each do |attachment| -%>
8
+ <% if attachment.type == :seo_set -%>
9
+ if @item.<%= attachment.name %>.blank?
10
+ @item.build_<%= attachment.name %>
11
+ @item.<%= attachment.name %>.build_social_media_image
12
+ end
13
+ <% else -%>
8
14
  @item.build_<%= attachment.name %> if @item.<%= attachment.name %>.blank?
15
+ <% end -%>
9
16
  <% end -%>
10
17
  end
11
18
  <% end %>
@@ -60,4 +60,19 @@ Fae.setup do |config|
60
60
  # on the parent app
61
61
  # Defaults to false
62
62
  # config.use_cache = true
63
- end
63
+
64
+ ## use_form_manager
65
+ # Enable Manage Form buttons in form headers
66
+ # Defaults to false
67
+ # config.use_form_manager = true
68
+
69
+ ## Netlify configs
70
+ # Environment variables are recommended for any sensitive Netlify configuration details.
71
+ # config.netlify = {
72
+ # api_user: 'netlify-api-user',
73
+ # api_token: 'netlify-api-token',
74
+ # site: 'site-name-in-netlify',
75
+ # site_id: 'site-id-in-netlify',
76
+ # api_base: 'https://api.netlify.com/api/v1/'
77
+ # }
78
+ end
@@ -1,4 +1,13 @@
1
- = simple_form_for(['admin', @item]) do |f|
1
+ ruby:
2
+ form_options = {
3
+ html: {
4
+ data: {
5
+ form_manager_model: @item.fae_form_manager_model_name,
6
+ form_manager_info: (@form_manager.present? ? @form_manager.to_json : nil)
7
+ }
8
+ }
9
+ }
10
+ = simple_form_for([:admin, @item], form_options) do |f|
2
11
  == render 'fae/shared/form_header', header: @klass_name
3
12
 
4
13
  main.content
@@ -14,5 +23,7 @@
14
23
  = fae_image_form f, :<%= attachment.name -%>
15
24
  <% elsif attachment.type == :file -%>
16
25
  = fae_file_form f, :<%= attachment.name -%>
26
+ <% elsif attachment.type == :seo_set -%>
27
+ = fae_seo_set_form f, :<%= attachment.name -%>
17
28
  <% end -%>
18
29
  <% end -%>
@@ -1,4 +1,18 @@
1
- = simple_form_for(['<%= options.namespace %>', @item], html: {multipart: true, novalidate: true, class: 'js-file-form'}, remote: true, data: {type: "html"}) do |f|
1
+ ruby:
2
+ form_options = {
3
+ html: {
4
+ multipart: true,
5
+ novalidate: true,
6
+ class: 'js-file-form',
7
+ remote: true,
8
+ data: {
9
+ type: "html",
10
+ form_manager_model: @item.fae_form_manager_model_name,
11
+ form_manager_info: (@form_manager.present? ? @form_manager.to_json : nil)
12
+ }
13
+ }
14
+ }
15
+ = simple_form_for(['<%= options.namespace %>', @item], form_options) do |f|
2
16
  <% @form_attrs.each do |attr| -%>
3
17
  = fae_input f, :<%= attr %>
4
18
  <% end -%>
@@ -1,4 +1,18 @@
1
- = simple_form_for(['<%= options.namespace %>', @item], html: {multipart: true, novalidate: true, class: 'js-file-form'}, remote: true, data: {type: "html"}) do |f|
1
+ ruby:
2
+ form_options = {
3
+ html: {
4
+ multipart: true,
5
+ novalidate: true,
6
+ class: 'js-file-form',
7
+ remote: true,
8
+ data: {
9
+ type: "html",
10
+ form_manager_model: @item.fae_form_manager_model_name,
11
+ form_manager_info: (@form_manager.present? ? @form_manager.to_json : nil)
12
+ }
13
+ }
14
+ }
15
+ = simple_form_for([:admin, @item], form_options) do |f|
2
16
  <% @form_attrs.each do |attr| -%>
3
17
  = fae_input f, :<%= attr %>
4
18
  <% end -%>
@@ -9,9 +23,15 @@
9
23
  = fae_file_form f, :<%= attachment.name -%>
10
24
  <% end -%>
11
25
  <% end -%>
12
- <% if options.parent_model.present? %>
26
+ <% if options.polymorphic %>
27
+ = f.hidden_field :<%= @polymorphic_name %>_id
28
+ = f.hidden_field :<%= @polymorphic_name %>_type
29
+ <% elsif options.parent_model.present? %>
13
30
  = f.hidden_field :<%= options.parent_model.underscore %>_id
14
31
  <% end -%>
15
32
 
16
33
  = f.submit
17
34
  = button_tag 'Cancel', type: 'button', class: 'js-cancel-nested cancel-nested-button'
35
+
36
+ - if Fae.use_form_manager
37
+ a.button.js-launch-form-manager href='#' = t('fae.form.launch_form_manager')
@@ -1,4 +1,16 @@
1
- = simple_form_for @item, url: fae.update_content_block_path(slug: @item.slug), method: :put do |f|
1
+ ruby:
2
+ form_options = {
3
+ url: fae.update_content_block_path(slug: @item.slug),
4
+ method: :put,
5
+ html: {
6
+ data: {
7
+ form_manager_model: @item.fae_form_manager_model_name,
8
+ form_manager_model_id: @item.fae_form_manager_model_id,
9
+ form_manager_info: (@form_manager.present? ? @form_manager.to_json : nil)
10
+ }
11
+ }
12
+ }
13
+ = simple_form_for @item, form_options do |f|
2
14
  == render 'fae/shared/form_header', header: @item
3
15
 
4
16
  main.content