Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tallty_import_export
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
tallty_import_export
Commits
d92af47e
Commit
d92af47e
authored
Nov 18, 2020
by
liyijie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add common concern with model_headers default
parent
83431f12
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
1 deletion
+25
-1
tallty_import_export.rb
lib/tallty_import_export.rb
+1
-0
common.rb
lib/tallty_import_export/common.rb
+21
-0
exportable.rb
lib/tallty_import_export/exportable.rb
+3
-1
No files found.
lib/tallty_import_export.rb
View file @
d92af47e
...
@@ -4,6 +4,7 @@ require 'axlsx'
...
@@ -4,6 +4,7 @@ require 'axlsx'
module
TalltyImportExport
module
TalltyImportExport
class
Error
<
StandardError
;
end
class
Error
<
StandardError
;
end
autoload
:Common
,
'tallty_import_export/common'
autoload
:Exportable
,
'tallty_import_export/exportable'
autoload
:Exportable
,
'tallty_import_export/exportable'
autoload
:Importable
,
'tallty_import_export/importable'
autoload
:Importable
,
'tallty_import_export/importable'
end
end
lib/tallty_import_export/common.rb
0 → 100644
View file @
d92af47e
module
TalltyImportExport
module
Common
extend
ActiveSupport
::
Concern
included
do
end
module
ClassMethods
def
model_headers
columns
.
map
do
|
column
|
{
key:
column
.
name
,
name:
column
.
comment
||
column
.
name
,
attr_type:
column
.
type
,
format:
column
.
type
==
:string
?
:
string
:
nil
,
}
end
end
end
end
end
lib/tallty_import_export/exportable.rb
View file @
d92af47e
...
@@ -2,6 +2,8 @@ module TalltyImportExport
...
@@ -2,6 +2,8 @@ module TalltyImportExport
module
Exportable
module
Exportable
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
include
Common
# export_headers / headers
# export_headers / headers
# key: 属性的英文名
# key: 属性的英文名
# name: 属性的中文名
# name: 属性的中文名
...
@@ -56,7 +58,7 @@ module TalltyImportExport
...
@@ -56,7 +58,7 @@ module TalltyImportExport
@row_height
||=
options
.
delete
(
:row_height
)
||
35
@row_height
||=
options
.
delete
(
:row_height
)
||
35
@width
||=
options
.
delete
(
:width
)
||
30
@width
||=
options
.
delete
(
:width
)
||
30
@filename
||=
options
.
delete
(
:filename
)
@filename
||=
options
.
delete
(
:filename
)
@headers
=
self
.
respond_to?
(
:export_headers
)
?
export_headers
:
headers
@headers
=
self
.
try
(
:export_headers
)
||
self
.
try
(
:headers
)
||
self
.
try
(
:model_headers
)
@headers
.
map!
{
|
header
|
header
.
with_indifferent_access
}
@headers
.
map!
{
|
header
|
header
.
with_indifferent_access
}
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment