mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-01 04:32:16 +08:00
Tables are now always atleast 5x5, like in scinote when creating new table
This commit is contained in:
parent
a37d4f3cde
commit
e56c0bb100
1 changed files with 9 additions and 4 deletions
|
@ -52,17 +52,24 @@ module ProtocolsIoHelper
|
|||
tables[table_counter.to_s] = {}
|
||||
tr_number = table[0].scan(tr_regex).count
|
||||
diff = 5 - tr_number # always tables have atleast 5 rows
|
||||
table_fixed_string = tr_number > 4 ? table[0] : table[0] + empty_tr_gen(diff)
|
||||
table_fixed_string = tr_number > 4 ? table[0] : table[0] + empty_tbl_gen(diff)
|
||||
tr_strings = table_fixed_string.scan(tr_regex)
|
||||
contents = {}
|
||||
contents['data'] = []
|
||||
tr_strings.each_with_index do |tr, tr_counter|
|
||||
td_strings = tr[0].scan(td_regex)
|
||||
contents['data'][tr_counter] = []
|
||||
td_counter = td_strings.count
|
||||
diff = 5 - td_counter
|
||||
td_strings.each do |td|
|
||||
td_stripped = ActionController::Base.helpers.strip_tags(td[0])
|
||||
contents['data'][tr_counter].push(td_stripped)
|
||||
end
|
||||
next if td_counter >= 5
|
||||
while diff > 0
|
||||
contents['data'][tr_counter].push(' ')
|
||||
diff -= 1
|
||||
end
|
||||
end
|
||||
tables[table_counter.to_s]['contents'] = Base64.encode64(
|
||||
contents.to_s.sub('=>', ':')
|
||||
|
@ -73,7 +80,7 @@ module ProtocolsIoHelper
|
|||
return tables, string_without_tables
|
||||
end
|
||||
|
||||
def empty_tr_gen(number)
|
||||
def empty_tbl_gen(number)
|
||||
result = ''
|
||||
while number > 0
|
||||
result += '<tr></tr>'
|
||||
|
@ -409,8 +416,6 @@ module ProtocolsIoHelper
|
|||
newj[i.to_s]['tables'], table_str = protocolsio_string_to_table_element(
|
||||
newj[i.to_s]['description']
|
||||
)
|
||||
# Base64.decode64(newj[i.to_s]['tables'][0]['contents'])
|
||||
# byebug
|
||||
newj[i.to_s]['description'] = table_str
|
||||
end # steps
|
||||
newj
|
||||
|
|
Loading…
Reference in a new issue