Skip to content
Snippets Groups Projects
Commit 066bb8a8 authored by Kyle Doherty's avatar Kyle Doherty Committed by GitHub
Browse files

Sync everything else display (#5518)

* fix name and order of everything else collection

* modernize card picker component

* return proper name from api

* update test
parent c8271139
No related branches found
No related tags found
No related merge requests found
......@@ -10,18 +10,13 @@ import Query from "metabase/lib/query";
import _ from "underscore";
export default class CardPicker extends Component {
constructor(props, context) {
super(props, context);
this.state = {
isOpen: false,
inputValue: "",
inputWidth: 300,
collectionId: undefined,
};
state = {
isOpen: false,
inputValue: "",
inputWidth: 300,
collectionId: undefined,
};
_.bindAll(this, "onChange", "onInputChange", "onInputFocus", "onInputBlur");
}
static propTypes = {
cardList: PropTypes.array.isRequired,
......@@ -32,15 +27,15 @@ export default class CardPicker extends Component {
clearTimeout(this._timer);
}
onInputChange(e) {
this.setState({ inputValue: e.target.value });
onInputChange = ({target}) => {
this.setState({ inputValue: target.value });
}
onInputFocus() {
onInputFocus = () => {
this.setState({ isOpen: true });
}
onInputBlur() {
onInputBlur = () => {
// Without a timeout here isOpen gets set to false when an item is clicked
// which causes the click handler to not fire. For some reason this even
// happens with a 100ms delay, but not 200ms?
......@@ -54,7 +49,7 @@ export default class CardPicker extends Component {
}, 250);
}
onChange(id) {
onChange = (id) => {
this.props.onChange(id);
ReactDOM.findDOMNode(this.refs.input).blur();
}
......@@ -107,10 +102,11 @@ export default class CardPicker extends Component {
.uniq(c => c && c.id)
.filter(c => c)
.sortBy("name")
// add "Everything else" as the last option for cards without a
// collection
.concat([{ id: null, name: "Everything else"}])
.value();
collections.unshift({ id: null, name: "None" });
let visibleCardList;
if (inputValue) {
let searchString = inputValue.toLowerCase();
......@@ -162,11 +158,11 @@ export default class CardPicker extends Component {
</ul>
: collections ?
<CollectionList>
{collections.map(collection =>
<CollectionListItem collection={collection} onClick={(e) => {
this.setState({ collectionId: collection.id, isClicking: true });
}}/>
)}
{collections.map(collection =>
<CollectionListItem collection={collection} onClick={(e) => {
this.setState({ collectionId: collection.id, isClicking: true });
}}/>
)}
</CollectionList>
: null }
</div>
......
......@@ -130,7 +130,7 @@
(cond-> {:id (str "card__" (u/get-id card))
:db_id database/virtual-id
:display_name (:name card)
:schema (get-in card [:collection :name] "All questions")
:schema (get-in card [:collection :name] "Everything else")
:description (:description card)}
include-fields? (assoc :fields (card-result-metadata->virtual-fields (u/get-id card) (:result_metadata card))))))
......
......@@ -343,7 +343,7 @@
(merge {:id (format "card__%d" (u/get-id card))
:db_id database/virtual-id
:display_name (:name card)
:schema "All questions"
:schema "Everything else"
:description nil}
kvs))
......
......@@ -461,7 +461,7 @@
:native {:query (format "SELECT NAME, ID, PRICE, LATITUDE FROM VENUES")}}}]]
(let [card-virtual-table-id (str "card__" (u/get-id card))]
{:display_name "Go Dubs!"
:schema "All questions"
:schema "Everything else"
:db_id database/virtual-id
:id card-virtual-table-id
:description nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment