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
fe4bd4cb
Commit
fe4bd4cb
authored
Apr 10, 2014
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3234 from edx/nimisha/container-duplicate-delete
Nimisha/container duplicate delete
parents
81597a5c
48d935d7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
131 additions
and
16 deletions
+131
-16
cms/envs/common.py
+6
-0
cms/static/js/spec/views/pages/container_spec.js
+0
-0
cms/static/js/views/pages/container.js
+96
-4
cms/templates/container.html
+1
-1
cms/templates/studio_xblock_wrapper.html
+28
-11
No files found.
cms/envs/common.py
View file @
fe4bd4cb
...
@@ -99,6 +99,12 @@ FEATURES = {
...
@@ -99,6 +99,12 @@ FEATURES = {
# Turn off Advanced Security by default
# Turn off Advanced Security by default
'ADVANCED_SECURITY'
:
False
,
'ADVANCED_SECURITY'
:
False
,
# Temporary feature flag for duplicating xblock leaves
'ENABLE_DUPLICATE_XBLOCK_LEAF_COMPONENT'
:
False
,
# Temporary feature flag for deleting xblock leaves
'ENABLE_DELETE_XBLOCK_LEAF_COMPONENT'
:
False
,
}
}
ENABLE_JASMINE
=
False
ENABLE_JASMINE
=
False
...
...
cms/static/js/spec/views/pages/container_spec.js
View file @
fe4bd4cb
This diff is collapsed.
Click to expand it.
cms/static/js/views/pages/container.js
View file @
fe4bd4cb
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
* XBlockContainerView is used to display an xblock which has children, and allows the
* XBlockContainerView is used to display an xblock which has children, and allows the
* user to interact with the children.
* user to interact with the children.
*/
*/
define
([
"jquery"
,
"underscore"
,
"
js/views/baseview"
,
"js/views/xblock"
,
"js/views/modals/edit_xblock
"
],
define
([
"jquery"
,
"underscore"
,
"
gettext"
,
"js/views/feedback_notification"
,
"js/views/feedback_prompt"
,
"js/views/baseview"
,
"js/views/xblock"
,
"js/views/modals/edit_xblock"
,
"js/models/xblock_info
"
],
function
(
$
,
_
,
BaseView
,
XBlockView
,
EditXBlockModal
)
{
function
(
$
,
_
,
gettext
,
NotificationView
,
PromptView
,
BaseView
,
XBlockView
,
EditXBlockModal
,
XBlockInfo
)
{
var
XBlockContainerView
=
BaseView
.
extend
({
var
XBlockContainerView
=
BaseView
.
extend
({
// takes XBlockInfo as a model
// takes XBlockInfo as a model
...
@@ -53,6 +53,10 @@ define(["jquery", "underscore", "js/views/baseview", "js/views/xblock", "js/view
...
@@ -53,6 +53,10 @@ define(["jquery", "underscore", "js/views/baseview", "js/views/xblock", "js/view
return
$
(
target
).
closest
(
'[data-locator]'
);
return
$
(
target
).
closest
(
'[data-locator]'
);
},
},
getURLRoot
:
function
()
{
return
this
.
xblockView
.
model
.
urlRoot
;
},
addButtonActions
:
function
(
element
)
{
addButtonActions
:
function
(
element
)
{
var
self
=
this
;
var
self
=
this
;
element
.
find
(
'.edit-button'
).
click
(
function
(
event
)
{
element
.
find
(
'.edit-button'
).
click
(
function
(
event
)
{
...
@@ -68,11 +72,98 @@ define(["jquery", "underscore", "js/views/baseview", "js/views/xblock", "js/view
...
@@ -68,11 +72,98 @@ define(["jquery", "underscore", "js/views/baseview", "js/views/xblock", "js/view
}
}
});
});
});
});
element
.
find
(
'.duplicate-button'
).
click
(
function
(
event
)
{
event
.
preventDefault
();
self
.
duplicateComponent
(
self
.
findXBlockElement
(
event
.
target
)
);
});
element
.
find
(
'.delete-button'
).
click
(
function
(
event
)
{
event
.
preventDefault
();
self
.
deleteComponent
(
self
.
findXBlockElement
(
event
.
target
)
);
});
},
},
refreshXBlock
:
function
(
xblockInfo
,
xblockElement
)
{
duplicateComponent
:
function
(
xblockElement
)
{
var
self
=
this
,
var
self
=
this
,
temporaryView
;
parentElement
=
self
.
findXBlockElement
(
xblockElement
.
parent
()),
duplicating
=
new
NotificationView
.
Mini
({
title
:
gettext
(
'Duplicating…'
)
});
duplicating
.
show
();
return
$
.
postJSON
(
self
.
getURLRoot
(),
{
duplicate_source_locator
:
xblockElement
.
data
(
'locator'
),
parent_locator
:
parentElement
.
data
(
'locator'
)
},
function
(
data
)
{
// copy the element
var
duplicatedElement
=
xblockElement
.
clone
(
false
);
// place it after the original element
xblockElement
.
after
(
duplicatedElement
);
// update its locator id
duplicatedElement
.
attr
(
'data-locator'
,
data
.
locator
);
// have it refresh itself
self
.
refreshXBlockElement
(
duplicatedElement
);
// hide the notification
duplicating
.
hide
();
});
},
deleteComponent
:
function
(
xblockElement
)
{
var
self
=
this
,
deleting
;
return
new
PromptView
.
Warning
({
title
:
gettext
(
'Delete this component?'
),
message
:
gettext
(
'Deleting this component is permanent and cannot be undone.'
),
actions
:
{
primary
:
{
text
:
gettext
(
'Yes, delete this component'
),
click
:
function
(
prompt
)
{
prompt
.
hide
();
deleting
=
new
NotificationView
.
Mini
({
title
:
gettext
(
'Deleting…'
)
});
deleting
.
show
();
return
$
.
ajax
({
type
:
'DELETE'
,
url
:
self
.
getURLRoot
()
+
"/"
+
xblockElement
.
data
(
'locator'
)
+
"?"
+
$
.
param
({
recurse
:
true
,
all_versions
:
true
})
}).
success
(
function
()
{
deleting
.
hide
();
xblockElement
.
remove
();
});
}
},
secondary
:
{
text
:
gettext
(
'Cancel'
),
click
:
function
(
prompt
)
{
return
prompt
.
hide
();
}
}
}
}).
show
();
},
refreshXBlockElement
:
function
(
xblockElement
)
{
this
.
refreshXBlock
(
new
XBlockInfo
({
id
:
xblockElement
.
data
(
'locator'
)
}),
xblockElement
);
},
refreshXBlock
:
function
(
xblockInfo
,
xblockElement
)
{
var
self
=
this
,
temporaryView
;
// There is only one Backbone view created on the container page, which is
// There is only one Backbone view created on the container page, which is
// for the container xblock itself. Any child xblocks rendered inside the
// for the container xblock itself. Any child xblocks rendered inside the
// container do not get a Backbone view. Thus, create a temporary XBlock
// container do not get a Backbone view. Thus, create a temporary XBlock
...
@@ -93,3 +184,4 @@ define(["jquery", "underscore", "js/views/baseview", "js/views/xblock", "js/view
...
@@ -93,3 +184,4 @@ define(["jquery", "underscore", "js/views/baseview", "js/views/xblock", "js/view
return
XBlockContainerView
;
return
XBlockContainerView
;
});
// end define();
});
// end define();
cms/templates/container.html
View file @
fe4bd4cb
...
@@ -131,6 +131,6 @@ main_xblock_info = {
...
@@ -131,6 +131,6 @@ main_xblock_info = {
</div>
</div>
</div>
</div>
<div
class=
"edit-xblock-modal"
/
>
<div
class=
"edit-xblock-modal"
></div
>
</
%
block>
</
%
block>
cms/templates/studio_xblock_wrapper.html
View file @
fe4bd4cb
<
%!
from
django
.
utils
.
translation
import
ugettext
as
_
%
>
<
%!
from
django
.
utils
.
translation
import
ugettext
as
_
%
>
<
%!
from
django
.
conf
import
settings
%
>
% if xblock.location != xblock_context['root_xblock'].location:
% if xblock.location != xblock_context['root_xblock'].location:
% if xblock.has_children:
<
%
section_class =
"level-nesting"
if
xblock
.
has_children
else
"
level-element
"
%
>
<section
class=
"wrapper-xblock level-nesting"
data-locator=
"${locator}"
data-display-name=
"${xblock.display_name_with_default | h}"
data-category=
"${xblock.category | h}"
>
<section
class=
"wrapper-xblock ${section_class}"
data-locator=
"${locator}"
data-display-name=
"${xblock.display_name_with_default | h}"
data-category=
"${xblock.category | h}"
>
% else:
<section
class=
"wrapper-xblock level-element"
data-locator=
"${locator}"
data-display-name=
"${xblock.display_name_with_default | h}"
data-category=
"${xblock.category | h}"
>
% endif
% endif
% endif
<header
class=
"xblock-header"
>
<header
class=
"xblock-header"
>
<div
class=
"header-details"
>
<div
class=
"header-details"
>
${xblock.display_name_with_default | h}
${xblock.display_name_with_default | h}
...
@@ -13,12 +13,28 @@
...
@@ -13,12 +13,28 @@
<div
class=
"header-actions"
>
<div
class=
"header-actions"
>
<ul
class=
"actions-list"
>
<ul
class=
"actions-list"
>
% if not xblock_context['read_only']:
% if not xblock_context['read_only']:
<li
class=
"action-item action-edit"
>
<li
class=
"action-item action-edit"
>
<a
href=
"#"
class=
"edit-button action-button"
>
<a
href=
"#"
class=
"edit-button action-button"
>
<i
class=
"icon-pencil"
></i>
<i
class=
"icon-pencil"
></i>
<span
class=
"action-button-text"
>
${_("Edit")}
</span>
<span
class=
"action-button-text"
>
${_("Edit")}
</span>
</a>
</a>
</li>
</li>
% endif
%if settings.FEATURES.get('ENABLE_DUPLICATE_XBLOCK_LEAF_COMPONENT'):
<li
class=
"action-item action-duplicate"
>
<a
href=
"#"
data-tooltip=
"${_("
Duplicate
")}"
class=
"duplicate-button action-button"
>
<i
class=
"icon-copy"
></i>
<span
class=
"sr"
>
${_("Duplicate")}
</span>
</a>
</li>
% endif
%if settings.FEATURES.get('ENABLE_DELETE_XBLOCK_LEAF_COMPONENT'):
<li
class=
"action-item action-delete"
>
<a
href=
"#"
data-tooltip=
"${_("
Delete
")}"
class=
"delete-button action-button"
>
<i
class=
"icon-trash"
></i>
<span
class=
"sr"
>
${_("Delete")}
</span>
</a>
</li>
% endif
% endif
</ul>
</ul>
</div>
</div>
...
@@ -26,6 +42,7 @@
...
@@ -26,6 +42,7 @@
<article
class=
"xblock-render"
>
<article
class=
"xblock-render"
>
${content}
${content}
</article>
</article>
% if xblock.location != xblock_context['root_xblock'].location:
% if xblock.location != xblock_context['root_xblock'].location:
</section>
</section>
% endif
% endif
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