<commit_before><template>
  <div>
    <div class="input-group" style="width: 100%;">
      <span class="input-group-btn" style="vertical-align: top;" v-if="!readonly">
        <button class="btn btn-block" :class="{btn_color: not_autoload_result}" style="white-space: normal;text-align: left;"
                title="Загрузить последний результат"
                @click="loadLast"
                v-tippy="{ placement : 'bottom', arrow: true }">
            <i class="fa fa-circle"/>
        </button>
      </span>
      <textarea :readonly="readonly" :rows="lines" class="form-control"
                :placeholder="title"
                v-tippy="{ placement : 'bottom', arrow: true }" :title="title" v-if="lines > 1" v-model="val"/>
      <input :readonly="readonly" class="form-control"
             :placeholder="title"
             v-tippy="{ placement : 'bottom', arrow: true }" :title="title" v-else v-model="val"/>
    </div>
    <a v-if="direction" class="a-under" href="#" @click.prevent="print_results">
      печать результатов направления {{direction}}
    </a>
  </div>
</template>

<script>
  import researches_point from '../api/researches-point'
  import directions_point from '../api/directions-point'

  export default {
    name: 'SearchFieldValueField',
    props: {
      readonly: {
        type: Boolean
      },
      fieldPk: {
        type: String,
        required: true,
      },
      clientPk: {
        type: Number,
        required: true,
      },
      value: {
        required: false,
      },
      lines: {
        type: Number,
      },
      raw: {
        type: Boolean,
        required: false,
        default: false,
      },
      not_autoload_result: {
        type: Boolean,
        required: false,
        default: false,
      },
      iss_pk: {
        type: Number,
        required: false,
      },
    },
    data() {
      return {
        val: this.value,
        title: '',
        direction: null,
      }
    },
    mounted() {
      if (!this.raw) {
        researches_point.fieldTitle({pk: this.fieldPk}).then(data => {
          const titles = new Set([data.research, data.group, data.field])
          this.title = [...titles].filter(t => !!t).join(' – ')
          this.checkDirection()

          setTimeout(() => {
            if (!this.val && !this.not_autoload_result) {
              this.loadLast()
            }
          }, 200)
        })
      }
      else {
        if (!this.val && !this.not_autoload_result) {
          this.loadLast()
        }
      }
    },
    watch: {
      val() {
        this.changeValue(this.val)
      },
      value() {
        this.val = this.value;
      },
    },
    model: {
      event: 'modified'
    },
    methods: {
      checkDirection() {
        const res = /направление (\d+)\)$/gm.exec(this.val)
        this.direction = !res ? null : parseInt(res[1])
      },
      changeValue(newVal) {
        this.$emit('modified', newVal)
      },
      async loadLast() {
        this.direction = null;
        const {result} = await directions_point.lastFieldResult(this, [
          'fieldPk',
          'clientPk',
          'iss_pk'<commit_msg>fix: ссылочное поле без автозагрузки<commit_after><template>
  <div>
    <div class="input-group" style="width: 100%;">
      <span class="input-group-btn" style="vertical-align: top;" v-if="!readonly">
        <button class="btn btn-block" :class="{btn_color: not_autoload_result}" style="white-space: normal;text-align: left;"
                title="Загрузить последний результат"
                @click="loadLast"
                v-tippy="{ placement : 'bottom', arrow: true }">
            <i class="fa fa-circle"/>
        </button>
      </span>
      <textarea :readonly="readonly" :rows="lines" class="form-control"
                :placeholder="title"
                v-tippy="{ placement : 'bottom', arrow: true }" :title="title" v-if="lines > 1" v-model="val"/>
      <input :readonly="readonly" class="form-control"
             :placeholder="title"
             v-tippy="{ placement : 'bottom', arrow: true }" :title="title" v-else v-model="val"/>
    </div>
    <a v-if="direction" class="a-under" href="#" @click.prevent="print_results">
      печать результатов направления {{direction}}
    </a>
  </div>
</template>

<script>
  import researches_point from '../api/researches-point'
  import directions_point from '../api/directions-point'

  export default {
    name: 'SearchFieldValueField',
    props: {
      readonly: {
        type: Boolean
      },
      fieldPk: {
        type: String,
        required: true,
      },
      clientPk: {
        type: Number,
        required: true,
      },
      value: {
        required: false,
      },
      lines: {
        type: Number,
      },
      raw: {
        type: Boolean,
        required: false,
        default: false,
      },
      not_autoload_result: {
        type: Boolean,
        required: false,
        default: false,
      },
      iss_pk: {
        type: Number,
        required: false,
      },
    },
    data() {
      return {
        val: this.value,
        title: '',
        direction: null,
      }
    },
    mounted() {
      if (!this.raw) {
        researches_point.fieldTitle({pk: this.fieldPk}).then(data => {
          const titles = new Set([data.research, data.group, data.field])
          this.title = [...titles].filter(t => !!t).join(' – ')
          this.checkDirection()

          setTimeout(() => {
            if (!this.val && !this.not_autoload_result) {
              this.loadLast()
            }
          }, 200)
        })
      }
      else {
        if (!this.val && !this.not_autoload_result) {
          this.loadLast()
        }
        else if (this.not_autoload_result){
          this.val = ' '
        }
      }
    },
    watch: {
      val() {
        this.changeValue(this.val)
      },
      value() {
        this.val = this.value;
      },
    },
    model: {
      event: 'modified'
    },
    methods: {
      checkDirection() {
        const res = /направление (\d+)\)$/gm.exec(this.val)
        this.direction = !res ? null : parseInt(res[1])
      },
      changeValue(newVal) {
        this.$emit('modified', newVal)
      },
      async loadLast() {
        this.direction = null;
        const {result} = await directions_point.lastFieldResult(this, [
          'fieldPk',
          'clientPk',
          'iss_pk'
{'fraction_non_alphanumeric': 0.15468409586056645, 'fraction_numerical': 0.0024898848428260194, 'mean_word_length': 1.7858690940615518, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 43, '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': '5706313', 'n_tokens_mistral': 2020, 'n_tokens_neox': 1997, 'n_words': 389}