Code coverage report for app/views/wizard/step6_view.js

Statements: 91.18% (31 / 34)      Branches: 85.71% (12 / 14)      Functions: 90.91% (10 / 11)      Lines: 91.18% (31 / 34)      Ignored: none     

All files » app/views/wizard/ » step6_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    1                                     1   1                             22                           2 2 2       2 2 2                     5 5   5 15 1   14   10 10 6     4       5       3 3 3 3       2 2       1                                     2 3   2                          
'use strict';
 
;require.register("views/wizard/step6_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.WizardStep6View = App.TableView.extend({
 
    templateName: require('templates/wizard/step6'),
 
    /**
     * Number of visible rows
     * @type {string}
     */
    displayLength: "25",
 
    /**
     * List of hosts
     * @type {object[]}
     */
    content: function () {
      return this.get('controller.hosts');
    }.property('controller.hosts'),
 
    /**
     * Synonym to <code>content</code> in this <code>App.TableView</code>
     * @type {object[]}
     */
    filteredContent: Em.computed.alias('content'),
 
    /**
     * Set <code>label</code> and do <code>loadStep</code>
     * @method didInsertElement
     */
    didInsertElement: function didInsertElement() {
      this.setLabel();
      this.get('controller').loadStep();
      Em.run.next(this, this.adjustColumnWidth);
    },
 
    adjustColumnWidth: function adjustColumnWidth() {
      var table = $('#component_assign_table');
      var columnsCount = this.get('controller.headers.length');
      Iif (table.width() > table.find('tbody').width()) {
        var columnWidth = Math.floor(table.width() / columnsCount);
        table.find("th:not('.freeze'), td:not('.freeze')").width(columnWidth);
      }
    },
 
    /**
     * Set <code>label</code> value
     * @method setLabel
     */
    setLabel: function setLabel() {
      var clients = this.get('controller.content.clients');
      var label = !!clients.length ? Em.I18n.t('installer.step6.body') + Em.I18n.t('installer.step6.body.clientText') : Em.I18n.t('installer.step6.body');
 
      clients.forEach(function (_client) {
        if (clients.length === 1) {
          label = label + ' ' + _client.display_name;
        } else {
          if (_client !== clients[clients.length - 1]) {
            // [clients.length - 1]
            label = label + ' ' + _client.display_name;
            if (_client !== clients[clients.length - 2]) {
              label = label + ',';
            }
          } else {
            label = label + ' ' + Em.I18n.t('and') + ' ' + _client.display_name + '.';
          }
        }
      }, this);
      this.set('label', label);
    },
 
    checkboxClick: function checkboxClick(e) {
      var checkbox = e.context;
      Em.set(checkbox, 'checked', !checkbox.checked);
      this.get('controller').checkCallback(checkbox.component);
      this.get('controller').callValidation();
    },
 
    columnCount: function () {
      var hosts = this.get('controller.hosts');
      return hosts && hosts.length > 0 ? hosts[0].get('checkboxes').length + 1 : 1;
    }.property('controller.hosts.@each.checkboxes')
  });
 
  App.WizardStep6HostView = Em.View.extend({
 
    /**
     * Bound <code>host</code> object
     * @type {object}
     */
    host: null,
 
    'data-qa': 'hostname-block',
 
    classNames: ['freeze'],
 
    tagName: 'td',
 
    /**
     * Create hover-labels for hostName with list of installed master-components
     * @method didInsertElement
     */
    didInsertElement: function didInsertElement() {
      var componentNames = this.get('controller').getMasterComponentsForHost(this.get('host.hostName')).map(function (_component) {
        return App.format.role(_component, false);
      }).join('<br />');
      App.popover(this.$(), {
        title: Em.I18n.t('installer.step6.wizardStep6Host.title').format(this.get('host.hostName')),
        content: '<div data-qa="master-component-popover">' + componentNames + '</div>',
        placement: 'right',
        trigger: 'hover'
      });
    },
 
    willDestroyElement: function willDestroyElement() {
      this.$().popover('destroy');
    }
 
  });
});