ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oleew...@apache.org
Subject [16/50] ambari git commit: AMBARI-20375. Remove duplicate code from wizard menu (onechiporenko)
Date Fri, 10 Mar 2017 20:46:44 GMT
AMBARI-20375. Remove duplicate code from wizard menu (onechiporenko)


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

Branch: refs/heads/branch-dev-logsearch
Commit: c3c3422e51c58c6e9ec3affd492f28a26499dc1e
Parents: af69dcc
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Thu Mar 9 14:03:11 2017 +0200
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Thu Mar 9 16:41:51 2017 +0200

----------------------------------------------------------------------
 .../app/mixins/wizard/wizard_menu_view.js       | 125 ++++++-------------
 .../app/views/main/service/reassign_view.js     |  32 -----
 2 files changed, 38 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c3c3422e/ambari-web/app/mixins/wizard/wizard_menu_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/wizard/wizard_menu_view.js b/ambari-web/app/mixins/wizard/wizard_menu_view.js
index 90b7354..712263e 100644
--- a/ambari-web/app/mixins/wizard/wizard_menu_view.js
+++ b/ambari-web/app/mixins/wizard/wizard_menu_view.js
@@ -16,101 +16,52 @@
  * limitations under the License.
  */
 
-
 var App = require('app');
 
+function isStepDisabled(index) {
+  return Em.computed('controller.isStepDisabled.@each.{step,value}', function () {
+    return this.isStepDisabled(index);
+  }).cacheable();
+}
+
+function isStepCompleted(index) {
+  return Em.computed('controller.{currentStep,isStepDisabled.@each.value}', function () {
+    return this.isStepCompleted(index);
+  }).cacheable();
+}
+
 App.WizardMenuMixin = Em.Mixin.create({
 
   isStepDisabled: function (index) {
     return this.get('controller.isStepDisabled').findProperty('step', index).get('value');
   },
 
-  isStep0Disabled: function () {
-    return this.isStepDisabled(0);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep1Disabled: function () {
-    return this.isStepDisabled(1);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep2Disabled: function () {
-    return this.isStepDisabled(2);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep3Disabled: function () {
-    return this.isStepDisabled(3);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep4Disabled: function () {
-    return this.isStepDisabled(4);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep5Disabled: function () {
-    return this.isStepDisabled(5);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep6Disabled: function () {
-    return this.isStepDisabled(6);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep7Disabled: function () {
-    return this.isStepDisabled(7);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep8Disabled: function () {
-    return this.isStepDisabled(8);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep9Disabled: function () {
-    return this.isStepDisabled(9);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep10Disabled: function () {
-    return this.isStepDisabled(10);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep0Completed: function () {
-    return this.get('controller.currentStep') > 0;
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep1Completed: function () {
-    return this.get('controller.currentStep') > 1;
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep2Completed: function () {
-    return this.get('controller.currentStep') > 2;
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep3Completed: function () {
-    return this.get('controller.currentStep') > 3;
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep4Completed: function () {
-    return this.get('controller.currentStep') > 4;
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep5Completed: function () {
-    return this.get('controller.currentStep') > 5;
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep6Completed: function () {
-    return this.get('controller.currentStep') > 6;
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep7Completed: function () {
-    return this.get('controller.currentStep') > 7;
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep8Completed: function () {
-    return this.get('controller.currentStep') > 8;
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep9Completed: function () {
-    return this.get('controller.currentStep') > 9;
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
+  isStepCompleted(index) {
+    return this.get('controller.currentStep') > index;
+  },
 
-  isStep10Completed: function () {
-    return this.get('controller.currentStep') > 10;
-  }.property('controller.isStepDisabled.@each.value').cacheable()
+  isStep0Disabled: isStepDisabled(0),
+  isStep1Disabled: isStepDisabled(1),
+  isStep2Disabled: isStepDisabled(2),
+  isStep3Disabled: isStepDisabled(3),
+  isStep4Disabled: isStepDisabled(4),
+  isStep5Disabled: isStepDisabled(5),
+  isStep6Disabled: isStepDisabled(6),
+  isStep7Disabled: isStepDisabled(7),
+  isStep8Disabled: isStepDisabled(8),
+  isStep9Disabled: isStepDisabled(9),
+  isStep10Disabled: isStepDisabled(10),
+
+  isStep0Completed: isStepCompleted(0),
+  isStep1Completed: isStepCompleted(1),
+  isStep2Completed: isStepCompleted(2),
+  isStep3Completed: isStepCompleted(3),
+  isStep4Completed: isStepCompleted(4),
+  isStep5Completed: isStepCompleted(5),
+  isStep6Completed: isStepCompleted(6),
+  isStep7Completed: isStepCompleted(7),
+  isStep8Completed: isStepCompleted(8),
+  isStep9Completed: isStepCompleted(9),
+  isStep10Completed: isStepCompleted(10)
 
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/c3c3422e/ambari-web/app/views/main/service/reassign_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/reassign_view.js b/ambari-web/app/views/main/service/reassign_view.js
index 4adbf11..6885726 100644
--- a/ambari-web/app/views/main/service/reassign_view.js
+++ b/ambari-web/app/views/main/service/reassign_view.js
@@ -23,38 +23,6 @@ App.ReassignMasterView = Em.View.extend(App.WizardMenuMixin, {
 
   templateName: require('templates/main/service/reassign'),
 
-  isStep1Disabled: function () {
-    return this.isStepDisabled(1);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep2Disabled: function () {
-    return this.isStepDisabled(2);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep3Disabled: function () {
-    return this.isStepDisabled(3);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep4Disabled: function () {
-    return this.isStepDisabled(4);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep5Disabled: function () {
-    return this.isStepDisabled(5);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep6Disabled: function () {
-    return this.isStepDisabled(6);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep7Disabled: function () {
-    return this.isStepDisabled(7);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStepDisabled: function (index) {
-    return this.get('controller.isStepDisabled').findProperty('step', index).get('value');
-  },
-
   isLoaded: false,
 
   willInsertElement: function() {


Mime
View raw message