2018-03-22 18:29:55 +08:00
|
|
|
const { get, isNone, run, isEmpty, makeArray } = Ember;
|
2017-11-21 18:53:09 +08:00
|
|
|
import computed from "ember-addons/ember-computed-decorators";
|
|
|
|
import UtilsMixin from "select-kit/mixins/utils";
|
|
|
|
import DomHelpersMixin from "select-kit/mixins/dom-helpers";
|
|
|
|
import EventsMixin from "select-kit/mixins/events";
|
|
|
|
import PluginApiMixin from "select-kit/mixins/plugin-api";
|
2017-11-22 17:34:12 +08:00
|
|
|
import {
|
2018-01-09 17:52:32 +08:00
|
|
|
applyContentPluginApiCallbacks,
|
2018-01-11 16:39:51 +08:00
|
|
|
applyHeaderContentPluginApiCallbacks,
|
2018-01-26 21:42:24 +08:00
|
|
|
applyCollectionHeaderCallbacks
|
2017-11-22 17:34:12 +08:00
|
|
|
} from "select-kit/mixins/plugin-api";
|
2017-11-21 18:53:09 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
export default Ember.Component.extend(
|
|
|
|
UtilsMixin,
|
|
|
|
PluginApiMixin,
|
|
|
|
DomHelpersMixin,
|
|
|
|
EventsMixin,
|
|
|
|
{
|
|
|
|
pluginApiIdentifiers: ["select-kit"],
|
|
|
|
layoutName: "select-kit/templates/components/select-kit",
|
|
|
|
classNames: ["select-kit"],
|
|
|
|
classNameBindings: [
|
|
|
|
"isLoading",
|
|
|
|
"isFocused",
|
|
|
|
"isExpanded",
|
|
|
|
"isDisabled",
|
|
|
|
"isHidden",
|
|
|
|
"hasSelection",
|
|
|
|
"hasReachedMaximum",
|
|
|
|
"hasReachedMinimum"
|
|
|
|
],
|
|
|
|
isDisabled: false,
|
|
|
|
isExpanded: false,
|
|
|
|
isFocused: false,
|
|
|
|
isHidden: false,
|
|
|
|
isLoading: false,
|
|
|
|
isAsync: false,
|
|
|
|
renderedBodyOnce: false,
|
|
|
|
renderedFilterOnce: false,
|
|
|
|
tabindex: 0,
|
|
|
|
none: null,
|
|
|
|
highlighted: null,
|
|
|
|
valueAttribute: "id",
|
|
|
|
nameProperty: "name",
|
|
|
|
autoFilterable: false,
|
|
|
|
filterable: false,
|
|
|
|
filter: "",
|
|
|
|
previousFilter: "",
|
|
|
|
filterIcon: "search",
|
|
|
|
headerIcon: null,
|
|
|
|
rowComponent: "select-kit/select-kit-row",
|
|
|
|
rowComponentOptions: null,
|
|
|
|
noneRowComponent: "select-kit/select-kit-none-row",
|
|
|
|
createRowComponent: "select-kit/select-kit-create-row",
|
|
|
|
filterComponent: "select-kit/select-kit-filter",
|
|
|
|
headerComponent: "select-kit/select-kit-header",
|
|
|
|
headerComponentOptions: null,
|
|
|
|
headerComputedContent: null,
|
|
|
|
collectionHeaderComputedContent: null,
|
|
|
|
collectionComponent: "select-kit/select-kit-collection",
|
|
|
|
verticalOffset: 0,
|
|
|
|
horizontalOffset: 0,
|
|
|
|
fullWidthOnMobile: false,
|
|
|
|
castInteger: false,
|
|
|
|
castBoolean: false,
|
|
|
|
allowAny: false,
|
|
|
|
allowInitialValueMutation: false,
|
|
|
|
content: null,
|
|
|
|
computedContent: null,
|
|
|
|
limitMatches: null,
|
|
|
|
nameChanges: false,
|
|
|
|
allowContentReplacement: false,
|
|
|
|
collectionHeader: null,
|
|
|
|
allowAutoSelectFirst: true,
|
|
|
|
highlightedSelection: null,
|
|
|
|
maximum: null,
|
|
|
|
minimum: null,
|
|
|
|
minimumLabel: null,
|
|
|
|
maximumLabel: null,
|
2018-09-12 18:19:04 +08:00
|
|
|
forceEscape: false,
|
2018-06-15 23:03:24 +08:00
|
|
|
|
|
|
|
init() {
|
|
|
|
this._super();
|
|
|
|
|
|
|
|
this.noneValue = "__none__";
|
2018-09-12 18:19:04 +08:00
|
|
|
this.set(
|
|
|
|
"headerComponentOptions",
|
|
|
|
Ember.Object.create({ forceEscape: this.get("forceEscape") })
|
|
|
|
);
|
|
|
|
this.set(
|
|
|
|
"rowComponentOptions",
|
|
|
|
Ember.Object.create({
|
|
|
|
forceEscape: this.get("forceEscape")
|
|
|
|
})
|
|
|
|
);
|
2018-06-15 23:03:24 +08:00
|
|
|
this.set("computedContent", []);
|
|
|
|
this.set("highlightedSelection", []);
|
|
|
|
|
|
|
|
if (this.get("nameChanges")) {
|
|
|
|
this.addObserver(
|
|
|
|
`content.@each.${this.get("nameProperty")}`,
|
|
|
|
this,
|
|
|
|
this._compute
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.get("allowContentReplacement")) {
|
|
|
|
this.addObserver(`content.[]`, this, this._compute);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.get("isAsync")) {
|
|
|
|
this.addObserver(`asyncContent.[]`, this, this._compute);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
keyDown(event) {
|
|
|
|
if (!isEmpty(this.get("filter"))) return true;
|
|
|
|
|
|
|
|
const keyCode = event.keyCode || event.which;
|
|
|
|
|
|
|
|
if (event.metaKey === true && keyCode === this.keys.A) {
|
|
|
|
this.didPressSelectAll();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (keyCode === this.keys.BACKSPACE) {
|
|
|
|
this.didPressBackspace();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
willDestroyElement() {
|
|
|
|
this.removeObserver(
|
|
|
|
`content.@each.${this.get("nameProperty")}`,
|
|
|
|
this,
|
|
|
|
this._compute
|
|
|
|
);
|
|
|
|
this.removeObserver(`content.[]`, this, this._compute);
|
|
|
|
this.removeObserver(`asyncContent.[]`, this, this._compute);
|
|
|
|
},
|
|
|
|
|
|
|
|
willComputeAttributes() {},
|
|
|
|
didComputeAttributes() {},
|
|
|
|
|
|
|
|
willComputeContent(content) {
|
|
|
|
return content;
|
|
|
|
},
|
|
|
|
computeContent(content) {
|
|
|
|
return content;
|
|
|
|
},
|
|
|
|
_beforeDidComputeContent(content) {
|
|
|
|
content = applyContentPluginApiCallbacks(
|
|
|
|
this.get("pluginApiIdentifiers"),
|
|
|
|
content,
|
|
|
|
this
|
|
|
|
);
|
|
|
|
|
2018-08-04 04:41:37 +08:00
|
|
|
let existingCreatedComputedContent = [];
|
|
|
|
if (!this.get("allowContentReplacement")) {
|
|
|
|
existingCreatedComputedContent = this.get("computedContent").filterBy(
|
|
|
|
"created",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-03-04 20:47:25 +08:00
|
|
|
this.setProperties({
|
2018-06-15 23:03:24 +08:00
|
|
|
computedContent: content
|
|
|
|
.map(c => this.computeContentItem(c))
|
|
|
|
.concat(existingCreatedComputedContent)
|
2018-03-04 20:47:25 +08:00
|
|
|
});
|
2018-06-15 23:03:24 +08:00
|
|
|
return content;
|
|
|
|
},
|
|
|
|
didComputeContent() {},
|
2017-11-22 20:49:45 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
willComputeAsyncContent(content) {
|
|
|
|
return content;
|
|
|
|
},
|
|
|
|
computeAsyncContent(content) {
|
|
|
|
return content;
|
|
|
|
},
|
|
|
|
_beforeDidComputeAsyncContent(content) {
|
|
|
|
content = applyContentPluginApiCallbacks(
|
|
|
|
this.get("pluginApiIdentifiers"),
|
|
|
|
content,
|
|
|
|
this
|
|
|
|
);
|
|
|
|
this.setProperties({
|
|
|
|
computedAsyncContent: content.map(c => this.computeAsyncContentItem(c))
|
|
|
|
});
|
|
|
|
return content;
|
|
|
|
},
|
|
|
|
didComputeAsyncContent() {},
|
2017-11-28 02:50:04 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
computeContentItem(contentItem, options) {
|
|
|
|
let originalContent;
|
|
|
|
options = options || {};
|
|
|
|
const name = options.name;
|
2018-02-26 18:42:57 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
if (typeof contentItem === "string" || typeof contentItem === "number") {
|
|
|
|
originalContent = {};
|
|
|
|
originalContent[this.get("valueAttribute")] = contentItem;
|
|
|
|
originalContent[this.get("nameProperty")] = name || contentItem;
|
|
|
|
} else {
|
|
|
|
originalContent = contentItem;
|
|
|
|
}
|
2017-11-22 20:49:45 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
let computedContentItem = {
|
|
|
|
value: this._cast(this.valueForContentItem(contentItem)),
|
|
|
|
name: name || this._nameForContent(contentItem),
|
|
|
|
locked: false,
|
|
|
|
created: options.created || false,
|
2018-11-15 22:21:40 +08:00
|
|
|
__sk_row_type: options.created
|
|
|
|
? "createRow"
|
|
|
|
: contentItem.__sk_row_type,
|
2018-06-15 23:03:24 +08:00
|
|
|
originalContent
|
|
|
|
};
|
2018-03-22 18:29:55 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
return computedContentItem;
|
|
|
|
},
|
2018-03-22 18:29:55 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
computeAsyncContentItem(contentItem, options) {
|
|
|
|
return this.computeContentItem(contentItem, options);
|
|
|
|
},
|
2018-03-22 18:29:55 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
@computed(
|
|
|
|
"isAsync",
|
|
|
|
"isLoading",
|
|
|
|
"filteredAsyncComputedContent.[]",
|
|
|
|
"filteredComputedContent.[]"
|
|
|
|
)
|
|
|
|
collectionComputedContent(
|
|
|
|
isAsync,
|
|
|
|
isLoading,
|
|
|
|
filteredAsyncComputedContent,
|
|
|
|
filteredComputedContent
|
|
|
|
) {
|
|
|
|
if (isAsync) {
|
|
|
|
return isLoading ? [] : filteredAsyncComputedContent;
|
|
|
|
} else {
|
|
|
|
return filteredComputedContent;
|
|
|
|
}
|
|
|
|
},
|
2017-11-21 18:53:09 +08:00
|
|
|
|
2018-08-06 23:22:48 +08:00
|
|
|
validateCreate(created) {
|
|
|
|
return !this.get("hasReachedMaximum") && created.length > 0;
|
2018-06-15 23:03:24 +08:00
|
|
|
},
|
2017-11-21 18:53:09 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
validateSelect() {
|
|
|
|
return !this.get("hasReachedMaximum");
|
|
|
|
},
|
2018-04-05 22:45:19 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
@computed("maximum", "selection.[]")
|
|
|
|
hasReachedMaximum(maximum, selection) {
|
|
|
|
if (!maximum) return false;
|
|
|
|
selection = makeArray(selection);
|
|
|
|
return selection.length >= maximum;
|
|
|
|
},
|
2017-11-21 18:53:09 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
@computed("minimum", "selection.[]")
|
|
|
|
hasReachedMinimum(minimum, selection) {
|
|
|
|
if (!minimum) return true;
|
|
|
|
selection = makeArray(selection);
|
|
|
|
return selection.length >= minimum;
|
|
|
|
},
|
2017-11-21 18:53:09 +08:00
|
|
|
|
2018-08-06 23:22:48 +08:00
|
|
|
@computed("shouldFilter", "allowAny")
|
|
|
|
shouldDisplayFilter(shouldFilter, allowAny) {
|
2018-06-15 23:03:24 +08:00
|
|
|
if (shouldFilter) return true;
|
2018-08-06 23:22:48 +08:00
|
|
|
if (allowAny) return true;
|
2018-06-15 23:03:24 +08:00
|
|
|
return false;
|
|
|
|
},
|
2017-11-21 18:53:09 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
@computed("filter", "collectionComputedContent.[]", "isLoading")
|
|
|
|
noContentRow(filter, collectionComputedContent, isLoading) {
|
|
|
|
if (
|
|
|
|
filter.length > 0 &&
|
|
|
|
collectionComputedContent.length === 0 &&
|
|
|
|
!isLoading
|
|
|
|
) {
|
|
|
|
return I18n.t("select_kit.no_content");
|
|
|
|
}
|
|
|
|
},
|
2017-11-21 18:53:09 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
@computed("hasReachedMaximum", "hasReachedMinimum", "isExpanded")
|
|
|
|
validationMessage(hasReachedMaximum, hasReachedMinimum) {
|
|
|
|
if (hasReachedMaximum && this.get("maximum")) {
|
|
|
|
const key =
|
|
|
|
this.get("maximumLabel") || "select_kit.max_content_reached";
|
|
|
|
return I18n.t(key, { count: this.get("maximum") });
|
|
|
|
}
|
2018-03-29 19:42:00 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
if (!hasReachedMinimum && this.get("minimum")) {
|
|
|
|
const key =
|
|
|
|
this.get("minimumLabel") || "select_kit.min_content_not_reached";
|
|
|
|
return I18n.t(key, { count: this.get("minimum") });
|
|
|
|
}
|
|
|
|
},
|
2017-11-21 18:53:09 +08:00
|
|
|
|
2018-08-06 23:22:48 +08:00
|
|
|
@computed("allowAny")
|
|
|
|
filterPlaceholder(allowAny) {
|
|
|
|
return allowAny
|
|
|
|
? "select_kit.filter_placeholder_with_any"
|
|
|
|
: "select_kit.filter_placeholder";
|
|
|
|
},
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
@computed("filter", "filterable", "autoFilterable", "renderedFilterOnce")
|
|
|
|
shouldFilter(filter, filterable, autoFilterable, renderedFilterOnce) {
|
|
|
|
if (renderedFilterOnce && filterable) return true;
|
|
|
|
if (filterable) return true;
|
|
|
|
if (autoFilterable && filter.length > 0) return true;
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
@computed(
|
|
|
|
"computedValue",
|
|
|
|
"filter",
|
|
|
|
"collectionComputedContent.[]",
|
|
|
|
"hasReachedMaximum",
|
|
|
|
"isLoading"
|
|
|
|
)
|
|
|
|
shouldDisplayCreateRow(
|
|
|
|
computedValue,
|
|
|
|
filter,
|
|
|
|
collectionComputedContent,
|
|
|
|
hasReachedMaximum,
|
|
|
|
isLoading
|
|
|
|
) {
|
|
|
|
if (isLoading || hasReachedMaximum) return false;
|
|
|
|
if (collectionComputedContent.map(c => c.value).includes(filter))
|
|
|
|
return false;
|
2018-08-06 23:22:48 +08:00
|
|
|
if (this.get("allowAny") && this.validateCreate(filter)) return true;
|
2018-06-15 23:03:24 +08:00
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
@computed("filter", "shouldDisplayCreateRow")
|
|
|
|
createRowComputedContent(filter, shouldDisplayCreateRow) {
|
|
|
|
if (shouldDisplayCreateRow) {
|
|
|
|
let content = this.createContentFromInput(filter);
|
|
|
|
let computedContentItem = this.computeContentItem(content, {
|
|
|
|
created: true
|
|
|
|
});
|
|
|
|
computedContentItem.__sk_row_type = "createRow";
|
|
|
|
return computedContentItem;
|
|
|
|
}
|
|
|
|
},
|
2017-11-21 18:53:09 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
@computed
|
|
|
|
templateForRow() {
|
|
|
|
return () => null;
|
|
|
|
},
|
2017-11-21 18:53:09 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
@computed
|
|
|
|
templateForNoneRow() {
|
|
|
|
return () => null;
|
|
|
|
},
|
2018-01-11 16:39:51 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
@computed("filter")
|
|
|
|
templateForCreateRow() {
|
|
|
|
return rowComponent => {
|
|
|
|
return I18n.t("select_kit.create", {
|
|
|
|
content: rowComponent.get("computedContent.name")
|
|
|
|
});
|
|
|
|
};
|
|
|
|
},
|
2018-01-11 16:39:51 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
@computed("none")
|
|
|
|
noneRowComputedContent(none) {
|
|
|
|
if (isNone(none)) return null;
|
2017-11-21 18:53:09 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
let noneRowComputedContent;
|
2017-11-21 18:53:09 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
switch (typeof none) {
|
|
|
|
case "string":
|
|
|
|
noneRowComputedContent = this.computeContentItem(this.noneValue, {
|
|
|
|
name: (I18n.t(none) || "").htmlSafe()
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
noneRowComputedContent = this.computeContentItem(none);
|
|
|
|
}
|
2018-03-22 18:29:55 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
noneRowComputedContent.__sk_row_type = "noneRow";
|
2018-03-22 18:29:55 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
return noneRowComputedContent;
|
|
|
|
},
|
2018-03-22 18:29:55 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
createContentFromInput(input) {
|
|
|
|
return input;
|
|
|
|
},
|
2017-11-21 18:53:09 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
highlightSelection(items) {
|
|
|
|
this.propertyWillChange("highlightedSelection");
|
|
|
|
this.set("highlightedSelection", makeArray(items));
|
|
|
|
this.propertyDidChange("highlightedSelection");
|
|
|
|
},
|
2018-02-14 00:23:12 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
clearHighlightSelection() {
|
|
|
|
this.highlightSelection([]);
|
|
|
|
},
|
2018-05-28 22:18:25 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
willSelect() {},
|
|
|
|
didSelect() {},
|
2018-01-09 17:52:32 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
willCreate() {},
|
|
|
|
didCreate() {},
|
2018-03-22 18:29:55 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
willDeselect() {},
|
|
|
|
didDeselect() {},
|
2018-03-22 18:29:55 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
clearFilter() {
|
|
|
|
this.$filterInput().val("");
|
|
|
|
this.setProperties({ filter: "", previousFilter: "" });
|
|
|
|
},
|
2018-01-11 16:39:51 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
startLoading() {
|
|
|
|
this.set("isLoading", true);
|
|
|
|
this.set("highlighted", null);
|
|
|
|
this._boundaryActionHandler("onStartLoading");
|
2017-11-21 18:53:09 +08:00
|
|
|
},
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
stopLoading() {
|
|
|
|
if (this.site && !this.site.isMobileDevice) {
|
|
|
|
this.focusFilterOrHeader();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.set("isLoading", false);
|
|
|
|
this._boundaryActionHandler("onStopLoading");
|
2017-11-21 18:53:09 +08:00
|
|
|
},
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
@computed("selection.[]", "isExpanded", "filter", "highlightedSelection.[]")
|
|
|
|
collectionHeaderComputedContent() {
|
|
|
|
return applyCollectionHeaderCallbacks(
|
|
|
|
this.get("pluginApiIdentifiers"),
|
|
|
|
this.get("collectionHeader"),
|
|
|
|
this
|
|
|
|
);
|
2018-03-22 18:29:55 +08:00
|
|
|
},
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
@computed("selection.[]", "isExpanded", "headerIcon")
|
|
|
|
headerComputedContent() {
|
|
|
|
return applyHeaderContentPluginApiCallbacks(
|
|
|
|
this.get("pluginApiIdentifiers"),
|
|
|
|
this.computeHeaderContent(),
|
|
|
|
this
|
|
|
|
);
|
2018-03-22 18:29:55 +08:00
|
|
|
},
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
_boundaryActionHandler(actionName, ...params) {
|
|
|
|
if (get(this.actions, actionName)) {
|
|
|
|
run.next(() => this.send(actionName, ...params));
|
|
|
|
} else if (this.get(actionName)) {
|
2018-07-20 02:33:11 +08:00
|
|
|
run.next(() => this.get(actionName)(...params));
|
2018-06-15 23:03:24 +08:00
|
|
|
}
|
2018-03-22 18:29:55 +08:00
|
|
|
},
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
highlight(computedContent) {
|
|
|
|
this.set("highlighted", computedContent);
|
|
|
|
this._boundaryActionHandler("onHighlight", computedContent);
|
|
|
|
},
|
2018-02-14 00:23:12 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
clearSelection() {
|
|
|
|
this.deselect(this.get("selection"));
|
2018-07-24 00:19:40 +08:00
|
|
|
this.focusFilterOrHeader();
|
2018-06-15 23:03:24 +08:00
|
|
|
},
|
2018-03-22 18:29:55 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
actions: {
|
|
|
|
onToggle() {
|
|
|
|
this.clearHighlightSelection();
|
|
|
|
|
|
|
|
if (this.get("isExpanded")) {
|
|
|
|
this.collapse();
|
|
|
|
} else {
|
|
|
|
this.expand();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onClickRow(computedContentItem) {
|
|
|
|
this.didClickRow(computedContentItem);
|
|
|
|
},
|
|
|
|
|
|
|
|
onClickSelectionItem(computedContentItem) {
|
|
|
|
this.didClickSelectionItem(computedContentItem);
|
|
|
|
},
|
|
|
|
|
|
|
|
onClearSelection() {
|
|
|
|
this.clearSelection();
|
|
|
|
},
|
|
|
|
|
|
|
|
onMouseoverRow(computedContentItem) {
|
|
|
|
this.highlight(computedContentItem);
|
|
|
|
},
|
|
|
|
|
|
|
|
onFilterComputedContent(filter) {
|
|
|
|
if (filter === this.get("previousFilter")) return;
|
|
|
|
|
|
|
|
this.clearHighlightSelection();
|
|
|
|
|
|
|
|
this.setProperties({
|
|
|
|
highlighted: null,
|
|
|
|
renderedFilterOnce: true,
|
|
|
|
previousFilter: filter,
|
|
|
|
filter
|
|
|
|
});
|
|
|
|
this.autoHighlight();
|
|
|
|
this._boundaryActionHandler("onFilter", filter);
|
|
|
|
}
|
2017-11-21 18:53:09 +08:00
|
|
|
}
|
|
|
|
}
|
2018-06-15 23:03:24 +08:00
|
|
|
);
|