|
|
@@ -271,6 +271,21 @@ class AddPeopleDialog extends AbstractAddPeopleDialog<Props, State> {
|
|
271
|
271
|
|
|
272
|
272
|
_parseQueryResults: (?Array<Object>) => Array<Object>;
|
|
273
|
273
|
|
|
|
274
|
+ /**
|
|
|
275
|
+ * Returns the avatar component for a user.
|
|
|
276
|
+ *
|
|
|
277
|
+ * @param {Object} user - The user
|
|
|
278
|
+ * @param {string} className - The CSS class for the avatar component
|
|
|
279
|
+ * @private
|
|
|
280
|
+ * @returns {ReactElement}
|
|
|
281
|
+ */
|
|
|
282
|
+ _getAvatar(user, className = 'avatar-small') {
|
|
|
283
|
+ return (<Avatar
|
|
|
284
|
+ className = { className }
|
|
|
285
|
+ status = { user.status }
|
|
|
286
|
+ url = { user.avatar } />);
|
|
|
287
|
+ }
|
|
|
288
|
+
|
|
274
|
289
|
/**
|
|
275
|
290
|
* Processes results from requesting available numbers and people by munging
|
|
276
|
291
|
* each result into a format {@code MultiSelectAutocomplete} can use for
|
|
|
@@ -283,24 +298,40 @@ class AddPeopleDialog extends AbstractAddPeopleDialog<Props, State> {
|
|
283
|
298
|
* search autocomplete.
|
|
284
|
299
|
*/
|
|
285
|
300
|
_parseQueryResults(response = []) {
|
|
286
|
|
- const { t } = this.props;
|
|
|
301
|
+ const { t, _dialOutEnabled } = this.props;
|
|
287
|
302
|
const users = response.filter(item => item.type !== 'phone');
|
|
288
|
|
- const userDisplayItems = users.map(user => {
|
|
289
|
|
- return {
|
|
290
|
|
- content: user.name,
|
|
291
|
|
- elemBefore: <Avatar
|
|
292
|
|
- className = { 'avatar-small' }
|
|
293
|
|
- status = { user.status }
|
|
294
|
|
- url = { user.avatar } />,
|
|
|
303
|
+ const userDisplayItems = [];
|
|
|
304
|
+
|
|
|
305
|
+ users.forEach(user => {
|
|
|
306
|
+ const { name, phone } = user;
|
|
|
307
|
+ const tagAvatar = this._getAvatar(user, 'avatar-xsmall');
|
|
|
308
|
+ const elemAvatar = this._getAvatar(user);
|
|
|
309
|
+
|
|
|
310
|
+ userDisplayItems.push({
|
|
|
311
|
+ content: name,
|
|
|
312
|
+ elemBefore: elemAvatar,
|
|
295
|
313
|
item: user,
|
|
296
|
314
|
tag: {
|
|
297
|
|
- elemBefore: <Avatar
|
|
298
|
|
- className = { 'avatar-xsmall' }
|
|
299
|
|
- status = { user.status }
|
|
300
|
|
- url = { user.avatar } />
|
|
|
315
|
+ elemBefore: tagAvatar
|
|
301
|
316
|
},
|
|
302
|
317
|
value: user.id || user.user_id
|
|
303
|
|
- };
|
|
|
318
|
+ });
|
|
|
319
|
+
|
|
|
320
|
+ if (phone && _dialOutEnabled) {
|
|
|
321
|
+ userDisplayItems.push({
|
|
|
322
|
+ filterValues: [ name, phone ],
|
|
|
323
|
+ content: `${phone} (${name})`,
|
|
|
324
|
+ elemBefore: elemAvatar,
|
|
|
325
|
+ item: {
|
|
|
326
|
+ type: 'phone',
|
|
|
327
|
+ number: phone
|
|
|
328
|
+ },
|
|
|
329
|
+ tag: {
|
|
|
330
|
+ elemBefore: tagAvatar
|
|
|
331
|
+ },
|
|
|
332
|
+ value: phone
|
|
|
333
|
+ });
|
|
|
334
|
+ }
|
|
304
|
335
|
});
|
|
305
|
336
|
|
|
306
|
337
|
const numbers = response.filter(item => item.type === 'phone');
|