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
37da3999
Commit
37da3999
authored
Apr 18, 2014
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update unit test based on changes in master.
parent
8e00f6dc
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
292 additions
and
388 deletions
+292
-388
CHANGELOG.rst
+2
-0
cms/static/js/spec/views/container_spec.js
+67
-53
cms/static/js/spec/views/modals/edit_xblock_spec.js
+1
-1
cms/static/js/views/container.js
+13
-11
cms/templates/js/mock/mock-container-xblock.underscore
+209
-114
cms/templates/js/mock/mock-container.underscore
+0
-209
No files found.
CHANGELOG.rst
View file @
37da3999
...
@@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes,
...
@@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes,
in roughly chronological order, most recent first. Add your entries at or near
in roughly chronological order, most recent first. Add your entries at or near
the top. Include a label indicating the component affected.
the top. Include a label indicating the component affected.
Studio: Add drag-and-drop support to the container page. STUD-1309.
Common: Add extensible third-party auth module.
Common: Add extensible third-party auth module.
Blades: Handle situation if no response were sent from XQueue to LMS in Matlab
Blades: Handle situation if no response were sent from XQueue to LMS in Matlab
...
...
cms/static/js/spec/views/container_spec.js
View file @
37da3999
define
([
"jquery"
,
"js/spec/create_sinon"
,
"URI"
,
"js/views/container"
,
"js/models/xblock_info"
,
define
([
"jquery"
,
"js/spec
_helpers
/create_sinon"
,
"URI"
,
"js/views/container"
,
"js/models/xblock_info"
,
"js/views/feedback_notification"
,
"jquery.simulate"
,
"js/views/feedback_notification"
,
"jquery.simulate"
,
"xmodule"
,
"coffee/src/main"
,
"xblock/cms.runtime.v1"
],
"xmodule"
,
"coffee/src/main"
,
"xblock/cms.runtime.v1"
],
function
(
$
,
create_sinon
,
URI
,
ContainerView
,
XBlockInfo
,
Notification
)
{
function
(
$
,
create_sinon
,
URI
,
ContainerView
,
XBlockInfo
,
Notification
)
{
...
@@ -7,24 +7,26 @@ define([ "jquery", "js/spec/create_sinon", "URI", "js/views/container", "js/mode
...
@@ -7,24 +7,26 @@ define([ "jquery", "js/spec/create_sinon", "URI", "js/views/container", "js/mode
describe
(
"Supports reordering components"
,
function
()
{
describe
(
"Supports reordering components"
,
function
()
{
var
model
,
containerView
,
mockContainerHTML
,
respondWithMockXBlockFragment
;
var
model
,
containerView
,
mockContainerHTML
,
respondWithMockXBlockFragment
,
init
,
dragHandle
,
verifyRequest
,
verifyNumReorderCalls
,
respondToRequest
,
// TODO: this will all need to be updated according to Andy's mock HTML,
rootLocator
=
'testCourse/branch/draft/split_test/splitFFF'
,
// and locators should be draft.
containerTestUrl
=
'/xblock/'
+
rootLocator
,
var
splitTestUrl
=
"/xblock/ccc.dd.ee/branch/draft/block/AB_Test"
;
var
groupAUrl
=
"/xblock/ccc.dd.ee/branch/published/block/group_a"
;
groupAUrl
=
"/xblock/locator-group-A"
,
var
groupA
=
"ccc.dd.ee/branch/published/block/group_a"
;
groupA
=
"locator-group-A"
,
var
groupAText
=
"ccc.dd.ee/branch/published/block/html_4658c0f4c400"
;
groupAComponent1
=
"locator-component-A1"
,
var
groupAVideo
=
"ccc.dd.ee/branch/published/block/group_a_video"
;
groupAComponent2
=
"locator-component-A2"
,
groupAComponent3
=
"locator-component-A3"
,
var
groupBUrl
=
"/xblock/ccc.dd.ee/branch/published/block/group_b"
;
groupBUrl
=
"/xblock/locator-group-B"
,
var
groupB
=
"ccc.dd.ee/branch/published/block/group_b"
;
groupB
=
"locator-group-B"
,
var
groupBText
=
"ccc.dd.ee/branch/published/block/html_b5c18016d991"
;
groupBComponent1
=
"locator-component-B1"
,
var
groupBProblem
=
"ccc.dd.ee/branch/published/block/Checkboxes"
;
groupBComponent2
=
"locator-component-B2"
,
groupBComponent3
=
"locator-component-B3"
;
// TODO: switch to using Andy's mock container view files (which uses mock xblocks).
rootLocator
=
'testCourse/branch/draft/split_test/splitFFF'
;
mockContainerHTML
=
readFixtures
(
'mock/mock-container.underscore'
);
mockContainerHTML
=
readFixtures
(
'mock/mock-container
-xblock
.underscore'
);
respondWithMockXBlockFragment
=
function
(
requests
,
response
)
{
respondWithMockXBlockFragment
=
function
(
requests
,
response
)
{
var
requestIndex
=
requests
.
length
-
1
;
var
requestIndex
=
requests
.
length
-
1
;
...
@@ -32,15 +34,17 @@ define([ "jquery", "js/spec/create_sinon", "URI", "js/views/container", "js/mode
...
@@ -32,15 +34,17 @@ define([ "jquery", "js/spec/create_sinon", "URI", "js/views/container", "js/mode
};
};
beforeEach
(
function
()
{
beforeEach
(
function
()
{
setFixtures
(
'<div class="wrapper-xblock level-page" data-locator="'
+
rootLocator
+
'"></div>'
);
model
=
new
XBlockInfo
({
model
=
new
XBlockInfo
({
id
:
'testCourse/branch/draft/split_test/splitFFF'
,
id
:
rootLocator
,
display_name
:
'Test AB Test'
,
display_name
:
'Test AB Test'
,
category
:
'split_test'
category
:
'split_test'
});
});
containerView
=
new
ContainerView
({
containerView
=
new
ContainerView
({
model
:
model
,
model
:
model
,
view
:
'container_preview'
view
:
'container_preview'
,
el
:
$
(
'.wrapper-xblock'
)
});
});
});
});
...
@@ -48,7 +52,7 @@ define([ "jquery", "js/spec/create_sinon", "URI", "js/views/container", "js/mode
...
@@ -48,7 +52,7 @@ define([ "jquery", "js/spec/create_sinon", "URI", "js/views/container", "js/mode
containerView
.
remove
();
containerView
.
remove
();
});
});
var
init
=
function
(
caller
)
{
init
=
function
(
caller
)
{
var
requests
=
create_sinon
.
requests
(
caller
);
var
requests
=
create_sinon
.
requests
(
caller
);
containerView
.
render
();
containerView
.
render
();
...
@@ -61,27 +65,29 @@ define([ "jquery", "js/spec/create_sinon", "URI", "js/views/container", "js/mode
...
@@ -61,27 +65,29 @@ define([ "jquery", "js/spec/create_sinon", "URI", "js/views/container", "js/mode
return
requests
;
return
requests
;
};
};
var
dragHandle
=
function
(
index
,
dy
)
{
dragHandle
=
function
(
index
,
dy
)
{
containerView
.
$el
.
find
(
".drag-handle:eq("
+
index
+
")"
).
simulate
(
"drag"
,
{
dy
:
dy
});
var
handle
=
containerView
.
$
(
".drag-handle:eq("
+
index
+
")"
);
handle
.
simulate
(
"drag"
,
{
dy
:
dy
});
};
};
var
verifyRequest
=
function
(
requests
,
reorderCallIndex
,
expectedURL
,
expectedChildren
)
{
verifyRequest
=
function
(
requests
,
reorderCallIndex
,
expectedURL
,
expectedChildren
)
{
var
request
,
children
,
i
;
// 0th call is the response to the initial render call to get HTML.
// 0th call is the response to the initial render call to get HTML.
var
request
=
requests
[
reorderCallIndex
+
1
];
request
=
requests
[
reorderCallIndex
+
1
];
expect
(
request
.
url
).
toEqual
(
expectedURL
);
expect
(
request
.
url
).
toEqual
(
expectedURL
);
var
children
=
(
JSON
.
parse
(
request
.
requestBody
)).
children
;
children
=
(
JSON
.
parse
(
request
.
requestBody
)).
children
;
expect
(
children
.
length
).
toEqual
(
expectedChildren
.
length
);
expect
(
children
.
length
).
toEqual
(
expectedChildren
.
length
);
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
children
.
length
;
i
++
)
{
expect
(
children
[
i
]).
toEqual
(
expectedChildren
[
i
]);
expect
(
children
[
i
]).
toEqual
(
expectedChildren
[
i
]);
}
}
};
};
v
ar
v
erifyNumReorderCalls
=
function
(
requests
,
expectedCalls
)
{
verifyNumReorderCalls
=
function
(
requests
,
expectedCalls
)
{
// Number of calls will be 1 more than expected because of the initial render call to get HTML.
// Number of calls will be 1 more than expected because of the initial render call to get HTML.
expect
(
requests
.
length
).
toEqual
(
expectedCalls
+
1
);
expect
(
requests
.
length
).
toEqual
(
expectedCalls
+
1
);
};
};
var
respondToRequest
=
function
(
requests
,
reorderCallIndex
,
status
)
{
respondToRequest
=
function
(
requests
,
reorderCallIndex
,
status
)
{
// Number of calls will be 1 more than expected because of the initial render call to get HTML.
// Number of calls will be 1 more than expected because of the initial render call to get HTML.
requests
[
reorderCallIndex
+
1
].
respond
(
status
);
requests
[
reorderCallIndex
+
1
].
respond
(
status
);
};
};
...
@@ -89,68 +95,70 @@ define([ "jquery", "js/spec/create_sinon", "URI", "js/views/container", "js/mode
...
@@ -89,68 +95,70 @@ define([ "jquery", "js/spec/create_sinon", "URI", "js/views/container", "js/mode
it
(
'does nothing if item not moved far enough'
,
function
()
{
it
(
'does nothing if item not moved far enough'
,
function
()
{
var
requests
=
init
(
this
);
var
requests
=
init
(
this
);
// Drag the first thing in Group A (text component) down very slightly, but not past second thing.
// Drag the first thing in Group A (text component) down very slightly, but not past second thing.
dragHandle
(
1
,
5
);
dragHandle
(
2
,
5
);
verifyNumReorderCalls
(
requests
,
0
);
verifyNumReorderCalls
(
requests
,
0
);
});
});
it
(
'can reorder within a group'
,
function
()
{
it
(
'can reorder within a group'
,
function
()
{
var
requests
=
init
(
this
);
var
requests
=
init
(
this
);
// Drag the first
thing in Group A (text component) after the second thing (video).
// Drag the first
component in Group A to the end
dragHandle
(
1
,
80
);
dragHandle
(
2
,
80
);
respondToRequest
(
requests
,
0
,
200
);
respondToRequest
(
requests
,
0
,
200
);
verifyNumReorderCalls
(
requests
,
1
);
verifyNumReorderCalls
(
requests
,
1
);
verifyRequest
(
requests
,
0
,
groupAUrl
,
[
groupA
Video
,
groupAText
]);
verifyRequest
(
requests
,
0
,
groupAUrl
,
[
groupA
Component2
,
groupAComponent3
,
groupAComponent1
]);
});
});
it
(
'can drag from one group to another'
,
function
()
{
it
(
'can drag from one group to another'
,
function
()
{
var
requests
=
init
(
this
);
var
requests
=
init
(
this
);
// Drag the first
thing in Group A (text component)
into the second group.
// Drag the first
component in Group A
into the second group.
dragHandle
(
1
,
2
00
);
dragHandle
(
2
,
3
00
);
respondToRequest
(
requests
,
0
,
200
);
respondToRequest
(
requests
,
0
,
200
);
respondToRequest
(
requests
,
1
,
200
);
respondToRequest
(
requests
,
1
,
200
);
// Will get an event to move into Group B and an event to remove from Group A.
// Will get an event to move into Group B and an event to remove from Group A.
verifyNumReorderCalls
(
requests
,
2
);
verifyNumReorderCalls
(
requests
,
2
);
verifyRequest
(
requests
,
0
,
groupBUrl
,
[
groupBText
,
groupAText
,
groupBProblem
]);
verifyRequest
(
requests
,
0
,
groupBUrl
,
verifyRequest
(
requests
,
1
,
groupAUrl
,
[
groupAVideo
]);
[
groupBComponent1
,
groupBComponent2
,
groupAComponent1
,
groupBComponent3
]);
verifyRequest
(
requests
,
1
,
groupAUrl
,
[
groupAComponent2
,
groupAComponent3
]);
});
});
it
(
'does not remove from old group if addition to new group fails'
,
function
()
{
it
(
'does not remove from old group if addition to new group fails'
,
function
()
{
var
requests
=
init
(
this
);
var
requests
=
init
(
this
);
// Drag the first
thing in Group A (text component)
into the second group.
// Drag the first
component in Group A
into the second group.
dragHandle
(
1
,
2
00
);
dragHandle
(
2
,
3
00
);
respondToRequest
(
requests
,
0
,
500
);
respondToRequest
(
requests
,
0
,
500
);
// Send failure for addition to new group-- no removal event should be received.
// Send failure for addition to new group-- no removal event should be received.
verifyNumReorderCalls
(
requests
,
1
);
verifyNumReorderCalls
(
requests
,
1
);
verifyRequest
(
requests
,
0
,
groupBUrl
,
[
groupBText
,
groupAText
,
groupBProblem
]);
verifyRequest
(
requests
,
0
,
groupBUrl
,
[
groupBComponent1
,
groupBComponent2
,
groupAComponent1
,
groupBComponent3
]);
});
});
it
(
'can swap group A and group B'
,
function
()
{
it
(
'can swap group A and group B'
,
function
()
{
var
requests
=
init
(
this
);
var
requests
=
init
(
this
);
// Drag Group B before group A.
// Drag Group B before group A.
dragHandle
(
3
,
-
2
00
);
dragHandle
(
5
,
-
3
00
);
respondToRequest
(
requests
,
0
,
200
);
respondToRequest
(
requests
,
0
,
200
);
verifyNumReorderCalls
(
requests
,
1
);
verifyNumReorderCalls
(
requests
,
1
);
verifyRequest
(
requests
,
0
,
split
TestUrl
,
[
groupB
,
groupA
]);
verifyRequest
(
requests
,
0
,
container
TestUrl
,
[
groupB
,
groupA
]);
});
});
it
(
'can drag a component to the top level, and nest one group in another'
,
function
()
{
it
(
'can drag a component to the top level, and nest one group in another'
,
function
()
{
var
requests
=
init
(
this
);
var
requests
=
init
(
this
);
// Drag text item in Group A to the top level (in first position).
// Drag text item in Group A to the top level (in first position).
dragHandle
(
1
,
-
2
0
);
dragHandle
(
2
,
-
4
0
);
respondToRequest
(
requests
,
0
,
200
);
respondToRequest
(
requests
,
0
,
200
);
respondToRequest
(
requests
,
1
,
200
);
respondToRequest
(
requests
,
1
,
200
);
verifyNumReorderCalls
(
requests
,
2
);
verifyNumReorderCalls
(
requests
,
2
);
verifyRequest
(
requests
,
0
,
splitTestUrl
,
[
groupAText
,
groupA
,
groupB
]);
verifyRequest
(
requests
,
0
,
containerTestUrl
,
[
groupAComponent1
,
groupA
,
groupB
]);
verifyRequest
(
requests
,
1
,
groupAUrl
,
[
groupA
Video
]);
verifyRequest
(
requests
,
1
,
groupAUrl
,
[
groupA
Component2
,
groupAComponent3
]);
// Drag Group A
(only contains video now)
into Group B.
// Drag Group A into Group B.
dragHandle
(
1
,
150
);
dragHandle
(
1
,
150
);
respondToRequest
(
requests
,
2
,
200
);
respondToRequest
(
requests
,
2
,
200
);
respondToRequest
(
requests
,
3
,
200
);
respondToRequest
(
requests
,
3
,
200
);
verifyNumReorderCalls
(
requests
,
4
);
verifyNumReorderCalls
(
requests
,
4
);
verifyRequest
(
requests
,
2
,
groupBUrl
,
[
groupB
Text
,
groupA
,
groupBProblem
]);
verifyRequest
(
requests
,
2
,
groupBUrl
,
[
groupB
Component1
,
groupA
,
groupBComponent2
]);
verifyRequest
(
requests
,
3
,
splitTestUrl
,
[
groupAText
,
groupB
]);
verifyRequest
(
requests
,
3
,
containerTestUrl
,
[
groupAComponent1
,
groupB
]);
});
});
describe
(
"Shows a saving message"
,
function
()
{
describe
(
"Shows a saving message"
,
function
()
{
...
@@ -163,13 +171,16 @@ define([ "jquery", "js/spec/create_sinon", "URI", "js/views/container", "js/mode
...
@@ -163,13 +171,16 @@ define([ "jquery", "js/spec/create_sinon", "URI", "js/views/container", "js/mode
});
});
it
(
'hides saving message upon success'
,
function
()
{
it
(
'hides saving message upon success'
,
function
()
{
var
requests
=
init
(
this
);
var
requests
,
savingOptions
;
// Drag text item in Group A to the top level (in first position).
requests
=
init
(
this
);
dragHandle
(
1
,
-
20
);
// Drag the first component in Group A into the second group.
dragHandle
(
2
,
200
);
expect
(
savingSpies
.
constructor
).
toHaveBeenCalled
();
expect
(
savingSpies
.
constructor
).
toHaveBeenCalled
();
expect
(
savingSpies
.
show
).
toHaveBeenCalled
();
expect
(
savingSpies
.
show
).
toHaveBeenCalled
();
expect
(
savingSpies
.
hide
).
not
.
toHaveBeenCalled
();
expect
(
savingSpies
.
hide
).
not
.
toHaveBeenCalled
();
var
savingOptions
=
savingSpies
.
constructor
.
mostRecentCall
.
args
[
0
];
savingOptions
=
savingSpies
.
constructor
.
mostRecentCall
.
args
[
0
];
expect
(
savingOptions
.
title
).
toMatch
(
/Saving/
);
expect
(
savingOptions
.
title
).
toMatch
(
/Saving/
);
respondToRequest
(
requests
,
0
,
200
);
respondToRequest
(
requests
,
0
,
200
);
...
@@ -181,8 +192,10 @@ define([ "jquery", "js/spec/create_sinon", "URI", "js/views/container", "js/mode
...
@@ -181,8 +192,10 @@ define([ "jquery", "js/spec/create_sinon", "URI", "js/views/container", "js/mode
it
(
'does not hide saving message if failure'
,
function
()
{
it
(
'does not hide saving message if failure'
,
function
()
{
var
requests
=
init
(
this
);
var
requests
=
init
(
this
);
// Drag text item in Group A to the top level (in first position).
dragHandle
(
1
,
-
20
);
// Drag the first component in Group A into the second group.
dragHandle
(
2
,
200
);
expect
(
savingSpies
.
constructor
).
toHaveBeenCalled
();
expect
(
savingSpies
.
constructor
).
toHaveBeenCalled
();
expect
(
savingSpies
.
show
).
toHaveBeenCalled
();
expect
(
savingSpies
.
show
).
toHaveBeenCalled
();
expect
(
savingSpies
.
hide
).
not
.
toHaveBeenCalled
();
expect
(
savingSpies
.
hide
).
not
.
toHaveBeenCalled
();
...
@@ -195,4 +208,5 @@ define([ "jquery", "js/spec/create_sinon", "URI", "js/views/container", "js/mode
...
@@ -195,4 +208,5 @@ define([ "jquery", "js/spec/create_sinon", "URI", "js/views/container", "js/mode
});
});
});
});
});
});
});
});
\ No newline at end of file
147
\ No newline at end of file
cms/static/js/spec/views/modals/edit_xblock_spec.js
View file @
37da3999
...
@@ -12,7 +12,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
...
@@ -12,7 +12,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
beforeEach
(
function
()
{
beforeEach
(
function
()
{
edit_helpers
.
installEditTemplates
();
edit_helpers
.
installEditTemplates
();
appendSetFixtures
(
'<div class="xblock" data-locator="mock-xblock"
data-display-name="Mock XBlock"
></div>'
);
appendSetFixtures
(
'<div class="xblock" data-locator="mock-xblock"></div>'
);
model
=
new
XBlockInfo
({
model
=
new
XBlockInfo
({
id
:
'testCourse/branch/draft/block/verticalFFF'
,
id
:
'testCourse/branch/draft/block/verticalFFF'
,
display_name
:
'Test Unit'
,
display_name
:
'Test Unit'
,
...
...
cms/static/js/views/container.js
View file @
37da3999
...
@@ -4,8 +4,8 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext",
...
@@ -4,8 +4,8 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext",
xblockReady
:
function
()
{
xblockReady
:
function
()
{
XBlockView
.
prototype
.
xblockReady
.
call
(
this
);
XBlockView
.
prototype
.
xblockReady
.
call
(
this
);
var
verticalContainer
=
$
(
this
.
$el
).
find
(
'.vertical-container'
),
var
verticalContainer
=
this
.
$
(
'.vertical-container'
),
alreadySortable
=
$
(
this
.
$el
).
find
(
'.ui-sortable'
),
alreadySortable
=
this
.
$
(
'.ui-sortable'
),
newParent
,
newParent
,
oldParent
,
oldParent
,
self
=
this
;
self
=
this
;
...
@@ -16,6 +16,8 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext",
...
@@ -16,6 +16,8 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext",
handle
:
'.drag-handle'
,
handle
:
'.drag-handle'
,
stop
:
function
(
event
,
ui
)
{
stop
:
function
(
event
,
ui
)
{
var
saving
,
hideSaving
,
removeFromParent
;
console
.
log
(
'stop'
);
console
.
log
(
'stop'
);
if
(
oldParent
===
undefined
)
{
if
(
oldParent
===
undefined
)
{
...
@@ -24,12 +26,12 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext",
...
@@ -24,12 +26,12 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext",
return
;
return
;
}
}
var
saving
=
new
NotificationView
.
Mini
({
saving
=
new
NotificationView
.
Mini
({
title
:
gettext
(
'Saving…'
)
title
:
gettext
(
'Saving…'
)
});
});
saving
.
show
();
saving
.
show
();
var
hideSaving
=
function
()
{
hideSaving
=
function
()
{
saving
.
hide
();
saving
.
hide
();
};
};
...
@@ -37,12 +39,11 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext",
...
@@ -37,12 +39,11 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext",
// add to new container before deleting from old to
// add to new container before deleting from old to
// avoid creating an orphan if the addition fails.
// avoid creating an orphan if the addition fails.
if
(
newParent
)
{
if
(
newParent
)
{
var
removeFromParent
=
oldParent
;
removeFromParent
=
oldParent
;
self
.
reorder
(
newParent
,
function
()
{
self
.
reorder
(
newParent
,
function
()
{
self
.
reorder
(
removeFromParent
,
hideSaving
);
self
.
reorder
(
removeFromParent
,
hideSaving
);
});
});
}
}
else
{
else
{
// No new parent, only reordering within same container.
// No new parent, only reordering within same container.
self
.
reorder
(
oldParent
,
hideSaving
);
self
.
reorder
(
oldParent
,
hideSaving
);
}
}
...
@@ -60,8 +61,7 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext",
...
@@ -60,8 +61,7 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext",
if
(
ui
.
sender
)
{
if
(
ui
.
sender
)
{
// Move to a new container (the addition part).
// Move to a new container (the addition part).
newParent
=
parent
;
newParent
=
parent
;
}
}
else
{
else
{
// Reorder inside a container, or deletion when moving to new container.
// Reorder inside a container, or deletion when moving to new container.
oldParent
=
parent
;
oldParent
=
parent
;
}
}
...
@@ -79,16 +79,18 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext",
...
@@ -79,16 +79,18 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext",
},
},
reorder
:
function
(
targetParent
,
successCallback
)
{
reorder
:
function
(
targetParent
,
successCallback
)
{
var
children
,
childLocators
;
console
.
log
(
'calling reorder for '
+
targetParent
.
data
(
'locator'
));
console
.
log
(
'calling reorder for '
+
targetParent
.
data
(
'locator'
));
// Find descendants with class "wrapper-xblock" whose parent == targetParent.
// Find descendants with class "wrapper-xblock" whose parent == targetParent.
// This is necessary to filter our grandchildren, great-grandchildren, etc.
// This is necessary to filter our grandchildren, great-grandchildren, etc.
var
children
=
targetParent
.
find
(
'.wrapper-xblock'
).
filter
(
function
()
{
children
=
targetParent
.
find
(
'.wrapper-xblock'
).
filter
(
function
()
{
var
parent
=
$
(
this
).
parent
().
closest
(
'.wrapper-xblock'
);
var
parent
=
$
(
this
).
parent
().
closest
(
'.wrapper-xblock'
);
return
parent
.
data
(
'locator'
)
===
targetParent
.
data
(
'locator'
);
return
parent
.
data
(
'locator'
)
===
targetParent
.
data
(
'locator'
);
});
});
var
childLocators
=
_
.
map
(
childLocators
=
_
.
map
(
children
,
children
,
function
(
child
)
{
function
(
child
)
{
return
$
(
child
).
data
(
'locator'
);
return
$
(
child
).
data
(
'locator'
);
...
...
cms/templates/js/mock/mock-container-xblock.underscore
View file @
37da3999
<header class="xblock-header"></header>
<header class="xblock-header"></header>
<article class="xblock-render">
<article class="xblock-render">
<div class="xblock" data-block-type="vertical">
<div class="xblock" data-block-type="vertical"
data-locator="locator-container"
>
<div class="vert-mod">
<div class="vert-mod">
<div class="vert vert-0">
<ol class="vertical-container">
<li class="vertical-element is-draggable">
<div class="xblock" data-block-type="vertical">
<div class="vert vert-0">
<div class="vert-mod">
<span data-tooltip="Drag to reorder" class="drag-handle action"></span>
<div class="vert vert-0">
<div class="xblock" data-block-type="vertical">
<div class="vert-mod">
<section class="wrapper-xblock level-nesting" data-locator="locator-group-A">
<ol class="vertical-container">
<header class="xblock-header"></header>
<li class="vertical-element is-draggable">
<div class="vert vert-0">
<article class="xblock-render">
<span data-tooltip="Drag to reorder" class="drag-handle action"></span>
<div class="xblock" data-block-type="vertical">
<section class="wrapper-xblock level-nesting" data-locator="locator-group-A">
<div class="vert-mod">
<header class="xblock-header"></header>
<div class="vert vert-0">
<article class="xblock-render">
<section class="wrapper-xblock level-element" data-locator="locator-component-A1">
<div class="xblock" data-block-type="vertical">
<div class="vert-mod">
<header class="xblock-header">
<ol class="vertical-container">
<div class="header-actions">
<li class="vertical-element is-draggable">
<ul class="actions-list">
<div class="vert vert-0">
<li class="action-item action-edit"><a href="#" class="edit-button action-button"></a></li>
<span data-tooltip="Drag to reorder" class="drag-handle action"></span>
<li class="action-item action-duplicate"><a href="#" class="duplicate-button action-button"></a></li>
<section class="wrapper-xblock level-element"
<li class="action-item action-delete"><a href="#" class="delete-button action-button"></a></li>
data-locator="locator-component-A1">
</ul>
<header class="xblock-header">
</div>
<div class="header-actions">
</header>
<ul class="actions-list">
<article class="xblock-render"></article>
<li class="action-item action-edit"><a
</section>
href="#"
class="edit-button action-button"></a>
<section class="wrapper-xblock level-element" data-locator="locator-component-A2">
</li>
<li class="action-item action-duplicate"><a
<header class="xblock-header">
href="#"
<div class="header-actions">
class="duplicate-button action-button"></a>
<ul class="actions-list">
</li>
<li class="action-item action-edit"><a href="#" class="edit-button action-button"></a></li>
<li class="action-item action-delete"><a
<li class="action-item action-duplicate"><a href="#" class="duplicate-button action-button"></a></li>
href="#"
<li class="action-item action-delete"><a href="#" class="delete-button action-button"></a></li>
class="delete-button action-button"></a>
</ul>
</li>
</div>
</ul>
</header>
</div>
<article class="xblock-render"></article>
</header>
</section>
<article class="xblock-render"></article>
</section>
<section class="wrapper-xblock level-element" data-locator="locator-component-A3">
</div>
<header class="xblock-header">
</li>
<div class="header-actions">
<li class="vertical-element is-draggable">
<ul class="actions-list">
<div class="vert vert-1">
<li class="action-item action-edit"><a href="#" class="edit-button action-button"></a></li>
<span data-tooltip="Drag to reorder" class="drag-handle action"></span>
<li class="action-item action-duplicate"><a href="#" class="duplicate-button action-button"></a></li>
<section class="wrapper-xblock level-element"
<li class="action-item action-delete"><a href="#" class="delete-button action-button"></a></li>
data-locator="locator-component-A2">
</ul>
<header class="xblock-header">
<div class="header-actions">
<ul class="actions-list">
<li class="action-item action-edit"><a
href="#"
class="edit-button action-button"></a>
</li>
<li class="action-item action-duplicate"><a
href="#"
class="duplicate-button action-button"></a>
</li>
<li class="action-item action-delete"><a
href="#"
class="delete-button action-button"></a>
</li>
</ul>
</div>
</header>
<article class="xblock-render"></article>
</section>
</div>
</li>
<li class="vertical-element is-draggable">
<div class="vert vert-2">
<span data-tooltip="Drag to reorder" class="drag-handle action"></span>
<section class="wrapper-xblock level-element"
data-locator="locator-component-A3">
<header class="xblock-header">
<div class="header-actions">
<ul class="actions-list">
<li class="action-item action-edit"><a
href="#"
class="edit-button action-button"></a>
</li>
<li class="action-item action-duplicate"><a
href="#"
class="duplicate-button action-button"></a>
</li>
<li class="action-item action-delete"><a
href="#"
class="delete-button action-button"></a>
</li>
</ul>
</div>
</header>
<article class="xblock-render"></article>
</section>
</div>
</li>
</ol>
</div>
</div>
</header>
</div>
<article class="xblock-render"></article>
</article>
</section>
</section>
</div>
</div>
</div>
</div>
</li>
</article>
<li class="vertical-element is-draggable">
</section>
<div class="vert vert-1">
<span data-tooltip="Drag to reorder" class="drag-handle action"></span>
<section class="wrapper-xblock level-nesting" data-locator="locator-group-B">
<section class="wrapper-xblock level-nesting" data-locator="locator-group-B">
<header class="xblock-header"></header>
<header class="xblock-header"></header>
<article class="xblock-render">
<article class="xblock-render">
<div class="xblock" data-block-type="vertical">
<div class="xblock" data-block-type="vertical">
<div class="vert-mod">
<div class="vert-mod">
<div class="vert vert-0">
<ol class="vertical-container">
<li class="vertical-element is-draggable">
<section class="wrapper-xblock level-element" data-locator="locator-component-B1">
<div class="vert vert-0">
<span data-tooltip="Drag to reorder" class="drag-handle action"></span>
<header class="xblock-header">
<section class="wrapper-xblock level-element"
<div class="header-actions">
data-locator="locator-component-B1">
<ul class="actions-list">
<li class="action-item action-edit"><a href="#" class="edit-button action-button"></a></li>
<header class="xblock-header">
<li class="action-item action-duplicate"><a href="#" class="duplicate-button action-button"></a></li>
<div class="header-actions">
<li class="action-item action-delete"><a href="#" class="delete-button action-button"></a></li>
<ul class="actions-list">
</ul>
<li class="action-item action-edit"><a
</div>
href="#"
</header>
class="edit-button action-button"></a>
<article class="xblock-render"></article>
</li>
</section>
<li class="action-item action-duplicate"><a
href="#"
<section class="wrapper-xblock level-element" data-locator="locator-component-B2">
class="duplicate-button action-button"></a>
</li>
<header class="xblock-header">
<li class="action-item action-delete"><a
<div class="header-actions">
href="#"
<ul class="actions-list">
class="delete-button action-button"></a>
<li class="action-item action-edit"><a href="#" class="edit-button action-button"></a></li>
</li>
<li class="action-item action-duplicate"><a href="#" class="duplicate-button action-button"></a></li>
</ul>
<li class="action-item action-delete"><a href="#" class="delete-button action-button"></a></li>
</div>
</ul>
</header>
</div>
<article class="xblock-render"></article>
</header>
</section>
<article class="xblock-render"></article>
</div>
</section>
</li>
<li class="vertical-element is-draggable">
<section class="wrapper-xblock level-element" data-locator="locator-component-B3">
<div class="vert vert-1">
<span data-tooltip="Drag to reorder" class="drag-handle action"></span>
<header class="xblock-header">
<section class="wrapper-xblock level-element"
<div class="header-actions">
data-locator="locator-component-B2">
<ul class="actions-list">
<li class="action-item action-edit"><a href="#" class="edit-button action-button"></a></li>
<header class="xblock-header">
<li class="action-item action-duplicate"><a href="#" class="duplicate-button action-button"></a></li>
<div class="header-actions">
<li class="action-item action-delete"><a href="#" class="delete-button action-button"></a></li>
<ul class="actions-list">
</ul>
<li class="action-item action-edit"><a
href="#"
class="edit-button action-button"></a>
</li>
<li class="action-item action-duplicate"><a
href="#"
class="duplicate-button action-button"></a>
</li>
<li class="action-item action-delete"><a
href="#"
class="delete-button action-button"></a>
</li>
</ul>
</div>
</header>
<article class="xblock-render"></article>
</section>
</div>
</li>
<li class="vertical-element is-draggable">
<div class="vert vert-2">
<span data-tooltip="Drag to reorder" class="drag-handle action"></span>
<section class="wrapper-xblock level-element"
data-locator="locator-component-B3">
<header class="xblock-header">
<div class="header-actions">
<ul class="actions-list">
<li class="action-item action-edit"><a
href="#"
class="edit-button action-button"></a>
</li>
<li class="action-item action-duplicate"><a
href="#"
class="duplicate-button action-button"></a>
</li>
<li class="action-item action-delete"><a
href="#"
class="delete-button action-button"></a>
</li>
</ul>
</div>
</header>
<article class="xblock-render"></article>
</section>
</div>
</li>
</ol>
</div>
</div>
</header>
</div>
<article class="xblock-render"></article>
</article>
</section>
</section>
</div>
</div>
</div>
</
div
>
</
li
>
</
article
>
</
ol
>
</
section
>
</
div
>
</div>
</div>
</div>
</div>
</
div
>
</
li
>
</
div
>
</
ol
>
</div>
</div>
</div>
</div>
</article>
</article>
cms/templates/js/mock/mock-container.underscore
deleted
100644 → 0
View file @
8e00f6dc
<section class="wrapper-xblock level-page" data-locator="ccc.dd.ee/branch/draft/block/AB_Test">
<header class="xblock-header">
<div class="header-details">A/B Test</div>
</header>
<article class="xblock-render">
<div class="xblock xblock-student_view xmodule_display xmodule_SplitTestModule xblock-initialized"
data-runtime-class="PreviewRuntime" data-init="XBlockToXModuleShim" data-runtime-version="1"
data-usage-id="i4x:;_;_ccc;_dd;_split_test;_AB_Test" data-type="None" data-block-type="split_test">
<div class="vert-mod">
<ol class="vertical-container">
<li class="vertical-element">
<div class="vert vert-0" data-id="i4x://ccc/dd/vertical/group_a">
<span data-tooltip="Drag to reorder" class="drag-handle action"></span>
<section class="wrapper-xblock level-nesting is-collapsible"
data-locator="ccc.dd.ee/branch/published/block/group_a">
<header class="xblock-header">
<div class="header-details">
<span>Group A</span>
</div>
<div class="header-actions">
<ul class="actions-list">
<li class="sr action-item">No Actions</li>
</ul>
</div>
</header>
<article class="xblock-render">
<div class="xblock xblock-student_view xmodule_display xmodule_VerticalModule xblock-initialized"
data-runtime-class="PreviewRuntime" data-init="XBlockToXModuleShim"
data-runtime-version="1"
data-usage-id="i4x:;_;_ccc;_dd;_vertical;_group_a" data-type="None"
data-block-type="vertical">
<div class="vert-mod">
<ol class="vertical-container">
<li class="vertical-element">
<div class="vert vert-0"
data-id="i4x://ccc/dd/html/html_4658c0f4c400">
<span data-tooltip="Drag to reorder"
class="drag-handle action"></span>
<section class="wrapper-xblock level-element"
data-locator="ccc.dd.ee/branch/published/block/html_4658c0f4c400">
<header class="xblock-header">
<div class="header-details">Text</div>
<div class="header-actions">
<ul class="actions-list">
</ul>
</div>
</header>
<article class="xblock-render">
<div class="xblock xblock-student_view xmodule_display xmodule_HtmlModule xblock-initialized"
data-runtime-class="PreviewRuntime"
data-init="XBlockToXModuleShim"
data-runtime-version="1"
data-usage-id="i4x:;_;_ccc;_dd;_html;_html_4658c0f4c400"
data-type="HTMLModule" data-block-type="html">
Welcome to group A.
</div>
</article>
</section>
</div>
</li>
<li class="vertical-element">
<div class="vert vert-1" data-id="i4x://ccc/dd/video/group_a_video">
<span data-tooltip="Drag to reorder"
class="drag-handle action"></span>
<section class="wrapper-xblock level-element"
data-locator="ccc.dd.ee/branch/published/block/group_a_video">
<header class="xblock-header">
<div class="header-details">
Video
</div>
<div class="header-actions">
<ul class="actions-list">
</ul>
</div>
</header>
<article class="xblock-render">
<div class="xblock xblock-student_view xmodule_display xmodule_VideoModule xblock-initialized"
data-runtime-class="PreviewRuntime"
data-init="XBlockToXModuleShim"
data-runtime-version="1"
data-usage-id="i4x:;_;_ccc;_dd;_video;_group_a_video"
data-type="Video"
data-block-type="video">
<h2>Video</h2>
</div>
</article>
</section>
</div>
</li>
</ol>
</div>
</div>
</article>
</section>
</div>
</li>
<li class="vertical-element">
<div class="vert vert-1" data-id="i4x://ccc/dd/vertical/group_b">
<span data-tooltip="Drag to reorder" class="drag-handle action"></span>
<section class="wrapper-xblock level-nesting is-collapsible"
data-locator="ccc.dd.ee/branch/published/block/group_b">
<header class="xblock-header">
<div class="header-details">
<span>Group B</span>
</div>
<div class="header-actions">
<ul class="actions-list">
<li class="sr action-item">No Actions</li>
</ul>
</div>
</header>
<article class="xblock-render">
<div class="xblock xblock-student_view xmodule_display xmodule_VerticalModule xblock-initialized"
data-runtime-class="PreviewRuntime" data-init="XBlockToXModuleShim"
data-runtime-version="1"
data-usage-id="i4x:;_;_ccc;_dd;_vertical;_group_b" data-type="None"
data-block-type="vertical">
<div class="vert-mod">
<ol class="vertical-container">
<li class="vertical-element">
<div class="vert vert-0"
data-id="i4x://ccc/dd/html/html_b5c18016d991">
<span data-tooltip="Drag to reorder"
class="drag-handle action"></span>
<section class="wrapper-xblock level-element"
data-locator="ccc.dd.ee/branch/published/block/html_b5c18016d991">
<header class="xblock-header">
<div class="header-details">
Text
</div>
<div class="header-actions">
<ul class="actions-list">
</ul>
</div>
</header>
<article class="xblock-render">
<div class="xblock xblock-student_view xmodule_display xmodule_HtmlModule xblock-initialized"
data-runtime-class="PreviewRuntime"
data-init="XBlockToXModuleShim"
data-runtime-version="1"
data-usage-id="i4x:;_;_ccc;_dd;_html;_html_b5c18016d991"
data-type="HTMLModule" data-block-type="html">
Welcome to group B.
</div>
</article>
</section>
</div>
</li>
<li class="vertical-element">
<div class="vert vert-1" data-id="i4x://ccc/dd/problem/Checkboxes">
<span data-tooltip="Drag to reorder"
class="drag-handle action"></span>
<section class="wrapper-xblock level-element"
data-locator="ccc.dd.ee/branch/published/block/Checkboxes">
<header class="xblock-header">
<div class="header-details">
Checkboxes
</div>
<div class="header-actions">
<ul class="actions-list">
</ul>
</div>
</header>
<article class="xblock-render">
<div class="xblock xblock-student_view xmodule_display xmodule_CapaModule xblock-initialized"
data-runtime-class="PreviewRuntime"
data-init="XBlockToXModuleShim"
data-runtime-version="1"
data-usage-id="i4x:;_;_ccc;_dd;_problem;_Checkboxes"
data-type="Problem" data-block-type="problem">
<div id="problem_i4x-ccc-dd-problem-Checkboxes"
class="problems-wrapper"
data-problem-id="i4x://ccc/dd/problem/Checkboxes"
data-url="/preview/xblock/i4x:;_;_ccc;_dd;_problem;_Checkboxes/handler/xmodule_handler"
data-progress_status="none"
data-progress_detail="0/1">
<h2 class="problem-header">
Checkboxes
</h2>
</div>
</div>
</article>
</section>
</div>
</li>
</ol>
</div>
</div>
</article>
</section>
</div>
</li>
</ol>
</div>
</div>
</article>
</section>
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