You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sharetabview.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. /* @global Handlebars */
  11. (function() {
  12. var TEMPLATE =
  13. '<div>' +
  14. '<div class="dialogContainer"></div>' +
  15. '</div>';
  16. /**
  17. * @memberof OCA.Sharing
  18. */
  19. var ShareTabView = OCA.Files.DetailTabView.extend(
  20. /** @lends OCA.Sharing.ShareTabView.prototype */ {
  21. id: 'shareTabView',
  22. className: 'tab shareTabView',
  23. template: function(params) {
  24. if (!this._template) {
  25. this._template = Handlebars.compile(TEMPLATE);
  26. }
  27. return this._template(params);
  28. },
  29. getLabel: function() {
  30. return t('files_sharing', 'Sharing');
  31. },
  32. /**
  33. * Renders this details view
  34. */
  35. render: function() {
  36. var self = this;
  37. if (this._dialog) {
  38. // remove/destroy older instance
  39. this._dialog.model.off();
  40. this._dialog.remove();
  41. this._dialog = null;
  42. }
  43. if (this.model) {
  44. this.$el.html(this.template());
  45. if (_.isUndefined(this.model.get('sharePermissions'))) {
  46. this.model.set('sharePermissions', OCA.Sharing.Util.getSharePermissions(this.model.attributes));
  47. }
  48. // TODO: the model should read these directly off the passed fileInfoModel
  49. var attributes = {
  50. itemType: this.model.isDirectory() ? 'folder' : 'file',
  51. itemSource: this.model.get('id'),
  52. possiblePermissions: this.model.get('sharePermissions')
  53. };
  54. var configModel = new OC.Share.ShareConfigModel();
  55. var shareModel = new OC.Share.ShareItemModel(attributes, {
  56. configModel: configModel,
  57. fileInfoModel: this.model
  58. });
  59. this._dialog = new OC.Share.ShareDialogView({
  60. configModel: configModel,
  61. model: shareModel
  62. });
  63. this.$el.find('.dialogContainer').append(this._dialog.$el);
  64. this._dialog.render();
  65. this._dialog.model.fetch();
  66. this._dialog.model.on('change', function() {
  67. self.trigger('sharesChanged', shareModel);
  68. });
  69. } else {
  70. this.$el.empty();
  71. // TODO: render placeholder text?
  72. }
  73. }
  74. });
  75. OCA.Sharing.ShareTabView = ShareTabView;
  76. })();