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.

54 lines
1.7 KiB

7 years ago
6 years ago
7 years ago
  1. /*******************************************************************************
  2. *
  3. * Copyright (C) 2017 MuK IT GmbH
  4. *
  5. * This program is free software: you can redistribute it and/or modify it under
  6. * the terms of the GNU Affero General Public License as published by the Free
  7. * Software Foundation, either version 3 of the License, or (at your option) any
  8. * later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12. * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  13. * details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. ******************************************************************************/
  19. odoo.define('muk_web_share.button', function(require) {
  20. "use strict";
  21. var core = require('web.core');
  22. var FormRenderer = require('web.FormRenderer');
  23. var ShareDialog = require('muk_web_share.dialog');
  24. var QWeb = core.qweb;
  25. var _t = core._t;
  26. FormRenderer.include({
  27. _renderShareButton: function() {
  28. var $sharebutton = $('<div>');
  29. $sharebutton.addClass("muk_share_button");
  30. $sharebutton.append($('<button>').addClass("btn btn-primary")
  31. .append($('<i class="fa fa-share-alt"/>')));
  32. $sharebutton.on('click', _.bind(this._clickShareButton, this));
  33. this.$el.find('.o_form_sheet').append($sharebutton);
  34. },
  35. _clickShareButton: function() {
  36. new ShareDialog.share(this);
  37. },
  38. _renderView: function() {
  39. var self = this;
  40. var _super = this._super.apply(this, arguments);
  41. _super.then(function() {
  42. if(self.mode === 'readonly') {
  43. self._renderShareButton();
  44. }
  45. });
  46. return _super;
  47. },
  48. });
  49. });