Add loading route support to admin flags
This commit is contained in:
parent
dc4da6b013
commit
873277ae5f
|
@ -2,10 +2,10 @@ import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
|||
import ObjectController from 'discourse/controllers/object';
|
||||
|
||||
export default ObjectController.extend(ModalFunctionality, {
|
||||
needs: ["adminFlags"],
|
||||
needs: ["admin-flags-list"],
|
||||
|
||||
_agreeFlag: function (actionOnPost) {
|
||||
var adminFlagController = this.get("controllers.adminFlags");
|
||||
var adminFlagController = this.get("controllers.admin-flags-list");
|
||||
var post = this.get("content");
|
||||
var self = this;
|
||||
|
||||
|
|
|
@ -3,13 +3,12 @@ import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
|||
import ObjectController from 'discourse/controllers/object';
|
||||
|
||||
export default ObjectController.extend(ModalFunctionality, {
|
||||
|
||||
needs: ["adminFlags"],
|
||||
needs: ["admin-flags-list"],
|
||||
|
||||
actions: {
|
||||
|
||||
deletePostDeferFlag: function () {
|
||||
var adminFlagController = this.get("controllers.adminFlags");
|
||||
var adminFlagController = this.get("controllers.admin-flags-list");
|
||||
var post = this.get("content");
|
||||
var self = this;
|
||||
|
||||
|
@ -22,7 +21,7 @@ export default ObjectController.extend(ModalFunctionality, {
|
|||
},
|
||||
|
||||
deletePostAgreeFlag: function () {
|
||||
var adminFlagController = this.get("controllers.adminFlags");
|
||||
var adminFlagController = this.get("controllers.admin-flags-list");
|
||||
var post = this.get("content");
|
||||
var self = this;
|
||||
|
||||
|
|
|
@ -1,18 +1,10 @@
|
|||
/**
|
||||
This controller supports the interface for dealing with flags in the admin section.
|
||||
|
||||
@class AdminFlagsController
|
||||
@extends Ember.Controller
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
export default Ember.ArrayController.extend({
|
||||
query: null,
|
||||
|
||||
adminOldFlagsView: Em.computed.equal("query", "old"),
|
||||
adminActiveFlagsView: Em.computed.equal("query", "active"),
|
||||
|
||||
actions: {
|
||||
|
||||
disagreeFlags: function (flaggedPost) {
|
||||
var self = this;
|
||||
flaggedPost.disagreeFlags().then(function () {
|
|
@ -0,0 +1,5 @@
|
|||
export default Discourse.Route.extend({
|
||||
redirect: function() {
|
||||
this.replaceWith('adminFlags.list', 'active');
|
||||
}
|
||||
});
|
|
@ -0,0 +1,24 @@
|
|||
export default Discourse.Route.extend({
|
||||
model: function(params) {
|
||||
this.filter = params.filter;
|
||||
return Discourse.FlaggedPost.findAll(params.filter);
|
||||
},
|
||||
|
||||
setupController: function(controller, model) {
|
||||
controller.set('model', model);
|
||||
controller.set('query', this.filter);
|
||||
},
|
||||
|
||||
actions: {
|
||||
showAgreeFlagModal: function (flaggedPost) {
|
||||
Discourse.Route.showModal(this, 'admin_agree_flag', flaggedPost);
|
||||
this.controllerFor('modal').set('modalClass', 'agree-flag-modal');
|
||||
},
|
||||
|
||||
showDeleteFlagModal: function (flaggedPost) {
|
||||
Discourse.Route.showModal(this, 'admin_delete_flag', flaggedPost);
|
||||
this.controllerFor('modal').set('modalClass', 'delete-flag-modal');
|
||||
}
|
||||
|
||||
}
|
||||
});
|
|
@ -1,41 +0,0 @@
|
|||
Discourse.AdminFlagsIndexRoute = Discourse.Route.extend({
|
||||
redirect: function() {
|
||||
this.transitionTo('adminFlags.active');
|
||||
}
|
||||
});
|
||||
|
||||
Discourse.AdminFlagsRouteType = Discourse.Route.extend({
|
||||
model: function() {
|
||||
return Discourse.FlaggedPost.findAll(this.get('filter'));
|
||||
},
|
||||
|
||||
setupController: function(controller, model) {
|
||||
var adminFlagsController = this.controllerFor('adminFlags');
|
||||
adminFlagsController.set('content', model);
|
||||
adminFlagsController.set('query', this.get('filter'));
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
Discourse.AdminFlagsActiveRoute = Discourse.AdminFlagsRouteType.extend({
|
||||
filter: 'active',
|
||||
|
||||
actions: {
|
||||
|
||||
showAgreeFlagModal: function (flaggedPost) {
|
||||
Discourse.Route.showModal(this, 'admin_agree_flag', flaggedPost);
|
||||
this.controllerFor('modal').set('modalClass', 'agree-flag-modal');
|
||||
},
|
||||
|
||||
showDeleteFlagModal: function (flaggedPost) {
|
||||
Discourse.Route.showModal(this, 'admin_delete_flag', flaggedPost);
|
||||
this.controllerFor('modal').set('modalClass', 'delete-flag-modal');
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Discourse.AdminFlagsOldRoute = Discourse.AdminFlagsRouteType.extend({
|
||||
filter: 'old'
|
||||
});
|
|
@ -30,8 +30,7 @@ Discourse.Route.buildRoutes(function() {
|
|||
this.resource('adminReports', { path: '/reports/:type' });
|
||||
|
||||
this.resource('adminFlags', { path: '/flags' }, function() {
|
||||
this.route('active');
|
||||
this.route('old');
|
||||
this.route('list', { path: '/:filter' });
|
||||
});
|
||||
|
||||
this.resource('adminLogs', { path: '/logs' }, function() {
|
||||
|
|
|
@ -0,0 +1,155 @@
|
|||
{{#if length}}
|
||||
<table class='admin-flags'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='user'></th>
|
||||
<th class='excerpt'></th>
|
||||
<th class='flaggers'>{{i18n admin.flags.flagged_by}}</th>
|
||||
<th class='flaggers'>{{#if adminOldFlagsView}}{{i18n admin.flags.resolved_by}}{{/if}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each flaggedPost in content}}
|
||||
<tr {{bind-attr class="flaggedPost.extraClasses"}}>
|
||||
|
||||
<td class='user'>
|
||||
{{#if flaggedPost.postAuthorFlagged}}
|
||||
{{#if flaggedPost.user}}
|
||||
{{#link-to 'adminUser' flaggedPost.user}}{{avatar flaggedPost.user imageSize="small"}}{{/link-to}}
|
||||
{{#if flaggedPost.wasEdited}}<i class="fa fa-pencil" title="{{i18n admin.flags.was_edited}}"></i>{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#if adminActiveFlagsView}}
|
||||
{{#if flaggedPost.previous_flags_count}}
|
||||
<span title="{{i18n admin.flags.previous_flags_count count=flaggedPost.previous_flags_count}}" class="badge-notification flagged-posts">{{flaggedPost.previous_flags_count}}</span>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</td>
|
||||
|
||||
<td class='excerpt'>
|
||||
<h3>
|
||||
{{#if flaggedPost.topic.isPrivateMessage}}
|
||||
<span class="private-message-glyph">{{fa-icon envelope}}</span>
|
||||
{{/if}}
|
||||
{{topic-status topic=flaggedPost.topic}}
|
||||
<a href='{{unbound flaggedPost.url}}'>{{flaggedPost.topic.title}}</a>
|
||||
</h3>
|
||||
{{#if flaggedPost.postAuthorFlagged}}
|
||||
{{{flaggedPost.excerpt}}}
|
||||
{{/if}}
|
||||
</td>
|
||||
|
||||
<td class='flaggers'>
|
||||
<table>
|
||||
<tbody>
|
||||
{{#each flaggedPost.flaggers}}
|
||||
<tr>
|
||||
<td class='avatar'>
|
||||
{{#link-to 'adminUser' user}}
|
||||
{{avatar user imageSize="small"}}
|
||||
{{/link-to}}
|
||||
</td>
|
||||
<td>
|
||||
{{#link-to 'adminUser' user}}
|
||||
{{user.username}}
|
||||
{{/link-to}}
|
||||
{{format-age flaggedAt}}
|
||||
<br />
|
||||
{{flagType}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<td class='flaggers result'>
|
||||
{{#if adminOldFlagsView}}
|
||||
<table>
|
||||
<tbody>
|
||||
{{#each flaggedPost.flaggers}}
|
||||
<tr>
|
||||
<td class='avatar'>
|
||||
{{#link-to 'adminUser' disposedBy}}
|
||||
{{avatar disposedBy imageSize="small"}}
|
||||
{{/link-to}}
|
||||
</td>
|
||||
<td>
|
||||
{{format-age disposedAt}}
|
||||
{{{dispositionIcon}}}
|
||||
{{#if tookAction}}
|
||||
<i class='fa fa-gavel' title='{{i18n admin.flags.took_action}}'></i>
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{/if}}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
{{#if flaggedPost.topicFlagged}}
|
||||
<tr class='message'>
|
||||
<td></td>
|
||||
<td colspan="3">
|
||||
<div>
|
||||
{{{i18n admin.flags.topic_flagged}}} <a href='{{unbound flaggedPost.url}}' class="btn">{{i18n admin.flags.visit_topic}}</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
|
||||
{{#each flaggedPost.conversations}}
|
||||
<tr class='message'>
|
||||
<td></td>
|
||||
<td colspan="3">
|
||||
<div>
|
||||
{{#if response}}
|
||||
<p>
|
||||
{{#link-to 'adminUser' response.user}}{{avatar response.user imageSize="small"}}{{/link-to}} {{{response.excerpt}}}
|
||||
</p>
|
||||
{{#if reply}}
|
||||
<p>
|
||||
{{#link-to 'adminUser' reply.user}}{{avatar reply.user imageSize="small"}}{{/link-to}} {{{reply.excerpt}}}
|
||||
{{#if hasMore}}
|
||||
<a href="{{unbound permalink}}">{{i18n admin.flags.more}}</a>
|
||||
{{/if}}
|
||||
</p>
|
||||
{{/if}}
|
||||
<a href="{{unbound permalink}}">
|
||||
<button class='btn btn-reply'><i class="fa fa-reply"></i> {{i18n admin.flags.reply_message}}</button>
|
||||
</a>
|
||||
{{/if}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
|
||||
<tr>
|
||||
<td colspan="4" class="action">
|
||||
{{#if adminActiveFlagsView}}
|
||||
<button title='{{i18n admin.flags.agree_title}}' class='btn' {{action "showAgreeFlagModal" flaggedPost}}><i class="fa fa-thumbs-o-up"></i>{{i18n admin.flags.agree}}…</button>
|
||||
{{#if flaggedPost.postHidden}}
|
||||
<button title='{{i18n admin.flags.disagree_flag_unhide_post_title}}' class='btn' {{action "disagreeFlags" flaggedPost}}><i class="fa fa-thumbs-o-down"></i>{{i18n admin.flags.disagree_flag_unhide_post}}</button>
|
||||
{{else}}
|
||||
<button title='{{i18n admin.flags.disagree_flag_title}}' class='btn' {{action "disagreeFlags" flaggedPost}}><i class="fa fa-thumbs-o-down"></i>{{i18n admin.flags.disagree_flag}}</button>
|
||||
{{/if}}
|
||||
<button title='{{i18n admin.flags.defer_flag_title}}' class='btn' {{action "deferFlags" flaggedPost}}><i class="fa fa-external-link"></i>{{i18n admin.flags.defer_flag}}</button>
|
||||
<button title='{{i18n admin.flags.delete_title}}' class='btn btn-danger' {{action "showDeleteFlagModal" flaggedPost}}><i class="fa fa-trash-o"></i>{{i18n admin.flags.delete}}…</button>
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{{/each}}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
{{#if view.loading}}
|
||||
{{loading-spinner}}
|
||||
{{/if}}
|
||||
|
||||
{{else}}
|
||||
<p>{{i18n admin.flags.no_results}}</p>
|
||||
{{/if}}
|
|
@ -1,170 +1,12 @@
|
|||
<div class='admin-controls'>
|
||||
<div class='span15'>
|
||||
<ul class="nav nav-pills">
|
||||
<li>{{#link-to 'adminFlags.active'}}{{i18n admin.flags.active}}{{/link-to}}</li>
|
||||
<li>{{#link-to 'adminFlags.old'}}{{i18n admin.flags.old}}{{/link-to}}</li>
|
||||
<li>{{#link-to 'adminFlags.list' 'active'}}{{i18n admin.flags.active}}{{/link-to}}</li>
|
||||
<li>{{#link-to 'adminFlags.list' 'old'}}{{i18n admin.flags.old}}{{/link-to}}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-container">
|
||||
{{#if loading}}
|
||||
{{loading-spinner}}
|
||||
{{else}}
|
||||
{{#if length}}
|
||||
<table class='admin-flags'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='user'></th>
|
||||
<th class='excerpt'></th>
|
||||
<th class='flaggers'>{{i18n admin.flags.flagged_by}}</th>
|
||||
<th class='flaggers'>{{#if adminOldFlagsView}}{{i18n admin.flags.resolved_by}}{{/if}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each flaggedPost in content}}
|
||||
<tr {{bind-attr class="flaggedPost.extraClasses"}}>
|
||||
|
||||
<td class='user'>
|
||||
{{#if flaggedPost.postAuthorFlagged}}
|
||||
{{#if flaggedPost.user}}
|
||||
{{#link-to 'adminUser' flaggedPost.user}}{{avatar flaggedPost.user imageSize="small"}}{{/link-to}}
|
||||
{{#if flaggedPost.wasEdited}}<i class="fa fa-pencil" title="{{i18n admin.flags.was_edited}}"></i>{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#if adminActiveFlagsView}}
|
||||
{{#if flaggedPost.previous_flags_count}}
|
||||
<span title="{{i18n admin.flags.previous_flags_count count=flaggedPost.previous_flags_count}}" class="badge-notification flagged-posts">{{flaggedPost.previous_flags_count}}</span>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</td>
|
||||
|
||||
<td class='excerpt'>
|
||||
<h3>
|
||||
{{#if flaggedPost.topic.isPrivateMessage}}
|
||||
<span class="private-message-glyph">{{fa-icon envelope}}</span>
|
||||
{{/if}}
|
||||
{{topic-status topic=flaggedPost.topic}}
|
||||
<a href='{{unbound flaggedPost.url}}'>{{flaggedPost.topic.title}}</a>
|
||||
</h3>
|
||||
{{#if flaggedPost.postAuthorFlagged}}
|
||||
{{{flaggedPost.excerpt}}}
|
||||
{{/if}}
|
||||
</td>
|
||||
|
||||
<td class='flaggers'>
|
||||
<table>
|
||||
<tbody>
|
||||
{{#each flaggedPost.flaggers}}
|
||||
<tr>
|
||||
<td class='avatar'>
|
||||
{{#link-to 'adminUser' user}}
|
||||
{{avatar user imageSize="small"}}
|
||||
{{/link-to}}
|
||||
</td>
|
||||
<td>
|
||||
{{#link-to 'adminUser' user}}
|
||||
{{user.username}}
|
||||
{{/link-to}}
|
||||
{{format-age flaggedAt}}
|
||||
<br />
|
||||
{{flagType}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<td class='flaggers result'>
|
||||
{{#if adminOldFlagsView}}
|
||||
<table>
|
||||
<tbody>
|
||||
{{#each flaggedPost.flaggers}}
|
||||
<tr>
|
||||
<td class='avatar'>
|
||||
{{#link-to 'adminUser' disposedBy}}
|
||||
{{avatar disposedBy imageSize="small"}}
|
||||
{{/link-to}}
|
||||
</td>
|
||||
<td>
|
||||
{{format-age disposedAt}}
|
||||
{{{dispositionIcon}}}
|
||||
{{#if tookAction}}
|
||||
<i class='fa fa-gavel' title='{{i18n admin.flags.took_action}}'></i>
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{/if}}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
{{#if flaggedPost.topicFlagged}}
|
||||
<tr class='message'>
|
||||
<td></td>
|
||||
<td colspan="3">
|
||||
<div>
|
||||
{{{i18n admin.flags.topic_flagged}}} <a href='{{unbound flaggedPost.url}}' class="btn">{{i18n admin.flags.visit_topic}}</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
|
||||
{{#each flaggedPost.conversations}}
|
||||
<tr class='message'>
|
||||
<td></td>
|
||||
<td colspan="3">
|
||||
<div>
|
||||
{{#if response}}
|
||||
<p>
|
||||
{{#link-to 'adminUser' response.user}}{{avatar response.user imageSize="small"}}{{/link-to}} {{{response.excerpt}}}
|
||||
</p>
|
||||
{{#if reply}}
|
||||
<p>
|
||||
{{#link-to 'adminUser' reply.user}}{{avatar reply.user imageSize="small"}}{{/link-to}} {{{reply.excerpt}}}
|
||||
{{#if hasMore}}
|
||||
<a href="{{unbound permalink}}">{{i18n admin.flags.more}}</a>
|
||||
{{/if}}
|
||||
</p>
|
||||
{{/if}}
|
||||
<a href="{{unbound permalink}}">
|
||||
<button class='btn btn-reply'><i class="fa fa-reply"></i> {{i18n admin.flags.reply_message}}</button>
|
||||
</a>
|
||||
{{/if}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
|
||||
<tr>
|
||||
<td colspan="4" class="action">
|
||||
{{#if adminActiveFlagsView}}
|
||||
<button title='{{i18n admin.flags.agree_title}}' class='btn' {{action "showAgreeFlagModal" flaggedPost}}><i class="fa fa-thumbs-o-up"></i>{{i18n admin.flags.agree}}…</button>
|
||||
{{#if flaggedPost.postHidden}}
|
||||
<button title='{{i18n admin.flags.disagree_flag_unhide_post_title}}' class='btn' {{action "disagreeFlags" flaggedPost}}><i class="fa fa-thumbs-o-down"></i>{{i18n admin.flags.disagree_flag_unhide_post}}</button>
|
||||
{{else}}
|
||||
<button title='{{i18n admin.flags.disagree_flag_title}}' class='btn' {{action "disagreeFlags" flaggedPost}}><i class="fa fa-thumbs-o-down"></i>{{i18n admin.flags.disagree_flag}}</button>
|
||||
{{/if}}
|
||||
<button title='{{i18n admin.flags.defer_flag_title}}' class='btn' {{action "deferFlags" flaggedPost}}><i class="fa fa-external-link"></i>{{i18n admin.flags.defer_flag}}</button>
|
||||
<button title='{{i18n admin.flags.delete_title}}' class='btn btn-danger' {{action "showDeleteFlagModal" flaggedPost}}><i class="fa fa-trash-o"></i>{{i18n admin.flags.delete}}…</button>
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{{/each}}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
{{#if view.loading}}
|
||||
{{loading-spinner}}
|
||||
{{/if}}
|
||||
|
||||
{{else}}
|
||||
<p>{{i18n admin.flags.no_results}}</p>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{outlet}}
|
||||
</div>
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
Discourse.AdminFlagsView = Discourse.View.extend(Discourse.LoadMore, {
|
||||
export default Discourse.View.extend(Discourse.LoadMore, {
|
||||
loading: false,
|
||||
eyelineSelector: '.admin-flags tbody tr',
|
||||
|
||||
actions: {
|
||||
|
||||
loadMore: function() {
|
||||
var self = this;
|
||||
|
||||
if (this.get("loading") || this.get("model.allLoaded")) { return; }
|
||||
|
||||
this.set("loading", true);
|
||||
|
@ -15,7 +13,6 @@ Discourse.AdminFlagsView = Discourse.View.extend(Discourse.LoadMore, {
|
|||
self.set("loading", false);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
|
@ -1,11 +1,3 @@
|
|||
/**
|
||||
A modal view for agreeing with a flag.
|
||||
|
||||
@class AdminAgreeFlagView
|
||||
@extends Discourse.ModalBodyView
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.AdminAgreeFlagView = Discourse.ModalBodyView.extend({
|
||||
templateName: 'admin/templates/modal/admin_agree_flag',
|
||||
title: I18n.t('admin.flags.agree_flag_modal_title')
|
||||
|
|
Loading…
Reference in New Issue