Commit 60499082 authored by Tom Quirk's avatar Tom Quirk

Migrate todo tabs to GlTabs

Update To-Do list page to use GlTab helpers,
conforming to Pajamas.
parent c7e9fbd3
/* eslint-disable class-methods-use-this, no-unneeded-ternary */ /* eslint-disable class-methods-use-this */
import $ from 'jquery'; import $ from 'jquery';
import { getGroups } from '~/api/groups_api'; import { getGroups } from '~/api/groups_api';
...@@ -78,7 +78,7 @@ export default class Todos { ...@@ -78,7 +78,7 @@ export default class Todos {
initDeprecatedJQueryDropdown($dropdown, { initDeprecatedJQueryDropdown($dropdown, {
fieldName, fieldName,
selectable: true, selectable: true,
filterable: searchFields ? true : false, filterable: Boolean(searchFields),
search: { fields: searchFields }, search: { fields: searchFields },
data: $dropdown.data('data'), data: $dropdown.data('data'),
clicked: () => { clicked: () => {
...@@ -172,8 +172,8 @@ export default class Todos { ...@@ -172,8 +172,8 @@ export default class Todos {
updateBadges(data) { updateBadges(data) {
$(document).trigger('todo:toggle', data.count); $(document).trigger('todo:toggle', data.count);
document.querySelector('.todos-pending .badge').innerHTML = addDelimiter(data.count); document.querySelector('.js-todos-pending .badge').innerHTML = addDelimiter(data.count);
document.querySelector('.todos-done .badge').innerHTML = addDelimiter(data.done_count); document.querySelector('.js-todos-done .badge').innerHTML = addDelimiter(data.done_count);
} }
goToTodoUrl(e) { goToTodoUrl(e) {
......
...@@ -10,19 +10,13 @@ ...@@ -10,19 +10,13 @@
- if current_user.todos.any? - if current_user.todos.any?
.top-area .top-area
%ul.nav-links.mobile-separator.nav.nav-tabs = gl_tabs_nav({ class: 'gl-flex-grow-1 gl-border-0' }) do
%li.todos-pending{ class: active_when(params[:state].blank? || params[:state] == 'pending') }> = gl_tab_link_to todos_filter_path(state: 'pending'), item_active: params[:state].blank? || params[:state] == 'pending', class: "js-todos-pending" do
= link_to todos_filter_path(state: 'pending') do = _("To Do")
%span = gl_tab_counter_badge number_with_delimiter(todos_pending_count)
To Do = gl_tab_link_to todos_filter_path(state: 'done'), item_active: params[:state] == 'done', class: "js-todos-done" do
%span.badge.gl-tab-counter-badge.badge-muted.badge-pill.gl-badge.sm = _("Done")
= number_with_delimiter(todos_pending_count) = gl_tab_counter_badge number_with_delimiter(todos_done_count)
%li.todos-done{ class: active_when(params[:state] == 'done') }>
= link_to todos_filter_path(state: 'done') do
%span
Done
%span.badge.gl-tab-counter-badge.badge-muted.badge-pill.gl-badge.sm
= number_with_delimiter(todos_done_count)
.nav-controls .nav-controls
- if @allowed_todos.any?(&:pending?) - if @allowed_todos.any?(&:pending?)
......
...@@ -94,13 +94,13 @@ describe('Todos', () => { ...@@ -94,13 +94,13 @@ describe('Todos', () => {
}); });
it('updates pending text', () => { it('updates pending text', () => {
expect(document.querySelector('.todos-pending .badge').innerHTML).toEqual( expect(document.querySelector('.js-todos-pending .badge').innerHTML).toEqual(
addDelimiter(TEST_COUNT_BIG), addDelimiter(TEST_COUNT_BIG),
); );
}); });
it('updates done text', () => { it('updates done text', () => {
expect(document.querySelector('.todos-done .badge').innerHTML).toEqual( expect(document.querySelector('.js-todos-done .badge').innerHTML).toEqual(
addDelimiter(TEST_DONE_COUNT_BIG), addDelimiter(TEST_DONE_COUNT_BIG),
); );
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment