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
12eeb30c
Commit
12eeb30c
authored
Sep 04, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete threads
parent
d9edc1b4
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
51 additions
and
7 deletions
+51
-7
lms/static/coffee/src/discussion/content.coffee
+10
-0
lms/static/coffee/src/discussion/discussion.coffee
+3
-0
lms/static/coffee/src/discussion/discussion_router.coffee
+5
-0
lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
+6
-0
lms/static/coffee/src/discussion/views/discussion_thread_view.coffee
+15
-4
lms/static/coffee/src/discussion/views/thread_list_item_view.coffee
+11
-2
lms/static/coffee/src/discussion/views/thread_response_view.coffee
+1
-1
No files found.
lms/static/coffee/src/discussion/content.coffee
View file @
12eeb30c
...
...
@@ -36,12 +36,14 @@ if Backbone?
@
get
(
'children'
).
push
comment
model
=
new
Comment
$
.
extend
{},
comment
,
{
thread
:
@
get
(
'thread'
)
}
@
get
(
'comments'
).
add
model
@
trigger
"comment:add"
model
removeComment
:
(
comment
)
->
thread
=
@
get
(
'thread'
)
comments_count
=
parseInt
(
thread
.
get
(
'comments_count'
))
thread
.
set
(
'comments_count'
,
comments_count
-
1
-
comment
.
getCommentsCount
())
@
trigger
"comment:remove"
resetComments
:
(
children
)
->
@
set
'children'
,
[]
...
...
@@ -56,6 +58,14 @@ if Backbone?
@
set
'user_url'
,
DiscussionUtil
.
urlFor
(
'user_profile'
,
@
get
(
'user_id'
))
@
resetComments
(
@
get
(
'children'
))
remove
:
->
if
@
get
(
'type'
)
==
'comment'
@
get
(
'thread'
).
removeComment
(
@
)
@
get
(
'thread'
).
trigger
"comment:remove"
,
@
else
@
trigger
"thread:remove"
,
@
@
addContent
:
(
id
,
content
)
->
@
contents
[
id
]
=
content
@
getContent
:
(
id
)
->
@
contents
[
id
]
...
...
lms/static/coffee/src/discussion/discussion.coffee
View file @
12eeb30c
...
...
@@ -6,6 +6,9 @@ if Backbone?
@
bind
"add"
,
(
item
)
=>
item
.
discussion
=
@
@
comparator
=
@
sortByDateRecentFirst
@
on
"thread:remove"
,
(
thread
)
=>
console
.
log
"remove triggered"
@
remove
(
thread
)
find
:
(
id
)
->
_
.
first
@
where
(
id
:
id
)
...
...
lms/static/coffee/src/discussion/discussion_router.coffee
View file @
12eeb30c
...
...
@@ -7,6 +7,7 @@ class @DiscussionRouter extends Backbone.Router
@
discussion
=
options
[
'discussion'
]
@
nav
=
new
DiscussionThreadListView
(
collection
:
@
discussion
,
el
:
$
(
".sidebar"
))
@
nav
.
on
"thread:selected"
,
@
navigateToThread
@
nav
.
on
"thread:removed"
,
@
navigateToAllThreads
@
nav
.
on
"threads:rendered"
,
@
setActiveThread
@
nav
.
render
()
...
...
@@ -33,3 +34,7 @@ class @DiscussionRouter extends Backbone.Router
navigateToThread
:
(
thread_id
)
=>
thread
=
@
discussion
.
get
(
thread_id
)
@
navigate
(
"
#{
thread
.
get
(
"commentable_id"
)
}
/threads/
#{
thread_id
}
"
,
trigger
:
true
)
navigateToAllThreads
:
=>
console
.
log
"navigating"
@
navigate
(
""
,
trigger
:
true
)
lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
View file @
12eeb30c
...
...
@@ -21,6 +21,7 @@ class @DiscussionThreadListView extends Backbone.View
@
timer
=
0
@
$el
.
html
(
@
template
())
@
displayedCollection
.
on
"reset"
,
@
renderThreads
@
displayedCollection
.
on
"thread:remove"
,
@
renderThreads
@
renderThreads
()
@
...
...
@@ -30,8 +31,10 @@ class @DiscussionThreadListView extends Backbone.View
@
trigger
"threads:rendered"
renderThreadListItem
:
(
thread
)
=>
console
.
log
"rendering"
view
=
new
ThreadListItemView
(
model
:
thread
)
view
.
on
"thread:selected"
,
@
threadSelected
view
.
on
"thread:removed"
,
@
threadRemoved
view
.
render
()
@
$
(
".post-list"
).
append
(
view
.
el
)
...
...
@@ -39,6 +42,9 @@ class @DiscussionThreadListView extends Backbone.View
@
setActiveThread
(
thread_id
)
@
trigger
(
"thread:selected"
,
thread_id
)
threadRemoved
:
(
thread_id
)
=>
@
trigger
(
"thread:removed"
,
thread_id
)
setActiveThread
:
(
thread_id
)
->
@
$
(
".post-list a"
).
removeClass
(
"active"
)
@
$
(
"a[data-id='
#{
thread_id
}
']"
).
addClass
(
"active"
)
...
...
lms/static/coffee/src/discussion/views/discussion_thread_view.coffee
View file @
12eeb30c
...
...
@@ -60,7 +60,7 @@ class @DiscussionThreadView extends DiscussionContentView
@
$
(
".responses"
).
append
(
view
.
el
)
addComment
:
=>
@
model
.
trigger
"comment:add"
toggleVote
:
(
event
)
->
event
.
preventDefault
()
...
...
@@ -110,8 +110,9 @@ class @DiscussionThreadView extends DiscussionContentView
url
=
@
model
.
urlFor
(
'reply'
)
body
=
@
$
(
"#wmd-input"
).
val
()
response
=
new
Comment
(
body
:
body
,
created_at
:
(
new
Date
()).
toISOString
(),
username
:
window
.
user
.
get
(
"username"
),
votes
:
{
up_count
:
0
},
endorsed
:
false
,
user_id
:
window
.
user
.
get
(
"id"
))
response
.
set
(
'thread'
,
@
model
.
get
(
'thread'
))
@
renderResponse
(
response
)
@
addComment
()
@
model
.
addComment
()
DiscussionUtil
.
safeAjax
$elem
:
$
(
event
.
target
)
...
...
@@ -123,8 +124,18 @@ class @DiscussionThreadView extends DiscussionContentView
edit
:
->
delete
:
->
delete
:
(
event
)
->
url
=
@
model
.
urlFor
(
'delete'
)
if
not
confirm
"Are you sure to delete thread
\"
#{
@
model
.
get
(
'title'
)
}
\"
?"
return
@
model
.
remove
()
$elem
=
$
(
event
.
target
)
DiscussionUtil
.
safeAjax
$elem
:
$elem
url
:
url
type
:
"POST"
success
:
(
response
,
textStatus
)
=>
toggleClosed
:
(
event
)
->
$elem
=
$
(
event
.
target
)
url
=
@
model
.
urlFor
(
'close'
)
...
...
lms/static/coffee/src/discussion/views/thread_list_item_view.coffee
View file @
12eeb30c
...
...
@@ -5,23 +5,32 @@ class @ThreadListItemView extends Backbone.View
"click a"
:
"threadSelected"
initialize
:
->
@
model
.
on
"change"
,
@
render
@
model
.
on
"thread:remove"
,
@
threadRemoved
@
model
.
on
"thread:follow"
,
@
follow
@
model
.
on
"thread:unfollow"
,
@
unfollow
@
model
.
on
"comment:add"
,
@
addComment
@
model
.
on
"comment:remove"
,
@
removeComment
render
:
=>
@
$el
.
html
(
@
template
(
@
model
.
toJSON
()))
if
window
.
user
.
following
(
@
model
)
@
follow
()
@
threadSelected
:
(
event
)
->
event
.
preventDefault
()
@
trigger
(
"thread:selected"
,
@
model
.
id
)
threadRemoved
:
=>
@
trigger
(
"thread:removed"
,
@
model
.
id
)
follow
:
=>
@
$
(
"a"
).
addClass
(
"followed"
)
unfollow
:
=>
@
$
(
"a"
).
removeClass
(
"followed"
)
addComment
:
=>
@
$
(
".comments-count"
).
html
(
parseInt
(
@
$
(
".comments-count"
).
html
())
+
1
)
addComment
:
(
comment
)
=>
@
$
(
".comments-count"
).
html
(
@
model
.
get
(
'comments_count'
))
removeComment
:
(
comment
)
=>
@
$
(
".comments-count"
).
html
(
@
model
.
get
(
'comments_count'
))
lms/static/coffee/src/discussion/views/thread_response_view.coffee
View file @
12eeb30c
...
...
@@ -68,7 +68,7 @@ class @ThreadResponseView extends DiscussionContentView
return
comment
=
new
Comment
(
body
:
body
,
created_at
:
(
new
Date
()).
toISOString
(),
username
:
window
.
user
.
get
(
"username"
),
user_id
:
window
.
user
.
get
(
"id"
))
@
renderComment
(
comment
)
@
trigger
"comment:add"
@
trigger
"comment:add"
,
comment
@
$
(
".comment-form-input"
).
val
(
""
)
DiscussionUtil
.
safeAjax
...
...
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