listview refactor part1
bzr revid: al@openerp.com-20120409193509-l6kps8m5k78wn1nn
This commit is contained in:
parent
9da88bbd76
commit
518d4ccfb6
|
@ -103,7 +103,6 @@ openerp.web.FormView = openerp.web.View.extend({
|
|||
this.has_been_loaded.resolve();
|
||||
return $.when();
|
||||
},
|
||||
|
||||
do_load_state: function(state, warm) {
|
||||
if (state.id && this.datarecord.id != state.id) {
|
||||
if (!this.dataset.get_id_index(state.id)) {
|
||||
|
@ -115,9 +114,13 @@ openerp.web.FormView = openerp.web.View.extend({
|
|||
}
|
||||
}
|
||||
},
|
||||
|
||||
do_show: function () {
|
||||
var self = this;
|
||||
if (this.sidebar) {
|
||||
this.sidebar.$element.show();
|
||||
}
|
||||
this.$buttons.find('.oe_form_buttons').show();
|
||||
this.$pager.find('.oe_form_pager').show();
|
||||
this.$element.show().css('visibility', 'hidden');
|
||||
this.$element.removeClass('oe_form_dirty');
|
||||
return this.has_been_loaded.pipe(function() {
|
||||
|
@ -137,6 +140,11 @@ openerp.web.FormView = openerp.web.View.extend({
|
|||
});
|
||||
},
|
||||
do_hide: function () {
|
||||
if (this.sidebar) {
|
||||
this.sidebar.$element.hide();
|
||||
}
|
||||
this.$buttons.find('.oe_form_buttons').hide();
|
||||
this.$pager.find('.oe_form_pager').hide();
|
||||
this._super();
|
||||
},
|
||||
on_record_loaded: function(record) {
|
||||
|
|
|
@ -207,6 +207,7 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
|
|||
|
||||
this.$element.html(QWeb.render(this._template, this));
|
||||
// Head hook
|
||||
// Selecting records
|
||||
this.$element.find('.all-record-selector').click(function(){
|
||||
self.$element.find('.oe-record-selector input').prop('checked',
|
||||
self.$element.find('.all-record-selector').prop('checked') || false);
|
||||
|
@ -215,28 +216,24 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
|
|||
'selected', [selection.ids, selection.records]);
|
||||
});
|
||||
|
||||
this.$element.find('.oe-list-add')
|
||||
.click(this.proxy('do_add_record'))
|
||||
.attr('disabled', grouped && this.options.editable);
|
||||
this.$element.find('.oe-list-delete')
|
||||
.attr('disabled', true)
|
||||
.click(this.proxy('do_delete_selected'));
|
||||
// Sorting columns
|
||||
this.$element.find('thead').delegate('th.oe-sortable[data-id]', 'click', function (e) {
|
||||
e.stopPropagation();
|
||||
|
||||
var $this = $(this);
|
||||
self.dataset.sort($this.data('id'));
|
||||
if ($this.find('span').length) {
|
||||
$this.find('span').toggleClass(
|
||||
'ui-icon-triangle-1-s ui-icon-triangle-1-n');
|
||||
$this.find('span').toggleClass( 'ui-icon-triangle-1-s ui-icon-triangle-1-n');
|
||||
} else {
|
||||
$this.append('<span class="ui-icon ui-icon-triangle-1-n">')
|
||||
.siblings('.oe-sortable').find('span').remove();
|
||||
$this.append('<span class="ui-icon ui-icon-triangle-1-n">') .siblings('.oe-sortable').find('span').remove();
|
||||
}
|
||||
|
||||
self.reload_content();
|
||||
});
|
||||
|
||||
// Add and delete
|
||||
this.$element.find('.oe-list-add') .click(this.proxy('do_add_record')) .attr('disabled', grouped && this.options.editable);
|
||||
this.$element.find('.oe-list-delete') .attr('disabled', true) .click(this.proxy('do_delete_selected'));
|
||||
|
||||
this.$element.find('.oe-list-pager')
|
||||
.delegate('button', 'click', function () {
|
||||
var $this = $(this);
|
||||
|
@ -274,11 +271,11 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
|
|||
})
|
||||
.val(self._limit || 'NaN');
|
||||
});
|
||||
if (!this.sidebar && this.options.sidebar && this.options.sidebar_id) {
|
||||
//this.sidebar = new openerp.web.Sidebar(this, this.options.sidebar_id);
|
||||
//this.sidebar.start();
|
||||
//this.sidebar.add_toolbar(this.fields_view.toolbar);
|
||||
//this.set_common_sidebar_sections(this.sidebar);
|
||||
|
||||
if (!this.sidebar && this.options.sidebar && this.options.$sidebar) {
|
||||
this.sidebar = new openerp.web.Sidebar(this);
|
||||
this.sidebar.appendTo(this.options.$sidebar);
|
||||
this.sidebar.add_toolbar(this.fields_view.toolbar);
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
@ -421,7 +418,6 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
|
|||
do_hide: function () {
|
||||
this._super();
|
||||
if (this.sidebar) {
|
||||
this.sidebar.$element.hide();
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
@ -546,13 +542,17 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
|
|||
this.$element.find('.oe-list-delete').attr('disabled', !ids.length);
|
||||
if (!ids.length) {
|
||||
this.dataset.index = 0;
|
||||
if (this.sidebar) { this.sidebar.do_fold(); }
|
||||
if (this.sidebar) {
|
||||
this.sidebar.$element.hide();
|
||||
}
|
||||
this.compute_aggregates();
|
||||
return;
|
||||
}
|
||||
|
||||
this.dataset.index = _(this.dataset.ids).indexOf(ids[0]);
|
||||
if (this.sidebar) { this.sidebar.do_unfold(); }
|
||||
if (this.sidebar) {
|
||||
this.sidebar.$element.show();
|
||||
}
|
||||
|
||||
this.compute_aggregates(_(records).map(function (record) {
|
||||
return {count: 1, values: record};
|
||||
|
|
|
@ -559,21 +559,9 @@
|
|||
<thead class="ui-widget-header">
|
||||
<tr t-if="options.action_buttons !== false or options.pager !== false">
|
||||
<th t-att-colspan="columns_count">
|
||||
<table>
|
||||
<tr>
|
||||
<td t-if="!no_leaf and options.action_buttons !== false" class="oe-actions">
|
||||
<button type="button" class="oe_button oe-list-add"
|
||||
t-if="options.addable">
|
||||
<t t-esc="options.addable"/>
|
||||
</button>
|
||||
<button type="button" class="oe_button oe-list-delete"
|
||||
t-if="options.selectable and options.deletable">
|
||||
Delete
|
||||
</button>
|
||||
</td>
|
||||
<t t-call="Listview.navigation.button"/>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="oe_list_buttons"/>
|
||||
<div class="oe_list_sidebar"/>
|
||||
<div class="oe_list_pager"/>
|
||||
</th>
|
||||
</tr>
|
||||
<tr t-if="options.header" class="oe-listview-header-columns">
|
||||
|
@ -583,13 +571,13 @@
|
|||
</th>
|
||||
</t>
|
||||
<th t-if="options.selectable" width="1" >
|
||||
<input type="checkbox" class="all-record-selector"/> </th>
|
||||
<th t-if="options.isClarkGable" width="1"> </th>
|
||||
<input type="checkbox" class="all-record-selector"/>
|
||||
</th>
|
||||
<th t-if="options.isClarkGable" width="1"></th>
|
||||
<t t-foreach="columns" t-as="column">
|
||||
<th t-if="!column.meta and column.invisible !== '1'" t-att-data-id="column.id"
|
||||
t-att-class="((options.sortable and column.tag !== 'button') ? 'oe-sortable' : null)">
|
||||
<t t-if="column.tag !== 'button'"
|
||||
><t t-esc="column.string"/></t>
|
||||
<t t-if="column.tag !== 'button'"><t t-esc="column.string"/></t>
|
||||
</th>
|
||||
</t>
|
||||
<th t-if="options.deletable" width="1"/>
|
||||
|
@ -604,32 +592,26 @@
|
|||
</td>
|
||||
<td t-if="options.deletable"/>
|
||||
</tr>
|
||||
<tr>
|
||||
<t t-call="Listview.navigation.button"/>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<t t-extend="ListView" t-name="One2Many.listview">
|
||||
<t t-jquery="thead.ui-widget-header > tr:first">
|
||||
this.removeAttr('t-if');
|
||||
</t>
|
||||
|
||||
<t t-jquery="tfoot > tr:last-child" t-operation="replace"/>
|
||||
|
||||
<t t-jquery="td.oe-actions">
|
||||
this.removeAttr('t-if');
|
||||
</t>
|
||||
<t t-jquery="td.oe-actions" t-operation="prepend">
|
||||
<h3 class="oe_view_title"><t t-esc="fields_view.arch.attrs.string"/></h3>
|
||||
</t>
|
||||
<t t-name="ListView.buttons">
|
||||
<div t-if="!no_leaf and options.action_buttons !== false" class="oe_list_buttons">
|
||||
<button type="button" class="oe_button oe-list-add" t-if="options.addable">
|
||||
<t t-esc="options.addable"/>
|
||||
</button>
|
||||
<button type="button" class="oe_button oe-list-delete" t-if="options.selectable and options.deletable">
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
</t>
|
||||
<t t-name="Listview.pager">
|
||||
<div t-if="!no_leaf and options.pager !== false" class="oe-list-pager" t-att-colspan="columns_count">
|
||||
<t t-call="ViewPager">
|
||||
<span class="oe-pager-state">
|
||||
</span>
|
||||
</t>
|
||||
</div>
|
||||
</t>
|
||||
<th t-name="Listview.navigation.button" t-if="!no_leaf and options.pager !== false"
|
||||
class="oe-list-pager" t-att-colspan="columns_count">
|
||||
<t t-call="ViewPager">
|
||||
<span class="oe-pager-state">
|
||||
</span>
|
||||
</t>
|
||||
</th>
|
||||
<t t-name="ListView.rows" t-foreach="records.length" t-as="index">
|
||||
<t t-call="ListView.row">
|
||||
<t t-set="record" t-value="records.at(index)"/>
|
||||
|
@ -1293,6 +1275,20 @@
|
|||
<button type="button" class="oe_button oe_form_button_create">Add</button>
|
||||
</t>
|
||||
</t>
|
||||
<t t-name="One2Many.listview" t-extend="ListView">
|
||||
<t t-jquery="thead.ui-widget-header > tr:first">
|
||||
this.removeAttr('t-if');
|
||||
</t>
|
||||
|
||||
<t t-jquery="tfoot > tr:last-child" t-operation="replace"/>
|
||||
|
||||
<t t-jquery="td.oe-actions">
|
||||
this.removeAttr('t-if');
|
||||
</t>
|
||||
<t t-jquery="td.oe-actions" t-operation="prepend">
|
||||
<h3 class="oe_view_title"><t t-esc="fields_view.arch.attrs.string"/></h3>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
<div t-name="SearchView" class="oe_searchview">
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue