vidhin mehta[Open Erp] has proposed merging
lp:~openerp-dev/openerp-web/trunk-vieweditor-vme into
lp:~openerp-dev/openerp-web/trunk-vieweditor-sma.
Requested reviews:
OpenERP R&D Team (openerp-dev)
For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-vieweditor-vme/+merge/77107
removed unnecessary code.
--
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-vieweditor-vme/+merge/77107
Your team OpenERP R&D Team is requested to review the proposed merge of
lp:~openerp-dev/openerp-web/trunk-vieweditor-vme into
lp:~openerp-dev/openerp-web/trunk-vieweditor-sma.
=== modified file 'addons/web/static/src/js/view_editor.js'
--- addons/web/static/src/js/view_editor.js 2011-09-22 09:45:13 +0000
+++ addons/web/static/src/js/view_editor.js 2011-09-27 07:26:23 +0000
@@ -67,9 +67,11 @@
obj.level = level;
var att_list = [];
var name1 = "<" + tag;
+ var xml_tag = "<" + tag;
$(xml).each(function() {
att_list = this.attributes;
att_list = _.select(att_list, function(attrs){
+ xml_tag += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';
if (tag != 'button'){
if(attrs.nodeName == "string" || attrs.nodeName == "name" || attrs.nodeName == "index"){
name1 += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';}
@@ -79,7 +81,9 @@
}
});
name1+= ">";
+ xml_tag+= ">";
});
+ obj.main_xml = xml_tag;
obj.name = name1;
return obj;
},
@@ -116,7 +120,6 @@
var string = self.check_attr(child_node,child_node.tagName.toLowerCase(),parents.length);
child_obj_list.push(string);
});
-
if(children_list.length != 0){
var child_ids = _.map(child_obj_list ,function(num){return num.id;});
parent_child_id.push({'key': parent_id, 'value': child_ids});
@@ -134,18 +137,28 @@
}
return {"main_object":main_object,"parent_child_id":parent_child_id};
},
+ parse_xml :function(arch){
+ var self = this;
+ var root = $(arch).filter(":first")[0];
+ var tag = root.tagName.toLowerCase();
+ var root_object = self.check_attr(root,tag,0);
+ return self.children_function(arch,tag,[],0,[root_object],[]);
+ },
get_data : function(){
var self = this;
+ var inherited_view =[];
+ var result;
var view_id =(($("input[name='radiogroup']:checked").parent()).parent()).attr('data-id');
var ve_dataset = new openerp.web.DataSet(this,'ir.ui.view');
+ dataset = new openerp.web.DataSetSearch(self,'ir.ui.view', null, null);
+ dataset.read_slice([],{domain : [['inherit_id','=',parseInt(view_id)]]},function (result) {
+ return result;
+ });
ve_dataset.read_ids([parseInt(view_id)],['arch'],function (arch){
- var arch = arch[0].arch;
- var root = $(arch).filter(":first")[0];
- var tag = root.tagName.toLowerCase();
- var root_object = self.check_attr(root,tag,0);
- var one_object = self.children_function(arch,tag,[],0,[root_object],[]);
- return self.edit_view(one_object);
- });
+ var one_object = self.parse_xml(arch[0].arch);
+ return self.edit_view(one_object);
+ });
+
},
edit_view : function(one_object){
var self = this;
@@ -186,7 +199,8 @@
}
});
$("img[id^='side-']").click(function() {
- var side = $(this).closest("'tr[id^='viewedit-']'");
+ var side = $(this).closest("tr[id^='viewedit-']")
+ var id_tr = (side.attr('id')).split('-')[1];
switch (this.id)
{
case "side-add":
@@ -196,15 +210,74 @@
case "side-edit":
break;
case "side-up":
- if(side.prev().attr('level') == side.attr('level')){
- console.log();
- $(side.prev()).before(side);
+ var img = side.find("img[id='parentimg-"+id_tr+"']").attr('src');
+ var level = side.attr('level');
+ var list_shift =[];
+ var last_tr;
+ var next_tr;
+ list_shift.push(side);
+ var cur_tr = side;
+ while(1){
+ var prev_tr = cur_tr.prev();
+ if(level >= prev_tr.attr('level') || prev_tr.length==0){
+ last_tr = prev_tr;
+ break;
+ }
+ cur_tr = prev_tr;
+ }
+ if(img){
+ while(1){
+ var next_tr = side.next();
+ if(next_tr.attr('level') <= level || next_tr.length==0){
+ break;
+ }else{
+ list_shift.push(next_tr);
+ side = next_tr;
+ }
+ }
+ }
+ if(last_tr.length!=0 && last_tr.attr('level') == level){
+ _.each(list_shift,function(rec){
+ $(last_tr).before(rec);
+ });
}
break;
case "side-down":
- if(side.next().attr('level') == side.attr('level')){
- var v = side.next().next().attr('level')
- $(side.next()).after(side);
+ var img = side.find("img[id='parentimg-"+id_tr+"']").attr('src');
+ var level = side.attr('level');
+ var list_shift =[];
+ var last_tr;
+ var next_tr;
+ var cur_tr = side;
+ list_shift.push(side);
+ if(img){
+ while(1){
+ var next_tr = cur_tr.next();
+ if(next_tr.attr('level') <= level || next_tr.length==0){
+ last_tr = next_tr;
+ break;
+ }else{
+ list_shift.push(next_tr);
+ cur_tr = next_tr;
+ }
+ }
+ }else{last_tr = cur_tr.next();}
+ if(last_tr.length != 0 && last_tr.attr('level')==level){
+ var last_tr_id = (last_tr.attr('id')).split('-')[1];
+ img = last_tr.find("img[id='parentimg-"+last_tr_id+"']").attr('src');
+ if(img){
+ $("img[id='parentimg-"+last_tr_id+"']").attr('src', '/web/static/src/img/expand.gif');
+ while(1){
+ var next_tr = last_tr.next();
+ if (next_tr.attr('level') <= level || next_tr.length==0){break;}
+ next_tr.hide();
+ last_tr = next_tr;
+ }
+ }
+ list_shift.reverse();
+ _.each(list_shift,function(rec){
+ $(last_tr).after(rec);
+ });
}
break;
}
@@ -218,10 +291,10 @@
if (nxt_tr.attr('level') > level){
cur_tr = nxt_tr;
nxt_tr.hide();
- }else break;
+ }else return nxt_tr;
}
},
- on_collapse: function(self,parent_child_id){
+ on_collapse: function(self,parent_child_id,id){
var id = self.id.split('-')[1];
var datas = _.detect(parent_child_id,function(res){
return res.key == id;
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp