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
fcbe595c
Commit
fcbe595c
authored
Jun 30, 2015
by
muhammad-ammar
Committed by
muzaffaryousaf
Dec 17, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bookmarks List Pagination
TNL-2490
parent
4304c66c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
69 additions
and
35 deletions
+69
-35
common/static/common/templates/components/paging-footer.underscore
+1
-1
common/test/acceptance/pages/common/paging.py
+6
-0
common/test/acceptance/pages/lms/bookmarks.py
+2
-1
common/test/acceptance/tests/lms/test_bookmarks.py
+0
-0
lms/static/js/bookmarks/collections/bookmarks.js
+17
-12
lms/static/js/bookmarks/views/bookmarks_list.js
+12
-10
lms/static/js/bookmarks/views/bookmarks_list_button.js
+14
-5
lms/static/js/spec/bookmarks/bookmark_button_view_spec.js
+2
-2
lms/static/js/spec/bookmarks/bookmarks_list_view_spec.js
+0
-0
lms/static/sass/views/_bookmarks.scss
+8
-1
lms/templates/bookmarks/bookmarks-list.underscore
+6
-2
lms/templates/courseware/courseware.html
+1
-1
No files found.
common/static/common/templates/components/paging-footer.underscore
View file @
fcbe595c
<nav class="pagination pagination-full bottom" aria-label="
Teams
Pagination">
<nav class="pagination pagination-full bottom" aria-label="Pagination">
<div class="nav-item previous"><button class="nav-link previous-page-link"><i class="icon fa fa-angle-left" aria-hidden="true"></i> <span class="nav-label"><%= gettext("Previous") %></span></button></div>
<div class="nav-item previous"><button class="nav-link previous-page-link"><i class="icon fa fa-angle-left" aria-hidden="true"></i> <span class="nav-label"><%= gettext("Previous") %></span></button></div>
<div class="nav-item page">
<div class="nav-item page">
<div class="pagination-form">
<div class="pagination-form">
...
...
common/test/acceptance/pages/common/paging.py
View file @
fcbe595c
...
@@ -15,6 +15,7 @@ class PaginatedUIMixin(object):
...
@@ -15,6 +15,7 @@ class PaginatedUIMixin(object):
PREVIOUS_PAGE_BUTTON_CSS
=
'button.previous-page-link'
PREVIOUS_PAGE_BUTTON_CSS
=
'button.previous-page-link'
PAGINATION_HEADER_TEXT_CSS
=
'div.search-tools'
PAGINATION_HEADER_TEXT_CSS
=
'div.search-tools'
CURRENT_PAGE_NUMBER_CSS
=
'span.current-page'
CURRENT_PAGE_NUMBER_CSS
=
'span.current-page'
TOTAL_PAGES_CSS
=
'span.total-pages'
def
get_pagination_header_text
(
self
):
def
get_pagination_header_text
(
self
):
"""Return the text showing which items the user is currently viewing."""
"""Return the text showing which items the user is currently viewing."""
...
@@ -31,6 +32,11 @@ class PaginatedUIMixin(object):
...
@@ -31,6 +32,11 @@ class PaginatedUIMixin(object):
"""Return the the current page number."""
"""Return the the current page number."""
return
int
(
self
.
q
(
css
=
self
.
CURRENT_PAGE_NUMBER_CSS
)
.
text
[
0
])
return
int
(
self
.
q
(
css
=
self
.
CURRENT_PAGE_NUMBER_CSS
)
.
text
[
0
])
@property
def
get_total_pages
(
self
):
"""Returns the total page value"""
return
int
(
self
.
q
(
css
=
self
.
TOTAL_PAGES_CSS
)
.
text
[
0
])
def
go_to_page
(
self
,
page_number
):
def
go_to_page
(
self
,
page_number
):
"""Go to the given page_number in the paginated list results."""
"""Go to the given page_number in the paginated list results."""
self
.
q
(
css
=
self
.
PAGE_NUMBER_INPUT_CSS
)
.
results
[
0
]
.
send_keys
(
unicode
(
page_number
),
Keys
.
ENTER
)
self
.
q
(
css
=
self
.
PAGE_NUMBER_INPUT_CSS
)
.
results
[
0
]
.
send_keys
(
unicode
(
page_number
),
Keys
.
ENTER
)
...
...
common/test/acceptance/pages/lms/bookmarks.py
View file @
fcbe595c
...
@@ -3,9 +3,10 @@ Courseware Boomarks
...
@@ -3,9 +3,10 @@ Courseware Boomarks
"""
"""
from
bok_choy.promise
import
EmptyPromise
from
bok_choy.promise
import
EmptyPromise
from
.course_page
import
CoursePage
from
.course_page
import
CoursePage
from
..common.paging
import
PaginatedUIMixin
class
BookmarksPage
(
CoursePage
):
class
BookmarksPage
(
CoursePage
,
PaginatedUIMixin
):
"""
"""
Courseware Bookmarks Page.
Courseware Bookmarks Page.
"""
"""
...
...
common/test/acceptance/tests/lms/test_bookmarks.py
View file @
fcbe595c
This diff is collapsed.
Click to expand it.
lms/static/js/bookmarks/collections/bookmarks.js
View file @
fcbe595c
;(
function
(
define
)
{
;(
function
(
define
)
{
'use strict'
;
'use strict'
;
define
([
'backbone'
,
'js/bookmarks/models/bookmark'
],
define
([
'backbone'
,
'
common/js/components/collections/paging_collection'
,
'
js/bookmarks/models/bookmark'
],
function
(
Backbone
,
BookmarkModel
)
{
function
(
Backbone
,
PagingCollection
,
BookmarkModel
)
{
return
PagingCollection
.
extend
({
initialize
:
function
(
options
)
{
PagingCollection
.
prototype
.
initialize
.
call
(
this
);
return
Backbone
.
Collection
.
extend
({
this
.
url
=
options
.
url
;
model
:
BookmarkModel
,
this
.
server_api
.
course_id
=
function
()
{
return
encodeURIComponent
(
options
.
course_id
);
};
this
.
server_api
.
fields
=
function
()
{
return
encodeURIComponent
(
'display_name,path'
);
};
delete
this
.
server_api
.
sort_order
;
// Sort order is not specified for the Bookmark API
},
url
:
function
()
{
model
:
BookmarkModel
,
return
$
(
".courseware-bookmarks-button"
).
data
(
'bookmarksApiUrl'
);
},
parse
:
function
(
response
)
{
url
:
function
(
)
{
return
response
.
results
;
return
this
.
url
;
}
}
});
});
});
});
})(
define
||
RequireJS
.
define
);
})(
define
||
RequireJS
.
define
);
\ No newline at end of file
lms/static/js/bookmarks/views/bookmarks_list.js
View file @
fcbe595c
;(
function
(
define
,
undefined
)
{
;(
function
(
define
,
undefined
)
{
'use strict'
;
'use strict'
;
define
([
'gettext'
,
'jquery'
,
'underscore'
,
'backbone'
,
'logger'
,
'moment'
],
define
([
'gettext'
,
'jquery'
,
'underscore'
,
'backbone'
,
'logger'
,
'moment'
,
function
(
gettext
,
$
,
_
,
Backbone
,
Logger
,
_moment
)
{
'common/js/components/views/paging_header'
,
'common/js/components/views/paging_footer'
],
function
(
gettext
,
$
,
_
,
Backbone
,
Logger
,
_moment
,
PagingHeaderView
,
PagingFooterView
)
{
var
moment
=
_moment
||
window
.
moment
;
var
moment
=
_moment
||
window
.
moment
;
...
@@ -16,27 +17,31 @@
...
@@ -16,27 +17,31 @@
errorMessage
:
gettext
(
'An error has occurred. Please try again.'
),
errorMessage
:
gettext
(
'An error has occurred. Please try again.'
),
loadingMessage
:
gettext
(
'Loading'
),
loadingMessage
:
gettext
(
'Loading'
),
PAGE_SIZE
:
500
,
defaultPage
:
1
,
events
:
{
events
:
{
'click .bookmarks-results-list-item'
:
'visitBookmark'
'click .bookmarks-results-list-item'
:
'visitBookmark'
},
},
initialize
:
function
(
options
)
{
initialize
:
function
(
options
)
{
this
.
template
=
_
.
template
(
$
(
'#bookmarks
_
list-tpl'
).
text
());
this
.
template
=
_
.
template
(
$
(
'#bookmarks
-
list-tpl'
).
text
());
this
.
loadingMessageView
=
options
.
loadingMessageView
;
this
.
loadingMessageView
=
options
.
loadingMessageView
;
this
.
errorMessageView
=
options
.
errorMessageView
;
this
.
errorMessageView
=
options
.
errorMessageView
;
this
.
courseId
=
$
(
this
.
el
).
data
(
'courseId'
);
this
.
langCode
=
$
(
this
.
el
).
data
(
'langCode'
);
this
.
langCode
=
$
(
this
.
el
).
data
(
'langCode'
);
this
.
pagingHeaderView
=
new
PagingHeaderView
({
collection
:
this
.
collection
});
this
.
pagingFooterView
=
new
PagingFooterView
({
collection
:
this
.
collection
});
this
.
listenTo
(
this
.
collection
,
'page_changed'
,
this
.
render
);
_
.
bindAll
(
this
,
'render'
,
'humanFriendlyDate'
);
_
.
bindAll
(
this
,
'render'
,
'humanFriendlyDate'
);
},
},
render
:
function
()
{
render
:
function
()
{
var
data
=
{
var
data
=
{
bookmarks
:
this
.
collection
.
models
,
bookmarks
Collection
:
this
.
collection
,
humanFriendlyDate
:
this
.
humanFriendlyDate
humanFriendlyDate
:
this
.
humanFriendlyDate
};
};
this
.
$el
.
html
(
this
.
template
(
data
));
this
.
$el
.
html
(
this
.
template
(
data
));
this
.
pagingHeaderView
.
setElement
(
this
.
$
(
'.paging-header'
)).
render
();
this
.
pagingFooterView
.
setElement
(
this
.
$
(
'.paging-footer'
)).
render
();
this
.
delegateEvents
();
this
.
delegateEvents
();
return
this
;
return
this
;
},
},
...
@@ -48,10 +53,7 @@
...
@@ -48,10 +53,7 @@
this
.
showBookmarksContainer
();
this
.
showBookmarksContainer
();
this
.
showLoadingMessage
();
this
.
showLoadingMessage
();
this
.
collection
.
fetch
({
this
.
collection
.
goTo
(
this
.
defaultPage
).
done
(
function
()
{
reset
:
true
,
data
:
{
course_id
:
this
.
courseId
,
page_size
:
this
.
PAGE_SIZE
,
fields
:
'display_name,path'
}
}).
done
(
function
()
{
view
.
hideLoadingMessage
();
view
.
hideLoadingMessage
();
view
.
render
();
view
.
render
();
view
.
focusBookmarksElement
();
view
.
focusBookmarksElement
();
...
...
lms/static/js/bookmarks/views/bookmarks_list_button.js
View file @
fcbe595c
...
@@ -16,11 +16,20 @@
...
@@ -16,11 +16,20 @@
},
},
initialize
:
function
()
{
initialize
:
function
()
{
this
.
bookmarksListView
=
new
BookmarksListView
({
var
bookmarksCollection
=
new
BookmarksCollection
(
collection
:
new
BookmarksCollection
(),
{
loadingMessageView
:
new
MessageView
({
el
:
$
(
this
.
loadingMessageElement
)}),
course_id
:
$
(
'.courseware-results'
).
data
(
'courseId'
),
errorMessageView
:
new
MessageView
({
el
:
$
(
this
.
errorMessageElement
)})
url
:
$
(
".courseware-bookmarks-button"
).
data
(
'bookmarksApiUrl'
)
});
}
);
bookmarksCollection
.
bootstrap
();
this
.
bookmarksListView
=
new
BookmarksListView
(
{
collection
:
bookmarksCollection
,
loadingMessageView
:
new
MessageView
({
el
:
$
(
this
.
loadingMessageElement
)}),
errorMessageView
:
new
MessageView
({
el
:
$
(
this
.
errorMessageElement
)})
}
);
},
},
toggleBookmarksListView
:
function
()
{
toggleBookmarksListView
:
function
()
{
...
...
lms/static/js/spec/bookmarks/bookmark_button_view_spec.js
View file @
fcbe595c
define
([
'backbone'
,
'jquery'
,
'underscore'
,
'
js/common_helpers/ajax_helpers'
,
'js/common_helpers/template
_helpers'
,
define
([
'backbone'
,
'jquery'
,
'underscore'
,
'
common/js/spec_helpers/ajax
_helpers'
,
'js/bookmarks/views/bookmark_button'
'
common/js/spec_helpers/template_helpers'
,
'
js/bookmarks/views/bookmark_button'
],
],
function
(
Backbone
,
$
,
_
,
AjaxHelpers
,
TemplateHelpers
,
BookmarkButtonView
)
{
function
(
Backbone
,
$
,
_
,
AjaxHelpers
,
TemplateHelpers
,
BookmarkButtonView
)
{
'use strict'
;
'use strict'
;
...
...
lms/static/js/spec/bookmarks/bookmarks_list_view_spec.js
View file @
fcbe595c
This diff is collapsed.
Click to expand it.
lms/static/sass/views/_bookmarks.scss
View file @
fcbe595c
...
@@ -57,7 +57,7 @@
...
@@ -57,7 +57,7 @@
// Rules for Bookmarks Results
// Rules for Bookmarks Results
.bookmarks-results-list
{
.bookmarks-results-list
{
padding-top
:
$baseline
;
padding-top
:
(
$baseline
/
2
)
;
.bookmarks-results-list-item
{
.bookmarks-results-list-item
{
@include
padding
((
$baseline
/
4
)
,
$baseline
,
(
$baseline
/
2
)
,
$baseline
);
@include
padding
((
$baseline
/
4
)
,
$baseline
,
(
$baseline
/
2
)
,
$baseline
);
...
@@ -181,3 +181,9 @@ i.bookmarked {
...
@@ -181,3 +181,9 @@ i.bookmarked {
@include
icon-style
(
"\f097"
,
$black
);
@include
icon-style
(
"\f097"
,
$black
);
@include
hover-style
(
$m-blue
,
$m-blue
,
"\f02e"
);
@include
hover-style
(
$m-blue
,
$m-blue
,
"\f02e"
);
}
}
.paging-header
{
.search-tools
{
margin
:
0
;
}
}
\ No newline at end of file
lms/templates/bookmarks/bookmarks
_
list.underscore
→
lms/templates/bookmarks/bookmarks
-
list.underscore
View file @
fcbe595c
<div id="my-bookmarks" class="sr-is-focusable" tabindex="-1"></div>
<div id="my-bookmarks" class="sr-is-focusable" tabindex="-1"></div>
<h2 class="bookmarks-results-header"><%= gettext("My Bookmarks") %></h2>
<h2 class="bookmarks-results-header"><%= gettext("My Bookmarks") %></h2>
<% if (bookmarks.length) { %>
<% if (bookmarksCollection.length) { %>
<div class="paging-header"></div>
<div class='bookmarks-results-list'>
<div class='bookmarks-results-list'>
<%
_.each(bookmarks,
function(bookmark, index) { %>
<%
bookmarksCollection.each(
function(bookmark, index) { %>
<a class="bookmarks-results-list-item" href="<%= bookmark.blockUrl() %>" aria-labelledby="bookmark-link-<%= index %>" data-bookmark-id="<%= bookmark.get('id') %>" data-component-type="<%= bookmark.get('block_type') %>" data-usage-id="<%= bookmark.get('usage_id') %>" aria-describedby="bookmark-type-<%= index %> bookmark-date-<%= index %>">
<a class="bookmarks-results-list-item" href="<%= bookmark.blockUrl() %>" aria-labelledby="bookmark-link-<%= index %>" data-bookmark-id="<%= bookmark.get('id') %>" data-component-type="<%= bookmark.get('block_type') %>" data-usage-id="<%= bookmark.get('usage_id') %>" aria-describedby="bookmark-type-<%= index %> bookmark-date-<%= index %>">
<div class="list-item-content">
<div class="list-item-content">
<div class="list-item-left-section">
<div class="list-item-left-section">
...
@@ -21,6 +23,8 @@
...
@@ -21,6 +23,8 @@
<% }); %>
<% }); %>
</div>
</div>
<div class="paging-footer"></div>
<% } else {%>
<% } else {%>
<div class="bookmarks-empty" tabindex="0">
<div class="bookmarks-empty" tabindex="0">
...
...
lms/templates/courseware/courseware.html
View file @
fcbe595c
...
@@ -53,7 +53,7 @@ ${page_title_breadcrumbs(course_name())}
...
@@ -53,7 +53,7 @@ ${page_title_breadcrumbs(course_name())}
% endfor
% endfor
% endif
% endif
% for template_name in ["bookmarks
_
list"]:
% for template_name in ["bookmarks
-
list"]:
<script
type=
"text/template"
id=
"${template_name}-tpl"
>
<script
type=
"text/template"
id=
"${template_name}-tpl"
>
<%
static
:
include
path
=
"bookmarks/${template_name}.underscore"
/>
<%
static
:
include
path
=
"bookmarks/${template_name}.underscore"
/>
</script>
</script>
...
...
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