export default { name: 'Assignees', data() { return { defaultRenderCount: 5, defaultMaxCounter: 99, showLess: true, }; }, props: { rootPath: { type: String, required: true, }, users: { type: Array, required: true, }, editable: { type: Boolean, required: true, }, }, computed: { firstUser() { return this.users[0]; }, hasMoreThanTwoAssignees() { return this.users.length > 2; }, hasMoreThanOneAssignee() { return this.users.length > 1; }, hasAssignees() { return this.users.length > 0; }, hasNoUsers() { return !this.users.length; }, hasOneUser() { return this.users.length === 1; }, renderShowMoreSection() { return this.users.length > this.defaultRenderCount; }, numberOfHiddenAssignees() { return this.users.length - this.defaultRenderCount; }, isHiddenAssignees() { return this.numberOfHiddenAssignees > 0; }, hiddenAssigneesLabel() { return `+ ${this.numberOfHiddenAssignees} more`; }, collapsedTooltipTitle() { const maxRender = Math.min(this.defaultRenderCount, this.users.length); const renderUsers = this.users.slice(0, maxRender); const names = renderUsers.map(u => u.name); if (this.users.length > maxRender) { names.push(`+ ${this.users.length - maxRender} more`); } return names.join(', '); }, sidebarAvatarCounter() { let counter = `+${this.users.length - 1}`; if (this.users.length > this.defaultMaxCounter) { counter = `${this.defaultMaxCounter}+`; } return counter; }, }, methods: { assignSelf() { this.$emit('assign-self'); }, toggleShowLess() { this.showLess = !this.showLess; }, renderAssignee(index) { return !this.showLess || (index < this.defaultRenderCount && this.showLess); }, avatarUrl(user) { return user.avatar || user.avatar_url; }, assigneeUrl(user) { return `${this.rootPath}${user.username}`; }, assigneeAlt(user) { return `${user.name}'s avatar`; }, assigneeUsername(user) { return `@${user.username}`; }, shouldRenderCollapsedAssignee(index) { const firstTwo = this.users.length <= 2 && index <= 2; return index === 0 || firstTwo; }, }, template: `
`, };