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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 id="collaborationResources"></div>'
  16. + '</div>'
  17. /**
  18. * @memberof OCA.Sharing
  19. */
  20. var ShareTabView = OCA.Files.DetailTabView.extend(
  21. /** @lends OCA.Sharing.ShareTabView.prototype */ {
  22. id: 'shareTabView',
  23. className: 'tab shareTabView',
  24. initialize: function(name, options) {
  25. OCA.Files.DetailTabView.prototype.initialize.call(this, name, options)
  26. OC.Plugins.attach('OCA.Sharing.ShareTabView', this)
  27. },
  28. template: function(params) {
  29. return TEMPLATE
  30. },
  31. getLabel: function() {
  32. return t('files_sharing', 'Sharing')
  33. },
  34. getIcon: function() {
  35. return 'icon-shared'
  36. },
  37. /**
  38. * Renders this details view
  39. */
  40. render: function() {
  41. var self = this
  42. if (this._dialog) {
  43. // remove/destroy older instance
  44. this._dialog.model.off()
  45. this._dialog.remove()
  46. this._dialog = null
  47. }
  48. if (this.model) {
  49. this.$el.html(this.template())
  50. if (_.isUndefined(this.model.get('sharePermissions'))) {
  51. this.model.set('sharePermissions', OCA.Sharing.Util.getSharePermissions(this.model.attributes))
  52. }
  53. // TODO: the model should read these directly off the passed fileInfoModel
  54. var attributes = {
  55. itemType: this.model.isDirectory() ? 'folder' : 'file',
  56. itemSource: this.model.get('id'),
  57. possiblePermissions: this.model.get('sharePermissions')
  58. }
  59. var configModel = new OC.Share.ShareConfigModel()
  60. var shareModel = new OC.Share.ShareItemModel(attributes, {
  61. configModel: configModel,
  62. fileInfoModel: this.model
  63. })
  64. this._dialog = new OC.Share.ShareDialogView({
  65. configModel: configModel,
  66. model: shareModel
  67. })
  68. this.$el.find('.dialogContainer').append(this._dialog.$el)
  69. this._dialog.render()
  70. this._dialog.model.fetch()
  71. this._dialog.model.on('change', function() {
  72. self.trigger('sharesChanged', shareModel)
  73. })
  74. import('./collaborationresources').then((Resources) => {
  75. var vm = new Resources.Vue({
  76. el: '#collaborationResources',
  77. render: h => h(Resources.View),
  78. data: {
  79. model: this.model.toJSON()
  80. }
  81. })
  82. this.model.on('change', () => { vm.data = this.model.toJSON() })
  83. })
  84. } else {
  85. this.$el.empty()
  86. // TODO: render placeholder text?
  87. }
  88. this.trigger('rendered')
  89. }
  90. })
  91. OCA.Sharing.ShareTabView = ShareTabView
  92. })()