Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
redmine_v2
Overview
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
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
VeNtura
redmine_v2
Commits
e8a1223a
Commit
e8a1223a
authored
Nov 07, 2023
by
Tấn Trần Thanh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
case for button download csv
parent
3f67f34d
Pipeline
#1567
failed with stages
in 0 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
29 deletions
+51
-29
plugins/workflow_report/app/views/workflow_report/_table_workflow_report.html.slim
+3
-4
plugins/workflow_report/app/views/workflow_report/index.html.slim
+1
-1
plugins/workflow_report/assets/javascripts/application.js
+26
-19
plugins/workflow_report/assets/stylesheets/style.css
+21
-5
No files found.
plugins/workflow_report/app/views/workflow_report/_table_workflow_report.html.slim
View file @
e8a1223a
-
if
result
[
0
].
size
>
0
-
if
result
.
present?
table
[
border
=
"1"
]
tr
.header_table--visible
th
.green
[
colspan
=
"8"
]
Task
information
...
...
@@ -7,7 +7,7 @@
th
.gray
[
colspan
=
"7"
]
Actual
time
detail
th
.yellow
[
colspan
=
"4"
]
Bugs
th
.pink
[
colspan
=
"8"
]
Github
tr
.header_table--visible
tr
.header_table--visible
.none_colspan
-
thead
.
each_with_index
do
|
head
,
index
|
-
if
(
0
..
7
).
include?
(
index
)
th
.green
=
head
...
...
@@ -31,4 +31,4 @@
-
else
td
=
result
[
i
][
index
]
-
else
h1
There
is
no
data
for
the
'workflow
report'
table
.
\ No newline at end of file
h1
.text-center
There
is
no
data
for
the
'workflow
report'
table
.
plugins/workflow_report/app/views/workflow_report/index.html.slim
View file @
e8a1223a
...
...
@@ -9,5 +9,5 @@ fieldset.box.tabular
=
select_tag
:year
,
options_for_select
((
Time
.
now
.
year
-
5
)
..
(
Time
.
now
.
year
+
1
),
Time
.
now
.
year
),{
prompt:
"Select year"
}
=
select_tag
:team
,
options_for_select
(
@team_options
),
{
prompt:
"Select team"
}
=
submit_tag
'export'
,
id:
'export'
button
.export-button
Download
.CSV
button
.export-button
.d-none
Download
.CSV
#data_workflow
plugins/workflow_report/assets/javascripts/application.js
View file @
e8a1223a
...
...
@@ -14,6 +14,11 @@ window.addEventListener('load', function () {
data
:
{
month
:
month
,
year
:
year
,
team
:
team
},
success
:
function
(
response
)
{
$
(
'#data_workflow'
).
html
(
response
)
if
(
$
(
'#data_workflow'
).
has
(
'table'
).
length
>
0
&&
$
(
'button.export-button'
).
hasClass
(
"d-none"
))
{
$
(
'button.export-button'
).
removeClass
(
'd-none'
)
}
else
{
$
(
'button.export-button'
).
addClass
(
'd-none'
)
}
},
error
:
function
(
error
)
{
console
.
log
(
error
)
...
...
@@ -24,33 +29,35 @@ window.addEventListener('load', function () {
})
const
download
=
function
(
data
)
{
const
blob
=
new
Blob
([
data
],
{
type
:
'text/csv'
})
;
const
blob
=
new
Blob
([
data
],
{
type
:
'text/csv'
})
const
url
=
window
.
URL
.
createObjectURL
(
blob
)
const
a
=
document
.
createElement
(
'a'
)
a
.
setAttribute
(
'href'
,
url
)
a
.
setAttribute
(
'download'
,
"download.csv"
);
a
.
click
()
const
aTag
=
document
.
createElement
(
'a'
)
const
fileName
=
$
(
'#year'
).
val
()
+
$
(
'#month'
).
val
()
+
$
(
'#team'
).
val
()
aTag
.
setAttribute
(
'href'
,
url
)
aTag
.
setAttribute
(
'download'
,
`
${
$
(
'#year'
).
val
()}
-
${
$
(
'#month'
).
val
()}
-
${
$
(
'#team'
).
val
()}
.csv`
)
aTag
.
click
()
}
$
(
".export-button"
).
on
(
"click"
,
function
()
{
exportToCSV
();
});
function
exportToCSV
()
{
const
table
=
$
(
"table"
)
;
const
rows
=
table
.
find
(
"tr"
)
;
let
csv
=
[]
;
const
table
=
$
(
"table"
)
const
rows
=
table
.
find
(
"tr"
)
let
csv
=
[]
rows
.
each
(
function
(
index
)
{
const
cols
=
$
(
this
).
find
(
"td, th"
)
;
let
rowText
=
[]
;
let
currentColspan
=
1
;
const
cols
=
$
(
this
).
find
(
"td, th"
)
let
rowText
=
[]
let
currentColspan
=
1
cols
.
each
(
function
()
{
const
text_report
=
$
(
this
).
text
()
;
const
text_report
=
$
(
this
).
text
()
if
(
$
(
this
).
attr
(
"colspan"
))
{
currentColspan
=
parseInt
(
$
(
this
).
attr
(
"colspan"
),
10
)
;
currentColspan
=
parseInt
(
$
(
this
).
attr
(
"colspan"
),
10
)
}
if
(
currentColspan
>
1
)
{
...
...
@@ -58,14 +65,14 @@ window.addEventListener('load', function () {
i
===
0
?
rowText
.
push
(
text_report
)
:
rowText
.
push
(
''
)
}
}
else
{
text_report
.
includes
(
','
)
?
rowText
.
push
(
`"
${
text_report
}
"`
)
:
rowText
.
push
(
text_report
)
;
text_report
.
includes
(
','
)
?
rowText
.
push
(
`"
${
text_report
}
"`
)
:
rowText
.
push
(
text_report
)
}
currentColspan
=
Math
.
max
(
1
,
currentColspan
-
1
)
;
currentColspan
=
Math
.
max
(
1
,
currentColspan
-
1
)
});
csv
.
push
(
rowText
.
join
(
","
))
;
csv
.
push
(
rowText
.
join
(
","
))
});
const
csvContent
=
csv
.
join
(
"
\
n"
)
;
download
(
csvContent
)
;
const
csvContent
=
csv
.
join
(
"
\
n"
)
download
(
csvContent
)
}
})
;
})
plugins/workflow_report/assets/stylesheets/style.css
View file @
e8a1223a
...
...
@@ -11,16 +11,21 @@ table {
.header_table--visible
{
position
:
sticky
;
top
:
0
;
top
:
-1px
;
z-index
:
2
;
}
.none_colspan
{
top
:
29px
;
}
.sidebar_visible
{
position
:
sticky
;
background
:
#dacbcb
;
left
:
0
;
z-index
:
1
;
}
.green
{
background-color
:
#92ce92
;
}
...
...
@@ -49,6 +54,18 @@ table {
background-color
:
pink
;
}
#date_from
,
#date_to
,
#team
,
#export
{
margin-right
:
24px
;
}
\ No newline at end of file
#year
,
#month
,
#team
,
#export
{
margin
:
8px
24px
0
0
;
}
button
.export-button
{
margin-bottom
:
35px
;
}
.d-none
{
display
:
none
;
}
.text-center
{
text-align
:
center
;
}
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