card template selection process

This commit is contained in:
Torsten 2022-11-29 20:22:57 +02:00
parent d1ecda07c4
commit 5ade5c6c19
8 changed files with 27 additions and 13 deletions

View File

@ -9,6 +9,9 @@ module Merged
def select_template
@sections = Style.sections
end
def select_card_template
@cards = Style.cards
end
def set_image
@section.content["image"] = params[:image]
@ -17,7 +20,17 @@ module Merged
end
def set_template
@section.content["template"] = params[:template]
template = params[:template]
raise "no template given" if template.blank?
@section.content["template"] = template
@page.save
redirect_to page_section_url(@page.id,@section.id)
end
def set_card_template
card_template = params[:card_template]
raise "no card template given" if card_template.blank?
@section.content["card_template"] = card_template
@page.save
redirect_to page_section_url(@page.id,@section.id)
end

View File

@ -31,6 +31,9 @@ module Merged
def template
@content["template"]
end
def card_template
@content["card_template"]
end
def id
@content["id"]

View File

@ -11,7 +11,6 @@ module Merged
def initialize content
@content = content
end
def template
@content["template"]
end

View File

@ -1,7 +0,0 @@
%h1 Editing merged_section
= render 'form'
= link_to 'Show', @merged_section
\|
= link_to 'Back', merged_sections_path

View File

@ -3,5 +3,7 @@
%p= value
%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 "Change Card Template" , page_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

@ -0,0 +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
=image_tag(style.card_preview , class: "h-56 w-full object-contain lg:h-72")
= style.header

View File

@ -12,7 +12,3 @@
.grid.grid-cols-2.gap-2.m-8
- @section.content.each do |key , value|
= render "merged/sections/editors/#{key}", section: @section , key: key , value: value
= #link_to 'Edit', edit_section_path(@merged_section)
\|
= #link_to 'Back', sections_path

View File

@ -7,6 +7,8 @@ Merged::Engine.routes.draw do
get :set_image
get :select_template
get :set_template
get :select_card_template
get :set_card_template
end
end
resources :images