Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
0a53a3d9
Commit
0a53a3d9
authored
Feb 21, 2017
by
mhasbini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change todos counter position & format ( for large counts )
parent
88152949
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
58 additions
and
5 deletions
+58
-5
app/assets/javascripts/header.js
app/assets/javascripts/header.js
+1
-1
app/assets/javascripts/lib/utils/text_utility.js
app/assets/javascripts/lib/utils/text_utility.js
+3
-0
app/assets/stylesheets/pages/todos.scss
app/assets/stylesheets/pages/todos.scss
+2
-0
app/controllers/dashboard/todos_controller.rb
app/controllers/dashboard/todos_controller.rb
+5
-0
app/helpers/todos_helper.rb
app/helpers/todos_helper.rb
+4
-0
app/views/layouts/header/_default.html.haml
app/views/layouts/header/_default.html.haml
+1
-1
changelogs/unreleased/26703-todos-count.yml
changelogs/unreleased/26703-todos-count.yml
+4
-0
doc/workflow/todos.md
doc/workflow/todos.md
+2
-1
spec/features/todos/todos_spec.rb
spec/features/todos/todos_spec.rb
+23
-0
spec/javascripts/header_spec.js
spec/javascripts/header_spec.js
+2
-2
spec/javascripts/lib/utils/text_utility_spec.js.es6
spec/javascripts/lib/utils/text_utility_spec.js.es6
+11
-0
No files found.
app/assets/javascripts/header.js
View file @
0a53a3d9
...
...
@@ -2,7 +2,7 @@
(
function
()
{
$
(
document
).
on
(
'
todo:toggle
'
,
function
(
e
,
count
)
{
var
$todoPendingCount
=
$
(
'
.todos-pending-count
'
);
$todoPendingCount
.
text
(
gl
.
text
.
addDelimiter
(
count
));
$todoPendingCount
.
text
(
gl
.
text
.
highCountTrim
(
count
));
$todoPendingCount
.
toggleClass
(
'
hidden
'
,
count
===
0
);
});
})();
app/assets/javascripts/lib/utils/text_utility.js
View file @
0a53a3d9
...
...
@@ -14,6 +14,9 @@ require('vendor/latinise');
gl
.
text
.
addDelimiter
=
function
(
text
)
{
return
text
?
text
.
toString
().
replace
(
/
\B(?=(\d{3})
+
(?!\d))
/g
,
"
,
"
)
:
text
;
};
gl
.
text
.
highCountTrim
=
function
(
count
)
{
return
count
>
99
?
'
99+
'
:
count
;
};
gl
.
text
.
randomString
=
function
()
{
return
Math
.
random
().
toString
(
36
).
substring
(
7
);
};
...
...
app/assets/stylesheets/pages/todos.scss
View file @
0a53a3d9
...
...
@@ -6,6 +6,8 @@
.navbar-nav
{
li
{
.badge.todos-pending-count
{
position
:
inherit
;
top
:
-6px
;
margin-top
:
-5px
;
font-weight
:
normal
;
background
:
$todo-alert-blue
;
...
...
app/controllers/dashboard/todos_controller.rb
View file @
0a53a3d9
...
...
@@ -35,6 +35,11 @@ class Dashboard::TodosController < Dashboard::ApplicationController
render
json:
todos_counts
end
# Used in TodosHelper also
def
self
.
todos_count_format
(
count
)
count
>=
100
?
'99+'
:
count
end
private
def
find_todos
...
...
app/helpers/todos_helper.rb
View file @
0a53a3d9
...
...
@@ -3,6 +3,10 @@ module TodosHelper
@todos_pending_count
||=
current_user
.
todos_pending_count
end
def
todos_count_format
(
count
)
count
>
99
?
'99+'
:
count
end
def
todos_done_count
@todos_done_count
||=
current_user
.
todos_done_count
end
...
...
app/views/layouts/header/_default.html.haml
View file @
0a53a3d9
...
...
@@ -35,7 +35,7 @@
=
link_to
dashboard_todos_path
,
title:
'Todos'
,
aria:
{
label:
"Todos"
},
data:
{
toggle:
'tooltip'
,
placement:
'bottom'
,
container:
'body'
}
do
=
icon
(
'bell fw'
)
%span
.badge.todos-pending-count
{
class:
(
"hidden"
if
todos_pending_count
==
0
)
}
=
todos_
pending_count
=
todos_
count_format
(
todos_pending_count
)
-
if
Gitlab
::
Sherlock
.
enabled?
%li
=
link_to
sherlock_transactions_path
,
title:
'Sherlock Transactions'
,
...
...
changelogs/unreleased/26703-todos-count.yml
0 → 100644
View file @
0a53a3d9
---
title
:
show 99+ for large count in todos notification bell
merge_request
:
9171
author
:
mhasbini
doc/workflow/todos.md
View file @
0a53a3d9
...
...
@@ -16,7 +16,8 @@ in a simple dashboard.
You can quickly access the Todos dashboard using the bell icon next to the
search bar in the upper right corner. The number in blue is the number of Todos
you still have open.
you still have open if the count is < 100, else it's 99+. The exact number
will still be shown in the body of the _To do_ tab.
![
Todos icon
](
img/todos_icon.png
)
...
...
spec/features/todos/todos_spec.rb
View file @
0a53a3d9
...
...
@@ -171,6 +171,29 @@ describe 'Dashboard Todos', feature: true do
end
end
context
'User have large number of todos'
do
before
do
create_list
(
:todo
,
101
,
:mentioned
,
user:
user
,
project:
project
,
target:
issue
,
author:
author
)
login_as
(
user
)
visit
dashboard_todos_path
end
it
'shows 99+ for count >= 100 in notification'
do
expect
(
page
).
to
have_selector
(
'.todos-pending-count'
,
text:
'99+'
)
end
it
'shows exact number in To do tab'
do
expect
(
page
).
to
have_selector
(
'.todos-pending .badge'
,
text:
'101'
)
end
it
'shows exact number for count < 100'
do
3
.
times
{
first
(
'.js-done-todo'
).
click
}
expect
(
page
).
to
have_selector
(
'.todos-pending-count'
,
text:
'98'
)
end
end
context
'User has a Build Failed todo'
do
let!
(
:todo
)
{
create
(
:todo
,
:build_failed
,
user:
user
,
project:
project
,
author:
author
)
}
...
...
spec/javascripts/header_spec.js
View file @
0a53a3d9
...
...
@@ -45,8 +45,8 @@ require('~/lib/utils/text_utility');
expect
(
isTodosCountHidden
()).
toEqual
(
false
);
});
it
(
'
should
add delimiter to
todos-pending-count
'
,
function
()
{
expect
(
$
(
todosPendingCount
).
text
()).
toEqual
(
'
1,000
'
);
it
(
'
should
show 99+ for
todos-pending-count
'
,
function
()
{
expect
(
$
(
todosPendingCount
).
text
()).
toEqual
(
'
99+
'
);
});
});
});
...
...
spec/javascripts/lib/utils/text_utility_spec.js.es6
View file @
0a53a3d9
...
...
@@ -35,5 +35,16 @@ require('~/lib/utils/text_utility');
expect(gl.text.pluralize('test', 1)).toBe('test');
});
});
describe('gl.text.highCountTrim', () => {
it('returns 99+ for count >= 100', () => {
expect(gl.text.highCountTrim(105)).toBe('99+');
expect(gl.text.highCountTrim(100)).toBe('99+');
});
it('returns exact number for count < 100', () => {
expect(gl.text.highCountTrim(45)).toBe(45);
});
});
});
})();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment