瀏覽代碼

AMBARI-10532 Time interval spinner widget allowing setting of value larger than max. (ababiichuk)

aBabiichuk 10 年之前
父節點
當前提交
f618d5f536

+ 1 - 1
ambari-web/app/messages.js

@@ -2552,7 +2552,7 @@ Em.I18n.translations = {
 
 
   'number.validate.empty': 'cannot be empty',
   'number.validate.empty': 'cannot be empty',
   'number.validate.notValidNumber': 'not a valid number',
   'number.validate.notValidNumber': 'not a valid number',
-  'number.validate.lessThanMinumum': 'value less than {0}',
+  'number.validate.lessThanMinimum': 'value less than {0}',
   'number.validate.moreThanMaximum': 'value greater than {0}',
   'number.validate.moreThanMaximum': 'value greater than {0}',
 
 
   'common.combobox.placeholder': 'Filter...',
   'common.combobox.placeholder': 'Filter...',

+ 4 - 0
ambari-web/app/templates/common/configs/widgets/controls.hbs

@@ -66,6 +66,10 @@
   {{/if}}
   {{/if}}
 {{/if}}
 {{/if}}
 
 
+{{#if view.config.errorMessage}}
+  <p class="text-error">{{view.config.errorMessage}}</p>
+{{/if}}
+
 {{#if view.isComparison}}
 {{#if view.isComparison}}
   <div class="widget-config-controls">
   <div class="widget-config-controls">
   {{#if controller.selectedConfigGroup.isDefault}}
   {{#if controller.selectedConfigGroup.isDefault}}

+ 1 - 1
ambari-web/app/utils/number_utils.js

@@ -77,7 +77,7 @@ module.exports = {
           return Em.I18n.t('number.validate.notValidNumber');
           return Em.I18n.t('number.validate.notValidNumber');
         }
         }
         if (!isNaN(min) && number < min) {
         if (!isNaN(min) && number < min) {
-          return Em.I18n.t('number.validate.lessThanMinumum').format(min);
+          return Em.I18n.t('number.validate.lessThanMinimum').format(min);
         }
         }
         if (!isNaN(max) && number > max) {
         if (!isNaN(max) && number > max) {
           return Em.I18n.t('number.validate.moreThanMaximum').format(max);
           return Em.I18n.t('number.validate.moreThanMaximum').format(max);

+ 6 - 6
ambari-web/app/views/common/configs/widgets/time_interval_spinner_view.js

@@ -155,8 +155,9 @@ App.TimeIntervalSpinnerView = App.ConfigWidgetView.extend({
 
 
   valueObserverCallback: function() {
   valueObserverCallback: function() {
     this.checkModified();
     this.checkModified();
-    this.checkErrors();
     this.setConfigValue();
     this.setConfigValue();
+    this.checkErrors();
+    this.sendRequestRorDependentConfigs(this.get('config'));
   },
   },
 
 
   /**
   /**
@@ -173,9 +174,9 @@ App.TimeIntervalSpinnerView = App.ConfigWidgetView.extend({
    */
    */
   checkErrors: function() {
   checkErrors: function() {
     var convertedValue = this.configValueByWidget(this.get('content'));
     var convertedValue = this.configValueByWidget(this.get('content'));
-    var errorMessage = false;
+    var errorMessage = '';
     if (convertedValue < parseInt(this.get('config.stackConfigProperty.valueAttributes.minimum'))) {
     if (convertedValue < parseInt(this.get('config.stackConfigProperty.valueAttributes.minimum'))) {
-      errorMessage = Em.I18n.t('number.validate.lessThanMinumum').format(this.dateToText(this.get('minValue')));
+      errorMessage = Em.I18n.t('number.validate.lessThanMinimum').format(this.dateToText(this.get('minValue')));
     }
     }
     else if (convertedValue > parseInt(this.get('config.stackConfigProperty.valueAttributes.maximum'))) {
     else if (convertedValue > parseInt(this.get('config.stackConfigProperty.valueAttributes.maximum'))) {
       errorMessage = Em.I18n.t('number.validate.moreThanMaximum').format(this.dateToText(this.get('maxValue')));
       errorMessage = Em.I18n.t('number.validate.moreThanMaximum').format(this.dateToText(this.get('maxValue')));
@@ -184,7 +185,7 @@ App.TimeIntervalSpinnerView = App.ConfigWidgetView.extend({
       isValid: !errorMessage,
       isValid: !errorMessage,
       errorMessage: errorMessage
       errorMessage: errorMessage
     });
     });
-    this.get('config').set('errorMessage', errorMessage);
+    this.set('config.errorMessage', errorMessage);
   },
   },
 
 
   /**
   /**
@@ -192,9 +193,8 @@ App.TimeIntervalSpinnerView = App.ConfigWidgetView.extend({
    * @method setConfigValue
    * @method setConfigValue
    */
    */
   setConfigValue: function() {
   setConfigValue: function() {
-    this.set('config.value', this.configValueByWidget(this.get('content')));
+    this.set('config.value', '' + this.configValueByWidget(this.get('content')));
     this.get('controller').removeCurrentFromDependentList(this.get('config'));
     this.get('controller').removeCurrentFromDependentList(this.get('config'));
-    this.sendRequestRorDependentConfigs(this.get('config'));
   },
   },
 
 
   /**
   /**

+ 2 - 2
ambari-web/test/utils/number_utils_test.js

@@ -233,8 +233,8 @@ describe('utils/number_utils', function() {
         str: "1",
         str: "1",
         min: 2,
         min: 2,
         max: 0,
         max: 0,
-        m: 'try to validate `1` with max = 0 and min = 2 should return ' + Em.I18n.t('number.validate.lessThanMinumum').format(2),
-        e: Em.I18n.t('number.validate.lessThanMinumum').format(2)
+        m: 'try to validate `1` with max = 0 and min = 2 should return ' + Em.I18n.t('number.validate.lessThanMinimum').format(2),
+        e: Em.I18n.t('number.validate.lessThanMinimum').format(2)
       }
       }
     ];
     ];