2024-08-23 12:17:07 +01:00
|
|
|
import { classNames } from "@ember-decorators/component";
|
2025-02-12 03:14:57 +03:00
|
|
|
import FilterForMore from "select-kit/components/filter-for-more";
|
2017-11-21 11:53:09 +01:00
|
|
|
import MultiSelectComponent from "select-kit/components/multi-select";
|
2024-08-23 12:17:07 +01:00
|
|
|
import {
|
2025-02-12 03:14:57 +03:00
|
|
|
MAIN_COLLECTION,
|
2024-08-23 12:17:07 +01:00
|
|
|
pluginApiIdentifiers,
|
|
|
|
selectKitOptions,
|
|
|
|
} from "select-kit/components/select-kit";
|
2017-11-21 11:53:09 +01:00
|
|
|
|
2025-02-12 03:14:57 +03:00
|
|
|
const FILTER_FOR_MORE_GROUPS_COLLECTION = "MORE_GROUPS_COLLECTION";
|
|
|
|
|
2024-08-23 12:17:07 +01:00
|
|
|
@classNames("group-chooser")
|
|
|
|
@selectKitOptions({
|
|
|
|
allowAny: false,
|
2025-02-12 03:14:57 +03:00
|
|
|
displayedGroupsLimit: 100,
|
2024-08-23 12:17:07 +01:00
|
|
|
})
|
|
|
|
@pluginApiIdentifiers("group-chooser")
|
2025-02-12 03:14:57 +03:00
|
|
|
export default class GroupChooser extends MultiSelectComponent {
|
|
|
|
init() {
|
|
|
|
super.init(...arguments);
|
|
|
|
|
|
|
|
this.insertAfterCollection(
|
|
|
|
MAIN_COLLECTION,
|
|
|
|
FILTER_FOR_MORE_GROUPS_COLLECTION
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
modifyComponentForCollection(identifier) {
|
|
|
|
if (identifier === FILTER_FOR_MORE_GROUPS_COLLECTION) {
|
|
|
|
return FilterForMore;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
modifyContent(content) {
|
|
|
|
const limit = this.selectKit.options.displayedGroupsLimit;
|
|
|
|
if (content.length > limit) {
|
|
|
|
this.showFilterForMore = true;
|
|
|
|
content = content.slice(0, limit);
|
|
|
|
} else {
|
|
|
|
this.showFilterForMore = false;
|
|
|
|
}
|
|
|
|
return content;
|
|
|
|
}
|
|
|
|
|
|
|
|
modifyContentForCollection(identifier) {
|
|
|
|
if (identifier === FILTER_FOR_MORE_GROUPS_COLLECTION) {
|
|
|
|
return {
|
|
|
|
shouldShowMoreTip: this.showFilterForMore,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|