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
bb6cd7dc
Commit
bb6cd7dc
authored
Oct 15, 2014
by
jmclaus
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5554 from edx/jmclaus/fix-errors-discussion-xmodule
Fixed errors in discussion XModule
parents
b6013a23
4f3240e4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
35 deletions
+40
-35
common/static/coffee/spec/discussion/view/discussion_thread_edit_view_spec.js
+3
-9
common/static/coffee/spec/discussion/view/new_post_view_spec.coffee
+2
-3
common/static/coffee/src/discussion/discussion_module_view.coffee
+5
-1
common/static/coffee/src/discussion/views/discussion_thread_edit_view.js
+14
-20
common/static/coffee/src/discussion/views/discussion_thread_view.coffee
+14
-0
common/static/coffee/src/discussion/views/new_post_view.coffee
+2
-2
No files found.
common/static/coffee/spec/discussion/view/discussion_thread_edit_view_spec.js
View file @
bb6cd7dc
...
@@ -29,10 +29,7 @@
...
@@ -29,10 +29,7 @@
testUpdate
=
function
(
view
,
thread
)
{
testUpdate
=
function
(
view
,
thread
)
{
spyOn
(
$
,
'ajax'
).
andCallFake
(
function
(
params
)
{
spyOn
(
$
,
'ajax'
).
andCallFake
(
function
(
params
)
{
expect
(
params
.
url
.
path
()).
toEqual
(
DiscussionUtil
.
urlFor
(
'update_thread'
,
'dummy_id'
));
expect
(
params
.
url
.
path
()).
toEqual
(
DiscussionUtil
.
urlFor
(
'update_thread'
,
'dummy_id'
));
if
(
view
.
isTabMode
())
{
expect
(
params
.
data
.
thread_type
).
toBe
(
'discussion'
);
// TODO remove the tabMode condition, depends on #5554 / TNL-606
expect
(
params
.
data
.
thread_type
).
toBe
(
'discussion'
);
}
expect
(
params
.
data
.
commentable_id
).
toBe
(
'other_topic'
);
expect
(
params
.
data
.
commentable_id
).
toBe
(
'other_topic'
);
expect
(
params
.
data
.
title
).
toBe
(
'changed thread title'
);
expect
(
params
.
data
.
title
).
toBe
(
'changed thread title'
);
params
.
success
();
params
.
success
();
...
@@ -45,15 +42,12 @@
...
@@ -45,15 +42,12 @@
expect
(
$
.
ajax
).
toHaveBeenCalled
();
expect
(
$
.
ajax
).
toHaveBeenCalled
();
expect
(
thread
.
get
(
'title'
)).
toBe
(
'changed thread title'
);
expect
(
thread
.
get
(
'title'
)).
toBe
(
'changed thread title'
);
if
(
view
.
isTabMode
())
{
expect
(
thread
.
get
(
'thread_type'
)).
toBe
(
'discussion'
);
// TODO remove the tabMode condition, depends on #5554 / TNL-606
expect
(
thread
.
get
(
'thread_type'
)).
toBe
(
'discussion'
);
}
expect
(
thread
.
get
(
'commentable_id'
)).
toBe
(
'other_topic'
);
expect
(
thread
.
get
(
'commentable_id'
)).
toBe
(
'other_topic'
);
expect
(
thread
.
get
(
'courseware_title'
)).
toBe
(
'Other Topic'
);
expect
(
thread
.
get
(
'courseware_title'
)).
toBe
(
'Other Topic'
);
expect
(
view
.
$
(
'.edit-post-title'
)).
toHaveValue
(
''
);
expect
(
view
.
$
(
'.edit-post-title'
)).
toHaveValue
(
''
);
expect
(
view
.
$
(
'.wmd-preview p'
)).
toHaveText
(
''
);
expect
(
view
.
$
(
'.wmd-preview p'
)).
toHaveText
(
''
);
}
}
;
it
(
'can save new data correctly in tab mode'
,
function
()
{
it
(
'can save new data correctly in tab mode'
,
function
()
{
this
.
createEditView
();
this
.
createEditView
();
...
...
common/static/coffee/spec/discussion/view/new_post_view_spec.coffee
View file @
bb6cd7dc
...
@@ -127,9 +127,8 @@ describe "NewPostView", ->
...
@@ -127,9 +127,8 @@ describe "NewPostView", ->
view
.
$
(
".cancel"
).
click
()
view
.
$
(
".cancel"
).
click
()
expect
(
eventSpy
).
toHaveBeenCalled
()
expect
(
eventSpy
).
toHaveBeenCalled
()
expect
(
view
.
$
(
".post-errors"
).
html
()).
toEqual
(
""
);
expect
(
view
.
$
(
".post-errors"
).
html
()).
toEqual
(
""
);
if
mode
==
"tab"
expect
(
$
(
"input[id$='post-type-question']"
)).
toBeChecked
()
expect
(
$
(
"input[id$='post-type-question']"
)).
toBeChecked
()
expect
(
$
(
"input[id$='post-type-discussion']"
)).
not
.
toBeChecked
()
expect
(
$
(
"input[id$='post-type-discussion']"
)).
not
.
toBeChecked
()
expect
(
view
.
$
(
".js-post-title"
).
val
()).
toEqual
(
""
);
expect
(
view
.
$
(
".js-post-title"
).
val
()).
toEqual
(
""
);
expect
(
view
.
$
(
".js-post-body textarea"
).
val
()).
toEqual
(
""
);
expect
(
view
.
$
(
".js-post-body textarea"
).
val
()).
toEqual
(
""
);
expect
(
view
.
$
(
".js-follow"
)).
toBeChecked
()
expect
(
view
.
$
(
".js-follow"
)).
toBeChecked
()
...
...
common/static/coffee/src/discussion/discussion_module_view.coffee
View file @
bb6cd7dc
...
@@ -99,13 +99,17 @@ if Backbone?
...
@@ -99,13 +99,17 @@ if Backbone?
@
newPostForm
=
$
(
'.new-post-article'
)
@
newPostForm
=
$
(
'.new-post-article'
)
@
threadviews
=
@
discussion
.
map
(
thread
)
=>
@
threadviews
=
@
discussion
.
map
(
thread
)
=>
new
DiscussionThreadView
(
view
=
new
DiscussionThreadView
(
el
:
@
$
(
"article#thread_
#{
thread
.
id
}
"
),
el
:
@
$
(
"article#thread_
#{
thread
.
id
}
"
),
model
:
thread
,
model
:
thread
,
mode
:
"inline"
,
mode
:
"inline"
,
course_settings
:
@
course_settings
,
course_settings
:
@
course_settings
,
topicId
:
discussionId
topicId
:
discussionId
)
)
thread
.
on
"thread:thread_type_updated"
,
->
view
.
rerender
()
view
.
expand
()
return
view
_
.
each
@
threadviews
,
(
dtv
)
->
dtv
.
render
()
_
.
each
@
threadviews
,
(
dtv
)
->
dtv
.
render
()
DiscussionUtil
.
bulkUpdateContentInfo
(
window
.
$
$annotated_content_info
)
DiscussionUtil
.
bulkUpdateContentInfo
(
window
.
$
$annotated_content_info
)
@
newPostView
=
new
NewPostView
(
@
newPostView
=
new
NewPostView
(
...
...
common/static/coffee/src/discussion/views/discussion_thread_edit_view.js
View file @
bb6cd7dc
...
@@ -28,11 +28,9 @@
...
@@ -28,11 +28,9 @@
this
.
template
=
_
.
template
(
$
(
'#thread-edit-template'
).
html
());
this
.
template
=
_
.
template
(
$
(
'#thread-edit-template'
).
html
());
this
.
$el
.
html
(
this
.
template
(
this
.
model
.
toJSON
())).
appendTo
(
this
.
container
);
this
.
$el
.
html
(
this
.
template
(
this
.
model
.
toJSON
())).
appendTo
(
this
.
container
);
this
.
submitBtn
=
this
.
$
(
'.post-update'
);
this
.
submitBtn
=
this
.
$
(
'.post-update'
);
if
(
this
.
isTabMode
())
{
threadTypeTemplate
=
_
.
template
(
$
(
"#thread-type-template"
).
html
());
threadTypeTemplate
=
_
.
template
(
$
(
"#thread-type-template"
).
html
());
this
.
addField
(
threadTypeTemplate
({
form_id
:
formId
}));
this
.
addField
(
threadTypeTemplate
({
form_id
:
formId
}));
this
.
$
(
"#"
+
formId
+
"-post-type-"
+
this
.
threadType
).
attr
(
'checked'
,
true
);
this
.
$
(
"#"
+
formId
+
"-post-type-"
+
this
.
threadType
).
attr
(
'checked'
,
true
);
}
this
.
topicView
=
new
DiscussionTopicMenuView
({
this
.
topicView
=
new
DiscussionTopicMenuView
({
topicId
:
this
.
topicId
,
topicId
:
this
.
topicId
,
course_settings
:
this
.
course_settings
course_settings
:
this
.
course_settings
...
@@ -55,7 +53,13 @@
...
@@ -55,7 +53,13 @@
var
title
=
this
.
$
(
'.edit-post-title'
).
val
(),
var
title
=
this
.
$
(
'.edit-post-title'
).
val
(),
threadType
=
this
.
$
(
".post-type-input:checked"
).
val
(),
threadType
=
this
.
$
(
".post-type-input:checked"
).
val
(),
body
=
this
.
$
(
'.edit-post-body textarea'
).
val
(),
body
=
this
.
$
(
'.edit-post-body textarea'
).
val
(),
commentableId
=
this
.
topicView
.
getCurrentTopicId
();
commentableId
=
this
.
topicView
.
getCurrentTopicId
(),
postData
=
{
title
:
title
,
thread_type
:
threadType
,
body
:
body
,
commentable_id
:
commentableId
};
return
DiscussionUtil
.
safeAjax
({
return
DiscussionUtil
.
safeAjax
({
$elem
:
this
.
submitBtn
,
$elem
:
this
.
submitBtn
,
...
@@ -64,28 +68,18 @@
...
@@ -64,28 +68,18 @@
type
:
'POST'
,
type
:
'POST'
,
dataType
:
'json'
,
dataType
:
'json'
,
async
:
false
,
// @TODO when the rest of the stuff below is made to work properly..
async
:
false
,
// @TODO when the rest of the stuff below is made to work properly..
data
:
{
data
:
postData
,
title
:
title
,
thread_type
:
threadType
,
body
:
body
,
commentable_id
:
commentableId
},
error
:
DiscussionUtil
.
formErrorHandler
(
this
.
$
(
'.post-errors'
)),
error
:
DiscussionUtil
.
formErrorHandler
(
this
.
$
(
'.post-errors'
)),
success
:
function
()
{
success
:
function
()
{
var
newAttrs
=
{
title
:
title
,
body
:
body
,
thread_type
:
threadType
,
commentable_id
:
commentableId
,
courseware_title
:
this
.
topicView
.
getFullTopicName
()
};
// @TODO: Move this out of the callback, this makes it feel sluggish
// @TODO: Move this out of the callback, this makes it feel sluggish
this
.
$
(
'.edit-post-title'
).
val
(
''
).
attr
(
'prev-text'
,
''
);
this
.
$
(
'.edit-post-title'
).
val
(
''
).
attr
(
'prev-text'
,
''
);
this
.
$
(
'.edit-post-body textarea'
).
val
(
''
).
attr
(
'prev-text'
,
''
);
this
.
$
(
'.edit-post-body textarea'
).
val
(
''
).
attr
(
'prev-text'
,
''
);
this
.
$
(
'.wmd-preview p'
).
html
(
''
);
this
.
$
(
'.wmd-preview p'
).
html
(
''
);
this
.
model
.
set
(
newAttrs
).
unset
(
'abbreviatedBody'
);
postData
.
courseware_title
=
this
.
topicView
.
getFullTopicName
();
this
.
model
.
set
(
postData
).
unset
(
'abbreviatedBody'
);
this
.
trigger
(
'thread:updated'
);
this
.
trigger
(
'thread:updated'
);
if
(
this
.
threadType
!==
threadType
)
{
if
(
this
.
threadType
!==
threadType
)
{
this
.
model
.
set
(
"thread_type"
,
threadType
)
this
.
model
.
trigger
(
'thread:thread_type_updated'
);
this
.
model
.
trigger
(
'thread:thread_type_updated'
);
this
.
trigger
(
'comment:endorse'
);
this
.
trigger
(
'comment:endorse'
);
}
}
...
...
common/static/coffee/src/discussion/views/discussion_thread_view.coffee
View file @
bb6cd7dc
...
@@ -34,6 +34,20 @@ if Backbone?
...
@@ -34,6 +34,20 @@ if Backbone?
if
@
isQuestion
()
if
@
isQuestion
()
@
markedAnswers
=
new
Comments
()
@
markedAnswers
=
new
Comments
()
rerender
:
()
->
if
@
showView
?
@
showView
.
undelegateEvents
()
@
undelegateEvents
()
@
$el
.
empty
()
@
initialize
(
mode
:
@
mode
model
:
@
model
el
:
@
el
course_settings
:
@
course_settings
topicId
:
@
topicId
)
@
render
()
renderTemplate
:
->
renderTemplate
:
->
@
template
=
_
.
template
(
$
(
"#thread-template"
).
html
())
@
template
=
_
.
template
(
$
(
"#thread-template"
).
html
())
@
template
(
@
model
.
toJSON
())
@
template
(
@
model
.
toJSON
())
...
...
common/static/coffee/src/discussion/views/new_post_view.coffee
View file @
bb6cd7dc
...
@@ -16,9 +16,9 @@ if Backbone?
...
@@ -16,9 +16,9 @@ if Backbone?
form_id
:
@
mode
+
(
if
@
topicId
then
"-"
+
@
topicId
else
""
)
form_id
:
@
mode
+
(
if
@
topicId
then
"-"
+
@
topicId
else
""
)
})
})
@
$el
.
html
(
_
.
template
(
$
(
"#new-post-template"
).
html
(),
context
))
@
$el
.
html
(
_
.
template
(
$
(
"#new-post-template"
).
html
(),
context
))
threadTypeTemplate
=
_
.
template
(
$
(
"#thread-type-template"
).
html
());
@
addField
(
threadTypeTemplate
({
form_id
:
_
.
uniqueId
(
"form-"
)}));
if
@
isTabMode
()
if
@
isTabMode
()
threadTypeTemplate
=
_
.
template
(
$
(
"#thread-type-template"
).
html
());
@
addField
(
threadTypeTemplate
({
form_id
:
_
.
uniqueId
(
"form-"
)}));
@
topicView
=
new
DiscussionTopicMenuView
{
@
topicView
=
new
DiscussionTopicMenuView
{
topicId
:
@
topicId
topicId
:
@
topicId
course_settings
:
@
course_settings
course_settings
:
@
course_settings
...
...
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