<commit_before>const _ = require('../../../ui-base/_');
const ajax = require('../../../ui-base/ajax');
const Validation = require('../../../util/validation');
const ValidationMixin = require('../../../util/validationMixin');

const template = require('./index.html');

/**
 * @class UIForm
 * @extend Validation
 * @param {object}      [options.data]                    = 绑定属性
 * @param {string}      [options.data.service]            => 全站异步获取source的接口地址
 * @param {string}      [options.data.class]              => 扩展样式
 * @param {boolean}     [options.data.inline='']          => 如果true,kl-form-item按照inline-block排列
 * @param {string}      [options.data.sourcePath=data]    => 获取到select数据后,读取json数据的路径
 * @param {string|number} [options.data.labelSize='']     => 批量设置kl-form-item的labelSize,取值与kl-form-item的labelSize相同
 * @param {string|number} [options.data.labelLineHeight='']  => 批量设置kl-form-item的labelLineHeight,取值与kl-form-item的labelLineHeight相同
 */
const KLForm = Validation.extend({
  name: 'kl-form',
  template,
  selectors: [],
  config(data) {
    _.extend(data, {
      service: null,
      sourcePath: 'data',
      class: '',
    });

    this.supr(data);
  },
  init() {
    this.supr();

    this.initValidation();

    this.$watch('this.controls.length', function () {
      this.initSelectorSource();
      this.initFormItem();
    });
  },
  initFormItem() {
    const {
      controls,
      labelSize,
      labelLineHeight,
    } = this.data;
    labelSize &&
      controls.forEach(($component) => {
        if (!$component.labelSize) {
          $component.$update('labelSize', labelSize);
        }
      });
    labelLineHeight &&
      controls.forEach(($component) => {
        if (!$component.labelLineHeight) {
          $component.$update('labelLineHeight', labelLineHeight);
        }
      });
  },
  initSelectorSource() {
    const controls = this.controls;
    this.selectors = controls.filter($formitem => !!$formitem.data.sourceKey);

    if (!this.data.service || !this.selectors.length) {
      return;<commit_msg>:bug: fix(kl-form): get controls from 'this'<commit_after>const _ = require('../../../ui-base/_');
const ajax = require('../../../ui-base/ajax');
const Validation = require('../../../util/validation');
const ValidationMixin = require('../../../util/validationMixin');

const template = require('./index.html');

/**
 * @class UIForm
 * @extend Validation
 * @param {object}      [options.data]                    = 绑定属性
 * @param {string}      [options.data.service]            => 全站异步获取source的接口地址
 * @param {string}      [options.data.class]              => 扩展样式
 * @param {boolean}     [options.data.inline='']          => 如果true,kl-form-item按照inline-block排列
 * @param {string}      [options.data.sourcePath=data]    => 获取到select数据后,读取json数据的路径
 * @param {string|number} [options.data.labelSize='']     => 批量设置kl-form-item的labelSize,取值与kl-form-item的labelSize相同
 * @param {string|number} [options.data.labelLineHeight='']  => 批量设置kl-form-item的labelLineHeight,取值与kl-form-item的labelLineHeight相同
 */
const KLForm = Validation.extend({
  name: 'kl-form',
  template,
  selectors: [],
  config(data) {
    _.extend(data, {
      service: null,
      sourcePath: 'data',
      class: '',
    });

    this.supr(data);
  },
  init() {
    this.supr();

    this.initValidation();

    this.$watch('this.controls.length', function () {
      this.initSelectorSource();
      this.initFormItem();
    });
  },
  initFormItem() {
    const controls = this.controls;
    const {
      labelSize,
      labelLineHeight,
    } = this.data;
    labelSize &&
      controls.forEach(($component) => {
        if (!$component.labelSize) {
          $component.$update('labelSize', labelSize);
        }
      });
    labelLineHeight &&
      controls.forEach(($component) => {
        if (!$component.labelLineHeight) {
          $component.$update('labelLineHeight', labelLineHeight);
        }
      });
  },
  initSelectorSource() {
    const controls = this.controls;
    this.selectors = controls.filter($formitem => !!$formitem.data.sourceKey);

    if (!this.data.service || !this.selectors.length) {
      return;
{'fraction_non_alphanumeric': 0.17543859649122806, 'fraction_numerical': 0.0, 'mean_word_length': 2.6929902395740903, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '6873397', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1367, 'n_words': 200}