mirror of
https://github.com/flarum/core.git
synced 2025-08-04 15:37:51 +02:00
Generalise the potential for display of flags to all posts, rather than just comments
This is just more future-proofing, in case any other extensions introduce new post types which can be flagged.
This commit is contained in:
22
extensions/flags/js/forum/dist/extension.js
vendored
22
extensions/flags/js/forum/dist/extension.js
vendored
@@ -60,17 +60,17 @@ System.register('flarum/flags/addFlagsDropdown', ['flarum/extend', 'flarum/app',
|
|||||||
});;
|
});;
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
System.register('flarum/flags/addFlagsToPosts', ['flarum/extend', 'flarum/app', 'flarum/components/CommentPost', 'flarum/components/Button', 'flarum/helpers/punctuate', 'flarum/helpers/username', 'flarum/utils/ItemList', 'flarum/utils/PostControls'], function (_export, _context) {
|
System.register('flarum/flags/addFlagsToPosts', ['flarum/extend', 'flarum/app', 'flarum/components/Post', 'flarum/components/Button', 'flarum/utils/ItemList', 'flarum/utils/PostControls'], function (_export, _context) {
|
||||||
var extend, app, CommentPost, Button, punctuate, username, ItemList, PostControls;
|
var extend, app, Post, Button, ItemList, PostControls;
|
||||||
|
|
||||||
_export('default', function () {
|
_export('default', function () {
|
||||||
extend(CommentPost.prototype, 'attrs', function (attrs) {
|
extend(Post.prototype, 'attrs', function (attrs) {
|
||||||
if (this.props.post.flags().length) {
|
if (this.props.post.flags().length) {
|
||||||
attrs.className += ' Post--flagged';
|
attrs.className += ' Post--flagged';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
CommentPost.prototype.dismissFlag = function (data) {
|
Post.prototype.dismissFlag = function (data) {
|
||||||
var post = this.props.post;
|
var post = this.props.post;
|
||||||
|
|
||||||
delete post.data.relationships.flags;
|
delete post.data.relationships.flags;
|
||||||
@@ -106,7 +106,7 @@ System.register('flarum/flags/addFlagsToPosts', ['flarum/extend', 'flarum/app',
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
CommentPost.prototype.flagActionItems = function () {
|
Post.prototype.flagActionItems = function () {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
var items = new ItemList();
|
var items = new ItemList();
|
||||||
@@ -138,7 +138,7 @@ System.register('flarum/flags/addFlagsToPosts', ['flarum/extend', 'flarum/app',
|
|||||||
return items;
|
return items;
|
||||||
};
|
};
|
||||||
|
|
||||||
extend(CommentPost.prototype, 'content', function (vdom) {
|
extend(Post.prototype, 'content', function (vdom) {
|
||||||
var _this2 = this;
|
var _this2 = this;
|
||||||
|
|
||||||
var post = this.props.post;
|
var post = this.props.post;
|
||||||
@@ -170,7 +170,7 @@ System.register('flarum/flags/addFlagsToPosts', ['flarum/extend', 'flarum/app',
|
|||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
CommentPost.prototype.flagReason = function (flag) {
|
Post.prototype.flagReason = function (flag) {
|
||||||
if (flag.type() === 'user') {
|
if (flag.type() === 'user') {
|
||||||
var user = flag.user();
|
var user = flag.user();
|
||||||
var reason = flag.reason();
|
var reason = flag.reason();
|
||||||
@@ -190,14 +190,10 @@ System.register('flarum/flags/addFlagsToPosts', ['flarum/extend', 'flarum/app',
|
|||||||
extend = _flarumExtend.extend;
|
extend = _flarumExtend.extend;
|
||||||
}, function (_flarumApp) {
|
}, function (_flarumApp) {
|
||||||
app = _flarumApp.default;
|
app = _flarumApp.default;
|
||||||
}, function (_flarumComponentsCommentPost) {
|
}, function (_flarumComponentsPost) {
|
||||||
CommentPost = _flarumComponentsCommentPost.default;
|
Post = _flarumComponentsPost.default;
|
||||||
}, function (_flarumComponentsButton) {
|
}, function (_flarumComponentsButton) {
|
||||||
Button = _flarumComponentsButton.default;
|
Button = _flarumComponentsButton.default;
|
||||||
}, function (_flarumHelpersPunctuate) {
|
|
||||||
punctuate = _flarumHelpersPunctuate.default;
|
|
||||||
}, function (_flarumHelpersUsername) {
|
|
||||||
username = _flarumHelpersUsername.default;
|
|
||||||
}, function (_flarumUtilsItemList) {
|
}, function (_flarumUtilsItemList) {
|
||||||
ItemList = _flarumUtilsItemList.default;
|
ItemList = _flarumUtilsItemList.default;
|
||||||
}, function (_flarumUtilsPostControls) {
|
}, function (_flarumUtilsPostControls) {
|
||||||
|
@@ -1,20 +1,18 @@
|
|||||||
import { extend } from 'flarum/extend';
|
import { extend } from 'flarum/extend';
|
||||||
import app from 'flarum/app';
|
import app from 'flarum/app';
|
||||||
import CommentPost from 'flarum/components/CommentPost';
|
import Post from 'flarum/components/Post';
|
||||||
import Button from 'flarum/components/Button';
|
import Button from 'flarum/components/Button';
|
||||||
import punctuate from 'flarum/helpers/punctuate';
|
|
||||||
import username from 'flarum/helpers/username';
|
|
||||||
import ItemList from 'flarum/utils/ItemList';
|
import ItemList from 'flarum/utils/ItemList';
|
||||||
import PostControls from 'flarum/utils/PostControls';
|
import PostControls from 'flarum/utils/PostControls';
|
||||||
|
|
||||||
export default function() {
|
export default function() {
|
||||||
extend(CommentPost.prototype, 'attrs', function(attrs) {
|
extend(Post.prototype, 'attrs', function(attrs) {
|
||||||
if (this.props.post.flags().length) {
|
if (this.props.post.flags().length) {
|
||||||
attrs.className += ' Post--flagged';
|
attrs.className += ' Post--flagged';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
CommentPost.prototype.dismissFlag = function(data) {
|
Post.prototype.dismissFlag = function(data) {
|
||||||
const post = this.props.post;
|
const post = this.props.post;
|
||||||
|
|
||||||
delete post.data.relationships.flags;
|
delete post.data.relationships.flags;
|
||||||
@@ -50,7 +48,7 @@ export default function() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
CommentPost.prototype.flagActionItems = function() {
|
Post.prototype.flagActionItems = function() {
|
||||||
const items = new ItemList();
|
const items = new ItemList();
|
||||||
|
|
||||||
const controls = PostControls.destructiveControls(this.props.post);
|
const controls = PostControls.destructiveControls(this.props.post);
|
||||||
@@ -78,7 +76,7 @@ export default function() {
|
|||||||
return items;
|
return items;
|
||||||
};
|
};
|
||||||
|
|
||||||
extend(CommentPost.prototype, 'content', function(vdom) {
|
extend(Post.prototype, 'content', function(vdom) {
|
||||||
const post = this.props.post;
|
const post = this.props.post;
|
||||||
const flags = post.flags();
|
const flags = post.flags();
|
||||||
|
|
||||||
@@ -102,7 +100,7 @@ export default function() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
CommentPost.prototype.flagReason = function(flag) {
|
Post.prototype.flagReason = function(flag) {
|
||||||
if (flag.type() === 'user') {
|
if (flag.type() === 'user') {
|
||||||
const user = flag.user();
|
const user = flag.user();
|
||||||
const reason = flag.reason();
|
const reason = flag.reason();
|
||||||
|
Reference in New Issue
Block a user