-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from akpaevj/develop
Develop
- Loading branch information
Showing
9 changed files
with
155 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,86 @@ | ||
class DashboardController < ApplicationController | ||
# frozen_string_literal: true | ||
|
||
class DashboardController < ApplicationController | ||
def index | ||
if request.query_parameters.key?("project_id") | ||
@selected_project_id = request.query_parameters["project_id"] | ||
else | ||
@selected_project_id = -1 | ||
end | ||
|
||
@statuses = getStatuses() | ||
@projects = getProjects() | ||
@issues = getIssues(@selected_project_id) | ||
@use_drop_down_menu = Setting.plugin_dashboard['use_drop_down_menu'] | ||
@selected_project_id = params[:project_id].nil? ? -1 : params[:project_id].to_i | ||
show_sub_tasks = Setting.plugin_dashboard['display_child_projects_tasks'] | ||
@show_project_badge = @selected_project_id == -1 || @selected_project_id != -1 && show_sub_tasks | ||
@display_minimized_closed_issue_cards = Setting.plugin_dashboard['display_closed_statuses'] ? Setting.plugin_dashboard['display_minimized_closed_issue_cards'] : false | ||
@statuses = get_statuses | ||
@projects = get_projects | ||
@issues = get_issues(@selected_project_id, show_sub_tasks) | ||
end | ||
|
||
private | ||
|
||
def getStatuses | ||
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], | ||
:is_closed => item.is_closed | ||
def get_statuses | ||
data = {} | ||
items = Setting.plugin_dashboard['display_closed_statuses'] ? IssueStatus.sorted : IssueStatus.sorted.where('is_closed = false') | ||
items.each do |item| | ||
data[item.id] = { | ||
:name => item.name, | ||
:color => Setting.plugin_dashboard["status_color_" + item.id.to_s], | ||
:is_closed => item.is_closed | ||
} | ||
} | ||
end | ||
data | ||
end | ||
|
||
def getProjects(project_id = -1) | ||
items = [] | ||
|
||
items.push({ | ||
:id => -1, | ||
def get_projects | ||
data = {-1 => { | ||
:name => l(:label_all), | ||
:color => '#4ec7ff' | ||
}) | ||
}} | ||
|
||
Project.visible().where('status = 1').each do |item| | ||
items.push({ | ||
:id => item.id, | ||
Project.visible.each do |item| | ||
data[item.id] = { | ||
:name => item.name, | ||
:color => Setting.plugin_dashboard["project_color_" + item.id.to_s] | ||
}) | ||
} | ||
end | ||
|
||
items | ||
data | ||
end | ||
|
||
def getIssues(project_id = -1) | ||
items = project_id == -1 ? (Issue.visible()) : (Issue.visible().where(:projects => {:id => project_id})) | ||
items.map { |item| { | ||
def get_issues(project_id, with_sub_tasks) | ||
id_array = [] | ||
|
||
if project_id != -1 | ||
id_array.push(project_id) | ||
end | ||
|
||
# fill array of children ids | ||
if project_id != -1 && with_sub_tasks | ||
project = Project.find(project_id) | ||
children = nil | ||
loop do | ||
if project.children.any? | ||
children = project.children.first | ||
id_array.push(children.id) | ||
project = children | ||
else | ||
break | ||
end | ||
end | ||
end | ||
|
||
items = id_array.empty? ? Issue.visible : Issue.visible.where(:projects => {:id => id_array}) | ||
|
||
unless Setting.plugin_dashboard['display_closed_statuses'] | ||
items = items.open | ||
end | ||
|
||
data = items.map do |item| | ||
{ | ||
:id => item.id, | ||
:subject => item.subject, | ||
:status_id => item.status.id, | ||
:project => item.project, | ||
:project_id => item.project.id, | ||
:created_at => item.start_date, | ||
:author => item.author.name(User::USER_FORMATS[:firstname_lastname]), | ||
:executor => item.assigned_to.nil? ? ('') : (item.assigned_to.name()) | ||
:executor => item.assigned_to.nil? ? '' : item.assigned_to.name | ||
} | ||
} | ||
end | ||
data.sort_by { |item| item[:created_at]} | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,34 +5,51 @@ | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css"> | ||
<% end %> | ||
|
||
<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> | ||
<% if @use_drop_down_menu %> | ||
<label class="select_project"> <%=l :field_project %> | ||
<select name="project"> | ||
<% @projects.each do |project_id, project| %> | ||
<% if project_id == @selected_project_id %> | ||
<option selected value="<%= project_id %>"><%= project[:name] %></option> | ||
<% else %> | ||
<option value="<%= project_id %>"><%= project[:name] %></option> | ||
<% end %> | ||
<% end %> | ||
</select> | ||
</label> | ||
<% else %> | ||
<div class="select_project_container"> | ||
<% @projects.each do |project_id, project| %> | ||
<% if project_id == @selected_project_id %> | ||
<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 %> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
<div class="issues_container"> | ||
<% @statuses.each do |status| %> | ||
<div class="status_column" data-id="<%= status[:id] %>"> | ||
<% @statuses.each do |status_id, 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[:is_closed] ? ("status_column_closed_issues") : ("status_column_issues") %>"> | ||
<% @issues.select {|issue| issue[:status_id] == status[:id] }.each do |issue| %> | ||
<% 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] %>)"> | ||
<div class="<%= status[:is_closed] ? "status_column_closed_issues" : "status_column_issues" %>"> | ||
<% @issues.select { |issue| issue[:status_id] == status_id }.each do |issue| %> | ||
<% project_color = @projects[issue[:project_id]][:color] %> | ||
<% project_name = @projects[issue[:project_id]][:name] %> | ||
<% if status[:is_closed] && @display_minimized_closed_issue_cards %> | ||
<div class="minimized_issue_card" style="border-bottom-color: <%= project_color %>" 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" 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> | ||
<% if @show_project_badge %> | ||
<div class="issue_card_header_project" style="background-color: <%= project_color %>"><%= project_name %></div> | ||
<% end %> | ||
</div> | ||
<span class="issue_card_title"> <%= issue[:subject] %> </span> | ||
<span class="issue_card_author"><i class="bi bi-person"></i> <%= issue[:author] %> </span> | ||
|
@@ -51,4 +68,4 @@ | |
|
||
<script> | ||
init(); | ||
</script> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.