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.

72 lines
2.9 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.$previewSidebar && this.$previewSidebar.hasClass('o_invisible_modifier'))) {
  31. this.$el.removeClass("mk_preview_sidebar_active");
  32. } else {
  33. var $sheet = this.$('.o_form_sheet_bg');
  34. this.$previewSidebar.insertAfter($sheet);
  35. if (this.chatter) {
  36. this.chatter.$el.appendTo($sheet);
  37. this.chatterPositionChanged = true;
  38. }
  39. this.$el.addClass("mk_preview_sidebar_active");
  40. }
  41. }.bind(this));
  42. },
  43. _renderNode: function (node) {
  44. if (node.tag === 'div' && node.attrs.class === 'mk_preview_sidebar') {
  45. this.$previewSidebar = $('<div>', {
  46. 'class': 'mk_preview_sidebar',
  47. 'width': this.previewSidebarWidth || '600px',
  48. });
  49. var childs = _.each(node.children, function (child) {
  50. this.$previewSidebar.append(this._renderNode(child));
  51. }, this);
  52. this.$previewSidebar.resizable({
  53. handles: 'w',
  54. minWidth: 400,
  55. maxWidth: 850,
  56. resize: function (event, ui) {
  57. this.previewSidebarWidth = ui.size.width;
  58. }.bind(this),
  59. });
  60. this._handleAttributes(this.$previewSidebar, node);
  61. this._registerModifiers(node, this.state, this.$previewSidebar);
  62. return this.$previewSidebar;
  63. } else {
  64. return this._super.apply(this, arguments);
  65. }
  66. },
  67. });
  68. });