[IMP]improve code for edit dialog box in manager view.

bzr revid: vme@tinyerp.com-20110920124302-0nxmhgb0u6tomi37
This commit is contained in:
Vidhin Mehta (OpenERP) 2011-09-20 18:13:02 +05:30
parent e34c9b01a5
commit e0724b4c33
3 changed files with 58 additions and 22 deletions

View File

@ -1369,6 +1369,12 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after {
border-color: rgba(0,0,0,0);
border-left-color: #CFCCCC;
}
.openerp .view_editor{
border-bottom: 1px solid #CFCCCC;
.openerp .view_editor{
font-size: 90%;
font-weight: normal;
height : 10%;
padding: 0;
border-bottom: 1px solid #CFCCCC;
}

View File

@ -70,9 +70,14 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({
$(xml).each(function() {
att_list = this.attributes;
att_list = _.select(att_list, function(attrs){
if(attrs.nodeName == "string" || attrs.nodeName == "name" || attrs.nodeName == "index"){
name1 += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';}
});
if (tag != 'button'){
if(attrs.nodeName == "string" || attrs.nodeName == "name" || attrs.nodeName == "index"){
name1 += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';}
}else{
if(attrs.nodeName == "name"){
name1 += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';}
}
});
name1+= ">";
});
obj.name = name1;
@ -138,7 +143,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({
return self.edit_view(one_object);
});
},
edit_view : function(o){
edit_view : function(one_object){
var self = this;
this.dialog = new openerp.web.Dialog(this,{
modal: true,
@ -160,9 +165,23 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({
this.dialog.start().open();
this.dialog.$element.html(QWeb.render('view_editor', {
'data': o,
'data': one_object,
}));
$("tr[id^='viewedit-']").click(function() {
$("tr[id^='viewedit-']").removeClass('ui-selected');
$(this).addClass('ui-selected');
});
$("img[id^='parentimg-']").click(function() {
if ($(this).attr('src') == '/web/static/src/img/collapse.gif'){
$(this).attr('src', '/web/static/src/img/expand.gif');
}else{
$(this).attr('src', '/web/static/src/img/collapse.gif');
}
});
}
});
};

View File

@ -1263,28 +1263,39 @@
</t>
</t>
<t t-name="view_editor">
<table align="left" width= "100%">
<table align="left" width= "100%" >
<t t-call="view_editor.row"/>
</table>
</t>
<t t-name="view_editor.row">
<t t-foreach="data" t-as="rec">
<tr >
<td class= "view_editor"
t-att-style="'background-position: ' + 30*rec.level + 'px; padding-left: ' + 30*rec.level + 'px'">
<img t-if="rec.child_id.length" src="/web/static/src/img/collapse.gif" width="16" height="16" border="0"/>
<t t-esc="rec.name"/>
</td>
</tr >
<tr t-name="view_editor.row" t-att-id="'viewedit-' + rec.id" t-foreach="data" t-as="rec">
<td t-att-id = "rec.id" class="view_editor">
<table>
<tr>
<td width="16px" t-att-style="'background-position: ' + 20*rec.level + 'px; padding-left: ' + 20*rec.level + 'px'">
<img t-if="rec.child_id.length" t-att-id="'parentimg-' + rec.id" src="/web/static/src/img/collapse.gif" width="16" height="16" border="0"/>
</td>
<td style="cursor: pointer;">
<a style="text-decoration:none" href="javascript:void(0);"> <t t-esc="rec.name"/> </a>
</td>
</tr>
</table>
</td>
<td align="left" class="view_editor" style="cursor: pointer;">
<table cellspacing="0" cellpadding ="0" width="100%">
<tr>
<td> <img src="/web/static/src/img/icons/gtk-add.png" border="0"/> </td>
<td> <img src="/web/static/src/img/icons/gtk-remove.png" border="0"/> </td>
<td> <img src="/web/static/src/img/icons/gtk-edit.png" border="0"/> </td>
<td> <img src="/web/static/src/img/icons/gtk-go-up.png" border="0"/> </td>
<td> <img src="/web/static/src/img/icons/gtk-go-down.png" border="0"/> </td>
</tr>
</table>
</td>
<t t-if="rec.child_id.length">
<t t-set="data" t-value="rec.child_id"/>
<t t-call="view_editor.row"/>
</t>
</t>
</t>
</tr>
<t t-name="ExportView">
<a id="exportview" href="javascript: void(0)" style="text-decoration: none;color: #3D3D3D;">Export</a>
</t>