OCA reporting engine fork for dev and update.
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.

52 lines
1.8 KiB

  1. /* Copyright 2015-2018 Onestein (<http://www.onestein.eu>)
  2. * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
  3. odoo.define('bi_view_editor.JoinNodeDialog', function (require) {
  4. "use strict";
  5. var Dialog = require("web.Dialog");
  6. var core = require('web.core');
  7. var qweb = core.qweb;
  8. var _t = core._t;
  9. var JoinNodeDialog = Dialog.extend({
  10. xmlDependencies: Dialog.prototype.xmlDependencies.concat([
  11. '/bi_view_editor/static/src/xml/bi_view_editor.xml'
  12. ]),
  13. events: {
  14. "click li": "choiceClicked"
  15. },
  16. init: function (parent, options, choices, model_data) {
  17. this.choices = choices;
  18. // Prepare data for view
  19. for (var i = 0; i < choices.length; i++) {
  20. if (choices[i].join_node !== -1 && choices[i].table_alias !== -1) {
  21. choices[i].model_name = model_data[choices[i].table_alias].model_name;
  22. }
  23. choices[i].index = i;
  24. }
  25. var defaults = _.defaults(options || {}, {
  26. title: _t("Join..."),
  27. dialogClass: 'oe_act_window',
  28. $content: qweb.render('bi_view_editor.JoinNodeDialog', {
  29. 'choices': choices
  30. }),
  31. buttons: [{
  32. text: _t("Cancel"),
  33. classes: "btn-default o_form_button_cancel",
  34. close: true
  35. }]
  36. });
  37. this._super(parent, defaults);
  38. },
  39. choiceClicked: function (e) {
  40. this.trigger('chosen', {
  41. choice: this.choices[$(e.currentTarget).attr('data-index')]
  42. });
  43. this.close();
  44. }
  45. });
  46. return JoinNodeDialog;
  47. });