mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
admins can now clear flags inline
This commit is contained in:
parent
0f5bef61dc
commit
c7461622a9
10 changed files with 86 additions and 10 deletions
|
@ -259,6 +259,9 @@ Discourse.TopicController = Ember.ObjectController.extend Discourse.Presence,
|
|||
post.toggleProperty('bookmarked')
|
||||
false
|
||||
|
||||
clearFlags: (actionType) ->
|
||||
actionType.clearFlags()
|
||||
|
||||
# Who acted on a particular post / action type
|
||||
whoActed: (actionType) ->
|
||||
actionType.loadUsers()
|
||||
|
|
|
@ -18,7 +18,7 @@ window.Discourse.ActionSummary = Em.Object.extend Discourse.Presence,
|
|||
@set('acted', false)
|
||||
@set('count', @get('count') - 1)
|
||||
@set('can_act', true)
|
||||
@set('can_undo', false)
|
||||
@set('can_undo', false)
|
||||
|
||||
# Perform this action
|
||||
act: (opts) ->
|
||||
|
@ -52,16 +52,28 @@ window.Discourse.ActionSummary = Em.Object.extend Discourse.Presence,
|
|||
@removeAction()
|
||||
|
||||
# Remove our post action
|
||||
jQuery.ajax
|
||||
jQuery.ajax
|
||||
url: "/post_actions/#{@get('post.id')}"
|
||||
type: 'DELETE'
|
||||
data:
|
||||
post_action_type_id: @get('id')
|
||||
post_action_type_id: @get('id')
|
||||
|
||||
clearFlags: ->
|
||||
$.ajax
|
||||
url: "/post_actions/clear_flags"
|
||||
type: "POST"
|
||||
data:
|
||||
post_action_type_id: @get('id')
|
||||
id: @get('post.id')
|
||||
success: (result) =>
|
||||
@set('post.hidden', result.hidden)
|
||||
@set('count', 0)
|
||||
|
||||
|
||||
loadUsers: ->
|
||||
$.getJSON "/post_actions/users",
|
||||
id: @get('post.id'),
|
||||
post_action_type_id: @get('id')
|
||||
(result) =>
|
||||
(result) =>
|
||||
@set('users', Em.A())
|
||||
result.each (u) => @get('users').pushObject(Discourse.User.create(u))
|
||||
|
|
|
@ -35,12 +35,20 @@ window.Discourse.ActionsHistoryView = Em.View.extend Discourse.Presence,
|
|||
|
||||
if c.get('can_undo')
|
||||
alsoName = Em.String.i18n("post.actions.undo", alsoName: c.get('actionType.alsoNameLower'))
|
||||
buffer.push(" <a href='#' data-undo='#{c.get('id')}'>#{alsoName}</a>.")
|
||||
buffer.push(" <a href='#' data-undo='#{c.get('id')}'>#{alsoName}</a>.")
|
||||
|
||||
if c.get('can_clear_flags')
|
||||
buffer.push(" <a href='#' data-clear-flags='#{c.get('id')}'>#{Em.String.i18n("post.actions.clear_flags",count: c.count)}</a>.")
|
||||
|
||||
buffer.push("</div>")
|
||||
|
||||
click: (e) ->
|
||||
$target = $(e.target)
|
||||
|
||||
if actionTypeId = $target.data('clear-flags')
|
||||
@get('controller').clearFlags(@content.findProperty('id', actionTypeId))
|
||||
return false
|
||||
|
||||
# User wants to know who actioned it
|
||||
if actionTypeId = $target.data('who-acted')
|
||||
@get('controller').whoActed(@content.findProperty('id', actionTypeId))
|
||||
|
@ -54,4 +62,4 @@ window.Discourse.ActionsHistoryView = Em.View.extend Discourse.Presence,
|
|||
@get('controller').undoAction(@content.findProperty('id', actionTypeId))
|
||||
return false
|
||||
|
||||
false
|
||||
false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue