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
5029f460
Commit
5029f460
authored
Jul 15, 2013
by
Peter Fogg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Backbone notifications for component delete.
parent
9fe4cb73
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
20 deletions
+74
-20
cms/djangoapps/contentstore/features/component.feature
+18
-0
cms/djangoapps/contentstore/features/component.py
+16
-0
cms/static/coffee/src/views/module_edit.coffee
+4
-0
cms/static/coffee/src/views/unit.coffee
+36
-20
No files found.
cms/djangoapps/contentstore/features/component.feature
View file @
5029f460
...
@@ -67,3 +67,21 @@ Feature: Component Adding
...
@@ -67,3 +67,21 @@ Feature: Component Adding
When
I will confirm all alerts
When
I will confirm all alerts
And
I delete all components
And
I delete all components
Then
I see no components
Then
I see no components
Scenario
:
I
see a prompt on delete
Given
I have opened a new course in studio
And
I am editing a new unit
And I add the following components
:
|
Component
|
|
Discussion
|
And
I delete a component
Then
I see a prompt
Scenario
:
I
see a notification on save
Given
I have opened a new course in studio
And
I am editing a new unit
And I add the following components
:
|
Component
|
|
Discussion
|
And
I edit and save a component
Then
I see a notification
cms/djangoapps/contentstore/features/component.py
View file @
5029f460
...
@@ -41,6 +41,22 @@ def see_no_components(steps):
...
@@ -41,6 +41,22 @@ def see_no_components(steps):
assert
world
.
is_css_not_present
(
'li.component'
)
assert
world
.
is_css_not_present
(
'li.component'
)
@step
(
u'I delete a component'
)
def
delete_one_component
(
step
):
world
.
css_click
(
'a.delete-button'
)
@step
(
u'I edit and save a component'
)
def
edit_and_save_component
(
step
):
world
.
css_click
(
'.edit-button'
)
world
.
css_click
(
'.save-button'
)
@step
(
u'I see a (.*)$'
)
def
i_see_a_notification
(
step
,
notification_type
):
assert
world
.
is_css_present
(
'.wrapper-
%
s'
%
notification_type
)
def
step_selector_list
(
data_type
,
path
,
index
=
1
):
def
step_selector_list
(
data_type
,
path
,
index
=
1
):
selector_list
=
[
'a[data-type="{}"]'
.
format
(
data_type
)]
selector_list
=
[
'a[data-type="{}"]'
.
format
(
data_type
)]
if
index
!=
1
:
if
index
!=
1
:
...
...
cms/static/coffee/src/views/module_edit.coffee
View file @
5029f460
...
@@ -84,11 +84,15 @@ class CMS.Views.ModuleEdit extends Backbone.View
...
@@ -84,11 +84,15 @@ class CMS.Views.ModuleEdit extends Backbone.View
data
.
metadata
=
_
.
extend
(
data
.
metadata
||
{},
@
changedMetadata
())
data
.
metadata
=
_
.
extend
(
data
.
metadata
||
{},
@
changedMetadata
())
@
hideModal
()
@
hideModal
()
saving
=
new
CMS
.
Views
.
Notification
.
Mini
title
:
gettext
(
'Saving'
)
+
'…'
saving
.
show
()
@
model
.
save
(
data
).
done
(
=>
@
model
.
save
(
data
).
done
(
=>
# # showToastMessage("Your changes have been saved.", null, 3)
# # showToastMessage("Your changes have been saved.", null, 3)
@
module
=
null
@
module
=
null
@
render
()
@
render
()
@
$el
.
removeClass
(
'editing'
)
@
$el
.
removeClass
(
'editing'
)
saving
.
hide
()
).
fail
(
->
).
fail
(
->
showToastMessage
(
gettext
(
"There was an error saving your changes. Please try again."
),
null
,
3
)
showToastMessage
(
gettext
(
"There was an error saving your changes. Please try again."
),
null
,
3
)
)
)
...
...
cms/static/coffee/src/views/unit.coffee
View file @
5029f460
...
@@ -115,27 +115,43 @@ class CMS.Views.UnitEdit extends Backbone.View
...
@@ -115,27 +115,43 @@ class CMS.Views.UnitEdit extends Backbone.View
@
model
.
save
()
@
model
.
save
()
deleteComponent
:
(
event
)
=>
deleteComponent
:
(
event
)
=>
if
not
confirm
'Are you sure you want to delete this component? This action cannot be undone.'
msg
=
new
CMS
.
Views
.
Prompt
.
Confirmation
(
return
title
:
gettext
(
'Are you sure you want to delete this component?'
),
$component
=
$
(
event
.
currentTarget
).
parents
(
'.component'
)
message
:
gettext
(
'This action cannot be undone.'
),
$
.
post
(
'/delete_item'
,
{
actions
:
id
:
$component
.
data
(
'id'
)
primary
:
},
=>
text
:
gettext
(
'OK'
),
analytics
.
track
"Deleted a Component"
,
click
:
(
view
)
=>
course
:
course_location_analytics
view
.
hide
()
unit_id
:
unit_location_analytics
deleting
=
new
CMS
.
Views
.
Notification
.
Mini
id
:
$component
.
data
(
'id'
)
title
:
gettext
(
'Deleting'
)
+
'…'
,
deleting
.
show
()
$component
.
remove
()
$component
=
$
(
event
.
currentTarget
).
parents
(
'.component'
)
# b/c we don't vigilantly keep children up to date
$
.
post
(
'/delete_item'
,
{
# get rid of it before it hurts someone
id
:
$component
.
data
(
'id'
)
# sorry for the js, i couldn't figure out the coffee equivalent
},
=>
`
_this
.
model
.
save
({
children
:
_this
.
components
()},
deleting
.
hide
()
{
success
:
function
(
model
)
{
analytics
.
track
"Deleted a Component"
,
model
.
unset
(
'children'
);
course
:
course_location_analytics
}}
unit_id
:
unit_location_analytics
);
`
id
:
$component
.
data
(
'id'
)
$component
.
remove
()
# b/c we don't vigilantly keep children up to date
# get rid of it before it hurts someone
# sorry for the js, i couldn't figure out the coffee equivalent
`
_this
.
model
.
save
({
children
:
_this
.
components
()},
{
success
:
function
(
model
)
{
model
.
unset
(
'children'
);
}}
);
`
)
secondary
:
text
:
gettext
(
'Cancel'
),
click
:
(
view
)
->
view
.
hide
()
)
)
msg
.
show
()
deleteDraft
:
(
event
)
->
deleteDraft
:
(
event
)
->
@
wait
(
true
)
@
wait
(
true
)
...
...
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