@ -85,12 +85,10 @@ openerp.bi_view_editor = function (instance, local) {
if ( this . $el . find ( ".field-list tbody tr" ) . length > 0 ) {
model . call ( "get_related_models" , [ this . get_model_ids ( ) ] , { context : new instance . web . CompoundContext ( ) } ) . then ( function ( result ) {
self . show_classes ( result ) ;
//if(scrollTo) self.$el.find('.class-list').scrollTo('#bve-class-' + scrollTo.model_id);
} ) ;
} else {
model . call ( "get_models" , { context : new instance . web . CompoundContext ( ) } ) . then ( function ( result ) {
self . show_classes ( result ) ;
//if(scrollTo) self.$el.find('.class-list').scrollTo('#bve-class-' + scrollTo.model_id);
} ) ;
}
} ,
@ -99,10 +97,10 @@ openerp.bi_view_editor = function (instance, local) {
var model = new instance . web . Model ( "ir.model" ) ;
self . $el . find ( ".class-list .class" ) . remove ( ) ;
self . $el . find ( ".class-list .field" ) . remove ( ) ;
var css = this . get ( 'effective_readonly' ) ? 'cursor: default' : 'cursor: pointer'
var css = this . get ( 'effective_readonly' ) ? 'cursor: default' : 'cursor: pointer' ;
for ( var i = 0 ; i < result . length ; i ++ ) {
var item = $ ( "<div style=\"" + css + "\" class=\"class\" title=\"" + result [ i ] [ "model" ] + "\" id=\"bve-class-" + result [ i ] [ "id" ] + "\">" + result [ i ] [ "name" ] + "</div>" )
var item = $ ( "<div style=\"" + css + "\" class=\"class\" title=\"" + result [ i ] . model + "\" id=\"bve-class-" + result [ i ] . id + "\">" + result [ i ] . name + "</div>" )
. data ( 'model-data' , result [ i ] )
. click ( function ( evt ) {
if ( self . get ( "effective_readonly" ) ) return ;
@ -117,9 +115,9 @@ openerp.bi_view_editor = function (instance, local) {
self . activeModelMenus . push ( classel . data ( 'model-data' ) . id ) ;
model . call ( "get_fields" , [ classel . data ( 'model-data' ) . id ] , { context : new instance . web . CompoundContext ( ) } ) . then ( function ( result ) {
for ( var i = 0 ; i < result . length ; i ++ ) {
classel . find ( "#bve-field-" + result [ i ] [ "name" ] ) . remove ( ) ;
classel . find ( "#bve-field-" + result [ i ] . name ) . remove ( ) ;
if ( self . $el . find ( ".field-list tbody [name=label-" + result [ i ] . id + "]" ) . length > 0 ) continue ;
classel . after ( $ ( "<div class=\"field\" title=\"" + result [ i ] [ "name" ] + "\" id=\"bve-field-" + result [ i ] [ "name" ] + "\">" + result [ i ] [ "description" ] + "</div>" )
classel . after ( $ ( "<div class=\"field\" title=\"" + result [ i ] . name + "\" id=\"bve-field-" + result [ i ] . name + "\">" + result [ i ] . description + "</div>" )
. data ( 'field-data' , result [ i ] )
. click ( function ( ) {
if ( ! self . get ( "effective_readonly" ) ) {
@ -150,7 +148,7 @@ openerp.bi_view_editor = function (instance, local) {
var item = self . $el . find ( ".class-list #bve-class-" + result [ 0 ] . model_id ) ;
for ( var o = 0 ; o < result . length ; o ++ ) {
if ( self . $el . find ( ".field-list tbody [name=label-" + result [ o ] . id + "]" ) . length > 0 ) continue ;
item . after ( $ ( "<div class=\"field\" title=\"" + result [ o ] [ "name" ] + "\" id=\"bve-field-" + result [ o ] [ "name" ] + "\">" + result [ o ] [ "description" ] + "</div>" )
item . after ( $ ( "<div class=\"field\" title=\"" + result [ o ] . name + "\" id=\"bve-field-" + result [ o ] . name + "\">" + result [ o ] . description + "</div>" )
. data ( 'field-data' , result [ o ] )
. click ( function ( ) {
if ( ! self . get ( "effective_readonly" ) ) {
@ -277,8 +275,8 @@ openerp.bi_view_editor = function (instance, local) {
$ ( document ) . mouseup ( function ( e ) {
var container = $ ( ".context-menu" ) ;
if ( ! container . is ( e . target ) // if the target of the click isn't the container...
&& container . has ( e . target ) . length === 0 ) // ... nor a descendant of the container
// if the target of the click isn't the container nor a descendant of the container
if ( ! container . is ( e . target ) && container . has ( e . target ) . length === 0 )
{
container . hide ( ) ;
}
@ -294,7 +292,7 @@ openerp.bi_view_editor = function (instance, local) {
self . internal_set_value ( JSON . stringify ( self . get_fields ( ) ) ) ;
self . load_classes ( ) ;
return false ;
} )
} ) ;
} ,
clean_join_nodes : function ( ) {
var aliases = $ . makeArray ( this . $el . find ( ".field-list tbody tr" ) . map ( function ( idx , el ) {
@ -359,8 +357,7 @@ openerp.bi_view_editor = function (instance, local) {
var field_data = this . get_fields ( ) ;
var self = this ;
model . call ( 'get_join_nodes' , [ field_data , data ] , { context : new instance . web . CompoundContext ( ) } ) . then ( function ( result ) {
//self.$el.find(".search-bar").val("");
//self.filter("");
if ( result . length == 1 ) {
self . add_field_and_join_node ( data , result [ 0 ] ) ;
self . internal_set_value ( JSON . stringify ( self . get_fields ( ) ) ) ;
@ -417,9 +414,9 @@ openerp.bi_view_editor = function (instance, local) {
description = "Use the field on table " + model_data [ choices [ i ] . table_alias ] . model_name ;
} else {
if ( choices [ i ] . join_node == - 1 ) {
description = "Join using the field '" + choices [ i ] [ 'description' ] + "' from model '" + choices [ i ] [ 'model_name' ] + "'" ;
description = "Join using the field '" + choices [ i ] . description + "' from model '" + choices [ i ] . model_name + "'" ;
} else {
description = "Join using the field '" + choices [ i ] [ 'description' ] + "' from new model '" + choices [ i ] [ 'model_name' ] + "'" ;
description = "Join using the field '" + choices [ i ] . description + "' from new model '" + choices [ i ] . model_name + "'" ;
}
}
joinnodes . append ( $ ( "<a>" + description + "</a>" )
@ -437,12 +434,8 @@ openerp.bi_view_editor = function (instance, local) {
joinnodes . find ( 'a' ) . click ( function ( ) {
callback ( callback_data , choices [ $ ( this ) . data ( 'idx' ) ] ) ;
dialog . close ( ) ;
} )
} ) ;
//dialog.on('closing', this, function (e){
// self.check_exit(true);
//});
//this.$buttonpane = dialog.$buttons;
this . start ( ) ;
}
} ) ;