ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject ambari git commit: AMBARI-11644. Enhanced configs: UNDO button not fully reset property for MapReduce2 (onechiporenko)
Date Wed, 03 Jun 2015 10:30:55 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk cf37e4ce2 -> 1ecc41996


AMBARI-11644. Enhanced configs: UNDO button not fully reset property for MapReduce2 (onechiporenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1ecc4199
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1ecc4199
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1ecc4199

Branch: refs/heads/trunk
Commit: 1ecc4199646a44be91e2f2e3f1705f6a6d81ea8d
Parents: cf37e4c
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Wed Jun 3 13:27:50 2015 +0300
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Wed Jun 3 13:27:50 2015 +0300

----------------------------------------------------------------------
 .../widgets/slider_config_widget_view.js        | 32 +++++++++++++++++---
 1 file changed, 27 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1ecc4199/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js b/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
index d8bc02b..46a0657 100644
--- a/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
+++ b/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
@@ -65,6 +65,12 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
   changeBoundariesProperties: ['maxMirrorValue', 'widgetRecommendedValue','minMirrorValue',
'mirrorStep'],
 
   /**
+   * Flag to check if value should be changed to recommended or saved.
+   * @type {boolean}
+   */
+  isRestoring: false,
+
+  /**
    * max allowed value transformed form config unit to widget unit
    * @type {Number}
    */
@@ -367,11 +373,8 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
      */
     this.set('config.value', correctConfigValue);
 
-    slider.on('change', function (obj) {
-      var val = self.get('mirrorValueParseFunction')(obj.newValue);
-      self.set('config.value', '' + self.configValueByWidget(val));
-      self.set('mirrorValue', val);
-    }).on('slideStop', function() {
+    slider.on('change', this.onSliderChange.bind(this))
+    .on('slideStop', function() {
       /**
        * action to run sendRequestRorDependentConfigs when
        * we have changed config value within slider
@@ -401,6 +404,23 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
   },
 
   /**
+   * Callback function triggered on slider change event.
+   * Set config property and widget value with new one, or ignore changes in case value restoration
executed by
+   * <code>restoreValue</code>, <code>setRecommendedValue</code>.
+   *
+   * @param {Object} e - object that contains <code>oldValue</code> and <code>newValue</code>
attributes.
+   * @method onSliderChange
+   */
+  onSliderChange: function(e) {
+    if (!this.get('isRestoring')) {
+      var val = this.get('mirrorValueParseFunction')(e.newValue);
+      this.set('config.value', '' + this.configValueByWidget(val));
+      this.set('mirrorValue', val);
+    } else {
+      this.set('isRestoring', false);
+    }
+  },
+  /**
    * Convert value according to property attribute unit.
    *
    * @method valueForTick
@@ -424,6 +444,7 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
    */
   restoreValue: function () {
     this._super();
+    this.set('isRestoring', true);
     this.get('slider').setValue(this.get('widgetDefaultValue'));
   },
 
@@ -432,6 +453,7 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
    */
   setRecommendedValue: function () {
     this._super();
+    this.set('isRestoring', true);
     this.get('slider').setValue(this.get('widgetRecommendedValue'));
   },
 


Mime
View raw message