diff --git a/src/sunstone/public/app/tabs/images-tab/form-panels/import.js b/src/sunstone/public/app/tabs/images-tab/form-panels/import.js index d6e82b6555..f1066f16b6 100644 --- a/src/sunstone/public/app/tabs/images-tab/form-panels/import.js +++ b/src/sunstone/public/app/tabs/images-tab/form-panels/import.js @@ -24,6 +24,7 @@ define(function(require) { var Sunstone = require('sunstone'); var Locale = require('utils/locale'); var VCenterImages = require('utils/vcenter/images'); + var ResourceSelect = require('utils/resource-select'); /* TEMPLATES @@ -65,6 +66,7 @@ define(function(require) { FormPanel.prototype.submitWizard = _submitWizard; FormPanel.prototype.onShow = _onShow; FormPanel.prototype.setup = _setup; + FormPanel.prototype.reInitForm = _reInitForm; return FormPanel; @@ -79,7 +81,7 @@ define(function(require) { }); } - function _setup(context) { + function _reInitForm(context) { var that = this; $("form.vcenter_credentials", context) @@ -110,7 +112,10 @@ define(function(require) { .on("submit", function(ev) { ev.preventDefault(); }); + } + function _setup(context) { + this.reInitForm(context); return false; } @@ -125,5 +130,24 @@ define(function(require) { } function _onShow(context) { + var that = this; + + var vcenter_datastore = $("div#vcenter_datastore_wrapper .resource_list_select", context).val(); + if (!vcenter_datastore) vcenter_datastore = undefined; + + ResourceSelect.insert({ + context: $('#vcenter_datastore_wrapper', context), + resourceName: 'Datastore', + initValue: vcenter_datastore, + emptyValue: true, + nameValues: true, + filterKey: 'DS_MAD', + filterValue: 'vcenter', + selectId: 'vcenter_datastore', + required: true, + callback: function(element){ + that.reInitForm(context); + } + }); } }); diff --git a/src/sunstone/public/app/tabs/images-tab/form-panels/import/html.hbs b/src/sunstone/public/app/tabs/images-tab/form-panels/import/html.hbs index 81046696c0..ab8ee9d356 100644 --- a/src/sunstone/public/app/tabs/images-tab/form-panels/import/html.hbs +++ b/src/sunstone/public/app/tabs/images-tab/form-panels/import/html.hbs @@ -32,8 +32,8 @@
- - + +
diff --git a/src/sunstone/public/app/utils/resource-select.js b/src/sunstone/public/app/utils/resource-select.js index 32925d7055..943b8ca8de 100644 --- a/src/sunstone/public/app/utils/resource-select.js +++ b/src/sunstone/public/app/utils/resource-select.js @@ -38,6 +38,9 @@ define(function(require) { * @param {string} [opts.filterValue] - RegExp that will be evaluated to filter the resources * @param {Boolean} [opts.nameValues] - Use the object NAME instead of the ID as the option values * @param {string} [opts.selectId] - Optional ID for the html select element + * @param {Boolean} [opts.required] - True to make the html select required + * @param {function}[opts.callback] - Callback function to call after the select element is + * added to the DOM */ var _insert = function(opts) { var Resource = require('opennebula/' + opts.resourceName.toLowerCase()); @@ -46,14 +49,20 @@ define(function(require) { Resource.list({ timeout: true, success: function (request, elemList) { - var selectHTML; + var elemId = ''; if (opts.selectId != undefined){ - selectHTML = ''; + elemId = 'id="'+opts.selectId+'"'; } + var required = ''; + + if (opts.required == true){ + required = 'required'; + } + + var selectHTML = '