load bin from user's list
This commit is contained in:
@@ -11,7 +11,8 @@ import {
|
|||||||
login_request_handler,
|
login_request_handler,
|
||||||
logout_request_handler,
|
logout_request_handler,
|
||||||
username_change_handler,
|
username_change_handler,
|
||||||
password_change_handler
|
password_change_handler,
|
||||||
|
choose_bin_handler
|
||||||
} from './handlers/App.js';
|
} from './handlers/App.js';
|
||||||
|
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ function App(vnode_init){
|
|||||||
view: function(vnode){
|
view: function(vnode){
|
||||||
const s = vnode.attrs.state;
|
const s = vnode.attrs.state;
|
||||||
const o = function(handler){ return handler.bind(null, s, dispatch); }
|
const o = function(handler){ return handler.bind(null, s, dispatch); }
|
||||||
|
const o1 = function(handler, p1){ return handler.bind(null, s, dispatch, p1); }
|
||||||
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'}, [
|
||||||
@@ -59,7 +61,7 @@ function App(vnode_init){
|
|||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
m('ul.bin-list', {key:'bin-list'}, s.login.bins.map(b=>
|
m('ul.bin-list', {key:'bin-list'}, s.login.bins.map(b=>
|
||||||
m('li.bin', b.name)
|
m('li.bin', {key:b.id, onclick:o1(choose_bin_handler, b.id)}, b.name)
|
||||||
))
|
))
|
||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
|
|||||||
@@ -69,6 +69,18 @@ const bin_name_commit_handler = function(state, dispatch){
|
|||||||
api.post('/bin-rename', {bin_id:state.bin.id, name:state.temp_bin_name});
|
api.post('/bin-rename', {bin_id:state.bin.id, name:state.temp_bin_name});
|
||||||
dispatch('commit-bin-name');
|
dispatch('commit-bin-name');
|
||||||
};
|
};
|
||||||
|
const choose_bin_handler = function(state, dispatch, bin_id){
|
||||||
|
window.history.pushState(null,'','#'+bin_id);
|
||||||
|
dispatch('bin-requested', bin_id);
|
||||||
|
api.post('/load-bin', {bin_id})
|
||||||
|
.then(res=>{
|
||||||
|
dispatch('bin-loaded', res.bin);
|
||||||
|
});
|
||||||
|
api.post('/load-notes', {bin_id})
|
||||||
|
.then(res=>{
|
||||||
|
dispatch('notes-loaded', res.notes);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export {new_note_handler,
|
export {new_note_handler,
|
||||||
search_term_change_handler,
|
search_term_change_handler,
|
||||||
@@ -81,5 +93,6 @@ export {new_note_handler,
|
|||||||
logout_request_handler,
|
logout_request_handler,
|
||||||
bin_name_editing_toggle_button_handler,
|
bin_name_editing_toggle_button_handler,
|
||||||
bin_name_change_handler,
|
bin_name_change_handler,
|
||||||
bin_name_commit_handler
|
bin_name_commit_handler,
|
||||||
|
choose_bin_handler
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user