You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2015/06/06 16:41:39 UTC

ambari git commit: AMBARI-11756. JS-error on override Time Interval Widget (onechiporenko)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 c53f3d09b -> aaca0a853


AMBARI-11756. JS-error on override Time Interval Widget (onechiporenko)


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

Branch: refs/heads/branch-2.1
Commit: aaca0a853da8b2d482cb7961c58c6a78941a454c
Parents: c53f3d0
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Sat Jun 6 17:29:58 2015 +0300
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Sat Jun 6 17:41:23 2015 +0300

----------------------------------------------------------------------
 .../widgets/time_interval_spinner_view.js        | 19 +++++++++----------
 .../widgets/time_interval_spinner_view_test.js   | 13 ++++++++++++-
 2 files changed, 21 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/aaca0a85/ambari-web/app/views/common/configs/widgets/time_interval_spinner_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/widgets/time_interval_spinner_view.js b/ambari-web/app/views/common/configs/widgets/time_interval_spinner_view.js
index aa5fb24..03cf16b 100644
--- a/ambari-web/app/views/common/configs/widgets/time_interval_spinner_view.js
+++ b/ambari-web/app/views/common/configs/widgets/time_interval_spinner_view.js
@@ -56,7 +56,9 @@ App.TimeIntervalSpinnerView = App.ConfigWidgetView.extend({
    * @property maxValue
    * @type {Object[]}
    */
-  maxValue: null,
+  maxValue: function() {
+    return this.generateWidgetValue(this.get('config.stackConfigProperty.valueAttributes.maximum'));
+  }.property('config.stackConfigProperty.valueAttributes.maximum'),
 
   /**
    * Minimum property value in widget format.
@@ -64,7 +66,11 @@ App.TimeIntervalSpinnerView = App.ConfigWidgetView.extend({
    * @property minValue
    * @type {Object[]}
    */
-  minValue: null,
+  minValue: function() {
+    return this.generateWidgetValue(this.get('config.stackConfigProperty.valueAttributes.minimum'));
+  }.property('config.stackConfigProperty.valueAttributes.minimum'),
+
+  propertyUnitBinding: 'config.stackConfigProperty.valueAttributes.unit',
 
   /**
    * @TODO move it to unit conversion view mixin?
@@ -83,7 +89,7 @@ App.TimeIntervalSpinnerView = App.ConfigWidgetView.extend({
 
   didInsertElement: function () {
     this._super();
-    Em.run.once(this, 'prepareContent');
+    this.prepareContent();
     this.toggleWidgetState();
     this.initPopover();
   },
@@ -91,19 +97,12 @@ App.TimeIntervalSpinnerView = App.ConfigWidgetView.extend({
   /**
    * Content setter.
    * Affects to view attributes:
-   *  @see propertyUnit
    *  @see savedValue
-   *  @see minValue
-   *  @see maxValue
    *       content
    * @method prepareContent
    */
   prepareContent: function() {
     var property = this.get('config');
-
-    this.set('propertyUnit', property.get('stackConfigProperty.valueAttributes.unit'));
-    this.set('minValue', this.generateWidgetValue(property.get('stackConfigProperty.valueAttributes.minimum')));
-    this.set('maxValue', this.generateWidgetValue(property.get('stackConfigProperty.valueAttributes.maximum')));
     this.setValue(!isNaN(parseInt(property.get('value'))) ? property.get('value') : 0);
     this.parseIncrement();
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaca0a85/ambari-web/test/views/common/configs/widgets/time_interval_spinner_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/widgets/time_interval_spinner_view_test.js b/ambari-web/test/views/common/configs/widgets/time_interval_spinner_view_test.js
index e47eb80..a7b81a9 100644
--- a/ambari-web/test/views/common/configs/widgets/time_interval_spinner_view_test.js
+++ b/ambari-web/test/views/common/configs/widgets/time_interval_spinner_view_test.js
@@ -253,7 +253,18 @@ describe('App.TimeIntervalSpinnerView', function () {
 
     beforeEach(function() {
       view.set('config', Em.Object.create({}));
-      stackConfigProperty = App.StackConfigProperty.createRecord({name: 'p1', valueAttributes: {minimum: 1, maximum: 10, increment_step: 4, type: 'int'}});
+      stackConfigProperty = App.StackConfigProperty.createRecord({
+        name: 'p1', valueAttributes: {
+          minimum: 1, maximum: 10, increment_step: 4, type: 'int', unit: 'seconds'
+        },
+        widget: {
+          units: [
+            {
+              'unit-name': 'hours,minutes'
+            }
+          ]
+        }
+      });
       view.set('config.stackConfigProperty', stackConfigProperty);
       view.set('config.isValid', true);
       view.set('maxValue', [{"value":10,"type":"hours","minValue":0,"maxValue":10,"incrementStep":1,"enabled":true},{"value":0,"type":"minutes","minValue":0,"maxValue":59,"incrementStep":1,"enabled":true}]);