mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 07:03:39 +08:00
improving flag handling, links and delete button
This commit is contained in:
parent
c7461622a9
commit
7b123e12dd
|
@ -7,6 +7,13 @@ window.Discourse.AdminFlagsController = Ember.Controller.extend
|
||||||
bootbox.alert("something went wrong")
|
bootbox.alert("something went wrong")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
deletePost: (item) ->
|
||||||
|
item.deletePost().then (=>
|
||||||
|
@content.removeObject(item)
|
||||||
|
), (->
|
||||||
|
bootbox.alert("something went wrong")
|
||||||
|
)
|
||||||
|
|
||||||
adminOldFlagsView: (->
|
adminOldFlagsView: (->
|
||||||
@query == 'old'
|
@query == 'old'
|
||||||
).property('query')
|
).property('query')
|
||||||
|
|
|
@ -28,6 +28,25 @@ window.Discourse.FlaggedPost = Discourse.Post.extend
|
||||||
@get('topic_visible') == 'f'
|
@get('topic_visible') == 'f'
|
||||||
).property('topic_hidden')
|
).property('topic_hidden')
|
||||||
|
|
||||||
|
deletePost: ->
|
||||||
|
promise = new RSVP.Promise()
|
||||||
|
if @get('post_number') == "1"
|
||||||
|
$.ajax "/t/#{@topic_id}",
|
||||||
|
type: 'DELETE'
|
||||||
|
cache: false
|
||||||
|
success: ->
|
||||||
|
promise.resolve()
|
||||||
|
error: (e)->
|
||||||
|
promise.reject()
|
||||||
|
else
|
||||||
|
$.ajax "/posts/#{@id}",
|
||||||
|
type: 'DELETE'
|
||||||
|
cache: false
|
||||||
|
success: ->
|
||||||
|
promise.resolve()
|
||||||
|
error: (e)->
|
||||||
|
promise.reject()
|
||||||
|
|
||||||
clearFlags: ->
|
clearFlags: ->
|
||||||
promise = new RSVP.Promise()
|
promise = new RSVP.Promise()
|
||||||
$.ajax "/admin/flags/clear/#{@id}",
|
$.ajax "/admin/flags/clear/#{@id}",
|
||||||
|
|
|
@ -21,14 +21,15 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
{{#each content}}
|
{{#each content}}
|
||||||
<tr {{bindAttr class="hiddenClass"}}>
|
<tr {{bindAttr class="hiddenClass"}}>
|
||||||
<td class='user'>{{avatar user imageSize="small"}}</td>
|
<td class='user'><a href="/admin{{unbound user.path}}">{{avatar user imageSize="small"}}</a></td>
|
||||||
<td class='excerpt'>{{#if topicHidden}}<i title='this topic is invisible' class='icon icon-eye-close'></i> {{/if}}<h3><a href='{{unbound url}}'>{{title}}</a></h3><br>{{{excerpt}}}
|
<td class='excerpt'>{{#if topicHidden}}<i title='this topic is invisible' class='icon icon-eye-close'></i> {{/if}}<h3><a href='{{unbound url}}'>{{title}}</a></h3><br>{{{excerpt}}}
|
||||||
</td>
|
</td>
|
||||||
<td class='flaggers'>{{#each flaggers}}{{avatar this imageSize="small"}}{{/each}}</td>
|
<td class='flaggers'>{{#each flaggers}}<a href="/admin{{unbound path}}">{{avatar this imageSize="small"}}</a>{{/each}}</td>
|
||||||
<td class='last-flagged'>{{date lastFlagged}}</td>
|
<td class='last-flagged'>{{date lastFlagged}}</td>
|
||||||
<td class='action'>
|
<td class='action'>
|
||||||
{{#if controller.adminActiveFlagsView}}
|
{{#if controller.adminActiveFlagsView}}
|
||||||
<button title='dismiss all flags on this post (will unhide hidden posts)' class='btn' {{action clearFlags this}}>Clear Flags</button>
|
<button title='{{i18n admin.flags.clear_title}}' class='btn' {{action clearFlags this}}>{{i18n admin.flags.clear}}</button>
|
||||||
|
<button title='{{i18n admin.flags.delete_title}}' class='btn' {{action deletePost this}}>{{i18n admin.flags.delete}}</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -314,6 +314,10 @@ en:
|
||||||
title: "Flags"
|
title: "Flags"
|
||||||
old: "Old"
|
old: "Old"
|
||||||
active: "Active"
|
active: "Active"
|
||||||
|
clear: "Clear Flags"
|
||||||
|
clear_title: "dismiss all flags on this post (will unhide hidden posts)"
|
||||||
|
delete: "Delete Post"
|
||||||
|
delete_title: "delete post (if its the first post delete topic)"
|
||||||
|
|
||||||
customize:
|
customize:
|
||||||
title: "Customize"
|
title: "Customize"
|
||||||
|
|
|
@ -63,15 +63,10 @@ describe Post do
|
||||||
post = Fabricate(:post)
|
post = Fabricate(:post)
|
||||||
user = Fabricate(:coding_horror)
|
user = Fabricate(:coding_horror)
|
||||||
PostAction.act(user, post, PostActionType.Types[:off_topic])
|
PostAction.act(user, post, PostActionType.Types[:off_topic])
|
||||||
PostAction.act(post.user, post, PostActionType.Types[:spam])
|
|
||||||
|
|
||||||
post.reload
|
post.reload
|
||||||
post.is_flagged?.should == true
|
post.is_flagged?.should == true
|
||||||
|
|
||||||
PostAction.remove_act(post.user, post, PostActionType.Types[:spam])
|
|
||||||
post.reload
|
|
||||||
post.is_flagged?.should == true
|
|
||||||
|
|
||||||
PostAction.remove_act(user, post, PostActionType.Types[:off_topic])
|
PostAction.remove_act(user, post, PostActionType.Types[:off_topic])
|
||||||
post.reload
|
post.reload
|
||||||
post.is_flagged?.should == false
|
post.is_flagged?.should == false
|
||||||
|
|
Loading…
Reference in New Issue
Block a user