fixes from option change
This commit is contained in:
parent
2abdf7add1
commit
d936fc05ab
@ -2,6 +2,7 @@ require "redcarpet"
|
||||
|
||||
module Merged
|
||||
module MergedHelper
|
||||
include OptionsHelper
|
||||
@@renderer = nil
|
||||
|
||||
def renderer
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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"]
|
||||
|
@ -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
|
||||
|
@ -1 +0,0 @@
|
||||
ActiveFile::Base.set_root_path "config"
|
@ -1,90 +1,89 @@
|
||||
---
|
||||
- name: fixed
|
||||
description:
|
||||
Paralax effect where background stays fixed
|
||||
during scrolling
|
||||
values: on off
|
||||
default: off
|
||||
- name: columns
|
||||
description:
|
||||
Number of columns in a layout that supports cards
|
||||
values: 2 3 4
|
||||
default: 3
|
||||
- name: background
|
||||
description:
|
||||
Background colors. Light colors stay with black text.
|
||||
Solid colors invert to white text.
|
||||
values: white none light_blue light_gray light_orange solid_blue solid_red solid_indigo
|
||||
default: none
|
||||
- name: color
|
||||
description:
|
||||
Text colors. Don't use with solid background colors.
|
||||
Same colors as background available. Default none, meas as parent.
|
||||
values: none white black light_blue light_gray solid_black solid_blue solid_red solid_indigo
|
||||
default: none
|
||||
- name: shade_color
|
||||
description:
|
||||
Color of transparent shaded area.
|
||||
The number means transparency.
|
||||
values: none black_25 white_25 light_red_25 light_blue_25 solid_blue_25 solid_red_25
|
||||
default: none
|
||||
- name: align
|
||||
description:
|
||||
Align text of children. Normal Word meaning
|
||||
values: left center right
|
||||
default: left
|
||||
- name: order
|
||||
description:
|
||||
For two column layout determine order of sub-cards
|
||||
Values of left and right usually refer to where the image is
|
||||
For cards it can also mean up and down
|
||||
values: left right
|
||||
default: left
|
||||
- name: margin
|
||||
description:
|
||||
Most sections have standard margin of 20.
|
||||
This option makes it possible to remove that
|
||||
values: 0 20
|
||||
default: 20
|
||||
- name: button_text
|
||||
description:
|
||||
Text for an optional button. Must also set button_link
|
||||
values:
|
||||
default:
|
||||
- name: subheader
|
||||
description:
|
||||
Smaller header between Header and text
|
||||
values:
|
||||
default:
|
||||
- name: text
|
||||
description:
|
||||
Second text. Just a second paragraph
|
||||
values:
|
||||
default:
|
||||
- name: button_link
|
||||
description:
|
||||
Link for an option button. Must also set button_text.
|
||||
Link must be a page name, ie only internal links allowed.
|
||||
values:
|
||||
default:
|
||||
- name: compulsory
|
||||
description:
|
||||
Form fields may be compulsory or not. By default they are.
|
||||
values: yes no
|
||||
default: no
|
||||
- name: form_type
|
||||
description:
|
||||
Form fields may have a type for special handling. The default is text
|
||||
- :name: fixed
|
||||
:description: Paralax effect where background stays fixed during scrolling
|
||||
:values: on off
|
||||
:default: false
|
||||
:id: 1
|
||||
- :name: columns
|
||||
:description: Number of columns in a layout that supports cards
|
||||
:values: 2 3 4
|
||||
:default: 3
|
||||
:id: 2
|
||||
- :name: background
|
||||
:description: Background colors. Light colors stay with black text. Solid colors
|
||||
invert to white text.
|
||||
:values: white none light_blue light_gray light_orange solid_blue solid_red solid_indigo
|
||||
:default: none
|
||||
:id: 3
|
||||
- :name: color
|
||||
:description: Text colors. Don't use with solid background colors. Same colors as
|
||||
background available. Default none, meas as parent.
|
||||
:values: none white black light_blue light_gray solid_black solid_blue solid_red
|
||||
solid_indigo
|
||||
:default: none
|
||||
:id: 4
|
||||
- :name: shade_color
|
||||
:description: Color of transparent shaded area. The number means transparency.
|
||||
:values: none black_25 white_25 light_red_25 light_blue_25 solid_blue_25 solid_red_25
|
||||
:default: none
|
||||
:id: 5
|
||||
- :name: align
|
||||
:description: Align text of children. Normal Word meaning
|
||||
:values: left center right
|
||||
:default: left
|
||||
:id: 6
|
||||
- :name: order
|
||||
:description: For two column layout determine order of sub-cards Values of left
|
||||
and right usually refer to where the image is For cards it can also mean up and
|
||||
down
|
||||
:values: left right
|
||||
:default: left
|
||||
:id: 7
|
||||
- :name: margin
|
||||
:description: Most sections have standard margin of 20. This option makes it possible
|
||||
to remove that
|
||||
:values: 0 20
|
||||
:default: 20
|
||||
:id: 8
|
||||
- :name: button_text
|
||||
:description: Text for an optional button. Must also set button_link
|
||||
:values:
|
||||
:default:
|
||||
:id: 9
|
||||
- :name: subheader
|
||||
:description: Smaller header between Header and text
|
||||
:values:
|
||||
:default:
|
||||
:id: 10
|
||||
- :name: text
|
||||
:description: Second text. Just a second paragraph
|
||||
:values:
|
||||
:default:
|
||||
:id: 11
|
||||
- :name: button_link
|
||||
:description: Link for an option button. Must also set button_text. Link must be
|
||||
a page name, ie only internal links allowed.
|
||||
:values:
|
||||
:default:
|
||||
:id: 12
|
||||
- :name: compulsory
|
||||
:description: Form fields may be compulsory or not. By default they are.
|
||||
:values: yes no
|
||||
:default: false
|
||||
:id: 13
|
||||
- :name: form_type
|
||||
:description: Form fields may have a type for special handling. The default is text
|
||||
but message would be a longer text, and email checked to be a name.
|
||||
values: text message email phone date
|
||||
default: text
|
||||
- name: ok_message
|
||||
description:
|
||||
Message shown to the user when a form was submitted
|
||||
values:
|
||||
default:
|
||||
- name: handler
|
||||
description:
|
||||
Form handler
|
||||
values: FormHandler
|
||||
default: FormHandler
|
||||
:values: text message email phone date
|
||||
:default: text
|
||||
:id: 14
|
||||
- :name: ok_message
|
||||
:description: Message shown to the user when a form was submitted
|
||||
:values:
|
||||
:default:
|
||||
:id: 15
|
||||
- :name: handler
|
||||
:description: Form handler
|
||||
:values: FormHandler
|
||||
:default: FormHandler
|
||||
:id: 16
|
||||
|
@ -4,10 +4,11 @@ require "merged/engine"
|
||||
module Merged
|
||||
|
||||
def self.load_data
|
||||
["card_style" , "section_style" , "option"].each do |kind|
|
||||
["card_style" , "section_style"].each do |kind|
|
||||
# loading egine definitions first, can be overriden
|
||||
load_from kind , Engine.root.join("config/merged/#{kind}.yaml")
|
||||
end
|
||||
Option.load
|
||||
Page.load_pages
|
||||
Image.load_images
|
||||
end
|
||||
|
@ -3,9 +3,9 @@ require 'rails_helper'
|
||||
RSpec.feature "Changes", type: :feature do
|
||||
describe "GET /changes" do
|
||||
it "returns http success" do
|
||||
visit "/merged/changes"
|
||||
expect(page).to have_title("Merged")
|
||||
expect(page).to have_text("Pages")
|
||||
visit "/merged/changes/index"
|
||||
expect(page).to have_title("Deletions")
|
||||
expect(page).to have_text("Additions")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ module Merged
|
||||
|
||||
it "has Style.cards" do
|
||||
expect(CardStyle.cards.class).to be Hash
|
||||
expect(CardStyle.cards.length).to be 4
|
||||
expect(CardStyle.cards.length).to be 5
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -2,16 +2,19 @@ require 'rails_helper'
|
||||
|
||||
module Merged
|
||||
RSpec.describe Option, type: :model do
|
||||
let(:first) {Option.options.values.first}
|
||||
let(:first) {Option.first}
|
||||
|
||||
it "has Option.options" do
|
||||
expect(Option.options.class).to be Hash
|
||||
it "has Option.first" do
|
||||
expect(Option.first.class).to be Option
|
||||
end
|
||||
it "there are options" do
|
||||
expect(Option.options.length).to be 16
|
||||
expect(Option.all.length).to be 16
|
||||
end
|
||||
it "has option objects" do
|
||||
expect(first.class).to be Option
|
||||
end
|
||||
it "has values" do
|
||||
expect(first.values.class).to be Array
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ module Merged
|
||||
|
||||
it "has Style.sections" do
|
||||
expect(SectionStyle.sections.class).to be Hash
|
||||
expect(SectionStyle.sections.length).to be 6
|
||||
expect(SectionStyle.sections.length).to be 7
|
||||
end
|
||||
it "Finds section by template" do
|
||||
spacer = SectionStyle.sections["section_spacer"]
|
||||
|
Loading…
Reference in New Issue
Block a user