Просмотр исходного кода

AMBARI-8823 Install Wizard Step 5 should have a checkbox for 'Select All' instead of 'all/none' (wangy6 via jaoki)

Jun Aoki 10 лет назад
Родитель
Сommit
de18175ff2

+ 15 - 35
ambari-web/app/controllers/wizard/step4_controller.js

@@ -29,6 +29,21 @@ App.WizardStep4Controller = Em.ArrayController.extend({
    */
   content: [],
 
+  /**
+   * Check / Uncheck 'Select All' checkbox with one argument; Check / Uncheck all other checkboxes with more arguments
+   * @type {bool}
+   */
+  isAllChecked: function(key, value) {
+    if (arguments.length > 1) {
+      this.filterProperty('isInstalled', false).setEach('isSelected', value);
+      return value;
+    } else {
+      return this.filterProperty('isInstalled', false).
+        filterProperty('isHiddenOnSelectServicePage', false).
+        everyProperty('isSelected', true);
+    }
+  }.property('@each.isSelected'),
+
   /**
    * Is Submit button disabled
    * @type {bool}
@@ -45,47 +60,12 @@ App.WizardStep4Controller = Em.ArrayController.extend({
    */
   errorStack: [],
 
-  /**
-   * Check whether all properties are selected
-   * @type {bool}
-   */
-  isAll: function () {
-    return this.filterProperty('isInstalled', false).
-      filterProperty('isHiddenOnSelectServicePage', false).
-      everyProperty('isSelected', true);
-  }.property('@each.isSelected'),
-
-  /**
-   * Check whether none properties(minimum) are selected
-   * @type {bool}
-   */
-  isMinimum: function () {
-    return this.filterProperty('isInstalled', false).
-      filterProperty('isHiddenOnSelectServicePage', false).
-      everyProperty('isSelected', false);
-  }.property('@each.isSelected'),
-
   /**
    * Drop errorStack content on selected state changes.
    **/
   clearErrors: function() {
     this.set('errorStack', []);
   }.observes('@each.isSelected'),
-  /**
-   * Onclick handler for <code>select all</code> link
-   * @method selectAll
-   */
-  selectAll: function () {
-    this.filterProperty('isInstalled', false).setEach('isSelected', true);
-  },
-
-  /**
-   * Onclick handler for <code>select minimum</code> link
-   * @method selectMinimum
-   */
-  selectMinimum: function () {
-    this.filterProperty('isInstalled', false).setEach('isSelected', false);
-  },
 
   /**
    * Check if multiple distributed file systems were selected

+ 5 - 0
ambari-web/app/styles/application.less

@@ -853,6 +853,11 @@ h1 {
     i.icon-asterisks {
       color: #00688B;
     }
+    th {
+      input {
+        margin-right: 5px;
+      }
+    }
   }
   #step6 {
     a.remove-link {

+ 2 - 8
ambari-web/app/templates/wizard/step4.hbs

@@ -25,14 +25,8 @@
   <table class="table table-striped">
     <thead>
     <tr>
-      <th class="span3">{{t common.service}}
-        <span style="margin-left:10px">
-          <a href="#" id="all" {{action selectAll target="controller"}} {{bindAttr
-          class="isAll:selected:deselected"}}>{{t all}}</a>
-           |
-          <a href="#" id="none" {{action selectMinimum target="controller"}} {{bindAttr
-          class="isMinimum:selected:deselected"}}>{{t none}}</a>
-        </span>
+      <th class="span3">
+          {{view Ember.Checkbox disabledBinding="isInstalled" checkedBinding="isAllChecked"}}{{t common.service}}
       </th>
       <th>{{t common.version}}</th>
       <th>{{t common.description}}</th>

+ 3 - 27
ambari-web/test/controllers/wizard/step4_test.js

@@ -75,40 +75,16 @@ describe('App.WizardStep4Controller', function () {
     });
   });
 
-  describe('#isAll', function () {
+  describe('#isAllChecked', function () {
     it('should return true if all services are selected', function () {
       controller.setEach('isInstalled', false);
       controller.findProperty('serviceName', 'HDFS').set('isSelected', true);
-      expect(controller.get('isAll')).to.equal(true);
+      expect(controller.get('isAllChecked')).to.equal(true);
     });
 
     it('should return false if at least one service is not selected', function () {
       controller.findProperty('serviceName', 'HDFS').set('isSelected', false);
-      expect(controller.get('isAll')).to.equal(false);
-    });
-  });
-
-  describe('#isMinimum', function () {
-    it('should return true if there are no services selected, except disabled', function () {
-      controller.setEach('isSelected', false);
-      expect(controller.get('isMinimum')).to.equal(true);
-    });
-  });
-
-  describe('#selectAll()', function () {
-    it('should select all services', function () {
-      controller.setEach('isSelected', false);
-      controller.selectAll();
-      expect(controller.filterProperty('canBeSelected', true).everyProperty('isSelected', true)).to.equal(true);
-    });
-  });
-
-  describe('#selectMinimum()', function () {
-    it('should set isSelected false for all services', function () {
-      controller.setEach('isSelected', true);
-      controller.selectMinimum();
-      expect(controller.findProperty('serviceName', 'HDFS').get('isSelected')).to.equal(false);
-      expect(controller.filterProperty('isDisabled', false).everyProperty('isSelected', false)).to.equal(true);
+      expect(controller.get('isAllChecked')).to.equal(false);
     });
   });