From b160624e4eb2cadd8e4621c08edfe8d5dbba03f3 Mon Sep 17 00:00:00 2001 From: rulingcom Date: Thu, 19 Jun 2025 22:24:59 +0800 Subject: [PATCH] add file upload --- .../admin/universal_tables_controller.rb | 15 +++++++++++++++ .../universal_tables/export_structure.xlsx.axlsx | 8 ++++---- app/views/utable_export/export.xlsx.axlsx | 8 ++++---- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/app/controllers/admin/universal_tables_controller.rb b/app/controllers/admin/universal_tables_controller.rb index 1c15cb0..92f9436 100644 --- a/app/controllers/admin/universal_tables_controller.rb +++ b/app/controllers/admin/universal_tables_controller.rb @@ -174,6 +174,21 @@ end ce.text_translations = v when "integer" ce.number = (val.blank? ? nil : val) + when "image" + ce.remote_image_url = val + when "file" + val.split("\;").each do |remote_file| + file = ColumnEntryFile.new + file.remote_file_url = remote_file + filename = {} + file.choose_lang.choose_lang.reject(&:empty?).each do |lang| + filename[lang] = file.file.file.filename + end + file.file_title = filename + # file.column_entry_id = ce.id + file.save + ce.column_entry_files << file + end when "editor" v = {} @site_in_use_locales.sort.each_with_index do |locale,x| diff --git a/app/views/admin/universal_tables/export_structure.xlsx.axlsx b/app/views/admin/universal_tables/export_structure.xlsx.axlsx index 4ad9559..f8b2de0 100644 --- a/app/views/admin/universal_tables/export_structure.xlsx.axlsx +++ b/app/views/admin/universal_tables/export_structure.xlsx.axlsx @@ -31,7 +31,7 @@ wb.add_worksheet(name: "Structure") do |sheet| when "image" row << column.title row1 << column.key - row2 << "Please leave this column blank. Upload the image manually." + row2 << "Public URL" when "date" row << column.title row1 << column.key @@ -46,17 +46,17 @@ wb.add_worksheet(name: "Structure") do |sheet| when "file" row << column.title row1 << column.key - row2 << "Please leave this column blank. Upload the files manually." + row2 << "Separate the files by ;" end end row << t("universal_table.hashtags") row1 << "table_tags" - row2 << "table_tags" + row2 << "Separate tags by ;" row << t("universal_table.related_entries") row1 << "related_entries" - row2 << "related_entries" + row2 << "Separate UIDs with ;" sheet.add_row row, :style => heading sheet.add_row row1 diff --git a/app/views/utable_export/export.xlsx.axlsx b/app/views/utable_export/export.xlsx.axlsx index 2d17a46..3efa942 100644 --- a/app/views/utable_export/export.xlsx.axlsx +++ b/app/views/utable_export/export.xlsx.axlsx @@ -36,7 +36,7 @@ wb.add_worksheet(name: "Structure") do |sheet| when "image" row << column.title row1 << column.key - row2 << "Please leave this column blank. Upload the image manually." + row2 << "Public URL" when "date" row << column.title row1 << column.key @@ -48,17 +48,17 @@ wb.add_worksheet(name: "Structure") do |sheet| when "file" row << column.title row1 << column.key - row2 << "Please leave this column blank. Upload the files manually." + row2 << "Separate the files by ;" end end row << t("universal_table.hashtags") row1 << "table_tags" - row2 << "table_tags" + row2 << "Separate tags by ;" row << t("universal_table.related_entries") row1 << "related_entries" - row2 << "related_entries" + row2 << "Separate UIDs with ;" sheet.add_row row, :style => heading sheet.add_row row1