merge.
This commit is contained in:
commit
14fd420767
3 files changed
+196
-38
No files matched your search
+46
-27
@@ -381,32 +381,6 @@
|
||||
loading = (this.model.fields[name].description.loading ||
|
||||
'eager');
|
||||
}
|
||||
if (~this.group.indexOf(this) && (loading == 'eager')) {
|
||||
var idx = this.group.indexOf(this);
|
||||
var length = this.group.length;
|
||||
var n = 1;
|
||||
while (Object.keys(id2record).length &&
|
||||
((idx - n >= 0) || (idx + n < length)) &&
|
||||
n < 100) {
|
||||
var record;
|
||||
if (idx - n >= 0) {
|
||||
record = this.group[idx - n];
|
||||
if (!(name in record._loaded) &&
|
||||
(record.id >= 0)) {
|
||||
id2record[record.id] = record;
|
||||
}
|
||||
}
|
||||
if (idx + n < length) {
|
||||
record = this.group[idx + n];
|
||||
if (!(name in record._loaded) &&
|
||||
(record.id >= 0)) {
|
||||
id2record[record.id] = record;
|
||||
}
|
||||
}
|
||||
n++;
|
||||
}
|
||||
}
|
||||
var context = jQuery.extend({}, this.get_context());
|
||||
var fnames = [];
|
||||
if (loading == 'eager') {
|
||||
for (fname in this.model.fields) {
|
||||
@@ -436,6 +410,48 @@
|
||||
fnames_to_fetch.push('rec_name');
|
||||
}
|
||||
fnames_to_fetch.push('_timestamp');
|
||||
|
||||
var context = jQuery.extend({}, this.get_context());
|
||||
if (loading == 'eager') {
|
||||
var limit = 1000; // TODO use config
|
||||
if (!this.group.parent) {
|
||||
// If not a children no need to load too much
|
||||
limit = parseInt(limit / fnames_to_fetch.length, 10);
|
||||
}
|
||||
|
||||
var filter_group = function(record) {
|
||||
return !(name in record._loaded) && (record.id >= 0);
|
||||
};
|
||||
// TODO pool
|
||||
[[this.group, filter_group]].forEach(function(e) {
|
||||
var group = e[0];
|
||||
var filter = e[1];
|
||||
var idx = this.group.indexOf(this);
|
||||
if (~idx) {
|
||||
var length = group.length;
|
||||
var n = 1;
|
||||
while (Object.keys(id2record).length &&
|
||||
((idx - n >= 0) || (idx + n < length)) &&
|
||||
(n < 2 * limit)) {
|
||||
var record;
|
||||
if (idx - n >= 0) {
|
||||
record = group[idx - n];
|
||||
if (filter(record)) {
|
||||
id2record[record.id] = record;
|
||||
}
|
||||
}
|
||||
if (idx + n < length) {
|
||||
record = group[idx + n];
|
||||
if (filter(record)) {
|
||||
id2record[record.id] = record;
|
||||
}
|
||||
}
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
for (fname in this.model.fields) {
|
||||
if (!this.model.fields.hasOwnProperty(fname)) {
|
||||
continue;
|
||||
@@ -456,7 +472,7 @@
|
||||
if (!id2record.hasOwnProperty(id)) {
|
||||
continue;
|
||||
}
|
||||
record = id2record[id];
|
||||
var record = id2record[id];
|
||||
// TODO exception
|
||||
var value = id2value[id];
|
||||
if (record && value) {
|
||||
@@ -1210,6 +1226,9 @@
|
||||
_default: null,
|
||||
get: function(record) {
|
||||
var value = record._values[this.name];
|
||||
if (value === undefined) {
|
||||
value = this._default;
|
||||
}
|
||||
// TODO force parent
|
||||
return value;
|
||||
},
|
||||
|
||||
+3
-1
@@ -1595,6 +1595,7 @@
|
||||
type: 'input'
|
||||
});
|
||||
// TODO add completion
|
||||
this.menu.append(this.wid_text);
|
||||
|
||||
this.but_add = jQuery('<button/>').button({
|
||||
icons: {
|
||||
@@ -1742,6 +1743,7 @@
|
||||
if (!access.write || !access.read) {
|
||||
return;
|
||||
}
|
||||
// TODO
|
||||
},
|
||||
remove: function(event_) {
|
||||
var access = Sao.common.MODELACCESS.get(this.screen.model_name);
|
||||
@@ -2076,7 +2078,7 @@
|
||||
},
|
||||
display: function(record, field) {
|
||||
Sao.View.Form.Binary._super.display.call(this, record, field);
|
||||
if (field === undefined) {
|
||||
if (!field) {
|
||||
this.size.val('');
|
||||
if (this.filename) {
|
||||
this.but_open.button('disable');
|
||||
|
||||
+147
-10
@@ -37,18 +37,25 @@
|
||||
this.callback = callback;
|
||||
this.el = jQuery('<div/>');
|
||||
|
||||
if (view_type == 'tree') {
|
||||
// TODO
|
||||
}
|
||||
|
||||
var buttons = [];
|
||||
buttons.push({
|
||||
text: 'Cancel',
|
||||
text: (!kwargs.new_ && this.screen.current_view &&
|
||||
this.screen.current_record.id < 0 ?
|
||||
'Delete' : 'Cancel'),
|
||||
click: function() {
|
||||
this.response('RESPONSE_CANCEL');
|
||||
}.bind(this)
|
||||
});
|
||||
|
||||
if (kwargs.new_ && this.many) {
|
||||
buttons.push({
|
||||
text: 'New',
|
||||
click: function() {
|
||||
this.response('RESPONSE_ACCEPT');
|
||||
}.bind(this)
|
||||
});
|
||||
}
|
||||
|
||||
if (this.save_current) {
|
||||
buttons.push({
|
||||
text: 'Save',
|
||||
@@ -65,24 +72,144 @@
|
||||
});
|
||||
}
|
||||
|
||||
var menu;
|
||||
if (view_type == 'tree') {
|
||||
menu = jQuery('<div/>');
|
||||
var access = Sao.common.MODELACCESS.get(this.screen.model_name);
|
||||
if (this.domain) {
|
||||
this.wid_text = jQuery('<input/>', {
|
||||
type: 'input'
|
||||
});
|
||||
menu.append(this.wid_text);
|
||||
|
||||
this.but_add = jQuery('<button/>').button({
|
||||
icons: {
|
||||
primary: 'ui-icon-plus'
|
||||
},
|
||||
label: 'Add'
|
||||
});
|
||||
this.but_add.click(this.add.bind(this));
|
||||
menu.append(this.but_add);
|
||||
this.but_add.prop('disabled', !access.read);
|
||||
|
||||
this.but_remove = jQuery('<button/>').button({
|
||||
icons: {
|
||||
primary: 'ui-icon-minus'
|
||||
},
|
||||
label: 'Remove'
|
||||
});
|
||||
this.but_remove.click(this.remove.bind(this));
|
||||
menu.append(this.but_remove);
|
||||
this.but_remove.prop('disabled', !access.read);
|
||||
}
|
||||
|
||||
this.but_new = jQuery('<button/>').button({
|
||||
icons: {
|
||||
primary: 'ui-icon-document'
|
||||
},
|
||||
label: 'New'
|
||||
});
|
||||
this.but_new.click(this.new_.bind(this));
|
||||
menu.append(this.but_new);
|
||||
this.but_new.prop('disabled', !access.create);
|
||||
|
||||
this.but_del = jQuery('<button/>').button({
|
||||
icons: {
|
||||
primary: 'ui-icon-trash'
|
||||
},
|
||||
label: 'Delete'
|
||||
});
|
||||
this.but_del.click(this.delete_.bind(this));
|
||||
menu.append(this.but_del);
|
||||
this.but_del.prop('disabled', !access['delete']);
|
||||
|
||||
this.but_undel = jQuery('<button/>').button({
|
||||
icons: {
|
||||
primary: 'ui-icon-arrowreturn-1-s'
|
||||
},
|
||||
label: 'Undelete'
|
||||
});
|
||||
this.but_undel.click(this.undelete.bind(this));
|
||||
menu.append(this.but_undel);
|
||||
|
||||
this.but_previous = jQuery('<button/>').button({
|
||||
icons: {
|
||||
primary: 'ui-icon-arrowthick-1-w'
|
||||
},
|
||||
label: 'Previous'
|
||||
});
|
||||
this.but_previous.click(this.previous.bind(this));
|
||||
menu.append(this.but_previous);
|
||||
|
||||
this.label = jQuery('<span/>');
|
||||
this.label.text('(0, 0)');
|
||||
menu.append(this.label);
|
||||
|
||||
this.but_next = jQuery('<button/>').button({
|
||||
icons: {
|
||||
primary: 'ui-icon-arrowthick-1-e'
|
||||
},
|
||||
label: 'Next'
|
||||
});
|
||||
this.but_next.click(this.next.bind(this));
|
||||
menu.append(this.but_next);
|
||||
|
||||
this.but_switch = jQuery('<button/>').button({
|
||||
icons: {
|
||||
primary: 'ui-icon-newwin'
|
||||
},
|
||||
label: 'Switch'
|
||||
});
|
||||
this.but_switch.click(this.switch_.bind(this));
|
||||
menu.append(this.but_switch);
|
||||
}
|
||||
|
||||
|
||||
switch_prm.done(function() {
|
||||
this.el.dialog({
|
||||
autoOpen: false,
|
||||
buttons: buttons,
|
||||
title: '' // this.screen.current_view
|
||||
});
|
||||
if (menu) {
|
||||
this.el.append(menu);
|
||||
}
|
||||
this.el.append(this.screen.screen_container.alternate_viewport);
|
||||
this.el.dialog('open');
|
||||
this.screen.display();
|
||||
}.bind(this));
|
||||
|
||||
},
|
||||
add: function() {
|
||||
// TODO
|
||||
},
|
||||
remove: function() {
|
||||
this.screen.remove(false, true, false);
|
||||
},
|
||||
new_: function() {
|
||||
this.screen.new_();
|
||||
},
|
||||
delete_: function() {
|
||||
this.screen.remove(false, false, false);
|
||||
},
|
||||
undelete: function() {
|
||||
this.screen.unremove();
|
||||
},
|
||||
previous: function() {
|
||||
this.screen.display_previous();
|
||||
},
|
||||
next: function() {
|
||||
this.screen.display_next();
|
||||
},
|
||||
switch_: function() {
|
||||
this.screen.switch_view();
|
||||
},
|
||||
response: function(response_id) {
|
||||
var result;
|
||||
this.screen.current_view.set_value();
|
||||
|
||||
if (response_id == 'RESPONSE_OK' &&
|
||||
this.screen.current_record !== null) {
|
||||
if (~['RESPONSE_OK', 'RESPONSE_ACCEPT'].indexOf(response_id) &&
|
||||
this.screen.current_record) {
|
||||
this.screen.current_record.validate().then(function(validate) {
|
||||
var closing_prm = jQuery.Deferred();
|
||||
if (validate && this.save_current) {
|
||||
@@ -116,15 +243,25 @@
|
||||
|
||||
// TODO Add support for many
|
||||
closing_prm.done(function() {
|
||||
this.callback(result);
|
||||
this.destroy();
|
||||
if (response_id == 'RESPONSE_ACCEPT') {
|
||||
this.screen.new_();
|
||||
this.screen.current_view.display();
|
||||
// TODO set_cursor
|
||||
this.many -= 1;
|
||||
if (this.many === 0) {
|
||||
this.but_new.prop('disabled', true);
|
||||
}
|
||||
} else {
|
||||
this.callback(result);
|
||||
this.destroy();
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
return;
|
||||
}
|
||||
|
||||
if (response_id == 'RESPONSE_CANCEL' &&
|
||||
this.screen.current_record !== null) {
|
||||
this.screen.current_record) {
|
||||
result = false;
|
||||
if ((this.screen.current_record.id < 0) || this.save_current) {
|
||||
this.screen.group.remove(this.screen.current_record, true);
|
||||
|
||||
Reference in new issue
Block a user