added 'modified' field to notes

readme
brian 4 years ago
parent b4b277adbf
commit 70293c9b27

@ -1,26 +1,41 @@
import Note from './Note.js'; import Note from './Note.js';
function App(){ function App(){
return {
view: function(vnode){
// const {bin, notes} = vnode.attrs;
const bin = {id: 'egf35'}; const bin = {id: 'egf35'};
const notes = [ const notes = [
{id: 'aaa', text: 'Note one'}, {id: 'aaa', text: 'Note one', modified: 1},
{id: 'bbb', text: 'Note two'}, {id: 'bbb', text: 'Note two', modified: 1},
{id: 'ccc', text: 'Note three'}, {id: 'ccc', text: 'Note three', modified: 1},
{id: 'ddd', text: 'Note four'}, {id: 'ddd', text: 'Note four', modified: 1},
{id: 'eee', text: 'Note five'}, {id: 'eee', text: 'Note five', modified: 1},
{id: 'fff', text: 'Note six'}, {id: 'fff', text: 'Note six', modified: 1},
{id: 'ggg', text: 'Note seven'}, {id: 'ggg', text: 'Note seven', modified: 1},
{id: 'hhh', text: 'Note eight'} {id: 'hhh', text: 'Note eight', modified: 1}
]; ];
let search_term = '';
let count = 9;
const new_note_handler = function(){
count++;
// TODO: make immutable-style:
notes.push({id: ''+count, text: '', modified: Date.now()});
};
const search_term_change_handler = function(e){
if(e.code === 'Enter'){
}
else{
search_term = e.target.value;
}
};
const sorting_change_handler = function(){
};
return {
view: function(vnode){
return m('.app', {key: 'app'}, [ return m('.app', {key: 'app'}, [
m('.top', {key: 'top'}, [ m('.top', {key: 'top'}, [
m('.top-left', {key: 'top-left'}, [ m('.top-left', {key: 'top-left'}, [
m('button', {key: 'button'}, 'New Note...'), m('button', {key: 'button', onclick: new_note_handler}, 'New Note...'),
m('input.search', {key: 'search', value: ''}), m('input.search', {key: 'search', value: search_term, onkeyup: search_term_change_handler}),
m('select.sorting', {key: 'sorting'}, [ m('select.sorting', {key: 'sorting', onchange: sorting_change_handler}, [
m('option', {key: 'new-old'}, 'Newest -> Oldest'), m('option', {key: 'new-old'}, 'Newest -> Oldest'),
m('option', {key: 'old-new'}, 'Oldest -> Newest') m('option', {key: 'old-new'}, 'Oldest -> Newest')
]) ])

Loading…
Cancel
Save