Day 68 of 100 Days Of Code

sunday

Day 68: September 30, Sunday

Today ‘s Progress: Gave up on Docker I have to have windows 10 pro and I do not have pro. So fell back 10 yards and punted. So on with learning by tutorials I am working through INTERMEDIATE: Learn Vue 2: Step By Stepand VUE.JS - SIMPLE TODO APP - PART 1.

Thoughts: Following these I am tiring to add features and update my first todo list hereVueApp after going though the videos I came up with thisVueJS_ToDoList

Resources used:

<div id="todoApp">
  <h2>  </h2>
  <p>
  New Tasks can be added below:
  </p>
  <form name="todo-form" method="post" action="" v-on:submit.prevent="addTask">
    <input name="add-todo" type="text" v-model="addTodoInput" v-bind:class="{error: hasError}"/>

    <button type="submit">Add</button>
  </form>

  <div class="todo-lists" v-if="lists.length"><br />
    <h3>My Todo Tasks:</h3>
    <ul>
      <li v-for="list in lists" :key="list.id">
        <input type="checkbox" v-on:change="completeTask(list)" v-bind:checked="list.isComplete"/>
        <del v-if="list.isComplete">
        
        </del>
         <span v-else class="title" contenteditable="true" v-on:keydown.enter="updateTask($event, list)" v-on:blur="updateTask($event, list)" v-bind:class="{completed: list.isComplete}"></span>
      </li>
    </ul>
  </div>
  <script>
  var todoApp = new Vue({
  el: '#todoApp',
  data: {
    message: 'Welcome to Todo App',
    addTodoInput: '',
    lists: [],
    hasError: false
  },
  methods:{
    addTask(){

      if(!this.addTodoInput){
        this.hasError = true;
        return;
      }

      this.hasError = false;

      this.lists.push({
        id:this.lists.length+1,
        title: this.addTodoInput,
        isComplete: false
      });

      this.addTodoInput = '';
    },

    updateTask(e, list){
      e.preventDefault();
      list.title = e.target.innerText;
      e.target.blur();
    },

    completeTask(list){
      list.isComplete = !list.isComplete;
    }

  }
});
//generate dummy data for demo purpose
todoApp.lists = [{
      id: 1,
      title: "Hello Vue.JS",
      isComplete: false
    },
    {
      id: 2,
      title: "Learn JavaScript",
      isComplete: false
    },
    {
      id: 3,
      title: "Learn Vue",
      isComplete: false
    },
    {
      id: 4,
      title: "Play around in JSFiddle",
      isComplete: true
    }];
  </script>

Link(s) to work

  1. Working on my TODO application jsfiddle.

Code is at https://jsfiddle.net/johnny2136/g72evm4L/.

Written on September 30, 2018