| 
									
										
										
										
											2018-04-04 10:48:47 -07:00
										 |  |  | import Component from '@ember/component'; | 
					
						
							|  |  |  | import { IAvatar } from 'wherehows-web/typings/app/avatars'; | 
					
						
							| 
									
										
										
										
											2019-08-31 20:51:14 -07:00
										 |  |  | import { set } from '@ember/object'; | 
					
						
							|  |  |  | import { action, computed } from '@ember/object'; | 
					
						
							| 
									
										
										
										
											2018-04-04 23:32:21 -07:00
										 |  |  | import { singularize, pluralize } from 'ember-inflector'; | 
					
						
							| 
									
										
										
										
											2019-08-31 20:51:14 -07:00
										 |  |  | import { tagName, classNames } from '@ember-decorators/component'; | 
					
						
							| 
									
										
										
										
											2018-04-04 10:48:47 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-31 20:51:14 -07:00
										 |  |  | @tagName('span') | 
					
						
							|  |  |  | @classNames('avatar-rollup') | 
					
						
							| 
									
										
										
										
											2018-05-15 13:13:37 -07:00
										 |  |  | export default class RollupAvatars extends Component { | 
					
						
							| 
									
										
										
										
											2018-04-04 10:48:47 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * References the full list of avatars | 
					
						
							|  |  |  |    * @type {Array<IAvatar>} | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2019-08-31 20:51:14 -07:00
										 |  |  |   avatars: Array<IAvatar> = []; | 
					
						
							| 
									
										
										
										
											2018-04-04 10:48:47 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   /** | 
					
						
							|  |  |  |    * Flag indicating if the avatars detail view should be rendered | 
					
						
							|  |  |  |    * @type {boolean} | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   isShowingAvatars = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 23:32:21 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * The type of avatars being shown | 
					
						
							|  |  |  |    * @type {string} | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2019-08-31 20:51:14 -07:00
										 |  |  |   avatarType: string = 'entity'; | 
					
						
							| 
									
										
										
										
											2018-04-04 23:32:21 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 10:48:47 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * Returns the text to be shown in the avatar detail page header | 
					
						
							| 
									
										
										
										
											2019-08-31 20:51:14 -07:00
										 |  |  |    * @type {string} | 
					
						
							| 
									
										
										
										
											2018-04-04 10:48:47 -07:00
										 |  |  |    */ | 
					
						
							| 
									
										
										
										
											2019-08-31 20:51:14 -07:00
										 |  |  |   @computed('avatars.length') | 
					
						
							|  |  |  |   get header(): string { | 
					
						
							|  |  |  |     const count = this.avatars.length; | 
					
						
							|  |  |  |     const suffix = this.avatarType; | 
					
						
							| 
									
										
										
										
											2018-04-04 23:32:21 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return `${count} ${count > 1 ? pluralize(suffix) : singularize(suffix)}`; | 
					
						
							| 
									
										
										
										
											2019-08-31 20:51:14 -07:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-04-04 10:48:47 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   /** | 
					
						
							|  |  |  |    * Handles the component click event | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2019-08-31 20:51:14 -07:00
										 |  |  |   click(): void { | 
					
						
							| 
									
										
										
										
											2018-04-04 10:48:47 -07:00
										 |  |  |     set(this, 'isShowingAvatars', true); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /** | 
					
						
							|  |  |  |    * Updates the flag indicating if the view should be rendered | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   @action | 
					
						
							| 
									
										
										
										
											2019-08-31 20:51:14 -07:00
										 |  |  |   dismissAvatars(): void { | 
					
						
							| 
									
										
										
										
											2018-04-04 10:48:47 -07:00
										 |  |  |     set(this, 'isShowingAvatars', false); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |