<commit_before><template>
  <div>
    <e-select v-model="optionsScheduleEntry" :items="scheduleEntries" />
  </div>
</template>

<script>
export default {
  name: 'ActivityConfig',
  props: {
    value: { type: Object, required: true },
    camp: { type: Object, required: true },
  },
  data() {
    return {}
  },
  computed: {
    options: {
      get() {
        return this.value
      },
      set(v) {
        this.$emit('input', v)
      },
    },
    optionsScheduleEntry: {
      get() {
        return {
          activity: this.options.activity,
          scheduleEntry: this.options.scheduleEntry,
        }
      },
      set(val) {
        this.options.activity = val.activity
        this.options.scheduleEntry = val.scheduleEntry
      },
    },
    scheduleEntries() {
      let scheduleEntries = []

      this.camp.periods().items.forEach((p) => {
        const periodScheduleEntries = p.scheduleEntries().items.map((se) => ({
          value: { activity: se.activity()._meta.self, scheduleEntry: se._meta.self },
          text: '(' + se.number + ') ' + se.activity().title,
        }))
        scheduleEntries = [...scheduleEntries, ...periodScheduleEntries]
      })

      return scheduleEntries
    },
  },
  defaultOptions() {
    return {
      activity: null,
      scheduleEntry: null,
    }
  },<commit_msg>Fix n+1 query when adding single activity to print config<commit_after><template>
  <div>
    <e-select v-if="!loading" v-model="optionsScheduleEntry" :items="scheduleEntries" />
    <v-skeleton-loader v-else type="image" height="56" />
  </div>
</template>

<script>
export default {
  name: 'ActivityConfig',
  props: {
    value: { type: Object, required: true },
    camp: { type: Object, required: true },
  },
  computed: {
    options: {
      get() {
        return this.value
      },
      set(v) {
        this.$emit('input', v)
      },
    },
    optionsScheduleEntry: {
      get() {
        return {
          activity: this.options.activity,
          scheduleEntry: this.options.scheduleEntry,
        }
      },
      set(val) {
        this.options.activity = val.activity
        this.options.scheduleEntry = val.scheduleEntry
      },
    },
    scheduleEntries() {
      let scheduleEntries = []

      this.camp.periods().items.forEach((p) => {
        const periodScheduleEntries = p.scheduleEntries().items.map((se) => ({
          value: { activity: se.activity()._meta.self, scheduleEntry: se._meta.self },
          text: '(' + se.number + ') ' + se.activity().title,
        }))
        scheduleEntries = [...scheduleEntries, ...periodScheduleEntries]
      })

      return scheduleEntries
    },
    loading() {
      return [
        this.camp.activities(),
        ...this.camp.periods().items.map((period) => period.scheduleEntries()),
      ].some((entity) => entity._meta.loading)
    },
  },
  defaultOptions() {
    return {
      activity: null,
      scheduleEntry: null,
    }
  },
{'fraction_non_alphanumeric': 0.15511997296383914, 'fraction_numerical': 0.001013856032443393, 'mean_word_length': 2.172561629153269, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 22, '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': '4149845', 'n_tokens_mistral': 874, 'n_tokens_neox': 870, 'n_words': 161}