jsdialog: only update the incoming control changes
It will update the control that has changed the model, in the current visible dialog instead to recreate the dialog again. Change-Id: Ibad681df32952f380d63ccd82b01d83c488d95b4 Signed-off-by: Henry Castro <hcastro@collabora.com>
This commit is contained in:
parent
c9cc7e840f
commit
5985ed252f
1 changed files with 28 additions and 0 deletions
|
@ -12,10 +12,12 @@ L.Control.JSDialog = L.Control.extend({
|
|||
this.map = map;
|
||||
|
||||
this.map.on('jsdialog', this.onJSDialog, this);
|
||||
this.map.on('commandresult', this.onJSUpdate, this);
|
||||
},
|
||||
|
||||
onRemove: function() {
|
||||
this.map.off('jsdialog', this.onJSDialog, this);
|
||||
this.map.off('commandresult', this.onJSUpdate, this);
|
||||
},
|
||||
|
||||
onJSDialog: function(e) {
|
||||
|
@ -101,6 +103,32 @@ L.Control.JSDialog = L.Control.extend({
|
|||
this.updatePosition(container, posX, posY);
|
||||
},
|
||||
|
||||
onJSUpdate: function (e) {
|
||||
if (e.commandName === '.uno:jsdialog' && e.success) {
|
||||
var data = e.result;
|
||||
var dialog = this.dialogs[data.dialog_id];
|
||||
if (!dialog)
|
||||
return;
|
||||
|
||||
var control = dialog.querySelector('#' + data.control_id);
|
||||
if (!control)
|
||||
return;
|
||||
|
||||
var parent = control.parentNode;
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
control.style.visibility = 'hidden';
|
||||
var builder = new L.control.jsDialogBuilder({windowId: data.dialog_id,
|
||||
mobileWizard: this,
|
||||
map: this.map,
|
||||
cssClass: 'jsdialog'});
|
||||
|
||||
builder.build(parent, [data.control], false);
|
||||
L.DomUtil.remove(control);
|
||||
}
|
||||
},
|
||||
|
||||
onPan: function (ev) {
|
||||
var target = this.draggingObject;
|
||||
if (target) {
|
||||
|
|
Loading…
Reference in a new issue