base class for styles

This commit is contained in:
Torsten 2022-12-16 16:49:26 +02:00
parent 22f21225a1
commit 46987dac70
4 changed files with 24 additions and 29 deletions

View File

@ -1,22 +1,11 @@
module Merged
class CardStyle < ActiveYaml::Base
set_root_path Engine.root + "config"
class CardStyle < Style
fields :template , :text , :header, :fields
def card_preview
"merged/card_preview/" + template
end
def options_definitions
option_defs = []
options.each do |name|
option = OptionDefinition.find_by_name(name)
raise "no option for #{name}:#{name.class}" if option.blank?
option_defs << option
end if options
option_defs
end
end
end

View File

@ -1,7 +1,5 @@
module Merged
class PageStyle < ActiveYaml::Base
set_root_path Engine.root + "config"
class PageStyle < Style
fields :type , :description
end

View File

@ -1,7 +1,6 @@
module Merged
class SectionStyle < ActiveYaml::Base
set_root_path Engine.root + "config"
class SectionStyle < Style
fields :template , :text , :header, :fields , :cards
def has_cards?
@ -12,15 +11,5 @@ module Merged
"merged/section_preview/" + template
end
def options_definitions
option_defs = []
options.each do |name|
option = OptionDefinition.find_by_name(name)
raise "no option for #{name}:#{name.class}" if option.blank?
option_defs << option
end if options
option_defs
end
end
end

View File

@ -0,0 +1,19 @@
module Merged
class Style < ActiveYaml::Base
set_root_path Engine.root + "config"
fields :options
def options_definitions
option_defs = []
options.each do |name|
option = OptionDefinition.find_by_name(name)
raise "no option for #{name}:#{name.class}" if option.blank?
option_defs << option
end if options
option_defs
end
end
end