mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 09:57:25 +08:00
Don't hardcode code button index and remove the for loop and use .some()
This commit is contained in:
@ -26,18 +26,12 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||||||
categoryId: Ember.computed.alias('model.category.id'),
|
categoryId: Ember.computed.alias('model.category.id'),
|
||||||
|
|
||||||
onShow() {
|
onShow() {
|
||||||
let showRelistButton = false;
|
const showRelistButton = this.get('model.topics').some(t => !t.visible);
|
||||||
const topics = this.get('model.topics');
|
const relistButtonIndex = _buttons.findIndex(b => b.action === 'relistTopics');
|
||||||
for (let t = 0; t < topics.length; t++) {
|
if (showRelistButton && relistButtonIndex === -1) {
|
||||||
if (!topics[t].visible) {
|
|
||||||
showRelistButton = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (showRelistButton && !_buttons[9]) {
|
|
||||||
addBulkButton('relistTopics', 'relist_topics');
|
addBulkButton('relistTopics', 'relist_topics');
|
||||||
} else if (!showRelistButton && _buttons[9]) {
|
} else if (!showRelistButton && relistButtonIndex !== -1) {
|
||||||
_buttons.splice(9, 1);
|
_buttons.splice(relistButtonIndex, 1);
|
||||||
}
|
}
|
||||||
this.set('modal.modalClass', 'topic-bulk-actions-modal small');
|
this.set('modal.modalClass', 'topic-bulk-actions-modal small');
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user