You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sr...@apache.org on 2013/12/12 19:59:26 UTC

git commit: AMBARI-4052. Rename config-group dialog should allow only description change also. (Denys Buzhor via srimanth)

Updated Branches:
  refs/heads/trunk 4e41f12f7 -> 83b348880


AMBARI-4052. Rename config-group dialog should allow only description change also. (Denys Buzhor via srimanth)


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

Branch: refs/heads/trunk
Commit: 83b34888031cc58ca921b0d4a5551fe2edf37f0e
Parents: 4e41f12
Author: Srimanth Gunturi <sg...@hortonworks.com>
Authored: Thu Dec 12 10:59:11 2013 -0800
Committer: Srimanth Gunturi <sg...@hortonworks.com>
Committed: Thu Dec 12 10:59:18 2013 -0800

----------------------------------------------------------------------
 .../service/manage_config_groups_controller.js  | 46 ++++++++++++++++----
 1 file changed, 37 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/83b34888/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
index eaae780..0488c1d 100644
--- a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
+++ b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
@@ -295,17 +295,31 @@ App.ManageConfigGroupsController = Em.Controller.extend({
         templateName: require('templates/main/service/new_config_group')
       }),
       configGroupName: "",
+      configGroupDesc: "",
       content: content,
+      isDescriptionDirty: false,
       validate: function () {
         var warningMessage = '';
-        if (self.get('configGroups').mapProperty('name').contains(this.get('configGroupName'))) {
-          warningMessage = Em.I18n.t("config.group.selection.dialog.err.name.exists");
+        var originalGroup = self.get('selectedConfigGroup');
+        if (originalGroup.get('description') !== this.get('configGroupDesc') && !this.get('isDescriptionDirty')) {
+          this.set('isDescriptionDirty', true);
+        }
+        if (originalGroup.get('name') === this.get('configGroupName')) {
+          if (this.get('isDescriptionDirty')) {
+            warningMessage = '';
+          } else {
+            warningMessage = Em.I18n.t("config.group.selection.dialog.err.name.exists");
+          }
+        } else {
+          if (self.get('configGroups').mapProperty('name').contains(this.get('configGroupName'))) {
+            warningMessage = Em.I18n.t("config.group.selection.dialog.err.name.exists");
+          }
         }
         this.set('warningMessage', warningMessage);
-      }.observes('configGroupName'),
+      }.observes('configGroupName', 'configGroupDesc'),
       enablePrimary: function () {
         return this.get('configGroupName').length > 0 && !this.get('warningMessage');
-      }.property('warningMessage', 'configGroupName'),
+      }.property('warningMessage', 'configGroupName', 'configGroupDesc'),
       onPrimary: function () {
         if (!this.get('enablePrimary')) {
           return false;
@@ -544,7 +558,7 @@ App.InstallerManageConfigGroupsController = App.ManageConfigGroupsController.ext
       return;
     }
     var self = this;
-    App.ModalPopup.show({
+    this.renameGroupPopup = App.ModalPopup.show({
       primary: Em.I18n.t('ok'),
       secondary: Em.I18n.t('common.cancel'),
       header: Em.I18n.t('services.service.config_groups.rename_config_group_popup.header'),
@@ -554,16 +568,29 @@ App.InstallerManageConfigGroupsController = App.ManageConfigGroupsController.ext
       configGroupName: self.get('selectedConfigGroup.name'),
       configGroupDesc: self.get('selectedConfigGroup.description'),
       warningMessage: '',
+      isDescriptionDirty: false,
       validate: function () {
         var warningMessage = '';
-        if (self.get('configGroups').mapProperty('name').contains(this.get('configGroupName'))) {
-          warningMessage = Em.I18n.t("config.group.selection.dialog.err.name.exists");
+        var originalGroup = self.get('selectedConfigGroup');
+        if (originalGroup.get('description') !== this.get('configGroupDesc') && !this.get('isDescriptionDirty')) {
+          this.set('isDescriptionDirty', true);
+        }
+        if (originalGroup.get('name') === this.get('configGroupName')) {
+          if (this.get('isDescriptionDirty')) {
+            warningMessage = '';
+          } else {
+            warningMessage = Em.I18n.t("config.group.selection.dialog.err.name.exists");
+          }
+        } else {
+          if (self.get('configGroups').mapProperty('name').contains(this.get('configGroupName'))) {
+            warningMessage = Em.I18n.t("config.group.selection.dialog.err.name.exists");
+          }
         }
         this.set('warningMessage', warningMessage);
-      }.observes('configGroupName'),
+      }.observes('configGroupName', 'configGroupDesc'),
       enablePrimary: function () {
         return this.get('configGroupName').length > 0 && !this.get('warningMessage');
-      }.property('warningMessage', 'configGroupName'),
+      }.property('warningMessage', 'configGroupName', 'configGroupDesc'),
       onPrimary: function () {
         if (!this.get('enablePrimary')) {
           return false;
@@ -576,6 +603,7 @@ App.InstallerManageConfigGroupsController = App.ManageConfigGroupsController.ext
         this.hide();
       }
     });
+    this.get('renameGroupPopup').validate();
   },
   /**
    * add new config group