Skip to content

Commit

Permalink
Spent hours can now be displayed on cards. #40
Browse files Browse the repository at this point in the history
  • Loading branch information
happy-se-life committed Sep 3, 2022
1 parent d3aaa7c commit e055176
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 57 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This plugin provides the Kanban board.

## What's new
* Spent hours can now be displayed on cards. #40
* Added tracker to issue filters. #39
* Show parent task in issues cards. (See screenshot)

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/kanban_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def initialize_params
end

# Card size (default)
if @card_size.nil? || (@card_size != "normal_days_left" && @card_size != "normal_estimated_hours" && @card_size != "small") then
if @card_size.nil? || (@card_size != "normal_days_left" && @card_size != "normal_estimated_hours" && @card_size != "normal_spent_hours" && @card_size != "small") then
@card_size = Constants::DEFAULT_CARD_SIZE
end

Expand Down
21 changes: 21 additions & 0 deletions app/views/kanban/_normal_card_days_left.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div id="issue-<%= issue.id %>" class="hascontextmenu created-by-me context-menu-selection
<!-- Card color by priority -->
<% if issue.priority_id >= Constants::DEFAULT_HIGH_PRIORITY_ISSUE_ID then %> my-issue-card-high-priority <% elsif issue.priority_id == Constants::DEFAULT_NORMAL_PRIORITY_ISSUE_ID %> my-issue-card <% else %> my-issue-card-low-priority <% end %>">
<div style="float: right; font-size: smaller"><%= issue.project.name %></div>
<p><input type="checkbox" name="ids[]" value="<%= issue.id %>"> <%= issue.tracker.name %> #<%= issue.id %></p>
<% if @show_ancestors == "1" then %>
<%= render_issue_ancestors(issue) %>
<% end %>
<p><a href="./issues/<%= issue.id %>"><%= issue.subject %></a></p>
<hr>
<!-- Days to due_date -->
<% if issue.due_date != nil and issue.done_ratio < 100 then %>
<% diff = issue.due_date - Date.today %>
<% if diff.to_i == 0 then %><div style="float: right; font-size: smaller"><%= I18n.t(:kanban_label_today) %></div><% end %>
<% if diff.to_i == 1 then %><div style="float: right; font-size: smaller"><%= I18n.t(:kanban_label_tommorow) %></div><% end %>
<% if diff.to_i >= 2 then %><div style="float: right; font-size: smaller"><%= I18n.t(:kanban_label_days_left, :value => diff.to_i) %></div><% end %>
<% if diff.to_i < 0 then %><div style="float: right; font-size: smaller"><%= I18n.t(:kanban_label_overdue) %></div><% end %>
<% end %>
<!-- User name -->
<p id="user_name_issue-<%= issue.id %>"><% if issue.assigned_to != nil %><%= issue.assigned_to.name %><% else %>Not assigned<% end %></p>
</div>
15 changes: 15 additions & 0 deletions app/views/kanban/_normal_card_estimated_hours.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div id="issue-<%= issue.id %>" class="hascontextmenu created-by-me context-menu-selection
<!-- Card color by priority -->
<% if issue.priority_id >= Constants::DEFAULT_HIGH_PRIORITY_ISSUE_ID then %> my-issue-card-high-priority <% elsif issue.priority_id == Constants::DEFAULT_NORMAL_PRIORITY_ISSUE_ID %> my-issue-card <% else %> my-issue-card-low-priority <% end %>">
<div style="float: right; font-size: smaller"><%= issue.project.name %></div>
<p><input type="checkbox" name="ids[]" value="<%= issue.id %>"> <%= issue.tracker.name %> #<%= issue.id %></p>
<% if @show_ancestors == "1" then %>
<%= render_issue_ancestors(issue) %>
<% end %>
<p><a href="./issues/<%= issue.id %>"><%= issue.subject %></a></p>
<hr>
<!-- Estimated Hours -->
<div style="float: right; font-size: smaller"><%= (issue.estimated_hours || 0.0) %><%= I18n.t(:kanban_hours_abbreviation) %></div>
<!-- User name -->
<p id="user_name_issue-<%= issue.id %>"><% if issue.assigned_to != nil %><%= issue.assigned_to.name %><% else %>Not assigned<% end %></p>
</div>
15 changes: 15 additions & 0 deletions app/views/kanban/_normal_card_spent_hours.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div id="issue-<%= issue.id %>" class="hascontextmenu created-by-me context-menu-selection
<!-- Card color by priority -->
<% if issue.priority_id >= Constants::DEFAULT_HIGH_PRIORITY_ISSUE_ID then %> my-issue-card-high-priority <% elsif issue.priority_id == Constants::DEFAULT_NORMAL_PRIORITY_ISSUE_ID %> my-issue-card <% else %> my-issue-card-low-priority <% end %>">
<div style="float: right; font-size: smaller"><%= issue.project.name %></div>
<p><input type="checkbox" name="ids[]" value="<%= issue.id %>"> <%= issue.tracker.name %> #<%= issue.id %></p>
<% if @show_ancestors == "1" then %>
<%= render_issue_ancestors(issue) %>
<% end %>
<p><a href="./issues/<%= issue.id %>"><%= issue.subject %></a></p>
<hr>
<!-- Spent hours -->
<div style="float: right; font-size: smaller"><%= (issue.spent_hours || 0.0) %><%= I18n.t(:kanban_hours_abbreviation) %></div>
<!-- User name -->
<p id="user_name_issue-<%= issue.id %>"><% if issue.assigned_to != nil %><%= issue.assigned_to.name %><% else %>Not assigned<% end %></p>
</div>
11 changes: 11 additions & 0 deletions app/views/kanban/_small_card.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div id="issue-<%= issue.id %>" class="hascontextmenu created-by-me context-menu-selection
<!-- Card color by priority -->
<% if issue.priority_id >= Constants::DEFAULT_HIGH_PRIORITY_ISSUE_ID then %> my-issue-card-high-priority-small <% elsif issue.priority_id == Constants::DEFAULT_NORMAL_PRIORITY_ISSUE_ID %> my-issue-card-small <% else %> my-issue-card-low-priority-small <% end %>">
<p class="my-string-ellipsis">
<input type="checkbox" name="ids[]" value="<%= issue.id %>">
<% if @show_ancestors == "1" then %>
<%= render_issue_ancestors(issue) %>
<% end %>
<a href="./issues/<%= issue.id %>" title="<%= issue.subject %>"><%= issue.subject %></a>
</p>
</div>
67 changes: 14 additions & 53 deletions app/views/kanban/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
<select name="card_size" id="card_size">
<option value="normal_days_left" <% if @card_size == "normal_days_left" then %> selected <% end %>><%= I18n.t(:kanban_label_card_size_normal_days_left) %></option>
<option value="normal_estimated_hours" <% if @card_size == "normal_estimated_hours" then %> selected <% end %>><%= I18n.t(:kanban_label_card_size_normal_estimated_hours) %></option>
<option value="normal_spent_hours" <% if @card_size == "normal_spent_hours" then %> selected <% end %>><%= I18n.t(:kanban_label_card_size_normal_spent_hours) %></option>
<option value="small" <% if @card_size == "small" then %> selected <% end %>><%= I18n.t(:kanban_label_card_size_small) %></option>
</select>
</td>
Expand Down Expand Up @@ -280,61 +281,17 @@
<% @issues_hash[status_id].each {|issue| %>
<% if uid == issue.assigned_to_id then %>
<% if @card_size == "small" then %>
<!-- This is SMALL SIZE card -->
<div id="issue-<%= issue.id %>" class="hascontextmenu created-by-me context-menu-selection
<!-- Card color by priority -->
<% if issue.priority_id >= Constants::DEFAULT_HIGH_PRIORITY_ISSUE_ID then %> my-issue-card-high-priority-small <% elsif issue.priority_id == Constants::DEFAULT_NORMAL_PRIORITY_ISSUE_ID %> my-issue-card-small <% else %> my-issue-card-low-priority-small <% end %>">
<p class="my-string-ellipsis">
<input type="checkbox" name="ids[]" value="<%= issue.id %>">
<% if @show_ancestors == "1" then %>
<%= render_issue_ancestors(issue) %>
<% end %>
<a href="./issues/<%= issue.id %>" title="<%= issue.subject %>"><%= issue.subject %></a>
</p>
</div>
<!-- End of the card -->
<!-- SMALL SIZE card -->
<%= render partial: 'kanban/small_card', locals: { issue: issue } %>
<% elsif @card_size == "normal_days_left" then %>
<!-- This is NORMAL SIZE card display with diff. of due date -->
<div id="issue-<%= issue.id %>" class="hascontextmenu created-by-me context-menu-selection
<!-- Card color by priority -->
<% if issue.priority_id >= Constants::DEFAULT_HIGH_PRIORITY_ISSUE_ID then %> my-issue-card-high-priority <% elsif issue.priority_id == Constants::DEFAULT_NORMAL_PRIORITY_ISSUE_ID %> my-issue-card <% else %> my-issue-card-low-priority <% end %>">
<div style="float: right; font-size: smaller"><%= issue.project.name %></div>
<p><input type="checkbox" name="ids[]" value="<%= issue.id %>"> <%= issue.tracker.name %> #<%= issue.id %></p>
<% if @show_ancestors == "1" then %>
<%= render_issue_ancestors(issue) %>
<% end %>
<p><a href="./issues/<%= issue.id %>"><%= issue.subject %></a></p>
<hr>
<!-- Days to due_date -->
<% if issue.due_date != nil and issue.done_ratio < 100 then %>
<% diff = issue.due_date - Date.today %>
<% if diff.to_i == 0 then %><div style="float: right; font-size: smaller"><%= I18n.t(:kanban_label_today) %></div><% end %>
<% if diff.to_i == 1 then %><div style="float: right; font-size: smaller"><%= I18n.t(:kanban_label_tommorow) %></div><% end %>
<% if diff.to_i >= 2 then %><div style="float: right; font-size: smaller"><%= I18n.t(:kanban_label_days_left, :value => diff.to_i) %></div><% end %>
<% if diff.to_i < 0 then %><div style="float: right; font-size: smaller"><%= I18n.t(:kanban_label_overdue) %></div><% end %>
<% end %>
<!-- User name -->
<p id="user_name_issue-<%= issue.id %>"><% if issue.assigned_to != nil %><%= issue.assigned_to.name %><% else %>Not assigned<% end %></p>
</div>
<!-- End of the card -->
<!-- NORMAL SIZE card display with days left -->
<%= render partial: 'kanban/normal_card_days_left', locals: { issue: issue } %>
<% elsif @card_size == "normal_estimated_hours" then %>
<!-- NORMAL SIZE card display with estimated hours -->
<%= render partial: 'kanban/normal_card_estimated_hours', locals: { issue: issue } %>
<% else %>
<!-- This is NORMAL SIZE card display with Estimated Hours -->
<div id="issue-<%= issue.id %>" class="hascontextmenu created-by-me context-menu-selection
<!-- Card color by priority -->
<% if issue.priority_id >= Constants::DEFAULT_HIGH_PRIORITY_ISSUE_ID then %> my-issue-card-high-priority <% elsif issue.priority_id == Constants::DEFAULT_NORMAL_PRIORITY_ISSUE_ID %> my-issue-card <% else %> my-issue-card-low-priority <% end %>">
<div style="float: right; font-size: smaller"><%= issue.project.name %></div>
<p><input type="checkbox" name="ids[]" value="<%= issue.id %>"> <%= issue.tracker.name %> #<%= issue.id %></p>
<% if @show_ancestors == "1" then %>
<%= render_issue_ancestors(issue) %>
<% end %>
<p><a href="./issues/<%= issue.id %>"><%= issue.subject %></a></p>
<hr>
<!-- Estimated Hours -->
<div style="float: right; font-size: smaller"><%= (issue.estimated_hours || 0.0) %><%= I18n.t(:kanban_hours_abbreviation) %></div>
<!-- User name -->
<p id="user_name_issue-<%= issue.id %>"><% if issue.assigned_to != nil %><%= issue.assigned_to.name %><% else %>Not assigned<% end %></p>
</div>
<!-- End of the card -->
<!-- NORMAL SIZE card display with spent hours -->
<%= render partial: 'kanban/normal_card_spent_hours', locals: { issue: issue } %>
<% end %>
<% end %>
<% } %>
Expand Down Expand Up @@ -400,6 +357,10 @@
<td>k</td>
<td>: <%= I18n.t(:kanban_keyboard_shortcuts_help_7) %></td>
</tr>
<tr>
<td>p</td>
<td>: <%= I18n.t(:kanban_keyboard_shortcuts_help_11) %></td>
</tr>
<tr>
<td>s</td>
<td>: <%= I18n.t(:kanban_keyboard_shortcuts_help_8) %></td>
Expand Down
6 changes: 5 additions & 1 deletion assets/javascripts/kanban.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ Object.defineProperty(window, 'onbeforeunload', {
});

// Keyboard Shortcuts
hotkeys('o,e,k,d+u,d+o,d+t,d+w,n,s,h,l', function(event,handler) {
hotkeys('o,e,k,d+u,d+o,d+t,d+w,n,s,h,l,p', function(event,handler) {
switch(handler.key){
// assignee == (login user)
case "o":
Expand Down Expand Up @@ -357,6 +357,10 @@ hotkeys('o,e,k,d+u,d+o,d+t,d+w,n,s,h,l', function(event,handler) {
case "k":
$('#card_size').val("normal_estimated_hours");
break;
// card_size == normal_spent_hours
case "p":
$('#card_size').val("normal_spent_hours");
break;
// card_size == small
case "s":
$('#card_size').val("small");
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ en:
kanban_label_card_size_small: Small
kanban_label_card_size_normal_days_left: Normal (diff. of due date)
kanban_label_card_size_normal_estimated_hours: Normal (estimated hours)
kanban_label_card_size_normal_spent_hours: Normal (spent hours)

kanban_label_show_ancestors: Show parent task

Expand All @@ -50,3 +51,4 @@ en:
kanban_keyboard_shortcuts_help_8: Show by small size card.
kanban_keyboard_shortcuts_help_9: Select all open issues.
kanban_keyboard_shortcuts_help_10: Show this help.
kanban_keyboard_shortcuts_help_11: Show by normal size card with spent hours.
2 changes: 2 additions & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ es:
kanban_label_card_size_small: Pequeño
kanban_label_card_size_normal_days_left: Normal 1 (con atrasos)
kanban_label_card_size_normal_estimated_hours: Normal 2 (con horas estimadas)
kanban_label_card_size_normal_spent_hours: Normal 3 (con horas dedicadas)

kanban_label_show_ancestors: Mostrar tarea principal

Expand All @@ -49,3 +50,4 @@ es:
kanban_keyboard_shortcuts_help_8: Mostrar por tarjeta de tamaño pequeño.
kanban_keyboard_shortcuts_help_9: Seleccione todos los problemas abiertos.
kanban_keyboard_shortcuts_help_10: Muestre esta ayuda.
kanban_keyboard_shortcuts_help_11: Mostrar por tarjeta de tamaño normal con horas dedicadas.
2 changes: 2 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fr:
kanban_label_card_size_small: Réduit
kanban_label_card_size_normal_days_left: Normal (en jours)
kanban_label_card_size_normal_estimated_hours: Normal (en heures)
kanban_label_card_size_normal_spent_hours: Normal (en heures de travail)

kanban_label_show_ancestors: Afficher la tâche parente

Expand All @@ -49,3 +50,4 @@ fr:
kanban_keyboard_shortcuts_help_8: Afficher par carte de petite taille.
kanban_keyboard_shortcuts_help_9: Sélectionnez tous les problèmes ouverts.
kanban_keyboard_shortcuts_help_10: Montrez cette aide.
kanban_keyboard_shortcuts_help_11: Afficher par carte de taille normale avec des heures de travail.
2 changes: 2 additions & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ja:
kanban_label_card_size_small: スモール
kanban_label_card_size_normal_days_left: ノーマル(期日との差)
kanban_label_card_size_normal_estimated_hours: ノーマル(予定工数)
kanban_label_card_size_normal_spent_hours: ノーマル(作業時間)

kanban_label_show_ancestors: 親タスクを表示する

Expand All @@ -49,3 +50,4 @@ ja:
kanban_keyboard_shortcuts_help_8: 小さいカードサイズで表示
kanban_keyboard_shortcuts_help_9: 全ての未解決のカードを選択
kanban_keyboard_shortcuts_help_10: このヘルプを表示
kanban_keyboard_shortcuts_help_11: 通常のカードサイズで表示(作業時間)
4 changes: 3 additions & 1 deletion config/locales/pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ pl:
kanban_label_card_size: "Wielkość karty"
kanban_label_card_size_small: "Mała"
kanban_label_card_size_normal_days_left: "Normalna(wyszczególnij czas oddania)"
kanban_label_card_size_normal_estimated_hours: "Normalna (wyszczególnij przepracowany czas)"
kanban_label_card_size_normal_estimated_hours: "Normalna (wyszczególnij szacowany czas)"
kanban_label_card_size_normal_spent_hours: "Normalna (wyszczególnij przepracowany czas)"

kanban_label_show_ancestors: Pokaż zadanie nadrzędne

Expand All @@ -49,3 +50,4 @@ pl:
kanban_keyboard_shortcuts_help_8: "Pokaż według małej karty rozmiaru."
kanban_keyboard_shortcuts_help_9: "Wybierz wszystkie otwarte problemy."
kanban_keyboard_shortcuts_help_10: "Pokaż tę pomoc."
kanban_keyboard_shortcuts_help_11: "Pokaż według karty normalnego rozmiaru z spędzonymi godzinami."
2 changes: 2 additions & 0 deletions config/locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ru:
kanban_label_card_size_small: "Маленький"
kanban_label_card_size_normal_days_left: "Нормальный (срок завершения)"
kanban_label_card_size_normal_estimated_hours: "Нормальный (расчетное время)"
kanban_label_card_size_normal_spent_hours: "Нормальный (Рабочее время)"

kanban_label_show_ancestors: "Показать pодительская задача"

Expand All @@ -50,3 +51,4 @@ ru:
kanban_keyboard_shortcuts_help_8: "Показать карточки малого размера."
kanban_keyboard_shortcuts_help_9: "Выбрать все открытые вопросы."
kanban_keyboard_shortcuts_help_10: "Показать эту справку."
kanban_keyboard_shortcuts_help_11: "Показать карточки норм. размера (Рабочее время)."
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 'Kanban plugin'
author 'Kohei Nomura'
description 'Kanban plugin for redmine'
version '0.0.10'
version '0.0.11'
url 'https://github.com/happy-se-life/kanban'
author_url 'mailto:kohei_nom@yahoo.co.jp'

Expand Down

0 comments on commit e055176

Please sign in to comment.