2021-02-01 05:07:11 -05:00
|
|
|
import UserChooserComponent from "select-kit/components/user-chooser";
|
|
|
|
|
|
|
|
export default UserChooserComponent.extend({
|
|
|
|
pluginApiIdentifiers: ["email-group-user-chooser"],
|
|
|
|
classNames: ["email-group-user-chooser"],
|
2021-02-12 05:51:36 -05:00
|
|
|
classNameBindings: ["selectKit.options.fullWidthWrap:full-width-wrap"],
|
2021-02-01 05:07:11 -05:00
|
|
|
valueProperty: "id",
|
|
|
|
nameProperty: "name",
|
|
|
|
|
|
|
|
modifyComponentForRow() {
|
|
|
|
return "email-group-user-chooser-row";
|
|
|
|
},
|
|
|
|
|
|
|
|
selectKitOptions: {
|
2021-02-03 10:06:16 -05:00
|
|
|
filterComponent: "email-group-user-chooser-filter",
|
2021-02-12 05:51:36 -05:00
|
|
|
fullWidthWrap: false,
|
2021-02-01 05:07:11 -05:00
|
|
|
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;
|
2022-09-28 09:31:20 -04:00
|
|
|
reconstructed.showUserStatus = this.showUserStatus;
|
2021-02-01 05:07:11 -05:00
|
|
|
}
|
|
|
|
} else if (item.name) {
|
|
|
|
reconstructed.id = item.name;
|
|
|
|
reconstructed.name = item.full_name;
|
|
|
|
reconstructed.isGroup = true;
|
|
|
|
}
|
|
|
|
return Object.assign({}, item, reconstructed);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|