<commit_before>var ACTIVE_LOCALE = window.ACTIVE_LOCALE;
var Polyglot = require('node-polyglot');
var Locale = require('../../../../../locale/index');
var polyglot = new Polyglot({
  locale: ACTIVE_LOCALE, // Needed for pluralize behaviour
  phrases: Locale[ACTIVE_LOCALE]
});

var _t = polyglot.t.bind(polyglot);

/*
 *  Dictionary that contains all the necessary components
 *  for the styles form
 */

function getSchema (querySchemaModel, filterFunction) {
  var columnsCollection = querySchemaModel.columnsCollection;
  if (filterFunction) {
    columnsCollection = columnsCollection[filterFunction];
  }
  return columnsCollection
    .map(function (m) {
      var columnName = m.get('name');
      return {
        val: columnName,
        label: columnName
      };
    });
}

function generateColumnsSchema (componentName, querySchemaModel, filterFunction) {
  var queryStatus = querySchemaModel.get('status');
  var isDisabled = queryStatus !== 'fetched';
  var helpMessage = _t('editor.style.components.' + componentName + '.' + queryStatus);

  return {
    type: 'Select',
    title: _t('editor.style.components.' + componentName + '.label'),
    help: isDisabled ? helpMessage : '',
    options: getSchema(querySchemaModel, filterFunction),
    editorAttrs: { disabled: isDisabled },
    validators: ['required']
  };
}

module.exports = {

  'labels-enabled': function () {
    return {
      type: 'Hidden'
    };
  },

  'labels-attribute': function (querySchemaModel) {
    return generateColumnsSchema('labels-attribute', querySchemaModel);
  },

  'labels-fill': function () {
    return {
      type: 'Fill',
      title: _t('editor.style.components.labels-fill'),
      options: [],
      editorAttrs: {
        size: {
          hidePanes: ['value']
        },
        color: {
          hidePanes: ['value']
        }
      },
      inputs: {
        size: {
          fixed: 10
        },
        color: {
          fixed: '#FFF'
        }
      },
      validators: ['required']
    };
  },

  // 'labels-halo': {
  //   type: 'Fill',
  //   title: _t('editor.style.components.labels-halo')<commit_msg>Added labels fill component<commit_after>var ACTIVE_LOCALE = window.ACTIVE_LOCALE;
var Polyglot = require('node-polyglot');
var Locale = require('../../../../../locale/index');
var polyglot = new Polyglot({
  locale: ACTIVE_LOCALE, // Needed for pluralize behaviour
  phrases: Locale[ACTIVE_LOCALE]
});

var _t = polyglot.t.bind(polyglot);

/*
 *  Dictionary that contains all the necessary components
 *  for the styles form
 */

function getSchema (querySchemaModel, filterFunction) {
  var columnsCollection = querySchemaModel.columnsCollection;
  if (filterFunction) {
    columnsCollection = columnsCollection[filterFunction];
  }
  return columnsCollection
    .map(function (m) {
      var columnName = m.get('name');
      return {
        val: columnName,
        label: columnName
      };
    });
}

function generateColumnsSchema (componentName, querySchemaModel, filterFunction) {
  var queryStatus = querySchemaModel.get('status');
  var isDisabled = queryStatus !== 'fetched';
  var helpMessage = _t('editor.style.components.' + componentName + '.' + queryStatus);

  return {
    type: 'Select',
    title: _t('editor.style.components.' + componentName + '.label'),
    help: isDisabled ? helpMessage : '',
    options: getSchema(querySchemaModel, filterFunction),
    editorAttrs: { disabled: isDisabled },
    validators: ['required']
  };
}

module.exports = {

  'labels-enabled': function () {
    return {
      type: 'Hidden'
    };
  },

  'labels-attribute': function (querySchemaModel) {
    return generateColumnsSchema('labels-attribute', querySchemaModel);
  },

  'labels-fill': function () {
    return {
      type: 'Fill',
      title: _t('editor.style.components.labels-fill'),
      options: [],
      editorAttrs: {
        size: {
          hidePanes: ['value']
        },
        color: {
          hidePanes: ['value']
        }
      },
      // inputs: {
      //   size: {
      //     fixed: 10
      //   },
      //   color: {
      //     fixed: '#FFF'
      //   }
      // },
      validators: ['required']
    };
  },

  // 'labels-halo': {
  //   type: 'Fill',
  //   title: _t('editor.style.components.labels-halo')
{'fraction_non_alphanumeric': 0.14531904983698182, 'fraction_numerical': 0.0009315323707498836, 'mean_word_length': 2.6898625429553267, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7492310', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1277, 'n_words': 270}