mirror of
https://github.com/flarum/core.git
synced 2025-08-02 06:30:53 +02:00
Split up post controls into "user", "moderation", "destructive"
This commit is contained in:
@@ -29,7 +29,11 @@ export default function(app) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Post.prototype.controls = function(context) {
|
Post.prototype.userControls = function(context) {
|
||||||
|
return new ItemList();
|
||||||
|
};
|
||||||
|
|
||||||
|
Post.prototype.moderationControls = function(context) {
|
||||||
var items = new ItemList();
|
var items = new ItemList();
|
||||||
|
|
||||||
if (this.contentType() === 'comment' && this.canEdit()) {
|
if (this.contentType() === 'comment' && this.canEdit()) {
|
||||||
@@ -37,16 +41,36 @@ export default function(app) {
|
|||||||
items.add('restore', ActionButton.component({ icon: 'reply', label: 'Restore', onclick: restoreAction.bind(this) }));
|
items.add('restore', ActionButton.component({ icon: 'reply', label: 'Restore', onclick: restoreAction.bind(this) }));
|
||||||
} else {
|
} else {
|
||||||
items.add('edit', ActionButton.component({ icon: 'pencil', label: 'Edit', onclick: editAction.bind(this) }));
|
items.add('edit', ActionButton.component({ icon: 'pencil', label: 'Edit', onclick: editAction.bind(this) }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
};
|
||||||
|
|
||||||
|
Post.prototype.destructiveControls = function(context) {
|
||||||
|
var items = new ItemList();
|
||||||
|
|
||||||
if (this.number() != 1) {
|
if (this.number() != 1) {
|
||||||
|
if (this.contentType() === 'comment' && !this.isHidden() && this.canEdit()) {
|
||||||
items.add('hide', ActionButton.component({ icon: 'times', label: 'Delete', onclick: hideAction.bind(this) }));
|
items.add('hide', ActionButton.component({ icon: 'times', label: 'Delete', onclick: hideAction.bind(this) }));
|
||||||
}
|
} else if ((this.contentType() !== 'comment' || this.isHidden()) && this.canDelete()) {
|
||||||
|
items.add('delete', ActionButton.component({ icon: 'times', label: 'Delete Forever', onclick: deleteAction.bind(this) }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((this.contentType() !== 'comment' || this.isHidden()) && this.canDelete() && this.number() != 1) {
|
return items;
|
||||||
items.add('delete', ActionButton.component({ icon: 'times', label: 'Delete', onclick: deleteAction.bind(this) }));
|
};
|
||||||
|
|
||||||
|
Post.prototype.controls = function(context) {
|
||||||
|
var items = new ItemList();
|
||||||
|
|
||||||
|
['user', 'moderation', 'destructive'].forEach(section => {
|
||||||
|
var controls = this[section+'Controls'](context).toArray();
|
||||||
|
if (controls.length) {
|
||||||
|
items.add(section, controls);
|
||||||
|
items.add(section+'Separator', Separator.component());
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user