Use form in modal
review9021002
This commit is contained in:
1 parent
2ea670313c
commit
06f3f3ec7b
3 files changed
+49
-26
No files matched your search
+2
-1
@@ -581,7 +581,8 @@
|
||||
init: function(attributes) {
|
||||
this.attributes = attributes;
|
||||
this.el = jQuery('<button/>', {
|
||||
'class': 'btn btn-default'
|
||||
'class': 'btn btn-default',
|
||||
'type': 'button'
|
||||
}).text(attributes.string || '')
|
||||
.append(jQuery('<span/>', {
|
||||
'class': 'glyphicon',
|
||||
|
||||
+33
-21
@@ -39,7 +39,7 @@
|
||||
'class': 'modal fade',
|
||||
role: 'dialog'
|
||||
});
|
||||
var content = jQuery('<div/>', {
|
||||
var content = jQuery('<form/>', {
|
||||
'class': 'modal-content'
|
||||
}).appendTo(jQuery('<div/>', {
|
||||
'class': 'modal-dialog modal-lg'
|
||||
@@ -61,7 +61,8 @@
|
||||
|
||||
if (view_type == 'form') {
|
||||
footer.append(jQuery('<button/>', {
|
||||
'class': 'btn btn-link'
|
||||
'class': 'btn btn-link',
|
||||
'type': 'button'
|
||||
}).append(!kwargs.new_ && this.screen.current_record.id < 0 ?
|
||||
'Delete' : 'Cancel')
|
||||
.click(function() {
|
||||
@@ -71,7 +72,8 @@
|
||||
|
||||
if (kwargs.new_ && this.many) {
|
||||
footer.append(jQuery('<button/>', {
|
||||
'class': 'btn btn-default'
|
||||
'class': 'btn btn-default',
|
||||
'type': 'button'
|
||||
}).append('New').click(function() {
|
||||
this.response('RESPONSE_ACCEPT');
|
||||
}.bind(this)));
|
||||
@@ -79,17 +81,19 @@
|
||||
|
||||
if (this.save_current) {
|
||||
footer.append(jQuery('<button/>', {
|
||||
'class': 'btn btn-primary'
|
||||
}).append('Save').click(function() {
|
||||
this.response('RESPONSE_OK');
|
||||
}.bind(this)));
|
||||
'class': 'btn btn-primary',
|
||||
'type': 'submit'
|
||||
}).append('Save'));
|
||||
} else {
|
||||
footer.append(jQuery('<button/>', {
|
||||
'class': 'btn btn-primary'
|
||||
}).append('OK').click(function() {
|
||||
this.response('RESPONSE_OK');
|
||||
}.bind(this)));
|
||||
'class': 'btn btn-primary',
|
||||
'type': 'submit'
|
||||
}).append('OK'));
|
||||
}
|
||||
content.submit(function(e) {
|
||||
this.response('RESPONSE_OK');
|
||||
e.preventDefault();
|
||||
}.bind(this));
|
||||
|
||||
if (view_type == 'tree') {
|
||||
var menu = jQuery('<div/>').appendTo(body);
|
||||
@@ -461,7 +465,7 @@
|
||||
'class': 'modal fade',
|
||||
role: 'dialog'
|
||||
});
|
||||
var content = jQuery('<div/>', {
|
||||
var content = jQuery('<form/>', {
|
||||
'class': 'modal-content'
|
||||
}).appendTo(jQuery('<div/>', {
|
||||
'class': 'modal-dialog modal-lg'
|
||||
@@ -479,15 +483,19 @@
|
||||
}).appendTo(content);
|
||||
|
||||
jQuery('<button/>', {
|
||||
'class': 'btn btn-link'
|
||||
'class': 'btn btn-link',
|
||||
'type': 'button'
|
||||
}).append('Cancel').click(function() {
|
||||
this.response('RESPONSE_CANCEL');
|
||||
}.bind(this)).appendTo(footer);
|
||||
jQuery('<button/>', {
|
||||
'class': 'btn btn-primary'
|
||||
}).append('OK').click(function() {
|
||||
'class': 'btn btn-primary',
|
||||
'type': 'submit'
|
||||
}).append('OK').appendTo(footer);
|
||||
content.submit(function(e) {
|
||||
this.response('RESPONSE_OK');
|
||||
}.bind(this)).appendTo(footer);
|
||||
e.preventDefault();
|
||||
}.bind(this));
|
||||
|
||||
this.screen = new Sao.Screen('res.user', {
|
||||
mode: []
|
||||
@@ -559,7 +567,7 @@
|
||||
'class': 'modal fade',
|
||||
role: 'dialog'
|
||||
});
|
||||
var content = jQuery('<div/>', {
|
||||
var content = jQuery('<form/>', {
|
||||
'class': 'modal-content'
|
||||
}).appendTo(jQuery('<div/>', {
|
||||
'class': 'modal-dialog modal-lg'
|
||||
@@ -577,15 +585,19 @@
|
||||
}).appendTo(content);
|
||||
|
||||
jQuery('<button/>', {
|
||||
'class': 'btn btn-link'
|
||||
'class': 'btn btn-link',
|
||||
'type': 'button'
|
||||
}).append('Cancel').click(function() {
|
||||
this.response('RESPONSE_CANCEL');
|
||||
}.bind(this)).appendTo(footer);
|
||||
jQuery('<button/>', {
|
||||
'class': 'btn btn-primary'
|
||||
}).append('OK').click(function() {
|
||||
'class': 'btn btn-primary',
|
||||
'type': 'submit'
|
||||
}).append('OK').appendTo(footer);
|
||||
content.submit(function(e) {
|
||||
this.response('RESPONSE_OK');
|
||||
}.bind(this)).appendTo(footer);
|
||||
e.preventDefault();
|
||||
}.bind(this));
|
||||
|
||||
var group = jQuery('<div/>', {
|
||||
'class': 'form-group'
|
||||
|
||||
+14
-4
@@ -173,7 +173,7 @@
|
||||
'class': 'wizard-dialog modal fade',
|
||||
role: 'dialog'
|
||||
});
|
||||
var content = jQuery('<div/>', {
|
||||
var content = this.content = jQuery('<form/>', {
|
||||
'class': 'modal-content'
|
||||
}).appendTo(jQuery('<div/>', {
|
||||
'class': 'modal-dialog modal-lg'
|
||||
@@ -200,12 +200,22 @@
|
||||
var button = Sao.Wizard.Dialog._super._get_button.call(this,
|
||||
definition);
|
||||
this.footer.append(button.el);
|
||||
button.el.click(function() {
|
||||
this.response(definition.state);
|
||||
}.bind(this));
|
||||
if (definition['default']) {
|
||||
this.content.unbind('submit');
|
||||
this.content.submit(function(e) {
|
||||
this.response(definition.state);
|
||||
e.preventDefault();
|
||||
}.bind(this));
|
||||
button.el.attr('type', 'submit');
|
||||
} else {
|
||||
button.el.click(function() {
|
||||
this.response(definition.state);
|
||||
}.bind(this));
|
||||
}
|
||||
return button;
|
||||
},
|
||||
update: function(view, defaults, buttons) {
|
||||
this.content.unbind('submit');
|
||||
Sao.Wizard.Dialog._super.update.call(this, view, defaults,
|
||||
buttons);
|
||||
this.dialog.modal('show');
|
||||
|
||||
Reference in new issue
Block a user