-
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 #3 from akpaevj/feature-select-project
Added project select field
- Loading branch information
Showing
7 changed files
with
97 additions
and
29 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,32 +1,72 @@ | ||
class DashboardController < ApplicationController | ||
|
||
def index | ||
issues = [] | ||
for issue in Issue.visible() do | ||
executor = "" | ||
if !issue.assigned_to.nil? | ||
executor = issue.assigned_to.name() | ||
end | ||
|
||
issues.push({ | ||
"id" => issue.id, | ||
"subject" => issue.subject, | ||
"status_id" => issue.status.id, | ||
"author" => issue.author.name(User::USER_FORMATS[:firstname_lastname]), | ||
"executor" => executor | ||
}) | ||
if request.query_parameters.key?("project_id") | ||
@selected_project_id = request.query_parameters["project_id"] | ||
else | ||
@selected_project_id = -1 | ||
end | ||
|
||
@statuses = [] | ||
for status in IssueStatus.sorted() do | ||
if !status.is_closed | ||
@statuses.push({ | ||
"id" => status.id, | ||
"name" => status.name, | ||
"color" => Setting.plugin_dashboard["status_color_" + status.id.to_s], | ||
"issues" => issues.select {|i| i["status_id"] == status.id } | ||
}) | ||
end | ||
@statuses = getData(@selected_project_id) | ||
@projects = getProjects(@selected_project_id) | ||
end | ||
end | ||
|
||
private | ||
|
||
def getProjects(selected_project_id = -1) | ||
projects = [] | ||
projects.push({ | ||
"id" => -1, | ||
"name" => l(:label_all) | ||
}) | ||
|
||
for project in Project.visible() do | ||
selected = "" | ||
if selected_project_id.to_s == project.id.to_s | ||
selected = "selected" | ||
end | ||
|
||
projects.push({ | ||
"id" => project.id, | ||
"name" => project.name, | ||
"selected" => selected | ||
}) | ||
end | ||
return projects | ||
end | ||
|
||
def getData(project_id = -1) | ||
issues = [] | ||
for issue in Issue.visible() do | ||
if project_id != -1 && issue.project_id.to_s != project_id.to_s | ||
next | ||
end | ||
|
||
executor = "" | ||
if !issue.assigned_to.nil? | ||
executor = issue.assigned_to.name() | ||
end | ||
|
||
issues.push({ | ||
"id" => issue.id, | ||
"subject" => issue.subject, | ||
"status_id" => issue.status.id, | ||
"author" => issue.author.name(User::USER_FORMATS[:firstname_lastname]), | ||
"executor" => executor | ||
}) | ||
end | ||
|
||
statuses = [] | ||
for status in IssueStatus.sorted() do | ||
if !status.is_closed | ||
statuses.push({ | ||
"id" => status.id, | ||
"name" => status.name, | ||
"color" => Setting.plugin_dashboard["status_color_" + status.id.to_s], | ||
"issues" => issues.select {|i| i["status_id"] == status.id } | ||
}) | ||
end | ||
end | ||
return statuses | ||
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 |
---|---|---|
|
@@ -4,6 +4,14 @@ | |
<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| %> | ||
<option <%= project["selected"] %> value="<%= project['id'] %>"><%= project["name"] %></option> | ||
<% end %> | ||
</select> | ||
</label> | ||
|
||
<div class="issues_container"> | ||
<% @statuses.each do |status| %> | ||
<div class="status_column" data-id="<%= status['id'] %>"> | ||
|
@@ -25,4 +33,8 @@ | |
</div> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
init(); | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,4 +93,8 @@ | |
.issue_card .issue_card_executor i { | ||
color: purple; | ||
font-size: medium; | ||
} | ||
|
||
.select_project { | ||
margin-left: 10px; | ||
} |
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,4 +1,5 @@ | ||
en: | ||
top_menu_item_title: "Dashboard" | ||
settings_header: "Colors of the status column header" | ||
executor_not_set: "Not set" | ||
executor_not_set: "Not set" | ||
label_all: "All" |
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,4 +1,5 @@ | ||
ru: | ||
top_menu_item_title: "Панель задач" | ||
settings_header: "Цвета заголовков колонок статусов" | ||
executor_not_set: "Не установлен" | ||
executor_not_set: "Не установлен" | ||
label_all: "Все" |
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