Add Unit & Nested blocks to breadcrumbs
hide links that has no url Hide sequence nav in nested pages Improve doc
This commit is contained in:
@@ -122,10 +122,36 @@ def container_handler(request, usage_key_string):
|
||||
|
||||
component_templates = get_component_templates(course)
|
||||
ancestor_xblocks = []
|
||||
parent = get_parent_xblock(xblock)
|
||||
action = request.GET.get('action', 'view')
|
||||
|
||||
is_unit_page = is_unit(xblock)
|
||||
unit = xblock if is_unit_page else get_parent_xblock(xblock)
|
||||
unit = xblock if is_unit_page else None
|
||||
|
||||
is_first = True
|
||||
block = xblock
|
||||
|
||||
# Build the breadcrumbs and find the ``Unit`` ancestor
|
||||
# if it is not the immediate parent.
|
||||
while parent:
|
||||
|
||||
if unit is None and is_unit(block):
|
||||
unit = block
|
||||
|
||||
# add all to nav except current xblock page
|
||||
if xblock != block:
|
||||
current_block = {
|
||||
'title': block.display_name_with_default,
|
||||
'children': parent.get_children(),
|
||||
'is_last': is_first
|
||||
}
|
||||
is_first = False
|
||||
ancestor_xblocks.append(current_block)
|
||||
|
||||
block = parent
|
||||
parent = get_parent_xblock(parent)
|
||||
|
||||
ancestor_xblocks.reverse()
|
||||
|
||||
assert unit is not None, "Could not determine unit page"
|
||||
subsection = get_parent_xblock(unit)
|
||||
@@ -134,15 +160,6 @@ def container_handler(request, usage_key_string):
|
||||
section = get_parent_xblock(subsection)
|
||||
assert section is not None, "Could not determine ancestor section from unit " + six.text_type(unit.location)
|
||||
|
||||
# build the breadcrumbs
|
||||
for block in (section, subsection):
|
||||
parent = get_parent_xblock(block)
|
||||
ancestor_xblocks.append({
|
||||
'title': block.display_name_with_default,
|
||||
'children': parent.get_children(),
|
||||
'is_last': block.category == 'sequential'
|
||||
})
|
||||
|
||||
# for the sequence navigator
|
||||
prev_url, next_url = get_sibling_urls(subsection)
|
||||
# these are quoted here because they'll end up in a query string on the page,
|
||||
|
||||
@@ -64,7 +64,7 @@ from openedx.core.djangolib.markup import HTML, Text
|
||||
$('.seq_new_button').click(function(evt) {
|
||||
evt.preventDefault();
|
||||
XBlockUtils.addXBlock($(evt.target)).done(function(locator) {
|
||||
ViewUtils.redirect('/container/' + locator + '?action=new');
|
||||
ViewUtils.redirect('/container/' + locator + '?action=new');
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
@@ -100,9 +100,17 @@ from openedx.core.djangolib.markup import HTML, Text
|
||||
<div class="nav-sub">
|
||||
<ul>
|
||||
% for child in block['children']:
|
||||
<li class="nav-item">
|
||||
<a href="${xblock_studio_url(child)}">${child.display_name_with_default}</a>
|
||||
</li>
|
||||
<%
|
||||
# Not all xblock has their own studio page
|
||||
# Check if siblings has any url to their own studio
|
||||
# page, otherwise avoid including them in dropdown.
|
||||
url = xblock_studio_url(child)
|
||||
%>
|
||||
% if url:
|
||||
<li class="nav-item">
|
||||
<a href="${url}">${child.display_name_with_default}</a>
|
||||
</li>
|
||||
% endif
|
||||
% endfor
|
||||
</ul>
|
||||
</div>
|
||||
@@ -123,6 +131,7 @@ from openedx.core.djangolib.markup import HTML, Text
|
||||
<nav class="nav-actions" aria-label="${_('Page Actions')}">
|
||||
<h3 class="sr">${_("Page Actions")}</h3>
|
||||
<ul>
|
||||
## Hide the sequence navigation when we've browsed into a child of the unit, e.g. showing the child blocks of a problem-builder xblock
|
||||
% if is_unit_page:
|
||||
<li class="action-item action-view nav-item">
|
||||
<a href="${published_preview_link}" class="button button-view action-button is-disabled" aria-disabled="true" rel="external" title="${_('Open the courseware in the LMS')}">
|
||||
@@ -144,7 +153,9 @@ from openedx.core.djangolib.markup import HTML, Text
|
||||
% endif
|
||||
</ul>
|
||||
</nav>
|
||||
% if is_unit_page:
|
||||
<div id="sequence-nav"></div>
|
||||
% endif
|
||||
</header>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user