Index: uvmm/DomainPage.js =================================================================== --- uvmm/DomainPage.js (Revision 36968) +++ uvmm/DomainPage.js (Arbeitskopie) @@ -34,6 +34,7 @@ "dojo/_base/array", "dojo/store/Memory", "dojo/store/Observable", + "dojo/promise/all", "umc/tools", "umc/dialog", "umc/store", @@ -55,7 +56,7 @@ "umc/modules/uvmm/DriveGrid", "umc/modules/uvmm/types", "umc/i18n!umc/modules/uvmm" -], function(declare, lang, array, Memory, Observable, tools, dialog, store, Page, Form, ContainerWidget, TabContainer, TitlePane, ExpandingTitlePane, StandbyMixin, +], function(declare, lang, array, Memory, Observable, all, tools, dialog, store, Page, Form, ContainerWidget, TabContainer, TitlePane, ExpandingTitlePane, StandbyMixin, TextBox, HiddenInput, ComboBox, MultiInput, CheckBox, PasswordBox, SnapshotGrid, InterfaceGrid, DriveGrid, types, _) { return declare("umc.modules.uvmm.DomainPage", [ TabContainer, StandbyMixin ], { @@ -77,6 +78,7 @@ _snapshotGrid: null, _domain: null, + _loadedValues: null, disabled: false, @@ -92,7 +94,7 @@ footerButtons: [{ label: _('Back to overview'), name: 'cancel', - callback: lang.hitch(this, 'onClose') + callback: lang.hitch(this, 'confirmClose') }, { label: _('Save'), defaultButton: true, @@ -162,7 +164,7 @@ footerButtons: [{ label: _('Back to overview'), name: 'cancel', - callback: lang.hitch(this, 'onClose') + callback: lang.hitch(this, 'confirmClose') }, { label: _('Save'), defaultButton: true, @@ -295,7 +297,7 @@ footerButtons: [{ label: _('Back to overview'), name: 'cancel', - callback: lang.hitch(this, 'onClose') + callback: lang.hitch(this, 'confirmClose') }, { label: _('Save'), defaultButton: true, @@ -354,7 +356,7 @@ footerButtons: [{ label: _('Back to overview'), name: 'cancel', - callback: lang.hitch(this, 'onClose') + callback: lang.hitch(this, 'confirmClose') }, { label: _('Save'), defaultButton: true, @@ -386,11 +388,11 @@ // validate var valid = true; var widgets = lang.mixin({}, this._generalForm._widgets, this._advancedForm._widgets); - var values = lang.clone(this._domain); + var values = this.getValues(); delete values.domainURI; + tools.forIn(widgets, function(iname, iwidget) { valid = valid && (false !== iwidget.isValid()); - values[iname] = iwidget.get('value'); return valid; }, this); @@ -398,21 +400,6 @@ dialog.alert(_('The entered data is not valid. Please correct your input.')); return; } - // special handling for boot devices - var paravirtual = this._domain.type == 'xen-xen'; - if ( paravirtual ) { - var disks = [], boot_medium = null; - array.forEach( this._domain.disks, function( disk ) { - if ( values.boot_pv == disk.source ) { - disks.unshift( disk ); - } else { - disks.push( disk ); - } - } ); - values.disks = disks; - } else { - values.boot = values.boot_hvm; - } this.standby(true); tools.umcpCommand('uvmm/domain/put', { @@ -489,7 +476,7 @@ idev.$id$ = i + 1; }); - // we need to add pseudo ids for the network interfaces + // we need to add pseudo ids for the disk drives array.forEach(this._domain.disks, function(idrive, i) { idrive.$id$ = i + 1; }); @@ -556,6 +543,18 @@ } ) ); this.selectChild( this._generalPage, true); +// this._loadedValues = this.getValues(); +// // iterate over all advanced settings to set dynamically loaded values +// tools.forIn(this._advancedForm._widgets, function(ikey) { +// if (this._loadedValues[ikey] === '' && this._domain[ikey] !== null && this._domain[ikey] !== undefined) { +// this._loadedValues[ikey] = String(this._domain[ikey]); +// } +// }, this); + + all([this._advancedForm.ready(), this._generalForm.ready()]).then(lang.hitch(this, function() { + this._loadedValues = this.getValues(); + })); + // force a refresh of the grids this._interfaceGrid.filter(); this._driveGrid.filter(); @@ -567,6 +566,58 @@ })); }, + getValues: function() { +// var values = lang.mixin({}, this._domain, +// this._generalForm.get('value'), +// this._advancedForm.get('value') +// ); + var values = lang.clone(this._domain); + var widgets = lang.mixin({}, this._generalForm._widgets, this._advancedForm._widgets); + + tools.forIn(widgets, function(iname, iwidget) { + values[iname] = iwidget.get('value'); + }, this); + + // special handling for boot devices + var paravirtual = this._domain.type == 'xen-xen'; + if ( paravirtual ) { + var disks = [], boot_medium = null; + array.forEach( this._domain.disks, function( disk ) { + if ( values.boot_pv == disk.source ) { + disks.unshift( disk ); + } else { + disks.push( disk ); + } + } ); + values.disks = disks; + } else { + values.boot = values.boot_hvm; + } + return values; + }, + + confirmClose: function() { + // summary: + // If changes have been made show a confirmation dialogue before closing the page + + if (!tools.isEqual(this._loadedValues, this.getValues())) { + // Changes have been made. Display confirm dialogue. + return dialog.confirm( _('There are unsaved changes. Are you sure to cancel nevertheless?'), [{ + label: _('Discard changes'), + name: 'quit', + callback: lang.hitch(this, 'onClose') + }, { + label: _('Continue editing'), + name: 'cancel', + 'default': true + }] + ); + } + + // No changes have been made. Close the page + this.onClose(); + }, + onClose: function() { // event stub }, Index: de.po =================================================================== --- de.po (Revision 36968) +++ de.po (Arbeitskopie) @@ -1963,3 +1963,11 @@ #~ msgid "unknown value" #~ msgstr "Unbekannter Wert" +msgid "There are unsaved changes. Are you sure to cancel nevertheless?" +msgstr "Einige Änderungen sind noch nicht gespeichert. Möchten Sie trotzdem abbrechen?" + +msgid "Continue editing" +msgstr "Bearbeiten fortführen" + +msgid "Discard changes" +msgstr "Änderungen verwerfen"