fix small stuff

This commit is contained in:
rulingcom 2025-08-04 21:20:08 +08:00
parent 77097850e0
commit bef8995307
3 changed files with 12 additions and 12 deletions

View File

@ -65,7 +65,7 @@ class UniversalTablesController < ApplicationController
cols << { "text" => text.to_s }
when "image"
text = ce.image&.thumb&.url ? (host_url + ce.image.thumb.url) : ""
text = ce.image.thumb.url ? (host_url + ce.image.thumb.url) : ""
cols << { "text" => text }
when "file"

View File

@ -4,9 +4,9 @@
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<%= stylesheet_link_tag "select2/select2" %>
<%= javascript_include_tag "select2/select2.min" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "select2/select2.min" %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>

View File

@ -74,9 +74,9 @@ namespace :universal_table_tasks do
exit(1)
end
column_titles = sheet[0].cells.map { |c| c&.value.to_s.strip }
column_keys = sheet[1].cells.map { |c| c&.value.to_s.strip }
column_types = sheet[2].cells.map { |c| c&.value.to_s.strip }
column_titles = sheet[0].cells.map { |c| c.value.to_s.strip }
column_keys = sheet[1].cells.map { |c| c.value.to_s.strip }
column_types = sheet[2].cells.map { |c| c.value.to_s.strip }
columns = column_keys.uniq.map.with_index do |key, i|
tc = table.table_columns.where(key: key).first
@ -90,7 +90,7 @@ namespace :universal_table_tasks do
end
next if i < 3
uid_val = row[0]&.value.to_s.strip rescue nil
uid_val = row[0].value.to_s.strip rescue nil
te = uid_val.present? ? TableEntry.where(uid: uid_val, u_table_id: table.id).first_or_initialize : TableEntry.new
te.u_table = table
@ -99,7 +99,7 @@ namespace :universal_table_tasks do
row.cells.each_with_index do |cell, col_idx|
next if skip > 0 && (skip -= 1) >= 0
val = cell&.value
val = cell.value
tc = columns[tc_idx]
tc_idx += 1
next if tc.nil?
@ -110,7 +110,7 @@ namespace :universal_table_tasks do
when "text", "editor"
v = {}
site_locales.each_with_index do |locale, offset|
v[locale.to_s] = row[col_idx + offset]&.value.to_s rescue ""
v[locale.to_s] = row[col_idx + offset].value.to_s rescue ""
end
skip = site_locales.size - 1
tc.type == "text" ? ce.text_translations = v : ce.content_translations = v
@ -126,7 +126,7 @@ namespace :universal_table_tasks do
file_titles = {}
skip = site_locales.size
site_locales.each_with_index do |locale, locale_idx|
file_titles[locale.to_s] = row[col_idx + locale_idx + 1]&.value.to_s.split(";").map(&:strip)
file_titles[locale.to_s] = row[col_idx + locale_idx + 1].value.to_s.split(";").map(&:strip)
end
# ce.column_entry_files.destroy_all
# ce.column_entry_files = []
@ -155,17 +155,17 @@ namespace :universal_table_tasks do
when "period"
skip = 1
ce.period_from = val
ce.period_to = row[col_idx + 1]&.value rescue nil
ce.period_to = row[col_idx + 1].value rescue nil
end
ce.save!
te.column_entries << ce
end
tags_text = row.cells[-2]&.value.to_s rescue ""
tags_text = row.cells[-2].value.to_s rescue ""
create_get_table_tags(te, tags_text.split(";")) if row.cells.count >= 2
related_uids = row.cells[-1]&.value.to_s.split(";").map(&:strip)
related_uids = row.cells[-1].value.to_s.split(";").map(&:strip)
related_ids = TableEntry.where(:uid.in => related_uids).pluck(:id)
te.related_entries = related_ids.join(",") if row.cells.count >= 1