Set 'default_rec_name' context key when query default_get

The last searched text is used as default rec_name

issue4136
review30351002
This commit is contained in:
Cédric Krier
2016-08-04 23:57:03 +02:00
parent a7342e10db
commit a077ee95eb
4 changed files with 15 additions and 9 deletions
+8 -4
View File
@@ -161,11 +161,11 @@
}
}
};
array.new_ = function(default_, id) {
array.new_ = function(default_, id, rec_name) {
var record = new Sao.Record(this.model, id);
record.group = this;
if (default_) {
record.default_get();
record.default_get(rec_name);
}
return record;
};
@@ -783,7 +783,7 @@
field_set_client: function(name, value, force_change) {
this.model.fields[name].set_client(this, value, force_change);
},
default_get: function() {
default_get: function(rec_name) {
var dfd = jQuery.Deferred();
var promises = [];
// Ensure promisses is filled before default_get is resolved
@@ -795,8 +795,12 @@
}
}
if (!jQuery.isEmptyObject(this.model.fields)) {
var context = this.get_context();
if (context.default_rec_name === undefined) {
context.default_rec_name = rec_name;
}
var prm = this.model.execute('default_get',
[Object.keys(this.model.fields)], this.get_context());
[Object.keys(this.model.fields)], context);
prm.then(function(values) {
if (this.group.parent &&
this.group.parent_name in this.group.model.fields) {
+2 -2
View File
@@ -1009,7 +1009,7 @@
return this.current_record.id;
}
},
new_: function(default_) {
new_: function(default_, rec_name) {
if (default_ === undefined) {
default_ = true;
}
@@ -1027,7 +1027,7 @@
} else {
group = this.group;
}
var record = group.new_(default_);
var record = group.new_(default_, undefined, rec_name);
group.add(record, this.new_model_position());
this.set_current_record(record);
this.display().done(function() {
+4 -2
View File
@@ -1790,7 +1790,8 @@
var win = new Sao.Window.Form(screen, callback.bind(this), {
new_: true,
save_current: true,
title: this.attributes.string
title: this.attributes.string,
rec_name: this.entry.val()
});
},
key_press: function(event_) {
@@ -2774,7 +2775,8 @@
new Sao.Window.Form(screen, callback, {
'new_': true,
'save_current': true,
title: this.attributes.string
title: this.attributes.string,
rec_name: this.entry.val()
});
});
}
+1 -1
View File
@@ -68,7 +68,7 @@
var switch_prm = form_prm.then(function() {
return this.screen.switch_view(view_type).done(function() {
if (kwargs.new_) {
this.screen.new_();
this.screen.new_(undefined, kwargs.rec_name);
}
}.bind(this));
}.bind(this));