Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
a454502b
Commit
a454502b
authored
May 09, 2014
by
Andy Armstrong
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3666 from edx/andya/fix-translation-string
Improve the translatability of Studio's paging header
parents
74578cd7
e75f2733
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
23 deletions
+62
-23
cms/static/js/spec/views/paging_spec.js
+25
-1
cms/static/js/views/paging.js
+0
-6
cms/static/js/views/paging_header.js
+37
-16
No files found.
cms/static/js/spec/views/paging_spec.js
View file @
a454502b
...
@@ -245,7 +245,6 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
...
@@ -245,7 +245,6 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
expect
(
pagingHeader
.
$
(
'.next-page-link'
)).
toHaveClass
(
'is-disabled'
);
expect
(
pagingHeader
.
$
(
'.next-page-link'
)).
toHaveClass
(
'is-disabled'
);
});
});
it
(
'should be disabled on an empty page'
,
function
()
{
it
(
'should be disabled on an empty page'
,
function
()
{
var
requests
=
create_sinon
.
requests
(
this
);
var
requests
=
create_sinon
.
requests
(
this
);
pagingView
.
setPage
(
0
);
pagingView
.
setPage
(
0
);
...
@@ -301,6 +300,31 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
...
@@ -301,6 +300,31 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
});
});
});
});
describe
(
"Page metadata section"
,
function
()
{
it
(
'shows the correct metadata for the current page'
,
function
()
{
var
requests
=
create_sinon
.
requests
(
this
),
message
;
pagingView
.
setPage
(
0
);
respondWithMockAssets
(
requests
);
message
=
pagingHeader
.
$
(
'.meta'
).
html
().
trim
();
expect
(
message
).
toBe
(
'<p>Showing <span class="count-current-shown">1-3</span>'
+
' out of <span class="count-total">4 total</span>, '
+
'sorted by <span class="sort-order">Date</span> descending</p>'
);
});
it
(
'shows the correct metadata when sorted ascending'
,
function
()
{
var
requests
=
create_sinon
.
requests
(
this
),
message
;
pagingView
.
setPage
(
0
);
pagingView
.
toggleSortOrder
(
'name-col'
);
respondWithMockAssets
(
requests
);
message
=
pagingHeader
.
$
(
'.meta'
).
html
().
trim
();
expect
(
message
).
toBe
(
'<p>Showing <span class="count-current-shown">1-3</span>'
+
' out of <span class="count-total">4 total</span>, '
+
'sorted by <span class="sort-order">Name</span> ascending</p>'
);
});
});
describe
(
"Asset count label"
,
function
()
{
describe
(
"Asset count label"
,
function
()
{
it
(
'should show correct count on first page'
,
function
()
{
it
(
'should show correct count on first page'
,
function
()
{
var
requests
=
create_sinon
.
requests
(
this
);
var
requests
=
create_sinon
.
requests
(
this
);
...
...
cms/static/js/views/paging.js
View file @
a454502b
...
@@ -87,12 +87,6 @@ define(["underscore", "js/views/baseview", "js/views/feedback_alert", "gettext"]
...
@@ -87,12 +87,6 @@ define(["underscore", "js/views/baseview", "js/views/feedback_alert", "gettext"]
return
sortInfo
.
displayName
;
return
sortInfo
.
displayName
;
},
},
sortDirectionName
:
function
()
{
var
collection
=
this
.
collection
,
ascending
=
collection
.
sortDirection
===
'asc'
;
return
ascending
?
gettext
(
"ascending"
)
:
gettext
(
"descending"
);
},
setInitialSortColumn
:
function
(
sortColumn
)
{
setInitialSortColumn
:
function
(
sortColumn
)
{
var
collection
=
this
.
collection
,
var
collection
=
this
.
collection
,
sortInfo
=
this
.
sortableColumns
[
sortColumn
];
sortInfo
=
this
.
sortableColumns
[
sortColumn
];
...
...
cms/static/js/views/paging_header.js
View file @
a454502b
...
@@ -31,27 +31,48 @@ define(["underscore", "gettext", "js/views/baseview"], function(_, gettext, Base
...
@@ -31,27 +31,48 @@ define(["underscore", "gettext", "js/views/baseview"], function(_, gettext, Base
},
},
messageHtml
:
function
()
{
messageHtml
:
function
()
{
var
message
;
if
(
this
.
view
.
collection
.
sortDirection
===
'asc'
)
{
// Translators: sample result: "Showing 0-9 out of 25 total, sorted by Date Added ascending"
message
=
gettext
(
'Showing %(current_item_range)s out of %(total_items_count)s, sorted by %(sort_name)s ascending'
);
}
else
{
// Translators: sample result: "Showing 0-9 out of 25 total, sorted by Date Added descending"
message
=
gettext
(
'Showing %(current_item_range)s out of %(total_items_count)s, sorted by %(sort_name)s descending'
);
}
return
'<p>'
+
interpolate
(
message
,
{
current_item_range
:
this
.
currentItemRangeLabel
(),
total_items_count
:
this
.
totalItemsCountLabel
(),
sort_name
:
this
.
sortNameLabel
()
},
true
)
+
"</p>"
;
},
currentItemRangeLabel
:
function
()
{
var
view
=
this
.
view
,
var
view
=
this
.
view
,
collection
=
view
.
collection
,
collection
=
view
.
collection
,
start
=
collection
.
start
,
start
=
collection
.
start
,
count
=
collection
.
size
(),
count
=
collection
.
size
(),
sortName
=
view
.
sortDisplayName
(),
end
=
start
+
count
;
sortDirectionName
=
view
.
sortDirectionName
(),
return
interpolate
(
'<span class="count-current-shown">%(start)s-%(end)s</span>'
,
{
end
=
start
+
count
,
total
=
collection
.
totalCount
,
fmts
=
gettext
(
'Showing %(current_span)s%(start)s-%(end)s%(end_span)s out of %(total_span)s%(total)s total%(end_span)s, sorted by %(order_span)s%(sort_order)s%(end_span)s %(sort_direction)s'
);
return
'<p>'
+
interpolate
(
fmts
,
{
start
:
Math
.
min
(
start
+
1
,
end
),
start
:
Math
.
min
(
start
+
1
,
end
),
end
:
end
,
end
:
end
total
:
total
,
},
true
);
sort_order
:
sortName
,
},
sort_direction
:
sortDirectionName
,
current_span
:
'<span class="count-current-shown">'
,
totalItemsCountLabel
:
function
()
{
total_span
:
'<span class="count-total">'
,
var
totalItemsLabel
;
order_span
:
'<span class="sort-order">'
,
// Translators: turns into "25 total" to be used in other sentences, e.g. "Showing 0-9 out of 25 total".
end_span
:
'</span>'
totalItemsLabel
=
interpolate
(
gettext
(
'%(total_items)s total'
),
{
},
true
)
+
"</p>"
;
total_items
:
this
.
view
.
collection
.
totalCount
},
true
);
return
interpolate
(
'<span class="count-total">%(total_items_label)s</span>'
,
{
total_items_label
:
totalItemsLabel
},
true
);
},
sortNameLabel
:
function
()
{
return
interpolate
(
'<span class="sort-order">%(sort_name)s</span>'
,
{
sort_name
:
this
.
view
.
sortDisplayName
()
},
true
);
},
},
nextPage
:
function
()
{
nextPage
:
function
()
{
...
...
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