This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/edit-category-tab.js.es6
Joffrey JAFFEUX b3eb67976d
DEV: Upgrades to Ember 3.10 (#7871)
Co-Authored-By: majakomel <maja.komel@gmail.com>
2019-07-16 12:45:15 +02:00

45 lines
1009 B
JavaScript

import { propertyEqual } from "discourse/lib/computed";
import computed from "ember-addons/ember-computed-decorators";
export default Ember.Component.extend({
tagName: "li",
classNameBindings: ["active", "tabClassName"],
@computed("tab")
tabClassName(tab) {
return "edit-category-" + tab;
},
active: propertyEqual("selectedTab", "tab"),
@computed("tab")
title(tab) {
return I18n.t("category." + tab.replace("-", "_"));
},
didInsertElement() {
this._super(...arguments);
Ember.run.scheduleOnce("afterRender", this, this._addToCollection);
},
_addToCollection: function() {
this.panels.addObject(this.tabClassName);
},
_resetModalScrollState() {
const $modalBody = $(this.element)
.parents("#discourse-modal")
.find(".modal-body");
if ($modalBody.length === 1) {
$modalBody.scrollTop(0);
}
},
actions: {
select: function() {
this.set("selectedTab", this.tab);
this._resetModalScrollState();
}
}
});