/*!
    Copyright (C) 2017 Google Inc.
    Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
*/

(function (can, GGRC) {
  'use strict';

  GGRC.Components('mappingTypeSelector', {
    tag: 'mapping-type-selector',
    template: can.view(
      GGRC.mustache_path +
      '/components/mapping-controls/mapping-type-selector.mustache'
    ),
    scope: {
      disabled: false,
      readonly: false,
      types: [],
      selectedType: ''
    },
    events: {
      init: function () {
        // We might need to add some specific logic for disabled/enable DropDown items
      }
    }
  });
})(window.can, window.GGRC);

/*!
    Copyright (C) 2017 Google Inc.
    Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
*/

(function (can, GGRC) {
  'use strict';

  GGRC.Components('mappingTypeSelector', {
    tag: 'mapping-type-selector',
    template: can.view(
      GGRC.mustache_path +
      '/components/mapping-controls/mapping-type-selector.mustache'
    ),
    viewModel: {
      disabled: false,
      readonly: false,
      types: [],
      selectedType: ''
    },
    init: function () {
      var selectedType = this.viewModel.selectedType;
      var types = this.viewModel.types;
      var groups = ['business', 'entities', 'governance'];
      var values = [];

      groups.forEach(function (name) {
        var groupItems = types.attr(name + '.items');
        values = values.concat(_.pluck(groupItems, 'value'));
      });
      if (values.indexOf(selectedType) < 0) {
        this.viewModel.attr('selectedType', values[0]);
      }
    }
  });
})(window.can, window.GGRC);

Fix Access Group's Mapper modal
Fix Access Group's Mapper modal
