unused image finder
This commit is contained in:
parent
dd0a0d0ced
commit
1570e34d35
@ -5,7 +5,7 @@ module Merged
|
|||||||
before_action :set_image, only: %i[ update destroy show scale crop copy ]
|
before_action :set_image, only: %i[ update destroy show scale crop copy ]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@images = Image.all
|
@images = get_images
|
||||||
@image_data = @images.collect{|i|
|
@image_data = @images.collect{|i|
|
||||||
data = i.attributes.dup
|
data = i.attributes.dup
|
||||||
data[:url] = view_context.asset_path(i.asset_name)
|
data[:url] = view_context.asset_path(i.asset_name)
|
||||||
@ -65,6 +65,18 @@ module Merged
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def get_images
|
||||||
|
images = Image.all
|
||||||
|
puts "Images #{images.length}"
|
||||||
|
return images unless params[:unused]
|
||||||
|
hash = images.collect{|i| [i.id , i ] }.to_h
|
||||||
|
puts "Images1 #{hash.length}"
|
||||||
|
Section.all.each{ |s| hash.delete(s.image&.id)}
|
||||||
|
puts "Images2 #{hash.length}"
|
||||||
|
Card.all.each{ |s| hash.delete(s.image&.id)}
|
||||||
|
puts "Images3 #{hash.length}"
|
||||||
|
hash.values
|
||||||
|
end
|
||||||
def set_image
|
def set_image
|
||||||
@image = Image.find(params[:id] || params[:image_id])
|
@image = Image.find(params[:id] || params[:image_id])
|
||||||
end
|
end
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
%script{:src => "https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.js"}
|
%script{:src => "https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.js"}
|
||||||
|
|
||||||
.mx-20.flex.h-16.items-center.gap-16
|
.mx-20.flex.h-16.items-center.gap-16.justify-between
|
||||||
.text-xl.font-bold.text-gray-900
|
.flex.gap-20
|
||||||
= text_for_index
|
.text-xl.font-bold.text-gray-900
|
||||||
|
= text_for_index
|
||||||
|
|
||||||
= link_to(merged.new_image_path(new_link_params) ) do
|
= link_to(merged.new_image_path(new_link_params) ) do
|
||||||
.button.action New Image
|
.button.action New Image
|
||||||
|
= link_to(merged.images_path(unused: true) ) do
|
||||||
|
.button.action Show unused Images
|
||||||
|
|
||||||
.images
|
.images
|
||||||
.flex.justify-center.gap-4
|
.flex.justify-center.gap-4
|
||||||
@ -27,7 +30,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"}
|
%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"}
|
%path{:d => "M15.75 17.25L12 21m0 0l-3.75-3.75M12 21V3", "stroke-linecap" => "round", "stroke-linejoin" => "round"}
|
||||||
|
|
||||||
.grid.grid-cols-6.gap-4.m-8
|
.grid.grid-cols-2.lg:grid-cols-4.xl: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.flex-col.border.border-gray-100.rounded.image_box{"v-for": "image in filter_and_sort"}
|
||||||
.flex.align-center.justify-between.mb-4
|
.flex.align-center.justify-between.mb-4
|
||||||
.text-lg.font-bold.mt-2.mx-2
|
.text-lg.font-bold.mt-2.mx-2
|
||||||
|
Loading…
Reference in New Issue
Block a user