Skip to content

Commit 52d3a7d

Browse files
authored
Merge pull request #9 from akpaevj/develop
Develop
2 parents fbd3870 + afefd8b commit 52d3a7d

File tree

8 files changed

+139
-52
lines changed

8 files changed

+139
-52
lines changed

app/controllers/dashboard_controller.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ def index
1515
private
1616

1717
def getStatuses
18-
IssueStatus.sorted().where('is_closed = false').map { |item| {
18+
items = Setting.plugin_dashboard['display_closed_statuses'] ? (IssueStatus.sorted()) : (IssueStatus.sorted().where('is_closed = false'))
19+
items.map { |item| {
1920
:id => item.id,
2021
:name => item.name,
21-
:color => Setting.plugin_dashboard["status_color_" + item.id.to_s]
22+
:color => Setting.plugin_dashboard["status_color_" + item.id.to_s],
23+
:is_closed => item.is_closed
2224
}
2325
}
2426
end
@@ -29,7 +31,7 @@ def getProjects(project_id = -1)
2931
items.push({
3032
:id => -1,
3133
:name => l(:label_all),
32-
:color => nil
34+
:color => '#4ec7ff'
3335
})
3436

3537
Project.visible().where('status = 1').each do |item|

app/views/dashboard/index.html.erb

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,44 @@
55
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
66
<% end %>
77

8-
<label class="select_project"> <%=l :field_project %>
9-
<select name="project">
10-
<% @projects.each do |project| %>
11-
<% if project[:id].to_s == @selected_project_id.to_s %>
12-
<option selected value="<%= project[:id] %>"><%= project[:name] %></option>
13-
<% else %>
14-
<option value="<%= project[:id] %>"><%= project[:name] %></option>
8+
<div class="select_project_container">
9+
<% @projects.each do |project| %>
10+
<% if project[:id].to_s == @selected_project_id.to_s %>
11+
<div class="select_project_item select_project_item_selected" style="background-color: <%= project[:color] %>" data-id="<%= project[:id] %>"><%= project[:name] %></div>
12+
<% else %>
13+
<div class="select_project_item" style="background-color: <%= project[:color] %>" data-id="<%= project[:id] %>"><%= project[:name] %></div>
14+
<% end %>
1515
<% end %>
16-
<% end %>
17-
</select>
18-
</label>
16+
</div>
1917

2018
<div class="issues_container">
2119
<% @statuses.each do |status| %>
2220
<div class="status_column" data-id="<%= status[:id] %>">
2321
<div class="status_column_header" style="border-bottom-color: <%= status[:color] %>">
2422
<span> <%= status[:name] %> </span>
2523
</div>
26-
<div class="status_column_issues">
24+
<div class="<% status[:is_closed] ? ("status_column_closed_issues") : ("status_column_issues") %>">
2725
<% @issues.select {|issue| issue[:status_id] == status[:id] }.each do |issue| %>
28-
<div class="issue_card" data-status="<%= status[:id] %>" data-id="<%= issue[:id] %>" onclick="goToIssue(<%= issue[:id] %>)">
29-
<div class="issue_card_header">
30-
<span class="issue_card_header_date"><%= issue[:created_at] %></span>
31-
<div class="issue_card_header_project" style="background-color: <%= @projects.select {|item| item[:id] == issue[:project].id }[0][:color] %>"><%= issue[:project].name %></div>
26+
<% project_color = @projects.select {|item| item[:id] == issue[:project].id }[0][:color] %>
27+
<% if status[:is_closed] && Setting.plugin_dashboard['display_minimized_closed_issue_cards'] %>
28+
<div class="minimized_issue_card" style="border-bottom-color: <%= project_color %>" data-status="<%= status[:id] %>" data-id="<%= issue[:id] %>" onclick="goToIssue(<%= issue[:id] %>)">
29+
<span> <%= "#" + issue[:id].to_s %> </span>
30+
</div>
31+
<% else %>
32+
<div class="issue_card" data-status="<%= status[:id] %>" data-id="<%= issue[:id] %>" onclick="goToIssue(<%= issue[:id] %>)">
33+
<div class="issue_card_header">
34+
<span class="issue_card_header_date"><%= issue[:created_at] %></span>
35+
<div class="issue_card_header_project" style="background-color: <%= project_color %>"><%= issue[:project].name %></div>
36+
</div>
37+
<span class="issue_card_title"> <%= issue[:subject] %> </span>
38+
<span class="issue_card_author"><i class="bi bi-person"></i> <%= issue[:author] %> </span>
39+
<% if issue[:executor] == '' || issue[:executor].nil? %>
40+
<span class="issue_card_executor_not_set"><i class="bi bi-hammer"></i> <%=l :executor_not_set %></span>
41+
<% else %>
42+
<span class="issue_card_executor"><i class="bi bi-hammer"></i> <%= issue[:executor] %> </span>
43+
<% end %>
3244
</div>
33-
<span class="issue_card_title"> <%= issue[:subject] %> </span>
34-
<span class="issue_card_author"><i class="bi bi-person"></i> <%= issue[:author] %> </span>
35-
<% if issue[:executor] == '' || issue[:executor].nil? %>
36-
<span class="issue_card_executor_not_set"><i class="bi bi-hammer"></i> <%=l :executor_not_set %></span>
37-
<% else %>
38-
<span class="issue_card_executor"><i class="bi bi-hammer"></i> <%= issue[:executor] %> </span>
39-
<% end %>
40-
</div>
45+
<% end %>
4146
<% end %>
4247
</div>
4348
</div>

app/views/settings/_dashboard_settings.erb

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
<th colspan="2"> <%=l :settings_header_statuses %> </td>
55
</tr>
66
<% IssueStatus.sorted().each do |status| %>
7-
<% if !status.is_closed %>
8-
<% property_name = "status_color_" + status.id.to_s %>
9-
<tr>
10-
<td> <%= status.name %> </th>
11-
<td>
12-
<input type="color" id="settings_<%= property_name %>" value="<%= settings[property_name] %>" name="settings[<%= property_name %>]">
13-
</td>
14-
</tr>
15-
<% end %>
7+
<% property_name = "status_color_" + status.id.to_s %>
8+
<tr>
9+
<td> <%= status.name %> </th>
10+
<td>
11+
<input type="color" id="settings_<%= property_name %>" value="<%= settings[property_name] %>" name="settings[<%= property_name %>]">
12+
</td>
13+
</tr>
1614
<% end %>
1715
<tr>
1816
<th colspan="2"> <%=l :settings_header_projects %> </td>
@@ -26,5 +24,20 @@
2624
</td>
2725
</tr>
2826
<% end %>
27+
<tr>
28+
<th colspan="2"> <%=l :settings_header_other %> </td>
29+
</tr>
30+
<tr>
31+
<td> <%=l :settings_display_closed_statuses %> </th>
32+
<td>
33+
<%= check_box_tag "settings[display_closed_statuses]", false, @settings['display_closed_statuses'] %>
34+
</td>
35+
</tr>
36+
<tr>
37+
<td> <%=l :settings_display_minimized_closed_issue_cards %> </th>
38+
<td>
39+
<%= check_box_tag "settings[display_minimized_closed_issue_cards]", false, @settings['display_minimized_closed_issue_cards'] %>
40+
</td>
41+
</tr>
2942
</tbody>
3043
</table>

assets/javascripts/script.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function getUriWithoutDashboard() {
2-
const reg = new RegExp('((?<=.+)\/dashboard.*$|\/$)');
3-
let baseUri = location.pathname;
2+
const reg = new RegExp('(\/dashboard.*$|\/$)');
3+
let baseUri = location.href;
44

55
if (baseUri.match(reg)!= null) {
66
baseUri = baseUri.replace(reg, '');
@@ -11,17 +11,21 @@ function getUriWithoutDashboard() {
1111

1212
function goToIssue(id) {
1313
const baseUri = getUriWithoutDashboard();
14-
location.pathname = `${baseUri}/issues/${id}`;
14+
location.href = `${baseUri}/issues/${id}`;
1515
}
1616

1717
function init() {
1818
document.querySelector('#main-menu').remove();
1919

20-
document.querySelector('[name=project]').addEventListener('change', function(e) {
21-
if (this.value == "-1") {
22-
location.search = "";
23-
} else {
24-
location.search = `project_id=${this.value}`;
25-
}
20+
document.querySelectorAll('.select_project_item').forEach(item => {
21+
item.addEventListener('click', function() {
22+
if (this.dataset.id == "-1") {
23+
location.search = "";
24+
} else {
25+
location.search = `project_id=${this.dataset.id}`;
26+
}
27+
})
2628
});
29+
30+
document.querySelector("#content").style.overflow = "hidden";
2731
}

assets/stylesheets/style.css

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,58 @@
3535
flex-direction: column;
3636
border-bottom-left-radius: 5px;
3737
border-bottom-right-radius: 5px;
38-
align-items: center;
38+
}
39+
40+
.status_column_closed_issues {
41+
display: flex;
42+
width: 100%;
43+
height: 100%;
44+
flex-direction: row;
45+
flex-wrap: wrap;
46+
border-bottom-left-radius: 5px;
47+
border-bottom-right-radius: 5px;
3948
}
4049

4150
.issue_card {
4251
display: flex;
43-
width: 96%;
52+
width: 100%;
4453
border-radius: 5px;
4554
height: auto;
4655
min-height: 50px;
4756
margin-top: 5px;
4857
padding-top: 5px;
4958
padding-bottom: 5px;
5059
background-color: rgb(240, 240, 240);
60+
align-self: center;
5161
margin-bottom: 5px;
5262
align-items: flex-start;
5363
flex-direction: column;
5464
justify-content: center;
5565
box-shadow: 0px 0px 2px 0px lightgray;
5666
}
5767

68+
.minimized_issue_card {
69+
display: inline-flex;
70+
width: min-content;
71+
align-items: center;
72+
justify-content: center;
73+
margin-top: 5px;
74+
margin-bottom: 5px;
75+
height: auto;
76+
border-radius: 5px;
77+
border-bottom: 2px solid;
78+
background-color: rgb(240, 240, 240);
79+
}
80+
81+
.minimized_issue_card span {
82+
padding: 5px;
83+
}
84+
85+
.minimized_issue_card:hover {
86+
background-color: rgb(220, 220, 220);
87+
cursor: pointer;
88+
}
89+
5890
.issue_card:hover {
5991
background-color: rgb(220, 220, 220);
6092
cursor: pointer;
@@ -95,10 +127,6 @@
95127
font-size: medium;
96128
}
97129

98-
.select_project {
99-
margin-left: 10px;
100-
}
101-
102130
.issue_card_header {
103131
display: flex;
104132
padding-top: 5px;
@@ -110,9 +138,40 @@
110138
margin-left: auto;
111139
padding-top: 5px;
112140
padding-bottom: 5px;
141+
padding-left: 10px;
142+
padding-right: 10px;
143+
margin-right: 10px;
144+
border-radius: 15px;
145+
color: rgb(255, 255, 255);
146+
font-size: smaller;
147+
}
148+
149+
.select_project_container {
150+
display: flex;
151+
flex-direction: row;
152+
margin-left: 10px;
153+
}
154+
155+
.select_project_item {
156+
display: inline-flex;
157+
padding-top: 5px;
158+
padding-bottom: 5px;
113159
padding-left: 8px;
114160
padding-right: 8px;
115-
margin-right: 10px;
116161
border-radius: 15px;
162+
margin-right: 10px;
117163
color: white;
164+
opacity: 0.5;
165+
min-width: 50px;
166+
align-items: center;
167+
justify-content: center;
168+
}
169+
170+
.select_project_item:hover {
171+
opacity: 1;
172+
cursor: pointer;
173+
}
174+
175+
.select_project_item_selected {
176+
opacity: 1;
118177
}

config/locales/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ en:
33
settings_header_statuses: "Statuses colors"
44
settings_header_projects: "Projects colors"
55
settings_header_other: "Other"
6+
settings_display_closed_statuses: 'Display "closed" statuses'
7+
settings_display_minimized_closed_issue_cards: 'Display minimized "closed" issue cards'
68
settings_enable_drag_and_drop: 'Enable "drag and drop" status changing'
79
executor_not_set: "Not set"
810
label_all: "All"

config/locales/ru.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ ru:
33
settings_header_statuses: "Цвета статусов"
44
settings_header_projects: "Цвета проектов"
55
settings_header_other: "Разное"
6+
settings_display_closed_statuses: 'Отображать "закрытые" статусы'
7+
settings_display_minimized_closed_issue_cards: 'Отображать свернутые карточки "закрытых" задач'
68
settings_enable_drag_and_drop: 'Включить "drag and drop" изменение статуса'
79
executor_not_set: "Не установлен"
810
label_all: "Все"

init.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name 'Dashboard'
33
author "Akpaev E.A."
44
description "Plugin adds an issues dashboard to the application"
5-
version '1.0.5'
5+
version '1.0.6'
66
url 'https://github.com/akpaevj/Dashboard'
77
author_url 'https://github.com/akpaevj'
88
menu :top_menu, :dashboard, { controller: 'dashboard', action: 'index' }, caption: :top_menu_item_title, first: true

0 commit comments

Comments
 (0)