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
d2b61f14
Commit
d2b61f14
authored
Jul 15, 2014
by
Andy Armstrong
Committed by
cahrens
Aug 07, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support faster deletes of sections
parent
20782f04
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
17 deletions
+45
-17
cms/djangoapps/contentstore/views/tests/test_course_index.py
+1
-1
cms/djangoapps/contentstore/views/tests/test_item.py
+1
-1
cms/static/js/spec/views/pages/course_outline_spec.js
+16
-0
cms/static/js/views/course_outline.js
+13
-0
cms/static/js/views/xblock_outline.js
+14
-15
No files found.
cms/djangoapps/contentstore/views/tests/test_course_index.py
View file @
d2b61f14
...
@@ -259,7 +259,7 @@ class TestCourseOutline(CourseTestCase):
...
@@ -259,7 +259,7 @@ class TestCourseOutline(CourseTestCase):
def
test_course_outline_initial_state
(
self
):
def
test_course_outline_initial_state
(
self
):
course_module
=
modulestore
()
.
get_item
(
self
.
course
.
location
)
course_module
=
modulestore
()
.
get_item
(
self
.
course
.
location
)
course_structure
=
create_xblock_info
(
course_structure
=
create_xblock_info
(
course_module
,
course_module
,
include_child_info
=
True
,
include_child_info
=
True
,
include_children_predicate
=
lambda
xblock
:
not
xblock
.
category
==
'vertical'
include_children_predicate
=
lambda
xblock
:
not
xblock
.
category
==
'vertical'
)
)
...
...
cms/djangoapps/contentstore/views/tests/test_item.py
View file @
d2b61f14
...
@@ -1190,7 +1190,7 @@ class TestXBlockInfo(ItemTest):
...
@@ -1190,7 +1190,7 @@ class TestXBlockInfo(ItemTest):
for
child_response
in
xblock_info
[
'child_info'
][
'children'
]:
for
child_response
in
xblock_info
[
'child_info'
][
'children'
]:
self
.
validate_xblock_info_consistency
(
self
.
validate_xblock_info_consistency
(
child_response
,
child_response
,
has_child_info
=
(
not
child_response
.
get
(
'child_info'
,
None
)
==
None
)
has_child_info
=
(
not
child_response
.
get
(
'child_info'
,
None
)
is
None
)
)
)
else
:
else
:
self
.
assertIsNone
(
xblock_info
.
get
(
'child_info'
,
None
))
self
.
assertIsNone
(
xblock_info
.
get
(
'child_info'
,
None
))
cms/static/js/spec/views/pages/course_outline_spec.js
View file @
d2b61f14
...
@@ -245,6 +245,22 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
...
@@ -245,6 +245,22 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
describe
(
"Section"
,
function
()
{
describe
(
"Section"
,
function
()
{
it
(
'can be deleted'
,
function
()
{
it
(
'can be deleted'
,
function
()
{
var
promptSpy
=
view_helpers
.
createPromptSpy
(),
requestCount
;
createCourseOutlinePage
(
this
,
createMockCourseJSON
(
'mock-course'
,
'Mock Course'
,
[
createMockSectionJSON
(
'mock-section'
,
'Mock Section'
,
[]),
createMockSectionJSON
(
'mock-section-2'
,
'Mock Section 2'
,
[])
]));
outlinePage
.
$
(
'.outline-item-section .delete-button'
).
first
().
click
();
view_helpers
.
confirmPrompt
(
promptSpy
);
requestCount
=
requests
.
length
;
create_sinon
.
expectJsonRequest
(
requests
,
'DELETE'
,
'/xblock/mock-section'
);
create_sinon
.
respondWithJson
(
requests
,
{});
expect
(
requests
.
length
).
toBe
(
requestCount
);
// No fetch should be performed
expect
(
outlinePage
.
$
(
'[data-locator="mock-section"]'
)).
not
.
toExist
();
expect
(
outlinePage
.
$
(
'[data-locator="mock-section-2"]'
)).
toExist
();
});
it
(
'can be deleted if it is the only section'
,
function
()
{
var
promptSpy
=
view_helpers
.
createPromptSpy
();
var
promptSpy
=
view_helpers
.
createPromptSpy
();
createCourseOutlinePage
(
this
,
mockSingleSectionCourseJSON
);
createCourseOutlinePage
(
this
,
mockSingleSectionCourseJSON
);
outlinePage
.
$
(
'.outline-item-section .delete-button'
).
click
();
outlinePage
.
$
(
'.outline-item-section .delete-button'
).
click
();
...
...
cms/static/js/views/course_outline.js
View file @
d2b61f14
...
@@ -117,6 +117,19 @@ define(["jquery", "underscore", "js/views/xblock_outline", "js/views/utils/view_
...
@@ -117,6 +117,19 @@ define(["jquery", "underscore", "js/views/xblock_outline", "js/views/utils/view_
}
}
},
},
onChildDeleted
:
function
(
childView
)
{
var
xblockInfo
=
this
.
model
,
childCategory
=
childView
.
model
.
get
(
'category'
),
children
=
xblockInfo
.
get
(
'child_info'
)
&&
xblockInfo
.
get
(
'child_info'
).
children
;
// If deleting a section that isn't the final one, just remove it for efficiency
// as it cannot visually effect the other sections.
if
(
childCategory
===
'chapter'
&&
children
&&
children
.
length
>
1
)
{
childView
.
$el
.
remove
();
}
else
{
this
.
refresh
();
}
},
createNewItemViewState
:
function
(
locator
,
scrollOffset
)
{
createNewItemViewState
:
function
(
locator
,
scrollOffset
)
{
return
{
return
{
locator_to_show
:
locator
,
locator_to_show
:
locator
,
...
...
cms/static/js/views/xblock_outline.js
View file @
d2b61f14
...
@@ -135,10 +135,7 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "js/views/utils/
...
@@ -135,10 +135,7 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "js/views/utils/
*/
*/
addButtonActions
:
function
(
element
)
{
addButtonActions
:
function
(
element
)
{
var
self
=
this
;
var
self
=
this
;
element
.
find
(
'.delete-button'
).
click
(
function
(
event
)
{
element
.
find
(
'.delete-button'
).
click
(
_
.
bind
(
this
.
handleDeleteEvent
,
this
));
event
.
preventDefault
();
self
.
deleteXBlock
(
$
(
event
.
target
));
});
element
.
find
(
'.add-button'
).
click
(
_
.
bind
(
this
.
handleAddEvent
,
this
));
element
.
find
(
'.add-button'
).
click
(
_
.
bind
(
this
.
handleAddEvent
,
this
));
},
},
...
@@ -203,6 +200,14 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "js/views/utils/
...
@@ -203,6 +200,14 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "js/views/utils/
this
.
initialState
=
null
;
this
.
initialState
=
null
;
},
},
/**
* Refresh the view's model from the server, which will cause the view to refresh.
* @returns {jQuery promise} A promise representing the refresh operation.
*/
refresh
:
function
()
{
return
this
.
model
.
fetch
();
},
onChildAdded
:
function
(
locator
,
category
)
{
onChildAdded
:
function
(
locator
,
category
)
{
// For units, redirect to the new page, and for everything else just refresh inline.
// For units, redirect to the new page, and for everything else just refresh inline.
if
(
category
===
'vertical'
)
{
if
(
category
===
'vertical'
)
{
...
@@ -220,23 +225,17 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "js/views/utils/
...
@@ -220,23 +225,17 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "js/views/utils/
this
.
refresh
();
this
.
refresh
();
},
},
deleteXBlock
:
function
()
{
handleDeleteEvent
:
function
(
event
)
{
var
parentView
=
this
.
parentView
;
var
self
=
this
,
parentView
=
this
.
parentView
;
event
.
preventDefault
();
XBlockViewUtils
.
deleteXBlock
(
this
.
model
).
done
(
function
()
{
XBlockViewUtils
.
deleteXBlock
(
this
.
model
).
done
(
function
()
{
if
(
parentView
)
{
if
(
parentView
)
{
parentView
.
onChildDeleted
();
parentView
.
onChildDeleted
(
self
,
event
);
}
}
});
});
},
},
/**
* Refresh the view's model from the server, which will cause the view to refresh.
* @returns {jQuery promise} A promise representing the refresh operation.
*/
refresh
:
function
()
{
return
this
.
model
.
fetch
();
},
handleAddEvent
:
function
(
event
)
{
handleAddEvent
:
function
(
event
)
{
var
self
=
this
,
var
self
=
this
,
target
=
$
(
event
.
target
),
target
=
$
(
event
.
target
),
...
...
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