donal
2018-04-04 9e628c998951ee020076a040e9cc943f0da78962
src/components/TodoItem.vue
@@ -3,21 +3,21 @@
    <div class="itemCardAndFlag">
    <md-list-item
      @click="markDone"
      @click="markCompleted"
      >
      <!-- 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.complete"/>
      <checkbox v-model="todoItem.completed"/>
      <span class="md-list-item-text" :class="{'strike-through': todoItem.complete}">{{ todoItem.title }}</span>
      <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': todoItem.important}" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" @click="markDone">
        <svg :class="{'red-flag': todoItem.important}" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" @click="markCompleted">
          <path d="M0 0h24v24H0z" fill="none"/>
          <path d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"/>
        </svg>
@@ -45,22 +45,14 @@
    };
  },
  methods: {
    markDone() {
      // Delete me below even if it works DEMO PURPOSE ONLY
      this.todoItem.complete = !this.todoItem.complete;
      debugger;
      // this.$store.dispatch("setNewTodo", this.todoItem);
      this.$store.dispatch("updateTodo", that.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.complete);
    markCompleted() {
      this.$store.dispatch("markTodoCompleted", this.todoItem._id);
      console.info("INFO - Mark todo as completed ", this.todoItem.completed);
    },
    markImportant() {
      this.todoItem.important = !this.todoItem.important;
      this.$store.dispatch("updateTodo", this.todoItem);
      console.info("INFO - ", this.todoItem, this.todoItem.important);
      console.info("INFO - Mark todo as important ", this.todoItem.important);
      // TODO - FILL THIS OUT IN THE LAB EXERCISE
    }
  }
};