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
77db1f8a
Commit
77db1f8a
authored
Jun 19, 2013
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixups and test fixes post-rebase
parent
4b2eb79d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
25 deletions
+16
-25
cms/static/coffee/spec/views/textbook_spec.coffee
+5
-5
cms/static/js/views/textbook.js
+11
-20
No files found.
cms/static/coffee/spec/views/textbook_spec.coffee
View file @
77db1f8a
...
...
@@ -36,17 +36,18 @@ describe "CMS.Views.TextbookShow", ->
expect
(
@
collection
.
editing
).
toEqual
(
@
model
)
it
"should pop a delete confirmation when the delete button is clicked"
,
->
promptSpies
=
spyOnConstructor
(
CMS
.
Views
,
"Prompt"
)
promptSpies
=
spyOnConstructor
(
CMS
.
Views
.
Prompt
,
"Warning"
,
[
"show"
,
"hide"
]
)
@
view
.
render
().
$
(
".delete"
).
click
()
expect
(
promptSpies
.
constructor
).
toHaveBeenCalled
()
msg
=
promptSpies
.
constructor
.
mostRecentCall
.
args
[
0
].
model
expect
(
msg
.
get
(
"title"
)
).
toMatch
(
/Life Sciences/
)
ctorOptions
=
promptSpies
.
constructor
.
mostRecentCall
.
args
[
0
]
expect
(
ctorOptions
.
title
).
toMatch
(
/Life Sciences/
)
# hasn't actually been removed
expect
(
@
collection
).
toContain
(
@
model
)
expect
(
@
collection
.
save
).
not
.
toHaveBeenCalled
()
# run the primary function to indicate confirmation
view
=
jasmine
.
createSpyObj
(
'view'
,
[
'hide'
])
msg
.
get
(
"actions"
).
primary
.
click
.
call
(
msg
,
view
)
context
=
jasmine
.
createSpy
(
'context'
)
ctorOptions
.
actions
.
primary
.
click
.
call
(
context
,
view
)
# now it's been removed
expect
(
@
collection
).
not
.
toContain
(
@
model
)
expect
(
@
collection
.
save
).
toHaveBeenCalled
()
...
...
@@ -150,7 +151,6 @@ describe "CMS.Views.ListTextbooks", ->
expect
(
@
view
.
$el
).
not
.
toContainText
(
"You haven't added any textbooks to this course yet"
)
expect
(
@
view
.
$el
).
toBe
(
"ul"
)
expect
(
@
showSpies
.
constructor
).
toHaveBeenCalled
()
expect
(
@
showSpies
.
constructor
.
calls
.
length
).
toEqual
(
3
);
expect
(
@
editSpies
.
constructor
).
not
.
toHaveBeenCalled
()
...
...
cms/static/js/views/textbook.js
View file @
77db1f8a
...
...
@@ -22,7 +22,7 @@ CMS.Views.TextbookShow = Backbone.View.extend({
confirmDelete
:
function
(
e
)
{
if
(
e
&&
e
.
preventDefault
)
{
e
.
preventDefault
();
}
var
textbook
=
this
.
model
,
collection
=
this
.
model
.
collection
;
var
msg
=
new
CMS
.
Models
.
WarningMessage
({
var
msg
=
new
CMS
.
Views
.
Prompt
.
Warning
({
title
:
_
.
str
.
sprintf
(
gettext
(
"Delete “%s”?"
),
textbook
.
escape
(
'name'
)),
message
:
gettext
(
"Deleting a textbook cannot be undone and once deleted any reference to it in your courseware's navigation will also be removed."
),
...
...
@@ -32,18 +32,14 @@ CMS.Views.TextbookShow = Backbone.View.extend({
click
:
function
(
view
)
{
view
.
hide
();
collection
.
remove
(
textbook
);
var
delmsg
=
new
CMS
.
Models
.
SystemFeedback
({
intent
:
"saving"
,
title
:
gettext
(
"Deleting…"
)
});
var
notif
=
new
CMS
.
Views
.
Notification
({
model
:
delmsg
,
var
delmsg
=
new
CMS
.
Views
.
Notification
.
Saving
({
title
:
gettext
(
"Deleting…"
),
closeIcon
:
false
,
minShown
:
1250
});
})
.
show
()
;
collection
.
save
({
complete
:
function
()
{
notif
.
hide
();
delmsg
.
hide
();
}
});
}
...
...
@@ -55,8 +51,7 @@ CMS.Views.TextbookShow = Backbone.View.extend({
}
}]
}
});
var
prompt
=
new
CMS
.
Views
.
Prompt
({
model
:
msg
});
}).
show
();
},
showChapters
:
function
(
e
)
{
if
(
e
&&
e
.
preventDefault
)
{
e
.
preventDefault
();
}
...
...
@@ -93,7 +88,7 @@ CMS.Views.TextbookEdit = Backbone.View.extend({
},
addOne
:
function
(
chapter
)
{
var
view
=
new
CMS
.
Views
.
ChapterEdit
({
model
:
chapter
});
this
.
$
(
"ol.chapters"
).
append
(
view
.
render
().
el
)
this
.
$
(
"ol.chapters"
).
append
(
view
.
render
().
el
)
;
return
this
;
},
addAll
:
function
()
{
...
...
@@ -116,19 +111,15 @@ CMS.Views.TextbookEdit = Backbone.View.extend({
chapter
.
set
({
"name"
:
$
(
".chapter-name"
,
li
).
val
(),
"asset_path"
:
$
(
".chapter-asset-path"
,
li
).
val
()
})
})
;
});
return
this
;
},
setAndClose
:
function
(
e
)
{
if
(
e
&&
e
.
preventDefault
)
{
e
.
preventDefault
();
}
this
.
setValues
();
msg
=
new
CMS
.
Models
.
SystemFeedback
({
intent
:
"saving"
,
title
:
gettext
(
"Saving…"
)
});
notif
=
new
CMS
.
Views
.
Notification
({
model
:
msg
,
var
saving
=
new
CMS
.
Views
.
Notification
.
Saving
({
title
:
gettext
(
"Saving…"
),
closeIcon
:
false
,
minShown
:
1250
});
...
...
@@ -138,7 +129,7 @@ CMS.Views.TextbookEdit = Backbone.View.extend({
that
.
close
();
},
complete
:
function
()
{
notif
.
hide
();
saving
.
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