diff --git a/src/components/input.js b/src/components/input.js index 25ee108..27177f4 100644 --- a/src/components/input.js +++ b/src/components/input.js @@ -10,9 +10,28 @@ class Input extends React.Component { render(){ switch (this.props.type) { case 'submit': - return + return + case 'range': + let range = this.props.range.split(':') + return default: - return + return } } } diff --git a/src/components/taskDetails.js b/src/components/taskDetails.js new file mode 100644 index 0000000..5f8ba2b --- /dev/null +++ b/src/components/taskDetails.js @@ -0,0 +1,42 @@ +import React from 'react' + +import Input from './input' + +class Details extends React.Component{ + render(){ + if(!this.props.display) return "" + + let ret = [] + let keys = Object.keys(this.props.task) + for(let i in Object.keys(this.props.task)){ + let key = keys[i] + console.log(key, this.props.task[key]) + ret.push({key}) + switch (key) { + case "lable": + ret.push() + break; + case "progress": + ret.push() + break; + default: + ret.push({this.props.task[key]}) + } + } + ret.push() + return
{ret}
+ } +} + +export default Details diff --git a/src/styles/App.css b/src/styles/App.css index 63a1a2e..a7dcd01 100644 --- a/src/styles/App.css +++ b/src/styles/App.css @@ -77,6 +77,11 @@ header h1 { .task-container.adding { padding: 0 0 10px 0; } +.task-container.focus{ + display: block; + height: auto; + padding: 10px; +} .task-progress{ position: relative; @@ -98,6 +103,21 @@ header h1 { height: 30px; } +.task-proppertys{ + position: relative; + width: 100%; +} + .task-add{ height: 30px; } + +.task-key{ + display: block; + padding-right: 10px; + font-weight: bold; +} + +.task-value{ + display: block; +} diff --git a/src/tasks.js b/src/tasks.js index 968035e..b1f7648 100644 --- a/src/tasks.js +++ b/src/tasks.js @@ -2,25 +2,13 @@ import React from 'react' import Database from './db' import Input from './components/input' +import Details from './components/taskDetails' import trashSvg from './res/trash.svg'; import addSvg from './res/add.svg' var db = new Database(); -function Details(props){ - if(!props.display) return "" - - let ret = [] - let keys = Object.keys(props.task) - for(let i in Object.keys(props.task)){ - let key = keys[i] - console.log(key, props.task[key]) - ret.push({key}) - ret.push({props.task[key]}) - } - return
{ret}
-} class Tasks extends React.Component { constructor(props){ @@ -39,41 +27,63 @@ class Tasks extends React.Component { this.setState(this.state); } + valueUpdate(key, value){ + console.log('valueUpdate: ', key, " => ", value) + this.form[key] = value + } + trash(id, e){ db.removeTask(id); + this.state.add = false; + this.state.details = -1; this.updateFromDB(); } add(e){ + this.form = {}; + this.state.add = true; this.state.details = -1; this.setState(this.state); } focus(id, e){ + this.form = {}; + this.state.add = false; this.state.details = id; this.setState(this.state); } + editTask(id, key, value){ + console.log(id, key, value) + this.state.tasks[id][key] = value; + db.updateTask(id, this.state.tasks[id]) + this.setState(this.state) + } + renderTask(task, id){ let classes = "task-container" if(this.state.details == id) classes += " focus" let progress = (task.progress*100) + "%" + if(this.state.details == id){ + return ( +
+
+ del +
+ ) + } return (
{task.lable}
del -
) } - valueUpdate(key, value){ - this.form[key] = value - } - addSubmit(){ db.addTask({ lable: this.form['lable'],