UI actions; Context menu
This commit is contained in:
19
src/js/services/ui/actions.js
Executable file
19
src/js/services/ui/actions.js
Executable file
@ -0,0 +1,19 @@
|
||||
|
||||
|
||||
export function showContextMenu( e, context = false, data ){
|
||||
return {
|
||||
type: 'UI_SHOW_CONTEXT_MENU',
|
||||
position_x: e.clientX,
|
||||
position_y: e.clientY,
|
||||
context: context,
|
||||
data: data
|
||||
}
|
||||
}
|
||||
|
||||
export function hideContextMenu(){
|
||||
return {
|
||||
type: 'UI_HIDE_CONTEXT_MENU'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
25
src/js/services/ui/reducer.js
Executable file
25
src/js/services/ui/reducer.js
Executable file
@ -0,0 +1,25 @@
|
||||
|
||||
export default function reducer(ui = {}, action){
|
||||
switch (action.type) {
|
||||
|
||||
case 'UI_SHOW_CONTEXT_MENU':
|
||||
return Object.assign({}, ui, {
|
||||
context_menu: {
|
||||
show: true,
|
||||
position_x: action.position_x,
|
||||
position_y: action.position_y,
|
||||
context: action.context,
|
||||
data: action.data
|
||||
}
|
||||
});
|
||||
|
||||
case 'UI_HIDE_CONTEXT_MENU':
|
||||
return Object.assign({}, ui, { context_menu: { show: false } });
|
||||
|
||||
default:
|
||||
return ui
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user