diff --git a/.babelrc b/.babelrc index 0d9e65c..40f3846 100644 --- a/.babelrc +++ b/.babelrc @@ -1,6 +1,7 @@ { "presets": [ - "env" + "env", + "stage-3" ], "comments": false } diff --git a/package-lock.json b/package-lock.json index 6abe157..6651bce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -630,6 +630,12 @@ "integrity": "sha1-ytnK0RkbWtY0vzCuCHI5HgZHvpU=", "dev": true }, + "babel-plugin-syntax-async-generators": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-async-generators/-/babel-plugin-syntax-async-generators-6.13.0.tgz", + "integrity": "sha1-a8lj67FuzLrmuStZbrfzXDQqi5o=", + "dev": true + }, "babel-plugin-syntax-exponentiation-operator": { "version": "6.13.0", "resolved": "https://registry.npmjs.org/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz", @@ -642,12 +648,29 @@ "integrity": "sha1-CvMqmm4Tyno/1QaeYtew9Y0NiUY=", "dev": true }, + "babel-plugin-syntax-object-rest-spread": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz", + "integrity": "sha1-/WU28rzhODb/o6VFjEkDpZe7O/U=", + "dev": true + }, "babel-plugin-syntax-trailing-function-commas": { "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz", "integrity": "sha1-ugNgk3+NBuQBgKQ/4NVhb/9TLPM=", "dev": true }, + "babel-plugin-transform-async-generator-functions": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-async-generator-functions/-/babel-plugin-transform-async-generator-functions-6.24.1.tgz", + "integrity": "sha1-8FiQAUX9PpkHpt3yjaWfIVJYpds=", + "dev": true, + "requires": { + "babel-helper-remap-async-to-generator": "6.24.1", + "babel-plugin-syntax-async-generators": "6.13.0", + "babel-runtime": "6.26.0" + } + }, "babel-plugin-transform-async-to-generator": { "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz", @@ -904,6 +927,16 @@ "babel-runtime": "6.26.0" } }, + "babel-plugin-transform-object-rest-spread": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.26.0.tgz", + "integrity": "sha1-DzZpLVD+9rfi1LOsFHgTepY7ewY=", + "dev": true, + "requires": { + "babel-plugin-syntax-object-rest-spread": "6.13.0", + "babel-runtime": "6.26.0" + } + }, "babel-plugin-transform-react-jsx": { "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-react-jsx/-/babel-plugin-transform-react-jsx-6.24.1.tgz", @@ -994,6 +1027,19 @@ } } }, + "babel-preset-stage-3": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-preset-stage-3/-/babel-preset-stage-3-6.24.1.tgz", + "integrity": "sha1-g2raCp56f6N8sTj7kyb4eTSkg5U=", + "dev": true, + "requires": { + "babel-plugin-syntax-trailing-function-commas": "6.22.0", + "babel-plugin-transform-async-generator-functions": "6.24.1", + "babel-plugin-transform-async-to-generator": "6.24.1", + "babel-plugin-transform-exponentiation-operator": "6.24.1", + "babel-plugin-transform-object-rest-spread": "6.26.0" + } + }, "babel-register": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-register/-/babel-register-6.26.0.tgz", @@ -16583,6 +16629,11 @@ } } }, + "vuex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/vuex/-/vuex-3.0.1.tgz", + "integrity": "sha512-wLoqz0B7DSZtgbWL1ShIBBCjv22GV5U+vcBFox658g6V0s4wZV9P4YjCNyoHSyIBpj1f29JBoNQIqD82cR4O3w==" + }, "whet.extend": { "version": "0.9.9", "resolved": "https://registry.npmjs.org/whet.extend/-/whet.extend-0.9.9.tgz", diff --git a/package.json b/package.json index 1b82000..f3fee1a 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "src": "^1.1.2", "sweetalert": "^2.1.0", "vue": "^2.1.10", - "vue-router": "^3.0.1" + "vue-router": "^3.0.1", + "vuex": "^3.0.1" }, "devDependencies": { "@vue/component-compiler-utils": "^1.0.0", @@ -32,6 +33,7 @@ "babel-core": "^6.22.1", "babel-eslint": "^7.1.1", "babel-preset-env": "^1.6.1", + "babel-preset-stage-3": "^6.24.1", "babel-register": "^6.22.0", "chai": "^3.5.0", "chalk": "^1.1.3", diff --git a/src/components/ListView/_ListView.vue b/src/components/ListView/_ListView.vue index 26b2574..da2ffe0 100644 --- a/src/components/ListView/_ListView.vue +++ b/src/components/ListView/_ListView.vue @@ -31,6 +31,7 @@ import sweetalert from 'sweetalert' import Todo from './Todo.vue' import CreateTodo from './TodoCreate.vue' + import { mapState } from 'vuex' // Todo: use absolute path src/ as root https://github.com/parcel-bundler/parcel/pull/850 import { TheHeader } from '../index.js' @@ -43,30 +44,35 @@ TheHeader, }, - data() { - return { - todos: [{ - title: 'Todo A', - project: 'Project A', - done: false, - }, { - title: 'Todo B', - project: 'Project B', - done: true, - }, { - title: 'Todo C', - project: 'Project C', - done: false, - }, { - title: 'Todo D', - project: 'Project D', - done: false, - }], - } - }, + /** Moved to store.js -> computed **/ + // data() { + // return { + // todos: [{ + // title: 'Test A', + // project: 'Project A', + // done: false, + // }, { + // title: 'Test B', + // project: 'Project B', + // done: true, + // }, { + // title: 'Test C', + // project: 'Project C', + // done: false, + // }, { + // title: 'Test D', + // project: 'Project D', + // done: false, + // }], + // } + // }, // Like methods, but are cached until dependency changes computed: { + ...mapState({ + todos: 'todos', + }), + counterDone () { return this.todos.filter(todo => todo.done).length },