dblclick for new note; immediately-cancellable notes

This commit is contained in:
brian
2021-04-12 08:36:22 -04:00
parent 6ec471c82a
commit 3e64bca676
5 changed files with 27 additions and 7 deletions
+8 -1
View File
@@ -1,6 +1,12 @@
import nanoid from '../nanoid.min.js';
import api from '../api.js';
const preventDblClickSelection = function(e){
// as per [https://stackoverflow.com/a/43321596]
if(e.detail>1){
e.preventDefault();
}
}
const load_notes = function(state, dispatch){
api.post('/load-notes', {bin_id: state.bin_id})
.then(res=>{
@@ -88,7 +94,8 @@ const choose_bin_handler = function(state, dispatch, bin_id){
});
};
export {new_note_handler,
export {preventDblClickSelection,
new_note_handler,
new_note_by_dblclick_handler,
search_term_change_handler,
sorting_change_handler,
+8 -2
View File
@@ -3,8 +3,14 @@ import api from '../api.js';
const edit_handler = function(note_state, dispatch){
dispatch('update-note-editing', {id: note_state.note_id, is_editing: true});
};
const cancel_handler = function(note_state, dispatch){
dispatch('update-note-editing', {id: note_state.note_id, is_editing: false});
const cancel_handler = function(state, note_state, dispatch){
// TODO: this `if` may cause glitches; keep in mind
if(note_state.is_new===true){
dispatch('immediately-cancel-note', note_state.note_id);
}
else{
dispatch('update-note-editing', {id: note_state.note_id, is_editing: false});
}
};
const text_change_handler = function(note_state, dispatch, e){
note_state.temp_text = e.target.value;