<commit_before><template>

  <core-modal
    :title="$tr('changeLessonStatusTitle')"
    @cancel="closeModal()"
  >
    <form @submit="updateLessonStatus">
      <k-radio-button
        :label="$tr('activeOption')"
        :radiovalue="true"
        v-model="lessonStatus"
      />
      <k-radio-button
        :label="$tr('inactiveOption')"
        :radiovalue="false"
        v-model="lessonStatus"
      />

      <div class="core-modal-buttons">
        <k-button
          :text="$tr('cancel')"
          appearance="flat-button"
          @click="closeModal()"
        />
        <k-button
          type="submit"
          :text="$tr('save')"
          :primary="true"
        />
      </div>
    </form>
  </core-modal>

</template>


<script>

  import coreModal from 'kolibri.coreVue.components.coreModal';
  import kRadioButton from 'kolibri.coreVue.components.kRadioButton';
  import kButton from 'kolibri.coreVue.components.kButton';
  import { LessonResource } from 'kolibri.resources';

  export default {
    components: {
      coreModal,
      kButton,
      kRadioButton,
    },
    data() {
      return {
        lessonStatus: null,
      };
    },
    computed: {
      statusHasChanged() {
        return this.lessonStatus !== this.lessonIsActive;
      },
    },
    created() {
      this.lessonStatus = this.lessonIsActive;
    },
    methods: {
      closeModal() {
        return this.$emit('cancel');
      },
      updateLessonStatus() {
        // If status has not changed, do nothing
        if (!this.statusHasChanged) {
          return this.closeModal();
        }
        return LessonResource.getModel(this.lessonId).save({
          is_active: this.lessonStatus,
        })
          ._promise
          .then(lesson => this.updateCurrentLesson(lesson))
          .then(() => this.closeModal())
          .catch(err => {
            // TODO handle error properly
            console.error(err)
          });
      },
    },
    vuex: {
      getters: {
        lessonId: state => state.pageState.currentLesson.id,
        lessonIsActive: state => state.pageState.currentLesson.is_active,
      },
      actions: {
        updateCurrentLesson(store, lesson) {
          store.dispatch('SET_CURRENT_LESSON', lesson);
        },
      },<commit_msg>Renaming<commit_after><template>

  <core-modal
    :title="$tr('changeLessonStatusTitle')"
    @cancel="closeModal()"
  >
    <form @submit="updateLessonStatus">
      <k-radio-button
        :label="$tr('activeOption')"
        :radiovalue="true"
        v-model="activeIsSelected"
      />
      <k-radio-button
        :label="$tr('inactiveOption')"
        :radiovalue="false"
        v-model="activeIsSelected"
      />

      <div class="core-modal-buttons">
        <k-button
          :text="$tr('cancel')"
          appearance="flat-button"
          @click="closeModal()"
        />
        <k-button
          type="submit"
          :text="$tr('save')"
          :primary="true"
        />
      </div>
    </form>
  </core-modal>

</template>


<script>

  import coreModal from 'kolibri.coreVue.components.coreModal';
  import kRadioButton from 'kolibri.coreVue.components.kRadioButton';
  import kButton from 'kolibri.coreVue.components.kButton';
  import { LessonResource } from 'kolibri.resources';

  export default {
    components: {
      coreModal,
      kButton,
      kRadioButton,
    },
    data() {
      return {
        activeIsSelected: null,
      };
    },
    computed: {
      statusHasChanged() {
        return this.activeIsSelected !== this.currentLessonIsActive;
      },
    },
    created() {
      this.activeIsSelected = this.currentLessonIsActive;
    },
    methods: {
      closeModal() {
        return this.$emit('cancel');
      },
      updateLessonStatus() {
        // If status has not changed, do nothing
        if (!this.statusHasChanged) {
          return this.closeModal();
        }
        return LessonResource.getModel(this.lessonId).save({
          is_active: this.activeIsSelected,
        })
          ._promise
          .then(lesson => this.updateCurrentLesson(lesson))
          .then(() => this.closeModal())
          .catch(err => {
            // TODO handle error properly
            console.error(err)
          });
      },
    },
    vuex: {
      getters: {
        lessonId: state => state.pageState.currentLesson.id,
        currentLessonIsActive: state => state.pageState.currentLesson.is_active,
      },
      actions: {
        updateCurrentLesson(store, lesson) {
          store.dispatch('SET_CURRENT_LESSON', lesson);
        },
      },
{'fraction_non_alphanumeric': 0.1383347788378144, 'fraction_numerical': 0.0, 'mean_word_length': 2.0013012361743656, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 39, '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': '5836501', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1394, 'n_words': 214}