fae-rails 1.7.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +0 -3
  3. data/app/assets/images/fae/tutorial_model_location.png +0 -0
  4. data/app/assets/javascripts/fae/_tables.js +11 -25
  5. data/app/assets/javascripts/fae/application.js +2 -2
  6. data/app/assets/javascripts/fae/fae_init.js +0 -4
  7. data/app/assets/javascripts/fae/form/_ajax.js +3 -6
  8. data/app/assets/javascripts/fae/form/_validator.js +2 -2
  9. data/app/assets/javascripts/fae/navigation/_language.js +1 -1
  10. data/app/assets/javascripts/fae/navigation/_navigation.js +9 -21
  11. data/app/assets/javascripts/fae/navigation/_subnav_highlighter.js +7 -41
  12. data/app/assets/stylesheets/fae/base.scss +2 -6
  13. data/app/assets/stylesheets/fae/globals/imports/_variables.scss +0 -2
  14. data/app/assets/stylesheets/fae/globals/layout/_content-header.scss +9 -29
  15. data/app/assets/stylesheets/fae/pages/_home.scss +18 -0
  16. data/app/controllers/fae/base_controller.rb +1 -1
  17. data/app/controllers/fae/pages_controller.rb +3 -2
  18. data/app/helpers/fae/application_helper.rb +1 -1
  19. data/app/helpers/fae/form_helper.rb +3 -4
  20. data/app/helpers/fae/nested_form_helper.rb +2 -2
  21. data/app/helpers/fae/view_helper.rb +1 -3
  22. data/app/models/concerns/fae/base_model_concern.rb +1 -7
  23. data/app/models/fae/change.rb +1 -1
  24. data/app/models/fae/file.rb +1 -1
  25. data/app/models/fae/image.rb +1 -1
  26. data/app/models/fae/option.rb +1 -1
  27. data/app/models/fae/role.rb +1 -1
  28. data/app/models/fae/static_page.rb +4 -0
  29. data/app/uploaders/fae/file_uploader.rb +1 -4
  30. data/app/uploaders/fae/image_uploader.rb +2 -2
  31. data/app/views/fae/images/_image_uploader.html.slim +2 -2
  32. data/app/views/fae/options/_form.html.slim +1 -1
  33. data/app/views/fae/pages/home.html.slim +32 -21
  34. data/app/views/fae/shared/_form_header.html.slim +33 -33
  35. data/app/views/fae/shared/_nested_table.html.slim +2 -4
  36. data/app/views/fae/users/index.html.slim +1 -1
  37. data/db/migrate/20140809222030_add_user_table.rb +1 -1
  38. data/db/migrate/20140822224029_create_fae_roles.rb +1 -1
  39. data/db/migrate/20141008180718_create_fae_images_table.rb +1 -1
  40. data/db/migrate/20141017194616_create_fae_options.rb +1 -1
  41. data/db/migrate/20141021181327_create_fae_files.rb +1 -1
  42. data/db/migrate/20141021183047_create_fae_text_areas.rb +1 -1
  43. data/db/migrate/20141021184311_create_fae_pages.rb +1 -1
  44. data/db/migrate/20141105214814_create_fae_text_fields.rb +1 -1
  45. data/db/migrate/20150930224821_create_fae_changes.rb +1 -1
  46. data/lib/fae/options.rb +1 -1
  47. data/lib/fae/version.rb +1 -1
  48. data/lib/generators/fae/base_generator.rb +5 -4
  49. data/lib/generators/fae/nested_index_scaffold_generator.rb +0 -1
  50. data/lib/generators/fae/nested_scaffold_generator.rb +2 -2
  51. data/lib/generators/fae/scaffold_generator.rb +0 -1
  52. data/lib/generators/fae/templates/views/_form.html.slim +1 -3
  53. data/lib/generators/fae/templates/views/index_nested.html.slim +1 -0
  54. data/lib/generators/fae/templates/views/static_page_form.html.slim +1 -2
  55. metadata +46 -47
  56. data/app/views/fae/shared/_form_buttons.html.slim +0 -11
  57. data/app/views/fae/shared/_nested_table_advanced.html.slim +0 -18
  58. data/lib/sub_test_task_patch.rb +0 -129
@@ -60,7 +60,7 @@ module Fae
60
60
 
61
61
  def change_item_link(change)
62
62
  text = "#{change.changeable_type.gsub('Fae::','')}: "
63
- test_source_method = Rails::VERSION::MAJOR > 4 ? :data_source_exists? : :table_exists?
63
+ test_source_method = :data_source_exists?
64
64
 
65
65
  if change.changeable_type.exclude?('Fae') && change.changeable_type.exclude?('Page') && !ActiveRecord::Base.connection.send(test_source_method, change.changeable_type.tableize)
66
66
  return "#{change.changeable_type}: model destroyed"
@@ -117,8 +117,7 @@ module Fae
117
117
  end
118
118
 
119
119
  def label_and_hint(attribute, options)
120
- # @depreciation - remove dark_hint option in v2.0
121
- hint = options[:hint] || options[:dark_hint]
120
+ hint = options[:hint]
122
121
 
123
122
  options[:helper_text] = attempt_common_helper_text(attribute) if options[:helper_text].blank?
124
123
 
@@ -229,9 +228,9 @@ module Fae
229
228
  def attempt_common_helper_text(attribute)
230
229
  case attribute
231
230
  when :seo_title
232
- return 'Company Name | Keyword-driven description of the page section. Approx 65 characters.'
231
+ return 'A descriptive page title of ~50-65 characters. Displayed in search engine results.'
233
232
  when :seo_description
234
- return 'Displayed in search engine results. Under 150 characters.'
233
+ return 'A helpful page summary of 320 characters or less. Displayed in search engine results.'
235
234
  else
236
235
  ''
237
236
  end
@@ -29,9 +29,9 @@ module Fae
29
29
  end
30
30
  end
31
31
  elsif item.class.columns_hash[attribute.to_s].present? && item.class.columns_hash[attribute.to_s].type == :boolean
32
- content_tag(:td) do attr_toggle(item, attribute) end
32
+ content_tag(:td, fae_toggle(item, attribute))
33
33
  else
34
- content_tag(:td) do col_name_or_image(item, attribute) end
34
+ content_tag(:td, col_name_or_image(item, attribute))
35
35
  end
36
36
  end
37
37
 
@@ -32,7 +32,7 @@ module Fae
32
32
  end
33
33
  end
34
34
 
35
- def attr_toggle(item, column)
35
+ def fae_toggle(item, column)
36
36
  active = item.send(column)
37
37
  link_class = active ? 'slider-yes-selected' : ''
38
38
  model_name = item.class.to_s.gsub('::','__').underscore.pluralize
@@ -46,8 +46,6 @@ module Fae
46
46
  </div>'.html_safe
47
47
  end
48
48
  end
49
- # for backwards compatibility
50
- alias_method :fae_toggle, :attr_toggle
51
49
 
52
50
  def fae_clone_button(item)
53
51
  return if item.blank?
@@ -45,12 +45,6 @@ module Fae
45
45
  end
46
46
  end
47
47
 
48
- # @depreciation - deprecate in v2.0
49
- def filter_all
50
- # override this method in your model
51
- for_fae_index
52
- end
53
-
54
48
  def filter(params)
55
49
  # override this method in your model
56
50
  for_fae_index
@@ -69,7 +63,7 @@ module Fae
69
63
  end
70
64
  end
71
65
 
72
- def translate(*attributes)
66
+ def fae_translate(*attributes)
73
67
  attributes.each do |attribute|
74
68
  define_method attribute.to_s do
75
69
  self.send "#{attribute}_#{I18n.locale}"
@@ -45,7 +45,7 @@ module Fae
45
45
  # apply conditions and search from above to our scope
46
46
  order(id: :desc)
47
47
  .includes(:user).references(:user)
48
- .where(date_scope).where(conditions).where(search)
48
+ .where(Arel.sql(date_scope)).where(conditions).where(Arel.sql(search))
49
49
  end
50
50
 
51
51
  end
@@ -14,7 +14,7 @@ module Fae
14
14
  maximum: Fae.max_file_upload_size.megabytes.to_i
15
15
  }
16
16
 
17
- belongs_to :fileable, polymorphic: true, touch: true
17
+ belongs_to :fileable, polymorphic: true, touch: true, optional: true
18
18
 
19
19
  def readonly?
20
20
  false
@@ -17,7 +17,7 @@ module Fae
17
17
  maximum: Fae.max_image_upload_size.megabytes.to_i
18
18
  }
19
19
 
20
- belongs_to :imageable, polymorphic: true, touch: true
20
+ belongs_to :imageable, polymorphic: true, touch: true, optional: true
21
21
 
22
22
  def readonly?
23
23
  false
@@ -27,7 +27,7 @@ module Fae
27
27
  instance = first
28
28
 
29
29
  if instance.blank?
30
- instance = Option.new({title: 'My FINE Admin', time_zone: 'Pacific Time (US & Canada)', live_url: 'http://www.wearefine.com'})
30
+ instance = Option.new({title: 'My Fae Admin', time_zone: 'Pacific Time (US & Canada)', live_url: 'http://www.wearefine.com'})
31
31
  instance.singleton_guard = 0
32
32
  instance.save!
33
33
  end
@@ -7,7 +7,7 @@ module Fae
7
7
  has_many :users
8
8
 
9
9
  acts_as_list add_new_at: :bottom
10
- default_scope { order('-position DESC') }
10
+ default_scope { order(Arel.sql('-position DESC')) }
11
11
 
12
12
  scope :public_roles, -> {where.not(name: 'super admin')}
13
13
 
@@ -91,6 +91,10 @@ module Fae
91
91
  case assoc_obj.class.name
92
92
  when 'Fae::TextField', 'Fae::TextArea'
93
93
  return assoc_obj.content
94
+ when 'Fae::Image', 'Fae::File'
95
+ assoc_json = assoc_obj.as_json
96
+ assoc_json['asset'] = assoc_obj.asset.as_json
97
+ return assoc_json
94
98
  else
95
99
  return assoc_obj.as_json
96
100
  end
@@ -2,11 +2,8 @@
2
2
  module Fae
3
3
  class FileUploader < CarrierWave::Uploader::Base
4
4
 
5
- # Include RMagick support:
6
- # include CarrierWave::RMagick
7
- include CarrierWave::MimeTypes
5
+ include CarrierWave::MiniMagick
8
6
 
9
- process :set_content_type
10
7
  process :save_file_size_in_model
11
8
 
12
9
  def save_file_size_in_model
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
  module Fae
3
3
  class ImageUploader < CarrierWave::Uploader::Base
4
- include CarrierWave::MimeTypes
5
- include CarrierWave::RMagick
4
+
5
+ include CarrierWave::MiniMagick
6
6
 
7
7
  # saves file size to DB
8
8
  process :save_file_size_in_model
@@ -4,8 +4,8 @@ ruby:
4
4
  image_name ||= :image
5
5
  the_image = item.send(image_name)
6
6
  label ||= image_name.to_s.titleize
7
- alt_label ||= "#{label} alt text"
8
- caption_label ||= "#{label} caption"
7
+ alt_label ||= "#{label} Alt Text"
8
+ caption_label ||= "#{label} Caption"
9
9
  helper_text ||= ""
10
10
  alt_helper_text ||= 'Brief description of image contents, used in hover text and by visually impaired users.'
11
11
  caption_helper_text ||= ""
@@ -1,7 +1,7 @@
1
1
  = simple_form_for(@option) do |f|
2
2
  header.content-header.js-content-header
3
3
  h1 Root Settings
4
- .main_content-header-save
4
+ .content-header-buttons
5
5
  a.button#js-header-cancel href=fae.root_path(cancelled: true) Cancel
6
6
  = f.submit 'Save'
7
7
 
@@ -1,25 +1,36 @@
1
1
  header.content-header.js-content-header.-dashboard
2
- i.icon-home>
3
- | &nbsp;&nbsp;Welcome,
4
- strong< = current_user.full_name
2
+ div
3
+ i.icon-home>
4
+ | &nbsp;&nbsp;Hello
5
+ strong< = current_user.full_name
5
6
 
6
7
  == render 'flash_messages'
7
8
 
8
- main.content
9
- table.js-sort-column
10
- thead
11
- tr
12
- th Name
13
- th Type
14
- th.-action-wide Modified
15
- tbody
16
- - @list.each do |item|
17
- - begin
18
- - parent = item.respond_to?(:fae_parent) ? item.fae_parent : nil
19
- - edit_path = edit_polymorphic_path([main_app, fae_scope, parent, item])
20
- - index_path = polymorphic_path([main_app, fae_scope, parent, item.class.to_s.pluralize.underscore])
21
- tr
22
- td: a href=edit_path = item.fae_display_field
23
- td: a href=index_path = item.class.to_s
24
- td = fae_date_format item.updated_at
25
- - rescue
9
+ - if @models.any?
10
+ main.content
11
+ table.js-sort-column
12
+ thead
13
+ tr
14
+ th Name
15
+ th Type
16
+ th.-action-wide Modified
17
+ tbody
18
+ - @list.each do |item|
19
+ - begin
20
+ - parent = item.respond_to?(:fae_parent) ? item.fae_parent : nil
21
+ - edit_path = edit_polymorphic_path([main_app, fae_scope, parent, item])
22
+ - index_path = polymorphic_path([main_app, fae_scope, parent, item.class.to_s.pluralize.underscore])
23
+ tr
24
+ td: a href=edit_path = item.fae_display_field
25
+ td: a href=index_path = item.class.to_s
26
+ td = fae_date_format item.updated_at
27
+ - rescue
28
+ - else
29
+ section.help-section
30
+ article.content
31
+ h2 Welcome to Fae
32
+ p
33
+ ' You don'thave any objects setup to manage. If you need help getting started, check out the
34
+ br
35
+ a href="https://www.faecms.com/documentation/quickstart-guide" target="_blank" Quickstart Guide and Documentation site
36
+ ' .
@@ -1,40 +1,40 @@
1
1
  ruby:
2
2
  require_locals ['header'], local_assigns
3
- save_button_text ||= 'Save'
4
- cancel_button_text ||= 'Cancel'
5
- cloneable ||= false
6
- clone_button_text ||= 'Clone'
7
- subnav ||= []
8
- header_as_string = header.is_a?(String) ? header : header.class.name.split('::').last
9
- header_as_string = header_as_string.singularize
10
- title ||= "#{params[:action]} #{header_as_string}".titleize
11
- breadcrumb = !local_assigns[:breadcrumbs].eql?(false)
12
- language ||= false # @depreciation - remove in favor of `languages` in v2.0
13
- languages ||= language
3
+ save_button_text ||= 'Save'
4
+ cancel_button_text ||= 'Cancel'
5
+ cloneable ||= false
6
+ clone_button_text ||= 'Clone'
7
+ subnav ||= []
8
+ header_as_string = header.is_a?(String) ? header : header.class.name.split('::').last
9
+ header_as_string = header_as_string.singularize
10
+ title ||= "#{params[:action]} #{header_as_string}".titleize
11
+ breadcrumb = !local_assigns[:breadcrumbs].eql?(false)
12
+ languages ||= false
13
+ show_flash_messages = !local_assigns[:show_flash_messages].eql?(false)
14
14
 
15
- - if breadcrumb
16
- == render 'breadcrumb', title: title
17
- - else
18
- = form_header header
15
+ header.content-header.js-content-header
16
+ - if breadcrumb
17
+ == render 'breadcrumb', title: title
18
+ - else
19
+ = form_header header
19
20
 
20
- .content-header-buttons
21
- - if languages
22
- - selected = current_user.language || ''
21
+ .content-header-buttons
22
+ - if languages
23
+ - selected = current_user.language || ''
23
24
 
24
- .content-header-select
25
- = select_tag 'fae-languages', options_for_select(Fae.languages.map(&:reverse), selected), id: 'js-language', class: 'small_pulldown', prompt: 'All Languages'
25
+ .content-header-select
26
+ = select_tag 'fae-languages', options_for_select(Fae.languages.map(&:reverse), selected), id: 'js-language', class: 'small_pulldown', prompt: 'All Languages'
26
27
 
27
- a.button#js-header-cancel href=@index_path = cancel_button_text
28
- - if cloneable.present? && params[:id].present?
29
- a.button data-method="post" href="#{@index_path}?from_existing=#{params[:id]}" = clone_button_text
30
- input name="commit" type="submit" value=save_button_text
28
+ a.button#js-header-cancel href=@index_path = cancel_button_text
29
+ - if cloneable.present? && params[:id].present?
30
+ a.button data-method="post" href="#{@index_path}?from_existing=#{params[:id]}" = clone_button_text
31
+ input name="commit" type="submit" value=save_button_text
31
32
 
32
- - if subnav.present?
33
- ul.content-header-subnav#js-content-header-subnav
34
- ruby:
35
- # @depreciation - remove conditional when Rails 4 support is dropped, below becomes:
36
- # link.parameterize(separator: '_')
37
- parameterize_argument = Rails::VERSION::MAJOR == 4 ? '_' : { separator: '_' }
38
- - subnav.each do |link, id_selector|
39
- - subnav_item = link.is_a?(Array) ? link : [link, link.parameterize(parameterize_argument)]
40
- li: a href="##{subnav_item[1]}" = subnav_item[0]
33
+ - if subnav.present?
34
+ ul.content-header-subnav#js-content-header-subnav
35
+ - subnav.each do |link, id_selector|
36
+ - subnav_item = link.is_a?(Array) ? link : [link, link.parameterize(separator: '_')]
37
+ li: a href="##{subnav_item[1]}" = subnav_item[0]
38
+
39
+ - if show_flash_messages
40
+ == render 'fae/shared/errors'
@@ -9,9 +9,7 @@ ruby:
9
9
 
10
10
  # optional locals
11
11
  assoc_name ||= assoc.to_s # 'restaurant_bars'
12
- # @depreciation - remove header option in v2.0
13
- header ||= assoc_name.titleize # 'Restaurant Bars'
14
- title ||= header
12
+ title ||= assoc_name.titleize # 'Restaurant Bars'
15
13
  add_button_text ||= "Add #{title.singularize}"
16
14
  ordered ||= false
17
15
  has_thumb ||= false
@@ -35,7 +33,7 @@ ruby:
35
33
  new_path += "item_id=#{parent_item.id}&=item_class=#{parent_item.class.to_s}"
36
34
  end
37
35
 
38
- options_for_table = { index: index, assoc: assoc, assoc_name: assoc_name, title: title, header: header, add_button_text: add_button_text, ordered: ordered, has_thumb: has_thumb, edit_column: edit_column, cols: cols, assoc_name_singular: assoc_name_singular, new_path: new_path, edit_path: edit_path }
36
+ options_for_table = { index: index, assoc: assoc, assoc_name: assoc_name, title: title, add_button_text: add_button_text, ordered: ordered, has_thumb: has_thumb, edit_column: edit_column, cols: cols, assoc_name_singular: assoc_name_singular, new_path: new_path, edit_path: edit_path }
39
37
  options_for_table[:parent_item] = parent_item unless index
40
38
 
41
39
  section.addedit-form.js-addedit-form class="#{'content' if index}"
@@ -19,5 +19,5 @@ main.content
19
19
  td = user.email
20
20
  td = user.role.name
21
21
  td = fae_date_format user.last_sign_in_at if user.last_sign_in_at.present?
22
- td = attr_toggle user, :active unless current_user == user
22
+ td = fae_toggle user, :active unless current_user == user
23
23
  td = fae_delete_button user, user unless current_user == user
@@ -1,4 +1,4 @@
1
- class AddUserTable < ActiveRecord::Migration
1
+ class AddUserTable < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table(:fae_users) do |t|
4
4
  ## Database authenticatable
@@ -1,4 +1,4 @@
1
- class CreateFaeRoles < ActiveRecord::Migration
1
+ class CreateFaeRoles < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :fae_roles do |t|
4
4
  t.string :name
@@ -1,4 +1,4 @@
1
- class CreateFaeImagesTable < ActiveRecord::Migration
1
+ class CreateFaeImagesTable < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table(:fae_images) do |t|
4
4
  t.string :name
@@ -1,4 +1,4 @@
1
- class CreateFaeOptions < ActiveRecord::Migration
1
+ class CreateFaeOptions < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :fae_options do |t|
4
4
  t.string :title
@@ -1,4 +1,4 @@
1
- class CreateFaeFiles < ActiveRecord::Migration
1
+ class CreateFaeFiles < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :fae_files do |t|
4
4
  t.string :name
@@ -1,4 +1,4 @@
1
- class CreateFaeTextAreas < ActiveRecord::Migration
1
+ class CreateFaeTextAreas < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :fae_text_areas do |t|
4
4
  t.string :label
@@ -1,4 +1,4 @@
1
- class CreateFaePages < ActiveRecord::Migration
1
+ class CreateFaePages < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :fae_static_pages do |t|
4
4
  t.string :title
@@ -1,4 +1,4 @@
1
- class CreateFaeTextFields < ActiveRecord::Migration
1
+ class CreateFaeTextFields < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :fae_text_fields do |t|
4
4
  t.references :contentable, polymorphic: true, index: true
@@ -1,4 +1,4 @@
1
- class CreateFaeChanges < ActiveRecord::Migration
1
+ class CreateFaeChanges < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :fae_changes do |t|
4
4
  t.integer :changeable_id
@@ -5,7 +5,7 @@ require_relative 'validation_helper_collection'
5
5
  module Fae
6
6
  # configurable defaults
7
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, :has_top_nav, :disabled_environments, :per_page, :use_cache
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
9
9
 
10
10
  self.devise_secret_key = ''
11
11
  self.devise_mailer_sender = 'change-me@example.com'
@@ -1,3 +1,3 @@
1
1
  module Fae
2
- VERSION = '1.7.1'
2
+ VERSION = '2.0.0'
3
3
  end
@@ -50,8 +50,9 @@ module Fae
50
50
  def generate_model
51
51
  generate "model #{file_name} #{@@attributes_flat}"
52
52
  inject_concern
53
- inject_position_scope
53
+ inject_display_field_to_model
54
54
  inject_model_attachments
55
+ inject_position_scope
55
56
  end
56
57
 
57
58
  def generate_controller_file
@@ -105,9 +106,9 @@ RUBY
105
106
  end
106
107
 
107
108
  inject_into_file "app/models/#{file_name}.rb", after: "include Fae::BaseModelConcern\n" do <<-RUBY
108
- \n def fae_display_field
109
+ def fae_display_field
109
110
  #{@@display_field}
110
- end\n
111
+ end
111
112
  RUBY
112
113
  end
113
114
 
@@ -117,7 +118,7 @@ RUBY
117
118
  if @@has_position
118
119
  inject_into_file "app/models/#{file_name}.rb", after: "include Fae::BaseModelConcern\n" do <<-RUBY
119
120
  \n acts_as_list add_new_at: :top
120
- default_scope { order(:position) }
121
+ default_scope { order(:position) }\n
121
122
  RUBY
122
123
  end
123
124
  end