88 lines
2.4 KiB
JavaScript
88 lines
2.4 KiB
JavaScript
import React from 'react';
|
|
import { DB } from '../static/storage';
|
|
|
|
|
|
const moment = require('moment');
|
|
|
|
export class Notes extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
var x = new Date();
|
|
this.state = {
|
|
notes:[],
|
|
date: moment(x).format("YYYY-MM-DD"),
|
|
time:moment(x).format("HH:MM"),
|
|
title:"-",
|
|
text:"---",
|
|
priority:"low"
|
|
}
|
|
this.chDate = this.chDate.bind(this);
|
|
this.chTime = this.chTime.bind(this);
|
|
this.chTitle = this.chTitle.bind(this);
|
|
this.chText = this.chText.bind(this);
|
|
this.chPriority = this.chPriority.bind(this);
|
|
this.save = this.save.bind(this);
|
|
this.delete = this.delete.bind(this);
|
|
}
|
|
componentDidMount(){
|
|
var sql = "SELECT * FROM notes;"
|
|
var stmt = DB.cdb.exec(sql);
|
|
/*var res = stmt.getAsObject(
|
|
{}
|
|
)
|
|
var dates = [];
|
|
dates.push(res.date);
|
|
while (stmt.step()) dates.push(stmt.get()[0]);
|
|
this.setState({dates:dates});*/
|
|
}
|
|
chDate(e){
|
|
var d = e.target.value;
|
|
this.setState({date:d});
|
|
}
|
|
chTime(e){
|
|
var t = e.target.value;
|
|
this.setState({time:t})
|
|
}
|
|
chTitle(e){
|
|
var t = e.target.value;
|
|
this.setState({title:t});
|
|
}
|
|
chText(e){
|
|
var t = e.target.value;
|
|
this.setState({text:t});
|
|
}
|
|
chPriority(e){
|
|
var p = e.target.value;
|
|
this.setState({priority:p})
|
|
}
|
|
delete(e){
|
|
|
|
}
|
|
save(e){
|
|
console.log("SAVE");
|
|
console.log(this.state.date);
|
|
var sql = `INSERT INTO notes ()`
|
|
}
|
|
render() {
|
|
return (
|
|
<div id="notes-frame">
|
|
<div id="notes-list">
|
|
|
|
</div>
|
|
<div id="notes-edit">
|
|
<button onClick={this.save}>Speichern</button><button onClick={this.delete}>Löschen</button>
|
|
<hr/>
|
|
Datum:<input type="date" value={this.state.date} onChange={this.chDate}/><br/>
|
|
Zeit:<input type="time" value={this.state.time} onChange={this.chTime}/><br/>
|
|
Titel:<input type="text" value={this.state.title} onChange={this.chTitle}/><br/>
|
|
Dringlichkeit:<select value={this.state.priority} onChange={this.chPriority}>
|
|
<option value="heigh">Hoch</option>
|
|
<option value="normal">Normal</option>
|
|
<option value="low">Niedrig</option>
|
|
</select><br/>
|
|
<textarea value={this.state.text} onChange={this.chText}></textarea>
|
|
</div>
|
|
</div>);
|
|
}
|
|
}
|