feat: stages module, mobility frontend, theme toggle, employeeOnly access control
- Add stages module with full CRUD API and admin overview island - Add mobility overview island (Liste, Kanban, Detail CRUD views) - Add contract PDF upload/download endpoints for mobilites - Add light/dark theme toggle in header - Add employeeOnly flag to hide entire modules from students (admin, students, stages) - Add read-only GET endpoints for modules/ues/ue-modules in notes module - Add [slug].tsx catch-all routes for direct URL navigation - Replace old mobility table with mobilites + stages schema (migration 0004) - Allow students to create mobilites and upload contracts - Redirect authenticated users from / to /apps catalog
This commit is contained in:
@@ -20,6 +20,7 @@ export interface AppProperties {
|
||||
pages: Record<string, string>;
|
||||
adminOnly: string[];
|
||||
studentOnly?: string[];
|
||||
employeeOnly?: boolean;
|
||||
hint: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import { FreshContext } from "$fresh/server.ts";
|
||||
import { Route, State } from "$root/defaults/interfaces.ts";
|
||||
import { ComponentChildren } from "preact";
|
||||
|
||||
/**
|
||||
* Generates a catch-all [slug] route that dynamically loads partials.
|
||||
* This enables direct URL navigation to sub-pages (e.g. /admin/modules).
|
||||
* @param basePath The base path of the module, should be `import.meta.dirname!`.
|
||||
* @returns A route handler that loads the partial matching the slug.
|
||||
*/
|
||||
export default function makeSlug(basePath: string): Route {
|
||||
return async function SlugRoute(
|
||||
request: Request,
|
||||
context: FreshContext<State>,
|
||||
): Promise<ComponentChildren | Response> {
|
||||
const slug = context.params.slug;
|
||||
|
||||
// Try partials/<slug>.tsx, then partials/(admin)/<slug>.tsx
|
||||
let page: Route | undefined;
|
||||
try {
|
||||
page = (await import(`${basePath}/partials/${slug}.tsx`)).Page;
|
||||
} catch {
|
||||
try {
|
||||
page = (await import(`${basePath}/partials/(admin)/${slug}.tsx`)).Page;
|
||||
} catch {
|
||||
// No partial found for this slug
|
||||
}
|
||||
}
|
||||
|
||||
if (!page) {
|
||||
return context.renderNotFound();
|
||||
}
|
||||
|
||||
return page(request, context);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user