card editing version one

This commit is contained in:
2022-11-30 23:49:23 +02:00
parent df5713e6fe
commit 204ab1abcc
12 changed files with 71 additions and 37 deletions

View File

@ -1,11 +0,0 @@
.relative.block.border.border-gray-100
%h3.mt-4.text-lg.font-bold= key.upcase
%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 "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" , 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,6 +1,6 @@
.relative.block.border.border-gray-100
%h3.mt-4.text-lg.font-bold= key.upcase
= section_form( class: "mx-auto mt-8 mb-0 max-w space-y-4") do
= text_field_tag( :header , @section.content["header"], class: "w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm")
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-sm.font-medium.text-white{:type => "submit"}
Update
%h3.mt-4.text-lg.font-bold Header
= form_tag( card_url(card.id) , {method: :patch } ) do
= text_field_tag( :header , card.content["header"], class: "w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm")
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-sm.font-medium.text-white{:type => "submit"}
Update

View File

@ -1,11 +1,3 @@
.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" , 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" , section_set_image_path( @page.name, @section.id , image: ""))
.relative.block.border.border-gray-100
-if( value.blank? )
No image

View File

@ -1,7 +1,6 @@
.relative.block.border.border-gray-100
%h3.mt-4.text-lg.font-bold= key.upcase
.relative.block.border.border-gray-100
= section_form( class: "mx-auto mt-8 mb-0 max-w space-y-4") do
= text_area_tag( :text , @section.content["text"], class: "w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm")
%h3.mt-4.text-lg.font-bold Text
= form_tag( card_url(card.id) , {method: :patch } ) do
= text_area_tag( :text , card.content["text"], class: "w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm")
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-sm.font-medium.text-white{:type => "submit"}
Update

View File

@ -24,6 +24,12 @@
=link_to "New" , "/index"
%button.mt-4.rounded-lg.bg-red-400.p-4
=link_to "Delete" , "/index"
.p-4
%h3.mt-4.text-lg.font-bold Image
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white
=link_to "Change Image" , card_select_image_url(card.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" , card_set_image_path( card.id , image: ""))
- card.content.each do |key , value|
= render "merged/cards/view/#{key}", card: card , key: key , value: value
= render "merged/cards/editors/#{key}", card: card , key: key , value: value

View File

@ -0,0 +1,15 @@
.grid.grid-cols-6.gap-2.m-8
.relative.block.border.border-gray-100
%h3.mt-4.text-lg.font-bold Add new image or select (click)
= form_tag(merged.images_path, multipart: true) do
= 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 , card_set_image_url(@card.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( card_set_image_path( image: name)) do
=image_tag("#{image_root}/#{name}" , class: "h-56 w-full object-contain lg:h-72")

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 #{@section.page.name}
Page #{link_to @section.page.name, page_url(@section.page.name)}
.flex.items-center.justify-center.flex-1
%h3.text-xl.font-bold.tracking-tight.text-gray-900
Section #{@section.id}