take new back out of images into ruby land
This commit is contained in:
parent
484fa4f6e7
commit
68179949c8
@ -1345,6 +1345,10 @@ select {
|
||||
grid-column: span 2 / span 2;
|
||||
}
|
||||
|
||||
.col-span-3 {
|
||||
grid-column: span 3 / span 3;
|
||||
}
|
||||
|
||||
.m-0 {
|
||||
margin: 0px;
|
||||
}
|
||||
@ -1885,6 +1889,10 @@ select {
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
.gap-20 {
|
||||
gap: 5rem;
|
||||
}
|
||||
|
||||
.space-y-4 > :not([hidden]) ~ :not([hidden]) {
|
||||
--tw-space-y-reverse: 0;
|
||||
margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse)));
|
||||
|
@ -9,7 +9,7 @@ module Merged
|
||||
@image_data = @images.collect{|i|
|
||||
data = i.attributes.dup
|
||||
data[:url] = view_context.asset_path(i.asset_name)
|
||||
data[:link] = build_link_for(i)
|
||||
data[:link] = build_select_link_for(i)
|
||||
data[:updated_at] = i.updated_at.to_date if i.updated_at
|
||||
data[:created] = i.updated_at.to_i
|
||||
data[:aspect_ratio] = i.aspect_ratio.join("/")
|
||||
@ -19,7 +19,7 @@ module Merged
|
||||
end
|
||||
|
||||
def destroy
|
||||
@image.destroy
|
||||
@image.destroy(current_member.email)
|
||||
redirect_to :images , notice: "Image #{@image.name} deleted"
|
||||
end
|
||||
|
||||
@ -82,7 +82,7 @@ module Merged
|
||||
end
|
||||
end
|
||||
|
||||
def build_link_for(image)
|
||||
def build_select_link_for(image)
|
||||
if(params[:section_id])
|
||||
return view_context.section_set_image_url(params[:section_id] , image_id: image.id)
|
||||
end
|
||||
|
@ -17,16 +17,25 @@ module Merged
|
||||
def text_for_new
|
||||
if(section_id)
|
||||
section = Section.find(section_id)
|
||||
"Add image for Section"
|
||||
"Add image for Section: #{section.header}"
|
||||
elsif(card_id)
|
||||
card = Card.find(card_id)
|
||||
"Select image for Card"
|
||||
"Select image for Card: #{card.header}"
|
||||
else
|
||||
"New Image"
|
||||
end
|
||||
end
|
||||
|
||||
def hidden_for_select
|
||||
def new_link_params
|
||||
if(params[:section_id])
|
||||
return {section_id: params[:section_id]}
|
||||
end
|
||||
if(params[:card_id])
|
||||
return {card_id: params[:card_id]}
|
||||
end
|
||||
nil
|
||||
end
|
||||
def hidden_for_select_image
|
||||
if(section_id)
|
||||
hidden_field_tag :section_id , section_id
|
||||
elsif(card_id)
|
||||
|
@ -53,9 +53,9 @@ module Merged
|
||||
self.size = (image.size/1024).to_i
|
||||
end
|
||||
|
||||
def destroy
|
||||
def destroy(editor)
|
||||
File.delete self.full_filename
|
||||
delete_save!(current_member.email)
|
||||
delete_save!(editor)
|
||||
end
|
||||
|
||||
def asset_name
|
||||
|
@ -1,7 +0,0 @@
|
||||
.flex.flex-col.border.border-gray-100.rounded.p-4
|
||||
%h3.my-4.text-xl.font-bold Add new image
|
||||
= text_field_tag 'filename' ,nil, placeholder: "Optiona name", class: "rounded"
|
||||
%p.my-4 Name will be taken from uploaded file
|
||||
= yield :hidden
|
||||
= file_field_tag 'image_file' , class: "mb-8 w-full px-2 text-xl bg-clip-padding border border-solid border-gray-300 rounded"
|
||||
= submit_button 'Submit'
|
@ -2,6 +2,8 @@
|
||||
.text-xl.font-bold.text-gray-900
|
||||
= text_for_index
|
||||
|
||||
= link_to( "New Image" , merged.new_image_path(new_link_params) , class: "p-2 border border-gray-200 bg-cyan-100 font-bold rounded-lg hover:bg-sky-100")
|
||||
|
||||
- if Rails.env.development?
|
||||
= javascript_include_tag "merged/vue.js"
|
||||
-else
|
||||
@ -9,8 +11,6 @@
|
||||
|
||||
.images
|
||||
.flex.justify-center.gap-4
|
||||
.rounded.border.mr-20{"@click" => "toggle_new" , ":class" => "{'bg-orange-200': show_new }"}
|
||||
.mx-4.text-lg.font-bold Add new
|
||||
|
||||
%label.block
|
||||
.mt-1.text-lg.font-bold Search:
|
||||
@ -29,21 +29,7 @@
|
||||
%svg.w-6.h-6.mt-1{:fill => "none", :stroke => "currentColor", "stroke-width" => "1.5", :viewbox => "0 0 24 24", :xmlns => "http://www.w3.org/2000/svg"}
|
||||
%path{:d => "M15.75 17.25L12 21m0 0l-3.75-3.75M12 21V3", "stroke-linecap" => "round", "stroke-linejoin" => "round"}
|
||||
|
||||
.grid.grid-cols-3.gap-4.m-8{":class" => "{'hidden': !show_new }"}
|
||||
%div
|
||||
= form_tag(merged.images_path, multipart: true) do
|
||||
.flex.flex-col.border.border-gray-100.rounded.p-4
|
||||
%h3.my-4.text-xl.font-bold= text_for_new
|
||||
= text_field_tag 'filename' ,nil, placeholder: "Optional name", class: "rounded mt-4"
|
||||
%p.my-4 Name will be taken from uploaded file if not given
|
||||
= text_field_tag 'tags' ,nil, placeholder: "Optional tags", class: "rounded mt-4"
|
||||
%p.my-4 Tags describe the size or format
|
||||
= hidden_for_select
|
||||
= file_field_tag 'image_file' , class: "mb-8 w-full px-2 text-xl bg-clip-padding border border-solid border-gray-300 rounded"
|
||||
= submit_button 'Submit'
|
||||
%div
|
||||
|
||||
.grid.grid-cols-6.gap-4.m-8{":class" => "{'hidden': show_new }"}
|
||||
.grid.grid-cols-6.gap-4.m-8
|
||||
.flex.flex-col.border.border-gray-100.rounded.image_box{"v-for": "image in filter_and_sort"}
|
||||
.flex.align-center.justify-between.mb-4
|
||||
.text-lg.font-bold.mt-2.mx-2
|
||||
@ -69,7 +55,6 @@
|
||||
@search_tag = ""
|
||||
@sort_by = "created"
|
||||
@sort_dir = -1 # 1 up
|
||||
@show_new = false
|
||||
end
|
||||
def filter_and_sort
|
||||
dat = @image_data
|
||||
@ -90,11 +75,4 @@
|
||||
end
|
||||
dat
|
||||
end
|
||||
def toggle_new()
|
||||
if @show_new == true
|
||||
@show_new = false
|
||||
else
|
||||
@show_new = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
12
app/views/merged/images/new.haml
Normal file
12
app/views/merged/images/new.haml
Normal file
@ -0,0 +1,12 @@
|
||||
.grid.grid-cols-3.gap-4.m-8{":class" => "{'hidden': !show_new }"}
|
||||
%div
|
||||
= form_tag(merged.images_path, multipart: true) do
|
||||
.flex.flex-col.border.border-gray-100.rounded.p-4
|
||||
%h3.my-4.text-xl.font-bold= text_for_new
|
||||
= text_field_tag 'filename' ,nil, placeholder: "Optional name", class: "rounded mt-4"
|
||||
%p.my-4 Name will be taken from uploaded file if not given
|
||||
= text_field_tag 'tags' ,nil, placeholder: "Optional tags", class: "rounded mt-4"
|
||||
%p.my-4 Tags describe the size or format
|
||||
= hidden_for_select_image
|
||||
= file_field_tag 'image_file' , class: "mb-8 w-full px-2 text-xl bg-clip-padding border border-solid border-gray-300 rounded"
|
||||
= submit_button 'Submit'
|
@ -17,7 +17,7 @@
|
||||
= @image.type
|
||||
%p
|
||||
.font-bold Size
|
||||
= @image.size
|
||||
= "#{@image.size}k"
|
||||
%p
|
||||
.font-bold Ratio
|
||||
= @image.ratio.round(2)
|
||||
@ -32,33 +32,32 @@
|
||||
|
||||
|
||||
=render "editor" , image: @image
|
||||
.flex.gap-2.m-20
|
||||
.flex.gap-10.m-20
|
||||
-if @used
|
||||
.grid.grid-cols-2
|
||||
%p
|
||||
Sections
|
||||
=@sections.length
|
||||
%p
|
||||
Cards
|
||||
=@cards.length
|
||||
%div
|
||||
.grid.grid-cols-2.gap-10
|
||||
.grid.grid-cols-3.gap-10
|
||||
%p.col-span-3.font-bold
|
||||
Sections using the image
|
||||
-@sections.each do |section|
|
||||
%p
|
||||
= link_to section.header , merged.section_path(section)
|
||||
on Page
|
||||
%p
|
||||
%em on Page
|
||||
%p
|
||||
= link_to section.page.name , merged.page_sections_path(section.page)
|
||||
%div
|
||||
.grid.grid-cols-3.gap-10
|
||||
%p.col-span-3.font-bold
|
||||
Cards using the image
|
||||
-@cards.each do |card|
|
||||
%p
|
||||
= link_to card.header , merged.section_cards_path(card.section)
|
||||
on Page
|
||||
%p
|
||||
%em on Page
|
||||
%p
|
||||
= link_to card.section.page.name , merged.page_sections_path(card.section.page)
|
||||
|
||||
-else
|
||||
.grid.grid-cols-2
|
||||
%div
|
||||
%p Not used, you may delete
|
||||
%div
|
||||
%p
|
||||
= form_tag( merged.image_path(@image.id) , {method: :delete } ) do
|
||||
=submit_button( "Delete" , true)
|
||||
%p.align-center Not used, you may delete
|
||||
%p
|
||||
= form_tag( merged.image_path(@image.id) , {method: :delete } ) do
|
||||
=submit_button( "Delete" , true)
|
||||
|
Loading…
x
Reference in New Issue
Block a user