[IMP]implement css and collapse all functionality.

bzr revid: vme@tinyerp.com-20120702121927-wbg5pncvw4qo8cni
This commit is contained in:
Vidhin Mehta (OpenERP) 2012-07-02 17:49:27 +05:30
parent 871cb1ac24
commit 9e952c3fba
4 changed files with 115 additions and 15 deletions

View File

@ -2215,6 +2215,56 @@
color: #333333;
}
.openerp .tree_header {
background-color: #f0f0f0;
border-bottom: 1px solid #cacaca;
color: #4c4c4c;
padding: 5px;
}
.openerp .tree_header button {
float: right;
}
.openerp .oe-treeview-table {
width: 100%;
background-color: white;
border-spacing: 0;
}
.openerp .oe-treeview-table th {
padding: 10px;
color: #4c4c4c;
font-weight: bold;
background-color: #f0f0f0;
border-bottom: 2px solid #cacaca;
}
.openerp .oe-treeview-table .treeview-tr, .openerp .oe-treeview-table .treeview-td {
cursor: pointer;
border-right: 1px dotted #afafb6;
vertical-align: top;
text-align: left;
border-bottom: 1px solid #cfcccc;
}
.openerp .oe-treeview-table tr:hover {
background-color: #e0e0f8;
}
.openerp .oe-treeview-table .oe-number {
text-align: right !important;
}
.openerp .oe-treeview-table span {
font-size: 90%;
font-weight: normal;
white-space: nowrap;
display: block;
}
.openerp .oe-treeview-table .treeview-tr.oe-treeview-first {
background: transparent url(/web/static/src/img/expand.gif) 0 50% no-repeat;
}
.openerp .oe-treeview-table .oe_open .treeview-tr.oe-treeview-first {
background-image: url(/web/static/src/img/collapse.gif);
}
.openerp .oe-treeview-table .treeview-tr.oe-treeview-first span, .openerp .oe-treeview-table .treeview-td.oe-treeview-first span {
margin-left: 16px;
}
.kitten-mode-activated {
background-image: url(http://placekitten.com/g/1365/769);
background-size: cover;

View File

@ -1747,6 +1747,46 @@ $colour4: #8a89ba
float: right
color: #333
// }}}
//Tree view
.openerp
.tree_header
background-color: #f0f0f0
border-bottom: 1px solid #cacaca
color: #4c4c4c
padding: 5px
button
float: right
.oe-treeview-table
width: 100%
background-color: white
border-spacing: 0
th
padding: 10px
color: #4c4c4c
font-weight: bold
background-color: #f0f0f0
border-bottom: 2px solid #cacaca
.treeview-tr, .treeview-td
cursor: pointer
border-right: 1px dotted #afafb6
vertical-align: top
text-align: left
border-bottom: 1px solid #cfcccc
tr:hover
background-color: #e0e0f8
.oe-number
text-align: right !important
span
font-size: 90%
font-weight: normal
white-space: nowrap
display: block
.treeview-tr.oe-treeview-first
background: transparent url(/web/static/src/img/expand.gif) 0 50% no-repeat
.oe_open .treeview-tr.oe-treeview-first
background-image: url(/web/static/src/img/collapse.gif)
.treeview-tr.oe-treeview-first span, .treeview-td.oe-treeview-first span
margin-left: 16px
// Kitten Mode {{{
.kitten-mode-activated
background-image: url(http://placekitten.com/g/1365/769)

View File

@ -112,7 +112,12 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
$select.change();
}
});
this.$element.find("#tree_view_expand").click(function(){
self.expand_all();
});
this.$element.find("#tree_view_collapse").click(function(){
self.collpase_all();
});
// TODO store open nodes in url ?...
this.do_push_state({});
@ -128,6 +133,17 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
return [color, py.parse(py.tokenize(expr)), expr];
}).value();
},
expand_all: function(){
},
collpase_all: function(){
var self = this;
var root_tr = this.$element.find(".oe-treeview-table tbody tr[data-level='"+1+"']");
_.each(root_tr,function(rec){
if($(rec).hasClass('oe_open')){
self.showcontent($(rec).attr('data-id'),false);
}
});
},
/**
* Returns the color for the provided record in the current view (from the
* ``@colors`` attribute)
@ -259,13 +275,5 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
}, this);
},
do_show: function () {
this.$element.show();
},
do_hide: function () {
this.$element.hide();
this.hidden = true;
}
});
};

View File

@ -535,14 +535,16 @@
</t>
<t t-name="TreeView">
<select t-if="toolbar" style="width: 30%">
</select>
<table class="oe_tree_table">
<div class = "tree_header">
<select t-if="toolbar" ></select>
<button id = "tree_view_collapse">Collapse All</button>
<button id = "tree_view_expand">Expand All</button>
</div>
<table class="oe-treeview-table">
<thead>
<tr>
<th t-foreach="fields_view" t-as="field"
t-if="!field.attrs.modifiers.tree_invisible"
class="treeview-header">
t-if="!field.attrs.modifiers.tree_invisible">
<t t-esc="fields[field.attrs.name].string" />
</th>
</tr>
@ -557,7 +559,7 @@
t-att-data-id="record.id" t-att-data-level="level + 1">
<t t-set="children" t-value="record[children_field]"/>
<t t-set="class" t-value="children and children.length ? 'treeview-tr' : 'treeview-td'"/>
<t t-set="rank" t-value="'oe_tree_first'"/>
<t t-set="rank" t-value="'oe-treeview-first'"/>
<t t-set="style" t-value="'background-position: ' + 19*level + 'px; padding-left: ' + 19*level + 'px;'"/>
<td t-foreach="fields_view" t-as="field"