Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added possibility to hide navigation after selection #350

Merged
merged 5 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ E.g., if it was used in a menu and the menu is red, the circle would be red.
## Changelog
### **WORK IN PROGRESS**
* (foxriver76) do not show empty icon category if jquery style selected for jquery button widgets
* (foxriver76) added possibility to hide navigation after selection

### 2.9.25 (2024-01-29)
* (foxriver76) fixed resizing issue for relative widgets
Expand Down
20 changes: 13 additions & 7 deletions src/src/Attributes/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,9 @@ const View = props => {
{
type: 'checkbox', name: 'Hide menu', field: 'navigationHideMenu', notStyle: true, hidden: '!data.navigation || data.navigationOrientation === "horizontal"', applyToAll: true,
},
{
type: 'checkbox', name: 'Hide after selection', field: 'navigationHideOnSelection', notStyle: true, hidden: '!data.navigation || data.navigationOrientation === "horizontal"', applyToAll: true,
},
{
type: 'text', name: 'Menu header text', field: 'navigationHeaderText', notStyle: true, hidden: '!data.navigation || data.navigationOrientation === "horizontal" || !data.navigationBar', applyToAll: true,
},
Expand Down Expand Up @@ -792,18 +795,20 @@ const View = props => {
selectedViewValue = selectedViewValue || '';
}
viewList.forEach(_view => {
let viewValue = store.getState().visProject[_view].settings[field.field];
const view = store.getState().visProject[_view];

let viewValue = view.settings[field.field];
if (field.type === 'boolean') {
viewValue = !!viewValue;
} else {
viewValue = viewValue || '';
}

if (store.getState().visProject[_view].settings.navigation &&
if (view.settings.navigation &&
viewValue !== selectedViewValue &&
!viewsToChange.includes(store.getState().visProject[_view].name || _view)
!viewsToChange.includes(view.name || _view)
) {
viewsToChange.push(store.getState().visProject[_view].name || _view);
viewsToChange.push(view.name || _view);
}
});
}
Expand All @@ -817,14 +822,15 @@ const View = props => {
selectedViewValue = selectedViewValue || '';
}
viewList.forEach(_view => {
let viewValue = store.getState().visProject[_view].settings[showAllViewDialog.field];
const projView = store.getState().visProject[_view];
let viewValue = projView.settings[showAllViewDialog.field];
if (showAllViewDialog.field.type === 'boolean') {
viewValue = !!viewValue;
} else {
viewValue = viewValue || '';
}
if (store.getState().visProject[_view].settings.navigation && viewValue !== selectedViewValue) {
viewsToChange.push(store.getState().visProject[_view].name || _view);
if (projView.settings.navigation && viewValue !== selectedViewValue) {
viewsToChange.push(projView.name || _view);
}
});
}
Expand Down
2 changes: 2 additions & 0 deletions src/src/Store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export const recalculateFields = createAction<boolean>('attributes/recalculate')

const initialState = {
visProject: {} as Project,
/** If fields need to be recalculated on next render */
recalculateFields: false,
/** Logged in user */
activeUser: '',
};

Expand Down
19 changes: 16 additions & 3 deletions src/src/Vis/visNavigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,12 @@ class VisNavigation extends React.Component {
key={index}
disablePadding
className={Utils.clsx(this.props.classes.menuItem, this.props.activeView === item.view && this.props.classes.selectedMenu)}
onClick={() => this.props.context.changeView(item.view)}
onClick={async () => {
if (settings.navigationHideOnSelection) {
await this.hideNavigationMenu();
}
await this.props.context.changeView(item.view);
}}
>
<ListItemButton>
<ListItemIcon>
Expand Down Expand Up @@ -378,10 +383,19 @@ class VisNavigation extends React.Component {
</div>;
}

/**
* Hide the navigation menu
*/
async hideNavigationMenu() {
window.localStorage.setItem('vis.navOpened', 'hidden');
await this.props.setMenuWidth('hidden');
}

render() {
if (!this.props.context.views || !this.props.context.views[this.props.view]) {
return null;
}

const settings = this.props.context.views[this.props.view].settings;

if (settings.navigation &&
Expand Down Expand Up @@ -428,8 +442,7 @@ class VisNavigation extends React.Component {
this.props.setMenuWidth('narrow');
} else if (this.props.menuWidth === 'narrow') {
if (!settings.navigationNoHide) {
window.localStorage.setItem('vis.navOpened', 'hidden');
this.props.setMenuWidth('hidden');
this.hideNavigationMenu();
} else {
window.localStorage.setItem('vis.navOpened', 'full');
this.props.setMenuWidth('full');
Expand Down
8 changes: 7 additions & 1 deletion src/src/Vis/visView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1227,8 +1227,14 @@ class VisView extends React.Component {
setMenuWidth={menuWidth => {
window.localStorage.setItem('vis.menuWidth', menuWidth);
this.setState({ menuWidth });

return new Promise(resolve => {
// re-calculate the width of the view
setTimeout(() => this.updateViewWidth(), 300);
setTimeout(() => {
this.updateViewWidth();
resolve();
}, 400);
});
}}
>
{content}
Expand Down
1 change: 1 addition & 0 deletions src/src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"HD - Portrait": "HD - Hochformat",
"Height": "Höhe",
"Hide": "Ausblenden",
"Hide after selection": "Nach Auswahl ausblenden",
"Hide attributes": "Attribute ausblenden",
"Hide menu": "Menü ausblenden",
"Hide palette": "Palette ausblenden",
Expand Down
1 change: 1 addition & 0 deletions src/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"HD - Portrait": "HD - Portrait",
"Height": "Height",
"Hide": "Hide",
"Hide after selection": "Hide after selection",
"Hide attributes": "Hide attributes",
"Hide menu": "Hide menu",
"Hide palette": "Hide palette",
Expand Down
1 change: 1 addition & 0 deletions src/src/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"HD - Portrait": "HD - Retrato",
"Height": "Altura",
"Hide": "Ocultar",
"Hide after selection": "Ocultar después de la selección",
"Hide attributes": "Ocultar atributos",
"Hide menu": "Ocultar el menú",
"Hide palette": "Ocultar paleta",
Expand Down
1 change: 1 addition & 0 deletions src/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"HD - Portrait": "HD-Portrait",
"Height": "Hauteur",
"Hide": "Cacher",
"Hide after selection": "Masquer après la sélection",
"Hide attributes": "Masquer les attributs",
"Hide menu": "Masquer le menu",
"Hide palette": "Masquer la palette",
Expand Down
1 change: 1 addition & 0 deletions src/src/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"HD - Portrait": "HD - Ritratto",
"Height": "Altezza",
"Hide": "Nascondere",
"Hide after selection": "Nascondi dopo la selezione",
"Hide attributes": "Nascondi attributi",
"Hide menu": "Nascondi menù",
"Hide palette": "Nascondi tavolozza",
Expand Down
1 change: 1 addition & 0 deletions src/src/i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"HD - Portrait": "HD - Portret",
"Height": "Hoogte",
"Hide": "Verbergen",
"Hide after selection": "Verbergen na selectie",
"Hide attributes": "Kenmerken verbergen",
"Hide menu": "Menu verbergen",
"Hide palette": "Palet verbergen",
Expand Down
1 change: 1 addition & 0 deletions src/src/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"HD - Portrait": "HD - Portret",
"Height": "Wysokość",
"Hide": "Ukrywać",
"Hide after selection": "Ukryj po zaznaczeniu",
"Hide attributes": "Ukryj atrybuty",
"Hide menu": "Ukryj menu",
"Hide palette": "Ukryj paletę",
Expand Down
1 change: 1 addition & 0 deletions src/src/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"HD - Portrait": "HD - Retrato",
"Height": "Altura",
"Hide": "Esconder",
"Hide after selection": "Ocultar após seleção",
"Hide attributes": "Ocultar atributos",
"Hide menu": "Ocultar menu",
"Hide palette": "Ocultar paleta",
Expand Down
1 change: 1 addition & 0 deletions src/src/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"HD - Portrait": "HD – Портрет",
"Height": "Высота",
"Hide": "Скрывать",
"Hide after selection": "Скрыть после выбора",
"Hide attributes": "Скрыть свойства",
"Hide menu": "Скрыть меню",
"Hide palette": "Скрыть палитру",
Expand Down
1 change: 1 addition & 0 deletions src/src/i18n/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"HD - Portrait": "HD - портрет",
"Height": "Висота",
"Hide": "Сховати",
"Hide after selection": "Сховати після виділення",
"Hide attributes": "Приховати атрибути",
"Hide menu": "Приховати меню",
"Hide palette": "Сховати палітру",
Expand Down
1 change: 1 addition & 0 deletions src/src/i18n/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"HD - Portrait": "高清 - 肖像",
"Height": "高度",
"Hide": "隐藏",
"Hide after selection": "选择后隐藏",
"Hide attributes": "隐藏属性",
"Hide menu": "隐藏菜单",
"Hide palette": "隐藏调色板",
Expand Down
Loading