[IMP] Improve code.

bzr revid: ysa@tinyerp.com-20110801114523-xk5jyx2iwn9ptj9n
This commit is contained in:
Yogesh (OpenERP) 2011-08-01 17:15:23 +05:30
parent f8091bb58f
commit 9bdcc4d379
3 changed files with 22 additions and 18 deletions

View File

@ -4,22 +4,22 @@
padding-bottom: 100px; padding-bottom: 100px;
} }
.portlet { .record {
width: 100%; width: 100%;
margin: 0 1em 1em 0; margin: 0 1em 1em 0;
} }
.portlet-header { .record-header {
margin: 0.3em; margin: 0.3em;
padding-bottom: 4px; padding-bottom: 4px;
padding-left: 0.2em; padding-left: 0.2em;
} }
.portlet-header .ui-icon { .record-header .ui-icon {
float: right; float: right;
} }
.portlet-content { .record-content {
padding: 0.4em; padding: 0.4em;
} }

View File

@ -46,25 +46,25 @@ openerp.base_kanban.KanbanView = openerp.base.View.extend({
this.$element.find(".oe_column").sortable({ this.$element.find(".oe_column").sortable({
connectWith: ".oe_column" connectWith: ".oe_column"
}); });
this.$element.find(".portlet").addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all") this.$element.find(".record").addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all")
.find(".portlet-header") .find(".record-header")
.addClass("ui-widget-header ui-corner-all") .addClass("ui-widget-header ui-corner-all")
.prepend( "<span class='ui-icon ui-icon-closethick'></span><span class='ui-icon ui-icon-minusthick'></span>") .prepend( "<span class='ui-icon ui-icon-closethick'></span><span class='ui-icon ui-icon-minusthick'></span>")
.end() .end()
.find( ".portlet-content" ); .find( ".record-content" );
this.$element.find(".portlet-header .ui-icon").click(function() { this.$element.find(".record-header .ui-icon").click(function() {
$(this).toggleClass("ui-icon-minusthick").toggleClass("ui-icon-plusthick"); $(this).toggleClass("ui-icon-minusthick").toggleClass("ui-icon-plusthick");
$(this).parents(".portlet:first").find(".portlet-content").toggle(); $(this).parents(".record:first").find(".record-content").toggle();
}); });
this.$element.find('.portlet .ui-icon-closethick').click(this.on_close_action); this.$element.find('.record .ui-icon-closethick').click(this.on_close_action);
this.$element.find(".oe_column").disableSelection(); this.$element.find(".oe_column").disableSelection();
this.$element.find(".ui.item").css("background-color","#c3dAf9"); this.$element.find(".ui.item").css("background-color","red");
self.$element.find( ".oe_column" ).css("width", 99 / datas.length +"%"); self.$element.find( ".oe_column" ).css("width", 99 / datas.length +"%");
}, },
on_close_action: function(e) { on_close_action: function(e) {
$(e.currentTarget).parents('.portlet:first').remove(); $(e.currentTarget).parents('.record:first').remove();
}, },
do_search: function (domains, contexts, group_by) { do_search: function (domains, contexts, group_by) {
@ -96,11 +96,15 @@ openerp.base_kanban.KanbanView = openerp.base.View.extend({
_.each(datagroups, function (group) { _.each(datagroups, function (group) {
self.dataset.context = group.context; self.dataset.context = group.context;
self.dataset.domain = group.domain; self.dataset.domain = group.domain;
if(!group.value) { var group_name = group.value;
group.value = "Undefined" if(!group_name) {
group_name = "Undefined"
}
else if(group_name instanceof Array) {
group_name = group_name[1]
} }
self.dataset.read_slice(false, false, false, function(records) { self.dataset.read_slice(false, false, false, function(records) {
self.columns.push({"value" : group.value, "records": records}); self.columns.push({"value" : group_name, "records": records});
if (datagroups.length == self.columns.length) { if (datagroups.length == self.columns.length) {
self.on_show_data(self.columns); self.on_show_data(self.columns);
} }

View File

@ -8,9 +8,9 @@
<table><tr><td class="oe_column_heading"><t t-esc="columns.value"/></td></tr></table> <table><tr><td class="oe_column_heading"><t t-esc="columns.value"/></td></tr></table>
</t> </t>
<t t-foreach="columns.records" t-as="record"> <t t-foreach="columns.records" t-as="record">
<div class="portlet" t-att-id="'main_' + record.id"> <div class="record" t-att-id="'main_' + record.id">
<div class="portlet-header" t-att-id="'header_' + record.id"><t t-esc="record.name"/></div> <div class="record-header" t-att-id="'header_' + record.id"><t t-esc="record.name"/></div>
<div class="portlet-content" t-att-id="'data_' + record.id"></div> <div class="record-content" t-att-id="'data_' + record.id"></div>
</div> </div>
</t> </t>
</td> </td>