add issue page
|
1 |
<% |
2 |
# API |
|
3 |
my $api = gitprep_api; |
|
4 | ||
5 |
# Parameters |
|
6 |
my $user_id = param('user'); |
|
7 |
my $project_id = param('project'); |
|
8 |
|
|
add issues page
|
9 |
my $is = param('is') // ''; |
add issue page
|
10 |
|
add issues page
|
11 |
my $open = $is eq 'closed' ? 0 : 1; |
12 |
|
|
13 |
# Git |
|
14 |
my $git = $self->app->git; |
|
15 |
|
|
fix issue count bugs
|
16 |
# Project row id |
17 |
my $project_row_id = $api->get_project_row_id($user_id, $project_id); |
|
18 |
|
|
add issues page
|
19 |
# Issues(which don't have pull request) |
20 |
my $issues = app->dbi->model('issue')->select( |
|
21 |
[ |
|
22 |
{__MY__ => '*'}, |
|
23 |
{open_user => ['id']}, |
|
24 |
], |
|
25 |
where => [ |
|
fix issue count bugs
|
26 |
['and', ':issue.open{=}', 'pull_request = 0', ':project{=}'], |
27 |
{'issue.open' => $open, project => $project_row_id} |
|
add issues page
|
28 |
] |
29 |
)->all; |
|
30 |
|
|
31 |
# Open count |
|
add open issue count to head...
|
32 |
my $open_count = $api->get_open_issue_count($user_id, $project_id); |
add issues page
|
33 |
|
34 |
# Close count |
|
add open issue count to head...
|
35 |
my $close_count = $api->get_close_issue_count($user_id, $project_id); |
add label initialize logic
|
36 |
|
37 |
# Initialize labels if there are no labels |
|
fix issue page bug
|
38 |
my $labels_count = app->dbi->model('label')->select( |
39 |
'count(*)', |
|
40 |
where => {project => $project_row_id} |
|
41 |
)->value; |
|
add label initialize logic
|
42 |
if ($labels_count == 0) { |
43 |
my @labels = ( |
|
44 |
{id => 'bug', color => '#fc2929'}, |
|
45 |
{id => 'duplicate', color => '#cccccc'}, |
|
46 |
{id => 'enhancement', color => '#84b6eb'}, |
|
47 |
{id => 'invalid', color => '#e6e6e6'}, |
|
48 |
{id => 'question', color => '#cc317c'}, |
|
49 |
{id => 'wontfix', color => '#ffffff'} |
|
50 |
); |
|
51 |
for my $label (@labels) { |
|
52 |
my $project_row_id = app->dbi->model('project')->select( |
|
53 |
'project.row_id', |
|
54 |
where => {'user.id' => $user_id, 'project.id' => $project_id} |
|
55 |
)->value; |
|
56 |
$label->{project} = $project_row_id; |
|
57 |
app->dbi->model('label')->insert($label); |
|
58 |
} |
|
59 |
} |
|
add issue page
|
60 | |
support markdown table
|
61 |
layout 'common', title => "Issues - $user_id/$project_id"; |
62 |
%> |
|
add issue page
|
63 |
|
64 |
%= include '/include/header'; |
|
65 |
|
|
66 |
<div class="container"> |
|
add labels page
|
67 |
<div class="issues-button-container"> |
68 |
<div class="issues-button-container-left"> |
|
69 |
<div class="issues-labels"><a href="<%= url_for("/$user_id/$project_id/labels") %>">Labels</a></div> |
|
70 |
</div> |
|
71 |
<div class="issues-button-container-right"> |
|
add labels to issues
|
72 |
% if ($api->logined) { |
improve button design
|
73 |
<a href="<%= url_for("/$user_id/$project_id/issues/new") %>" class="btn btn-green btn-new">New issue</a> |
add labels to issues
|
74 |
% } |
add labels page
|
75 |
</div> |
add issues page
|
76 |
</div> |
add labels page
|
77 |
<div class="issues"> |
78 |
<div class="issues-header"> |
|
add issues page
|
79 |
% if ($open) { |
80 |
<b><%= $open_count %> Open</b> |
|
81 |
<a href="<%= url_with->query([is => 'closed']) %>" style="margin-left:5px;color:#767676"><%= "\x{2714}" %><%= $close_count %> Closed</a> |
|
82 |
% } else { |
|
83 |
<a style="margin-left:5px;color:#767676" href="<%= url_with->query([is => undef]) %>"><%= $open_count %> Open</a> |
|
84 |
<b> |
|
85 |
<span style="margin-left:5px;color:#767676"><%= "\x{2714}" %><%= $close_count %> Closed</span> |
|
86 |
</b> |
|
87 |
% } |
|
88 |
</div> |
|
add labels page
|
89 |
<div class="issues-body"> |
add issues page
|
90 |
% if (@$issues) { |
91 |
<ul> |
|
92 |
% for my $issue (@$issues) { |
|
add labels to issues
|
93 |
<% |
94 |
my $issue_labels = app->dbi->model('issue_label')->select( |
|
95 |
{label => ['id', 'color']}, |
|
96 |
where => {issue => $issue->{row_id}} |
|
97 |
)->all; |
|
98 |
%> |
|
99 | ||
add issues page
|
100 |
<% |
101 |
my $open_time = $issue->{open_time}; |
|
102 |
my $open_time_age = Time::Moment->now->epoch - $open_time; |
|
103 |
my $open_time_age_string = $self->app->git->_age_string($open_time_age); |
|
104 |
%> |
|
105 |
<li> |
|
add labels page
|
106 |
<div class="issues-title"> |
fix issues link bugs
|
107 |
<a href="<%= url_for("/$user_id/$project_id/issues/$issue->{number}") %>"> |
add issues page
|
108 |
<b><%= $issue->{title} %></b> |
109 |
</a> |
|
add labels to issues
|
110 |
<ul class="issues-label-pallet"> |
111 |
% for my $issue_label (@$issue_labels) { |
|
112 |
<li style="background:<%= $issue_label->{'label.color'} %>"> |
|
113 |
<%= $issue_label->{'label.id'} %> |
|
114 |
</li> |
|
115 |
% } |
|
116 |
</ul> |
|
add issues page
|
117 |
</div> |
add labels page
|
118 |
<div class="issues-description"> |
add issues page
|
119 |
#<%= $issue->{number} %> <%= $issue->{open} ? 'opened' : 'closed' %> |
120 |
<%= $open_time_age_string %> |
|
121 |
by <%= $issue->{'open_user.id'} %> |
|
122 |
</div> |
|
123 |
</li> |
|
124 |
% } |
|
125 |
</ul> |
|
126 |
% } else { |
|
add labels page
|
127 |
<div class="issues-no-request"> |
add issues page
|
128 |
<div style="font-size:18px"><b>There aren’t any issues.</b></div> |
129 |
</div> |
|
130 |
% } |
|
131 |
</div> |
|
132 |
</div> |
|
add issue page
|
133 |
</div> |
134 |
|
|
135 |
%= include '/include/footer'; |