<commit_before><template>
  <div class="tipp">
    <div class="tipp__summary box" v-if="!editMode">
      <h2 class="h5">
        <span>{{tipp.user.displayName}}</span>
        <span v-if="tipp.user.email">(<a :href="`mailto:${tipp.user.email}`">{{tipp.user.email}}</a>)</span>
      </h2>
      <p>{{tipp.text}}</p>
      <p>
        <button class="small" @click="deleteTipp">Delete</button>
        <button class="small" @click="toggleEditMode">Edit</button>
      </p>
    </div>
    <div class="tipp__edit-form box" v-if="editMode">
      <p>
        <label for="">Name</label>
        <input type="text" v-model="editTipp.user.displayName">
      </p>
      <p>
        <label for="">Tipp Text</label>
        <textarea class="tipp__text" type="text" v-model="editTipp.text"></textarea>
      </p>
      <p>
        <button class="small" @click="toggleEditMode">Abbräche</button>
        <button class="small" @click="saveTipp">Spichere</button>
      </p>
    </div>
  </div>
</template>

<script>
  import Tipp from '@/models/Tipp';

  export default {
    data() {
      return {
        editMode: false,
        editTipp: null,
      }
    },
    props: {
      tipp: Object,
    },
    methods: {
      toggleEditMode() {
        this.editTipp = new Tipp(this.tipp);
        this.editMode = !this.editMode;
      },
      deleteTipp() {
        return confirm('Wosch würk lösche?') ? this.tipp.remove() : false;
      },
      saveTipp() {
        this.editMode = false;
        return this.editTipp.set();
      }
    },
  };
</script>

<style lang="scss" scoped>
  .tipp__text {
    border: 1px solid black;
    padding: 0.5em;
  }
</style><commit_msg>Add created date<commit_after><template>
  <div class="tipp">
    <div class="tipp__summary box" v-if="!editMode">
      <h2 class="h5">
        <span>{{tipp.user.displayName}}</span>
        <span v-if="tipp.user.email">(<a :href="`mailto:${tipp.user.email}`">{{tipp.user.email}}</a>)</span>
        <br>
        <time class="tipp__created">{{dateFormat(tipp.created)}}</time>
      </h2>
      <p>{{tipp.text}}</p>
      <p>
        <button class="small" @click="deleteTipp">Delete</button>
        <button class="small" @click="toggleEditMode">Edit</button>
      </p>
    </div>
    <div class="tipp__edit-form box" v-if="editMode">
      <p>
        <label for="">Name</label>
        <input type="text" v-model="editTipp.user.displayName">
      </p>
      <p>
        <label for="">Tipp Text</label>
        <textarea class="tipp__text" type="text" v-model="editTipp.text"></textarea>
      </p>
      <p>
        <button class="small" @click="toggleEditMode">Abbräche</button>
        <button class="small" @click="saveTipp">Spichere</button>
      </p>
    </div>
  </div>
</template>

<script>
  import Tipp from '@/models/Tipp';
  import dateFormat from '@/filters/date-format';

  export default {
    data() {
      return {
        editMode: false,
        editTipp: null,
        dateFormat,
      }
    },
    props: {
      tipp: Object,
    },
    methods: {
      toggleEditMode() {
        this.editTipp = new Tipp(this.tipp);
        this.editMode = !this.editMode;
      },
      deleteTipp() {
        return confirm('Wosch würk lösche?') ? this.tipp.remove() : false;
      },
      saveTipp() {
        this.editMode = false;
        return this.editTipp.set();
      }
    },
  };
</script>

<style lang="scss" scoped>
  .tipp__text {
    border: 1px solid black;
    padding: 0.5em;
  }

  .tipp__created {
    font-style: italic;
    color: grey;
    font-size: 0.9em;
  }
</style>
{'fraction_non_alphanumeric': 0.18611810803246573, 'fraction_numerical': 0.003918275958578225, 'mean_word_length': 2.346441947565543, 'pattern_counts': {'":': 0, '<': 96, '<?xml version=': 0, '>': 96, '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': '750937', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1275, 'n_words': 220}