group_badge.ts 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /**
  2. * This file is part of Threema Web.
  3. *
  4. * Threema Web is free software: you can redistribute it and/or modify it
  5. * under the terms of the GNU Affero General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or (at
  7. * your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Affero General Public License
  15. * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * Show a contact receiver with small avatar, name and verification level
  19. */
  20. export default [
  21. '$translate',
  22. '$state',
  23. function($translate, $state: ng.ui.IStateService) {
  24. return {
  25. restrict: 'EA',
  26. scope: {},
  27. bindToController: {
  28. groupReceiver: '=eeeGroupReceiver',
  29. contactReceiver: '=?eeeContactReceiver',
  30. },
  31. controllerAs: 'ctrl',
  32. controller: [function() {
  33. this.showRoleIcon = this.contactReceiver !== undefined;
  34. if (this.showRoleIcon) {
  35. if (this.contactReceiver.id === this.groupReceiver.administrator) {
  36. this.roleIcon = 'people';
  37. $translate('messenger.GROUP_ROLE_CREATOR')
  38. .then((label) => {
  39. this.roleName = label;
  40. });
  41. } else {
  42. this.roleIcon = 'people_outline';
  43. $translate('messenger.GROUP_ROLE_NORMAL')
  44. .then((label) => {
  45. this.roleName = label;
  46. });
  47. }
  48. }
  49. this.click = () => {
  50. $state.go('messenger.home.conversation', {
  51. type: 'group',
  52. id: this.groupReceiver.id,
  53. initParams: null,
  54. });
  55. };
  56. }],
  57. template: `
  58. <div class="group-badge receiver-badge" ng-click="ctrl.click()">
  59. <section class="avatar-box">
  60. <eee-avatar eee-type="'group'"
  61. eee-receiver="ctrl.groupReceiver"
  62. eee-resolution="'low'"></eee-avatar>
  63. </section>
  64. <div class="receiver-badge-name">
  65. {{ctrl.groupReceiver.displayName}}
  66. </div>
  67. <div class="receiver-role" ng-if="ctrl.showRoleIcon" title="{{ctrl.roleLabel}}">
  68. <md-icon aria-label="{{ctrl.roleLabel}}" class="material-icons md-24">
  69. {{ctrl.roleIcon}}
  70. </md-icon>
  71. </div>
  72. </div>
  73. `,
  74. };
  75. },
  76. ];