mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 19:55:43 +00:00
FIX: improves uncategorized support for category-select-box
This commit is contained in:
parent
861dbe3b51
commit
f101fec19c
@ -7,6 +7,8 @@ import Category from "discourse/models/category";
|
|||||||
export default SelectBoxComponent.extend({
|
export default SelectBoxComponent.extend({
|
||||||
classNames: ["category-select-box"],
|
classNames: ["category-select-box"],
|
||||||
|
|
||||||
|
selectBoxRowComponent: "category-select-box/category-select-box-row",
|
||||||
|
|
||||||
textKey: "name",
|
textKey: "name",
|
||||||
|
|
||||||
filterable: true,
|
filterable: true,
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
import computed from 'ember-addons/ember-computed-decorators';
|
||||||
|
import SelectBoxRowComponent from "discourse/components/select-box/select-box-row";
|
||||||
|
import Category from "discourse/models/category";
|
||||||
|
|
||||||
|
export default SelectBoxRowComponent.extend({
|
||||||
|
classNameBindings: ["isUncategorized"],
|
||||||
|
|
||||||
|
@computed("content")
|
||||||
|
isUncategorized(content) {
|
||||||
|
const category = Category.findById(content.id);
|
||||||
|
return category.get("isUncategorizedCategory");
|
||||||
|
}
|
||||||
|
});
|
@ -5,29 +5,16 @@ export default Ember.Component.extend({
|
|||||||
|
|
||||||
classNameBindings: ["focused:is-focused"],
|
classNameBindings: ["focused:is-focused"],
|
||||||
|
|
||||||
showClearButton: false,
|
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
this._super();
|
this._super();
|
||||||
|
|
||||||
this._setCaretIcon();
|
this._setCaretIcon();
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("clearable", "selectedId")
|
|
||||||
showClearButton(clearable, selectedId) {
|
|
||||||
return clearable === true && !Ember.isNone(selectedId);
|
|
||||||
},
|
|
||||||
|
|
||||||
click() {
|
click() {
|
||||||
this.sendAction("onToggle");
|
this.sendAction("onToggle");
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
|
||||||
clearSelection() {
|
|
||||||
this.sendAction("onClearSelection");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_setCaretIcon() {
|
_setCaretIcon() {
|
||||||
if(this.get("expanded")) {
|
if(this.get("expanded")) {
|
||||||
this.set("caretIcon", this.get("caretUpIcon"));
|
this.set("caretIcon", this.get("caretUpIcon"));
|
||||||
|
@ -13,9 +13,7 @@
|
|||||||
caretUpIcon=caretUpIcon
|
caretUpIcon=caretUpIcon
|
||||||
caretDownIcon=caretDownIcon
|
caretDownIcon=caretDownIcon
|
||||||
onToggle=(action "onToggle")
|
onToggle=(action "onToggle")
|
||||||
onClearSelection=(action "onClearSelection")
|
|
||||||
icon=icon
|
icon=icon
|
||||||
clearable=clearable
|
|
||||||
expanded=expanded
|
expanded=expanded
|
||||||
value=value
|
value=value
|
||||||
}}
|
}}
|
||||||
|
@ -6,10 +6,4 @@
|
|||||||
{{text}}
|
{{text}}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
{{#if showClearButton}}
|
|
||||||
<button class="btn btn-primary clear-selection" {{action "clearSelection" bubbles=false}}>
|
|
||||||
{{d-icon "times"}}
|
|
||||||
</button>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{d-icon caretIcon class="caret-icon"}}
|
{{d-icon caretIcon class="caret-icon"}}
|
||||||
|
@ -8,6 +8,12 @@
|
|||||||
-ms-flex-direction: column;
|
-ms-flex-direction: column;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
|
&.is-uncategorized {
|
||||||
|
.topic-count {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.topic-count {
|
.topic-count {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
color: $primary;
|
color: $primary;
|
||||||
|
@ -91,18 +91,6 @@
|
|||||||
-webkit-box-shadow: $tertiary 0px 0px 6px 0px;
|
-webkit-box-shadow: $tertiary 0px 0px 6px 0px;
|
||||||
box-shadow: $tertiary 0px 0px 6px 0px;
|
box-shadow: $tertiary 0px 0px 6px 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.clear-selection {
|
|
||||||
margin: 0 5px;
|
|
||||||
padding: 0;
|
|
||||||
outline: none;
|
|
||||||
|
|
||||||
.d-icon {
|
|
||||||
margin: 0;
|
|
||||||
padding-left: 10px;
|
|
||||||
padding-right: 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.select-box-body {
|
.select-box-body {
|
||||||
|
@ -324,28 +324,6 @@ componentTest('static headerText', {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
componentTest('clearable selection', {
|
|
||||||
template: '{{select-box value=1 content=content clearable=true}}',
|
|
||||||
|
|
||||||
beforeEach() {
|
|
||||||
this.set("content", [{ id: 1, text: "robin" }, { id: 2, text: "regis" }]);
|
|
||||||
},
|
|
||||||
|
|
||||||
test(assert) {
|
|
||||||
click(".select-box-header");
|
|
||||||
andThen(() => {
|
|
||||||
assert.ok(exists(".select-box-row.is-highlighted"));
|
|
||||||
assert.equal(find(".select-box-header .current-selection").html().trim(), "robin");
|
|
||||||
});
|
|
||||||
|
|
||||||
click(".select-box-header .clear-selection");
|
|
||||||
andThen(() => {
|
|
||||||
assert.notOk(exists(".select-box-row.is-highlighted"));
|
|
||||||
assert.equal(find(".select-box-header .current-selection").html().trim(), "Select...");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
componentTest('supports custom row title', {
|
componentTest('supports custom row title', {
|
||||||
template: '{{select-box content=content titleForRow=titleForRow}}',
|
template: '{{select-box content=content titleForRow=titleForRow}}',
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user