flattened routes, lots of paths and arg changes

This commit is contained in:
2022-11-30 16:22:11 +02:00
parent 1d91ff2fc6
commit df5713e6fe
31 changed files with 121 additions and 104 deletions

View File

@ -4,8 +4,8 @@
%p #{section.content['cards'].length} cards
%p view cards (index)
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white
=link_to "View and Edit Cards" , page_section_card_url(@page.name,@section.id)
=link_to "View and Edit Cards" , section_card_url(@page.name,@section.id)
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white
=link_to "Change Card Template" , page_section_select_card_template_url(@page.name,@section.id)
=link_to "Change Card Template" , section_select_card_template_url(@page.name,@section.id)
.relative.block.border.border-gray-100
=image_tag("merged/card_preview/#{value}" , class: "w-full object-contain")

View File

@ -1,9 +1,9 @@
.relative.block.border.border-gray-100
%h3.mt-4.text-lg.font-bold= key.upcase
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white
=link_to "Change Image" , page_section_select_image_url(@page.name,@section.id)
=link_to "Change Image" , section_select_image_url(@page.name,@section.id)
%button.ml-3.inline-block.rounded-lg.bg-red-500.px-5.py-3.text-md.font-medium.text-white
= link_to( "Remove image" , page_section_set_image_path( @page.name, @section.id , image: ""))
= link_to( "Remove image" , section_set_image_path( @page.name, @section.id , image: ""))
.relative.block.border.border-gray-100

View File

@ -1,6 +1,6 @@
.relative.block.border.border-gray-100
%h3.mt-4.text-lg.font-bold= key.upcase + " : " + value
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white
=link_to "Change Template" , page_section_select_template_url(@page.name,@section.id)
=link_to "Change Template" , section_select_template_url(@section.id)
.relative.block.border.border-gray-100
=image_tag("merged/section_preview/#{section.template}" , class: "w-full object-contain")

View File

@ -4,10 +4,10 @@
.flex.items-center.justify-center.flex-1
.max-w-xl.px-4.py-8.mx-auto.text-center
%h1.text-2xl.font-bold.tracking-tight.text-gray-900
Page #{@page.name}
Page #{@section.page.name}
.flex.items-center.justify-center.flex-1
%h3.text-xl.font-bold.tracking-tight.text-gray-900
Cards for Section #{@section.id}
Cards for Section #{@section.index + 1}
.grid.grid-cols-4.gap-2.m-8
- @section.cards.each_with_index do |card , index|
@ -19,7 +19,7 @@
%button.mt-4.rounded-lg.bg-yellow-500.p-4
=link_to "Down" , "/index"
%button.mt-4.rounded-lg.bg-blue-400.p-4
=link_to "Edit" , page_section_path(@page.name , @section.id)
=link_to "Edit" , card_path( @section.id)
%button.mt-4.rounded-lg.bg-cyan-400.p-4
=link_to "New" , "/index"
%button.mt-4.rounded-lg.bg-red-400.p-4

View File

@ -1,10 +0,0 @@
= form_for @merged_page do |f|
- if @merged_page.errors.any?
#error_explanation
%h2= "#{pluralize(@merged_page.errors.count, "error")} prohibited this merged_page from being saved:"
%ul
- @merged_page.errors.full_messages.each do |message|
%li= message
.actions
= f.submit 'Save'

View File

@ -1,7 +0,0 @@
%h1 Editing #{@merged_page.name}
= render 'form'
= link_to 'Show', page_url(@merged_page.name)
\|
= link_to 'Back', pages_path

View File

@ -17,14 +17,14 @@
- @pages.each do |merged_page|
%tr
%td.whitespace-nowrap.px-4.py-2.text-gray-700
= link_to merged_page.name , page_path(merged_page.name)
= link_to merged_page.name , page_sections_path(merged_page.name)
%td.whitespace-nowrap.px-4.py-2.text-gray-700
= merged_page.first_template
%td.whitespace-nowrap.px-4.py-2.text-gray-700
= merged_page.content.length
%td.whitespace-nowrap.px-4.py-2
%strong.rounded.bg-green-100.px-3.text-xs.font-medium.text-green-700{:class => "py-1.5"}
= link_to 'Show', page_path(merged_page.name)
= link_to 'Sections', page_sections_path(merged_page.name)
%strong.rounded.bg-amber-100.px-3.text-xs.font-medium.text-amber-700{:class => "py-1.5"}
= link_to 'Edit', edit_page_path(merged_page.name)

View File

@ -1,5 +0,0 @@
%h1 New merged_page
= render 'form'
= link_to 'Back', pages_path

View File

@ -5,17 +5,17 @@
%h1.text-2xl.font-bold.tracking-tight.text-gray-900.sm:text-4xl
Page #{@page.name}
-@page.sections.each_with_index do |section , index|
.grid.grid-cols-6.gap-2.m-8{class: (index%2)==1 ? 'bg-cyan-50' : 'bg-red-50' }
-@page.sections.each do |section |
.grid.grid-cols-6.gap-2.m-8{class: (section.index%2)==1 ? 'bg-cyan-50' : 'bg-red-50' }
.relative.block.border.border-gray-100
.p-4
%h3.mt-4.text-lg.font-bold Section #{index + 1}
%h3.mt-4.text-lg.font-bold Section #{section.index + 1}
%button.mt-4.rounded-lg.bg-yellow-500.p-4
=link_to( "Up" , "/index")
%button.mt-4.rounded-lg.bg-yellow-500.p-4
=link_to "Down" , "/index"
%button.mt-4.rounded-lg.bg-blue-400.p-4
=link_to "Edit" , page_section_path(@page.name , section.id)
=link_to "Edit" , section_path(section.id)
%button.mt-4.rounded-lg.bg-cyan-400.p-4
=link_to "New" , "/index"
%button.mt-4.rounded-lg.bg-red-400.p-4

View File

@ -4,8 +4,8 @@
%p #{section.content['cards'].length} cards
%p view cards (index)
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white
=link_to "View and Edit Cards" , page_section_card_url(@page.name,@section.id)
=link_to "View and Edit Cards" , section_cards_url(@section.id)
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white
=link_to "Change Card Template" , page_section_select_card_template_url(@page.name,@section.id)
=link_to "Change Card Template" , section_select_card_template_url(@section.id)
.relative.block.border.border-gray-100
=image_tag("merged/card_preview/#{value}" , class: "w-full object-contain")

View File

@ -1,9 +1,9 @@
.relative.block.border.border-gray-100
%h3.mt-4.text-lg.font-bold= key.upcase
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white
=link_to "Change Image" , page_section_select_image_url(@page.name,@section.id)
=link_to "Change Image" , section_select_image_url(@section.id)
%button.ml-3.inline-block.rounded-lg.bg-red-500.px-5.py-3.text-md.font-medium.text-white
= link_to( "Remove image" , page_section_set_image_path( @page.name, @section.id , image: ""))
= link_to( "Remove image" , section_set_image_path( @section.id , image: ""))
.relative.block.border.border-gray-100

View File

@ -1,6 +1,6 @@
.relative.block.border.border-gray-100
%h3.mt-4.text-lg.font-bold= key.upcase + " : " + value
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white
=link_to "Change Template" , page_section_select_template_url(@page.name,@section.id)
=link_to "Change Template" , section_select_template_url(@section.id)
.relative.block.border.border-gray-100
=image_tag("merged/section_preview/#{section.template}" , class: "w-full object-contain")

View File

@ -5,17 +5,17 @@
%h1.text-2xl.font-bold.tracking-tight.text-gray-900.sm:text-4xl
Page #{@page.name}
-@page.sections.each_with_index do |section , index|
.grid.grid-cols-6.gap-2.m-8{class: (index%2)==1 ? 'bg-cyan-50' : 'bg-red-50' }
-@page.sections.each do |section |
.grid.grid-cols-6.gap-2.m-8{class: (section.index%2)==1 ? 'bg-cyan-50' : 'bg-red-50' }
.relative.block.border.border-gray-100
.p-4
%h3.mt-4.text-lg.font-bold Section #{index + 1}
%h3.mt-4.text-lg.font-bold Section #{section.index + 1}
%button.mt-4.rounded-lg.bg-yellow-500.p-4
=link_to( "Up" , "/index")
%button.mt-4.rounded-lg.bg-yellow-500.p-4
=link_to "Down" , "/index"
%button.mt-4.rounded-lg.bg-blue-400.p-4
=link_to "Edit" , page_section_path(@page.name , section.id)
=link_to "Edit" , section_path(section.id)
%button.mt-4.rounded-lg.bg-cyan-400.p-4
=link_to "New" , "/index"
%button.mt-4.rounded-lg.bg-red-400.p-4

View File

@ -1,6 +1,6 @@
.grid.grid-cols-4.gap-2.m-8
- @cards.each do |style|
.relative.block.border.border-gray-100
= link_to( page_section_set_card_template_path( card_template: style.template )) do
= link_to( section_set_card_template_path( card_template: style.template )) do
=image_tag(style.card_preview , class: "h-56 w-full object-contain lg:h-72")
= style.header

View File

@ -5,11 +5,11 @@
= text_field_tag 'filename'
%h5.mt-4.text-lg.font-bold Name is optional
%p will be taken from uploaded file
= hidden_field_tag :redirect , page_section_set_image_url(@page.name,@section.id,image: "NEW")
= hidden_field_tag :redirect , section_set_image_url(@section.id,image: "NEW")
= file_field_tag 'image_file'
.inline-block.rounded.border.border-indigo-600.bg-indigo-600.px-12.py-3.text-sm.font-medium.text-white.hover:bg-transparent.hover:text-indigo-600.focus:outline-none.focus:ring.active:text-indigo-500{:href => merged.new_image_path}
= submit_tag 'Submit'
-@images.each do |name , image|
.relative.block.border.border-gray-100
= link_to( page_section_set_image_path( image: name)) do
=image_tag("cms/#{name}" , class: "h-56 w-full object-contain lg:h-72")
= link_to( section_set_image_path( image: name)) do
=image_tag("#{image_root}/#{name}" , class: "h-56 w-full object-contain lg:h-72")

View File

@ -1,6 +1,6 @@
.grid.grid-cols-4.gap-2.m-8
- @sections.each do |style|
.relative.block.border.border-gray-100
= link_to( page_section_set_template_path( template: style.template )) do
= link_to( section_set_template_path( template: style.template )) do
=image_tag(style.section_preview , class: "h-56 w-full object-contain lg:h-72")
= style.header

View File

@ -4,7 +4,7 @@
.flex.items-center.justify-center.flex-1
.max-w-xl.px-4.py-8.mx-auto.text-center
%h1.text-2xl.font-bold.tracking-tight.text-gray-900
Page #{@page.name}
Page #{@section.page.name}
.flex.items-center.justify-center.flex-1
%h3.text-xl.font-bold.tracking-tight.text-gray-900
Section #{@section.id}