Files
tryton/src/window.js
T

643 lines
25 KiB
JavaScript
Raw Normal View History

2013-04-18 13:07:21 +02:00
/* This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. */
(function() {
'use strict';
2013-04-18 16:58:32 +02:00
Sao.Window = {};
2013-04-18 13:07:21 +02:00
Sao.Window.Form = Sao.class_(Object, {
init: function(screen, callback, kwargs) {
2013-05-23 16:17:56 +02:00
kwargs = kwargs || {};
2013-04-18 13:07:21 +02:00
this.screen = screen;
2013-05-23 16:17:56 +02:00
this.screen.screen_container.alternate_view = true;
2013-04-18 13:07:21 +02:00
var view_type = kwargs.view_type || 'form';
2013-05-23 16:17:56 +02:00
var form_prm = jQuery.when();
2013-04-18 13:07:21 +02:00
var screen_views = [];
2013-05-23 16:17:56 +02:00
for (var i = 0, len = this.screen.views.length; i < len; i++) {
2013-04-18 13:07:21 +02:00
screen_views.push(this.screen.views[i].view_type);
}
if (!~screen_views.indexOf(view_type) &&
!~this.screen.view_to_load.indexOf(view_type)) {
2013-05-23 16:17:56 +02:00
form_prm = this.screen.add_view_id(null, view_type);
2013-04-18 13:07:21 +02:00
}
2013-05-23 16:17:56 +02:00
var switch_prm = form_prm.then(function() {
return this.screen.switch_view(view_type).done(function() {
if (kwargs.new_) {
this.screen.new_();
}
}.bind(this));
2013-04-18 13:07:21 +02:00
}.bind(this));
this.many = kwargs.many || 0;
this.domain = kwargs.domain || null;
this.context = kwargs.context || null;
this.save_current = kwargs.save_current;
this.prev_view = screen.current_view;
this.callback = callback;
2015-02-06 00:32:51 +01:00
this.el = jQuery('<div/>', {
'class': 'modal fade',
role: 'dialog'
});
2015-02-27 10:25:02 +01:00
var content = jQuery('<form/>', {
2015-02-06 00:32:51 +01:00
'class': 'modal-content'
}).appendTo(jQuery('<div/>', {
'class': 'modal-dialog modal-lg'
}).appendTo(this.el));
var header = jQuery('<div/>', {
'class': 'modal-header'
}).append(jQuery('<h4/>', {
'class': 'modal-title'
})).appendTo(content);
var body = jQuery('<div/>', {
'class': 'modal-body'
}).appendTo(content);
var footer = jQuery('<div/>', {
'class': 'modal-footer'
}).appendTo(content);
2013-04-18 13:07:21 +02:00
2014-03-28 20:03:17 +01:00
var readonly = (this.screen.attributes.readonly ||
this.screen.group.get_readonly());
if (view_type == 'form') {
2015-02-06 00:32:51 +01:00
footer.append(jQuery('<button/>', {
2015-02-27 10:25:02 +01:00
'class': 'btn btn-link',
'type': 'button'
2015-02-06 00:32:51 +01:00
}).append(!kwargs.new_ && this.screen.current_record.id < 0 ?
'Delete' : 'Cancel')
.click(function() {
2014-03-28 20:03:17 +01:00
this.response('RESPONSE_CANCEL');
2015-02-06 00:32:51 +01:00
}.bind(this)));
2014-03-28 20:03:17 +01:00
}
2013-04-18 13:07:21 +02:00
2013-08-23 14:12:39 +02:00
if (kwargs.new_ && this.many) {
2015-02-06 00:32:51 +01:00
footer.append(jQuery('<button/>', {
2015-02-27 10:25:02 +01:00
'class': 'btn btn-default',
'type': 'button'
2015-02-06 00:32:51 +01:00
}).append('New').click(function() {
this.response('RESPONSE_ACCEPT');
}.bind(this)));
2013-08-23 14:12:39 +02:00
}
2013-04-18 13:07:21 +02:00
if (this.save_current) {
2015-02-06 00:32:51 +01:00
footer.append(jQuery('<button/>', {
2015-02-27 10:25:02 +01:00
'class': 'btn btn-primary',
'type': 'submit'
}).append('Save'));
2013-04-18 13:07:21 +02:00
} else {
2015-02-06 00:32:51 +01:00
footer.append(jQuery('<button/>', {
2015-02-27 10:25:02 +01:00
'class': 'btn btn-primary',
'type': 'submit'
}).append('OK'));
2013-04-18 13:07:21 +02:00
}
2015-02-27 10:25:02 +01:00
content.submit(function(e) {
this.response('RESPONSE_OK');
e.preventDefault();
}.bind(this));
2013-04-18 13:07:21 +02:00
2013-08-23 14:12:39 +02:00
if (view_type == 'tree') {
2015-02-06 00:32:51 +01:00
var menu = jQuery('<div/>').appendTo(body);
var group = jQuery('<div/>', {
'class': 'input-group input-group-sm'
}).appendTo(menu);
this.wid_text = jQuery('<input/>', {
type: 'input'
}).appendTo(menu);
this.wid_text.hide();
var buttons = jQuery('<div/>', {
'class': 'input-group-btn'
}).appendTo(group);
2013-08-23 14:12:39 +02:00
var access = Sao.common.MODELACCESS.get(this.screen.model_name);
if (this.domain) {
2015-02-06 00:32:51 +01:00
this.wid_text.show();
2013-08-23 14:12:39 +02:00
2015-02-06 00:32:51 +01:00
this.but_add = jQuery('<button/>', {
'class': 'btn btn-default btn-sm',
'aria-label': 'Add'
}).append(jQuery('<span/>', {
'class': 'glyphicon glyphicon-plus'
})).appendTo(buttons);
2013-08-23 14:12:39 +02:00
this.but_add.click(this.add.bind(this));
2014-03-18 19:56:07 +01:00
this.but_add.prop('disabled', !access.read || readonly);
2013-08-23 14:12:39 +02:00
2015-02-06 00:32:51 +01:00
this.but_remove = jQuery('<button/>', {
'class': 'btn btn-default btn-sm',
'aria-label': 'Remove'
}).append(jQuery('<span/>', {
'class': 'glyphicon glyphicon-minus'
})).appendTo(buttons);
2013-08-23 14:12:39 +02:00
this.but_remove.click(this.remove.bind(this));
2014-03-18 19:56:07 +01:00
this.but_remove.prop('disabled', !access.read || readonly);
2013-08-23 14:12:39 +02:00
}
2015-02-06 00:32:51 +01:00
this.but_new = jQuery('<button/>', {
'class': 'btn btn-default btn-sm',
'aria-label': 'New'
}).append(jQuery('<span/>', {
'class': 'glyphicon glyphicon-edit'
})).appendTo(buttons);
2013-08-23 14:12:39 +02:00
this.but_new.click(this.new_.bind(this));
2014-03-18 19:56:07 +01:00
this.but_new.prop('disabled', !access.create || readonly);
2013-08-23 14:12:39 +02:00
2015-02-06 00:32:51 +01:00
this.but_del = jQuery('<button/>', {
'class': 'btn btn-default btn-sm',
'aria-label': 'Delete'
}).append(jQuery('<span/>', {
'class': 'glyphicon glyphicon-trash'
})).appendTo(buttons);
2013-08-23 14:12:39 +02:00
this.but_del.click(this.delete_.bind(this));
2014-03-18 19:56:07 +01:00
this.but_del.prop('disabled', !access['delete'] || readonly);
2013-08-23 14:12:39 +02:00
2015-02-06 00:32:51 +01:00
this.but_undel = jQuery('<button/>', {
'class': 'btn btn-default btn-sm',
'aria-label': 'Undelete'
}).append(jQuery('<span/>', {
'class': 'glyphicon glyphicon-repeat'
})).appendTo(buttons);
2013-08-23 14:12:39 +02:00
this.but_undel.click(this.undelete.bind(this));
2014-03-18 19:56:07 +01:00
this.but_undel.prop('disabled', !access['delete'] || readonly);
2013-08-23 14:12:39 +02:00
2015-02-06 00:32:51 +01:00
this.but_previous = jQuery('<button/>', {
'class': 'btn btn-default btn-sm',
'aria-label': 'Previous'
}).append(jQuery('<span/>', {
'class': 'glyphicon glyphicon-arrow-left'
})).appendTo(buttons);
2013-08-23 14:12:39 +02:00
this.but_previous.click(this.previous.bind(this));
2015-02-06 00:32:51 +01:00
this.label = jQuery('<span/>', {
'class': 'btn'
}).appendTo(buttons);
2013-08-23 14:12:39 +02:00
this.label.text('(0, 0)');
2015-02-06 00:32:51 +01:00
this.but_next = jQuery('<button/>', {
'class': 'btn btn-default btn-sm',
'aria-label': 'Next'
}).append(jQuery('<span/>', {
'class': 'glyphicon glyphicon-arrow-right'
})).appendTo(buttons);
2013-08-23 14:12:39 +02:00
this.but_next.click(this.next.bind(this));
2015-02-06 00:32:51 +01:00
this.but_switch = jQuery('<button/>', {
'class': 'btn btn-default btn-sm',
'aria-label': 'Switch'
}).append(jQuery('<span/>', {
'class': 'glyphicon glyphicon-list-alt'
})).appendTo(buttons);
2013-08-23 14:12:39 +02:00
this.but_switch.click(this.switch_.bind(this));
}
2013-05-10 18:24:26 +02:00
switch_prm.done(function() {
2015-02-06 00:32:51 +01:00
// TODO header this.screen.current_view
body.append(this.screen.screen_container.alternate_viewport);
this.el.modal('show');
2013-04-18 13:07:21 +02:00
this.screen.display();
}.bind(this));
},
2013-08-23 14:12:39 +02:00
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();
},
2013-05-10 18:24:26 +02:00
response: function(response_id) {
2013-04-18 13:07:21 +02:00
var result;
this.screen.current_view.set_value();
2014-03-28 20:03:17 +01:00
var readonly = this.screen.group.get_readonly();
2013-08-23 14:12:39 +02:00
if (~['RESPONSE_OK', 'RESPONSE_ACCEPT'].indexOf(response_id) &&
2014-03-28 20:03:17 +01:00
!readonly &&
2013-08-23 14:12:39 +02:00
this.screen.current_record) {
2013-07-23 10:44:54 +02:00
this.screen.current_record.validate().then(function(validate) {
var closing_prm = jQuery.Deferred();
if (validate && this.save_current) {
this.screen.save_current().then(closing_prm.resolve,
closing_prm.reject);
} else if (validate &&
this.screen.current_view.view_type == 'form') {
var view = this.screen.current_view;
var validate_prms = [];
for (var name in this.widgets) {
var widget = this.widgets[name];
if (widget.screen && widget.screen.pre_validate) {
var record = widget.screen.current_record;
if (record) {
validate_prms.push(record.pre_validate());
}
2013-04-18 13:07:21 +02:00
}
}
2013-07-23 10:44:54 +02:00
jQuery.when.apply(jQuery, validate_prms).then(
closing_prm.resolve, closing_prm.reject);
} else if (!validate) {
closing_prm.reject();
} else {
closing_prm.resolve();
2013-04-18 13:07:21 +02:00
}
2013-07-23 10:44:54 +02:00
closing_prm.fail(function() {
// TODO set_cursor
this.screen.display();
}.bind(this));
// TODO Add support for many
closing_prm.done(function() {
2013-08-23 14:12:39 +02:00
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 {
2014-02-13 22:45:27 +01:00
result = true;
2013-08-23 14:12:39 +02:00
this.callback(result);
this.destroy();
}
2013-07-23 10:44:54 +02:00
}.bind(this));
2013-04-18 13:07:21 +02:00
}.bind(this));
2013-07-23 10:44:54 +02:00
return;
2013-04-18 13:07:21 +02:00
}
if (response_id == 'RESPONSE_CANCEL' &&
2014-03-28 20:03:17 +01:00
!readonly &&
this.screen.current_record) {
2013-07-23 10:44:54 +02:00
result = false;
2013-04-18 13:07:21 +02:00
if ((this.screen.current_record.id < 0) || this.save_current) {
2013-07-23 10:44:54 +02:00
this.screen.group.remove(this.screen.current_record, true);
2013-04-18 13:07:21 +02:00
} else if (this.screen.current_record.has_changed()) {
this.screen.current_record.cancel();
2013-07-23 10:44:54 +02:00
this.screen.current_record.reload().always(function() {
this.callback(result);
this.destroy();
}.bind(this));
return;
2013-04-18 13:07:21 +02:00
}
} else {
result = response_id != 'RESPONSE_CANCEL';
}
2013-07-23 10:44:54 +02:00
this.callback(result);
this.destroy();
2013-05-23 16:17:56 +02:00
},
destroy: function() {
this.screen.screen_container.alternate_view = false;
this.screen.screen_container.alternate_viewport.children()
.detach();
2015-02-06 00:32:51 +01:00
if (this.prev_view) {
// Empty when opening from Many2One
this.screen.switch_view(this.prev_view.view_type);
}
this.el.modal('hide').remove();
2013-04-18 13:07:21 +02:00
}
});
2013-08-26 14:26:03 +02:00
Sao.Window.Attachment = Sao.class_(Sao.Window.Form, {
init: function(record, callback) {
this.resource = record.model.name + ',' + record.id;
this.attachment_callback = callback;
2014-03-18 19:56:07 +01:00
var context = jQuery.extend({}, record.get_context());
context.resource = this.resource;
2013-08-26 14:26:03 +02:00
var screen = new Sao.Screen('ir.attachment', {
domain: [['resource', '=', this.resource]],
mode: ['tree', 'form'],
2014-03-18 19:56:07 +01:00
context: context,
2013-08-26 14:26:03 +02:00
exclude_field: 'resource'
});
screen.switch_view().done(function() {
screen.search_filter();
2014-07-09 00:30:23 +02:00
screen.group.parent = record;
2013-08-26 14:26:03 +02:00
});
Sao.Window.Attachment._super.init.call(this, screen, this.callback,
{view_type: 'tree'});
},
callback: function(result) {
if (result) {
this.screen.group.save();
}
if (this.attachment_callback) {
this.attachment_callback();
}
}
});
2013-04-18 13:07:21 +02:00
Sao.Window.Search = Sao.class_(Object, {
init: function(model, callback, kwargs) {
2013-05-23 16:17:56 +02:00
kwargs = kwargs || {};
2013-04-18 13:07:21 +02:00
var views_preload = kwargs.views_preload || {};
this.model_name = model;
this.domain = kwargs.domain || [];
this.context = kwargs.context || {};
this.sel_multi = kwargs.sel_multi;
this.callback = callback;
2015-02-06 00:32:51 +01:00
this.el = jQuery('<div/>', {
'class': 'modal fade',
role: 'dialog'
});
var content = jQuery('<div/>', {
'class': 'modal-content'
}).appendTo(jQuery('<div/>', {
'class': 'modal-dialog modal-lg'
}).appendTo(this.el));
var header = jQuery('<div/>', {
'class': 'modal-header'
}).append(jQuery('<h4/>', {
'class': 'modal-title'
}).append('Search')).appendTo(content);
var body = jQuery('<div/>', {
'class': 'modal-body'
}).appendTo(content);
var footer = jQuery('<div/>', {
'class': 'modal-footer'
}).appendTo(content);
2013-04-18 13:07:21 +02:00
2015-02-06 00:32:51 +01:00
jQuery('<button/>', {
'class': 'btn btn-link'
}).append('Cancel').click(function() {
this.response('RESPONSE_CANCEL');
}.bind(this)).appendTo(footer);
jQuery('<button/>', {
'class': 'btn btn-default'
}).append('Find').click(function() {
this.response('RESPONSE_APPLY');
}.bind(this)).appendTo(footer);
2013-08-21 16:26:20 +02:00
if (kwargs.new_ && Sao.common.MODELACCESS.get(model).create) {
2015-02-06 00:32:51 +01:00
jQuery('<button/>', {
'class': 'btn btn-default'
}).append('New').click(function() {
this.response('RESPONSE_ACCEPT');
}.bind(this)).appendTo(footer);
2013-04-18 13:07:21 +02:00
}
2015-02-06 00:32:51 +01:00
jQuery('<button/>', {
'class': 'btn btn-primary'
}).append('OK').click(function() {
this.response('RESPONSE_OK');
}.bind(this)).appendTo(footer);
2013-04-18 13:07:21 +02:00
this.screen = new Sao.Screen(model, {
mode: ['tree'],
context: this.context,
domain: this.domain,
2013-04-18 13:07:21 +02:00
view_ids: kwargs.view_ids,
views_preload: views_preload
});
this.screen.load_next_view().done(function() {
2013-05-10 18:24:26 +02:00
this.screen.switch_view().done(function() {
2015-02-06 00:32:51 +01:00
body.append(this.screen.screen_container.el);
this.el.modal('show');
2013-04-18 13:07:21 +02:00
this.screen.display();
2014-09-18 19:11:40 +02:00
if (kwargs.search_filter !== undefined) {
this.screen.search_filter(kwargs.search_filter);
}
2013-04-18 13:07:21 +02:00
}.bind(this));
}.bind(this));
},
2013-05-10 18:24:26 +02:00
response: function(response_id) {
2013-04-18 13:07:21 +02:00
var records;
var value = [];
if (response_id == 'RESPONSE_OK') {
records = this.screen.current_view.selected_records();
} else if (response_id == 'RESPONSE_APPLY') {
2013-05-14 19:15:37 +02:00
this.screen.search_filter();
return;
2013-04-18 13:07:21 +02:00
} else if (response_id == 'RESPONSE_ACCEPT') {
2013-05-14 19:15:37 +02:00
var screen = new Sao.Screen(this.model_name, {
domain: this.domain,
context: this.context,
mode: ['form']
});
var callback = function(result) {
if (result) {
screen.save_current().then(function() {
var record = screen.current_record;
this.callback([[record.id,
record._values.rec_name || '']]);
}.bind(this), function() {
this.callback(null);
}.bind(this));
} else {
this.callback(null);
}
};
2015-02-06 00:32:51 +01:00
this.el.modal('hide').remove();
2013-05-14 19:15:37 +02:00
new Sao.Window.Form(screen, callback.bind(this), {
new_: true
});
return;
2013-04-18 13:07:21 +02:00
}
if (records) {
var index, record;
for (index in records) {
record = records[index];
value.push([record.id, record._values.rec_name || '']);
}
}
this.callback(value);
2015-02-06 00:32:51 +01:00
this.el.modal('hide').remove();
2013-04-18 13:07:21 +02:00
}
});
2013-05-14 11:59:11 +02:00
Sao.Window.Preferences = Sao.class_(Object, {
init: function(callback) {
this.callback = callback;
2015-02-06 00:32:51 +01:00
this.el = jQuery('<div/>', {
'class': 'modal fade',
role: 'dialog'
});
2015-02-27 10:25:02 +01:00
var content = jQuery('<form/>', {
2015-02-06 00:32:51 +01:00
'class': 'modal-content'
}).appendTo(jQuery('<div/>', {
'class': 'modal-dialog modal-lg'
}).appendTo(this.el));
var header = jQuery('<div/>', {
'class': 'modal-header'
}).append(jQuery('<h4/>', {
'class': 'modal-title'
}).append('Preferences')).appendTo(content);
var body = jQuery('<div/>', {
'class': 'modal-body'
}).appendTo(content);
var footer = jQuery('<div/>', {
'class': 'modal-footer'
}).appendTo(content);
2013-05-14 11:59:11 +02:00
2015-02-06 00:32:51 +01:00
jQuery('<button/>', {
2015-02-27 10:25:02 +01:00
'class': 'btn btn-link',
'type': 'button'
2015-02-06 00:32:51 +01:00
}).append('Cancel').click(function() {
this.response('RESPONSE_CANCEL');
}.bind(this)).appendTo(footer);
jQuery('<button/>', {
2015-02-27 10:25:02 +01:00
'class': 'btn btn-primary',
'type': 'submit'
}).append('OK').appendTo(footer);
content.submit(function(e) {
2015-02-06 00:32:51 +01:00
this.response('RESPONSE_OK');
2015-02-27 10:25:02 +01:00
e.preventDefault();
}.bind(this));
2013-05-14 11:59:11 +02:00
this.screen = new Sao.Screen('res.user', {
mode: []
});
2014-03-18 19:56:07 +01:00
this.screen.group.set_readonly(false);
this.screen.group.skip_model_access = true;
2013-05-14 11:59:11 +02:00
var set_view = function(view) {
this.screen.add_view(view);
this.screen.switch_view().done(function() {
this.screen.new_(false);
this.screen.model.execute('get_preferences', [false], {})
.then(set_preferences.bind(this), this.destroy);
}.bind(this));
};
var set_preferences = function(preferences) {
this.screen.current_record.set(preferences);
this.screen.current_record.id =
this.screen.model.session.user_id;
2013-07-23 10:44:54 +02:00
this.screen.current_record.validate(null, true).then(
function() {
this.screen.display();
}.bind(this));
2015-02-06 00:32:51 +01:00
body.append(this.screen.screen_container.el);
this.el.modal('show');
2013-05-14 11:59:11 +02:00
};
this.screen.model.execute('get_preferences_fields_view', [], {})
.then(set_view.bind(this), this.destroy);
},
response: function(response_id) {
2013-11-25 12:18:32 +01:00
var end = function() {
this.destroy();
this.callback();
}.bind(this);
var prm = jQuery.when();
2013-05-14 11:59:11 +02:00
if (response_id == 'RESPONSE_OK') {
2013-11-25 12:18:32 +01:00
prm = this.screen.current_record.validate()
.then(function(validate) {
if (validate) {
var values = jQuery.extend({}, this.screen.get());
var set_preferences = function(password) {
return this.screen.model.execute(
'set_preferences', [values, password], {});
}.bind(this);
if ('password' in values) {
return Sao.common.ask.run(
'Current Password:', false)
.then(function(password) {
return set_preferences(password);
});
} else {
return set_preferences(false);
2013-07-23 10:44:54 +02:00
}
2013-05-14 11:59:11 +02:00
}
2013-11-25 12:18:32 +01:00
}.bind(this));
2013-05-14 11:59:11 +02:00
}
2013-11-25 12:18:32 +01:00
prm.done(end);
2013-05-14 11:59:11 +02:00
},
destroy: function() {
2015-02-06 00:32:51 +01:00
this.el.modal('hide').remove();
2013-05-14 11:59:11 +02:00
}
});
2014-03-18 19:56:07 +01:00
Sao.Window.Revision = Sao.class_(Object, {
init: function(revisions, callback) {
this.callback = callback;
2015-02-06 00:32:51 +01:00
this.el = jQuery('<div/>', {
'class': 'modal fade',
role: 'dialog'
2014-03-18 19:56:07 +01:00
});
2015-02-27 10:25:02 +01:00
var content = jQuery('<form/>', {
2015-02-06 00:32:51 +01:00
'class': 'modal-content'
}).appendTo(jQuery('<div/>', {
'class': 'modal-dialog modal-lg'
}).appendTo(this.el));
var header = jQuery('<div/>', {
'class': 'modal-header'
}).append(jQuery('<h4/>', {
'class': 'modal-title'
}).append('Revision')).appendTo(content);
var body = jQuery('<div/>', {
'class': 'modal-body'
}).appendTo(content);
var footer = jQuery('<div/>', {
'class': 'modal-footer'
}).appendTo(content);
2014-03-18 19:56:07 +01:00
2015-02-06 00:32:51 +01:00
jQuery('<button/>', {
2015-02-27 10:25:02 +01:00
'class': 'btn btn-link',
'type': 'button'
2015-02-06 00:32:51 +01:00
}).append('Cancel').click(function() {
this.response('RESPONSE_CANCEL');
}.bind(this)).appendTo(footer);
jQuery('<button/>', {
2015-02-27 10:25:02 +01:00
'class': 'btn btn-primary',
'type': 'submit'
}).append('OK').appendTo(footer);
content.submit(function(e) {
2015-02-06 00:32:51 +01:00
this.response('RESPONSE_OK');
2015-02-27 10:25:02 +01:00
e.preventDefault();
}.bind(this));
2014-03-18 19:56:07 +01:00
2015-02-06 00:32:51 +01:00
var group = jQuery('<div/>', {
'class': 'form-group'
}).appendTo(body);
jQuery('<label/>', {
'for': 'revision',
'text': 'Revision'
}).appendTo(group);
this.select = jQuery('<select/>', {
'class': 'form-control',
id: 'revision',
'placeholder': 'Revision'
}).appendTo(group);
2014-03-18 19:56:07 +01:00
var date_format = Sao.common.date_format();
var time_format = '%H:%M:%S.%f';
this.select.append(jQuery('<option/>', {
value: null,
text: ''
}));
revisions.forEach(function(revision) {
var name = revision[2];
revision = revision[0];
this.select.append(jQuery('<option/>', {
value: revision.valueOf(),
text: Sao.common.format_datetime(
date_format, time_format, revision) + ' ' + name
}));
}.bind(this));
2015-02-06 00:32:51 +01:00
this.el.modal('show');
2014-03-18 19:56:07 +01:00
},
response: function(response_id) {
var revision = null;
if (response_id == 'RESPONSE_OK') {
revision = this.select.val();
if (revision) {
revision = Sao.DateTime(parseInt(revision, 10));
}
}
2015-02-06 00:32:51 +01:00
this.el.modal('hide').remove();
2014-03-18 19:56:07 +01:00
this.callback(revision);
}
});
2013-04-18 13:07:21 +02:00
}());