<commit_before>ManageIQ.angular.app.component('mainCustomButtonFormComponent', {
  bindings: {
    genericObjectDefinitionRecordId: '@?',
    customButtonGroupRecordId: '@?',
    customButtonRecordId: '@?',
    redirectUrl: '@',
  },
  controllerAs: 'vm',
  controller: mainCustomButtonFormController,
  templateUrl: '/static/generic_object/main_custom_button_form.html.haml',
});

mainCustomButtonFormController.$inject = ['API', 'miqService', '$q', '$http'];

function mainCustomButtonFormController(API, miqService, $q, $http) {
  var vm = this;

  var optionsPromise = null;
  var serviceDialogsPromise = null;
  var rolesPromise = null;
  var instancesPromise = null;

  vm.$onInit = function() {
    vm.entity = __('Custom Button');
    vm.saveable = miqService.saveable;
    vm.afterGet = false;

    vm.customButtonModel = {
      button_type: 'default',
      name: '',
      description: '',
      display: true,
      button_icon: '',
      button_color: '#4d5258',
      options: {},
      resource_action: {},
      visibility: {},
      dialog_id: undefined,
      open_url: false,
      display_for: 'single',
      submit_how: 'one',
      ae_instance: 'Request',
      ae_message: 'create',
      request: '',
      roles: ['_ALL_'],
      attribute_names: [],
      attribute_values: [],
      attributeValuesTableChanged: false,
      current_visibility: 'all',
      available_roles: [],
    };

    vm.dialogs = [];
    vm.button_types = [];
    vm.ae_instances = [];

    vm.attributeValueTableHeaders = [__("Name"), __("Value")];

    vm.display_for = [
      {id: 'single', name: __('Single Entity')},
      {id: 'list', name: __('List')},
      {id: 'both', name: __('Single and List')},
    ];

    vm.submit_how = [
      {id: 'all', name: __('Submit all')},
      {id: 'one', name: __('One by one')},
    ];

    vm.visibilities = [
      {id: 'all', name: __('<To All>')},
      {id: 'role', name: __('<By Role>')},
    ];

    miqService.sparkleOn();
    optionsPromise = API.options('/api/custom_buttons')
      .then(getCustomButtonOptions)
      .catch(miqService.handleFailure);

    serviceDialogsPromise = API.get('/api/service_dialogs?expand=resources&attributes=label')
      .then(getServiceDialogs)
      .catch(miqService.handleFailure);

    rolesPromise = API.get('/api/roles?expand=resources&attributes=name')
      .then(getRoles)
      .catch(miqService.handleFailure);

    instancesPromise = $http.get('/generic_object_definition/retrieve_distinct_instances_across_domains')<commit_msg>Apply gettext inside angle brackets <><commit_after>ManageIQ.angular.app.component('mainCustomButtonFormComponent', {
  bindings: {
    genericObjectDefinitionRecordId: '@?',
    customButtonGroupRecordId: '@?',
    customButtonRecordId: '@?',
    redirectUrl: '@',
  },
  controllerAs: 'vm',
  controller: mainCustomButtonFormController,
  templateUrl: '/static/generic_object/main_custom_button_form.html.haml',
});

mainCustomButtonFormController.$inject = ['API', 'miqService', '$q', '$http'];

function mainCustomButtonFormController(API, miqService, $q, $http) {
  var vm = this;

  var optionsPromise = null;
  var serviceDialogsPromise = null;
  var rolesPromise = null;
  var instancesPromise = null;

  vm.$onInit = function() {
    vm.entity = __('Custom Button');
    vm.saveable = miqService.saveable;
    vm.afterGet = false;

    vm.customButtonModel = {
      button_type: 'default',
      name: '',
      description: '',
      display: true,
      button_icon: '',
      button_color: '#4d5258',
      options: {},
      resource_action: {},
      visibility: {},
      dialog_id: undefined,
      open_url: false,
      display_for: 'single',
      submit_how: 'one',
      ae_instance: 'Request',
      ae_message: 'create',
      request: '',
      roles: ['_ALL_'],
      attribute_names: [],
      attribute_values: [],
      attributeValuesTableChanged: false,
      current_visibility: 'all',
      available_roles: [],
    };

    vm.dialogs = [];
    vm.button_types = [];
    vm.ae_instances = [];

    vm.attributeValueTableHeaders = [__("Name"), __("Value")];

    vm.display_for = [
      {id: 'single', name: __('Single Entity')},
      {id: 'list', name: __('List')},
      {id: 'both', name: __('Single and List')},
    ];

    vm.submit_how = [
      {id: 'all', name: __('Submit all')},
      {id: 'one', name: __('One by one')},
    ];

    vm.visibilities = [
      {id: 'all', name: '<' + __('To All') + '>'},
      {id: 'role', name: '<' + __('By Role') + '>'},
    ];

    miqService.sparkleOn();
    optionsPromise = API.options('/api/custom_buttons')
      .then(getCustomButtonOptions)
      .catch(miqService.handleFailure);

    serviceDialogsPromise = API.get('/api/service_dialogs?expand=resources&attributes=label')
      .then(getServiceDialogs)
      .catch(miqService.handleFailure);

    rolesPromise = API.get('/api/roles?expand=resources&attributes=name')
      .then(getRoles)
      .catch(miqService.handleFailure);

    instancesPromise = $http.get('/generic_object_definition/retrieve_distinct_instances_across_domains')
{'fraction_non_alphanumeric': 0.15998435360844906, 'fraction_numerical': 0.0019557989438685705, 'mean_word_length': 3.363481228668942, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '380242', 'n_tokens_mistral': 1643, 'n_tokens_neox': 1606, 'n_words': 286}