You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pastebin/Note.js

30 lines
1.1 KiB
JavaScript

import {edit_handler, cancel_handler, text_change_handler, save_handler} from './handlers/Note.js';
function Note(vnode_init){
const {dispatch} = vnode_init.attrs;
return {
view: function(vnode){
const {note_state} = vnode.attrs;
const {is_editing, note} = note_state;
if(is_editing){
return m('.note', [
m('textarea', {key: 'textarea', onchange: text_change_handler.bind(null, note_state, dispatch) }, note.text),
m('.buttons', {key: 'editing-buttons'}, [
m('button', {key: 'cancel-button', onclick: cancel_handler.bind(null, note_state, dispatch) }, 'Cancel'),
m('button', {key: 'save-button', onclick: save_handler.bind(null, note_state, dispatch) }, 'Save')
])
]);
}
else{
return m('.note', [
m('.text', {key: 'text'}, note.text),
m('.buttons', {key: 'viewing-buttons'}, [
m('button', {key: 'edit-button', onclick: edit_handler.bind(null, note_state, dispatch) }, 'Edit')
])
]);
}
}
};
}
export default Note;