1
0

sharedialogresharerinfoview.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * Copyright (c) 2015
  3. *
  4. * This file is licensed under the Affero General Public License version 3
  5. * or later.
  6. *
  7. * See the COPYING-README file.
  8. *
  9. */
  10. /* globals Handlebars */
  11. (function() {
  12. if (!OC.Share) {
  13. OC.Share = {};
  14. }
  15. /**
  16. * @class OCA.Share.ShareDialogView
  17. * @member {OC.Share.ShareItemModel} model
  18. * @member {jQuery} $el
  19. * @memberof OCA.Sharing
  20. * @classdesc
  21. *
  22. * Represents the GUI of the share dialogue
  23. *
  24. */
  25. var ShareDialogResharerInfoView = OC.Backbone.View.extend({
  26. /** @type {string} **/
  27. id: 'shareDialogResharerInfo',
  28. /** @type {string} **/
  29. tagName: 'div',
  30. /** @type {string} **/
  31. className: 'reshare',
  32. /** @type {OC.Share.ShareConfigModel} **/
  33. configModel: undefined,
  34. /** @type {Function} **/
  35. _template: undefined,
  36. initialize: function(options) {
  37. var view = this;
  38. this.model.on('change:reshare', function() {
  39. view.render();
  40. });
  41. if(!_.isUndefined(options.configModel)) {
  42. this.configModel = options.configModel;
  43. } else {
  44. throw 'missing OC.Share.ShareConfigModel';
  45. }
  46. },
  47. render: function() {
  48. if (!this.model.hasReshare()
  49. || this.model.getReshareOwner() === OC.currentUser)
  50. {
  51. this.$el.empty();
  52. return this;
  53. }
  54. var reshareTemplate = this.template();
  55. var ownerDisplayName = this.model.getReshareOwnerDisplayname();
  56. var shareNote = this.model.getReshareNote();
  57. var sharedByText = '';
  58. if (this.model.getReshareType() === OC.Share.SHARE_TYPE_GROUP) {
  59. sharedByText = t(
  60. 'core',
  61. 'Shared with you and the group {group} by {owner}',
  62. {
  63. group: this.model.getReshareWithDisplayName(),
  64. owner: ownerDisplayName
  65. },
  66. undefined,
  67. {escape: false}
  68. );
  69. } else if (this.model.getReshareType() === OC.Share.SHARE_TYPE_CIRCLE) {
  70. sharedByText = t(
  71. 'core',
  72. 'Shared with you and {circle} by {owner}',
  73. {
  74. circle: this.model.getReshareWithDisplayName(),
  75. owner: ownerDisplayName
  76. },
  77. undefined,
  78. {escape: false}
  79. );
  80. } else if (this.model.getReshareType() === OC.Share.SHARE_TYPE_ROOM) {
  81. if (this.model.get('reshare').share_with_displayname) {
  82. sharedByText = t(
  83. 'core',
  84. 'Shared with you and the conversation {conversation} by {owner}',
  85. {
  86. conversation: this.model.getReshareWithDisplayName(),
  87. owner: ownerDisplayName
  88. },
  89. undefined,
  90. {escape: false}
  91. );
  92. } else {
  93. sharedByText = t(
  94. 'core',
  95. 'Shared with you in a conversation by {owner}',
  96. {
  97. owner: ownerDisplayName
  98. },
  99. undefined,
  100. {escape: false}
  101. );
  102. }
  103. } else {
  104. sharedByText = t(
  105. 'core',
  106. 'Shared with you by {owner}',
  107. { owner: ownerDisplayName },
  108. undefined,
  109. {escape: false}
  110. );
  111. }
  112. this.$el.html(reshareTemplate({
  113. reshareOwner: this.model.getReshareOwner(),
  114. sharedByText: sharedByText,
  115. shareNote: shareNote,
  116. hasShareNote: shareNote !== ''
  117. }));
  118. this.$el.find('.avatar').each(function() {
  119. var $this = $(this);
  120. $this.avatar($this.data('username'), 32);
  121. });
  122. this.$el.find('.reshare').contactsMenu(
  123. this.model.getReshareOwner(),
  124. OC.Share.SHARE_TYPE_USER,
  125. this.$el);
  126. return this;
  127. },
  128. /**
  129. * @returns {Function} from Handlebars
  130. * @private
  131. */
  132. template: function () {
  133. return OC.Share.Templates['sharedialogresharerinfoview'];
  134. }
  135. });
  136. OC.Share.ShareDialogResharerInfoView = ShareDialogResharerInfoView;
  137. })();