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.

75 lines
2.9 KiB

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