constructor-pages 0.9.1 → 1.0.0beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/constructor_pages/fields_controller.rb +11 -8
  3. data/app/controllers/constructor_pages/pages_controller.rb +9 -4
  4. data/app/controllers/constructor_pages/templates_controller.rb +9 -5
  5. data/app/helpers/constructor_pages/for_select.rb +13 -0
  6. data/app/helpers/constructor_pages/pages_helper.rb +1 -1
  7. data/app/helpers/constructor_pages/templates_helper.rb +1 -1
  8. data/app/models/constructor_pages/page.rb +1 -0
  9. data/app/models/constructor_pages/template.rb +1 -0
  10. data/app/models/constructor_pages/types/image_type.rb +1 -0
  11. data/app/views/constructor_pages/fields/_field.html.slim +6 -11
  12. data/app/views/constructor_pages/fields/_form.html.slim +16 -20
  13. data/app/views/constructor_pages/fields/edit.html.slim +2 -3
  14. data/app/views/constructor_pages/fields/new.html.slim +2 -3
  15. data/app/views/constructor_pages/fields/types/_float.html.slim +1 -1
  16. data/app/views/constructor_pages/fields/types/_image.html.slim +1 -2
  17. data/app/views/constructor_pages/fields/types/_integer.html.slim +1 -1
  18. data/app/views/constructor_pages/pages/_field.html.slim +3 -4
  19. data/app/views/constructor_pages/pages/_form.html.slim +79 -96
  20. data/app/views/constructor_pages/pages/edit.html.slim +3 -4
  21. data/app/views/constructor_pages/pages/index.html.slim +5 -28
  22. data/app/views/constructor_pages/pages/new.html.slim +2 -3
  23. data/app/views/constructor_pages/templates/_form.html.slim +22 -29
  24. data/app/views/constructor_pages/templates/edit.html.slim +2 -3
  25. data/app/views/constructor_pages/templates/index.html.slim +5 -26
  26. data/app/views/constructor_pages/templates/new.html.slim +2 -3
  27. data/app/views/pages/expand_node.slim +8 -0
  28. data/app/views/templates/expand_node.slim +8 -0
  29. data/config/locales/en.yml +1 -3
  30. data/config/locales/fr.yml +1 -3
  31. data/config/locales/ru.yml +1 -2
  32. data/config/routes.rb +16 -7
  33. data/spec/features/constructor_pages/fields_spec.rb +0 -6
  34. data/spec/features/constructor_pages/pages_spec.rb +1 -96
  35. data/spec/features/constructor_pages/templates_spec.rb +1 -63
  36. metadata +9 -8
  37. data/app/controllers/constructor_pages/application_controller.rb +0 -20
  38. data/app/helpers/constructor_pages/treeview_helper.rb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e755c7454fde82d556e68e6749f7b00f1978329c
4
- data.tar.gz: 08e089d2046af17158a9d625e021d6201bc37f6b
3
+ metadata.gz: 076592077cf4756361ca5c20ab57059950ffc7f5
4
+ data.tar.gz: b6fdd943392882e13f845a80b61a02696a449230
5
5
  SHA512:
6
- metadata.gz: 8688f88106b25e39fd86809883682dbebd091b208513e7141979983541606ba9c304ec22e67231f88d2e4dbd655a4e9901b69bc3760cc4783eef3a9f60cbf3ba
7
- data.tar.gz: b352ae490e4241bae3ea985ca6c6daf4bd54e7d0f2b02ae6c5fbf7845d14339896b69680debd5fe190702d295d359a2a144f6579b39e0ac763406cc9c6af3fd8
6
+ metadata.gz: ad18e8a26816becc289dd612ddd8270cdc3babacb8deb4b792f0e108e557fcec13138135b49fc1ab2cf4c430f3f97e17c0c8ef3ef36d579a36594cbb487577d3
7
+ data.tar.gz: 72d2db5db1bd322ec155f42e77284b1e952f002692f485f848a5b1ef34afa42d62c442abddc5cb342fce915ab9a1fb81776fe812ec0e4b36c710fe8f9ff9a0d8
@@ -1,7 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module ConstructorPages
4
- class FieldsController < ApplicationController
4
+ class FieldsController < ConstructorCore::ApplicationController
5
+ include TheSortableTreeController::Rebuild
6
+ include TheSortableTreeController::ExpandNode
7
+
5
8
  def new
6
9
  @field = Field.new.tap {|f| @template = f.template = Template.find(params[:template_id])}
7
10
  end
@@ -50,7 +53,13 @@ module ConstructorPages
50
53
  redirect_to edit_template_url(template), notice: t(:field_success_removed, name: name)
51
54
  end
52
55
 
53
- %w{up down}.each {|m| define_method "move_#{m}" do move_to m.to_sym end}
56
+ def sortable_model
57
+ Field
58
+ end
59
+
60
+ def sortable_collection
61
+ ConstructorPages::Field
62
+ end
54
63
 
55
64
  private
56
65
 
@@ -62,11 +71,5 @@ module ConstructorPages
62
71
  :type_value
63
72
  )
64
73
  end
65
-
66
- def move_to(to)
67
- @field = Field.find(params[:id])
68
- to == :up ? @field.move_higher : @field.move_lower
69
- redirect_to :back, notice: t(:field_success_moved, name: @field.name)
70
- end
71
74
  end
72
75
  end
@@ -1,15 +1,16 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module ConstructorPages
4
- class PagesController < ApplicationController
5
- layout 'constructor_core/application_core', except: [:show]
4
+ class PagesController < ConstructorCore::ApplicationController
5
+ include TheSortableTreeController::Rebuild
6
+ include TheSortableTreeController::ExpandNode
6
7
 
7
- movable :page
8
+ layout 'constructor_core/application_core', except: [:show]
8
9
 
9
10
  before_filter -> {@pages = Page.all}, only: [:new, :edit]
10
11
 
11
12
  def index
12
- @pages = Page.includes(:template).load
13
+ @pages = Page.nested_set.roots.includes(:template)
13
14
  @pages_cache = Digest::MD5.hexdigest(@pages.map{|p| [p.id, p.name, p.full_url, p.in_url, p.template.lft, p.lft, p.template_id]}.join)
14
15
  @template_exists = Template.count != 0
15
16
  flash[:notice] = 'Create at least one template' unless @template_exists
@@ -83,6 +84,10 @@ module ConstructorPages
83
84
  redirect_to pages_path, notice: t(:page_success_removed, name: @page.name)
84
85
  end
85
86
 
87
+ def sortable_model
88
+ Page
89
+ end
90
+
86
91
  private
87
92
 
88
93
  def page_params
@@ -1,14 +1,14 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module ConstructorPages
4
- class TemplatesController < ApplicationController
5
- include TreeviewHelper
4
+ class TemplatesController < ConstructorCore::ApplicationController
5
+ include TheSortableTreeController::Rebuild
6
+ include TheSortableTreeController::ExpandNode
6
7
 
7
- movable :template
8
-
9
- before_filter -> {@templates = Template.all}, only: [:index, :new, :edit, :update, :create]
8
+ before_filter -> {@templates = Template.all}, only: [:new, :edit, :update, :create]
10
9
 
11
10
  def index
11
+ @templates = Template.roots
12
12
  @templates_cache = Digest::MD5.hexdigest(@templates.map{|t| [t.id, t.name, t.lft]}.join)
13
13
  end
14
14
 
@@ -52,6 +52,10 @@ module ConstructorPages
52
52
  end
53
53
  end
54
54
 
55
+ def sortable_model
56
+ Template
57
+ end
58
+
55
59
  private
56
60
 
57
61
  def template_params
@@ -0,0 +1,13 @@
1
+ module ConstructorPages
2
+ module ForSelect
3
+ def for_select(items, full_url = false)
4
+ result = []
5
+ items && items.each do |i|
6
+ arr = ["#{'--'*i.level} #{i.name}", i.id]
7
+ arr << {'data-full_url' => i.full_url} if full_url
8
+ result.push(arr)
9
+ end
10
+ result
11
+ end
12
+ end
13
+ end
@@ -1,6 +1,6 @@
1
1
  module ConstructorPages
2
2
  module PagesHelper
3
- include TreeviewHelper
3
+ include ForSelect
4
4
 
5
5
  def templates
6
6
  Template.all.map{|t| ["#{'--'*t.level} #{t.name}", t.id]}
@@ -1,5 +1,5 @@
1
1
  module ConstructorPages
2
2
  module TemplatesHelper
3
- include TreeviewHelper
3
+ include ForSelect
4
4
  end
5
5
  end
@@ -4,6 +4,7 @@ module ConstructorPages
4
4
  # Page model. Pages are core for company websites, blogs etc.
5
5
  class Page < ActiveRecord::Base
6
6
  include ActiveSupport::Inflector
7
+ include TheSortableTree::Scopes
7
8
 
8
9
  # Adding has_many for all field types
9
10
  Field::TYPES.each do |t|
@@ -9,6 +9,7 @@ module ConstructorPages
9
9
  class Template < ActiveRecord::Base
10
10
  # Adding code_name_uniqueness method
11
11
  include CodeNameUniq
12
+ include TheSortableTree::Scopes
12
13
 
13
14
  validates_presence_of :name, :code_name
14
15
  validates_uniqueness_of :code_name
@@ -5,6 +5,7 @@ module ConstructorPages
5
5
  # Image type. Render select file field.
6
6
  class ImageType < ActiveRecord::Base
7
7
  extend Dragonfly::Model
8
+
8
9
  belongs_to :field
9
10
  belongs_to :page, touch: true
10
11
 
@@ -1,11 +1,6 @@
1
- .control-group
2
- = label_tag '', field.name, class: 'control-label'
3
- .controls
4
- = link_to field_move_down_path(field), class: "btn btn-mini #{'disabled' if field.last?}" do
5
- i.icon-arrow-down
6
- = link_to field_move_up_path(field), class: "btn btn-mini #{'disabled' if field.first?}" do
7
- i.icon-arrow-up
8
- = link_to edit_template_field_path(field.template, field), class: 'btn btn-mini btn-primary' do
9
- i.icon-pencil
10
- = link_to [field.template, field], method: :delete, data: {confirm: t(:are_you_sure?)}, class: 'btn btn-mini btn-danger' do
11
- i.icon-remove
1
+ .b-form__row
2
+ = label_tag '', field.name, class: 'b-form__label'
3
+ = link_to edit_template_field_path(field.template, field), class: 'b-button b-button_size_small b-button_color_light' do
4
+ i.fa.fa-pencil
5
+ = link_to [field.template, field], method: :delete, data: {confirm: t(:are_you_sure?)}, class: 'b-button b-button_size_small b-button_color_light' do
6
+ i.fa.fa-times
@@ -1,29 +1,25 @@
1
1
  = form_for [@template, @field] do |f|
2
2
  - if @field.errors.any?
3
- .alert.alert-error.fade.in.span12
3
+ .b-error
4
4
  = link_to '×', '#', class: 'close', 'data-dismiss' => 'alert'
5
5
  - @field.errors.full_messages.each do |m|
6
6
  = m
7
7
 
8
- .form-horizontal
9
- .control-group
10
- = f.label :name, class: 'control-label'
11
- .controls= f.text_field :name, class: 'span4'
8
+ .b-form__row
9
+ = f.label :name, class: 'b-form__label'
10
+ = f.text_field :name, class: 'b-form__field'
12
11
 
13
- .control-group
14
- = f.label :code_name, class: 'control-label'
15
- .controls= f.text_field :code_name, class: 'span4'
16
- = f.hidden_field :template_id, value: @template.id, class: 'span4'
12
+ .b-form__row
13
+ = f.label :code_name, class: 'b-form__label'
14
+ = f.text_field :code_name, class: 'b-form__field'
15
+ = f.hidden_field :template_id, value: @template.id
17
16
 
18
- - unless @field.type_value == 'image'
19
- .control-group
20
- = f.label :type_value, class: 'control-label'
21
- .controls
22
- = f.select :type_value, options_for_select(types_value, selected: @field.type_value), class: 'span4'
17
+ - unless @field.type_value == 'image'
18
+ .b-form__row
19
+ = f.label :type_value, class: 'b-form__label'
20
+ = f.select :type_value, options_for_select(types_value, selected: @field.type_value), class: 'b-form__field'
23
21
 
24
- .row-fluid
25
- .span12
26
- .form-actions
27
- = f.submit class: 'btn btn-primary'
28
- = link_to t(:cancel), edit_template_path(@template), class: 'btn'
29
- = link_to t(:delete_field), [@template, @field], method: :delete, data: {confirm: t(:are_you_sure?)}, class: 'btn btn-danger pull-right' unless @field.new_record?
22
+ .b-form__actions
23
+ = f.submit class: 'b-button'
24
+ = link_to t(:cancel), edit_template_path(@template), class: 'b-button b-button_color_light'
25
+ = link_to t(:delete_field), [@template, @field], method: :delete, data: {confirm: t(:are_you_sure?)}, class: 'btn btn-danger pull-right' unless @field.new_record?
@@ -1,6 +1,5 @@
1
- - content_for :page_title do
1
+ .b-header
2
2
  =t :edit_field
3
3
 
4
- section.span12
5
- = render 'form'
4
+ = render 'form'
6
5
 
@@ -1,6 +1,5 @@
1
- - content_for :page_title do
1
+ .b-header
2
2
  =t :new_field
3
3
 
4
- section.span12
5
- = render 'form'
4
+ = render 'form'
6
5
 
@@ -1 +1 @@
1
- = number_field_tag "fields[#{field.code_name}]", page.get_field_value(field.code_name), class: 'span2', step: 'any'
1
+ = number_field_tag "fields[#{field.code_name}]", page.get_field_value(field.code_name), class: 'b-form__field', step: 'any'
@@ -2,6 +2,5 @@
2
2
 
3
3
  - if image
4
4
  = image_tag image.thumb('200x200').url
5
- br
6
5
 
7
- = file_field_tag "fields[#{field.code_name}]", class: 'span6'
6
+ = file_field_tag "fields[#{field.code_name}]", class: 'b-form__file'
@@ -1 +1 @@
1
- = number_field_tag "fields[#{field.code_name}]", page.get_field_value(field.code_name), class: 'span2'
1
+ = number_field_tag "fields[#{field.code_name}]", page.get_field_value(field.code_name), class: 'b-form__field'
@@ -1,4 +1,3 @@
1
- .control-group
2
- = label_tag "fields[#{field.code_name}]", field.name, class: 'control-label'
3
- .controls
4
- = render "constructor_pages/fields/types/#{field.type_value}", field: field, page: @page
1
+ .b-form__row
2
+ = label_tag "fields[#{field.code_name}]", field.name, class: 'b-form__label'
3
+ = render "constructor_pages/fields/types/#{field.type_value}", field: field, page: @page
@@ -1,97 +1,80 @@
1
- = form_for @page, html: {multipart: @page.multipart?} do |f|
1
+ = form_for @page, html: {multipart: @page.multipart?, class: 'b-form'} do |f|
2
2
  - if @page.errors.any?
3
- .row-fluid
4
- .alert.alert-error.fade.in.span12
5
- = link_to '×', '#', class: 'close', 'data-dismiss' => 'alert'
6
- - @page.errors.full_messages.each do |m|
7
- = m
8
-
9
- .form-horizontal
10
- .control-group
11
- = f.label :active, class: 'control-label'
12
- .controls= f.check_box :active, class: 'span6'
13
-
14
- .control-group
15
- = f.label :name, class: 'control-label'
16
- .controls= f.text_field :name, class: 'span4'
17
-
18
- .control-group.auto_url
19
- = f.label :auto_url, class: 'control-label'
20
- .controls
21
- = f.check_box :auto_url, class: 'span9'
22
-
23
- .control-group.url
24
- = f.label :url, class: 'control-label'
25
- .controls
26
- .full_url
27
- span.path= @page.parent.full_url if @page.parent
28
- | /
29
- span.address= @page.url
30
- = f.text_field :url, class: 'span3'
31
- i.address_icon.icon-pencil<
32
-
33
- = render partial: 'field', collection: @page.fields
34
-
35
- .accordion
36
- .accordion-group
37
- .accordion-heading.text-center
38
- = link_to t(:settings), '#collapse', class: 'accordion-toggle', 'data-toggle' => 'collapse'
39
- .accordion-body.in.collapse#collapse
40
- .accordion-inner
41
- .control-group
42
- = f.label :parent_id, class: 'control-label'
43
- .controls
44
- = f.select :parent_id, options_for_select(for_select(@pages, true), selected: @parent_id), disabled: @page.self_and_descendants.map(&:id), include_blank: '--'
45
-
46
- .control-group
47
- = f.label :template_id, :class => 'control-label'
48
- .controls
49
- = f.select :template_id, options_for_select(templates, selected: @template_id)
50
- .control-group
51
- = f.label :redirect, class: 'control-label'
52
- .controls
53
- = f.text_field :redirect, class: 'span9'
54
- .control-group
55
- label.control-label=t :display_in
56
- .controls
57
- label.checkbox.inline.span2 for='in_menu'
58
- = f.check_box :in_menu
59
- =t :menu
60
-
61
- label.checkbox.inline.span2 for='in_map'
62
- = f.check_box :in_map
63
- =t :sitemap
64
-
65
- label.checkbox.inline.span2 for='in_nav'
66
- = f.check_box :in_nav
67
- =t :breadcrumbs
68
-
69
- label.checkbox.inline.span2 for='in_url'
70
- = f.check_box :in_url
71
- =t :url
72
-
73
- .accordion
74
- .accordion-group
75
- .accordion-heading.text-center
76
- = link_to t(:seo), '#collapse-three', class: 'accordion-toggle', 'data-toggle' => 'collapse'
77
- .accordion-body.in.collapse#collapse-three
78
- .accordion-inner
79
- .control-group
80
- = f.label :title, class: 'control-label'
81
- .controls
82
- = f.text_field :title, class: 'span9'
83
- .control-group
84
- = f.label :keywords, class: 'control-label'
85
- .controls
86
- = f.text_field :keywords, class: 'span9'
87
- .control-group
88
- = f.label :description, class: 'control-label'
89
- .controls
90
- = f.text_area :description, class: 'span9', rows: 8
91
-
92
- .row-fluid
93
- .span12
94
- .form-actions
95
- = f.submit class: 'btn btn-primary'
96
- = link_to t(:cancel), pages_url, class: 'btn'
97
- = link_to t(:delete_page), @page, method: :delete, data: {confirm: t(:are_you_sure?)}, class: 'btn btn-danger pull-right' unless @page.new_record?
3
+ .b-error
4
+ = link_to '×', '#', class: 'close', 'data-dismiss' => 'alert'
5
+ - @page.errors.full_messages.each do |m|
6
+ = m
7
+
8
+ .b-form__row
9
+ = f.label :active, class: 'b-form__label'
10
+ = f.check_box :active
11
+
12
+ .b-form__row
13
+ = f.label :name, class: 'b-form__label'
14
+ = f.text_field :name, class: 'b-form__field'
15
+
16
+ .b-form__row.auto_url
17
+ = f.label :auto_url, class: 'b-form__label'
18
+ = f.check_box :auto_url
19
+
20
+ .b-form__row.url
21
+ = f.label :url, class: 'b-form__label'
22
+ .b-inline.b-full-url
23
+ span.b-full-url__path
24
+ = @page.parent.full_url if @page.parent
25
+ | /
26
+ span.b-full-url__url= @page.url
27
+ = f.text_field :url, class: 'b-form__field'
28
+ i.fa.fa-pencil.b-full-url__icon
29
+
30
+ = render partial: 'field', collection: @page.fields
31
+
32
+ .b-form__row
33
+ = f.label :parent_id, class: 'b-form__label'
34
+ = f.select :parent_id, options_for_select(for_select(@pages, true), selected: @parent_id), disabled: @page.self_and_descendants.map(&:id), include_blank: '--'
35
+
36
+ .b-form__row
37
+ = f.label :template_id, class: 'b-form__label'
38
+ = f.select :template_id, options_for_select(templates, selected: @template_id)
39
+
40
+ .b-form__row
41
+ = f.label :redirect, class: 'b-form__label'
42
+ = f.text_field :redirect, class: 'b-form__field'
43
+
44
+ .b-form__row
45
+ label.b-form__label
46
+ =t :display_in
47
+
48
+ label for='in_menu'
49
+ = f.check_box :in_menu
50
+ =t :menu
51
+
52
+ label for='in_map'
53
+ = f.check_box :in_map
54
+ =t :sitemap
55
+
56
+ label for='in_nav'
57
+ = f.check_box :in_nav
58
+ =t :breadcrumbs
59
+
60
+ label for='in_url'
61
+ = f.check_box :in_url
62
+ =t :url
63
+
64
+ .b-form__row
65
+ = f.label :title, class: 'b-form__label'
66
+ = f.text_field :title, class: 'b-form__field'
67
+
68
+
69
+ .b-form__row
70
+ = f.label :keywords, class: 'b-form__label'
71
+ = f.text_field :keywords, class: 'b-form__field'
72
+
73
+ .b-form__row
74
+ = f.label :description, class: 'b-form__label'
75
+ = f.text_area :description, class: 'b-form__field', rows: 8
76
+
77
+ .b-form__actions
78
+ = f.submit class: 'b-button'
79
+ = link_to t(:cancel), pages_url, class: 'b-button b-button_color_light'
80
+ = link_to t(:delete_page), @page, method: :delete, data: {confirm: t(:are_you_sure?)}, class: 'b-button b-button_color_light g-float_right' unless @page.new_record?
@@ -1,6 +1,5 @@
1
- - content_for :page_title do
1
+ .b-header
2
2
  =t :edit_page
3
-
4
- section.span12
5
- = render 'form'
3
+
4
+ = render 'form'
6
5
 
@@ -1,31 +1,8 @@
1
- - content_for :page_title do
2
- =t :structure
3
-
4
- - content_for :actions do
1
+ .l-pages
5
2
  - if @template_exists
6
- .span4.clearfix.text-right
7
- = link_to pages.new_page_path, class: 'btn btn-large btn-link' do
8
- i.icon-plus>
9
- =t :new_page
10
-
11
- section.b-tree.span12
12
- ul
13
- - cache @pages_cache do
14
- - @pages.each do |page|
15
- li class="level#{page.level}"
16
- - if page.published?
17
- = link_to page.name, page.full_url, class: 'btn btn-link'
18
- - else
19
- button.btn.disabled= page.name
20
-
21
- .b-tree__buttons
22
- = arrow_buttons_for(page)
3
+ = link_to new_page_path, class: 'b-button' do
4
+ =t :new_page
23
5
 
24
- = link_to edit_page_path(page), class: 'btn btn-primary btn-mini' do
25
- i.icon-pencil>
26
- =>t :edit
27
- = page.template.to_accusative
28
6
 
29
- = link_to page, method: :delete, class: 'btn btn-danger btn-mini pull-right', data: {confirm: t(:are_you_sure?)} do
30
- i.icon-remove>
31
- =t :delete
7
+ ol.b-block.b-tree.g-out data-rebuild_url="#{rebuild_pages_path}" data-expand-node-url="#{expand_node_pages_path}" data-cookie-store='true'
8
+ = expandable_tree(@pages, title: :name)
@@ -1,6 +1,5 @@
1
- - content_for :page_title do
1
+ .b-header
2
2
  =t :new_page
3
3
 
4
- section.span12
5
- = render 'form'
4
+ = render 'form'
6
5
 
@@ -1,37 +1,30 @@
1
- = form_for @template do |f|
1
+ = form_for @template, html: {class: 'b-form'} do |f|
2
2
  - if @template.errors.any?
3
- .row-fluid
4
- .alert.alert-error.fade.in.span12
5
- = link_to '×', '#', class: 'close', 'data-dismiss' => 'alert'
6
- - @template.errors.full_messages.each do |m|
7
- = m
3
+ = link_to '×', '#', class: 'close', 'data-dismiss' => 'alert'
4
+ - @template.errors.full_messages.each do |m|
5
+ = m
8
6
 
9
- .form-horizontal
10
- .control-group
11
- = f.label :name, class: 'control-label'
12
- .controls= f.text_field :name, class: 'span4'
7
+ .b-form__row
8
+ = f.label :name, class: 'b-form__label'
9
+ = f.text_field :name, class: 'b-form__field'
13
10
 
14
- .control-group
15
- = f.label :code_name, class: 'control-label'
16
- .controls= f.text_field :code_name, class: 'span4'
11
+ .b-form__row
12
+ = f.label :code_name, class: 'b-form__label'
13
+ = f.text_field :code_name, class: 'b-form__field'
17
14
 
18
- .control-group
19
- = f.label :parent_id, class: 'control-label'
20
- .controls
21
- = f.select :parent_id, options_for_select(for_select(@templates), selected: @template.parent_id), disabled: @template.self_and_descendants.map(&:id), include_blank: '--'
15
+ .b-form__row
16
+ = f.label :parent_id, class: 'b-form__label'
17
+ = f.select :parent_id, options_for_select(for_select(@templates), selected: @template.parent_id), disabled: @template.self_and_descendants.map(&:id), include_blank: '--'
22
18
 
23
- - unless @template.new_record?
24
- .control-group
25
- .controls
26
- = link_to new_template_field_path(@template), class: 'btn btn-mini btn-link' do
27
- i.icon-plus
28
- =t :new_field
19
+ - unless @template.new_record?
20
+ .b-form__row
21
+ .b-form__label
22
+ = link_to new_template_field_path(@template), class: 'b-button b-button_color_light b-button_size_small' do
23
+ =t :new_field
29
24
 
30
25
  = render @template.fields
31
26
 
32
- .row-fluid
33
- .span12
34
- .form-actions
35
- = f.submit class: 'btn btn-primary'
36
- = link_to t(:cancel), templates_url, class: 'btn'
37
- = link_to t(:delete_template), @template, method: :delete, data: {confirm: t(:are_you_sure?)}, class: 'btn btn-danger pull-right' unless @template.new_record?
27
+ .b-form__actions
28
+ = f.submit class: 'b-button'
29
+ = link_to t(:cancel), templates_url, class: 'b-button b-button_color_light'
30
+ = link_to t(:delete_template), @template, method: :delete, data: {confirm: t(:are_you_sure?)}, class: 'b-button b-button_color_light g-float_right' unless @template.new_record?
@@ -1,6 +1,5 @@
1
- - content_for :page_title do
1
+ .b-header
2
2
  =t :edit_template
3
3
 
4
- section.span12
5
- = render 'form'
4
+ = render 'form'
6
5
 
@@ -1,27 +1,6 @@
1
- - content_for :page_title do
2
- =t :templates
1
+ .l-pages
2
+ = link_to new_template_path, class: 'b-button' do
3
+ =t :new_template
3
4
 
4
- - content_for :actions do
5
- .span4.clearfix.text-right
6
- = link_to new_template_path, class: 'btn btn-link btn-large' do
7
- i.icon-plus>
8
- =t :new_template
9
-
10
- section.b-tree.span12
11
- ul
12
- - cache @templates_cache do
13
- - @templates.each do |template|
14
- li class="level#{template.level}"
15
- button.btn.btn-link.disabled= template.name
16
-
17
- .b-tree__buttons
18
- = arrow_buttons_for(template)
19
-
20
- = link_to edit_template_path(template), class: 'btn btn-primary btn-mini' do
21
- i.icon-pencil>
22
- =>t :edit
23
- = t(:template).mb_chars.downcase
24
-
25
- = link_to template, method: :delete, class: 'btn btn-danger btn-mini pull-right', data: {confirm: t(:are_you_sure?)} do
26
- i.icon-remove>
27
- =t :delete
5
+ ol.b-block.b-tree.g-out data-rebuild_url="#{rebuild_templates_path}" data-expand-node-url="#{expand_node_templates_path}" data-cookie-store='true'
6
+ = expandable_tree(@templates, title: :name)
@@ -1,6 +1,5 @@
1
- - content_for :page_title do
1
+ .b-header
2
2
  =t :new_template
3
3
 
4
- section.span12
5
- = render 'form'
4
+ = render 'form'
6
5
 
@@ -0,0 +1,8 @@
1
+ ol.b-tree__nested-set
2
+ - @children.each do |child|
3
+ li.b-tree__li data-node-id="#{ child.id }"
4
+ .b-tree__item
5
+ i.fa.fa-bars.b-tree__handle
6
+ - unless child.leaf?
7
+ i.fa.fa-plus-square-o.b-tree__expand.b-tree__plus
8
+ = link_to child.name, edit_page_path(child), class: 'b-tree__link'
@@ -0,0 +1,8 @@
1
+ ol.b-tree__nested-set
2
+ - @children.each do |child|
3
+ li.b-tree__li data-node-id="#{ child.id }"
4
+ .b-tree__item
5
+ i.fa.fa-bars.b-tree__handle
6
+ - unless child.leaf?
7
+ i.fa.fa-plus-square-o.b-tree__expand.b-tree__plus
8
+ = link_to child.name, edit_template_path(child), class: 'b-tree__link'
@@ -1,5 +1,5 @@
1
1
  en:
2
- structure: Structure
2
+ pages: Pages
3
3
  templates: Templates
4
4
  settings: Settings
5
5
  new_field: New field
@@ -30,8 +30,6 @@ en:
30
30
  menu: Menu
31
31
  breadcrumbs: Breadcrumbs
32
32
 
33
- are_you_sure?: Are you sure?
34
-
35
33
  page_not_found: Page not found
36
34
 
37
35
  new_page: New page
@@ -1,5 +1,5 @@
1
1
  fr:
2
- structure: Structure
2
+ pages: Pages
3
3
  templates: Modèles
4
4
  settings: Réglages
5
5
  new_field: Nouveau champ
@@ -29,8 +29,6 @@ fr:
29
29
  menu: Menu
30
30
  breadcrumbs: Chapelure
31
31
 
32
- are_you_sure?: Etes-vous sûr?
33
-
34
32
  page_not_found: Page introuvable
35
33
 
36
34
  new_page: Nouvelle page
@@ -1,11 +1,10 @@
1
1
  ru:
2
- structure: Структура
2
+ pages: Страницы
3
3
  templates: Шаблоны
4
4
  settings: Настройки
5
5
  new_field: Новое поле
6
6
  edit_field: Редактирование поля
7
7
  seo: Поисковая оптимизация
8
- are_you_sure?: Вы уверены?
9
8
  display_in: Отображать в
10
9
  delete: Удалить
11
10
  url: "Адрес"
@@ -1,18 +1,27 @@
1
1
  ConstructorPages::Engine.routes.draw do
2
2
  scope '/admin' do
3
- resources :pages, except: [:show]
3
+ resources :pages, except: [:show] do
4
+ collection do
5
+ post :rebuild
6
+ post :expand_node
7
+ end
8
+ end
9
+
4
10
  resources :templates, except: [:show] do
5
- resources :fields, except: [:show, :index]
6
- end
11
+ collection do
12
+ post :rebuild
13
+ post :expand_node
14
+ end
7
15
 
8
- %w{page template field}.each do |c|
9
- %w{up down}.each do |d|
10
- get "#{c.pluralize}/move/#{d}/:id" => "#{c.pluralize}#move_#{d}", as: "#{c}_move_#{d}"
16
+ resources :fields, except: [:show, :index] do
17
+ collection do
18
+ post :rebuild
19
+ end
11
20
  end
12
21
  end
13
22
  end
14
23
 
15
- root :to => 'pages#show'
24
+ root to: 'pages#show'
16
25
 
17
26
  get '*all(.:format)' => 'pages#show', format: /(html|json|xml)/
18
27
  end
@@ -47,12 +47,6 @@ module ConstructorPages
47
47
  find("a[href='#{pages.template_field_path(@template, @content_field)}']").should be_true
48
48
  find("a[href='#{pages.template_field_path(@template, @price_field)}']").should be_true
49
49
  end
50
-
51
- it 'should has move field link' do
52
- visit pages.edit_template_path(@template)
53
- find("a[href='#{pages.field_move_down_path(@content_field)}']").should be_true
54
- find("a[href='#{pages.field_move_up_path(@price_field)}']").should be_true
55
- end
56
50
  end
57
51
 
58
52
  describe 'New field' do
@@ -66,13 +66,7 @@ module ConstructorPages
66
66
  it 'should has edit_page link' do
67
67
  _page = Page.create name: 'Zanussi'
68
68
  visit pages.pages_path
69
- page.should have_link 'Edit page', pages.edit_page_path(_page)
70
- end
71
-
72
- it 'should has delete_page link' do
73
- _page = Page.create name: 'Zanussi'
74
- visit pages.pages_path
75
- page.should have_link 'Delete', pages.page_path(_page)
69
+ page.should have_link 'Zanussi', pages.edit_page_path(_page)
76
70
  end
77
71
  end
78
72
 
@@ -111,52 +105,6 @@ module ConstructorPages
111
105
  end
112
106
  end
113
107
 
114
- describe 'Moving' do
115
- it 'should move page' do
116
- _page_first = Page.create name: 'First'
117
- _page_second = Page.create name: 'Second'
118
- _page_third = Page.create name: 'Third'
119
-
120
- _page_first.left_sibling.should be_nil
121
- _page_first.right_sibling.should == _page_second
122
-
123
- _page_second.left_sibling.should == _page_first
124
- _page_second.right_sibling.should == _page_third
125
-
126
- _page_third.left_sibling.should == _page_second
127
- _page_third.right_sibling.should be_nil
128
-
129
- visit pages.pages_path
130
- find("a[href='#{pages.page_move_down_path(_page_first.id)}']").click
131
-
132
- _page_first.reload
133
- _page_first.left_sibling.should == _page_second
134
- _page_first.right_sibling.should == _page_third
135
-
136
- _page_second.reload
137
- _page_second.left_sibling.should be_nil
138
- _page_second.right_sibling.should == _page_first
139
-
140
- _page_third.reload
141
- _page_third.left_sibling.should == _page_first
142
- _page_third.right_sibling.should be_nil
143
-
144
- find("a[href='#{pages.page_move_up_path(_page_third.id)}']").click
145
-
146
- _page_first.reload
147
- _page_first.left_sibling.should == _page_third
148
- _page_first.right_sibling.should be_nil
149
-
150
- _page_second.reload
151
- _page_second.left_sibling.should be_nil
152
- _page_second.right_sibling.should == _page_third
153
-
154
- _page_third.reload
155
- _page_third.left_sibling.should == _page_second
156
- _page_third.right_sibling.should == _page_first
157
- end
158
- end
159
-
160
108
  describe 'New page' do
161
109
  describe 'Access' do
162
110
  it 'should be accessed by new_page_path if logged in' do
@@ -257,52 +205,9 @@ module ConstructorPages
257
205
  @page.description.should == 'Zanussi conditioners Voronezh'
258
206
  page.should have_text 'updated successfully'
259
207
  end
260
-
261
- describe 'regenerate descendants' do
262
- before :each do
263
- _template = Template.create name: 'Another page', code_name: 'another_page'
264
- _page_first = Page.create name: 'First', template: _template
265
- _page_second = Page.create name: 'Second', parent_id: _page_first.id, template: _template
266
- _page_third = Page.create name: 'Third', parent_id: _page_second.id, template: _template
267
-
268
- visit pages.pages_path
269
- page.should have_link('First', '/first')
270
- page.should have_link('Second', '/first/second')
271
- page.should have_link('Third', '/first/second/third')
272
-
273
- visit pages.edit_page_path(_page_first)
274
- end
275
-
276
- it 'should regenerate full_url of descendants without url if full_url or in_url changed' do
277
- uncheck 'URL'
278
- click_button 'Update Page'
279
-
280
- page.should have_link('First', '/first')
281
- page.should have_link('Second', '/second')
282
- page.should have_link('Third', '/second/third')
283
- end
284
-
285
- it 'should regenerate full_url of descendants with url if full_url or in_url changed' do
286
- uncheck 'URL'
287
- click_button 'Update Page'
288
-
289
- page.should have_link('First', '/first')
290
- page.should have_link('Second', '/first/second')
291
- page.should have_link('Third', '/first/second/third')
292
- end
293
- end
294
208
  end
295
209
 
296
210
  describe 'Delete page' do
297
- it 'should delete from pages index' do
298
- Page.create name: 'Page'
299
- visit pages.pages_path
300
- Page.count.should == 1
301
- click_link 'Delete'
302
- Page.count.should == 0
303
- page.should have_text 'removed successfully'
304
- end
305
-
306
211
  it 'should delete from page' do
307
212
  _page = Page.create name: 'Page'
308
213
  visit pages.edit_page_path(_page)
@@ -51,60 +51,7 @@ module ConstructorPages
51
51
  it 'should has edit_template link' do
52
52
  _template = Template.create name: 'Page', code_name: 'page'
53
53
  visit pages.templates_path
54
- page.should have_link 'Edit template', pages.edit_template_path(_template)
55
- end
56
-
57
- it 'should has delete_page link' do
58
- _template = Template.create name: 'Page', code_name: 'page'
59
- visit pages.templates_path
60
- page.should have_link 'Delete', pages.template_path(_template)
61
- end
62
- end
63
-
64
- describe 'Moving' do
65
- it 'should move template' do
66
- _template_first = Template.create name: 'First', code_name: 'first'
67
- _template_second = Template.create name: 'Second', code_name: 'second'
68
- _template_third = Template.create name: 'Third', code_name: 'third'
69
-
70
- _template_first.left_sibling.should be_nil
71
- _template_first.right_sibling.should == _template_second
72
-
73
- _template_second.left_sibling.should == _template_first
74
- _template_second.right_sibling.should == _template_third
75
-
76
- _template_third.left_sibling.should == _template_second
77
- _template_third.right_sibling.should be_nil
78
-
79
- visit pages.templates_path
80
-
81
- find("a[href='#{pages.template_move_down_path(_template_first.id)}']").click
82
-
83
- _template_first.reload
84
- _template_first.left_sibling.should == _template_second
85
- _template_first.right_sibling.should == _template_third
86
-
87
- _template_second.reload
88
- _template_second.left_sibling.should be_nil
89
- _template_second.right_sibling.should == _template_first
90
-
91
- _template_third.reload
92
- _template_third.left_sibling.should == _template_first
93
- _template_third.right_sibling.should be_nil
94
-
95
- find("a[href='#{pages.template_move_up_path(_template_third.id)}']").click
96
-
97
- _template_first.reload
98
- _template_first.left_sibling.should == _template_third
99
- _template_first.right_sibling.should be_nil
100
-
101
- _template_second.reload
102
- _template_second.left_sibling.should be_nil
103
- _template_second.right_sibling.should == _template_third
104
-
105
- _template_third.reload
106
- _template_third.left_sibling.should == _template_second
107
- _template_third.right_sibling.should == _template_first
54
+ page.should have_link 'Page', pages.edit_template_path(_template)
108
55
  end
109
56
  end
110
57
 
@@ -234,15 +181,6 @@ module ConstructorPages
234
181
  end
235
182
 
236
183
  describe 'Delete template' do
237
- it 'should delete from templates index' do
238
- Template.create name: 'Page', code_name: 'page'
239
- visit pages.templates_path
240
- Template.count.should == 1
241
- click_link 'Delete'
242
- Template.count.should == 0
243
- page.should have_text 'removed successfully'
244
- end
245
-
246
184
  it 'should delete from template' do
247
185
  _template = Template.create name: 'Page', code_name: 'page'
248
186
  visit pages.edit_template_path(_template)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: constructor-pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 1.0.0beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Zotov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-12 00:00:00.000000000 Z
11
+ date: 2014-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: constructor-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.9.1
19
+ version: 1.0.0beta1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.9.1
26
+ version: 1.0.0beta1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: dragonfly
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -122,15 +122,14 @@ files:
122
122
  - app/assets/javascripts/constructor_pages/.keep
123
123
  - app/assets/javascripts/constructor_pages/urlify.js
124
124
  - app/assets/stylesheets/constructor_pages/.keep
125
- - app/controllers/constructor_pages/application_controller.rb
126
125
  - app/controllers/constructor_pages/fields_controller.rb
127
126
  - app/controllers/constructor_pages/pages_controller.rb
128
127
  - app/controllers/constructor_pages/templates_controller.rb
129
128
  - app/helpers/constructor_pages/code_name_uniq.rb
130
129
  - app/helpers/constructor_pages/fields_helper.rb
130
+ - app/helpers/constructor_pages/for_select.rb
131
131
  - app/helpers/constructor_pages/pages_helper.rb
132
132
  - app/helpers/constructor_pages/templates_helper.rb
133
- - app/helpers/constructor_pages/treeview_helper.rb
134
133
  - app/models/constructor_pages/field.rb
135
134
  - app/models/constructor_pages/page.rb
136
135
  - app/models/constructor_pages/template.rb
@@ -163,6 +162,8 @@ files:
163
162
  - app/views/constructor_pages/templates/edit.html.slim
164
163
  - app/views/constructor_pages/templates/index.html.slim
165
164
  - app/views/constructor_pages/templates/new.html.slim
165
+ - app/views/pages/expand_node.slim
166
+ - app/views/templates/expand_node.slim
166
167
  - config/initializers/dragonfly.rb
167
168
  - config/locales/en.yml
168
169
  - config/locales/fr.yml
@@ -217,9 +218,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
217
218
  version: '0'
218
219
  required_rubygems_version: !ruby/object:Gem::Requirement
219
220
  requirements:
220
- - - '>='
221
+ - - '>'
221
222
  - !ruby/object:Gem::Version
222
- version: '0'
223
+ version: 1.3.1
223
224
  requirements: []
224
225
  rubyforge_project:
225
226
  rubygems_version: 2.1.11
@@ -1,20 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module ConstructorPages
4
- class ApplicationController < ConstructorCore::ApplicationController
5
- def self.movable(what)
6
- %w{up down}.each {|m| define_method "move_#{m}" do move_to what, params[:id], m.to_sym end}
7
- end
8
-
9
- def move_to(what, id, to)
10
- from = ('constructor_pages/'+what.to_s).classify.constantize.find(id)
11
- to_sibling = to == :up ? from.left_sibling : from.right_sibling
12
-
13
- if not to_sibling.nil? and from.move_possible?(to_sibling)
14
- to == :up ? from.move_left : from.move_right
15
- end
16
-
17
- redirect_to :back
18
- end
19
- end
20
- end
@@ -1,27 +0,0 @@
1
- module ConstructorPages
2
- module TreeviewHelper
3
- def arrow_buttons_for(item)
4
- output = "<div class='btn-group'>"
5
-
6
- {down: :right, up: :left}.each_pair do |a, b|
7
- sibling = item.send(b.to_s+'_sibling')
8
- if sibling and item.move_possible?(sibling)
9
- output += link_to("<i class='icon-arrow-#{a}'></i>".html_safe, "/admin/#{item.class.to_s.demodulize.downcase.pluralize}/move/#{a}/#{item.id}", class: 'btn btn-mini')
10
- end
11
- end
12
-
13
- output += "</div>"
14
- output.html_safe
15
- end
16
-
17
- def for_select(items, full_url = false)
18
- result = []
19
- items && items.each do |i|
20
- arr = ["#{'--'*i.level} #{i.name}", i.id]
21
- arr << {'data-full_url' => i.full_url} if full_url
22
- result.push(arr)
23
- end
24
- result
25
- end
26
- end
27
- end