<commit_before><template>
  <v-expansion-panel-content>
    <h3 class="grey--text">
      {{ dayName }}
    </h3>
    <template v-if="entriesWithStory.length">
      <template v-for="{ scheduleEntry, storyChapters } in entriesWithStory">
        <div v-for="chapter in storyChapters" :key="chapter._meta.uri">
          <h4 class="mt-1 mb-2">
            <div class="d-flex">
              {{ scheduleEntry.number }}
              <v-chip v-if="!scheduleEntry.activity().category()._meta.loading"
                      small
                      dark
                      class="mx-1"
                      :color="scheduleEntry.activity().category().color">
                {{ scheduleEntry.activity().category().short }}
              </v-chip>
              {{ scheduleEntry.activity().title }}
              <template v-if="chapter.contentNode().instanceName">
                - {{ chapter.contentNode().instanceName }}
              </template>
              <v-spacer />
              <router-link :to="{ name: 'activity', params: { campId: day.period().camp().id, scheduleEntryId: scheduleEntry.id } }">
                <v-icon small>mdi-open-in-new</v-icon>
              </router-link>
            </div>
          </h4>
          <api-form v-show="editing"
                    :entity="chapter">
            <api-textarea
              fieldname="text"
              label=""
              auto-grow
              :outlined="false"
              :solo="false"
              dense />
          </api-form>
          <tiptap-editor v-show="!editing"
                         :value="chapter.text"
                         :editable="false"
                         class="mt-1 v-input" />
        </div>
      </template>
    </template>
    <div v-else class="grey--text">
      {{ $tc('components.camp.storyDay.noStory') }}
    </div>
  </v-expansion-panel-content>
</template>
<script>
import { sortBy } from 'lodash'
import ApiForm from '@/components/form/api/ApiForm'
import ApiTextarea from '@/components/form/api/ApiTextarea'
import TiptapEditor from '@/components/form/tiptap/TiptapEditor'

export default {
  name: 'StoryDay',
  components: { TiptapEditor, ApiForm, ApiTextarea },
  props: {
    day: { type: Object, required: true },
    editing: { type: Boolean, default: false }
  },
  computed: {
    dayName () {
      const date = this.addDays(this.day.period().start, this.day.dayOffset)
      return this.$date.utc(date).format(this.$tc('global.datetime.dateLong'))
    },
    sortedScheduleEntries () {
      return sortBy(this.day.scheduleEntries().items, scheduleEntry => scheduleEntry.periodOffset)
    },
    entries () {
      return this.sortedScheduleEntries.map(scheduleEntry => {
        return {
          scheduleEntry: scheduleEntry,
          storyChapters: (scheduleEntry.activity().contentNodes() || { items: [] })
            .items
            .filter(contentNode => contentNode.contentTypeName === 'Storycontext')
            .map(contentNode => contentNode.singleText())
        }
      })
    },
    entriesWithStory () {
      return this.entries.filter(({ storyChapters }) => storyChapters.length)
    }
  },
  methods: {
    addDays (date, days) {
      return Date.parse(date) + days * 24 * 60 * 60 * 1000
    }<commit_msg>Refresh content nodes on entering story overview<commit_after><template>
  <v-expansion-panel-content>
    <h3 class="grey--text">
      {{ dayName }}
    </h3>
    <template v-if="entriesWithStory.length">
      <template v-for="{ scheduleEntry, storyChapters } in entriesWithStory">
        <div v-for="chapter in storyChapters" :key="chapter._meta.uri">
          <h4 class="mt-1 mb-2">
            <div class="d-flex">
              {{ scheduleEntry.number }}
              <v-chip v-if="!scheduleEntry.activity().category()._meta.loading"
                      small
                      dark
                      class="mx-1"
                      :color="scheduleEntry.activity().category().color">
                {{ scheduleEntry.activity().category().short }}
              </v-chip>
              {{ scheduleEntry.activity().title }}
              <template v-if="chapter.contentNode().instanceName">
                - {{ chapter.contentNode().instanceName }}
              </template>
              <v-spacer />
              <router-link :to="{ name: 'activity', params: { campId: day.period().camp().id, scheduleEntryId: scheduleEntry.id } }">
                <v-icon small>mdi-open-in-new</v-icon>
              </router-link>
            </div>
          </h4>
          <api-form v-show="editing"
                    :entity="chapter">
            <api-textarea
              fieldname="text"
              label=""
              auto-grow
              :outlined="false"
              :solo="false"
              dense />
          </api-form>
          <tiptap-editor v-show="!editing"
                         :value="chapter.text"
                         :editable="false"
                         class="mt-1 v-input" />
        </div>
      </template>
    </template>
    <div v-else class="grey--text">
      {{ $tc('components.camp.storyDay.noStory') }}
    </div>
  </v-expansion-panel-content>
</template>
<script>
import { sortBy } from 'lodash'
import ApiForm from '@/components/form/api/ApiForm'
import ApiTextarea from '@/components/form/api/ApiTextarea'
import TiptapEditor from '@/components/form/tiptap/TiptapEditor'

export default {
  name: 'StoryDay',
  components: { TiptapEditor, ApiForm, ApiTextarea },
  props: {
    day: { type: Object, required: true },
    editing: { type: Boolean, default: false }
  },
  computed: {
    dayName () {
      const date = this.addDays(this.day.period().start, this.day.dayOffset)
      return this.$date.utc(date).format(this.$tc('global.datetime.dateLong'))
    },
    sortedScheduleEntries () {
      return sortBy(this.day.scheduleEntries().items, scheduleEntry => scheduleEntry.periodOffset)
    },
    entries () {
      return this.sortedScheduleEntries.map(scheduleEntry => {
        return {
          scheduleEntry: scheduleEntry,
          storyChapters: (scheduleEntry.activity().contentNodes() || { items: [] })
            .items
            .filter(contentNode => contentNode.contentTypeName === 'Storycontext')
            .map(contentNode => contentNode.singleText())
        }
      })
    },
    entriesWithStory () {
      return this.entries.filter(({ storyChapters }) => storyChapters.length)
    }
  },
  mounted () {
    this.day.scheduleEntries().items.map(entry => this.api.reload(entry.activity().contentNodes()))
  },
  methods: {
    addDays (date, days) {
      return Date.parse(date) + days * 24 * 60 * 60 * 1000
    }
{'fraction_non_alphanumeric': 0.1486950037285608, 'fraction_numerical': 0.005369127516778523, 'mean_word_length': 1.9386503067484662, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 78, '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': '7647312', 'n_tokens_mistral': 1967, 'n_tokens_neox': 1889, 'n_words': 329}