constructor-pages 0.7.10 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/constructor_pages/pages_controller.rb +3 -1
- data/app/controllers/constructor_pages/templates_controller.rb +6 -1
- data/app/helpers/constructor_pages/pages_helper.rb +0 -8
- data/app/helpers/constructor_pages/templates_helper.rb +0 -8
- data/app/helpers/constructor_pages/treeview_helper.rb +8 -30
- data/app/models/constructor_pages/page.rb +3 -1
- data/app/views/constructor_pages/pages/_form.haml +1 -1
- data/app/views/constructor_pages/pages/index.haml +21 -19
- data/app/views/constructor_pages/templates/index.haml +14 -11
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0457fa097a8f3640bda13ce1f9699d1de07fe13
|
4
|
+
data.tar.gz: 2dbd8ce3ee79fd7a4faa636823dc87ee6710b532
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41e7f40d889a96c0210994feb7362c743912c700c373e49091a7d4b7ac51bb40a2896fa2899016d30bea7659420cbf88d54399aee5346051418c2c071f087732
|
7
|
+
data.tar.gz: 1384f5b705a64fda65ae8d1ef04c62c29071d487bdd038ee9322179b2c046b5aa3f68100e51ae4b9810c9b291dd7d073ae11a7c43699078702939fc1d75aee8a
|
@@ -6,9 +6,11 @@ module ConstructorPages
|
|
6
6
|
|
7
7
|
movable :page
|
8
8
|
|
9
|
-
before_filter -> {@
|
9
|
+
before_filter -> {@pages = Page.all}, only: [:new, :edit]
|
10
10
|
|
11
11
|
def index
|
12
|
+
@pages = Page.includes(:template).load
|
13
|
+
@pages_cache = Digest::MD5.hexdigest(@pages.map{|p| [p.name, p.lft, p.template_id]}.join)
|
12
14
|
@template_exists = Template.count != 0
|
13
15
|
flash[:notice] = 'Create at least one template' unless @template_exists
|
14
16
|
end
|
@@ -6,7 +6,12 @@ module ConstructorPages
|
|
6
6
|
|
7
7
|
movable :template
|
8
8
|
|
9
|
-
before_filter {@roots = Template.roots}
|
9
|
+
before_filter -> {@roots = Template.roots}, only: [:new, :edit]
|
10
|
+
|
11
|
+
def index
|
12
|
+
@templates = Template.all
|
13
|
+
@templates_cache = Digest::MD5.hexdigest(@templates.map{|t| [t.name, t.lft]}.join)
|
14
|
+
end
|
10
15
|
|
11
16
|
def new
|
12
17
|
@template = Template.new
|
@@ -2,14 +2,6 @@ module ConstructorPages
|
|
2
2
|
module PagesHelper
|
3
3
|
include TreeviewHelper
|
4
4
|
|
5
|
-
def for_select(roots)
|
6
|
-
result = []
|
7
|
-
roots.each do |r|
|
8
|
-
r.self_and_descendants.each {|i| result.push(["#{'--'*i.level} #{i.name}", i.id, {'data-full_url' => i.full_url}])}
|
9
|
-
end
|
10
|
-
result
|
11
|
-
end
|
12
|
-
|
13
5
|
def templates
|
14
6
|
Template.all.map{|t| ["#{'--'*t.level} #{t.name}", t.id]}
|
15
7
|
end
|
@@ -1,13 +1,5 @@
|
|
1
1
|
module ConstructorPages
|
2
2
|
module TemplatesHelper
|
3
3
|
include TreeviewHelper
|
4
|
-
|
5
|
-
def for_select(roots)
|
6
|
-
result = []
|
7
|
-
roots.each do |r|
|
8
|
-
r.self_and_descendants.each {|i| result.push(["#{'--'*i.level} #{i.name}", i.id])}
|
9
|
-
end
|
10
|
-
result
|
11
|
-
end
|
12
4
|
end
|
13
5
|
end
|
@@ -1,35 +1,5 @@
|
|
1
1
|
module ConstructorPages
|
2
2
|
module TreeviewHelper
|
3
|
-
def render_tree(roots, &block)
|
4
|
-
output = '<ul>'
|
5
|
-
|
6
|
-
roots.each do |root|
|
7
|
-
level, last = root.level, nil
|
8
|
-
|
9
|
-
root.self_and_descendants.each do |item|
|
10
|
-
if item.level > level
|
11
|
-
output += '<ul>'
|
12
|
-
elsif item.level < level
|
13
|
-
output += '</li>'
|
14
|
-
output += '</ul></li>' * (level-item.level)
|
15
|
-
elsif !item.root?
|
16
|
-
output += '</li>'
|
17
|
-
end
|
18
|
-
|
19
|
-
output += '<li>'
|
20
|
-
|
21
|
-
output += capture(item, &block)
|
22
|
-
|
23
|
-
level, last = item.level, item
|
24
|
-
end
|
25
|
-
|
26
|
-
output += '</li>'
|
27
|
-
output += '</ul></li>' * last.level
|
28
|
-
end
|
29
|
-
|
30
|
-
output.html_safe
|
31
|
-
end
|
32
|
-
|
33
3
|
def arrow_buttons_for(item)
|
34
4
|
output = "<div class='btn-group'>"
|
35
5
|
|
@@ -43,5 +13,13 @@ module ConstructorPages
|
|
43
13
|
output += "</div>"
|
44
14
|
output.html_safe
|
45
15
|
end
|
16
|
+
|
17
|
+
def for_select(items, full_url = false)
|
18
|
+
result = []
|
19
|
+
items && items.each do |i|
|
20
|
+
result.push(["#{'--'*i.level} #{i.name}", i.id, ({'data-full_url' => i.full_url} if full_url) ])
|
21
|
+
end
|
22
|
+
result
|
23
|
+
end
|
46
24
|
end
|
47
25
|
end
|
@@ -41,7 +41,7 @@
|
|
41
41
|
.control-group
|
42
42
|
= f.label :parent_id, class: 'control-label'
|
43
43
|
.controls
|
44
|
-
= f.select :parent_id, options_for_select(for_select(@
|
44
|
+
= f.select :parent_id, options_for_select(for_select(@pages, true), selected: @parent_id), disabled: @page.self_and_descendants.map(&:id), include_blank: t(:no)
|
45
45
|
|
46
46
|
.control-group
|
47
47
|
= f.label :template_id, :class => 'control-label'
|
@@ -10,26 +10,28 @@
|
|
10
10
|
|
11
11
|
%section.b-tree.span12
|
12
12
|
%ul
|
13
|
-
|
14
|
-
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
+
.b-tree__buttons
|
22
|
+
= arrow_buttons_for(page)
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
- if page.template.child
|
30
|
+
= link_to new_child_page_path(page), class: 'btn btn-success btn-mini' do
|
31
|
+
%i.icon-chevron-down
|
32
|
+
=t :add
|
33
|
+
= page.template.child.to_accusative
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
= link_to page, method: :delete, class: 'btn btn-danger btn-mini pull-right', data: {confirm: t(:are_you_sure?)} do
|
36
|
+
%i.icon-remove
|
37
|
+
=t :delete
|
@@ -8,17 +8,20 @@
|
|
8
8
|
=t :new_template
|
9
9
|
|
10
10
|
%section.b-tree.span12
|
11
|
-
|
12
|
-
|
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
|
13
16
|
|
14
|
-
|
15
|
-
|
17
|
+
.b-tree__buttons
|
18
|
+
= arrow_buttons_for(template)
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
21
24
|
|
22
|
-
|
23
|
-
|
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
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: constructor-pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Zotov
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.8.0
|
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.
|
26
|
+
version: 0.8.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: dragonfly
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|