diff --git a/app/assets/javascripts/admin/templates/components/embeddable-host.hbs b/app/assets/javascripts/admin/templates/components/embeddable-host.hbs
index f4367abefff..88317ecd187 100644
--- a/app/assets/javascripts/admin/templates/components/embeddable-host.hbs
+++ b/app/assets/javascripts/admin/templates/components/embeddable-host.hbs
@@ -9,7 +9,7 @@
{{input value=buffered.path_whitelist placeholder="/blog/.*" enter="save" class="path-whitelist"}}
- {{category-chooser value=categoryId}}
+ {{category-select-box value=categoryId class="small"}}
|
{{d-button icon="check" action="save" class="btn-primary" disabled=cantSave}}
diff --git a/app/assets/javascripts/discourse/components/category-select-box.js.es6 b/app/assets/javascripts/discourse/components/category-select-box.js.es6
index 9dfe0302a1d..185dfe673f4 100644
--- a/app/assets/javascripts/discourse/components/category-select-box.js.es6
+++ b/app/assets/javascripts/discourse/components/category-select-box.js.es6
@@ -15,10 +15,19 @@ export default SelectBoxComponent.extend({
castInteger: true,
- width: "100%",
-
clearable: true,
+ allowUncategorized: null,
+
+ init() {
+ this._super();
+
+ if (!Ember.isNone(this.get("categories"))) {
+ this.set("content", this.get("categories"));
+ this._scopeCategories();
+ }
+ },
+
filterFunction: function(content) {
const _matchFunction = (filter, text) => {
return text.toLowerCase().indexOf(filter) > -1;
@@ -57,7 +66,6 @@ export default SelectBoxComponent.extend({
this.set("headerText", headerText);
},
- // original method is kept for compatibility
templateForRow: function() {
return (rowComponent) => this.rowContentTemplate(rowComponent.get("content"));
}.property(),
@@ -79,8 +87,11 @@ export default SelectBoxComponent.extend({
const categoryId = c.get("id");
if (scopedCategoryId && categoryId !== scopedCategoryId && c.get("parent_category_id") !== scopedCategoryId) { return false; }
if (excludeCategoryId === categoryId) { return false; }
- if (!this.siteSettings.allow_uncategorized_topics && c.get("isUncategorizedCategory")) {
- return false;
+ if (this.get("allowUncategorized") === false && c.get("isUncategorizedCategory")) { return false; }
+ if (this.get("allowUncategorized") !== true) {
+ if (!this.siteSettings.allow_uncategorized_topics && c.get("isUncategorizedCategory")) {
+ return false;
+ }
}
return c.get("permission") === PermissionType.FULL;
});
diff --git a/app/assets/javascripts/discourse/components/select-box.js.es6 b/app/assets/javascripts/discourse/components/select-box.js.es6
index 3085f35eaea..8a48b9e4d3a 100644
--- a/app/assets/javascripts/discourse/components/select-box.js.es6
+++ b/app/assets/javascripts/discourse/components/select-box.js.es6
@@ -14,6 +14,7 @@ export default Ember.Component.extend({
renderBody: false,
wrapper: true,
tabindex: 0,
+ scrollableParentSelector: ".modal-body",
caretUpIcon: "caret-up",
caretDownIcon: "caret-down",
@@ -24,8 +25,9 @@ export default Ember.Component.extend({
value: null,
selectedContent: null,
- noContentText: I18n.t("select_box.no_content"),
+ noContentLabel: I18n.t("select_box.no_content"),
lastHovered: null,
+ clearSelectionLabel: null,
idKey: "id",
textKey: "text",
@@ -41,7 +43,7 @@ export default Ember.Component.extend({
selectBoxHeaderComponent: "select-box/select-box-header",
selectBoxCollectionComponent: "select-box/select-box-collection",
- width: 220,
+ minWidth: 220,
maxCollectionHeight: 200,
verticalOffset: 0,
horizontalOffset: 0,
@@ -65,7 +67,7 @@ export default Ember.Component.extend({
shouldHighlightRow: function() {
return (rowComponent) => {
- if (Ember.isNone(this.get("value"))) {
+ if (Ember.isNone(this.get("value")) && Ember.isNone(this.get("lastHovered"))) {
return false;
}
@@ -96,14 +98,14 @@ export default Ember.Component.extend({
applyDirection() {
const offsetTop = this.$()[0].getBoundingClientRect().top;
const windowHeight = $(window).height();
- const headerHeight = this.$(".select-box-header").outerHeight();
- const filterHeight = this.$(".select-box-filter").outerHeight();
+ const headerHeight = this.$(".select-box-header").outerHeight(false);
+ const filterHeight = this.$(".select-box-filter").outerHeight(false);
if (windowHeight - (offsetTop + this.get("maxCollectionHeight") + filterHeight + headerHeight) < 0) {
this.$().addClass("is-reversed");
this.$(".select-box-body").css({
left: this.get("horizontalOffset"),
- top: "",
+ top: "auto",
bottom: headerHeight + this.get("verticalOffset")
});
} else {
@@ -111,7 +113,7 @@ export default Ember.Component.extend({
this.$(".select-box-body").css({
left: this.get("horizontalOffset"),
top: headerHeight + this.get("verticalOffset"),
- bottom: ""
+ bottom: "auto"
});
}
},
@@ -150,21 +152,31 @@ export default Ember.Component.extend({
@on("didRender")
_configureSelectBoxDOM: function() {
- this.$().css("width", this.get("width"));
- this.$(".select-box-header").css("height", this.$().css("height"));
- this.$(".select-box-filter").css("height", this.$().css("height"));
+ if (this.get("scrollableParent").length === 1) {
+ this._removeFixedPosition();
+ }
+
+ this.$().css("min-width", this.get("minWidth"));
+
+ const computedWidth = this.$().outerWidth(false);
+ const computedHeight = this.$().outerHeight(false);
+
+ this.$(".select-box-header").css("height", computedHeight);
+ this.$(".select-box-filter").css("height", computedHeight);
if (this.get("expanded")) {
- this.$(".select-box-body").css("width", this.$().css("width"));
+ if (this.get("scrollableParent").length === 1) {
+ this._applyFixedPosition(computedWidth, computedHeight);
+ }
+
+ this.$(".select-box-body").css("width", computedWidth);
this.$(".select-box-collection").css("max-height", this.get("maxCollectionHeight"));
- Ember.run.schedule("afterRender", () => {
- this.applyDirection();
+ this.applyDirection();
- if (this.get("wrapper")) {
- this._positionSelectBoxWrapper();
- }
- });
+ if (this.get("wrapper")) {
+ this._positionSelectBoxWrapper();
+ }
} else {
if (this.get("wrapper")) {
this.$(".select-box-wrapper").hide();
@@ -250,12 +262,16 @@ export default Ember.Component.extend({
});
},
- @computed("headerText", "dynamicHeaderText", "selectedContent", "textKey")
- generatedHeadertext(headerText, dynamic, selectedContent, textKey) {
+ @computed("headerText", "dynamicHeaderText", "selectedContent", "textKey", "clearSelectionLabel")
+ generatedHeadertext(headerText, dynamic, selectedContent, textKey, clearSelectionLabel) {
if (dynamic && !Ember.isNone(selectedContent)) {
return selectedContent[textKey];
}
+ if (dynamic && Ember.isNone(selectedContent) && !Ember.isNone(clearSelectionLabel)) {
+ return I18n.t(clearSelectionLabel);
+ }
+
return headerText;
},
@@ -272,6 +288,11 @@ export default Ember.Component.extend({
return filteredContent;
},
+ @computed("scrollableParentSelector")
+ scrollableParent(scrollableParentSelector) {
+ return this.$().parents(scrollableParentSelector).first();
+ },
+
actions: {
onToggle() {
this.toggleProperty("expanded");
@@ -288,18 +309,22 @@ export default Ember.Component.extend({
});
},
+ onClearSelection() {
+ this.setProperties({ value: null, expanded: false });
+ },
+
onHoverRow(content) {
this.set("lastHovered", this._castInteger(content[this.get("idKey")]));
}
},
_positionSelectBoxWrapper() {
- const headerHeight = this.$(".select-box-header").outerHeight();
+ const headerHeight = this.$(".select-box-header").outerHeight(false);
this.$(".select-box-wrapper").css({
width: this.$().width(),
display: "block",
- height: headerHeight + this.$(".select-box-body").outerHeight()
+ height: headerHeight + this.$(".select-box-body").outerHeight(false)
});
},
@@ -309,5 +334,33 @@ export default Ember.Component.extend({
}
return id;
+ },
+
+ _applyFixedPosition(width, height) {
+ const $placeholder = $(``);
+
+ this.$()
+ .before($placeholder)
+ .css({
+ width,
+ position: "fixed",
+ "margin-top": -this.get("scrollableParent").scrollTop(),
+ "margin-left": -width
+ });
+
+ this.get("scrollableParent").on("scroll.select-box", () => this.set("expanded", false) );
+ },
+
+ _removeFixedPosition() {
+ $(`.select-box-fixed-placeholder-${this.get("componentId")}`).remove();
+ this.$().css({
+ top: "auto",
+ left: "auto",
+ "margin-left": "auto",
+ "margin-top": "auto",
+ position: "relative"
+ });
+
+ this.get("scrollableParent").off("scroll.select-box");
}
});
diff --git a/app/assets/javascripts/discourse/components/select-box/select-box-collection.js.es6 b/app/assets/javascripts/discourse/components/select-box/select-box-collection.js.es6
index 922121c7088..4b5fea95d5b 100644
--- a/app/assets/javascripts/discourse/components/select-box/select-box-collection.js.es6
+++ b/app/assets/javascripts/discourse/components/select-box/select-box-collection.js.es6
@@ -1,3 +1,9 @@
export default Ember.Component.extend({
- classNames: "select-box-collection"
+ classNames: "select-box-collection",
+
+ actions: {
+ onClearSelection() {
+ this.sendAction("onClearSelection");
+ }
+ }
});
diff --git a/app/assets/javascripts/discourse/templates/components/edit-category-general.hbs b/app/assets/javascripts/discourse/templates/components/edit-category-general.hbs
index 734ad2b4c70..d0690538630 100644
--- a/app/assets/javascripts/discourse/templates/components/edit-category-general.hbs
+++ b/app/assets/javascripts/discourse/templates/components/edit-category-general.hbs
@@ -19,7 +19,11 @@
{{/each}}
{{else}}
- {{category-chooser valueAttribute="id" value=category.parent_category_id categories=parentCategories rootNone=true allowUncategorized="true"}}
+ {{category-select-box
+ clearSelectionLabel="category.none"
+ value=category.parent_category_id
+ categories=parentCategories
+ allowUncategorized=true}}
{{/if}}
{{/if}}
diff --git a/app/assets/javascripts/discourse/templates/components/queued-post.hbs b/app/assets/javascripts/discourse/templates/components/queued-post.hbs
index e0bbe42ac7f..172275ce093 100644
--- a/app/assets/javascripts/discourse/templates/components/queued-post.hbs
+++ b/app/assets/javascripts/discourse/templates/components/queued-post.hbs
@@ -24,7 +24,7 @@
{{text-field value=buffered.title maxlength=siteSettings.max_topic_title_length}}
- {{category-chooser value=buffered.category_id}}
+ {{category-select-box value=buffered.category_id}}
{{else}}
{{i18n "queue.topic"}}
diff --git a/app/assets/javascripts/discourse/templates/components/select-box.hbs b/app/assets/javascripts/discourse/templates/components/select-box.hbs
index 65e99d5b8ac..338c850b881 100644
--- a/app/assets/javascripts/discourse/templates/components/select-box.hbs
+++ b/app/assets/javascripts/discourse/templates/components/select-box.hbs
@@ -30,6 +30,7 @@
{{/if}}
{{component selectBoxCollectionComponent
+ clearSelectionLabel=clearSelectionLabel
filteredContent=filteredContent
selectBoxRowComponent=selectBoxRowComponent
templateForRow=templateForRow
@@ -38,7 +39,8 @@
lastHovered=lastHovered
onSelectRow=(action "onSelectRow")
onHoverRow=(action "onHoverRow")
- noContentText=noContentText
+ onClearSelection=(action "onClearSelection")
+ noContentLabel=noContentLabel
value=value
}}
{{/if}}
diff --git a/app/assets/javascripts/discourse/templates/components/select-box/select-box-collection.hbs b/app/assets/javascripts/discourse/templates/components/select-box/select-box-collection.hbs
index 5c0123b6471..1e0aae5268d 100644
--- a/app/assets/javascripts/discourse/templates/components/select-box/select-box-collection.hbs
+++ b/app/assets/javascripts/discourse/templates/components/select-box/select-box-collection.hbs
@@ -1,4 +1,10 @@
+ {{#if clearSelectionLabel}}
+ -
+ {{i18n clearSelectionLabel}}
+
+ {{/if}}
+
{{#each filteredContent as |content|}}
{{component selectBoxRowComponent
content=content
@@ -11,9 +17,9 @@
value=value
}}
{{else}}
- {{#if noContentText}}
+ {{#if noContentLabel}}
-
- {{noContentText}}
+ {{noContentLabel}}
{{/if}}
{{/each}}
diff --git a/app/assets/javascripts/discourse/templates/modal/bulk-change-category.hbs b/app/assets/javascripts/discourse/templates/modal/bulk-change-category.hbs
index cc96a49d6f0..fd12a91835d 100644
--- a/app/assets/javascripts/discourse/templates/modal/bulk-change-category.hbs
+++ b/app/assets/javascripts/discourse/templates/modal/bulk-change-category.hbs
@@ -1,6 +1,6 @@
{{i18n "topics.bulk.choose_new_category"}}
-{{category-chooser value=newCategoryId}}
+{{category-select-box value=newCategoryId}}
{{#conditional-loading-spinner condition=loading}}
{{d-button action="changeCategory" label="topics.bulk.change_category"}}
diff --git a/app/assets/javascripts/discourse/templates/modal/edit-topic-timer.hbs b/app/assets/javascripts/discourse/templates/modal/edit-topic-timer.hbs
index 6a1b4c24bee..99e067de197 100644
--- a/app/assets/javascripts/discourse/templates/modal/edit-topic-timer.hbs
+++ b/app/assets/javascripts/discourse/templates/modal/edit-topic-timer.hbs
@@ -13,10 +13,9 @@
{{else if publishToCategory}}
- {{category-chooser
- valueAttribute="id"
- value=topicTimer.category_id
- excludeCategoryId=excludeCategoryId}}
+ {{category-select-box
+ value=topicTimer.category_id
+ excludeCategoryId=excludeCategoryId}}
{{auto-update-input
diff --git a/app/assets/javascripts/discourse/templates/modal/split-topic.hbs b/app/assets/javascripts/discourse/templates/modal/split-topic.hbs
index 3902c3daf1a..84ffc1d00cd 100644
--- a/app/assets/javascripts/discourse/templates/modal/split-topic.hbs
+++ b/app/assets/javascripts/discourse/templates/modal/split-topic.hbs
@@ -6,7 +6,7 @@
{{text-field value=topicName placeholderKey="composer.title_placeholder" elementId='split-topic-name'}}
- {{category-chooser value=categoryId}}
+ {{category-select-box value=categoryId class="small"}}
{{/d-modal-body}}
diff --git a/app/assets/stylesheets/common/admin/admin_base.scss b/app/assets/stylesheets/common/admin/admin_base.scss
index 0edf8af7764..da1f06fbd71 100644
--- a/app/assets/stylesheets/common/admin/admin_base.scss
+++ b/app/assets/stylesheets/common/admin/admin_base.scss
@@ -349,7 +349,7 @@ td.flaggers td {
margin-top: 10px;
}
- input, textarea, select {
+ input, textarea, select, .select-box {
width: 350px;
}
@@ -1672,6 +1672,10 @@ table#user-badges {
}
}
+.embedding td input {
+ margin-bottom: 0;
+}
+
// Emails
.email-list {
diff --git a/app/assets/stylesheets/common/components/select-box.scss b/app/assets/stylesheets/common/components/select-box.scss
index 8c93b34c186..e0f3d22fdb0 100644
--- a/app/assets/stylesheets/common/components/select-box.scss
+++ b/app/assets/stylesheets/common/components/select-box.scss
@@ -10,6 +10,10 @@
position: relative;
height: 34px;
+ &.small {
+ height: 28px;
+ }
+
&.is-expanded {
z-index: 102;
@@ -97,6 +101,7 @@
.select-box-body {
display: none;
+ background: $secondary;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
diff --git a/app/assets/stylesheets/desktop/compose.scss b/app/assets/stylesheets/desktop/compose.scss
index 7d4e24fcb19..972e18a0763 100644
--- a/app/assets/stylesheets/desktop/compose.scss
+++ b/app/assets/stylesheets/desktop/compose.scss
@@ -239,7 +239,7 @@
position: relative;
display: inline-block;
- .category-input {
+ .category-input .category-select-box {
width: 430px;
@include medium-width { width: 285px; }
@include small-width { width: 220px; }
diff --git a/app/assets/stylesheets/desktop/modal.scss b/app/assets/stylesheets/desktop/modal.scss
index 35b4f4d6f1c..000e2d168be 100644
--- a/app/assets/stylesheets/desktop/modal.scss
+++ b/app/assets/stylesheets/desktop/modal.scss
@@ -70,6 +70,10 @@
}
.modal {
+ .category-select-box {
+ width: 430px;
+ }
+
.category-combobox {
width: 430px;
diff --git a/app/assets/stylesheets/mobile/compose.scss b/app/assets/stylesheets/mobile/compose.scss
index 13257d46a56..48844826c50 100644
--- a/app/assets/stylesheets/mobile/compose.scss
+++ b/app/assets/stylesheets/mobile/compose.scss
@@ -148,6 +148,10 @@ input[type=radio], input[type=checkbox] {
}
.category-input {
margin-top: 3px;
+
+ .category-select-box {
+ width: 100%;
+ }
}
.wmd-controls {
transition: top 0.3s ease;
diff --git a/app/assets/stylesheets/mobile/modal.scss b/app/assets/stylesheets/mobile/modal.scss
index 9cd00e091eb..234ed59b07f 100644
--- a/app/assets/stylesheets/mobile/modal.scss
+++ b/app/assets/stylesheets/mobile/modal.scss
@@ -91,10 +91,6 @@
width: 100%;
}
}
-
- .category-combobox {
- width: 100%;
- }
}
.flag-modal {
diff --git a/test/javascripts/acceptance/category-edit-test.js.es6 b/test/javascripts/acceptance/category-edit-test.js.es6
index 170a692c05b..10913c314c2 100644
--- a/test/javascripts/acceptance/category-edit-test.js.es6
+++ b/test/javascripts/acceptance/category-edit-test.js.es6
@@ -74,11 +74,12 @@ QUnit.test("Subcategory list settings", assert => {
});
click('.edit-category-general');
- selectDropdown('.edit-category-tab-general .category-combobox', 2);
+
+ selectBox('.edit-category-tab-general .category-select-box', 'feature')
click('.edit-category-settings');
andThen(() => {
assert.ok(!visible(".show-subcategory-list-field"), "show subcategory list isn't visible for child categories");
assert.ok(!visible(".subcategory-list-style-field"), "subcategory list style isn't visible for child categories");
});
-});
\ No newline at end of file
+});
diff --git a/test/javascripts/acceptance/queued-posts-test.js.es6 b/test/javascripts/acceptance/queued-posts-test.js.es6
index 1dcffd1a5ef..d3a561c71e4 100644
--- a/test/javascripts/acceptance/queued-posts-test.js.es6
+++ b/test/javascripts/acceptance/queued-posts-test.js.es6
@@ -20,7 +20,7 @@ QUnit.test("For topics: body of post, title, category and tags are all editbale"
andThen(() => {
assert.ok(exists(".d-editor-container"), "the body should be editable");
assert.ok(exists(".edit-title .ember-text-field"), "the title should be editable");
- assert.ok(exists(".category-combobox"), "category should be editbale");
+ assert.ok(exists(".category-select-box"), "category should be editbale");
assert.ok(exists(".tag-chooser"), "tags should be editable");
});
});
@@ -41,7 +41,7 @@ QUnit.test("For replies: only the body of post is editbale", assert => {
andThen(() => {
assert.ok(exists(".d-editor-container"), "the body should be editable");
assert.notOk(exists(".edit-title .ember-text-field"), "title should not be editbale");
- assert.notOk(exists(".category-combobox"), "category should not be editable");
+ assert.notOk(exists(".category-select-box"), "category should not be editable");
assert.notOk(exists("div.tag-chooser"), "tags should not be editable");
});
});
diff --git a/test/javascripts/components/select-box-test.js.es6 b/test/javascripts/components/select-box-test.js.es6
index de1dbfbece7..8f15b1668f3 100644
--- a/test/javascripts/components/select-box-test.js.es6
+++ b/test/javascripts/components/select-box-test.js.es6
@@ -222,7 +222,7 @@ componentTest('persists filter state when expandind/collapsing', {
});
componentTest('supports options to limit size', {
- template: '{{select-box width=50 maxCollectionHeight=20 content=content}}',
+ template: '{{select-box maxCollectionHeight=20 content=content}}',
beforeEach() {
this.set("content", [{ id: 1, text: "robin" }]);
@@ -233,7 +233,6 @@ componentTest('supports options to limit size', {
andThen(() => {
assert.equal(find(".select-box-body").height(), 20, "it limits the height");
- assert.equal(find(".select-box").width(), 50, "it limits the width");
});
}
});
|