fixes from option change

This commit is contained in:
2022-12-10 19:22:44 +02:00
parent 2abdf7add1
commit d936fc05ab
12 changed files with 117 additions and 124 deletions

View File

@ -2,6 +2,7 @@ require "redcarpet"
module Merged
module MergedHelper
include OptionsHelper
@@renderer = nil
def renderer

View File

@ -1,6 +1,7 @@
module Merged
module SectionsHelper
include ViewHelper #for previews
def section_form(options)
url = section_url( @section.id)
form_tag( url , {method: :patch}) do

View File

@ -54,6 +54,11 @@ module Merged
def save
section.save
end
def save_soon
super
data = Option.all.collect {|obj| obj.attributes}
File.write( Option.full_path , data.to_yaml)
end
def set_index(index)
@index = index

View File

@ -21,7 +21,7 @@ module Merged
def options
option_defs = []
@content["options"].each do |name|
option = Option.options[name]
option = Option.find_by_name(name)
raise "no option for #{name}:#{name.class}" if option.blank?
option_defs << option
end if @content["options"]

View File

@ -1,20 +1,11 @@
module Merged
class Option < ActiveYaml::Base
@@options = {}
set_root_path Engine.root + "config"
fields :name , :default , :description , :values , :type
def initialize_old(options)
@name = options["name"]
@default = options["default"]
@description = options["description"]
@values = options["values"]
@type = options["type"]
end
def type
return @type unless @type.blank?
return attributes[:type] unless attributes[:type].blank?
if has_values?
"select"
else
@ -23,24 +14,17 @@ module Merged
end
def has_values?
return false if @values.nil?
! @values.empty?
return false if attributes[:values].nil?
! attributes[:values].empty?
end
def values
return [] unless has_values?
@values.split(" ")
attributes[:values].split(" ")
end
def self.options
@@options
end
def self.load(yaml)
yaml.each do |content|
option = Option.new(content)
@@options[option.name] = option
end
def self.load()
self.all
end
end