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.

71 lines
2.8 KiB

  1. /**********************************************************************************
  2. *
  3. * Copyright (C) 2017 MuK IT GmbH
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Affero General Public License as
  7. * published by the Free Software Foundation, either version 3 of the
  8. * License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Affero General Public License for more 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_preview.FormRenderer', function (require) {
  20. "use strict";
  21. var core = require('web.core');
  22. var config = require('web.config');
  23. var session = require('web.session');
  24. var pyUtils = require('web.py_utils');
  25. var FormRenderer = require('web.FormRenderer');
  26. FormRenderer.include({
  27. _renderView: function () {
  28. return this._super.apply(this, arguments).then(function () {
  29. if (!this.$previewSidebar || config.device.size_class < config.device.SIZES.XXL) {
  30. this.$el.removeClass("mk_preview_sidebar_active");
  31. } else {
  32. var $sheet = this.$('.o_form_sheet_bg');
  33. this.$previewSidebar.insertAfter($sheet);
  34. if (this.chatter) {
  35. this.chatter.$el.appendTo($sheet);
  36. }
  37. this.$el.addClass("mk_preview_sidebar_active");
  38. }
  39. }.bind(this));
  40. },
  41. _renderNode: function (node) {
  42. if (node.tag === 'div' && node.attrs.class === 'mk_preview_sidebar') {
  43. this.$previewSidebar = $('<div>', {
  44. 'class': 'mk_preview_sidebar',
  45. 'width': this.previewSidebarWidth || '600px',
  46. });
  47. var childs = _.each(node.children, function (child) {
  48. this.$previewSidebar.append(this._renderNode(child));
  49. }, this);
  50. this.$previewSidebar.resizable({
  51. handles: 'w',
  52. minWidth: 400,
  53. maxWidth: 850,
  54. resize: function (event, ui) {
  55. this.previewSidebarWidth = ui.size.width;
  56. }.bind(this),
  57. });
  58. this._handleAttributes(this.$previewSidebar, node);
  59. this._registerModifiers(node, this.state, this.$previewSidebar);
  60. return this.$previewSidebar;
  61. } else {
  62. return this._super.apply(this, arguments);
  63. }
  64. },
  65. });
  66. });