Skip to content

Commit

Permalink
Show team title & page in title
Browse files Browse the repository at this point in the history
(Closes #48)
  • Loading branch information
rafaelurben committed Nov 25, 2023
1 parent 2fa7046 commit bcef28b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
20 changes: 11 additions & 9 deletions teamized/app/src/components/pageloader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ import * as Cache from "../utils/cache.js";
This component is used to render the pages.
*/

export const PAGELIST = [
"home",
"club",
"calendars",
"team",
"teamlist",
"workingtime",
"todo",
]
export const PAGE_NAMES = {
"home": "Startseite",
"club": "Verein",
"calendars": "Kalender",
"team": "Team",
"teamlist": "Teams",
"workingtime": "Arbeitszeit",
"todo": "To-do-Listen",
}

export const PAGE_LIST = Object.keys(PAGE_NAMES);

export class PageLoader extends React.Component {
constructor(props) {
Expand Down
18 changes: 14 additions & 4 deletions teamized/app/src/utils/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@
* Module for navigation, routing and rendering
*/

import {PageLoader, PAGELIST} from "../components/pageloader.js";
import {PageLoader, PAGE_LIST, PAGE_NAMES} from "../components/pageloader.js";
import AppMenubar from "../components/menubar.js";
import AppSidebar from "../components/sidebar.js";
import * as Teams from './teams.js';
import {getCurrentTeamData} from "./cache.js";


function ensureExistingPage() {
if (!PAGELIST.includes(window.appdata.currentPage)) {
window.appdata.currentPage = PAGELIST[0];
if (!PAGE_LIST.includes(window.appdata.currentPage)) {
window.appdata.currentPage = PAGE_LIST[0];
}
}

function updatePageTitle() {
let teamName = getCurrentTeamData().team.name;
let pageName = PAGE_NAMES[window.appdata.currentPage];
document.title = `${pageName} - ${teamName} | Teamized App`;
}

/**
* Export changes from the cache to the URL
*
Expand Down Expand Up @@ -67,6 +74,8 @@ export function exportToURL(options) {
window.history.pushState(...args);
}
}

updatePageTitle();
}

/**
Expand Down Expand Up @@ -155,7 +164,7 @@ export function reRender() {
* @param {String} page
*/
export function selectPage(page) {
if (PAGELIST.includes(page)) {
if (PAGE_LIST.includes(page)) {
window.appdata.currentPage = page;
exportToURL();
render();
Expand All @@ -174,4 +183,5 @@ export function handleHistoryNavigation() {
ensureExistingPage();
Teams.ensureExistingTeam();
render();
updatePageTitle();
}

0 comments on commit bcef28b

Please sign in to comment.