super_tools 0.0.25 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/test.yml +21 -0
- data/.gitignore +5 -0
- data/.ruby-version +1 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +161 -150
- data/README.md +2 -1
- data/dependabot.yml +7 -0
- data/lib/super_form/basic.rb +2 -7
- data/lib/super_form/concerns/atomic_save.rb +3 -3
- data/lib/super_form/reform.rb +28 -6
- data/lib/super_formatter/ecan/head.rb +4 -4
- data/lib/super_formatter/ecan/import.rb +4 -3
- data/lib/super_formatter/ecan/row.rb +3 -2
- data/lib/super_formatter/hct/head.rb +5 -5
- data/lib/super_formatter/hct/import.rb +4 -3
- data/lib/super_formatter/hct/row.rb +4 -3
- data/lib/super_formatter/shopline/head.rb +16 -16
- data/lib/super_formatter/shopline/import.rb +5 -6
- data/lib/super_formatter/shopline/order.rb +9 -8
- data/lib/super_formatter/shopline/row.rb +2 -2
- data/lib/super_formatter/tcat/head.rb +4 -4
- data/lib/super_formatter/tcat/import.rb +4 -4
- data/lib/super_formatter/tcat/row.rb +5 -4
- data/lib/super_interaction/beyond.rb +77 -0
- data/lib/super_interaction/beyond_helper.rb +13 -0
- data/lib/super_interaction/{command.rb → bootstrap.rb} +2 -2
- data/lib/super_interaction/{controller_helper.rb → bootstrap_helper.rb} +2 -2
- data/lib/super_interaction/engine.rb +6 -0
- data/lib/super_interaction/views/layouts/beyond.haml +27 -0
- data/lib/super_interaction/views/layouts/modal_bs3.haml +2 -2
- data/lib/super_interaction/views/layouts/modal_bs4.haml +2 -2
- data/lib/super_process/basic.rb +12 -0
- data/lib/super_process/core.rb +26 -25
- data/lib/super_search/scroll.rb +11 -8
- data/lib/super_spreadsheet/loader.rb +14 -14
- data/lib/super_table/action_view.rb +4 -4
- data/lib/super_table/builder.rb +5 -4
- data/lib/super_table/record.rb +1 -1
- data/lib/super_tools/version.rb +2 -2
- data/lib/super_tools.rb +42 -28
- data/lib/super_zipcode/taiwan.rb +131 -102
- data/super_tools.gemspec +17 -23
- metadata +92 -67
- data/lib/super_logger/formatter.rb +0 -15
@@ -3,22 +3,22 @@ module SuperFormatter
|
|
3
3
|
Head = Struct.new(:data) do
|
4
4
|
def indexes
|
5
5
|
@indexes ||= {
|
6
|
-
order_id: data.index(
|
7
|
-
order_created: data.index(
|
8
|
-
shipping_method: data.index(
|
9
|
-
payment_method: data.index(
|
10
|
-
payment_status: data.index(
|
11
|
-
recipient: data.index(
|
12
|
-
mobile: data.index(
|
13
|
-
store_id: data.index(
|
14
|
-
address: data.index(
|
15
|
-
total_order_amount: data.index(
|
16
|
-
note: data.index(
|
17
|
-
item_title: data.index(
|
18
|
-
item_option: data.index(
|
19
|
-
item_code: data.index(
|
20
|
-
item_qty: data.index(
|
21
|
-
item_cost: data.index(
|
6
|
+
order_id: data.index("訂單號碼"),
|
7
|
+
order_created: data.index("訂單日期"),
|
8
|
+
shipping_method: data.index("送貨方式"),
|
9
|
+
payment_method: data.index("付款方式"),
|
10
|
+
payment_status: data.index("付款狀態"),
|
11
|
+
recipient: data.index("收件人"),
|
12
|
+
mobile: data.index("收件人電話號碼"),
|
13
|
+
store_id: data.index("全家服務編號 / 7-11 店號"),
|
14
|
+
address: data.index("完整地址"),
|
15
|
+
total_order_amount: data.index("訂單合計"),
|
16
|
+
note: data.index("送貨備註"),
|
17
|
+
item_title: data.index("商品名稱"),
|
18
|
+
item_option: data.index("選項"),
|
19
|
+
item_code: data.index("商品貨號"),
|
20
|
+
item_qty: data.index("數量"),
|
21
|
+
item_cost: data.index("商品成本")
|
22
22
|
}
|
23
23
|
end
|
24
24
|
end
|
@@ -1,16 +1,15 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "super_formatter/import"
|
2
|
+
require "super_formatter/shopline/head"
|
3
|
+
require "super_formatter/shopline/row"
|
4
|
+
require "super_formatter/shopline/order"
|
5
|
+
|
5
6
|
module SuperFormatter
|
6
7
|
module Shopline
|
7
8
|
class Import < ::SuperFormatter::Import
|
8
9
|
|
9
10
|
callable do
|
10
11
|
build_rows!(Head, Row)
|
11
|
-
|
12
12
|
self.orders = merged_orders!.values
|
13
|
-
|
14
13
|
self.orders
|
15
14
|
end
|
16
15
|
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require
|
1
|
+
require "warehouse"
|
2
|
+
|
2
3
|
module SuperFormatter
|
3
4
|
module Shopline
|
4
5
|
class Order
|
@@ -13,7 +14,7 @@ module SuperFormatter
|
|
13
14
|
delegate :complete?, to: :row
|
14
15
|
|
15
16
|
def order_id
|
16
|
-
row.order_id.gsub("#",
|
17
|
+
row.order_id.gsub("#", "")
|
17
18
|
end
|
18
19
|
|
19
20
|
def initialize(row)
|
@@ -23,13 +24,13 @@ module SuperFormatter
|
|
23
24
|
|
24
25
|
def provider
|
25
26
|
@provider ||= case
|
26
|
-
when row.shipping_method.include?(
|
27
|
+
when row.shipping_method.include?("7-11")
|
27
28
|
:UNIMART
|
28
|
-
when row.shipping_method.include?(
|
29
|
+
when row.shipping_method.include?("全家")
|
29
30
|
:FAMI
|
30
|
-
when row.shipping_method.include?(
|
31
|
+
when row.shipping_method.include?("新竹")
|
31
32
|
:HCT
|
32
|
-
when row.shipping_method.include?(
|
33
|
+
when row.shipping_method.include?("黑貓")
|
33
34
|
:TCAT
|
34
35
|
else
|
35
36
|
nil
|
@@ -58,7 +59,7 @@ module SuperFormatter
|
|
58
59
|
end
|
59
60
|
|
60
61
|
def cash_on_delivery?
|
61
|
-
if row.payment_method.include?(
|
62
|
+
if row.payment_method.include?("取貨付款")
|
62
63
|
true
|
63
64
|
else
|
64
65
|
false
|
@@ -70,7 +71,7 @@ module SuperFormatter
|
|
70
71
|
end
|
71
72
|
|
72
73
|
def paid?
|
73
|
-
row.payment_status ==
|
74
|
+
row.payment_status == "已付款"
|
74
75
|
end
|
75
76
|
|
76
77
|
def items
|
@@ -3,10 +3,10 @@ module SuperFormatter
|
|
3
3
|
Head = Struct.new(:data) do
|
4
4
|
def indexes
|
5
5
|
@indexes ||= {
|
6
|
-
global_order_id: data.index(
|
7
|
-
mobile: data.index(
|
8
|
-
recipient: data.index(
|
9
|
-
tracking_code: data.index(
|
6
|
+
global_order_id: data.index("訂單編號"),
|
7
|
+
mobile: data.index("手機(收)"),
|
8
|
+
recipient: data.index("收件人"),
|
9
|
+
tracking_code: data.index("託運單號")
|
10
10
|
}
|
11
11
|
end
|
12
12
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "super_formatter/import"
|
2
|
+
require "super_formatter/hct/head"
|
3
|
+
require "super_formatter/hct/row"
|
4
|
+
|
4
5
|
module SuperFormatter
|
5
6
|
module Tcat
|
6
7
|
class Import < SuperFormatter::Import
|
7
|
-
|
8
8
|
callable do
|
9
9
|
build_rows!(Head, Row)
|
10
10
|
end
|
@@ -1,16 +1,17 @@
|
|
1
|
-
require
|
1
|
+
require "super_formatter/row"
|
2
|
+
|
2
3
|
module SuperFormatter
|
3
4
|
module Tcat
|
4
5
|
class Row < ::SuperFormatter::Row
|
5
6
|
|
6
7
|
def tracking_code
|
7
|
-
(find(:tracking_code) || "").gsub("'",
|
8
|
+
(find(:tracking_code) || "").gsub("'", "")
|
8
9
|
end
|
9
|
-
|
10
|
+
|
10
11
|
def mobile
|
11
12
|
@mobile ||= begin
|
12
13
|
text = (find(:mobile) || "").gsub("'", "")
|
13
|
-
if text[0] ==
|
14
|
+
if text[0] == "9" && text.length == 9
|
14
15
|
"0#{text}"
|
15
16
|
else
|
16
17
|
text
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module SuperInteraction
|
2
|
+
class Beyond < Struct.new(:context)
|
3
|
+
|
4
|
+
attr_accessor :commands
|
5
|
+
|
6
|
+
delegate :helpers, to: :context
|
7
|
+
|
8
|
+
def run
|
9
|
+
context.render js: (commands || []).join(";"), layout: false
|
10
|
+
end
|
11
|
+
|
12
|
+
def b_notice(message)
|
13
|
+
b_alert('info', message)
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def b_danger(message)
|
18
|
+
b_alert('danger', message)
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
def b_success(message)
|
23
|
+
b_alert('success', message)
|
24
|
+
end
|
25
|
+
|
26
|
+
def alert(message)
|
27
|
+
cmd("alert('#{helpers.j(message)}');")
|
28
|
+
end
|
29
|
+
|
30
|
+
# modal 裡如果有 javascript 需寫在 .modal 層
|
31
|
+
# size: sm / md / lg / xl / xxl
|
32
|
+
# 注意:不要包 respond_to :js 會有問題
|
33
|
+
def modal(partial: nil, size: 'md', title: '', desc: '', classname: '')
|
34
|
+
partial ||= context.action_name
|
35
|
+
locals = { size: size, title: title, desc: desc, classname: classname }
|
36
|
+
modal_html = context.render_to_string(partial, layout: "beyond.haml", locals: locals)
|
37
|
+
cmd("$(function() { $.uniqModal().modal('show', '#{helpers.j(modal_html)}'); });")
|
38
|
+
end
|
39
|
+
|
40
|
+
# 關閉 Modal
|
41
|
+
def close
|
42
|
+
cmd("$.uniqModal().modal('hide');")
|
43
|
+
end
|
44
|
+
|
45
|
+
# 重新讀取頁面
|
46
|
+
def reload
|
47
|
+
cmd("Turbolinks.visit(location.toString());");
|
48
|
+
end
|
49
|
+
|
50
|
+
# 導入頁面
|
51
|
+
def redirect_to(url)
|
52
|
+
cmd("Turbolinks.visit('#{url}');");
|
53
|
+
end
|
54
|
+
|
55
|
+
def modal_saved_rediret_to(message, redirect_url)
|
56
|
+
close.alert(message).redirect_to(redirect_url)
|
57
|
+
end
|
58
|
+
|
59
|
+
def modal_saved_reload(message)
|
60
|
+
close.alert(message).reload
|
61
|
+
end
|
62
|
+
|
63
|
+
def ajax_get(url)
|
64
|
+
cmd("$.get('#{url}');")
|
65
|
+
end
|
66
|
+
|
67
|
+
def b_alert(class_type, text)
|
68
|
+
cmd("if (typeof($.alert) === 'undefined') { alert('#{helpers.j(text)}'); } else { $.alert.#{class_type}('#{helpers.j(text)}'); }")
|
69
|
+
end
|
70
|
+
|
71
|
+
def cmd(js_code)
|
72
|
+
self.commands ||= []
|
73
|
+
self.commands.push(js_code)
|
74
|
+
self
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module SuperInteraction
|
2
|
-
class
|
2
|
+
class Bootstrap < Struct.new(:context)
|
3
3
|
|
4
4
|
attr_accessor :commands
|
5
5
|
|
@@ -32,7 +32,7 @@ module SuperInteraction
|
|
32
32
|
# 注意:不要包 respond_to :js 會有問題
|
33
33
|
def modal(partial: nil, size: 'md', title: '', desc: '')
|
34
34
|
partial ||= context.action_name
|
35
|
-
modal_html = context.render_to_string(partial, layout: ::SuperInteraction::Layout.modal_layout, locals: {
|
35
|
+
modal_html = context.render_to_string(partial, layout: ::SuperInteraction::Layout.modal_layout, locals: { size: size, title: title, desc: desc })
|
36
36
|
cmd("$(function() { $.modal.show('#{helpers.j(modal_html)}'); });")
|
37
37
|
end
|
38
38
|
|
@@ -2,6 +2,12 @@ module SuperInteraction
|
|
2
2
|
if defined?(Rails::Engine)
|
3
3
|
class Engine < Rails::Engine
|
4
4
|
paths["app/views"] = "lib/super_interaction/views"
|
5
|
+
|
6
|
+
# NOTE: 需要確認底下的程式有無作用
|
7
|
+
# lib/super_interaction 底下並沒有 javascripts 目錄
|
8
|
+
initializer 'beyond.assets.precompile' do |app|
|
9
|
+
app.config.assets.paths << root.join('lib', 'super_interaction', 'javascripts').to_s
|
10
|
+
end
|
5
11
|
end
|
6
12
|
end
|
7
13
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
- if Rails.version[0].to_i >= 5
|
2
|
+
- size = local_assigns[:size]
|
3
|
+
- title = local_assigns[:title]
|
4
|
+
- desc = local_assigns[:desc]
|
5
|
+
- classname = local_assigns[:classname]
|
6
|
+
|
7
|
+
.modal{"aria-labelledby" => "modalLabel", "data-modal" => "box-modal", :role => "dialog", :tabindex => "-1"}
|
8
|
+
.modal-dialog{ role: 'document', class: "modal-#{size} #{classname}" }
|
9
|
+
.modal-content
|
10
|
+
.modal-header
|
11
|
+
= yield :header
|
12
|
+
- if title.present?
|
13
|
+
%h4.modal-title
|
14
|
+
= title
|
15
|
+
%small= desc if desc
|
16
|
+
%button.btn-close{'aria-label': 'Close', 'data-close': true, 'type': 'button'}
|
17
|
+
= b_icon('cross')
|
18
|
+
= yield
|
19
|
+
= yield :before_body
|
20
|
+
- body_html = capture { yield :body }
|
21
|
+
- if body_html.present?
|
22
|
+
.modal-body.bg-content= body_html
|
23
|
+
= yield :after_body
|
24
|
+
- footer_html = capture { yield :footer }
|
25
|
+
- if footer_html.present?
|
26
|
+
.modal-footer
|
27
|
+
= footer_html
|
@@ -1,10 +1,10 @@
|
|
1
1
|
- if Rails.version[0].to_i >= 5
|
2
|
-
-
|
2
|
+
- size = local_assigns[:size]
|
3
3
|
- title = local_assigns[:title]
|
4
4
|
- desc = local_assigns[:desc]
|
5
5
|
.modal
|
6
6
|
= yield :wrapper
|
7
|
-
.modal-dialog{ class: "modal-#{
|
7
|
+
.modal-dialog{ class: "modal-#{size}" }
|
8
8
|
.modal-content
|
9
9
|
.modal-header
|
10
10
|
%button.close{"aria-label" => "Close", "data-dismiss" => "modal", :type => "button"}
|
@@ -1,10 +1,10 @@
|
|
1
1
|
- if Rails.version[0].to_i >= 5
|
2
|
-
-
|
2
|
+
- size = local_assigns[:size]
|
3
3
|
- title = local_assigns[:title]
|
4
4
|
- desc = local_assigns[:desc]
|
5
5
|
.modal
|
6
6
|
= yield :wrapper
|
7
|
-
.modal-dialog{ class: "modal-#{
|
7
|
+
.modal-dialog{ class: "modal-#{size}" }
|
8
8
|
.modal-content
|
9
9
|
.modal-header
|
10
10
|
= yield :header
|
data/lib/super_process/core.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require
|
1
|
+
require "virtus"
|
2
|
+
|
2
3
|
module SuperProcess
|
3
4
|
class Core
|
4
5
|
include ActiveModel::Validations
|
@@ -7,30 +8,38 @@ module SuperProcess
|
|
7
8
|
|
8
9
|
ValidError = Class.new(StandardError)
|
9
10
|
|
10
|
-
|
11
|
+
CALLBACK_CALL = :"__super_process__call"
|
12
|
+
CALLBACK_TASK = :"__super_process__task"
|
13
|
+
|
14
|
+
# https://github.com/rails/rails/blob/v6.1.6/activesupport/lib/active_support/callbacks.rb#L97
|
15
|
+
# 這裡透過 define_callbacks define 了 CALLBACK_CALL 與 CALLBACK_TASK
|
16
|
+
# 卻沒有 set_callbacks,所以在 run_callbacks 時
|
17
|
+
# 會因為找不到儲存的 callback 而直接執行 block
|
18
|
+
# 這裡的用法必須注意 rails 內部或是使用此 class 的開發者
|
19
|
+
# 不可以使用 CALLBACK_CALL 與 CALLBACK_TASK 相同命名的 callback
|
20
|
+
# 否則會有不可預期的副作用
|
21
|
+
define_callbacks CALLBACK_CALL, CALLBACK_TASK
|
11
22
|
|
12
23
|
def self.before_call(method_name)
|
13
|
-
set_callback
|
24
|
+
set_callback CALLBACK_CALL, :before, method_name
|
14
25
|
end
|
15
26
|
|
16
27
|
def self.after_call(method_name)
|
17
|
-
set_callback
|
28
|
+
set_callback CALLBACK_CALL, :after, method_name
|
18
29
|
end
|
19
30
|
|
20
31
|
def self.before_task(method_name)
|
21
|
-
set_callback
|
32
|
+
set_callback CALLBACK_TASK, :before, method_name
|
22
33
|
end
|
23
34
|
|
24
35
|
def self.after_task(method_name)
|
25
|
-
set_callback
|
36
|
+
set_callback CALLBACK_TASK, :after, method_name
|
26
37
|
end
|
27
38
|
|
28
|
-
def self.init(model_name
|
39
|
+
def self.init(model_name)
|
29
40
|
attr_accessor model_name
|
30
|
-
|
31
|
-
class_eval(&block) if block_given?
|
32
|
-
|
33
41
|
define_method :initialize do |model|
|
42
|
+
super({})
|
34
43
|
self.send("#{model_name}=", model)
|
35
44
|
end
|
36
45
|
end
|
@@ -40,10 +49,9 @@ module SuperProcess
|
|
40
49
|
params.each do |attr, value|
|
41
50
|
public_send("#{attr}=", value) if respond_to?("#{attr}=")
|
42
51
|
end
|
43
|
-
run_callbacks
|
52
|
+
run_callbacks CALLBACK_CALL do
|
44
53
|
raise ValidError, "Validation Error" if valid? == false
|
45
|
-
|
46
|
-
run_callbacks :task do
|
54
|
+
run_callbacks CALLBACK_TASK do
|
47
55
|
instance_eval(&block)
|
48
56
|
end
|
49
57
|
end
|
@@ -63,20 +71,13 @@ module SuperProcess
|
|
63
71
|
@result
|
64
72
|
end
|
65
73
|
|
66
|
-
def
|
67
|
-
if errors.messages.values.present?
|
68
|
-
errors.messages.values.first.first
|
69
|
-
else
|
70
|
-
""
|
71
|
-
end
|
74
|
+
def error_message
|
75
|
+
errors.messages.values.first.first if errors.messages.values.present?
|
72
76
|
end
|
73
77
|
|
74
|
-
def
|
75
|
-
|
76
|
-
new.public_send(m, *args, &block)
|
77
|
-
else
|
78
|
-
new.public_send(m, *args)
|
79
|
-
end
|
78
|
+
def error_messages
|
79
|
+
errors.messages.values.flatten
|
80
80
|
end
|
81
|
+
|
81
82
|
end
|
82
83
|
end
|
data/lib/super_search/scroll.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
-
|
1
|
+
# NOTE: 這個 class 完全沒有在 landing 或 xdelivery 出現過
|
2
|
+
require "searchkick"
|
3
|
+
|
2
4
|
module SuperSearch
|
3
5
|
class Scroll
|
4
6
|
attr_accessor :expire_time, :size, :query
|
5
7
|
|
6
|
-
# ScrollSearch.new(Member,
|
7
|
-
def initialize(model, term:
|
8
|
-
self.expire_time = options.delete(:scroll) ||
|
8
|
+
# ScrollSearch.new(Member, "*", where: {}, order: {}, scroll: "5m", size: 10000)
|
9
|
+
def initialize(model, term: "*", options: {})
|
10
|
+
self.expire_time = options.delete(:scroll) || "5m"
|
9
11
|
|
10
12
|
# 單次筆數不得超過 10000
|
11
13
|
self.size = options.delete(:size).to_i
|
@@ -48,7 +50,7 @@ module SuperSearch
|
|
48
50
|
# searchkick/query line: 104
|
49
51
|
def handle_response(response)
|
50
52
|
# 從 response 設定 scroll ID
|
51
|
-
@scroll_id = response[
|
53
|
+
@scroll_id = response["_scroll_id"]
|
52
54
|
super
|
53
55
|
end
|
54
56
|
|
@@ -66,9 +68,10 @@ module SuperSearch
|
|
66
68
|
|
67
69
|
# 開始遍歷搜尋
|
68
70
|
def search(&block)
|
69
|
-
while r = query.execute and not r.response[
|
70
|
-
|
71
|
-
end
|
71
|
+
while r = query.execute and not r.response["hits"]["hits"].empty? do
|
72
|
+
block.call(r.results, r.total_count) if block
|
72
73
|
end
|
73
74
|
end
|
75
|
+
|
74
76
|
end
|
77
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
|
1
|
+
require "csv"
|
2
|
+
require "roo"
|
3
|
+
require "roo-xls"
|
4
|
+
|
5
5
|
module SuperSpreadsheet
|
6
6
|
class Loader < SuperProcess::Core
|
7
7
|
attr_accessor :file_path
|
@@ -20,14 +20,14 @@ module SuperSpreadsheet
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def extension
|
23
|
-
::File.extname(file_path).split(
|
23
|
+
::File.extname(file_path).split(".").last.force_encoding("utf-8").downcase
|
24
24
|
end
|
25
25
|
|
26
26
|
def valid_format
|
27
27
|
if rows == false
|
28
|
-
errors.add(:file,
|
28
|
+
errors.add(:file, "檔案格式錯誤")
|
29
29
|
elsif rows.flatten.empty?
|
30
|
-
errors.add(:file,
|
30
|
+
errors.add(:file, "檔案內容錯誤,空白檔案")
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -39,11 +39,11 @@ module SuperSpreadsheet
|
|
39
39
|
|
40
40
|
def rows!
|
41
41
|
case extension
|
42
|
-
when
|
42
|
+
when "xls"
|
43
43
|
::Roo::Excel.new(file_path).map { |row| convert_float_to_integer(row) }
|
44
|
-
when
|
44
|
+
when "xlsx"
|
45
45
|
::Roo::Excelx.new(file_path).map { |row| convert_float_to_integer(row) }
|
46
|
-
when
|
46
|
+
when "csv"
|
47
47
|
::CSV.parse(csv_content!)
|
48
48
|
else
|
49
49
|
false
|
@@ -55,10 +55,10 @@ module SuperSpreadsheet
|
|
55
55
|
def csv_content!
|
56
56
|
@decode_csv_content ||= begin
|
57
57
|
csv_content_big5!
|
58
|
-
rescue
|
58
|
+
rescue
|
59
59
|
begin
|
60
60
|
csv_content_big5_hkscs!
|
61
|
-
rescue
|
61
|
+
rescue
|
62
62
|
csv_content
|
63
63
|
end
|
64
64
|
end
|
@@ -71,11 +71,11 @@ module SuperSpreadsheet
|
|
71
71
|
private
|
72
72
|
|
73
73
|
def csv_content_big5!
|
74
|
-
|
74
|
+
csv_content.encode!(Encoding::UTF_8, Encoding::BIG5)
|
75
75
|
end
|
76
76
|
|
77
77
|
def csv_content_big5_hkscs!
|
78
|
-
|
78
|
+
csv_content.encode!(Encoding::UTF_8, Encoding::BIG5_HKSCS)
|
79
79
|
end
|
80
80
|
|
81
81
|
def convert_float_to_integer(row)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "super_table/builder"
|
2
2
|
|
3
3
|
module SuperTable
|
4
4
|
module ActionView
|
@@ -10,15 +10,15 @@ module SuperTable
|
|
10
10
|
table_responsive = options.delete(:responsive)
|
11
11
|
table_size = options.delete(:size).to_s
|
12
12
|
|
13
|
-
classes = [
|
13
|
+
classes = ["table"]
|
14
14
|
classes << options[:class] if options[:class]
|
15
15
|
classes.push("table-hover") if is_hover && table.collection.present?
|
16
|
-
classes.push("table-sm") if table_size ==
|
16
|
+
classes.push("table-sm") if table_size == "sm"
|
17
17
|
|
18
18
|
options[:class] = classes.join(" ")
|
19
19
|
|
20
20
|
case table_responsive.to_s
|
21
|
-
when
|
21
|
+
when "sm", "md", "lg", "xl"
|
22
22
|
content_tag(:div, class: "table-responsive-#{table_responsive}") do
|
23
23
|
render_table(table, options, &block)
|
24
24
|
end
|
data/lib/super_table/builder.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require
|
1
|
+
require "super_table/view_helpers"
|
2
|
+
|
2
3
|
module SuperTable
|
3
4
|
class Builder
|
4
5
|
include ViewHelpers
|
@@ -16,7 +17,7 @@ module SuperTable
|
|
16
17
|
def heads(*args, &block)
|
17
18
|
options = args.extract_options!
|
18
19
|
|
19
|
-
classes = [
|
20
|
+
classes = ["table-secondary"]
|
20
21
|
classes << options[:class] if options[:class]
|
21
22
|
options[:class] = classes.join(" ")
|
22
23
|
|
@@ -54,7 +55,7 @@ module SuperTable
|
|
54
55
|
|
55
56
|
th(column_options) do
|
56
57
|
concat(title)
|
57
|
-
concat content_tag(:div, desc, class:
|
58
|
+
concat content_tag(:div, desc, class: "small text-primary") if desc
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
@@ -99,7 +100,7 @@ module SuperTable
|
|
99
100
|
def placeholder_row
|
100
101
|
tr do
|
101
102
|
content = table.placeholder || "尚無資料"
|
102
|
-
td(content, colspan: table.columns.length, class:
|
103
|
+
td(content, colspan: table.columns.length, class: "text-center")
|
103
104
|
end
|
104
105
|
end
|
105
106
|
|
data/lib/super_table/record.rb
CHANGED
data/lib/super_tools/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module SuperTools
|
2
|
-
VERSION =
|
3
|
-
end
|
2
|
+
VERSION = "3.0.1"
|
3
|
+
end
|