mirror of
https://github.com/flarum/core.git
synced 2025-08-11 10:55:47 +02:00
update: forum/utils/DiscussionControls
- replyAction has not yet been tested.
This commit is contained in:
committed by
Franz Liedke
parent
60c3f23667
commit
63e07b2044
@@ -55,19 +55,23 @@ export default {
|
|||||||
items.add(
|
items.add(
|
||||||
'reply',
|
'reply',
|
||||||
!app.session.user || discussion.canReply()
|
!app.session.user || discussion.canReply()
|
||||||
? Button.component({
|
? Button.component(
|
||||||
icon: 'fas fa-reply',
|
{
|
||||||
children: app.translator.trans(
|
icon: 'fas fa-reply',
|
||||||
|
onclick: this.replyAction.bind(discussion, true, false),
|
||||||
|
},
|
||||||
|
app.translator.trans(
|
||||||
app.session.user ? 'core.forum.discussion_controls.reply_button' : 'core.forum.discussion_controls.log_in_to_reply_button'
|
app.session.user ? 'core.forum.discussion_controls.reply_button' : 'core.forum.discussion_controls.log_in_to_reply_button'
|
||||||
),
|
)
|
||||||
onclick: this.replyAction.bind(discussion, true, false),
|
)
|
||||||
})
|
: Button.component(
|
||||||
: Button.component({
|
{
|
||||||
icon: 'fas fa-reply',
|
icon: 'fas fa-reply',
|
||||||
children: app.translator.trans('core.forum.discussion_controls.cannot_reply_button'),
|
className: 'disabled',
|
||||||
className: 'disabled',
|
title: app.translator.trans('core.forum.discussion_controls.cannot_reply_text'),
|
||||||
title: app.translator.trans('core.forum.discussion_controls.cannot_reply_text'),
|
},
|
||||||
})
|
app.translator.trans('core.forum.discussion_controls.cannot_reply_button')
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,11 +93,13 @@ export default {
|
|||||||
if (discussion.canRename()) {
|
if (discussion.canRename()) {
|
||||||
items.add(
|
items.add(
|
||||||
'rename',
|
'rename',
|
||||||
Button.component({
|
Button.component(
|
||||||
icon: 'fas fa-pencil-alt',
|
{
|
||||||
children: app.translator.trans('core.forum.discussion_controls.rename_button'),
|
icon: 'fas fa-pencil-alt',
|
||||||
onclick: this.renameAction.bind(discussion),
|
onclick: this.renameAction.bind(discussion),
|
||||||
})
|
},
|
||||||
|
app.translator.trans('core.forum.discussion_controls.rename_button')
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,33 +122,39 @@ export default {
|
|||||||
if (discussion.canHide()) {
|
if (discussion.canHide()) {
|
||||||
items.add(
|
items.add(
|
||||||
'hide',
|
'hide',
|
||||||
Button.component({
|
Button.component(
|
||||||
icon: 'far fa-trash-alt',
|
{
|
||||||
children: app.translator.trans('core.forum.discussion_controls.delete_button'),
|
icon: 'far fa-trash-alt',
|
||||||
onclick: this.hideAction.bind(discussion),
|
onclick: this.hideAction.bind(discussion),
|
||||||
})
|
},
|
||||||
|
app.translator.trans('core.forum.discussion_controls.delete_button')
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (discussion.canHide()) {
|
if (discussion.canHide()) {
|
||||||
items.add(
|
items.add(
|
||||||
'restore',
|
'restore',
|
||||||
Button.component({
|
Button.component(
|
||||||
icon: 'fas fa-reply',
|
{
|
||||||
children: app.translator.trans('core.forum.discussion_controls.restore_button'),
|
icon: 'fas fa-reply',
|
||||||
onclick: this.restoreAction.bind(discussion),
|
onclick: this.restoreAction.bind(discussion),
|
||||||
})
|
},
|
||||||
|
app.translator.trans('core.forum.discussion_controls.restore_button')
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (discussion.canDelete()) {
|
if (discussion.canDelete()) {
|
||||||
items.add(
|
items.add(
|
||||||
'delete',
|
'delete',
|
||||||
Button.component({
|
Button.component(
|
||||||
icon: 'fas fa-times',
|
{
|
||||||
children: app.translator.trans('core.forum.discussion_controls.delete_forever_button'),
|
icon: 'fas fa-times',
|
||||||
onclick: this.deleteAction.bind(discussion),
|
onclick: this.deleteAction.bind(discussion),
|
||||||
})
|
},
|
||||||
|
app.translator.trans('core.forum.discussion_controls.delete_forever_button')
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,33 +175,31 @@ export default {
|
|||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
replyAction(goToLast, forceRefresh) {
|
replyAction(goToLast, forceRefresh) {
|
||||||
const deferred = m.deferred();
|
return new Promise((resolve, reject) => {
|
||||||
|
if (app.session.user) {
|
||||||
|
if (this.canReply()) {
|
||||||
|
if (!app.composer.composingReplyTo(this) || forceRefresh) {
|
||||||
|
app.composer.load(ReplyComposer, {
|
||||||
|
user: app.session.user,
|
||||||
|
discussion: this,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
app.composer.show();
|
||||||
|
|
||||||
if (app.session.user) {
|
if (goToLast && app.viewingDiscussion(this) && !app.composer.isFullScreen()) {
|
||||||
if (this.canReply()) {
|
app.current.get('stream').goToNumber('reply');
|
||||||
if (!app.composer.composingReplyTo(this) || forceRefresh) {
|
}
|
||||||
app.composer.load(ReplyComposer, {
|
|
||||||
user: app.session.user,
|
return resolve(app.composer);
|
||||||
discussion: this,
|
} else {
|
||||||
});
|
return reject();
|
||||||
}
|
}
|
||||||
app.composer.show();
|
|
||||||
|
|
||||||
if (goToLast && app.viewingDiscussion(this) && !app.composer.isFullScreen()) {
|
|
||||||
app.current.get('stream').goToNumber('reply');
|
|
||||||
}
|
|
||||||
|
|
||||||
deferred.resolve(app.composer);
|
|
||||||
} else {
|
|
||||||
deferred.reject();
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
deferred.reject();
|
|
||||||
|
|
||||||
app.modal.show(LogInModal);
|
app.modal.show(LogInModal);
|
||||||
}
|
|
||||||
|
|
||||||
return deferred.promise;
|
return reject();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user