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