Code coverage report for app/views/main/service/manage_config_groups_view.js

Statements: 96.43% (27 / 28)      Branches: 83.33% (10 / 12)      Functions: 100% (9 / 9)      Lines: 100% (27 / 27)      Ignored: none     

All files » app/views/main/service/ » manage_config_groups_view.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153    1                                     1   1                                                                                                                             3 3 1   2         3       1 1       3 3 3 3 3                 10 10 10 10                   5   5 4   5 1   5               2 2          
'use strict';
 
;require.register("views/main/service/manage_config_groups_view", function (exports, require, module) {
  /**
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements.  See the NOTICE file
   * distributed with this work for additional information
   * regarding copyright ownership.  The ASF licenses this file
   * to you under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in compliance
   * with the License.  You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
 
  var App = require('app');
 
  App.MainServiceManageConfigGroupView = Em.View.extend({
 
    templateName: require('templates/main/service/manage_configuration_groups_popup'),
 
    /**
     * Select Config Group
     * @type {App.ConfigGroup}
     */
    selectedConfigGroup: null,
 
    /**
     * Determines if "Delete Config Group" button is disabled
     * @type {boolean}
     */
    isRemoveButtonDisabled: true,
 
    /**
     * Determines if "Rename Config Group" button is disabled
     * @type {boolean}
     */
    isRenameButtonDisabled: true,
 
    /**
     * Determines if "Duplicate Config Group" button is disabled
     * @type {boolean}
     */
    isDuplicateButtonDisabled: true,
 
    /**
     * Tooltip for "Add Config Group" button
     * @type {string}
     */
    addButtonTooltip: Em.I18n.t('services.service.config_groups_popup.addButton'),
 
    /**
     * Tooltip for "Remove Config Group" button
     * @type {string}
     */
    removeButtonTooltip: Em.I18n.t('services.service.config_groups_popup.removeButton'),
 
    /**
     * Tooltip for "Rename Config Group" button
     * @type {string}
     */
    renameButtonTooltip: Em.I18n.t('services.service.config_groups_popup.renameButton'),
 
    /**
     * Tooltip for "Duplicate Config Group" button
     * @type {string}
     */
    duplicateButtonTooltip: Em.I18n.t('services.service.config_groups_popup.duplicateButton'),
 
    /**
     * Tooltip for "Remove Host From Config Group" button
     * @type {string}
     */
    removeHostTooltip: Em.I18n.t('services.service.config_groups_popup.removeHost'),
 
    /**
     * Tooltip for "Add Host To Config Group" button
     * @type {string}
     */
    addHostTooltip: function () {
      var selectedConfigGroup = this.get('controller.selectedConfigGroup');
      if (!selectedConfigGroup.get('isDefault') && selectedConfigGroup.get('isAddHostsDisabled')) {
        return Em.I18n.t('services.service.config_groups_popup.addHostDisabled');
      } else {
        return Em.I18n.t('services.service.config_groups_popup.addHost');
      }
    }.property('controller.selectedConfigGroup.isDefault', 'controller.selectedConfigGroup.isAddHostsDisabled'),
 
    willInsertElement: function willInsertElement() {
      this.get('controller').loadHosts();
    },
 
    willDestroyElement: function willDestroyElement() {
      this.get('controller.configGroups').clear();
      this.get('controller.originalConfigGroups').clear();
    },
 
    showTooltip: function () {
      Iif (!this.get('controller.isLoaded')) return false;
      Em.run.next(function () {
        App.tooltip($('.properties-link'), { html: true });
        App.tooltip($("[rel='button-info']"));
        App.tooltip($("[rel='button-info-dropdown']"), { placement: 'left' });
      });
    }.observes('controller.isLoaded'),
 
    /**
     * Disable actions remove and rename for Default config group
     * @method buttonObserver
     */
    buttonObserver: function () {
      var selectedConfigGroup = this.get('controller.selectedConfigGroup');
      this.set('isRemoveButtonDisabled', selectedConfigGroup.get('isDefault'));
      this.set('isRenameButtonDisabled', selectedConfigGroup.get('isDefault'));
      this.set('isDuplicateButtonDisabled', false);
    }.observes('controller.selectedConfigGroup'),
 
    /**
     * Prevent user to select more than 1 config group
     * Select last one of "selected"
     * Clean up <code>controller.selectedHosts</code>
     * @method onGroupSelect
     */
    onGroupSelect: function () {
      var selectedConfigGroup = this.get('selectedConfigGroup');
      // to unable user select more than one config group at a time
      if (selectedConfigGroup.length) {
        this.set('controller.selectedConfigGroup', selectedConfigGroup[selectedConfigGroup.length - 1]);
      }
      if (selectedConfigGroup.length > 1) {
        this.set('selectedConfigGroup', selectedConfigGroup[selectedConfigGroup.length - 1]);
      }
      this.set('controller.selectedHosts', []);
    }.observes('selectedConfigGroup'),
 
    /**
     * Select default config group after all config groups are loaded
     * @method selectDefaultGroup
     */
    selectDefaultGroup: function () {
      Eif (this.get('controller.isLoaded')) {
        this.set('selectedConfigGroup', [this.get('controller.configGroups').findProperty('isDefault')]);
      }
    }.observes('controller.isLoaded', 'controller.groupDeleteTrigger')
 
  });
});