Commit 233c19916618dbfeec8eee0eaf76a820b4f4a733

Authored by Austin Smith
1 parent 7bac2c66c0
Exists in master

enable taskboard filtering

Showing 4 changed files with 103 additions and 3 deletions Side-by-side Diff

app/views/my_taskboard/index.html.erb View file @ 233c199
1 1 <%= javascript_include_tag('task_board', :plugin => 'redmine_task_board') %>
2 2  
  3 +<div id="taskboard-filters">
  4 + <p>
  5 + <%= label_tag "priority", "Priority" %>
  6 + <%= select_tag("priority", options_for_select([['Any', '0']] + IssuePriority.all.collect { |m| [ m.name, m.id ] } )) %>
  7 + <%= label_tag "project", "Project" %>
  8 + <%= select_tag("project", options_for_select([['Any', '0']] + Project.all(:order => 'name', :conditions => {:status => 1}).select{|project| @user.allowed_to?(:log_time, project)}.collect{|p| [p.name, p.id] })) %>
  9 + </p>
  10 +</div>
  11 +
3 12 <div id="taskboard-buttons">
4 13 <input type="button" id="edit-issues" value="<%= translate :task_board_issue_bulk_edit %>" />
5 14 </div>
... ... @@ -9,7 +18,8 @@
9 18 <h4><%= translate :task_board_prioritized %></h4>
10 19 <ul id="prioritized">
11 20 <% @prioritized.each do|issue| %>
12   - <li class="card priority-<%= issue.priority_id.to_s %> <%= issue.tracker_name.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '') %>" id="issue_<%= issue.id %>" data-issue-id="<%= issue.id %>" data-status-id="<%= issue.status_id %>">
  21 + <li class="card priority-<%= issue.priority.id.to_s %> <%= issue.tracker_name.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '') %>" id="issue_<%= issue.id %>" data-issue-id="<%= issue.id %>" data-priority="<%= issue.priority.id.to_s %>" data-status-id="<%= issue.status_id %>" data-project="<%= issue.project.id.to_s %>">
  22 +
13 23 <div class="issue">
14 24 <div class="issue-heading">
15 25 <p class="issue-number meta">
... ... @@ -33,7 +43,7 @@
33 43 <h4><%= translate :task_board_not_prioritized %></h4>
34 44 <ul id="not-prioritized">
35 45 <% @not_prioritized.each do|issue| %>
36   - <li class="card priority-<%= issue.priority_id.to_s %> <%= issue.tracker_name.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '') %>" id="issue_<%= issue.id %>" data-issue-id="<%= issue.id %>" data-status-id="<%= issue.status_id %>">
  46 + <li class="card priority-<%= issue.priority.id.to_s %> <%= issue.tracker_name.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '') %>" id="issue_<%= issue.id %>" data-issue-id="<%= issue.id %>" data-priority="<%= issue.priority.id.to_s %>" data-status-id="<%= issue.status_id %>" data-project="<%= issue.project.id.to_s %>">
37 47 <div class="issue">
38 48 <div class="issue-heading">
39 49 <p class="issue-number meta">
... ... @@ -65,6 +75,7 @@
65 75 new MyTaskBoardPane(sections[i], {connectWith: '#sortable-root .taskboard-pane ul', constraint: false, scroll: true, dropOnEmpty: true, items: '> .card'});
66 76 }
67 77 TaskBoardUtils.checkboxListener();
  78 + var filters = new TaskBoardFilters();
68 79 // Sortable.create('sortable-root', {tree: true, dropOnEmpty: true, constraint: false, overlap: 'vertical'});
69 80 </script>
70 81  
app/views/taskboard/index.html.erb View file @ 233c199
1 1 <%= javascript_include_tag('task_board', :plugin => 'redmine_task_board') %>
2 2  
  3 +<div id="taskboard-filters">
  4 + <p>
  5 + <%= label_tag "assignee", "Assigned to" %>
  6 + <%= select_tag("assignee", options_for_select([['Anyone', '0']] + @project.members.collect { |m| [ m.name, m.user.id ] } )) %>
  7 + <%= label_tag "priority", "Priority" %>
  8 + <%= select_tag("priority", options_for_select([['Any', '0']] + IssuePriority.all.collect { |m| [ m.name, m.id ] } )) %>
  9 + <%= label_tag "category", "Category" %>
  10 + <%= select_tag("category", options_for_select([['Any', '0']] + @project.issue_categories.collect { |m| [ m.name, m.id ] } )) %>
  11 + </p>
  12 +</div>
  13 +
3 14 <div id="taskboard-buttons">
4 15 <input type="button" id="edit-issues" value="<%= translate :task_board_issue_bulk_edit %>" />
5 16 <input type="button" id="archive-issues" value="<%= translate :task_board_issue_bulk_archive %>" />
... ... @@ -15,7 +26,7 @@
15 26 <% end %>
16 27 <ul data-status-id="<%= status_id %>" data-max-issues="<%= column.max_issues %>" id="column_<%= status_id %>"<% if issues.empty? %> class="empty"<% end %>>
17 28 <% issues.each do|issue| %>
18   - <li class="card priority-<%= issue.priority.id.to_s %> <%= issue.tracker.name.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '') %>" id="issue_<%= issue.id %>" data-issue-id="<%= issue.id %>" data-weight="<%= issue.weight %>" data-status-id="<%= issue.status_id %>">
  29 + <li class="card priority-<%= issue.priority.id.to_s %> <%= issue.tracker.name.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '') %>" id="issue_<%= issue.id %>" data-issue-id="<%= issue.id %>" data-priority="<%= issue.priority.id.to_s %>" data-assignee="<%= issue.assigned_to ? issue.assigned_to.id.to_s : 0 %>" data-category="<%= issue.category ? issue.category.id.to_s : 0 %>" data-weight="<%= issue.weight %>" data-status-id="<%= issue.status_id %>">
19 30 <div class="issue">
20 31 <div class="issue-heading">
21 32 <p class="issue-number meta">
... ... @@ -52,6 +63,7 @@
52 63 new TaskBoardPane(sections[i], {connectWith: '#sortable-root .taskboard-pane ul', constraint: false, scroll: true, dropOnEmpty: true, items: '> .card'});
53 64 }
54 65 TaskBoardUtils.checkboxListener();
  66 + var filters = new TaskBoardFilters();
55 67 // Sortable.create('sortable-root', {tree: true, dropOnEmpty: true, constraint: false, overlap: 'vertical'});
56 68 </script>
57 69  
assets/javascripts/task_board.js View file @ 233c199
... ... @@ -36,6 +36,39 @@
36 36 };
37 37 })();
38 38  
  39 +var TaskBoardFilters = Class.extend({
  40 + filters: {
  41 + priority: 0,
  42 + category: 0,
  43 + assignee: 0, // only used on project taskboard
  44 + project: 0 // only used on "my" taskboard
  45 + },
  46 + init: function() {
  47 + var self = this;
  48 + $('#taskboard-filters').on('change', 'select', function() {
  49 + self.filters[$(this).attr('name')] = parseInt($(this).val());
  50 + self.applyFilters();
  51 + });
  52 + },
  53 + applyFilters: function() {
  54 + var self = this;
  55 + $('#sortable-root').find('li.card').each(function() {
  56 + var minimized = false;
  57 + for (var f in self.filters) {
  58 + if (self.filters[f] == 0 || self.filters[f] == parseInt($(this).data(f))) {
  59 + continue;
  60 + }
  61 + else {
  62 + minimized = true;
  63 + break;
  64 + }
  65 + }
  66 + if (minimized) $(this).hide();
  67 + else $(this).show();
  68 + });
  69 + }
  70 +});
  71 +
39 72 var TaskBoardSortable = Class.extend({
40 73  
41 74 sortable: null,
assets/stylesheets/taskboard.css View file @ 233c199
1 1 .taskboard-wrapper {
2 2 width: 100%;
3 3 overflow: auto;
  4 + margin-top: 32px;
4 5 }
5 6  
  7 +.my-taskboard-wrapper {
  8 + margin-top: 32px;
  9 +}
  10 +
6 11 .taskboard-pane {
7 12 float: left;
8 13 width: 250px;
... ... @@ -120,6 +125,19 @@
120 125 position: relative;
121 126 }
122 127  
  128 +#taskboard-filters {
  129 + position: absolute;
  130 + top: 0;
  131 + left: 0;
  132 + background: #dadada;
  133 + padding: 4px;
  134 +}
  135 +
  136 +#taskboard-filters p {
  137 + margin: 0;
  138 + padding: 0;
  139 +}
  140 +
123 141 #taskboard-buttons {
124 142 position: absolute;
125 143 top: 0;
... ... @@ -170,5 +188,31 @@
170 188 font-size: 12px;
171 189 margin-bottom: 0;
172 190 overflow: hidden;
  191 +}
  192 +
  193 +.taskboard-pane ul li.card.minimized div.issue {
  194 + background-color: #efefef;
  195 + border: none;
  196 + padding: 0px;
  197 + margin-bottom: -2px;
  198 + margin-top: -2px;
  199 + height: 12px;
  200 + overflow: hidden;
  201 +}
  202 +
  203 +.taskboard-pane ul li.card.minimized div.issue .issue-heading,
  204 +.taskboard-pane ul li.card.minimized div.issue p.meta {
  205 + display: none;
  206 +}
  207 +
  208 +.taskboard-pane ul li.card.minimized div.issue h3,
  209 +.taskboard-pane ul li.card.minimized div.issue h3 a {
  210 + font-size: 10px;
  211 + line-height: 10px;
  212 + color: #aaa;
  213 +}
  214 +
  215 +#not-prioritized-wrapper li.card.minimized {
  216 + display: none;
173 217 }