-
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.
Add the ability to nest components in the CMS
Why: We need to be able to include some component inside of other bigger components and have them render a dynamic number of options. This change addresses the need by: Including some methods from the ArrayComponent class in the larger Editor class so they are available to all inheriting classes. Update the atomic_cms.js to be able to add subcomponents to parent ones.
- Loading branch information
Showing
7 changed files
with
52 additions
and
22 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
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
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