class PublicUserList extends RessourceList { static autoInit() { for (let publicUserListElement of document.querySelectorAll('.public-user-list:not(.no-autoinit)')) { new PublicUserList(publicUserListElement); } } static options = { initialHtmlGenerator: (id) => { return `
search
Username Full name Location Organization Corpora online
`.trim(); }, item: ` user-image send `.trim(), ressourceMapper: (user) => { return { 'id': user.id, 'member-since': user.member_since, 'avatar': user.avatar ? `/profile/${user.id}/avatar` : '/static/images/user_avatar.png', 'username': user.username, 'full-name': user.full_name ? user.full_name : '', 'location': user.location ? user.location : '', 'organization': user.organization ? user.organization : '', 'corpora-online': '0' }; }, sortArgs: ['member-since', {order: 'desc'}], valueNames: [ {data: ['id']}, {data: ['member-since']}, {name: 'avatar', attr: 'src'}, 'username', 'full-name', 'location', 'organization', 'corpora-online' ] }; constructor(listElement, options = {}) { super(listElement, {...PublicUserList.options, ...options}); } init(users) { super._init(Object.values(users)); } onClick(event) { let actionButtonElement = event.target.closest('.action-button'); let action = actionButtonElement === null ? 'view' : actionButtonElement.dataset.action; let publicUserElement = event.target.closest('tr'); let publicUserId = publicUserElement.dataset.id; switch (action) { case 'view': { window.location.href = `/profile/${publicUserId}`; break; } default: { break; } } } }