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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4e679f4b41ffa1f04baee132e45b854efa2317e03b6300d747968f858caab6a6
|
4
|
+
data.tar.gz: 4e635e119e9dfd2bcf058be7db40418e0874eaef755b3892048ec7c54bda3011
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32a411a0cd5e85fb222c5d1224e6e67b22fabdc2a3918ff757a4f816ff3c1e705ac79d8d83f753eb6256852f9286e6c7debb20a260e598bdb6ec5719dc5020be
|
7
|
+
data.tar.gz: d7c222e501cd6d8877cadaf6b2524428b5c478d02f61572fc6ec063a0d5243db1b36fee4181050e4dd68628c44447023af68995616b497dca71d35cd72241f84
|
@@ -0,0 +1,21 @@
|
|
1
|
+
name: Test
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- 'fix-**'
|
6
|
+
- 'feat-**'
|
7
|
+
- develop
|
8
|
+
- master
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
test:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v3
|
15
|
+
with:
|
16
|
+
fetch-depth: 1
|
17
|
+
- uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
bundler-cache: true
|
20
|
+
- run: bundle
|
21
|
+
- run: bundle exec rake t
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.0.4
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,18 +1,26 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/superlanding/reform-rails
|
3
|
+
revision: 66240539260e6969dc01a77cf181b39109ebb941
|
4
|
+
branch: fix-infinite-parent-loop
|
5
|
+
specs:
|
6
|
+
reform-rails (0.2.2)
|
7
|
+
activemodel (>= 5.0)
|
8
|
+
reform (>= 2.3.1, < 3.0.0)
|
9
|
+
|
1
10
|
PATH
|
2
11
|
remote: .
|
3
12
|
specs:
|
4
|
-
super_tools (0.0
|
5
|
-
dry-logic (
|
6
|
-
dry-types (
|
13
|
+
super_tools (3.0.0)
|
14
|
+
dry-logic (= 1.2.0)
|
15
|
+
dry-types (= 1.5.1)
|
7
16
|
fast_excel
|
8
17
|
forwardable
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
reform (~> 2.2.4)
|
18
|
+
nokogiri (>= 1.6)
|
19
|
+
rails (> 6, < 7)
|
20
|
+
reform (= 2.6.2)
|
13
21
|
reform-rails
|
14
22
|
roo
|
15
|
-
roo-xls
|
23
|
+
roo-xls (= 1.2.0)
|
16
24
|
searchkick
|
17
25
|
spreadsheet
|
18
26
|
virtus (~> 1.0.5)
|
@@ -21,194 +29,191 @@ PATH
|
|
21
29
|
GEM
|
22
30
|
remote: https://rubygems.org/
|
23
31
|
specs:
|
24
|
-
actioncable (
|
25
|
-
actionpack (=
|
32
|
+
actioncable (6.1.6)
|
33
|
+
actionpack (= 6.1.6)
|
34
|
+
activesupport (= 6.1.6)
|
26
35
|
nio4r (~> 2.0)
|
27
36
|
websocket-driver (>= 0.6.1)
|
28
|
-
|
29
|
-
actionpack (=
|
30
|
-
|
31
|
-
|
37
|
+
actionmailbox (6.1.6)
|
38
|
+
actionpack (= 6.1.6)
|
39
|
+
activejob (= 6.1.6)
|
40
|
+
activerecord (= 6.1.6)
|
41
|
+
activestorage (= 6.1.6)
|
42
|
+
activesupport (= 6.1.6)
|
43
|
+
mail (>= 2.7.1)
|
44
|
+
actionmailer (6.1.6)
|
45
|
+
actionpack (= 6.1.6)
|
46
|
+
actionview (= 6.1.6)
|
47
|
+
activejob (= 6.1.6)
|
48
|
+
activesupport (= 6.1.6)
|
32
49
|
mail (~> 2.5, >= 2.5.4)
|
33
50
|
rails-dom-testing (~> 2.0)
|
34
|
-
actionpack (
|
35
|
-
actionview (=
|
36
|
-
activesupport (=
|
37
|
-
rack (~> 2.0)
|
51
|
+
actionpack (6.1.6)
|
52
|
+
actionview (= 6.1.6)
|
53
|
+
activesupport (= 6.1.6)
|
54
|
+
rack (~> 2.0, >= 2.0.9)
|
38
55
|
rack-test (>= 0.6.3)
|
39
56
|
rails-dom-testing (~> 2.0)
|
40
|
-
rails-html-sanitizer (~> 1.0, >= 1.0
|
41
|
-
|
42
|
-
|
57
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
58
|
+
actiontext (6.1.6)
|
59
|
+
actionpack (= 6.1.6)
|
60
|
+
activerecord (= 6.1.6)
|
61
|
+
activestorage (= 6.1.6)
|
62
|
+
activesupport (= 6.1.6)
|
63
|
+
nokogiri (>= 1.8.5)
|
64
|
+
actionview (6.1.6)
|
65
|
+
activesupport (= 6.1.6)
|
43
66
|
builder (~> 3.1)
|
44
67
|
erubi (~> 1.4)
|
45
68
|
rails-dom-testing (~> 2.0)
|
46
|
-
rails-html-sanitizer (~> 1.
|
47
|
-
activejob (
|
48
|
-
activesupport (=
|
69
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
70
|
+
activejob (6.1.6)
|
71
|
+
activesupport (= 6.1.6)
|
49
72
|
globalid (>= 0.3.6)
|
50
|
-
activemodel (
|
51
|
-
activesupport (=
|
52
|
-
activerecord (
|
53
|
-
activemodel (=
|
54
|
-
activesupport (=
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
activerecord (=
|
59
|
-
|
60
|
-
|
73
|
+
activemodel (6.1.6)
|
74
|
+
activesupport (= 6.1.6)
|
75
|
+
activerecord (6.1.6)
|
76
|
+
activemodel (= 6.1.6)
|
77
|
+
activesupport (= 6.1.6)
|
78
|
+
activestorage (6.1.6)
|
79
|
+
actionpack (= 6.1.6)
|
80
|
+
activejob (= 6.1.6)
|
81
|
+
activerecord (= 6.1.6)
|
82
|
+
activesupport (= 6.1.6)
|
83
|
+
marcel (~> 1.0)
|
84
|
+
mini_mime (>= 1.1.0)
|
85
|
+
activesupport (6.1.6)
|
61
86
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
62
|
-
i18n (>=
|
63
|
-
minitest (
|
64
|
-
tzinfo (~>
|
65
|
-
|
87
|
+
i18n (>= 1.6, < 2)
|
88
|
+
minitest (>= 5.1)
|
89
|
+
tzinfo (~> 2.0)
|
90
|
+
zeitwerk (~> 2.3)
|
66
91
|
axiom-types (0.1.1)
|
67
92
|
descendants_tracker (~> 0.0.4)
|
68
93
|
ice_nine (~> 0.11.0)
|
69
94
|
thread_safe (~> 0.3, >= 0.3.1)
|
70
|
-
builder (3.2.
|
95
|
+
builder (3.2.4)
|
71
96
|
coercible (1.0.0)
|
72
97
|
descendants_tracker (~> 0.0.1)
|
73
|
-
concurrent-ruby (1.1.
|
74
|
-
crass (1.0.
|
75
|
-
declarative (0.0.
|
76
|
-
declarative-builder (0.1.0)
|
77
|
-
declarative-option (< 0.2.0)
|
78
|
-
declarative-option (0.1.0)
|
98
|
+
concurrent-ruby (1.1.10)
|
99
|
+
crass (1.0.6)
|
100
|
+
declarative (0.0.20)
|
79
101
|
descendants_tracker (0.0.4)
|
80
102
|
thread_safe (~> 0.3, >= 0.3.1)
|
81
|
-
disposable (0.
|
103
|
+
disposable (0.6.3)
|
82
104
|
declarative (>= 0.0.9, < 1.0.0)
|
83
|
-
|
84
|
-
|
85
|
-
representable (>= 2.4.0, <= 3.1.0)
|
86
|
-
uber (< 0.2.0)
|
87
|
-
dry-configurable (0.7.0)
|
105
|
+
representable (>= 3.1.1, < 4)
|
106
|
+
dry-configurable (0.15.0)
|
88
107
|
concurrent-ruby (~> 1.0)
|
89
|
-
|
108
|
+
dry-core (~> 0.6)
|
109
|
+
dry-container (0.9.0)
|
90
110
|
concurrent-ruby (~> 1.0)
|
91
|
-
dry-configurable (~> 0.
|
92
|
-
dry-core (0.
|
111
|
+
dry-configurable (~> 0.13, >= 0.13.0)
|
112
|
+
dry-core (0.7.1)
|
93
113
|
concurrent-ruby (~> 1.0)
|
94
|
-
dry-
|
95
|
-
dry-
|
96
|
-
|
97
|
-
dry-
|
98
|
-
|
99
|
-
dry-equalizer (~> 0.2)
|
100
|
-
dry-types (0.13.4)
|
114
|
+
dry-inflector (0.2.1)
|
115
|
+
dry-logic (1.2.0)
|
116
|
+
concurrent-ruby (~> 1.0)
|
117
|
+
dry-core (~> 0.5, >= 0.5)
|
118
|
+
dry-types (1.5.1)
|
101
119
|
concurrent-ruby (~> 1.0)
|
102
120
|
dry-container (~> 0.3)
|
103
|
-
dry-core (~> 0.
|
104
|
-
dry-equalizer (~> 0.2)
|
121
|
+
dry-core (~> 0.5, >= 0.5)
|
105
122
|
dry-inflector (~> 0.1, >= 0.1.2)
|
106
|
-
dry-logic (~> 0
|
107
|
-
elasticsearch (7.0.0)
|
108
|
-
elasticsearch-api (= 7.0.0)
|
109
|
-
elasticsearch-transport (= 7.0.0)
|
110
|
-
elasticsearch-api (7.0.0)
|
111
|
-
multi_json
|
112
|
-
elasticsearch-transport (7.0.0)
|
113
|
-
faraday
|
114
|
-
multi_json
|
123
|
+
dry-logic (~> 1.0, >= 1.0.2)
|
115
124
|
equalizer (0.0.11)
|
116
|
-
erubi (1.
|
117
|
-
|
118
|
-
multipart-post (>= 1.2, < 3)
|
119
|
-
fast_excel (0.2.6)
|
125
|
+
erubi (1.10.0)
|
126
|
+
fast_excel (0.4.0)
|
120
127
|
ffi (> 1.9, < 2)
|
121
|
-
ffi (1.
|
122
|
-
forwardable (1.2
|
123
|
-
globalid (0.
|
124
|
-
activesupport (>=
|
125
|
-
hashie (
|
126
|
-
i18n (1.
|
128
|
+
ffi (1.15.5)
|
129
|
+
forwardable (1.3.2)
|
130
|
+
globalid (1.0.0)
|
131
|
+
activesupport (>= 5.0)
|
132
|
+
hashie (5.0.0)
|
133
|
+
i18n (1.10.0)
|
127
134
|
concurrent-ruby (~> 1.0)
|
128
135
|
ice_nine (0.11.2)
|
129
|
-
|
130
|
-
loofah (2.2.3)
|
136
|
+
loofah (2.18.0)
|
131
137
|
crass (~> 1.0.2)
|
132
138
|
nokogiri (>= 1.5.9)
|
133
139
|
mail (2.7.1)
|
134
140
|
mini_mime (>= 0.1.1)
|
135
|
-
marcel (0.
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
actionview (=
|
155
|
-
activejob (=
|
156
|
-
activemodel (=
|
157
|
-
activerecord (=
|
158
|
-
activestorage (=
|
159
|
-
activesupport (=
|
160
|
-
bundler (>= 1.
|
161
|
-
railties (=
|
141
|
+
marcel (1.0.2)
|
142
|
+
method_source (1.0.0)
|
143
|
+
mini_mime (1.1.2)
|
144
|
+
minitest (5.16.2)
|
145
|
+
nio4r (2.5.8)
|
146
|
+
nokogiri (1.13.6-arm64-darwin)
|
147
|
+
racc (~> 1.4)
|
148
|
+
nokogiri (1.13.6-x86_64-linux)
|
149
|
+
racc (~> 1.4)
|
150
|
+
racc (1.6.0)
|
151
|
+
rack (2.2.4)
|
152
|
+
rack-test (2.0.2)
|
153
|
+
rack (>= 1.3)
|
154
|
+
rails (6.1.6)
|
155
|
+
actioncable (= 6.1.6)
|
156
|
+
actionmailbox (= 6.1.6)
|
157
|
+
actionmailer (= 6.1.6)
|
158
|
+
actionpack (= 6.1.6)
|
159
|
+
actiontext (= 6.1.6)
|
160
|
+
actionview (= 6.1.6)
|
161
|
+
activejob (= 6.1.6)
|
162
|
+
activemodel (= 6.1.6)
|
163
|
+
activerecord (= 6.1.6)
|
164
|
+
activestorage (= 6.1.6)
|
165
|
+
activesupport (= 6.1.6)
|
166
|
+
bundler (>= 1.15.0)
|
167
|
+
railties (= 6.1.6)
|
162
168
|
sprockets-rails (>= 2.0.0)
|
163
169
|
rails-dom-testing (2.0.3)
|
164
170
|
activesupport (>= 4.2.0)
|
165
171
|
nokogiri (>= 1.6)
|
166
|
-
rails-html-sanitizer (1.
|
167
|
-
loofah (~> 2.
|
168
|
-
railties (
|
169
|
-
actionpack (=
|
170
|
-
activesupport (=
|
172
|
+
rails-html-sanitizer (1.4.3)
|
173
|
+
loofah (~> 2.3)
|
174
|
+
railties (6.1.6)
|
175
|
+
actionpack (= 6.1.6)
|
176
|
+
activesupport (= 6.1.6)
|
171
177
|
method_source
|
172
|
-
rake (>=
|
173
|
-
thor (
|
174
|
-
rake (
|
175
|
-
reform (2.2
|
176
|
-
disposable (>= 0.
|
177
|
-
representable (>=
|
178
|
-
|
179
|
-
|
180
|
-
reform (>= 2.2.0)
|
181
|
-
representable (3.0.4)
|
178
|
+
rake (>= 12.2)
|
179
|
+
thor (~> 1.0)
|
180
|
+
rake (13.0.6)
|
181
|
+
reform (2.6.2)
|
182
|
+
disposable (>= 0.5.0, < 1.0.0)
|
183
|
+
representable (>= 3.1.1, < 4)
|
184
|
+
uber (< 0.2.0)
|
185
|
+
representable (3.2.0)
|
182
186
|
declarative (< 0.1.0)
|
183
|
-
|
187
|
+
trailblazer-option (>= 0.1.1, < 0.2.0)
|
184
188
|
uber (< 0.2.0)
|
185
|
-
roo (2.
|
189
|
+
roo (2.9.0)
|
186
190
|
nokogiri (~> 1)
|
187
|
-
rubyzip (
|
191
|
+
rubyzip (>= 1.3.0, < 3.0.0)
|
188
192
|
roo-xls (1.2.0)
|
189
193
|
nokogiri
|
190
194
|
roo (>= 2.0.0, < 3)
|
191
195
|
spreadsheet (> 0.9.0)
|
192
196
|
ruby-ole (1.2.12.2)
|
193
|
-
rubyzip (
|
194
|
-
searchkick (
|
195
|
-
activemodel (>=
|
196
|
-
elasticsearch (>= 5)
|
197
|
+
rubyzip (2.3.2)
|
198
|
+
searchkick (5.0.4)
|
199
|
+
activemodel (>= 5.2)
|
197
200
|
hashie
|
198
|
-
shoulda-context (
|
199
|
-
spreadsheet (1.
|
200
|
-
ruby-ole
|
201
|
-
sprockets (
|
201
|
+
shoulda-context (2.0.0)
|
202
|
+
spreadsheet (1.3.0)
|
203
|
+
ruby-ole
|
204
|
+
sprockets (4.1.1)
|
202
205
|
concurrent-ruby (~> 1.0)
|
203
206
|
rack (> 1, < 3)
|
204
|
-
sprockets-rails (3.2
|
205
|
-
actionpack (>=
|
206
|
-
activesupport (>=
|
207
|
+
sprockets-rails (3.4.2)
|
208
|
+
actionpack (>= 5.2)
|
209
|
+
activesupport (>= 5.2)
|
207
210
|
sprockets (>= 3.0.0)
|
208
|
-
|
211
|
+
sqlite3 (1.4.4)
|
212
|
+
thor (1.2.1)
|
209
213
|
thread_safe (0.3.6)
|
210
|
-
|
211
|
-
|
214
|
+
trailblazer-option (0.1.2)
|
215
|
+
tzinfo (2.0.4)
|
216
|
+
concurrent-ruby (~> 1.0)
|
212
217
|
uber (0.1.0)
|
213
218
|
virtus (1.0.5)
|
214
219
|
axiom-types (~> 0.1)
|
@@ -217,19 +222,25 @@ GEM
|
|
217
222
|
equalizer (~> 0.0, >= 0.0.9)
|
218
223
|
warehouse_items (0.3.0)
|
219
224
|
activesupport
|
220
|
-
|
225
|
+
warning (1.2.1)
|
226
|
+
websocket-driver (0.7.5)
|
221
227
|
websocket-extensions (>= 0.1.0)
|
222
|
-
websocket-extensions (0.1.
|
228
|
+
websocket-extensions (0.1.5)
|
229
|
+
zeitwerk (2.6.0)
|
223
230
|
|
224
231
|
PLATFORMS
|
225
|
-
|
232
|
+
arm64-darwin-21
|
233
|
+
x86_64-linux
|
226
234
|
|
227
235
|
DEPENDENCIES
|
228
|
-
bundler (
|
236
|
+
bundler (>= 2, < 3)
|
229
237
|
minitest (~> 5.0)
|
230
|
-
rake (
|
238
|
+
rake (>= 12.2)
|
239
|
+
reform-rails!
|
231
240
|
shoulda-context
|
241
|
+
sqlite3 (= 1.4.4)
|
232
242
|
super_tools!
|
243
|
+
warning
|
233
244
|
|
234
245
|
BUNDLED WITH
|
235
|
-
|
246
|
+
2.3.16
|
data/README.md
CHANGED
@@ -84,7 +84,8 @@ SuperTable::Tableable.send(:include, ::Rails.application.routes.url_helpers)
|
|
84
84
|
|
85
85
|
```ruby
|
86
86
|
class ApplicationController < ActionController::Base
|
87
|
-
include SuperInteraction::
|
87
|
+
include SuperInteraction::BootstrapHelper
|
88
|
+
include SuperInteraction::BeyondrHelper
|
88
89
|
end
|
89
90
|
```
|
90
91
|
|
data/dependabot.yml
ADDED
data/lib/super_form/basic.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require
|
1
|
+
require "virtus"
|
2
|
+
|
2
3
|
module SuperForm
|
3
4
|
class Basic
|
4
5
|
include ActiveModel::Model
|
@@ -7,12 +8,6 @@ module SuperForm
|
|
7
8
|
include ActiveModel::Validations
|
8
9
|
include Virtus.model
|
9
10
|
|
10
|
-
def sync_params(params)
|
11
|
-
params.each do |attr, value|
|
12
|
-
public_send("#{attr}=", value) if respond_to?("#{attr}=")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
11
|
class << self
|
17
12
|
def form_name(name)
|
18
13
|
# 定義 form name (給 form 用的)
|
@@ -60,17 +60,17 @@ module SuperForm
|
|
60
60
|
# 1. do validate data
|
61
61
|
run_callbacks :validations do
|
62
62
|
if validate(params) == false
|
63
|
-
raise ReformAtomicSaveError, "Not Validate => #{self.errors.full_messages
|
63
|
+
raise ReformAtomicSaveError, "Not Validate => #{self.errors.full_messages}"
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
# 2. sync to model
|
68
68
|
sync
|
69
69
|
|
70
|
-
#
|
70
|
+
# 3. define how to store data in block
|
71
71
|
yield if block_given?
|
72
72
|
|
73
|
-
#
|
73
|
+
# 4. save all data
|
74
74
|
save!
|
75
75
|
end
|
76
76
|
end
|
data/lib/super_form/reform.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "super_form/concerns/atomic_save"
|
2
|
+
require "reform"
|
3
|
+
require "reform/rails"
|
4
|
+
require "reform/form"
|
5
|
+
require "reform/active_record"
|
5
6
|
require "reform/form/coercion"
|
6
|
-
require
|
7
|
-
require
|
7
|
+
require "disposable"
|
8
|
+
require "disposable/twin/parent"
|
8
9
|
|
9
10
|
class SuperForm::Reform < Reform::Form
|
10
11
|
include SuperForm::AtomicSave
|
@@ -25,6 +26,27 @@ class SuperForm::Reform < Reform::Form
|
|
25
26
|
define_singleton_method :model_name do
|
26
27
|
active_model_name_for(name.to_s.camelize) # Reform::Form::ActiveModel
|
27
28
|
end
|
29
|
+
# NOTE: 這行很可能沒有作用
|
28
30
|
model(name)
|
29
31
|
end
|
30
32
|
end
|
33
|
+
|
34
|
+
# Hack Dry::Type 升級 0.15 以後
|
35
|
+
# 變成強制型別,會造成 params input 空字串時的錯誤
|
36
|
+
# 這裡是 hack
|
37
|
+
# https://github.com/apotonick/disposable/blob/master/lib/disposable/twin/coercion.rb
|
38
|
+
# https://github.com/dry-rb/dry-types/blob/a4983c88299b6f323a769f783cf956629e61f8ed/lib/dry/types/coercions/params.rb#L86
|
39
|
+
|
40
|
+
Dry::Types::Coercions::Params.module_eval do
|
41
|
+
def self.to_int(input, &block)
|
42
|
+
if input.is_a? String
|
43
|
+
Integer(input, 10)
|
44
|
+
else
|
45
|
+
Integer(input)
|
46
|
+
end
|
47
|
+
rescue ArgumentError, TypeError => e
|
48
|
+
return input.to_i if input.respond_to?(:to_i)
|
49
|
+
|
50
|
+
CoercionError.handle(e, &block)
|
51
|
+
end
|
52
|
+
end
|
@@ -3,11 +3,11 @@ module SuperFormatter
|
|
3
3
|
Head = Struct.new(:data) do
|
4
4
|
def indexes
|
5
5
|
@indexes ||= {
|
6
|
-
global_order_id: data.index(
|
7
|
-
recipient: data.index(
|
8
|
-
tracking_code: data.index(
|
6
|
+
global_order_id: data.index("客戶單號"),
|
7
|
+
recipient: data.index("收件人"),
|
8
|
+
tracking_code: data.index("宅配單號")
|
9
9
|
}
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
13
|
-
end
|
13
|
+
end
|
@@ -1,6 +1,7 @@
|
|
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 Ecan
|
6
7
|
class Import < SuperFormatter::Import
|
@@ -1,11 +1,12 @@
|
|
1
|
-
require
|
1
|
+
require "super_formatter/row"
|
2
|
+
|
2
3
|
module SuperFormatter
|
3
4
|
module Ecan
|
4
5
|
class Row < ::SuperFormatter::Row
|
5
6
|
|
6
7
|
def global_order_id
|
7
8
|
order_id = (find(:global_order_id) || "")
|
8
|
-
if order_id[0] ==
|
9
|
+
if order_id[0] == "C"
|
9
10
|
order_id[1, order_id.length - 1]
|
10
11
|
else
|
11
12
|
order_id
|
@@ -3,12 +3,12 @@ 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("訂單號碼") || data.index("清單編號"),
|
7
|
+
mobile: data.index("收貨人電話") || data.index("收貨人電話1"),
|
8
|
+
recipient: data.index("收貨人") || data.index("收貨人名稱"),
|
9
|
+
tracking_code: data.index("查貨號碼") || data.index("十碼貨號")
|
10
10
|
}
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
14
|
-
end
|
14
|
+
end
|
@@ -1,6 +1,7 @@
|
|
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 Hct
|
6
7
|
class Import < ::SuperFormatter::Import
|
@@ -1,16 +1,17 @@
|
|
1
|
-
require
|
1
|
+
require "super_formatter/row"
|
2
|
+
|
2
3
|
module SuperFormatter
|
3
4
|
module Hct
|
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
|