-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from spartansystems/nested_collections
Nested collections
- Loading branch information
Showing
8 changed files
with
75 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,11 @@ | ||
class ArrayComponent < AtomicAssets::Component | ||
def children | ||
options[:children] ||= [] | ||
end | ||
|
||
def render | ||
children.map(&:render).reduce(:+) | ||
end | ||
|
||
def edit | ||
rtn = cms_fields | ||
rtn << cms_array(:children) do | ||
rtn2 = "" | ||
children.each do |child| | ||
rtn2 << cms_array_node { child.edit } | ||
end | ||
rtn2.html_safe | ||
end | ||
rtn << render_child_array | ||
rtn.html_safe | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
class AtomicCms::ComponentsController < ApplicationController | ||
def edit | ||
render text: component(params[:id]).edit_array(!!params[:inline]) | ||
module AtomicCms | ||
class ComponentsController < ApplicationController | ||
def edit | ||
render text: component(params[:id]).edit_array(!!params[:inline]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module ComponentHelper | ||
def add_option(option, output = nil) | ||
return unless option | ||
return output if output | ||
option | ||
end | ||
|
||
def markdown(text) | ||
return unless text | ||
Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(text).html_safe | ||
end | ||
|
||
def markdown_help_url | ||
"http://nestacms.com/docs/creating-content/markdown-cheat-sheet" | ||
end | ||
|
||
def render_children(children) | ||
return children unless children.present? && children.is_a?(Array) | ||
children.map(&:render).reduce(:+) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
span.li.string.input | ||
label.label #{name.to_s.humanize} | ||
select.cms-field class="children-sublist" | ||
option | ||
= options_for_select(options[:collection], value) | ||
a class="button add-children-sublist-item" Add |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters