commit 01a5436b73538edbb9537a6db318ac176dec2caa Author: Jeff Pihach Date: Wed Jul 9 09:43:53 2014 -0600 Adding manually placed units calls env add_unit method diff --git a/app/templates/scale-up.handlebars b/app/templates/scale-up.handlebars index 6ad5de0..740caa7 100644 --- a/app/templates/scale-up.handlebars +++ b/app/templates/scale-up.handlebars @@ -4,12 +4,12 @@ - xx units + units
- + Units
diff --git a/app/views/viewlets/scale-up.js b/app/views/viewlets/scale-up.js index 622f507..a67304e 100644 --- a/app/views/viewlets/scale-up.js +++ b/app/views/viewlets/scale-up.js @@ -31,6 +31,7 @@ YUI.add('scale-up-view', function(Y) { '.add.button': { click: '_showScaleUp' }, '.placement .cancel.button': { click: '_hideScaleUp' }, 'input[name="placement"]': { change: '_toggleConstraints' }, + 'form': { submit: '_preventFormSubmit' }, '.edit.link': { click: '_toggleEditConstraints' }, '.inspector-buttons .cancel': { click: '_hideScaleUp' }, '.inspector-buttons .confirm': { click: '_submitScaleUp' } @@ -49,6 +50,17 @@ YUI.add('scale-up-view', function(Y) { }, /** + This prevents the placement forms from submitting without the user + clicking the Confirm button manually. + + @method _preventFormSubmit + @param {Object} e Submit event facade. + */ + _preventFormSubmit: function(e) { + e.preventDefault(); + }, + + /** Updates the state class on the viewlet templates container. See scale-up.less for available classes. @@ -121,6 +133,22 @@ YUI.add('scale-up-view', function(Y) { */ _submitScaleUp: function(e) { e.preventDefault(); + var container = this.get('container'); + var env = this.get('env'); + var type = container.one('input[name="placement"]:checked').get('id'); + var numUnits = container.one('input[name="units-number"]').get('value'); + if (type === 'manually-place') { + env.add_unit( + this.get('serviceId'), numUnits); + } else { + + } + } + + }, { + ATTRS: { + serviceId: {}, + env: {} } }); diff --git a/app/views/viewlets/service-overview.js b/app/views/viewlets/service-overview.js index 62cb4ff..d81f670 100644 --- a/app/views/viewlets/service-overview.js +++ b/app/views/viewlets/service-overview.js @@ -435,7 +435,10 @@ YUI.add('inspector-overview-view', function(Y) { */ _instantiateScaleUp: function() { if (!this.scaleUp) { - this.scaleUp = new ns.ScaleUp(); + this.scaleUp = new ns.ScaleUp({ + env: this.options.env, + serviceId: this.viewletManager.get('model').get('id') + }); } },