donal
2018-04-04 e3884467d3cf833d690ad22dd05b9133fcb4091f
src/components/TodoItem.vue
@@ -1,29 +1,37 @@
<template>
  <div>
    <md-list-item
      @click="markDone"
      >
        <!-- Material design checkbox not working as not importing @angular/material anywhere -->
        <!-- <md-checkbox :v-model="isActive"/> -->
        <input type="checkbox" v-model="isActive" />
    <div class="itemCardAndFlag">
        <span class="md-list-item-text" :class="{'strike-through': isActive}">{{ todoItem.title }}</span>
        <md-button>
          <img src="@/assets/insert-photo.svg">
        </md-button>
    <md-list-item
      @click="markDone"
      >
      <!-- TODO find a nice way of not calling markdone when clicking flag on card rather than calling "markDone" twice -->
      <!-- Material design checkbox not displaying, EDIT: Still can't figure out why it's not displaying -->
      <!-- <md-checkbox :v-model="isActive">x</md-checkbox> -->
      <!-- <input type="checkbox" v-model="todoItem.complete"/> -->
      <checkbox v-model="todoItem.completed"/>
      <span class="md-list-item-text" :class="{'strike-through': todoItem.completed}">{{ todoItem.title }}</span>
      <!-- find a nice way to utilise svg fill property without doing it inline -->
      <md-button 
        @click="markImportant"
        >
        <svg :class="{'red-flag': isImportant}" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
        <svg :class="{'red-flag': todoItem.important}" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" @click="markDone">
          <path d="M0 0h24v24H0z" fill="none"/>
          <path d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"/>
        </svg>
      </md-button>
    </md-list-item>
    </div>
  </div>
</template>
<script>
import Vue from "vue";
import { Checkbox, Radio } from "vue-checkbox-radio";
Vue.component("checkbox", Checkbox);
Vue.component("radio", Radio);
export default {
  name: "TodoItem",
  props: {
@@ -32,20 +40,27 @@
  },
  data() {
    return {
      isActive: false,
      isImportant: false
      // isActive: false,
      // isImportant: false
    };
  },
  methods: {
    markDone() {
      // set to greyed out / true false
      this.isActive = !this.isActive;
      console.info("INFO - ", this.todoItem, this.isActive);
      // Delete me below even if it works DEMO PURPOSE ONLY
      this.todoItem.completed = !this.todoItem.completed;
      // debugger;
      // this.$store.dispatch("setNewTodo", this.todoItem);
      // this.$store.dispatch("updateTodo", this.todoItem);
      // this.$store.dispatch("clearNewTodo");
      // Do we need to add a new action/mutation to change todo.x?
      // this.$store.dispatch("setNewTodo", this.newTodo)
      console.info("INFO - ", this.todoItem, this.todoItem.completed);
    },
    markImportant() {
      // set to greyed out / true false
      this.isImportant = !this.isImportant;
      console.info("INFO - ", this.todoItem, this.isImportant);
      this.todoItem.important = !this.todoItem.important;
      // this.$store.dispatch("updateTodo", this.todoItem);
      console.info("INFO - ", this.todoItem, this.todoItem.important);
    }
  }
};
@@ -63,6 +78,10 @@
  vertical-align: top;
}
.md-list-item-text {
  padding-left: 0.5em;
}
.strike-through {
  text-decoration: line-through;
  font-style: italic;