[IMP] improve code and fix problem of show tree structure.
bzr revid: ysa@tinyerp.com-20110714061352-6f47mbow332ats0m
This commit is contained in:
parent
191361eda0
commit
e790623f90
|
@ -29,15 +29,15 @@ openerp.base_export.Export = openerp.base.Dialog.extend({
|
|||
},
|
||||
close: function(event, ui){ self.close();}
|
||||
});
|
||||
jQuery(self.$dialog).find('#add_field').click(function(){
|
||||
$('#add_field').click(function(){
|
||||
for (var key in self.selected_fields) {
|
||||
self.add_field(key, self.selected_fields[key])
|
||||
}
|
||||
});
|
||||
jQuery(self.$dialog).find('#remove_field').click(function(){
|
||||
$('#remove_field').click(function(){
|
||||
jQuery(self.$dialog).find("#fields_list option:selected").remove();
|
||||
});
|
||||
jQuery(self.$dialog).find('#remove_all_field').click(function(){
|
||||
$('#remove_all_field').click(function(){
|
||||
jQuery(self.$dialog).find("#fields_list option").remove();
|
||||
});
|
||||
this.rpc("/base_export/export/get_fields", {"model": this.dataset.model}, this.on_show_data);
|
||||
|
@ -51,11 +51,10 @@ openerp.base_export.Export = openerp.base.Dialog.extend({
|
|||
var name = ''
|
||||
var is_loaded = 0;
|
||||
_.each(result, function(record) {
|
||||
if(record['id'] == self.field_id){
|
||||
if(record['id'] == self.field_id && (record['children']).length >= 1){
|
||||
model = record['params']['model']
|
||||
prefix = record['params']['prefix']
|
||||
name = record['params']['name']
|
||||
if ((record['children']).length >= 1){
|
||||
$(record['children']).each (function(e, childid) {
|
||||
if ($("tr[id='treerow_" + childid +"']").length > 0) {
|
||||
if ($("tr[id='treerow_" + childid +"']").is(':hidden')) {
|
||||
|
@ -79,7 +78,6 @@ openerp.base_export.Export = openerp.base.Dialog.extend({
|
|||
self.showcontent(self.field_id, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
|
@ -92,15 +90,15 @@ openerp.base_export.Export = openerp.base.Dialog.extend({
|
|||
current_tr.after(QWeb.render('ExportTreeView-Secondary', {'fields': result}));
|
||||
}
|
||||
else{
|
||||
jQuery(this.$dialog).find('#left_field_panel').append(QWeb.render('ExportTreeView-Secondary', {'fields': result}));
|
||||
$('#left_field_panel').append(QWeb.render('ExportTreeView-Secondary', {'fields': result}));
|
||||
}
|
||||
jQuery($.find('img[id ^= parentimg]')).click(function(){
|
||||
$('img[id ^= parentimg]').click(function(){
|
||||
self.on_click(this.id, result);
|
||||
});
|
||||
jQuery($.find('[id^=export-]')).dblclick(function(){
|
||||
$('[id^=export-]').dblclick(function(){
|
||||
self.add_field(this.id.split('-')[1], this.text)
|
||||
});
|
||||
jQuery($.find('[id^=export-]')).click(function(){
|
||||
$('[id^=export-]').click(function(){
|
||||
self.on_field_click(this);
|
||||
});
|
||||
|
||||
|
@ -123,7 +121,7 @@ openerp.base_export.Export = openerp.base.Dialog.extend({
|
|||
}
|
||||
});
|
||||
|
||||
jQuery($.find('#fields_list')).mouseover(function(event){
|
||||
$('#fields_list').mouseover(function(event){
|
||||
if(event.relatedTarget){
|
||||
if ('id' in event.relatedTarget.attributes && 'string' in event.relatedTarget.attributes){
|
||||
field_id = event.relatedTarget.attributes["id"]["value"]
|
||||
|
@ -154,14 +152,20 @@ openerp.base_export.Export = openerp.base.Dialog.extend({
|
|||
first_child.attr('src', '/base/static/src/img/collapse.gif');
|
||||
}
|
||||
var child_field = $("tr[id^='treerow_" + id +"/']")
|
||||
var child_len = (id.split("/")).length + 1
|
||||
for (var i = 0; i < child_field.length; i++) {
|
||||
if (flag) {
|
||||
$(child_field[i]).hide();
|
||||
}
|
||||
else {
|
||||
if(child_len == (child_field[i].id.split("/")).length){
|
||||
if( jQuery(child_field[i]).find('img').attr('src') == '/base/static/src/img/collapse.gif'){
|
||||
jQuery(child_field[i]).find('img').attr('src', '/base/static/src/img/expand.gif')
|
||||
}
|
||||
$(child_field[i]).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
add_field: function(field_id, string) {
|
||||
|
|
Loading…
Reference in New Issue