feat(web): add ability to not be able to close menu

This commit is contained in:
Luke
2022-09-08 10:26:35 +02:00
parent adf0994b3f
commit 336a16baed
2 changed files with 3 additions and 0 deletions

View File

@@ -43,6 +43,7 @@ function lib.showMenu(id)
action = 'setMenu', action = 'setMenu',
data = { data = {
position = menu.position, position = menu.position,
canClose = menu.canClose,
title = menu.title, title = menu.title,
items = menu.options items = menu.options
} }

View File

@@ -21,6 +21,7 @@ export interface MenuItem {
export interface MenuSettings { export interface MenuSettings {
position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
title: string; title: string;
canClose?: boolean;
items: Array<MenuItem>; items: Array<MenuItem>;
} }
@@ -36,6 +37,7 @@ const ListMenu: React.FC = () => {
const listRefs = useRef<Array<HTMLDivElement | null>>([]); const listRefs = useRef<Array<HTMLDivElement | null>>([]);
const closeMenu = (ignoreFetch?: boolean) => { const closeMenu = (ignoreFetch?: boolean) => {
if (menu.canClose === false) return;
setVisible(false); setVisible(false);
if (!ignoreFetch) fetchNui('closeMenu'); if (!ignoreFetch) fetchNui('closeMenu');
}; };