File tree Expand file tree Collapse file tree 2 files changed +30
-5
lines changed Expand file tree Collapse file tree 2 files changed +30
-5
lines changed Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
1
3
module RedmineGttPrint
2
4
3
5
# Transforms the given array of issues into JSON ready to be sent to the
@@ -17,10 +19,19 @@ def self.call(*_)
17
19
def call
18
20
hsh = {
19
21
layout : @layout ,
22
+ outputFilename : "DailyList" ,
23
+ outputFormat : "pdf" ,
24
+ custom_text : @other_attributes [ :custom_text ] ,
20
25
attributes : {
21
- issues : @issues . map { |i |
22
- IssueToJson . attributes_hash ( i , @other_attributes )
23
- }
26
+ datasource : [
27
+ {
28
+ table : {
29
+ columns : %w( id status start_date created_on assigned_to_name subject ) ,
30
+ data : @issues . map { |i | issue_to_data_row i }
31
+ }
32
+ }
33
+
34
+ ]
24
35
}
25
36
}
26
37
@@ -36,6 +47,19 @@ def call
36
47
hsh . to_json
37
48
end
38
49
50
+ private
51
+
52
+ def issue_to_data_row ( i )
53
+ [
54
+ i . id ,
55
+ i . status . name ,
56
+ i . start_date ,
57
+ i . created_on ,
58
+ i . assigned_to &.name ,
59
+ i . subject
60
+ ]
61
+ end
62
+
39
63
end
40
64
end
41
65
Original file line number Diff line number Diff line change @@ -24,8 +24,9 @@ class IssuesToJsonTest < ActiveSupport::TestCase
24
24
assert j = RedmineGttPrint ::IssuesToJson . ( @issues , 'das layout' )
25
25
assert h = JSON . parse ( j )
26
26
assert_equal 'das layout' , h [ 'layout' ]
27
- assert_equal @issues [ 0 ] . subject , h [ 'attributes' ] [ 'issues' ] [ 0 ] [ 'subject' ]
28
- assert_equal @issues [ 1 ] . subject , h [ 'attributes' ] [ 'issues' ] [ 1 ] [ 'subject' ]
27
+ assert table = h [ 'attributes' ] [ 'datasource' ] [ 0 ] [ 'table' ] [ 'data' ]
28
+ assert_equal @issues [ 0 ] . subject , table [ 0 ] . last
29
+ assert_equal @issues [ 1 ] . subject , table [ 1 ] . last
29
30
30
31
assert map = h [ 'attributes' ] [ 'map' ]
31
32
assert_equal 2 , map [ 'center' ] . size
You can’t perform that action at this time.
0 commit comments