[FIX] view manager: effectively take into account the
> selected view. bzr revid: tde@openerp.com-20140217120453-oen4xfbkngemnrab
This commit is contained in:
parent
15a1aef33c
commit
f9838a6032
|
@ -15,7 +15,7 @@ instance.web.ViewManagerAction.include({
|
||||||
}
|
}
|
||||||
evt.currentTarget.selectedIndex = 0;
|
evt.currentTarget.selectedIndex = 0;
|
||||||
}else{
|
}else{
|
||||||
return this._super.apply(this,arguments);
|
return this._super.apply(this,arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -73,12 +73,10 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({
|
||||||
$.when(this.action_manager.do_action(action)).done(function() {
|
$.when(this.action_manager.do_action(action)).done(function() {
|
||||||
var viewmanager = self.action_manager.inner_widget;
|
var viewmanager = self.action_manager.inner_widget;
|
||||||
var controller = viewmanager.views[viewmanager.active_view].controller;
|
var controller = viewmanager.views[viewmanager.active_view].controller;
|
||||||
controller.on('view_loaded', self, function(){
|
$(controller.groups).bind({
|
||||||
$(controller.groups).bind({
|
'selected': function (e, ids, records, deselected) {
|
||||||
'selected': function(e, ids, records) {
|
|
||||||
self.main_view_id = ids[0];
|
self.main_view_id = ids[0];
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -232,10 +230,11 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({
|
||||||
return main_object;
|
return main_object;
|
||||||
},
|
},
|
||||||
parse_xml: function(arch, view_id) {
|
parse_xml: function(arch, view_id) {
|
||||||
|
//First element of att_list must be element tagname.
|
||||||
main_object = {
|
main_object = {
|
||||||
'level': 0,
|
'level': 0,
|
||||||
'id': this.xml_element_id +=1,
|
'id': this.xml_element_id +=1,
|
||||||
'att_list': [],
|
'att_list': ["view"],
|
||||||
'name': _.str.sprintf("<view view_id = %s>", view_id),
|
'name': _.str.sprintf("<view view_id = %s>", view_id),
|
||||||
'child_id': []
|
'child_id': []
|
||||||
};
|
};
|
||||||
|
@ -535,15 +534,22 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({
|
||||||
var field_dataset = new instance.web.DataSetSearch(this, this.model, null, null);
|
var field_dataset = new instance.web.DataSetSearch(this, this.model, null, null);
|
||||||
parent_tr = self.get_object_by_id(parseInt($(parent_tr).attr('id').replace(/[^0-9]+/g, '')), this.one_object['main_object'], [])[0].att_list[0];
|
parent_tr = self.get_object_by_id(parseInt($(parent_tr).attr('id').replace(/[^0-9]+/g, '')), this.one_object['main_object'], [])[0].att_list[0];
|
||||||
_.each([tr, parent_tr],function(element) {
|
_.each([tr, parent_tr],function(element) {
|
||||||
var value = _.has(_CHILDREN, element) ? element : _.str.include(html_tag, element)?"html_tag":false;
|
var value = _.has(_CHILDREN, element) ? element : _.str.include(html_tag, element)?"html_tag":false;
|
||||||
property_to_check.push(value);
|
property_to_check.push(value);
|
||||||
});
|
});
|
||||||
field_dataset.call( 'fields_get', []).done(function(result) {
|
field_dataset.call( 'fields_get', []).done(function(result) {
|
||||||
var fields = _.keys(result);
|
var fields = _.keys(result);
|
||||||
fields.push(" "),fields.sort();
|
fields.push(" "),fields.sort();
|
||||||
self.on_add_node(property_to_check, fields);
|
self.on_add_node(property_to_check, fields, self.inject_position(parent_tr,tr));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
inject_position : function(parent_tag,current_tag){
|
||||||
|
if(parent_tag == "view")
|
||||||
|
return ['Inside'];
|
||||||
|
if(current_tag == "field")
|
||||||
|
return ['After','Before'];
|
||||||
|
return ['After','Before','Inside'];
|
||||||
|
},
|
||||||
do_node_edit: function(side) {
|
do_node_edit: function(side) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var result = self.get_object_by_id(this.one_object.clicked_tr_id, this.one_object['main_object'], []);
|
var result = self.get_object_by_id(this.one_object.clicked_tr_id, this.one_object['main_object'], []);
|
||||||
|
@ -637,12 +643,12 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({
|
||||||
var children = _.filter(xml_arch.childNodes[0].childNodes, function (child) {
|
var children = _.filter(xml_arch.childNodes[0].childNodes, function (child) {
|
||||||
return child.nodeType == 1;
|
return child.nodeType == 1;
|
||||||
});
|
});
|
||||||
arch.arch = _.detect(children, function(xml_child) {
|
var inherited_view = _.detect(children, function(xml_child) {
|
||||||
var temp_obj = self.create_View_Node(xml_child),
|
var temp_obj = self.create_View_Node(xml_child),
|
||||||
insert = _.intersection(_.flatten(temp_obj.att_list),_.uniq(check_list));
|
insert = _.intersection(_.flatten(temp_obj.att_list),_.uniq(check_list));
|
||||||
if (insert.length == _.uniq(check_list).length ) {return xml_child;}
|
if (insert.length == _.uniq(check_list).length ) {return xml_child;}
|
||||||
});
|
});
|
||||||
xml_arch = QWeb.load_xml(arch.arch);
|
xml_arch = QWeb.load_xml(instance.web.xml_to_str(inherited_view));
|
||||||
}
|
}
|
||||||
return self.do_save_xml(xml_arch.documentElement, obj[0].child_id[0],obj[0].child_id, move_direct, update_values,arch);
|
return self.do_save_xml(xml_arch.documentElement, obj[0].child_id[0],obj[0].child_id, move_direct, update_values,arch);
|
||||||
},
|
},
|
||||||
|
@ -941,11 +947,11 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({
|
||||||
});
|
});
|
||||||
return def.promise();
|
return def.promise();
|
||||||
},
|
},
|
||||||
on_add_node: function(properties, fields){
|
on_add_node: function(properties, fields, position){
|
||||||
var self = this;
|
var self = this;
|
||||||
var render_list = [{'name': 'node_type','selection': _.keys(_CHILDREN).sort(), 'value': 'field', 'string': 'Node Type','type': 'selection'},
|
var render_list = [{'name': 'node_type','selection': _.keys(_CHILDREN).sort(), 'value': 'field', 'string': 'Node Type','type': 'selection'},
|
||||||
{'name': 'field_value','selection': fields, 'value': false, 'string': '','type': 'selection'},
|
{'name': 'field_value','selection': fields, 'value': false, 'string': '','type': 'selection'},
|
||||||
{'name': 'position','selection': ['After','Before','Inside'], 'value': false, 'string': 'Position','type': 'selection'}];
|
{'name': 'position','selection': position, 'value': false, 'string': 'Position','type': 'selection'}];
|
||||||
this.add_widget = [];
|
this.add_widget = [];
|
||||||
this.add_node_dialog = new instance.web.Dialog(this,{
|
this.add_node_dialog = new instance.web.Dialog(this,{
|
||||||
title: _t("Properties"),
|
title: _t("Properties"),
|
||||||
|
@ -1186,7 +1192,7 @@ var _CHILDREN = {
|
||||||
//e.g.:xyz 'td' : ['field']
|
//e.g.:xyz 'td' : ['field']
|
||||||
};
|
};
|
||||||
// Generic html_tag list and can be added html tag in future. It's support above _CHILDREN dict's *html_tag* by default.
|
// Generic html_tag list and can be added html tag in future. It's support above _CHILDREN dict's *html_tag* by default.
|
||||||
// For specific child node one has to define tag above and specify children tag in list. Like above xyz example.
|
// For specific child node one has to define tag above and specify children tag in list. Like above xyz example.
|
||||||
var html_tag = ['div','h1','h2','h3','h4','h5','h6','td','tr'];
|
var html_tag = ['div','h1','h2','h3','h4','h5','h6','td','tr'];
|
||||||
|
|
||||||
var _ICONS = ['','STOCK_ABOUT', 'STOCK_ADD', 'STOCK_APPLY', 'STOCK_BOLD',
|
var _ICONS = ['','STOCK_ABOUT', 'STOCK_ADD', 'STOCK_APPLY', 'STOCK_BOLD',
|
||||||
|
|
Loading…
Reference in New Issue