Skip to content

Commit

Permalink
Merge pull request #9 from akpaevj/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
akpaevj authored May 19, 2021
2 parents fbd3870 + afefd8b commit 52d3a7d
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 52 deletions.
8 changes: 5 additions & 3 deletions app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ def index
private

def getStatuses
IssueStatus.sorted().where('is_closed = false').map { |item| {
items = Setting.plugin_dashboard['display_closed_statuses'] ? (IssueStatus.sorted()) : (IssueStatus.sorted().where('is_closed = false'))
items.map { |item| {
:id => item.id,
:name => item.name,
:color => Setting.plugin_dashboard["status_color_" + item.id.to_s]
:color => Setting.plugin_dashboard["status_color_" + item.id.to_s],
:is_closed => item.is_closed
}
}
end
Expand All @@ -29,7 +31,7 @@ def getProjects(project_id = -1)
items.push({
:id => -1,
:name => l(:label_all),
:color => nil
:color => '#4ec7ff'
})

Project.visible().where('status = 1').each do |item|
Expand Down
51 changes: 28 additions & 23 deletions app/views/dashboard/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,44 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<% end %>

<label class="select_project"> <%=l :field_project %>
<select name="project">
<% @projects.each do |project| %>
<% if project[:id].to_s == @selected_project_id.to_s %>
<option selected value="<%= project[:id] %>"><%= project[:name] %></option>
<% else %>
<option value="<%= project[:id] %>"><%= project[:name] %></option>
<div class="select_project_container">
<% @projects.each do |project| %>
<% if project[:id].to_s == @selected_project_id.to_s %>
<div class="select_project_item select_project_item_selected" style="background-color: <%= project[:color] %>" data-id="<%= project[:id] %>"><%= project[:name] %></div>
<% else %>
<div class="select_project_item" style="background-color: <%= project[:color] %>" data-id="<%= project[:id] %>"><%= project[:name] %></div>
<% end %>
<% end %>
<% end %>
</select>
</label>
</div>

<div class="issues_container">
<% @statuses.each do |status| %>
<div class="status_column" data-id="<%= status[:id] %>">
<div class="status_column_header" style="border-bottom-color: <%= status[:color] %>">
<span> <%= status[:name] %> </span>
</div>
<div class="status_column_issues">
<div class="<% status[:is_closed] ? ("status_column_closed_issues") : ("status_column_issues") %>">
<% @issues.select {|issue| issue[:status_id] == status[:id] }.each do |issue| %>
<div class="issue_card" data-status="<%= status[:id] %>" data-id="<%= issue[:id] %>" onclick="goToIssue(<%= issue[:id] %>)">
<div class="issue_card_header">
<span class="issue_card_header_date"><%= issue[:created_at] %></span>
<div class="issue_card_header_project" style="background-color: <%= @projects.select {|item| item[:id] == issue[:project].id }[0][:color] %>"><%= issue[:project].name %></div>
<% project_color = @projects.select {|item| item[:id] == issue[:project].id }[0][:color] %>
<% if status[:is_closed] && Setting.plugin_dashboard['display_minimized_closed_issue_cards'] %>
<div class="minimized_issue_card" style="border-bottom-color: <%= project_color %>" data-status="<%= status[:id] %>" data-id="<%= issue[:id] %>" onclick="goToIssue(<%= issue[:id] %>)">
<span> <%= "#" + issue[:id].to_s %> </span>
</div>
<% else %>
<div class="issue_card" data-status="<%= status[:id] %>" data-id="<%= issue[:id] %>" onclick="goToIssue(<%= issue[:id] %>)">
<div class="issue_card_header">
<span class="issue_card_header_date"><%= issue[:created_at] %></span>
<div class="issue_card_header_project" style="background-color: <%= project_color %>"><%= issue[:project].name %></div>
</div>
<span class="issue_card_title"> <%= issue[:subject] %> </span>
<span class="issue_card_author"><i class="bi bi-person"></i> <%= issue[:author] %> </span>
<% if issue[:executor] == '' || issue[:executor].nil? %>
<span class="issue_card_executor_not_set"><i class="bi bi-hammer"></i> <%=l :executor_not_set %></span>
<% else %>
<span class="issue_card_executor"><i class="bi bi-hammer"></i> <%= issue[:executor] %> </span>
<% end %>
</div>
<span class="issue_card_title"> <%= issue[:subject] %> </span>
<span class="issue_card_author"><i class="bi bi-person"></i> <%= issue[:author] %> </span>
<% if issue[:executor] == '' || issue[:executor].nil? %>
<span class="issue_card_executor_not_set"><i class="bi bi-hammer"></i> <%=l :executor_not_set %></span>
<% else %>
<span class="issue_card_executor"><i class="bi bi-hammer"></i> <%= issue[:executor] %> </span>
<% end %>
</div>
<% end %>
<% end %>
</div>
</div>
Expand Down
31 changes: 22 additions & 9 deletions app/views/settings/_dashboard_settings.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
<th colspan="2"> <%=l :settings_header_statuses %> </td>
</tr>
<% IssueStatus.sorted().each do |status| %>
<% if !status.is_closed %>
<% property_name = "status_color_" + status.id.to_s %>
<tr>
<td> <%= status.name %> </th>
<td>
<input type="color" id="settings_<%= property_name %>" value="<%= settings[property_name] %>" name="settings[<%= property_name %>]">
</td>
</tr>
<% end %>
<% property_name = "status_color_" + status.id.to_s %>
<tr>
<td> <%= status.name %> </th>
<td>
<input type="color" id="settings_<%= property_name %>" value="<%= settings[property_name] %>" name="settings[<%= property_name %>]">
</td>
</tr>
<% end %>
<tr>
<th colspan="2"> <%=l :settings_header_projects %> </td>
Expand All @@ -26,5 +24,20 @@
</td>
</tr>
<% end %>
<tr>
<th colspan="2"> <%=l :settings_header_other %> </td>
</tr>
<tr>
<td> <%=l :settings_display_closed_statuses %> </th>
<td>
<%= check_box_tag "settings[display_closed_statuses]", false, @settings['display_closed_statuses'] %>
</td>
</tr>
<tr>
<td> <%=l :settings_display_minimized_closed_issue_cards %> </th>
<td>
<%= check_box_tag "settings[display_minimized_closed_issue_cards]", false, @settings['display_minimized_closed_issue_cards'] %>
</td>
</tr>
</tbody>
</table>
22 changes: 13 additions & 9 deletions assets/javascripts/script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function getUriWithoutDashboard() {
const reg = new RegExp('((?<=.+)\/dashboard.*$|\/$)');
let baseUri = location.pathname;
const reg = new RegExp('(\/dashboard.*$|\/$)');
let baseUri = location.href;

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

function goToIssue(id) {
const baseUri = getUriWithoutDashboard();
location.pathname = `${baseUri}/issues/${id}`;
location.href = `${baseUri}/issues/${id}`;
}

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

document.querySelector('[name=project]').addEventListener('change', function(e) {
if (this.value == "-1") {
location.search = "";
} else {
location.search = `project_id=${this.value}`;
}
document.querySelectorAll('.select_project_item').forEach(item => {
item.addEventListener('click', function() {
if (this.dataset.id == "-1") {
location.search = "";
} else {
location.search = `project_id=${this.dataset.id}`;
}
})
});

document.querySelector("#content").style.overflow = "hidden";
}
73 changes: 66 additions & 7 deletions assets/stylesheets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,58 @@
flex-direction: column;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
align-items: center;
}

.status_column_closed_issues {
display: flex;
width: 100%;
height: 100%;
flex-direction: row;
flex-wrap: wrap;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}

.issue_card {
display: flex;
width: 96%;
width: 100%;
border-radius: 5px;
height: auto;
min-height: 50px;
margin-top: 5px;
padding-top: 5px;
padding-bottom: 5px;
background-color: rgb(240, 240, 240);
align-self: center;
margin-bottom: 5px;
align-items: flex-start;
flex-direction: column;
justify-content: center;
box-shadow: 0px 0px 2px 0px lightgray;
}

.minimized_issue_card {
display: inline-flex;
width: min-content;
align-items: center;
justify-content: center;
margin-top: 5px;
margin-bottom: 5px;
height: auto;
border-radius: 5px;
border-bottom: 2px solid;
background-color: rgb(240, 240, 240);
}

.minimized_issue_card span {
padding: 5px;
}

.minimized_issue_card:hover {
background-color: rgb(220, 220, 220);
cursor: pointer;
}

.issue_card:hover {
background-color: rgb(220, 220, 220);
cursor: pointer;
Expand Down Expand Up @@ -95,10 +127,6 @@
font-size: medium;
}

.select_project {
margin-left: 10px;
}

.issue_card_header {
display: flex;
padding-top: 5px;
Expand All @@ -110,9 +138,40 @@
margin-left: auto;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 10px;
padding-right: 10px;
margin-right: 10px;
border-radius: 15px;
color: rgb(255, 255, 255);
font-size: smaller;
}

.select_project_container {
display: flex;
flex-direction: row;
margin-left: 10px;
}

.select_project_item {
display: inline-flex;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 8px;
padding-right: 8px;
margin-right: 10px;
border-radius: 15px;
margin-right: 10px;
color: white;
opacity: 0.5;
min-width: 50px;
align-items: center;
justify-content: center;
}

.select_project_item:hover {
opacity: 1;
cursor: pointer;
}

.select_project_item_selected {
opacity: 1;
}
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ en:
settings_header_statuses: "Statuses colors"
settings_header_projects: "Projects colors"
settings_header_other: "Other"
settings_display_closed_statuses: 'Display "closed" statuses'
settings_display_minimized_closed_issue_cards: 'Display minimized "closed" issue cards'
settings_enable_drag_and_drop: 'Enable "drag and drop" status changing'
executor_not_set: "Not set"
label_all: "All"
2 changes: 2 additions & 0 deletions config/locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ ru:
settings_header_statuses: "Цвета статусов"
settings_header_projects: "Цвета проектов"
settings_header_other: "Разное"
settings_display_closed_statuses: 'Отображать "закрытые" статусы'
settings_display_minimized_closed_issue_cards: 'Отображать свернутые карточки "закрытых" задач'
settings_enable_drag_and_drop: 'Включить "drag and drop" изменение статуса'
executor_not_set: "Не установлен"
label_all: "Все"
2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name 'Dashboard'
author "Akpaev E.A."
description "Plugin adds an issues dashboard to the application"
version '1.0.5'
version '1.0.6'
url 'https://github.com/akpaevj/Dashboard'
author_url 'https://github.com/akpaevj'
menu :top_menu, :dashboard, { controller: 'dashboard', action: 'index' }, caption: :top_menu_item_title, first: true
Expand Down

0 comments on commit 52d3a7d

Please sign in to comment.