[IMP] move saving a row from per-row buttons to a single global button replacing [Create]
bzr revid: xmo@openerp.com-20120710143228-mqfuaxw894x9khkc
This commit is contained in:
parent
5b6df7ebeb
commit
46da3547ca
|
@ -1999,6 +1999,15 @@
|
||||||
.openerp .oe_form .oe_form_field_many2many > .oe-listview .oe_list_pager_single_page {
|
.openerp .oe_form .oe_form_field_many2many > .oe-listview .oe_list_pager_single_page {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
.openerp .oe_list_buttons .oe_list_save {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.openerp .oe_list_buttons.oe_editing .oe_list_add, .openerp .oe_list_buttons.oe_editing .oe_alternative {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.openerp .oe_list_buttons.oe_editing .oe_list_save {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
.openerp .oe-listview {
|
.openerp .oe-listview {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
@ -2115,20 +2124,6 @@
|
||||||
.openerp .oe-listview-content .numeric input {
|
.openerp .oe-listview-content .numeric input {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
.openerp .oe-listview-content tr.oe_edition th.oe-record-selector {
|
|
||||||
padding: 0 6px;
|
|
||||||
font-size: 1px;
|
|
||||||
letter-spacing: -1px;
|
|
||||||
color: transparent;
|
|
||||||
}
|
|
||||||
.openerp .oe-listview-content tr.oe_edition th.oe-record-selector:before {
|
|
||||||
font: 21px "mnmliconsRegular";
|
|
||||||
content: "S";
|
|
||||||
color: #404040;
|
|
||||||
}
|
|
||||||
.openerp .oe-listview-content tr.oe_edition th.oe-record-selector input {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
.openerp .oe_trad_field.touched {
|
.openerp .oe_trad_field.touched {
|
||||||
border: 1px solid green !important;
|
border: 1px solid green !important;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1587,6 +1587,15 @@ $colour4: #8a89ba
|
||||||
display: none
|
display: none
|
||||||
// }}}
|
// }}}
|
||||||
// ListView {{{
|
// ListView {{{
|
||||||
|
.oe_list_buttons
|
||||||
|
.oe_list_save
|
||||||
|
display: none
|
||||||
|
&.oe_editing
|
||||||
|
.oe_list_add, .oe_alternative
|
||||||
|
display: none
|
||||||
|
.oe_list_save
|
||||||
|
display: inline-block
|
||||||
|
|
||||||
.oe-listview
|
.oe-listview
|
||||||
position: relative
|
position: relative
|
||||||
.oe_form .oe_form_field
|
.oe_form .oe_form_field
|
||||||
|
@ -1666,12 +1675,6 @@ $colour4: #8a89ba
|
||||||
width: 82px
|
width: 82px
|
||||||
input
|
input
|
||||||
text-align: right
|
text-align: right
|
||||||
|
|
||||||
tr.oe_edition th.oe-record-selector
|
|
||||||
padding: 0 6px
|
|
||||||
@include text-to-icon("S")
|
|
||||||
input
|
|
||||||
display: none
|
|
||||||
// }}}
|
// }}}
|
||||||
// Translation {{{
|
// Translation {{{
|
||||||
.oe_trad_field.touched
|
.oe_trad_field.touched
|
||||||
|
|
|
@ -285,7 +285,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
||||||
}
|
}
|
||||||
this.$buttons.find('.oe_list_add')
|
this.$buttons.find('.oe_list_add')
|
||||||
.click(this.proxy('do_add_record'))
|
.click(this.proxy('do_add_record'))
|
||||||
.prop('disabled', grouped && this.options.editable);
|
.prop('disabled', grouped);
|
||||||
this.$buttons.on('click', '.oe_list_button_import', function() {
|
this.$buttons.on('click', '.oe_list_button_import', function() {
|
||||||
self.on_sidebar_import();
|
self.on_sidebar_import();
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -29,7 +29,14 @@ openerp.web.list_editable = function (instance) {
|
||||||
self.configure_pager(self.dataset);
|
self.configure_pager(self.dataset);
|
||||||
self.compute_aggregates();
|
self.compute_aggregates();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
|
this.on('edit:after', this, function () {
|
||||||
|
self.$element.add(self.$buttons).addClass('oe_editing');
|
||||||
|
});
|
||||||
|
this.on('save:after cancel:after', this, function () {
|
||||||
|
self.$element.add(self.$buttons).removeClass('oe_editing');
|
||||||
|
});
|
||||||
},
|
},
|
||||||
destroy: function () {
|
destroy: function () {
|
||||||
instance.web.bus.off('resize', this, this.resizeFields);
|
instance.web.bus.off('resize', this, this.resizeFields);
|
||||||
|
@ -93,6 +100,10 @@ openerp.web.list_editable = function (instance) {
|
||||||
this.options.editable = ! this.options.read_only && (data.arch.attrs.editable || this.options.editable);
|
this.options.editable = ! this.options.read_only && (data.arch.attrs.editable || this.options.editable);
|
||||||
var result = this._super(data, grouped);
|
var result = this._super(data, grouped);
|
||||||
if (this.options.editable) {
|
if (this.options.editable) {
|
||||||
|
// FIXME: any hook available to ensure this is only done once?
|
||||||
|
this.$buttons
|
||||||
|
.off('click', 'button.oe_list_save')
|
||||||
|
.on('click', 'button.oe_list_save', this.proxy('saveEdition'));
|
||||||
// Editor is not restartable due to formview not being
|
// Editor is not restartable due to formview not being
|
||||||
// restartable
|
// restartable
|
||||||
this.editor = this.makeEditor();
|
this.editor = this.makeEditor();
|
||||||
|
@ -498,33 +509,12 @@ openerp.web.list_editable = function (instance) {
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.web.ListView.List.include(/** @lends instance.web.ListView.List# */{
|
instance.web.ListView.List.include(/** @lends instance.web.ListView.List# */{
|
||||||
init: function () {
|
|
||||||
var self = this;
|
|
||||||
this._super.apply(this, arguments);
|
|
||||||
var selection_handler = _.find(this.$_element.data('events').click, function (h) {
|
|
||||||
return h.selector === 'th.oe-record-selector';
|
|
||||||
}).handler;
|
|
||||||
// TODO: cleaner way to do that?
|
|
||||||
this.$_element
|
|
||||||
.off('click', 'th.oe-record-selector')
|
|
||||||
.on('click', '.oe_edition th.oe-record-selector', function (e) {
|
|
||||||
e.stopImmediatePropagation();
|
|
||||||
self.view.saveEdition();
|
|
||||||
})
|
|
||||||
.on('click', 'th.oe-record-selector', selection_handler);
|
|
||||||
},
|
|
||||||
row_clicked: function (event) {
|
row_clicked: function (event) {
|
||||||
if (!this.options.editable) {
|
if (!this.options.editable) {
|
||||||
return this._super.apply(this, arguments);
|
return this._super.apply(this, arguments);
|
||||||
}
|
}
|
||||||
this.edit_record($(event.currentTarget).data('id'));
|
var record_id = $(event.currentTarget).data('id');
|
||||||
},
|
this.view.startEdition(record_id ? this.records.get(record_id) : null);
|
||||||
/**
|
|
||||||
* Edits record currently selected via dataset
|
|
||||||
*/
|
|
||||||
edit_record: function (record_id) {
|
|
||||||
return this.view.startEdition(
|
|
||||||
record_id ? this.records.get(record_id) : null);
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* If a row mapping to the record (@data-id matching the record's id or
|
* If a row mapping to the record (@data-id matching the record's id or
|
||||||
|
|
|
@ -619,7 +619,9 @@
|
||||||
<button type="button" class="oe_button oe_list_add oe_highlight">
|
<button type="button" class="oe_button oe_list_add oe_highlight">
|
||||||
<t t-esc="widget.options.addable"/>
|
<t t-esc="widget.options.addable"/>
|
||||||
</button>
|
</button>
|
||||||
<span class="oe_fade">or</span> <a href="#" class="oe_bold oe_list_button_import">Import</a>
|
<span class="oe_alternative">
|
||||||
|
<span class="oe_fade">or</span> <a href="#" class="oe_bold oe_list_button_import">Import</a>
|
||||||
|
</span>
|
||||||
</t>
|
</t>
|
||||||
</div>
|
</div>
|
||||||
<t t-name="ListView.pager">
|
<t t-name="ListView.pager">
|
||||||
|
@ -663,10 +665,11 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<t t-name="ListView.row.save">
|
<t t-extend="ListView.buttons">
|
||||||
<td>
|
<t t-jquery="button.oe_list_add" t-operation="after">
|
||||||
<button class='oe_i oe-edit-row-save' type='button' name='save'>S</button>
|
<button class="oe_button oe_list_save oe_highlight"
|
||||||
</td>
|
type="button">Save Row</button>
|
||||||
|
</t>
|
||||||
</t>
|
</t>
|
||||||
|
|
||||||
<t t-name="FormView">
|
<t t-name="FormView">
|
||||||
|
|
Loading…
Reference in New Issue