mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[13.0][MIG] bi_view_editor
This commit is contained in:
@@ -159,11 +159,6 @@
|
||||
width: 175px;
|
||||
}
|
||||
|
||||
.oe_form_field_bi_editor .context-menu .checkbox {
|
||||
margin-top: 0px;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.oe_form_field_bi_editor .context-menu .checkbox label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@@ -7,28 +7,32 @@ odoo.define("bi_view_editor.FieldList", function(require) {
|
||||
var core = require("web.core");
|
||||
var qweb = core.qweb;
|
||||
var Widget = require("web.Widget");
|
||||
var mixins = require("web.mixins");
|
||||
|
||||
var FieldListContextMenu = Widget.extend({
|
||||
start: function() {
|
||||
var res = this._super.apply(this, arguments);
|
||||
this.$el.mouseleave(function() {
|
||||
$(this).addClass("d-none");
|
||||
});
|
||||
return res;
|
||||
},
|
||||
open: function(x, y) {
|
||||
this.$el.css({
|
||||
left: x + "px",
|
||||
top: y + "px",
|
||||
});
|
||||
this.$el.removeClass("d-none");
|
||||
return _.extend({}, window.Backbone.Events);
|
||||
},
|
||||
});
|
||||
var FieldListContextMenu = Widget.extend(
|
||||
_.extend({}, mixins.EventDispatcherMixin, {
|
||||
start: function() {
|
||||
var res = this._super.apply(this, arguments);
|
||||
this.$el.mouseleave(function() {
|
||||
$(this).addClass("d-none");
|
||||
});
|
||||
return res;
|
||||
},
|
||||
open: function(x, y) {
|
||||
this.$el.css({
|
||||
left: x + "px",
|
||||
top: y + "px",
|
||||
});
|
||||
this.$el.removeClass("d-none");
|
||||
return this;
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
var FieldListFieldContextMenu = FieldListContextMenu.extend({
|
||||
template: "bi_view_editor.FieldList.FieldContextMenu",
|
||||
open: function(x, y, field) {
|
||||
open: function(x, y, $item) {
|
||||
var field = $item.data("field");
|
||||
this.$el.find(".checkbox-column").prop("checked", field.column);
|
||||
this.$el.find(".checkbox-row").prop("checked", field.row);
|
||||
this.$el.find(".checkbox-measure").prop("checked", field.measure);
|
||||
@@ -49,7 +53,7 @@ odoo.define("bi_view_editor.FieldList", function(require) {
|
||||
var $checkbox = $(this);
|
||||
var property = $checkbox.attr("data-for");
|
||||
field[property] = $checkbox.is(":checked");
|
||||
events.trigger("change", field);
|
||||
events.trigger("change", field, $item);
|
||||
});
|
||||
|
||||
return events;
|
||||
@@ -58,7 +62,8 @@ odoo.define("bi_view_editor.FieldList", function(require) {
|
||||
|
||||
var FieldListJoinContextMenu = FieldListContextMenu.extend({
|
||||
template: "bi_view_editor.FieldList.JoinContextMenu",
|
||||
open: function(x, y, node) {
|
||||
open: function(x, y, $item) {
|
||||
var node = $item.data("field");
|
||||
this.$el.find(".checkbox-join-left").prop("checked", node.join_left);
|
||||
|
||||
var events = this._super(x, y, node);
|
||||
@@ -83,8 +88,26 @@ odoo.define("bi_view_editor.FieldList", function(require) {
|
||||
var res = this._super.apply(this, arguments);
|
||||
this.contextmenu = new FieldListFieldContextMenu(this);
|
||||
this.contextmenu.appendTo(this.$el);
|
||||
this.contextmenu.on(
|
||||
"change",
|
||||
this,
|
||||
function(f, $item) {
|
||||
$item.data("field", f);
|
||||
this.refreshItem($item);
|
||||
this.trigger("updated");
|
||||
}.bind(this)
|
||||
);
|
||||
this.contextmenu_join = new FieldListJoinContextMenu(this);
|
||||
this.contextmenu_join.appendTo(this.$el);
|
||||
this.contextmenu_join.on(
|
||||
"change",
|
||||
this,
|
||||
function(f, $item) {
|
||||
$item.data("field", f);
|
||||
this.refreshItem($item);
|
||||
this.trigger("updated");
|
||||
}.bind(this)
|
||||
);
|
||||
this.$table = this.$el.find("tbody");
|
||||
this.mode = null;
|
||||
return res;
|
||||
@@ -201,14 +224,7 @@ odoo.define("bi_view_editor.FieldList", function(require) {
|
||||
if (field.join_node) {
|
||||
return;
|
||||
}
|
||||
contextmenu.open(x - 20, y - 20, $item.data("field")).on(
|
||||
"change",
|
||||
function(f) {
|
||||
$item.data("field", f);
|
||||
this.refreshItem($item);
|
||||
this.trigger("updated");
|
||||
}.bind(this)
|
||||
);
|
||||
contextmenu.open(x - 20, y - 20, $item);
|
||||
},
|
||||
refreshItem: function($item) {
|
||||
var data = $item.data("field");
|
||||
|
||||
@@ -80,7 +80,7 @@ odoo.define("bi_view_editor.ModelList", function(require) {
|
||||
self.$el.find(".class-list").append($html);
|
||||
|
||||
if (self.isActive(model.id)) {
|
||||
self.loadFields(model.id).done(function(fields) {
|
||||
self.loadFields(model.id).then(function(fields) {
|
||||
self.populateFields(fields, model.id);
|
||||
});
|
||||
}
|
||||
@@ -129,7 +129,7 @@ odoo.define("bi_view_editor.ModelList", function(require) {
|
||||
this.removeAsActive(model.id);
|
||||
} else {
|
||||
this.addAsActive(model.id);
|
||||
this.loadFields(model.id).done(
|
||||
this.loadFields(model.id).then(
|
||||
function(fields) {
|
||||
this.populateFields(fields, model.id);
|
||||
}.bind(this)
|
||||
|
||||
@@ -30,24 +30,27 @@ odoo.define("bi_view_editor", function(require) {
|
||||
|
||||
// Init FieldList
|
||||
this.field_list = new FieldList(this);
|
||||
this.field_list.appendTo(this.$(".body > .right"));
|
||||
this.field_list.on("removed", this, this.fieldListRemoved);
|
||||
this.field_list.on("updated", this, this.fieldListChanged);
|
||||
this.field_list.appendTo(this.$(".body > .right")).then(
|
||||
function() {
|
||||
this.field_list.on("removed", this, this.fieldListRemoved);
|
||||
this.field_list.on("updated", this, this.fieldListChanged);
|
||||
this.$el.find(".body > .right").droppable({
|
||||
accept: "div.class-list div.field",
|
||||
drop: function(event, ui) {
|
||||
self.addField(_.extend({}, ui.draggable.data("field")));
|
||||
ui.draggable.draggable("option", "revert", false);
|
||||
},
|
||||
});
|
||||
|
||||
this.$el.find(".body > .right").droppable({
|
||||
accept: "div.class-list div.field",
|
||||
drop: function(event, ui) {
|
||||
self.addField(_.extend({}, ui.draggable.data("field")));
|
||||
ui.draggable.draggable("option", "revert", false);
|
||||
},
|
||||
});
|
||||
this.on("change:effective_readonly", this, function() {
|
||||
this.updateMode();
|
||||
});
|
||||
this.renderValue();
|
||||
this.loadAndPopulateModelList();
|
||||
this.updateMode();
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
this.on("change:effective_readonly", this, function() {
|
||||
this.updateMode();
|
||||
});
|
||||
this.renderValue();
|
||||
this.loadAndPopulateModelList();
|
||||
this.updateMode();
|
||||
return res;
|
||||
},
|
||||
clear: function() {
|
||||
@@ -61,10 +64,9 @@ odoo.define("bi_view_editor", function(require) {
|
||||
this._setValue(this.field_list.get());
|
||||
},
|
||||
fieldListRemoved: function() {
|
||||
console.log(this.field_list.get());
|
||||
this._setValue(this.field_list.get());
|
||||
var model = new Data.DataSet(this, "bve.view");
|
||||
model.call("get_clean_list", [this.value]).then(
|
||||
model.call("get_clean_list", [this.lastSetValue]).then(
|
||||
function(result) {
|
||||
this.field_list.set(JSON.parse(result));
|
||||
this._setValue(this.field_list.get());
|
||||
@@ -91,7 +93,7 @@ odoo.define("bi_view_editor", function(require) {
|
||||
if (this.field_list.get().length > 0) {
|
||||
model_ids = this.field_list.getModelIds();
|
||||
}
|
||||
this.model_list.loadModels(model_ids).done(
|
||||
this.model_list.loadModels(model_ids).then(
|
||||
function(models) {
|
||||
this.model_list.populateModels(models);
|
||||
}.bind(this)
|
||||
|
||||
@@ -116,22 +116,20 @@
|
||||
<li>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input
|
||||
<input
|
||||
type="checkbox"
|
||||
data-for="column"
|
||||
class="checkbox-column"
|
||||
/> Column
|
||||
</label>
|
||||
/>
|
||||
<span>Column</span>
|
||||
</label>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
data-for="row"
|
||||
class="checkbox-row"
|
||||
/> Row
|
||||
<input type="checkbox" data-for="row" class="checkbox-row" />
|
||||
<span>Row</span>
|
||||
</label>
|
||||
</div>
|
||||
</li>
|
||||
@@ -142,18 +140,16 @@
|
||||
type="checkbox"
|
||||
data-for="measure"
|
||||
class="checkbox-measure"
|
||||
/> Measure
|
||||
/>
|
||||
<span>Measure</span>
|
||||
</label>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
data-for="list"
|
||||
class="checkbox-list"
|
||||
/> List
|
||||
<input type="checkbox" data-for="list" class="checkbox-list" />
|
||||
<span>List</span>
|
||||
</label>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user