activeadmin-selleo-cms 0.0.2 → 0.0.3

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.
@@ -16,12 +16,9 @@ ActiveAdmin.register ActiveadminSelleoCms::Page, as: "Page", sort_order: "lft_as
16
16
  filter :parent
17
17
 
18
18
  index do
19
- column do |page|
20
- unless page.root?
21
- "#{image_tag('http://placehold.it/20x15') * page.depth}".html_safe
22
- end
19
+ column :title do |page|
20
+ "#{'—' * page.depth} #{page.title}".html_safe
23
21
  end
24
- column :title
25
22
  column :show_in_menu do |page|
26
23
  check_box_tag "activeadmin_selleo_cms_page[show_in_menu][#{page.id}]", 1, page.show_in_menu, data: { route: admin_page_path(page.id), id: page.id, resource: 'page', attribute: 'show_in_menu' }
27
24
  end
@@ -44,23 +41,17 @@ ActiveAdmin.register ActiveadminSelleoCms::Page, as: "Page", sort_order: "lft_as
44
41
  controller do
45
42
  respond_to :html, :js
46
43
 
47
- def index
48
- index! {
49
- #@pages = @pages.where(parent_id: nil)
50
- }
51
- end
52
-
53
44
  def create
54
45
  create! do |success, failure|
55
- success.html { redirect_to admin_pages_path }
46
+ success.html { render action: :edit }
56
47
  failure.html { render action: :new }
57
48
  end
58
49
  end
59
50
 
60
51
  def update
61
52
  update! do |success, failure|
62
- success.html { redirect_to admin_pages_path }
63
- failure.html { render action: :edit }
53
+ success.html { render action: :edit }
54
+ failure.html { render action: :edit }
64
55
  end
65
56
  end
66
57
  end
@@ -16,12 +16,16 @@ module ActiveadminSelleoCms
16
16
  end
17
17
  end
18
18
 
19
- def link_to_page(page)
19
+ def url_to_page(page)
20
20
  if page.is_link_url
21
- link_to page.title, page.link_url
21
+ page.link_url
22
22
  else
23
- link_to page.title, page_path(I18n.locale, page)
23
+ page_path(I18n.locale, page)
24
24
  end
25
25
  end
26
+
27
+ def link_to_page(page)
28
+ link_to page.title, url_to_page(page)
29
+ end
26
30
  end
27
31
  end
@@ -31,6 +31,10 @@ module ActiveadminSelleoCms
31
31
  end
32
32
  end
33
33
 
34
+ after_initialize do
35
+ self.layout = Layout.all.first if new_record? and layout.blank?
36
+ end
37
+
34
38
  def initialize_missing_sections
35
39
  section_names.each do |section_name|
36
40
  sections.build(name: section_name) unless sections.detect{|section| section.name == section_name}
@@ -5,12 +5,21 @@
5
5
  - @page.initialize_missing_sections
6
6
  - @section_forms = []
7
7
 
8
+ = form.inputs "Layout" do
9
+ = form.input :layout, collection: ActiveadminSelleoCms::Layout.all, include_blank: false, hint: "The form will reload on change"
10
+
8
11
  = form.inputs "General options" do
9
12
  = form.input :parent_id, as: :select, collection: nested_set_options(ActiveadminSelleoCms::Page, @page) {|i| "#{'-' * i.level} #{i.title}" }
10
- = form.input :layout, collection: ActiveadminSelleoCms::Layout.all, include_blank: false
11
13
  = form.input :is_published, as: :boolean, input_html: { checked: @page.published_at.present? }
12
14
  = form.input :is_link_url, as: :boolean, input_html: { checked: @page.link_url.present? }
13
- = form.input :link_url
15
+ = form.input :link_url, hint: "Enter remote URL including the http part at the beginning"
16
+
17
+ = form.semantic_fields_for :sections do |section_form|
18
+ - if @page.section_names.include? section_form.object.name
19
+ - @section_forms << section_form
20
+ = section_form.input :name, as: :hidden, label: false
21
+ - else
22
+ = ""
14
23
 
15
24
  .language-tabs
16
25
  %ul.language-selection
@@ -20,16 +29,10 @@
20
29
  - additional_locale = ActiveadminSelleoCms::Locale.find_by_code(translation.locale)
21
30
  %li= link_to additional_locale.name, "#lang-#{additional_locale.code}"
22
31
 
23
- %div{id: "lang-#{current_locale.code}"}
24
- = render partial: 'fields_current_locale', locals: { locale: current_locale, form: form }
25
-
26
32
  = form.semantic_fields_for :translations do |translated_form|
27
- - unless translated_form.object.locale == current_locale.code
28
- - additional_locale = ActiveadminSelleoCms::Locale.find_by_code(translated_form.object.locale)
29
- %div{id: "lang-#{additional_locale.code}", style: "#{'display:none;' if additional_locale.code == current_locale.code}"}
30
- = render partial: 'fields_additional_locale', locals: { locale: additional_locale, form: translated_form }
31
- - else
32
- = ""
33
+ - additional_locale = ActiveadminSelleoCms::Locale.find_by_code(translated_form.object.locale)
34
+ %div{id: "lang-#{additional_locale.code}", style: "#{'display:none;' if additional_locale.code == current_locale.code}"}
35
+ = render partial: 'translated_fields', locals: { locale: additional_locale, form: translated_form }
33
36
 
34
37
  = form.actions do
35
38
  = form.action :submit
@@ -53,13 +56,22 @@
53
56
  is_link_url();
54
57
 
55
58
  $("input[id$='_title']").blur(function(){
56
- slugId = '#' + $(this).attr('id').replace('_title', '_slug');
59
+ slugId = '#' + $(this).attr('id').replace('_title', '_slug');
57
60
  if ($(slugId).attr('value') == '') {
58
61
  $(slugId).attr('value', slug($(this).attr('value')) )
59
62
  }
63
+
64
+ browserTitleId = '#' + $(this).attr('id').replace('_title', '_browser_title');
65
+ if ($(browserTitleId).attr('value') == '') {
66
+ $(browserTitleId).attr('value', $(this).attr('value') )
67
+ }
60
68
  });
61
69
 
62
70
  $('input#page_is_link_url').change(function(){
63
71
  is_link_url();
64
72
  });
73
+
74
+ $('select#page_layout').change(function(){
75
+ $(this).closest('form').submit();
76
+ });
65
77
  });
@@ -11,7 +11,7 @@
11
11
  - @section_forms.each do |section_form|
12
12
  = section_form.semantic_fields_for :translations do |section_form_translated|
13
13
  - if section_form_translated.object.locale.to_sym == locale.code
14
- = section_form_translated.input :body, as: :ckeditor, label: "#{section_form.object.name.titleize} part", input_html: { toolbar: "Full" }
14
+ = section_form_translated.input :body, as: :ckeditor, label: "#{section_form.object.name.titleize} part", input_html: { toolbar: "Easy" }
15
15
  = section_form_translated.input :locale, :as => :hidden, :label => false
16
16
  - else
17
17
  = ""
@@ -1,8 +1,8 @@
1
1
  require "i18n/backend/fallbacks"
2
2
  I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
3
3
 
4
- if ActiveRecord::Base.connection.table_exists? 'translations'
5
- require 'i18n/backend/active_record'
6
- I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Fallbacks)
7
- I18n.backend = I18n::Backend::Chain.new(I18n::Backend::ActiveRecord.new, I18n.backend)
8
- end
4
+ #if ActiveRecord::Base.connection.table_exists? 'translations'
5
+ # require 'i18n/backend/active_record'
6
+ # I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Fallbacks)
7
+ # I18n.backend = I18n::Backend::Chain.new(I18n::Backend::ActiveRecord.new, I18n.backend)
8
+ #end
@@ -1,3 +1,3 @@
1
1
  module ActiveadminSelleoCms
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-selleo-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -218,9 +218,8 @@ files:
218
218
  - app/admin/activeadmin_selleo_cms/locale.rb
219
219
  - app/admin/activeadmin_selleo_cms/page.rb
220
220
  - app/views/layouts/activeadmin_selleo_cms/application.html.erb
221
- - app/views/admin/pages/_fields_additional_locale.html.haml
222
221
  - app/views/admin/pages/_form.html.haml
223
- - app/views/admin/pages/_fields_current_locale.html.haml
222
+ - app/views/admin/pages/_translated_fields.html.haml
224
223
  - app/views/admin/pages/_js.html.haml
225
224
  - app/views/admin/translations/update.js.haml
226
225
  - app/views/activeadmin_selleo_cms/pages/show.html.haml
@@ -1,14 +0,0 @@
1
- = form.inputs "#{locale.name} translation" do
2
- %ol
3
- = form.input :title
4
- = form.input :slug
5
- = form.input :browser_title
6
- = form.input :meta_keywords
7
- = form.input :meta_description, input_html: { rows: 3 }
8
- = form.semantic_fields_for :sections do |section_form|
9
- - if @page.section_names.include? section_form.object.name
10
- - @section_forms << section_form
11
- = section_form.input :name, as: :hidden, label: false
12
- = section_form.input :body, as: :ckeditor, label: "#{section_form.object.name.titleize} part", input_html: { toolbar: "Easy" }
13
- - else
14
- = ""