filter pages by type

This commit is contained in:
Torsten 2022-12-28 18:33:46 +02:00
parent d375bad897
commit 547d750034
8 changed files with 30 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View File

@ -5,6 +5,9 @@ module Merged
def index
@pages = Page.all
if(! params[:type].blank?)
@pages = @pages.where(type: params[:type])
end
@page_styles = PageStyle.all
end
@ -22,7 +25,6 @@ module Merged
options = params[:option]
if options
@page.option_definitions.each do |option|
puts "Option #{option.name}:#{options[option.name]}"
@page.set_option(option.name, options[option.name])
end
@page.edit_save(current_member.email)

View File

@ -17,6 +17,7 @@ module Merged
if( precision == "precise")
return date.to_formatted_s(:short) + " " + date.year.to_s
end
return Date.today if date.blank?
if(date.day < 10)
attr = "Beginning"
elsif date.day < 20

View File

@ -1,6 +1,8 @@
- content_for( :merged_menu ) do
.text-xl.font-bold.text-gray-900
All Pages
= link_to( "All" , merged.pages_path(type: '') , class: "p-2 px-4 border border-gray-200 font-bold rounded-lg hover:bg-sky-100 #{params[:type].blank? ? 'bg-blue-200':''}")
- @page_styles.each do |style|
= link_to( "Only #{style.type.capitalize}s" , merged.pages_path(type: style.type) , class: "p-2 px-4 border border-gray-200 font-bold rounded-lg hover:bg-sky-100 #{(params[:type] == style.type) ? 'bg-blue-200':''}")
= render "layouts/merged_header"
.overflow-hidden.overflow-x-auto.rounded-lg.border.border-gray-200.m-20

View File

@ -0,0 +1,9 @@
%section{ options(section , :background , :margin)}
.px-4.py-16.mx-20{options(section , :text_align , :color)}
%h1.text-2xl.font-bold.tracking-tight.sm:text-4xl
= section.header
-if section.has_option?("subheader")
%h4.text-xl.mt-10.md:text-2xl
= section.option("subheader")
.prose.mt-4.text-lg.pt-10
= markdown(section)

View File

@ -28,6 +28,18 @@
- item_align
- button_link
- button_text
- template: section_text
header: Text only section for longer passages of text, mostly news
text: Text may be markdown
fields:
- header
- text
options:
- background
- color
- margin
- subheader
- text_align
- template: section_half_image
header: Split section with image left or right
text: Image on one side, header and text on the other.

View File

@ -11,7 +11,7 @@ module Merged
assert_equal OptionDefinition.first.class , OptionDefinition
end
def test_there_options
assert_equal OptionDefinition.all.length , 19
assert_equal OptionDefinition.all.length , 20
end
def test_has_option_objects
assert_equal first.class , OptionDefinition

View File

@ -12,7 +12,7 @@ module Merged
assert spacer
end
def test_has_sections
assert_equal SectionStyle.all.length , 7
assert_equal SectionStyle.all.length , 9
end
def test_finds_section_by_template
spacer = SectionStyle.find_by_template("section_spacer")