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
3b3b3dcd
Commit
3b3b3dcd
authored
Oct 28, 2014
by
Daniel Friedman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show current unit in unit outline.
TNL-291
parent
a4e1cc48
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
93 additions
and
33 deletions
+93
-33
cms/static/js/spec/views/unit_outline_spec.js
+11
-0
cms/static/js/views/course_outline.js
+3
-10
cms/static/js/views/unit_outline.js
+18
-4
cms/static/js/views/unit_outline_child.js
+34
-0
cms/static/js/views/xblock_outline.js
+26
-18
cms/templates/js/unit-outline.underscore
+1
-1
No files found.
cms/static/js/spec/views/unit_outline_spec.js
View file @
3b3b3dcd
...
...
@@ -88,6 +88,17 @@ define(["jquery", "js/common_helpers/ajax_helpers", "js/common_helpers/template_
expect
(
unitOutlineView
.
$
(
'.list-units'
)).
toExist
();
});
it
(
'highlights the current unit'
,
function
()
{
createUnitOutlineView
(
this
,
createMockXBlockInfo
(
'Mock Unit'
));
$
(
'.outline-unit'
).
each
(
function
(
i
)
{
if
(
$
(
this
).
data
(
'locator'
)
===
model
.
get
(
'id'
))
{
expect
(
$
(
this
)).
toHaveClass
(
'is-current'
);
}
else
{
expect
(
$
(
this
)).
not
.
toHaveClass
(
'is-current'
);
}
});
});
it
(
'can add a unit'
,
function
()
{
var
redirectSpy
;
createUnitOutlineView
(
this
,
createMockXBlockInfo
(
'Mock Unit'
));
...
...
cms/static/js/views/course_outline.js
View file @
3b3b3dcd
...
...
@@ -35,15 +35,8 @@ define(["jquery", "underscore", "js/views/xblock_outline", "js/views/utils/view_
return
!
this
.
model
.
isVertical
();
},
createChildView
:
function
(
xblockInfo
,
parentInfo
,
parentView
)
{
return
new
CourseOutlineView
({
model
:
xblockInfo
,
parentInfo
:
parentInfo
,
initialState
:
this
.
initialState
,
expandedLocators
:
this
.
expandedLocators
,
template
:
this
.
template
,
parentView
:
parentView
||
this
});
getChildViewClass
:
function
()
{
return
CourseOutlineView
;
},
/**
...
...
@@ -112,7 +105,7 @@ define(["jquery", "underscore", "js/views/xblock_outline", "js/views/utils/view_
});
// Fetch the full xblock info for the section and then create a view for it
sectionInfo
.
fetch
().
done
(
function
()
{
sectionView
=
self
.
createChildView
(
sectionInfo
,
self
.
model
,
self
);
sectionView
=
self
.
createChildView
(
sectionInfo
,
self
.
model
,
{
parentView
:
self
}
);
sectionView
.
initialState
=
initialState
;
sectionView
.
expandedLocators
=
self
.
expandedLocators
;
sectionView
.
render
();
...
...
cms/static/js/views/unit_outline.js
View file @
3b3b3dcd
...
...
@@ -3,9 +3,8 @@
* the ancestors of the unit along with its direct siblings. It also has a single "New Unit"
* button to allow a new sibling unit to be added.
*/
define
([
'js/views/xblock_outline'
],
function
(
XBlockOutlineView
)
{
define
([
'underscore'
,
'js/views/xblock_outline'
,
'js/views/unit_outline_child'
],
function
(
_
,
XBlockOutlineView
,
UnitOutlineChildView
)
{
var
UnitOutlineView
=
XBlockOutlineView
.
extend
({
// takes XBlockInfo as a model
...
...
@@ -29,7 +28,11 @@ define(['js/views/xblock_outline'],
// i.e. subsection and then section.
for
(
i
=
ancestors
.
length
-
1
;
i
>=
0
;
i
--
)
{
ancestor
=
ancestors
[
i
];
ancestorView
=
this
.
createChildView
(
ancestor
,
previousAncestor
,
ancestorView
);
ancestorView
=
this
.
createChildView
(
ancestor
,
previousAncestor
,
{
parentView
:
ancestorView
,
currentUnitId
:
this
.
model
.
get
(
'id'
)}
);
ancestorView
.
render
();
listElement
.
append
(
ancestorView
.
$el
);
previousAncestor
=
ancestor
;
...
...
@@ -37,6 +40,17 @@ define(['js/views/xblock_outline'],
}
}
return
ancestorView
;
},
getChildViewClass
:
function
()
{
return
UnitOutlineChildView
;
},
getTemplateContext
:
function
()
{
return
_
.
extend
(
XBlockOutlineView
.
prototype
.
getTemplateContext
.
call
(
this
),
{
currentUnitId
:
this
.
model
.
get
(
'id'
)}
);
}
});
...
...
cms/static/js/views/unit_outline_child.js
0 → 100644
View file @
3b3b3dcd
/**
* The UnitOutlineChildView is used to render each Section,
* Subsection, and Unit within the Unit Outline component on the unit
* page.
*/
define
([
'underscore'
,
'js/views/xblock_outline'
],
function
(
_
,
XBlockOutlineView
)
{
var
UnitOutlineChildView
=
XBlockOutlineView
.
extend
({
initialize
:
function
()
{
XBlockOutlineView
.
prototype
.
initialize
.
call
(
this
);
this
.
currentUnitId
=
this
.
options
.
currentUnitId
;
},
getTemplateContext
:
function
()
{
return
_
.
extend
(
XBlockOutlineView
.
prototype
.
getTemplateContext
.
call
(
this
),
{
currentUnitId
:
this
.
currentUnitId
}
);
},
getChildViewClass
:
function
()
{
return
UnitOutlineChildView
;
},
createChildView
:
function
(
childInfo
,
parentInfo
,
options
)
{
options
=
_
.
isUndefined
(
options
)
?
{}
:
options
;
return
XBlockOutlineView
.
prototype
.
createChildView
.
call
(
this
,
childInfo
,
parentInfo
,
_
.
extend
(
options
,
{
currentUnitId
:
this
.
currentUnitId
})
);
}
});
return
UnitOutlineChildView
;
});
// end define()
cms/static/js/views/xblock_outline.js
View file @
3b3b3dcd
...
...
@@ -54,6 +54,15 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "js/views/utils/
},
renderTemplate
:
function
()
{
var
html
=
this
.
template
(
this
.
getTemplateContext
());
if
(
this
.
parentInfo
)
{
this
.
setElement
(
$
(
html
));
}
else
{
this
.
$el
.
html
(
html
);
}
},
getTemplateContext
:
function
()
{
var
xblockInfo
=
this
.
model
,
childInfo
=
xblockInfo
.
get
(
'child_info'
),
parentInfo
=
this
.
parentInfo
,
...
...
@@ -62,7 +71,6 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "js/views/utils/
parentType
=
parentInfo
?
XBlockViewUtils
.
getXBlockType
(
parentInfo
.
get
(
'category'
))
:
null
,
addChildName
=
null
,
defaultNewChildName
=
null
,
html
,
isCollapsed
=
this
.
shouldRenderChildren
()
&&
!
this
.
shouldExpandChildren
();
if
(
childInfo
)
{
addChildName
=
interpolate
(
gettext
(
'New %(component_type)s'
),
{
...
...
@@ -70,7 +78,7 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "js/views/utils/
},
true
);
defaultNewChildName
=
childInfo
.
display_name
;
}
html
=
this
.
template
(
{
return
{
xblockInfo
:
xblockInfo
,
visibilityClass
:
XBlockViewUtils
.
getXBlockVisibilityClass
(
xblockInfo
.
get
(
'visibility_state'
)),
typeListClass
:
XBlockViewUtils
.
getXBlockListTypeClass
(
xblockType
),
...
...
@@ -86,20 +94,15 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "js/views/utils/
includesChildren
:
this
.
shouldRenderChildren
(),
hasExplicitStaffLock
:
this
.
model
.
get
(
'has_explicit_staff_lock'
),
staffOnlyMessage
:
this
.
model
.
get
(
'staff_only_message'
)
});
if
(
this
.
parentInfo
)
{
this
.
setElement
(
$
(
html
));
}
else
{
this
.
$el
.
html
(
html
);
}
};
},
renderChildren
:
function
()
{
var
self
=
this
,
xblock
Info
=
this
.
model
;
if
(
xblock
Info
.
get
(
'child_info'
))
{
_
.
each
(
this
.
model
.
get
(
'child_info'
).
children
,
function
(
child
)
{
var
childOutlineView
=
self
.
createChildView
(
child
,
xblock
Info
);
parent
Info
=
this
.
model
;
if
(
parent
Info
.
get
(
'child_info'
))
{
_
.
each
(
this
.
model
.
get
(
'child_info'
).
children
,
function
(
child
Info
)
{
var
childOutlineView
=
self
.
createChildView
(
child
Info
,
parent
Info
);
childOutlineView
.
render
();
self
.
addChildView
(
childOutlineView
);
});
...
...
@@ -182,15 +185,20 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "js/views/utils/
return
true
;
},
createChildView
:
function
(
xblockInfo
,
parentInfo
,
parentView
)
{
return
new
XBlockOutlineView
({
model
:
xblockInfo
,
getChildViewClass
:
function
()
{
return
XBlockOutlineView
;
},
createChildView
:
function
(
childInfo
,
parentInfo
,
options
)
{
var
viewClass
=
this
.
getChildViewClass
();
return
new
viewClass
(
_
.
extend
({
model
:
childInfo
,
parentInfo
:
parentInfo
,
parentView
:
this
,
initialState
:
this
.
initialState
,
expandedLocators
:
this
.
expandedLocators
,
template
:
this
.
template
,
parentView
:
parentView
||
this
});
template
:
this
.
template
},
options
));
},
onSync
:
function
(
event
)
{
...
...
cms/templates/js/unit-outline.underscore
View file @
3b3b3dcd
<% if (parentInfo) { %>
<li class="outline-item outline-<%= xblockType %> <%= visibilityClass %>"
<li class="outline-item outline-<%= xblockType %> <%= visibilityClass %>
<%= xblockInfo.get('id') === currentUnitId ? 'is-current' : '' %>
"
data-parent="<%= parentInfo.get('id') %>" data-locator="<%= xblockInfo.get('id') %>">
<div class="<%= xblockType %>-header">
<h3 class="<%= xblockType %>-header-details">
...
...
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