diff --git a/ucs-4.0-1/management/univention-management-console-frontend/umc/widgets/MultiUploader.js b/ucs-4.0-1/management/univention-management-console-frontend/umc/widgets/MultiUploader.js index 7abc1a8..c3b4609 100644 --- a/ucs-4.0-1/management/univention-management-console-frontend/umc/widgets/MultiUploader.js +++ b/ucs-4.0-1/management/univention-management-console-frontend/umc/widgets/MultiUploader.js @@ -154,6 +154,7 @@ define([ _setValueAttr: function(newVal) { this._files.selection.clear(); this._files.set('staticValues', newVal); + this._set('value', newVal); }, _getValueAttr: function() { @@ -161,13 +162,14 @@ define([ }, _setButtonLabelAttr: function(newVal) { - this.buttonLabel = newVal; this._uploader.set('buttonLabel', newVal); + this._set('buttonLabel', newVal); }, _setDisabledAttr: function(newVal) { this._files.set('disabled', newVal); this._uploader.set('disabled', newVal); + this._set('disabled', newVal); }, _getDisabledAttr: function() { diff --git a/ucs-4.0-1/management/univention-management-console-frontend/umc/widgets/Uploader.js b/ucs-4.0-1/management/univention-management-console-frontend/umc/widgets/Uploader.js index e5c3d52..5d8b84e 100644 --- a/ucs-4.0-1/management/univention-management-console-frontend/umc/widgets/Uploader.js +++ b/ucs-4.0-1/management/univention-management-console-frontend/umc/widgets/Uploader.js @@ -81,7 +81,7 @@ define([ // value: String // The content of the base64 encoded file data. - value: "", + value: null, // maxSize: Number // A size limit for the uploaded file. @@ -116,6 +116,12 @@ define([ postMixInProperties: function() { this.inherited(arguments); + if (this.multiFile) { + this.value = []; + } else { + this.value = ''; + } + // save the original label this._origButtonLabel = this.buttonLabel; }, @@ -193,7 +199,7 @@ define([ lang.mixin(params, { iframe: (this._uploader.uploadType === 'iframe') ? true : false }); - + this._uploader.upload(params); this._updateLabel(); this.onUploadStarted(_data); @@ -239,10 +245,23 @@ define([ this.set('value', this.value); }, - _setDataAttr: function(newVal) { - this.data = newVal; + _setDataAttr: function(data) { + this._set('data', data); this._settingData = true; - this.set( 'value', newVal && 'content' in newVal ? newVal.content : '' ); + var value = ''; + if (!this.multiFile && data && 'content' in data) { + // single file upload with data containing content + value = data.content; + } else if (this.multiFile && data instanceof Array) { + // multi file upload -> handle array accordingly + value = array.map(data, function(idata) { + return idata && 'content' in idata ? idata.content : ''; + }); + } else if (this.multiFile) { + // multi file fallback if data is not an array + value = []; + } + this.set('value', value); this._settingData = false; }, @@ -250,14 +269,20 @@ define([ if (!this._settingData) { this.data = null; } - this.value = newVal; - if ( this.showClearButton ) { + if (this.showClearButton) { // decide whether to show/hide remove button - domClass.toggle(this._clearButton.domNode, 'dijitHidden', !(typeof this.value == "string" && this.value !== "")); + var isVisible = false; + if (!this.multiFile) { + isVisible = typeof newVal == "string" && newVal !== ""; + } else { + isVisible = newVal instanceof Array && newVal.length; + } + domClass.toggle(this._clearButton.domNode, 'dijitHidden', !isVisible); } // send events + this._set('value', newVal); this.onChange(newVal); this.updateView(this.value, this.data); },