diff --git a/ucs/management/univention-management-console-frontend/umc/widgets/Form.js b/ucs/management/univention-management-console-frontend/umc/widgets/Form.js index 6d2d360..36e7f52 100644 --- a/ucs/management/univention-management-console-frontend/umc/widgets/Form.js +++ b/ucs/management/univention-management-console-frontend/umc/widgets/Form.js @@ -218,10 +218,12 @@ dojo.declare("umc.widgets.Form", [ // widget values have not been loaded completely so far //console.log('iwidget:', iwidget.name); ++this._initializingElements; + console.log("Form Init: " + iwidget.id); var handle = this.connect(iwidget, 'onValuesLoaded', dojo.hitch(this, function() { //console.log('onValuesLoaded:', iwidget.name, iwidget.get('value')); // disconnect from the signal this.disconnect(handle); + console.log("Form Callback: " + iwidget.id); // decrement the internal counter --this._initializingElements; diff --git a/ucs/management/univention-management-console-frontend/umc/widgets/MultiInput.js b/ucs/management/univention-management-console-frontend/umc/widgets/MultiInput.js index 1e3a386..be9db81 100644 --- a/ucs/management/univention-management-console-frontend/umc/widgets/MultiInput.js +++ b/ucs/management/univention-management-console-frontend/umc/widgets/MultiInput.js @@ -82,6 +82,8 @@ dojo.declare("umc.widgets.MultiInput", [ _lastDepends: null, + _initializingElements: 0, + _createHandler: function(ifunc) { // This handler will be called by all subwidgets of the MultiInput widget. // When the first request comes in, we will execute the function to compute @@ -149,14 +151,48 @@ dojo.declare("umc.widgets.MultiInput", [ _loadValues: function(depends) { // delegate the call to _loadValues to all widgets + console.log('MultiInput: _loadValues: ' + this.id); this._lastDepends = depends; - dojo.forEach(this._widgets, function(iwidgets) { + this._initializingElements = 0; + dojo.forEach(this._widgets, dojo.hitch(this, function(iwidgets) { + + dojo.forEach(iwidgets, dojo.hitch(this, function(jwidget) { + if ('onValuesLoaded' in jwidget && !(jwidget._valuesLoaded && !jwidget._deferredOrValues)) { + ++this._initializingElements; + console.log("MultiInput Init: " + jwidget.id); + var handle = this.connect(jwidget, 'onValuesLoaded', dojo.hitch(this, function() { + console.log("MultiInput Callback: " + jwidget.id); + // disconnect from the signal + this.disconnect(handle); + + // decrement the internal counter + --this._initializingElements; + + // send event when the last element has been initialized + if (0 === this._initializingElements) { + console.log('MultiInput: top: _initializingElements == 0 ==> calling onValuesLoaded'); + this.onValuesLoaded(); + } + })); + } + })); + dojo.forEach(iwidgets, function(jwidget) { if ('_loadValues' in jwidget) { jwidget._loadValues(depends); } }); - }); + })); + + // maybe all elements are already initialized + if (!this._initializingElements) { + console.log('MultiInput: bottom: _initializingElements == 0 ==> calling onValuesLoaded'); + this.onValuesLoaded(); + } + }, + + onValuesLoaded: function() { + // event stub }, _setAllValues: function(_valList) { @@ -400,13 +436,14 @@ dojo.declare("umc.widgets.MultiInput", [ rowContainer.startup(); this.addChild(rowContainer); - // call the _loadValues method by hand - dojo.forEach(order, function(iname) { - var iwidget = widgets[iname]; - if ('_loadValues' in iwidget) { - iwidget._loadValues(this._lastDepends); - } - }, this); +// // call the _loadValues method by hand +// dojo.forEach(order, function(iname) { +// var iwidget = widgets[iname]; +// if ('_loadValues' in iwidget) { +// iwidget._loadValues(this._lastDepends); +// } +// }, this); + this._loadValues(this._lastDepends); } // add the new button diff --git a/ucs/management/univention-management-console-module-udm/umc/js/_udm/DetailPage.js b/ucs/management/univention-management-console-module-udm/umc/js/_udm/DetailPage.js index ef230b1..4594ca6 100644 --- a/ucs/management/univention-management-console-module-udm/umc/js/_udm/DetailPage.js +++ b/ucs/management/univention-management-console-module-udm/umc/js/_udm/DetailPage.js @@ -688,9 +688,16 @@ dojo.declare("umc.modules._udm.DetailPage", [ dijit.layout.ContentPane, umc.widg this._form.getWidget( '$objecttype$' ).set( 'content', this._( 'Type: %(type)s', { type: vals.$labelObjectType$ } ) ); this._form.getWidget( '$location$' ).set( 'content', this._( 'Position: %(path)s', { path: path } ) ); + this._receivedObjFormData = this.getValues(); + this._receivedObjFormData.$policies$ = this._receivedObjOrigData.$policies$; + })); + + var handle = this.connect(this._form, 'onValuesInitialized', dojo.hitch(this, function() { + this.disconnect(handle); // save the original form data this._receivedObjFormData = this.getValues(); this._receivedObjFormData.$policies$ = this._receivedObjOrigData.$policies$; + console.warn("ONVALUESINIT: 3b"); })); } else {