contact_badge.ts 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. // tslint:disable:max-line-length
  18. import {WebClientService} from '../services/webclient';
  19. /**
  20. * Show a contact receiver with small avatar, name and verification level
  21. */
  22. export default [
  23. 'WebClientService',
  24. '$state',
  25. function(webClientService: WebClientService, $state: ng.ui.IStateService) {
  26. return {
  27. restrict: 'EA',
  28. scope: {},
  29. bindToController: {
  30. identity: '=?eeeIdentity',
  31. contactReceiver: '=?eeeContact',
  32. linked: '=?eeeLinked',
  33. onRemove: '=?eeeOnRemove',
  34. },
  35. controllerAs: 'ctrl',
  36. controller: [function() {
  37. this.$onInit = function() {
  38. if (this.contactReceiver === undefined) {
  39. this.contactReceiver = webClientService.contacts.get(this.identity);
  40. } else {
  41. this.identity = this.contactReceiver.id;
  42. }
  43. this.click = () => {
  44. if (this.linked !== undefined
  45. && this.linked === true) {
  46. $state.go('messenger.home.conversation', {type: 'contact', id: this.identity, initParams: null});
  47. }
  48. };
  49. this.showActions = this.onRemove !== undefined;
  50. };
  51. }],
  52. template: `
  53. <div class="contact-badge receiver-badge" ng-click="ctrl.click()">
  54. <section class="avatar-box">
  55. <eee-avatar eee-receiver="ctrl.contactReceiver"
  56. eee-resolution="'low'"></eee-avatar>
  57. </section>
  58. <div class="receiver-badge-name"
  59. ng-bind-html="ctrl.contactReceiver.displayName | escapeHtml | emojify">
  60. </div>
  61. <div class="contact-badge-identity">
  62. {{ctrl.contactReceiver.id}}
  63. </div>
  64. <div class="contact-badge-actions" ng-if="ctrl.showActions">
  65. <md-button aria-label="Remove" class="md-icon-button" ng-click="ctrl.onRemove(ctrl.contactReceiver)">
  66. <i class="material-icons md-dark md-24">delete</i>
  67. </md-button>
  68. </div>
  69. </div>
  70. `,
  71. };
  72. },
  73. ];