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
a242a7f1
Commit
a242a7f1
authored
Sep 04, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make delete work for responses
parent
0e6b7d77
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
5 deletions
+30
-5
lms/static/coffee/src/discussion/views/discussion_thread_view.coffee
+3
-0
lms/static/coffee/src/discussion/views/thread_response_view.coffee
+24
-2
lms/templates/discussion/_underscore_templates.html
+3
-3
No files found.
lms/static/coffee/src/discussion/views/discussion_thread_view.coffee
View file @
a242a7f1
...
...
@@ -63,6 +63,7 @@ class @DiscussionThreadView extends DiscussionContentView
@
trigger
"thread:responses:rendered"
renderResponse
:
(
response
)
=>
response
.
set
(
'thread'
,
@
model
)
view
=
new
ThreadResponseView
(
model
:
response
)
view
.
on
"comment:add"
,
@
addComment
view
.
render
()
...
...
@@ -136,6 +137,8 @@ class @DiscussionThreadView extends DiscussionContentView
delete
:
(
event
)
->
url
=
@
model
.
urlFor
(
'delete'
)
if
not
@
model
.
can
(
'can_delete'
)
return
if
not
confirm
"Are you sure to delete thread
\"
#{
@
model
.
get
(
'title'
)
}
\"
?"
return
@
model
.
remove
()
...
...
lms/static/coffee/src/discussion/views/thread_response_view.coffee
View file @
a242a7f1
...
...
@@ -6,9 +6,13 @@ class @ThreadResponseView extends DiscussionContentView
"click .vote-btn"
:
"toggleVote"
"submit form"
:
"submitComment"
"click .action-endorse"
:
"toggleEndorse"
"click .action-delete"
:
"delete"
render
:
->
@
$el
.
html
(
@
template
(
@
model
.
toJSON
()))
@
initLocal
()
console
.
log
@
$local
@
delegateEvents
()
if
window
.
user
.
voted
(
@
model
)
@
$
(
".vote-btn"
).
addClass
(
"is-cast"
)
@
renderAttrs
()
...
...
@@ -23,12 +27,13 @@ class @ThreadResponseView extends DiscussionContentView
MathJax
.
Hub
.
Queue
[
"Typeset"
,
MathJax
.
Hub
,
element
[
0
]]
renderComments
:
->
@
model
.
get
(
"comments"
).
each
@
renderComment
@
model
.
get
(
"comments"
).
each
@
renderComment
renderComment
:
(
comment
)
=>
comment
.
set
(
'thread'
,
@
model
.
get
(
'thread'
))
view
=
new
ResponseCommentView
(
model
:
comment
)
view
.
render
()
@
$
(
".comments li:last"
).
before
(
view
.
el
)
@
$
el
.
find
(
".comments li:last"
).
before
(
view
.
el
)
toggleVote
:
(
event
)
->
event
.
preventDefault
()
...
...
@@ -79,6 +84,23 @@ class @ThreadResponseView extends DiscussionContentView
data
:
body
:
body
delete
:
(
event
)
->
event
.
preventDefault
()
if
not
@
model
.
can
(
'can_delete'
)
return
console
.
log
$
(
event
.
target
)
url
=
@
model
.
urlFor
(
'delete'
)
if
not
confirm
"Are you sure to delete this response? "
return
@
model
.
remove
()
@
$el
.
remove
()
$elem
=
$
(
event
.
target
)
DiscussionUtil
.
safeAjax
$elem
:
$elem
url
:
url
type
:
"POST"
success
:
(
response
,
textStatus
)
=>
toggleEndorse
:
(
event
)
->
event
.
preventDefault
()
if
not
@
model
.
can
(
'can_endorse'
)
...
...
lms/templates/discussion/_underscore_templates.html
View file @
a242a7f1
...
...
@@ -45,14 +45,14 @@
</script>
<script
type=
"text/template"
id=
"thread-response-template"
>
<
header
>
<
header
class
=
"local"
>
<
a
href
=
"javascript:void(0)"
class
=
"vote-btn"
data
-
tooltip
=
"vote"
><
span
class
=
"plus-icon"
><
/span><span class="votes-count-number">${"<%- votes
[
'up_count'
]
%>"}</
span
><
/a
>
<
a
href
=
"javascript:void(0)"
class
=
"endorse-btn${'<% if (endorsed) { %> is-endorsed<% } %>'} action-endorse"
style
=
"cursor: default"
data
-
tooltip
=
"endorse"
><
span
class
=
"check-icon"
style
=
"pointer-events: none; "
><
/span></
a
>
<
a
href
=
"${'<%- user_url %>'}"
class
=
"posted-by"
>
$
{
"<%- username %>"
}
<
/a
>
<
p
class
=
"posted-details"
title
=
"${'<%- created_at %>'}"
>
Sometime
<
/p
>
<
/header
>
<
div
class
=
"
response-body"
>
$
{
"<%- body %>"
}
<
/div
>
<
ul
class
=
"moderator-actions"
>
<
div
class
=
"
local"
><
div
class
=
"response-body"
>
$
{
"<%- body %>"
}
<
/div>
</
div
>
<
ul
class
=
"moderator-actions
local
"
>
<
li
style
=
"display: none"
><
a
class
=
"action-edit"
href
=
"javascript:void(0)"
><
span
class
=
"edit-icon"
><
/span> Edit</
a
><
/li
>
<
li
style
=
"display: none"
><
a
class
=
"action-delete"
href
=
"javascript:void(0)"
><
span
class
=
"delete-icon"
><
/span> Delete</
a
><
/li
>
<
li
style
=
"display: none"
><
a
class
=
"action-openclose"
href
=
"javascript:void(0)"
><
span
class
=
"edit-icon"
><
/span> Close</
a
><
/li
>
...
...
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