mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 01:43:45 +08:00
cb59681d86
Major changes included: - better support for screen readers - trapping focus in modals - better tabbing order in composer - alerts on no content found/number of items found - better autofocus in modals - mini-tag-chooser is now a multi-select component - each multi-select-component will now display selection on one row
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
import UserChooserComponent from "select-kit/components/user-chooser";
|
|
|
|
export default UserChooserComponent.extend({
|
|
pluginApiIdentifiers: ["email-group-user-chooser"],
|
|
classNames: ["email-group-user-chooser"],
|
|
classNameBindings: ["selectKit.options.fullWidthWrap:full-width-wrap"],
|
|
valueProperty: "id",
|
|
nameProperty: "name",
|
|
|
|
modifyComponentForRow() {
|
|
return "email-group-user-chooser-row";
|
|
},
|
|
|
|
selectKitOptions: {
|
|
filterComponent: "email-group-user-chooser-filter",
|
|
fullWidthWrap: false,
|
|
autoWrap: false,
|
|
},
|
|
|
|
search() {
|
|
const superPromise = this._super(...arguments);
|
|
if (!superPromise) {
|
|
return;
|
|
}
|
|
return superPromise.then((results) => {
|
|
if (!results || results.length === 0) {
|
|
return;
|
|
}
|
|
return results.map((item) => {
|
|
const reconstructed = {};
|
|
if (item.username) {
|
|
reconstructed.id = item.username;
|
|
if (item.username.includes("@")) {
|
|
reconstructed.isEmail = true;
|
|
} else {
|
|
reconstructed.isUser = true;
|
|
reconstructed.name = item.name;
|
|
}
|
|
} else if (item.name) {
|
|
reconstructed.id = item.name;
|
|
reconstructed.name = item.full_name;
|
|
reconstructed.isGroup = true;
|
|
}
|
|
return Object.assign({}, item, reconstructed);
|
|
});
|
|
});
|
|
},
|
|
});
|