[FIX] Fixed button image position, limit of list and show more every time.
bzr revid: nicolas.vanhoren@openerp.com-20110516070956-63u36dkygncatr7c
This commit is contained in:
parent
f959208232
commit
28290faf6d
|
@ -827,10 +827,11 @@ body.openerp {
|
|||
|
||||
/* Many2one Autosearch */
|
||||
.openerp .ui_combo {
|
||||
height: 20px;
|
||||
margin-right: 1px;
|
||||
top: 4px;
|
||||
width: 22px;
|
||||
height: 19px;
|
||||
top: 6px;
|
||||
width: 20px;
|
||||
position: relative;
|
||||
margin-left: -26px;
|
||||
}
|
||||
/* ------------- End autocomplete ------- */
|
||||
/*------------- End autocomplete ------- */
|
||||
|
||||
|
|
|
@ -7,12 +7,13 @@ openerp.base.m2o = function(openerp){
|
|||
this.view_manager = view_manager
|
||||
this.session = session;
|
||||
this.element = element_id.find('input');
|
||||
this.button = element_id.find('div');
|
||||
this.dataset = dataset;
|
||||
var cache = {};
|
||||
var lastXhr;
|
||||
this.relation = model;
|
||||
this.result_ids = []
|
||||
var self = this
|
||||
this.result_ids = [];
|
||||
var self = this;
|
||||
|
||||
var $input = this.element.autocomplete({
|
||||
|
||||
|
@ -24,10 +25,10 @@ openerp.base.m2o = function(openerp){
|
|||
}
|
||||
//pass request to server
|
||||
lastXhr = self.dataset.name_search(search_val, function(obj, status, xhr){
|
||||
var result = obj.result
|
||||
var result = obj.result;
|
||||
var values = [];
|
||||
if (!result.length) {
|
||||
values.push({'value': 'Create...', id: 'create'})
|
||||
values.push({'value': 'Create...', id: 'create', orig_val: ''});
|
||||
}
|
||||
|
||||
$.each(result, function(i, val){
|
||||
|
@ -36,14 +37,13 @@ openerp.base.m2o = function(openerp){
|
|||
id: val[0],
|
||||
orig_val: val[1]
|
||||
});
|
||||
self.result_ids.push(result[i][0])
|
||||
self.result_ids.push(result[i][0]);
|
||||
});
|
||||
|
||||
if (values.length > 10) {
|
||||
values = values.slice(0, 10);
|
||||
values.push({'value': 'More...', id: 'more'})
|
||||
if (values.length > 7) {
|
||||
values = values.slice(0, 7);
|
||||
}
|
||||
//process response
|
||||
values.push({'value': 'More...', id: 'more', orig_val:''});
|
||||
cache[search_val] = values;
|
||||
response(values);
|
||||
});
|
||||
|
@ -51,19 +51,19 @@ openerp.base.m2o = function(openerp){
|
|||
},
|
||||
|
||||
select: function(event, ui){
|
||||
ui.item.value = ui.item.orig_val? ui.item.orig_val : self.element.data( "autocomplete" ).term
|
||||
ui.item.value = ui.item.orig_val? ui.item.orig_val : self.element.data( "autocomplete" ).term;
|
||||
if (ui.item.id == 'more') {
|
||||
self.dataset.ids = self.result_ids;
|
||||
self.dataset.count = self.dataset.ids.length;
|
||||
self.dataset.domain = []
|
||||
self.element.val('')
|
||||
self.dataset.domain = [];
|
||||
self.element.val('');
|
||||
var pop = new openerp.base.form.Many2XSelectPopup(null, self.session);
|
||||
pop.select_element(self.relation, self.dataset);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ui.item.id == 'create') {
|
||||
var val = self.element.val()
|
||||
var val = self.element.val();
|
||||
self.dataset.create({'name': ui.item.value},
|
||||
function(r){}, function(r){
|
||||
var element_id = _.uniqueId("act_window_dialog");
|
||||
|
@ -73,7 +73,7 @@ openerp.base.m2o = function(openerp){
|
|||
modal: true,
|
||||
minWidth: 800
|
||||
});
|
||||
self.element.val('')
|
||||
self.element.val('');
|
||||
var event_form = new openerp.base.FormView(self.view_manager, self.session, element_id, self.dataset, false);
|
||||
event_form.start();
|
||||
});
|
||||
|
@ -89,33 +89,26 @@ openerp.base.m2o = function(openerp){
|
|||
if (ui.item.id == ('create')) {
|
||||
return true;
|
||||
}
|
||||
ui.item.value = self.element.data("autocomplete").term.length ? self.element.val() + '[' + ui.item.orig_val.substring(self.element.data("autocomplete").term.length) + ']' : this.lastSearch
|
||||
ui.item.value = self.element.data("autocomplete").term.length ? self.element.val() + '[' + ui.item.orig_val.substring(self.element.data("autocomplete").term.length) + ']' : this.lastSearch;
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
$("<div type='button' class='ui_combo'> </div>")
|
||||
.attr("tabIndex", -1)
|
||||
.attr("title", "Show All Items")
|
||||
.insertAfter($input)
|
||||
.button({
|
||||
icons: {
|
||||
primary: "ui-icon-triangle-1-s"
|
||||
},
|
||||
text: false
|
||||
})
|
||||
.removeClass("ui-corner-all")
|
||||
.addClass("ui-corner-right ui-button-icon")
|
||||
.click(function() {
|
||||
// close if already visible
|
||||
if ($input.autocomplete("widget").is(":visible")) {
|
||||
$input.autocomplete( "close" );
|
||||
return;
|
||||
}
|
||||
$(this).blur();
|
||||
$input.autocomplete("search", "" );
|
||||
$input.focus();
|
||||
});
|
||||
this.button.button({
|
||||
icons: {
|
||||
primary: "ui-icon-triangle-1-s"},
|
||||
text: false
|
||||
})
|
||||
.click(function() {
|
||||
// close if already visible
|
||||
if ($input.autocomplete("widget").is(":visible")) {
|
||||
$input.autocomplete( "close" );
|
||||
return;
|
||||
}
|
||||
$(this).blur();
|
||||
$input.autocomplete("search", "" );
|
||||
$input.focus();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
|
@ -350,9 +350,9 @@
|
|||
t-att-name="widget.name"
|
||||
t-att-id="widget.element_id + '_field'"
|
||||
t-att-class="'field_' + widget.type"
|
||||
t-att-type="widget.type"
|
||||
t-att-type="widget.type"
|
||||
style="width: 100%;"/>
|
||||
|
||||
<div type='button' class='ui_combo' tabindex="'-1'" title="'Show All Items'"></div>
|
||||
</t>
|
||||
<t t-name="FieldOne2Many">
|
||||
<div t-att-id="widget.element_id">
|
||||
|
|
Loading…
Reference in New Issue