Author: yusaku
Date: Sat Mar 23 04:47:11 2013
New Revision: 1460097

URL: http://svn.apache.org/r1460097
Log:
AMBARI-1661. For custom advanced properties, a new config with an empty key can 
be added. (yusaku)

Modified:
    incubator/ambari/trunk/CHANGES.txt
    
incubator/ambari/trunk/ambari-web/app/templates/common/configs/addPropertyWindow.hbs
    
incubator/ambari/trunk/ambari-web/app/views/common/configs/services_config.js

Modified: incubator/ambari/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1460097&r1=1460096&r2=1460097&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Sat Mar 23 04:47:11 2013
@@ -513,6 +513,9 @@ Trunk (unreleased changes):
 
  BUG FIXES
 
+ AMBARI-1661. For custom advanced properties, a new config with an empty key
+ can be added. (yusaku)
+
  AMBARI-1659. Arrows often do not show up on config category expander. (yusaku)
 
  AMBARI-1645. Undo should not be allowed on component hosts. (yusaku)

Modified: 
incubator/ambari/trunk/ambari-web/app/templates/common/configs/addPropertyWindow.hbs
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/templates/common/configs/addPropertyWindow.hbs?rev=1460097&r1=1460096&r2=1460097&view=diff
==============================================================================
--- 
incubator/ambari/trunk/ambari-web/app/templates/common/configs/addPropertyWindow.hbs
 (original)
+++ 
incubator/ambari/trunk/ambari-web/app/templates/common/configs/addPropertyWindow.hbs
 Sat Mar 23 04:47:11 2013
@@ -22,10 +22,11 @@
         {{view.serviceConfigProperty.filename}}
       </div>
     </div>
-    <div class="each-row">
+    <div {{bindAttr class="view.serviceConfigProperty.isKeyEmpty:error 
:each-row :control-group"}}>
       <label class="control-label">Key</label>
       <div class="controls">
         {{view Ember.TextField valueBinding="view.serviceConfigProperty.name" 
class="span4"}}
+        <span 
class="help-inline">{{view.serviceConfigProperty.errorMessage}}</span>
       </div>
     </div>
     <div class="each-row">

Modified: 
incubator/ambari/trunk/ambari-web/app/views/common/configs/services_config.js
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/views/common/configs/services_config.js?rev=1460097&r1=1460096&r2=1460097&view=diff
==============================================================================
--- 
incubator/ambari/trunk/ambari-web/app/views/common/configs/services_config.js 
(original)
+++ 
incubator/ambari/trunk/ambari-web/app/views/common/configs/services_config.js 
Sat Mar 23 04:47:11 2013
@@ -105,13 +105,24 @@ App.ServiceConfigsByCategoryView = Ember
   },
   showAddPropertyWindow: function (event) {
 
-    var serviceConfigObj = {
+    var serviceConfigObj = Ember.Object.create({
       name: '',
       value: '',
       defaultValue: null,
       filename: '',
-      isUserProperty: true
-    };
+      isUserProperty: true,
+      isKeyEmpty:false,
+      errorMessage:"",
+      observeAddPropertyValue:function(){
+        if(this.get("name").trim() != ""){
+          this.set("isKeyEmpty", false);
+          this.set("errorMessage", "");
+        }else{
+          this.set("isKeyEmpty", true);
+          this.set("errorMessage", 
Em.I18n.t('services.service.config.addPropertyWindow.errorMessage'));
+        }
+      }.observes("name")
+    });
 
     var category = this.get('category');
     serviceConfigObj.displayType = "advanced";
@@ -135,12 +146,20 @@ App.ServiceConfigsByCategoryView = Ember
       primary: 'Add',
       secondary: 'Cancel',
       onPrimary: function () {
-        serviceConfigObj.displayName = serviceConfigObj.name;
-        serviceConfigObj.id = 'site property';
-        serviceConfigObj.serviceName = serviceName;
-        var serviceConfigProperty = 
App.ServiceConfigProperty.create(serviceConfigObj);
-        self.get('serviceConfigs').pushObject(serviceConfigProperty);
-        this.hide();
+        /**
+         * For the first entrance use this if (serviceConfigObj.name.trim() != 
"")
+         */
+        if(!serviceConfigObj.isKeyEmpty && serviceConfigObj.name.trim() != ""){
+          serviceConfigObj.displayName = serviceConfigObj.name;
+          serviceConfigObj.id = 'site property';
+          serviceConfigObj.serviceName = serviceName;
+          var serviceConfigProperty = 
App.ServiceConfigProperty.create(serviceConfigObj);
+          self.get('serviceConfigs').pushObject(serviceConfigProperty);
+          this.hide();
+        }else{
+          serviceConfigObj.set("isKeyEmpty", true);
+          serviceConfigObj.set("errorMessage", 
Em.I18n.t('services.service.config.addPropertyWindow.errorMessage'));
+        }
       },
       onSecondary: function () {
         this.hide();


Reply via email to