donal
2018-04-16 e351bf9cb34df51e911e9aa46450ad6da8561f77
SOLUTION to exercise 3
3 files modified
20 ■■■■■ changed files
src/components/TodoItem.vue 14 ●●●●● patch | view | raw | blame | history
src/store/actions.js 5 ●●●● patch | view | raw | blame | history
tests/unit/vue-components/TodoItem.spec.js 1 ●●●● patch | view | raw | blame | history
src/components/TodoItem.vue
@@ -6,12 +6,10 @@
      >
      <checkbox v-model="todoItem.completed" class="checkbox-completed"/> 
      <span class="md-list-item-text" :class="{'strike-through': todoItem.completed}">{{ todoItem.title }}</span>
    </md-list-item>
      <!-- TODO - Uncomment this as part of exercise3 -->
      <md-button class="important-flag"
        @click="markImportant()"
        >
        <span class="md-list-item-text" :class="{'strike-through': todoItem.completed}">{{ todoItem.title }}</span>
      </md-list-item>
      <!-- TODO - SVG for use in Lab3 -->
      <md-button class="important-flag" @click="markImportant()">
        <svg :class="{'red-flag': todoItem.important}"  height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" ><path d="M0 0h24v24H0z" fill="none"/><path d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"/></svg>
      </md-button>
    </div>
@@ -35,9 +33,9 @@
      console.info("INFO - Mark todo as completed ", this.todoItem.completed);
    },
    markImportant() {
      this.$store.dispatch("updateTodo", {id :this.todoItem._id, important: true} );
      console.info("INFO - Mark todo as important ", this.todoItem.important);
      // TODO - FILL THIS OUT IN THE LAB EXERCISE
      this.$store.dispatch("updateTodo", {id: this.todoItem._id, important: true} );
      console.info("INFO - Mark todo as important ", this.todoItem.important);
    }
  }
};
src/store/actions.js
@@ -98,14 +98,11 @@
  updateTodo({ commit, state }, { id, important }) {
    let i = state.todos.findIndex(todo => todo._id === id);
    if (important) {
      // TODO - add commit imporant here!
      commit("MARK_TODO_IMPORTANT", i);
    } else {
      commit("MARK_TODO_COMPLETED", i);
    }
    console.info(
      "TESTSY MC TESTFACES",
      config.todoEndpoint + "/" + state.todos[i]._id
    );
    // Fire and forget style backend update ;)
    return axios
      .put(config.todoEndpoint + "/" + state.todos[i]._id, state.todos[i])
tests/unit/vue-components/TodoItem.spec.js
@@ -72,7 +72,6 @@
    // TODO - test goes here!
    expect(wrapper.find(".red-flag").exists()).toBe(false);
  });
  it("call makImportant when clicked", () => {
    const wrapper = mount(TodoItem, {
      methods,