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
4d2183d7
Commit
4d2183d7
authored
Jun 24, 2013
by
David Baumgold
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #253 from edx/db/notifications-secondary-single
Backbone notifications secondary actions
parents
f1825eff
72ffe2d8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
2 deletions
+46
-2
cms/static/coffee/spec/views/feedback_spec.coffee
+41
-2
cms/static/js/views/feedback.js
+5
-0
No files found.
cms/static/coffee/spec/views/feedback_spec.coffee
View file @
4d2183d7
...
...
@@ -100,11 +100,10 @@ describe "CMS.Views.SystemFeedback click events", ->
text
:
"Save"
,
class
:
"save-button"
,
click
:
@
primaryClickSpy
secondary
:
[{
secondary
:
text
:
"Revert"
,
class
:
"cancel-button"
,
click
:
@
secondaryClickSpy
}]
)
@
view
.
show
()
...
...
@@ -124,6 +123,46 @@ describe "CMS.Views.SystemFeedback click events", ->
it
"should apply class to secondary action"
,
->
expect
(
@
view
.
$
(
".action-secondary"
)).
toHaveClass
(
"cancel-button"
)
describe
"CMS.Views.SystemFeedback multiple secondary actions"
,
->
beforeEach
->
@
secondarySpyOne
=
jasmine
.
createSpy
(
'secondarySpyOne'
)
@
secondarySpyTwo
=
jasmine
.
createSpy
(
'secondarySpyTwo'
)
@
view
=
new
CMS
.
Views
.
Notification
.
Warning
(
title
:
"No Primary"
,
message
:
"Pick a secondary action"
,
actions
:
secondary
:
[
{
text
:
"Option One"
class
:
"option-one"
click
:
@
secondarySpyOne
},
{
text
:
"Option Two"
class
:
"option-two"
click
:
@
secondarySpyTwo
}
]
)
@
view
.
show
()
it
"should render both"
,
->
expect
(
@
view
.
el
).
toContain
(
".action-secondary.option-one"
)
expect
(
@
view
.
el
).
toContain
(
".action-secondary.option-two"
)
expect
(
@
view
.
el
).
not
.
toContain
(
".action-secondary.option-one.option-two"
)
expect
(
@
view
.
$
(
".action-secondary.option-one"
)).
toContainText
(
"Option One"
)
expect
(
@
view
.
$
(
".action-secondary.option-two"
)).
toContainText
(
"Option Two"
)
it
"should differentiate clicks (1)"
,
->
@
view
.
$
(
".option-one"
).
click
()
expect
(
@
secondarySpyOne
).
toHaveBeenCalled
()
expect
(
@
secondarySpyTwo
).
not
.
toHaveBeenCalled
()
it
"should differentiate clicks (2)"
,
->
@
view
.
$
(
".option-two"
).
click
()
expect
(
@
secondarySpyOne
).
not
.
toHaveBeenCalled
()
expect
(
@
secondarySpyTwo
).
toHaveBeenCalled
()
describe
"CMS.Views.Notification minShown and maxShown"
,
->
beforeEach
->
@
showSpy
=
spyOn
(
CMS
.
Views
.
Notification
.
Saving
.
prototype
,
'show'
)
...
...
cms/static/js/views/feedback.js
View file @
4d2183d7
...
...
@@ -49,6 +49,11 @@ CMS.Views.SystemFeedback = Backbone.View.extend({
}
this
.
template
=
_
.
template
(
tpl
);
this
.
setElement
(
$
(
"#page-"
+
this
.
options
.
type
));
// handle single "secondary" action
if
(
this
.
options
.
actions
&&
this
.
options
.
actions
.
secondary
&&
!
_
.
isArray
(
this
.
options
.
actions
.
secondary
))
{
this
.
options
.
actions
.
secondary
=
[
this
.
options
.
actions
.
secondary
];
}
return
this
;
},
// public API: show() and hide()
...
...
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